Initial boiler plate project

This commit is contained in:
2024-09-24 03:52:46 +00:00
parent 6120b2d6c3
commit 154b93e267
10034 changed files with 2079352 additions and 2 deletions

View File

@ -0,0 +1,5 @@
import type { PathnameNormalizer } from './pathname-normalizer';
import { SuffixPathnameNormalizer } from './suffix';
export declare class ActionPathnameNormalizer extends SuffixPathnameNormalizer implements PathnameNormalizer {
constructor();
}

View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "ActionPathnameNormalizer", {
enumerable: true,
get: function() {
return ActionPathnameNormalizer;
}
});
const _constants = require("../../../../lib/constants");
const _suffix = require("./suffix");
class ActionPathnameNormalizer extends _suffix.SuffixPathnameNormalizer {
constructor(){
super(_constants.ACTION_SUFFIX);
}
}
//# sourceMappingURL=action.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/normalizers/request/action.ts"],"names":["ActionPathnameNormalizer","SuffixPathnameNormalizer","constructor","ACTION_SUFFIX"],"mappings":";;;;+BAKaA;;;eAAAA;;;2BAHiB;wBACW;AAElC,MAAMA,iCACHC,gCAAwB;IAGhCC,aAAc;QACZ,KAAK,CAACC,wBAAa;IACrB;AACF"}

View File

@ -0,0 +1,5 @@
import type { PathnameNormalizer } from './pathname-normalizer';
import { PrefixPathnameNormalizer } from './prefix';
export declare class BasePathPathnameNormalizer extends PrefixPathnameNormalizer implements PathnameNormalizer {
constructor(basePath: string);
}

View File

@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "BasePathPathnameNormalizer", {
enumerable: true,
get: function() {
return BasePathPathnameNormalizer;
}
});
const _prefix = require("./prefix");
class BasePathPathnameNormalizer extends _prefix.PrefixPathnameNormalizer {
constructor(basePath){
if (!basePath || basePath === "/") {
throw new Error('Invariant: basePath must be set and cannot be "/"');
}
super(basePath);
}
}
//# sourceMappingURL=base-path.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/normalizers/request/base-path.ts"],"names":["BasePathPathnameNormalizer","PrefixPathnameNormalizer","constructor","basePath","Error"],"mappings":";;;;+BAIaA;;;eAAAA;;;wBAF4B;AAElC,MAAMA,mCACHC,gCAAwB;IAGhCC,YAAYC,QAAgB,CAAE;QAC5B,IAAI,CAACA,YAAYA,aAAa,KAAK;YACjC,MAAM,IAAIC,MAAM;QAClB;QAEA,KAAK,CAACD;IACR;AACF"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,8 @@
import type { PathnameNormalizer } from './pathname-normalizer';
export declare class NextDataPathnameNormalizer implements PathnameNormalizer {
private readonly prefix;
private readonly suffix;
constructor(buildID: string);
match(pathname: string): boolean;
normalize(pathname: string, matched?: boolean): string;
}

View File

@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "NextDataPathnameNormalizer", {
enumerable: true,
get: function() {
return NextDataPathnameNormalizer;
}
});
const _denormalizepagepath = require("../../../../shared/lib/page-path/denormalize-page-path");
const _prefix = require("./prefix");
const _suffix = require("./suffix");
class NextDataPathnameNormalizer {
constructor(buildID){
this.suffix = new _suffix.SuffixPathnameNormalizer(".json");
if (!buildID) {
throw new Error("Invariant: buildID is required");
}
this.prefix = new _prefix.PrefixPathnameNormalizer(`/_next/data/${buildID}`);
}
match(pathname) {
return this.prefix.match(pathname) && this.suffix.match(pathname);
}
normalize(pathname, matched) {
// If we're not matched and we don't match, we don't need to normalize.
if (!matched && !this.match(pathname)) return pathname;
pathname = this.prefix.normalize(pathname, true);
pathname = this.suffix.normalize(pathname, true);
return (0, _denormalizepagepath.denormalizePagePath)(pathname);
}
}
//# sourceMappingURL=next-data.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/normalizers/request/next-data.ts"],"names":["NextDataPathnameNormalizer","constructor","buildID","suffix","SuffixPathnameNormalizer","Error","prefix","PrefixPathnameNormalizer","match","pathname","normalize","matched","denormalizePagePath"],"mappings":";;;;+BAMaA;;;eAAAA;;;qCAJuB;wBACK;wBACA;AAElC,MAAMA;IAGXC,YAAYC,OAAe,CAAE;aADZC,SAAS,IAAIC,gCAAwB,CAAC;QAErD,IAAI,CAACF,SAAS;YACZ,MAAM,IAAIG,MAAM;QAClB;QAEA,IAAI,CAACC,MAAM,GAAG,IAAIC,gCAAwB,CAAC,CAAC,YAAY,EAAEL,QAAQ,CAAC;IACrE;IAEOM,MAAMC,QAAgB,EAAE;QAC7B,OAAO,IAAI,CAACH,MAAM,CAACE,KAAK,CAACC,aAAa,IAAI,CAACN,MAAM,CAACK,KAAK,CAACC;IAC1D;IAEOC,UAAUD,QAAgB,EAAEE,OAAiB,EAAU;QAC5D,uEAAuE;QACvE,IAAI,CAACA,WAAW,CAAC,IAAI,CAACH,KAAK,CAACC,WAAW,OAAOA;QAE9CA,WAAW,IAAI,CAACH,MAAM,CAACI,SAAS,CAACD,UAAU;QAC3CA,WAAW,IAAI,CAACN,MAAM,CAACO,SAAS,CAACD,UAAU;QAE3C,OAAOG,IAAAA,wCAAmB,EAACH;IAC7B;AACF"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,5 @@
import type { Normalizer } from '../normalizer';
export interface PathnameNormalizer extends Normalizer {
match(pathname: string): boolean;
normalize(pathname: string, matched?: boolean): string;
}

View File

@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
//# sourceMappingURL=pathname-normalizer.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":""}

View File

@ -0,0 +1,6 @@
import type { PathnameNormalizer } from './pathname-normalizer';
import { PrefixPathnameNormalizer } from './prefix';
export declare class PostponedPathnameNormalizer extends PrefixPathnameNormalizer implements PathnameNormalizer {
constructor();
normalize(pathname: string, matched?: boolean): string;
}

View File

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "PostponedPathnameNormalizer", {
enumerable: true,
get: function() {
return PostponedPathnameNormalizer;
}
});
const _denormalizepagepath = require("../../../../shared/lib/page-path/denormalize-page-path");
const _prefix = require("./prefix");
const prefix = "/_next/postponed/resume";
class PostponedPathnameNormalizer extends _prefix.PrefixPathnameNormalizer {
constructor(){
super(prefix);
}
normalize(pathname, matched) {
// If we're not matched and we don't match, we don't need to normalize.
if (!matched && !this.match(pathname)) return pathname;
// Remove the prefix.
pathname = super.normalize(pathname, true);
return (0, _denormalizepagepath.denormalizePagePath)(pathname);
}
}
//# sourceMappingURL=postponed.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/normalizers/request/postponed.ts"],"names":["PostponedPathnameNormalizer","prefix","PrefixPathnameNormalizer","constructor","normalize","pathname","matched","match","denormalizePagePath"],"mappings":";;;;+BAOaA;;;eAAAA;;;qCAPuB;wBAGK;AAEzC,MAAMC,SAAS;AAER,MAAMD,oCACHE,gCAAwB;IAGhCC,aAAc;QACZ,KAAK,CAACF;IACR;IAEOG,UAAUC,QAAgB,EAAEC,OAAiB,EAAU;QAC5D,uEAAuE;QACvE,IAAI,CAACA,WAAW,CAAC,IAAI,CAACC,KAAK,CAACF,WAAW,OAAOA;QAE9C,qBAAqB;QACrBA,WAAW,KAAK,CAACD,UAAUC,UAAU;QAErC,OAAOG,IAAAA,wCAAmB,EAACH;IAC7B;AACF"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,5 @@
import type { PathnameNormalizer } from './pathname-normalizer';
import { SuffixPathnameNormalizer } from './suffix';
export declare class PrefetchRSCPathnameNormalizer extends SuffixPathnameNormalizer implements PathnameNormalizer {
constructor();
}

View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "PrefetchRSCPathnameNormalizer", {
enumerable: true,
get: function() {
return PrefetchRSCPathnameNormalizer;
}
});
const _constants = require("../../../../lib/constants");
const _suffix = require("./suffix");
class PrefetchRSCPathnameNormalizer extends _suffix.SuffixPathnameNormalizer {
constructor(){
super(_constants.RSC_PREFETCH_SUFFIX);
}
}
//# sourceMappingURL=prefetch-rsc.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/normalizers/request/prefetch-rsc.ts"],"names":["PrefetchRSCPathnameNormalizer","SuffixPathnameNormalizer","constructor","RSC_PREFETCH_SUFFIX"],"mappings":";;;;+BAKaA;;;eAAAA;;;2BAHuB;wBACK;AAElC,MAAMA,sCACHC,gCAAwB;IAGhCC,aAAc;QACZ,KAAK,CAACC,8BAAmB;IAC3B;AACF"}

View File

@ -0,0 +1,7 @@
import type { Normalizer } from '../normalizer';
export declare class PrefixPathnameNormalizer implements Normalizer {
private readonly prefix;
constructor(prefix: string);
match(pathname: string): boolean;
normalize(pathname: string, matched?: boolean): string;
}

View File

@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "PrefixPathnameNormalizer", {
enumerable: true,
get: function() {
return PrefixPathnameNormalizer;
}
});
class PrefixPathnameNormalizer {
constructor(prefix){
this.prefix = prefix;
if (prefix.endsWith("/")) {
throw new Error(`PrefixPathnameNormalizer: prefix "${prefix}" should not end with a slash`);
}
}
match(pathname) {
// If the pathname doesn't start with the prefix, we don't match.
if (pathname !== this.prefix && !pathname.startsWith(this.prefix + "/")) {
return false;
}
return true;
}
normalize(pathname, matched) {
// If we're not matched and we don't match, we don't need to normalize.
if (!matched && !this.match(pathname)) return pathname;
if (pathname.length === this.prefix.length) {
return "/";
}
return pathname.substring(this.prefix.length);
}
}
//# sourceMappingURL=prefix.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/normalizers/request/prefix.ts"],"names":["PrefixPathnameNormalizer","constructor","prefix","endsWith","Error","match","pathname","startsWith","normalize","matched","length","substring"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA;IACXC,YAAY,AAAiBC,MAAc,CAAE;aAAhBA,SAAAA;QAC3B,IAAIA,OAAOC,QAAQ,CAAC,MAAM;YACxB,MAAM,IAAIC,MACR,CAAC,kCAAkC,EAAEF,OAAO,6BAA6B,CAAC;QAE9E;IACF;IAEOG,MAAMC,QAAgB,EAAE;QAC7B,iEAAiE;QACjE,IAAIA,aAAa,IAAI,CAACJ,MAAM,IAAI,CAACI,SAASC,UAAU,CAAC,IAAI,CAACL,MAAM,GAAG,MAAM;YACvE,OAAO;QACT;QAEA,OAAO;IACT;IAEOM,UAAUF,QAAgB,EAAEG,OAAiB,EAAU;QAC5D,uEAAuE;QACvE,IAAI,CAACA,WAAW,CAAC,IAAI,CAACJ,KAAK,CAACC,WAAW,OAAOA;QAE9C,IAAIA,SAASI,MAAM,KAAK,IAAI,CAACR,MAAM,CAACQ,MAAM,EAAE;YAC1C,OAAO;QACT;QAEA,OAAOJ,SAASK,SAAS,CAAC,IAAI,CAACT,MAAM,CAACQ,MAAM;IAC9C;AACF"}

View File

@ -0,0 +1 @@
export {};

View File

@ -0,0 +1,5 @@
import type { PathnameNormalizer } from './pathname-normalizer';
import { SuffixPathnameNormalizer } from './suffix';
export declare class RSCPathnameNormalizer extends SuffixPathnameNormalizer implements PathnameNormalizer {
constructor();
}

View File

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "RSCPathnameNormalizer", {
enumerable: true,
get: function() {
return RSCPathnameNormalizer;
}
});
const _constants = require("../../../../lib/constants");
const _suffix = require("./suffix");
class RSCPathnameNormalizer extends _suffix.SuffixPathnameNormalizer {
constructor(){
super(_constants.RSC_SUFFIX);
}
}
//# sourceMappingURL=rsc.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/normalizers/request/rsc.ts"],"names":["RSCPathnameNormalizer","SuffixPathnameNormalizer","constructor","RSC_SUFFIX"],"mappings":";;;;+BAKaA;;;eAAAA;;;2BAHc;wBACc;AAElC,MAAMA,8BACHC,gCAAwB;IAGhCC,aAAc;QACZ,KAAK,CAACC,qBAAU;IAClB;AACF"}

View File

@ -0,0 +1,7 @@
import type { Normalizer } from '../normalizer';
export declare class SuffixPathnameNormalizer implements Normalizer {
private readonly suffix;
constructor(suffix: string);
match(pathname: string): boolean;
normalize(pathname: string, matched?: boolean): string;
}

View File

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "SuffixPathnameNormalizer", {
enumerable: true,
get: function() {
return SuffixPathnameNormalizer;
}
});
class SuffixPathnameNormalizer {
constructor(suffix){
this.suffix = suffix;
}
match(pathname) {
// If the pathname doesn't end in the suffix, we don't match.
if (!pathname.endsWith(this.suffix)) return false;
return true;
}
normalize(pathname, matched) {
// If we're not matched and we don't match, we don't need to normalize.
if (!matched && !this.match(pathname)) return pathname;
return pathname.substring(0, pathname.length - this.suffix.length);
}
}
//# sourceMappingURL=suffix.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/normalizers/request/suffix.ts"],"names":["SuffixPathnameNormalizer","constructor","suffix","match","pathname","endsWith","normalize","matched","substring","length"],"mappings":";;;;+BAEaA;;;eAAAA;;;AAAN,MAAMA;IACXC,YAAY,AAAiBC,MAAc,CAAE;aAAhBA,SAAAA;IAAiB;IAEvCC,MAAMC,QAAgB,EAAE;QAC7B,6DAA6D;QAC7D,IAAI,CAACA,SAASC,QAAQ,CAAC,IAAI,CAACH,MAAM,GAAG,OAAO;QAE5C,OAAO;IACT;IAEOI,UAAUF,QAAgB,EAAEG,OAAiB,EAAU;QAC5D,uEAAuE;QACvE,IAAI,CAACA,WAAW,CAAC,IAAI,CAACJ,KAAK,CAACC,WAAW,OAAOA;QAE9C,OAAOA,SAASI,SAAS,CAAC,GAAGJ,SAASK,MAAM,GAAG,IAAI,CAACP,MAAM,CAACO,MAAM;IACnE;AACF"}

View File

@ -0,0 +1 @@
export {};