added fonts
This commit is contained in:
1 parent
4134e3a234
commit
142d2986b6
9079 files changed
+1498421
-2
No files matched your search
+7
@@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
export const AmpStateContext = React.createContext({});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
AmpStateContext.displayName = 'AmpStateContext';
|
||||
}
|
||||
|
||||
//# sourceMappingURL=amp-context.shared-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/amp-context.shared-runtime.ts"],"sourcesContent":["import React from 'react'\n\nexport const AmpStateContext: React.Context<any> = React.createContext({})\n\nif (process.env.NODE_ENV !== 'production') {\n AmpStateContext.displayName = 'AmpStateContext'\n}\n"],"names":["React","AmpStateContext","createContext","process","env","NODE_ENV","displayName"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AAEzB,OAAO,MAAMC,kBAAsCD,MAAME,aAAa,CAAC,CAAC,GAAE;AAE1E,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzCJ,gBAAgBK,WAAW,GAAG;AAChC"}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export function isInAmpMode(param) {
|
||||
let { ampFirst = false, hybrid = false, hasQuery = false } = param === void 0 ? {} : param;
|
||||
return ampFirst || hybrid && hasQuery;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=amp-mode.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/amp-mode.ts"],"sourcesContent":["export function isInAmpMode({\n ampFirst = false,\n hybrid = false,\n hasQuery = false,\n} = {}): boolean {\n return ampFirst || (hybrid && hasQuery)\n}\n"],"names":["isInAmpMode","ampFirst","hybrid","hasQuery"],"mappings":"AAAA,OAAO,SAASA,YAAY;IAAA,IAAA,EAC1BC,WAAW,KAAK,EAChBC,SAAS,KAAK,EACdC,WAAW,KAAK,EACjB,GAJ2B,mBAIxB,CAAC,IAJuB;IAK1B,OAAOF,YAAaC,UAAUC;AAChC"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import React from 'react';
|
||||
import { AmpStateContext } from './amp-context.shared-runtime';
|
||||
import { isInAmpMode } from './amp-mode';
|
||||
export function useAmp() {
|
||||
// Don't assign the context value to a variable to save bytes
|
||||
return isInAmpMode(React.useContext(AmpStateContext));
|
||||
}
|
||||
|
||||
//# sourceMappingURL=amp.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/amp.ts"],"sourcesContent":["import React from 'react'\nimport { AmpStateContext } from './amp-context.shared-runtime'\nimport { isInAmpMode } from './amp-mode'\n\nexport function useAmp(): boolean {\n // Don't assign the context value to a variable to save bytes\n return isInAmpMode(React.useContext(AmpStateContext))\n}\n"],"names":["React","AmpStateContext","isInAmpMode","useAmp","useContext"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AACzB,SAASC,eAAe,QAAQ,+BAA8B;AAC9D,SAASC,WAAW,QAAQ,aAAY;AAExC,OAAO,SAASC;IACd,6DAA6D;IAC7D,OAAOD,YAAYF,MAAMI,UAAU,CAACH;AACtC"}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import Loadable from './lazy-dynamic/loadable';
|
||||
export default function dynamic(dynamicOptions, options) {
|
||||
var _mergedOptions_loadableGenerated;
|
||||
const loadableOptions = {};
|
||||
if (typeof dynamicOptions === 'function') {
|
||||
loadableOptions.loader = dynamicOptions;
|
||||
}
|
||||
const mergedOptions = {
|
||||
...loadableOptions,
|
||||
...options
|
||||
};
|
||||
return Loadable({
|
||||
...mergedOptions,
|
||||
modules: (_mergedOptions_loadableGenerated = mergedOptions.loadableGenerated) == null ? void 0 : _mergedOptions_loadableGenerated.modules
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=app-dynamic.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/app-dynamic.tsx"],"sourcesContent":["import type React from 'react'\nimport type { JSX } from 'react'\nimport Loadable from './lazy-dynamic/loadable'\n\nimport type {\n LoadableGeneratedOptions,\n DynamicOptionsLoadingProps,\n Loader,\n LoaderComponent,\n} from './lazy-dynamic/types'\n\nexport {\n type LoadableGeneratedOptions,\n type DynamicOptionsLoadingProps,\n type Loader,\n type LoaderComponent,\n}\n\nexport type DynamicOptions<P = {}> = LoadableGeneratedOptions & {\n loading?: () => JSX.Element | null\n loader?: Loader<P>\n loadableGenerated?: LoadableGeneratedOptions\n modules?: string[]\n ssr?: boolean\n}\n\nexport type LoadableOptions<P = {}> = DynamicOptions<P>\n\nexport type LoadableFn<P = {}> = (\n opts: LoadableOptions<P>\n) => React.ComponentType<P>\n\nexport type LoadableComponent<P = {}> = React.ComponentType<P>\n\nexport default function dynamic<P = {}>(\n dynamicOptions: DynamicOptions<P> | Loader<P>,\n options?: DynamicOptions<P>\n): React.ComponentType<P> {\n const loadableOptions: LoadableOptions<P> = {}\n\n if (typeof dynamicOptions === 'function') {\n loadableOptions.loader = dynamicOptions\n }\n\n const mergedOptions = {\n ...loadableOptions,\n ...options,\n }\n\n return Loadable({\n ...mergedOptions,\n modules: mergedOptions.loadableGenerated?.modules,\n })\n}\n"],"names":["Loadable","dynamic","dynamicOptions","options","mergedOptions","loadableOptions","loader","modules","loadableGenerated"],"mappings":"AAEA,OAAOA,cAAc,0BAAyB;AAgC9C,eAAe,SAASC,QACtBC,cAA6C,EAC7CC,OAA2B;QAehBC;IAbX,MAAMC,kBAAsC,CAAC;IAE7C,IAAI,OAAOH,mBAAmB,YAAY;QACxCG,gBAAgBC,MAAM,GAAGJ;IAC3B;IAEA,MAAME,gBAAgB;QACpB,GAAGC,eAAe;QAClB,GAAGF,OAAO;IACZ;IAEA,OAAOH,SAAS;QACd,GAAGI,aAAa;QAChBG,OAAO,GAAEH,mCAAAA,cAAcI,iBAAiB,qBAA/BJ,iCAAiCG,OAAO;IACnD;AACF"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
'use client';
|
||||
import React from 'react';
|
||||
export const AppRouterContext = React.createContext(null);
|
||||
export const LayoutRouterContext = React.createContext(null);
|
||||
export const GlobalLayoutRouterContext = React.createContext(null);
|
||||
export const TemplateContext = React.createContext(null);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
AppRouterContext.displayName = 'AppRouterContext';
|
||||
LayoutRouterContext.displayName = 'LayoutRouterContext';
|
||||
GlobalLayoutRouterContext.displayName = 'GlobalLayoutRouterContext';
|
||||
TemplateContext.displayName = 'TemplateContext';
|
||||
}
|
||||
export const MissingSlotContext = React.createContext(new Set());
|
||||
|
||||
//# sourceMappingURL=app-router-context.shared-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/app-router-context.shared-runtime.ts"],"sourcesContent":["'use client'\n\nimport type { FetchServerResponseResult } from '../../client/components/router-reducer/fetch-server-response'\nimport type {\n FocusAndScrollRef,\n PrefetchKind,\n} from '../../client/components/router-reducer/router-reducer-types'\nimport type {\n FlightRouterState,\n FlightSegmentPath,\n} from '../../server/app-render/types'\nimport React from 'react'\n\nexport type ChildSegmentMap = Map<string, CacheNode>\n\n/**\n * Cache node used in app-router / layout-router.\n */\nexport type CacheNode = ReadyCacheNode | LazyCacheNode\n\nexport type LoadingModuleData =\n | [React.JSX.Element, React.ReactNode, React.ReactNode]\n | null\n\n/** viewport metadata node */\nexport type HeadData = React.ReactNode\n\nexport type LazyCacheNode = {\n /**\n * When rsc is null, this is a lazily-initialized cache node.\n *\n * If the app attempts to render it, it triggers a lazy data fetch,\n * postpones the render, and schedules an update to a new tree.\n *\n * TODO: This mechanism should not be used when PPR is enabled, though it\n * currently is in some cases until we've implemented partial\n * segment fetching.\n */\n rsc: null\n\n /**\n * A prefetched version of the segment data. See explanation in corresponding\n * field of ReadyCacheNode (below).\n *\n * Since LazyCacheNode mostly only exists in the non-PPR implementation, this\n * will usually be null, but it could have been cloned from a previous\n * CacheNode that was created by the PPR implementation. Eventually we want\n * to migrate everything away from LazyCacheNode entirely.\n */\n prefetchRsc: React.ReactNode\n\n /**\n * A pending response for the lazy data fetch. If this is not present\n * during render, it is lazily created.\n */\n lazyData: Promise<FetchServerResponseResult> | null\n\n prefetchHead: HeadData | null\n\n head: HeadData\n\n loading: LoadingModuleData | Promise<LoadingModuleData>\n\n /**\n * Child parallel routes.\n */\n parallelRoutes: Map<string, ChildSegmentMap>\n\n /**\n * The timestamp of the navigation that last updated the CacheNode's data. If\n * a CacheNode is reused from a previous navigation, this value is not\n * updated. Used to track the staleness of the data.\n */\n navigatedAt: number\n}\n\nexport type ReadyCacheNode = {\n /**\n * When rsc is not null, it represents the RSC data for the\n * corresponding segment.\n *\n * `null` is a valid React Node but because segment data is always a\n * <LayoutRouter> component, we can use `null` to represent empty.\n *\n * TODO: For additional type safety, update this type to\n * Exclude<React.ReactNode, null>. Need to update createEmptyCacheNode to\n * accept rsc as an argument, or just inline the callers.\n */\n rsc: React.ReactNode\n\n /**\n * Represents a static version of the segment that can be shown immediately,\n * and may or may not contain dynamic holes. It's prefetched before a\n * navigation occurs.\n *\n * During rendering, we will choose whether to render `rsc` or `prefetchRsc`\n * with `useDeferredValue`. As with the `rsc` field, a value of `null` means\n * no value was provided. In this case, the LayoutRouter will go straight to\n * rendering the `rsc` value; if that one is also missing, it will suspend and\n * trigger a lazy fetch.\n */\n prefetchRsc: React.ReactNode\n\n /**\n * There should never be a lazy data request in this case.\n */\n lazyData: null\n prefetchHead: HeadData | null\n\n head: HeadData\n\n loading: LoadingModuleData | Promise<LoadingModuleData>\n\n parallelRoutes: Map<string, ChildSegmentMap>\n\n navigatedAt: number\n}\n\nexport interface NavigateOptions {\n scroll?: boolean\n}\n\nexport interface PrefetchOptions {\n kind: PrefetchKind\n}\n\nexport interface AppRouterInstance {\n /**\n * Navigate to the previous history entry.\n */\n back(): void\n /**\n * Navigate to the next history entry.\n */\n forward(): void\n /**\n * Refresh the current page.\n */\n refresh(): void\n /**\n * Refresh the current page. Use in development only.\n * @internal\n */\n hmrRefresh(): void\n /**\n * Navigate to the provided href.\n * Pushes a new history entry.\n */\n push(href: string, options?: NavigateOptions): void\n /**\n * Navigate to the provided href.\n * Replaces the current history entry.\n */\n replace(href: string, options?: NavigateOptions): void\n /**\n * Prefetch the provided href.\n */\n prefetch(href: string, options?: PrefetchOptions): void\n}\n\nexport const AppRouterContext = React.createContext<AppRouterInstance | null>(\n null\n)\nexport const LayoutRouterContext = React.createContext<{\n parentTree: FlightRouterState\n parentCacheNode: CacheNode\n parentSegmentPath: FlightSegmentPath | null\n url: string\n} | null>(null)\n\nexport const GlobalLayoutRouterCLine truncated
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
// minimal implementation MurmurHash2 hash function
|
||||
function murmurhash2(str) {
|
||||
let h = 0;
|
||||
for(let i = 0; i < str.length; i++){
|
||||
const c = str.charCodeAt(i);
|
||||
h = Math.imul(h ^ c, 0x5bd1e995);
|
||||
h ^= h >>> 13;
|
||||
h = Math.imul(h, 0x5bd1e995);
|
||||
}
|
||||
return h >>> 0;
|
||||
}
|
||||
// default to 0.01% error rate as the filter compresses very well
|
||||
const DEFAULT_ERROR_RATE = 0.0001;
|
||||
export class BloomFilter {
|
||||
static from(items, errorRate) {
|
||||
if (errorRate === void 0) errorRate = DEFAULT_ERROR_RATE;
|
||||
const filter = new BloomFilter(items.length, errorRate);
|
||||
for (const item of items){
|
||||
filter.add(item);
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
export() {
|
||||
const data = {
|
||||
numItems: this.numItems,
|
||||
errorRate: this.errorRate,
|
||||
numBits: this.numBits,
|
||||
numHashes: this.numHashes,
|
||||
bitArray: this.bitArray
|
||||
};
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
if (this.errorRate < DEFAULT_ERROR_RATE) {
|
||||
const filterData = JSON.stringify(data);
|
||||
const gzipSize = require('next/dist/compiled/gzip-size').sync(filterData);
|
||||
if (gzipSize > 1024) {
|
||||
console.warn("Creating filter with error rate less than 0.1% (0.001) can increase the size dramatically proceed with caution. Received error rate " + this.errorRate + " resulted in size " + filterData.length + " bytes, " + gzipSize + " bytes (gzip)");
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
import(data) {
|
||||
this.numItems = data.numItems;
|
||||
this.errorRate = data.errorRate;
|
||||
this.numBits = data.numBits;
|
||||
this.numHashes = data.numHashes;
|
||||
this.bitArray = data.bitArray;
|
||||
}
|
||||
add(item) {
|
||||
const hashValues = this.getHashValues(item);
|
||||
hashValues.forEach((hash)=>{
|
||||
this.bitArray[hash] = 1;
|
||||
});
|
||||
}
|
||||
contains(item) {
|
||||
const hashValues = this.getHashValues(item);
|
||||
return hashValues.every((hash)=>this.bitArray[hash]);
|
||||
}
|
||||
getHashValues(item) {
|
||||
const hashValues = [];
|
||||
for(let i = 1; i <= this.numHashes; i++){
|
||||
const hash = murmurhash2("" + item + i) % this.numBits;
|
||||
hashValues.push(hash);
|
||||
}
|
||||
return hashValues;
|
||||
}
|
||||
constructor(numItems, errorRate = DEFAULT_ERROR_RATE){
|
||||
this.numItems = numItems;
|
||||
this.errorRate = errorRate;
|
||||
this.numBits = Math.ceil(-(numItems * Math.log(errorRate)) / (Math.log(2) * Math.log(2)));
|
||||
this.numHashes = Math.ceil(this.numBits / numItems * Math.log(2));
|
||||
this.bitArray = new Array(this.numBits).fill(0);
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=bloom-filter.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/bloom-filter.ts"],"sourcesContent":["// minimal implementation MurmurHash2 hash function\nfunction murmurhash2(str: string) {\n let h = 0\n for (let i = 0; i < str.length; i++) {\n const c = str.charCodeAt(i)\n h = Math.imul(h ^ c, 0x5bd1e995)\n h ^= h >>> 13\n h = Math.imul(h, 0x5bd1e995)\n }\n return h >>> 0\n}\n\n// default to 0.01% error rate as the filter compresses very well\nconst DEFAULT_ERROR_RATE = 0.0001\n\nexport class BloomFilter {\n numItems: number\n errorRate: number\n numBits: number\n numHashes: number\n bitArray: number[]\n\n constructor(numItems: number, errorRate: number = DEFAULT_ERROR_RATE) {\n this.numItems = numItems\n this.errorRate = errorRate\n this.numBits = Math.ceil(\n -(numItems * Math.log(errorRate)) / (Math.log(2) * Math.log(2))\n )\n this.numHashes = Math.ceil((this.numBits / numItems) * Math.log(2))\n this.bitArray = new Array(this.numBits).fill(0)\n }\n\n static from(items: string[], errorRate = DEFAULT_ERROR_RATE) {\n const filter = new BloomFilter(items.length, errorRate)\n\n for (const item of items) {\n filter.add(item)\n }\n return filter\n }\n\n export() {\n const data = {\n numItems: this.numItems,\n errorRate: this.errorRate,\n numBits: this.numBits,\n numHashes: this.numHashes,\n bitArray: this.bitArray,\n }\n\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n if (this.errorRate < DEFAULT_ERROR_RATE) {\n const filterData = JSON.stringify(data)\n const gzipSize = require('next/dist/compiled/gzip-size').sync(\n filterData\n )\n\n if (gzipSize > 1024) {\n console.warn(\n `Creating filter with error rate less than 0.1% (0.001) can increase the size dramatically proceed with caution. Received error rate ${this.errorRate} resulted in size ${filterData.length} bytes, ${gzipSize} bytes (gzip)`\n )\n }\n }\n }\n\n return data\n }\n\n import(data: ReturnType<(typeof this)['export']>) {\n this.numItems = data.numItems\n this.errorRate = data.errorRate\n this.numBits = data.numBits\n this.numHashes = data.numHashes\n this.bitArray = data.bitArray\n }\n\n add(item: string) {\n const hashValues = this.getHashValues(item)\n hashValues.forEach((hash) => {\n this.bitArray[hash] = 1\n })\n }\n\n contains(item: string) {\n const hashValues = this.getHashValues(item)\n return hashValues.every((hash) => this.bitArray[hash])\n }\n\n getHashValues(item: string) {\n const hashValues = []\n for (let i = 1; i <= this.numHashes; i++) {\n const hash = murmurhash2(`${item}${i}`) % this.numBits\n hashValues.push(hash)\n }\n return hashValues\n }\n}\n"],"names":["murmurhash2","str","h","i","length","c","charCodeAt","Math","imul","DEFAULT_ERROR_RATE","BloomFilter","from","items","errorRate","filter","item","add","export","data","numItems","numBits","numHashes","bitArray","process","env","NEXT_RUNTIME","filterData","JSON","stringify","gzipSize","require","sync","console","warn","import","hashValues","getHashValues","forEach","hash","contains","every","push","constructor","ceil","log","Array","fill"],"mappings":"AAAA,mDAAmD;AACnD,SAASA,YAAYC,GAAW;IAC9B,IAAIC,IAAI;IACR,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIG,MAAM,EAAED,IAAK;QACnC,MAAME,IAAIJ,IAAIK,UAAU,CAACH;QACzBD,IAAIK,KAAKC,IAAI,CAACN,IAAIG,GAAG;QACrBH,KAAKA,MAAM;QACXA,IAAIK,KAAKC,IAAI,CAACN,GAAG;IACnB;IACA,OAAOA,MAAM;AACf;AAEA,iEAAiE;AACjE,MAAMO,qBAAqB;AAE3B,OAAO,MAAMC;IAiBX,OAAOC,KAAKC,KAAe,EAAEC,SAA8B,EAAE;QAAhCA,IAAAA,sBAAAA,YAAYJ;QACvC,MAAMK,SAAS,IAAIJ,YAAYE,MAAMR,MAAM,EAAES;QAE7C,KAAK,MAAME,QAAQH,MAAO;YACxBE,OAAOE,GAAG,CAACD;QACb;QACA,OAAOD;IACT;IAEAG,SAAS;QACP,MAAMC,OAAO;YACXC,UAAU,IAAI,CAACA,QAAQ;YACvBN,WAAW,IAAI,CAACA,SAAS;YACzBO,SAAS,IAAI,CAACA,OAAO;YACrBC,WAAW,IAAI,CAACA,SAAS;YACzBC,UAAU,IAAI,CAACA,QAAQ;QACzB;QAEA,IAAIC,QAAQC,GAAG,CAACC,YAAY,KAAK,UAAU;YACzC,IAAI,IAAI,CAACZ,SAAS,GAAGJ,oBAAoB;gBACvC,MAAMiB,aAAaC,KAAKC,SAAS,CAACV;gBAClC,MAAMW,WAAWC,QAAQ,gCAAgCC,IAAI,CAC3DL;gBAGF,IAAIG,WAAW,MAAM;oBACnBG,QAAQC,IAAI,CACV,AAAC,yIAAsI,IAAI,CAACpB,SAAS,GAAC,uBAAoBa,WAAWtB,MAAM,GAAC,aAAUyB,WAAS;gBAEnN;YACF;QACF;QAEA,OAAOX;IACT;IAEAgB,OAAOhB,IAAyC,EAAE;QAChD,IAAI,CAACC,QAAQ,GAAGD,KAAKC,QAAQ;QAC7B,IAAI,CAACN,SAAS,GAAGK,KAAKL,SAAS;QAC/B,IAAI,CAACO,OAAO,GAAGF,KAAKE,OAAO;QAC3B,IAAI,CAACC,SAAS,GAAGH,KAAKG,SAAS;QAC/B,IAAI,CAACC,QAAQ,GAAGJ,KAAKI,QAAQ;IAC/B;IAEAN,IAAID,IAAY,EAAE;QAChB,MAAMoB,aAAa,IAAI,CAACC,aAAa,CAACrB;QACtCoB,WAAWE,OAAO,CAAC,CAACC;YAClB,IAAI,CAAChB,QAAQ,CAACgB,KAAK,GAAG;QACxB;IACF;IAEAC,SAASxB,IAAY,EAAE;QACrB,MAAMoB,aAAa,IAAI,CAACC,aAAa,CAACrB;QACtC,OAAOoB,WAAWK,KAAK,CAAC,CAACF,OAAS,IAAI,CAAChB,QAAQ,CAACgB,KAAK;IACvD;IAEAF,cAAcrB,IAAY,EAAE;QAC1B,MAAMoB,aAAa,EAAE;QACrB,IAAK,IAAIhC,IAAI,GAAGA,KAAK,IAAI,CAACkB,SAAS,EAAElB,IAAK;YACxC,MAAMmC,OAAOtC,YAAY,AAAC,KAAEe,OAAOZ,KAAO,IAAI,CAACiB,OAAO;YACtDe,WAAWM,IAAI,CAACH;QAClB;QACA,OAAOH;IACT;IAzEAO,YAALine truncated
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
export function isStableBuild() {
|
||||
var _process_env___NEXT_VERSION;
|
||||
return !((_process_env___NEXT_VERSION = "15.3.4") == null ? void 0 : _process_env___NEXT_VERSION.includes('canary')) && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
||||
}
|
||||
export class CanaryOnlyError extends Error {
|
||||
constructor(arg){
|
||||
if (typeof arg === 'object' && 'feature' in arg) {
|
||||
super('The experimental feature "' + arg.feature + '" can only be enabled when using the latest canary version of Next.js.');
|
||||
} else {
|
||||
super(arg);
|
||||
}
|
||||
// This error is meant to interrupt the server start/build process
|
||||
// but the stack trace isn't meaningful, as it points to internal code.
|
||||
this.stack = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=canary-only.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/canary-only.ts"],"sourcesContent":["export function isStableBuild() {\n return (\n !process.env.__NEXT_VERSION?.includes('canary') &&\n !process.env.__NEXT_TEST_MODE &&\n !process.env.NEXT_PRIVATE_LOCAL_DEV\n )\n}\n\nexport class CanaryOnlyError extends Error {\n constructor(arg: { feature: string } | string) {\n if (typeof arg === 'object' && 'feature' in arg) {\n super(\n `The experimental feature \"${arg.feature}\" can only be enabled when using the latest canary version of Next.js.`\n )\n } else {\n super(arg)\n }\n\n // This error is meant to interrupt the server start/build process\n // but the stack trace isn't meaningful, as it points to internal code.\n this.stack = undefined\n }\n}\n"],"names":["isStableBuild","process","env","__NEXT_VERSION","includes","__NEXT_TEST_MODE","NEXT_PRIVATE_LOCAL_DEV","CanaryOnlyError","Error","constructor","arg","feature","stack","undefined"],"mappings":"AAAA,OAAO,SAASA;QAEXC;IADH,OACE,GAACA,8BAAAA,QAAQC,GAAG,CAACC,cAAc,qBAA1BF,4BAA4BG,QAAQ,CAAC,cACtC,CAACH,QAAQC,GAAG,CAACG,gBAAgB,IAC7B,CAACJ,QAAQC,GAAG,CAACI,sBAAsB;AAEvC;AAEA,OAAO,MAAMC,wBAAwBC;IACnCC,YAAYC,GAAiC,CAAE;QAC7C,IAAI,OAAOA,QAAQ,YAAY,aAAaA,KAAK;YAC/C,KAAK,CACH,AAAC,+BAA4BA,IAAIC,OAAO,GAAC;QAE7C,OAAO;YACL,KAAK,CAACD;QACR;QAEA,kEAAkE;QAClE,uEAAuE;QACvE,IAAI,CAACE,KAAK,GAAGC;IACf;AACF"}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
import MODERN_BROWSERSLIST_TARGET from './modern-browserslist-target';
|
||||
export { MODERN_BROWSERSLIST_TARGET };
|
||||
export const COMPILER_NAMES = {
|
||||
client: 'client',
|
||||
server: 'server',
|
||||
edgeServer: 'edge-server'
|
||||
};
|
||||
export const COMPILER_INDEXES = {
|
||||
[COMPILER_NAMES.client]: 0,
|
||||
[COMPILER_NAMES.server]: 1,
|
||||
[COMPILER_NAMES.edgeServer]: 2
|
||||
};
|
||||
export const UNDERSCORE_NOT_FOUND_ROUTE = '/_not-found';
|
||||
export const UNDERSCORE_NOT_FOUND_ROUTE_ENTRY = "" + UNDERSCORE_NOT_FOUND_ROUTE + "/page";
|
||||
export const PHASE_EXPORT = 'phase-export';
|
||||
export const PHASE_PRODUCTION_BUILD = 'phase-production-build';
|
||||
export const PHASE_PRODUCTION_SERVER = 'phase-production-server';
|
||||
export const PHASE_DEVELOPMENT_SERVER = 'phase-development-server';
|
||||
export const PHASE_TEST = 'phase-test';
|
||||
export const PHASE_INFO = 'phase-info';
|
||||
export const PAGES_MANIFEST = 'pages-manifest.json';
|
||||
export const WEBPACK_STATS = 'webpack-stats.json';
|
||||
export const APP_PATHS_MANIFEST = 'app-paths-manifest.json';
|
||||
export const APP_PATH_ROUTES_MANIFEST = 'app-path-routes-manifest.json';
|
||||
export const BUILD_MANIFEST = 'build-manifest.json';
|
||||
export const APP_BUILD_MANIFEST = 'app-build-manifest.json';
|
||||
export const FUNCTIONS_CONFIG_MANIFEST = 'functions-config-manifest.json';
|
||||
export const SUBRESOURCE_INTEGRITY_MANIFEST = 'subresource-integrity-manifest';
|
||||
export const NEXT_FONT_MANIFEST = 'next-font-manifest';
|
||||
export const EXPORT_MARKER = 'export-marker.json';
|
||||
export const EXPORT_DETAIL = 'export-detail.json';
|
||||
export const PRERENDER_MANIFEST = 'prerender-manifest.json';
|
||||
export const ROUTES_MANIFEST = 'routes-manifest.json';
|
||||
export const IMAGES_MANIFEST = 'images-manifest.json';
|
||||
export const SERVER_FILES_MANIFEST = 'required-server-files.json';
|
||||
export const DEV_CLIENT_PAGES_MANIFEST = '_devPagesManifest.json';
|
||||
export const MIDDLEWARE_MANIFEST = 'middleware-manifest.json';
|
||||
export const TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST = '_clientMiddlewareManifest.json';
|
||||
export const DEV_CLIENT_MIDDLEWARE_MANIFEST = '_devMiddlewareManifest.json';
|
||||
export const REACT_LOADABLE_MANIFEST = 'react-loadable-manifest.json';
|
||||
export const SERVER_DIRECTORY = 'server';
|
||||
export const CONFIG_FILES = [
|
||||
'next.config.js',
|
||||
'next.config.mjs',
|
||||
'next.config.ts'
|
||||
];
|
||||
export const BUILD_ID_FILE = 'BUILD_ID';
|
||||
export const BLOCKED_PAGES = [
|
||||
'/_document',
|
||||
'/_app',
|
||||
'/_error'
|
||||
];
|
||||
export const CLIENT_PUBLIC_FILES_PATH = 'public';
|
||||
export const CLIENT_STATIC_FILES_PATH = 'static';
|
||||
export const STRING_LITERAL_DROP_BUNDLE = '__NEXT_DROP_CLIENT_FILE__';
|
||||
export const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__';
|
||||
export const BARREL_OPTIMIZATION_PREFIX = '__barrel_optimize__';
|
||||
// server/[entry]/page_client-reference-manifest.js
|
||||
export const CLIENT_REFERENCE_MANIFEST = 'client-reference-manifest';
|
||||
// server/server-reference-manifest
|
||||
export const SERVER_REFERENCE_MANIFEST = 'server-reference-manifest';
|
||||
// server/middleware-build-manifest.js
|
||||
export const MIDDLEWARE_BUILD_MANIFEST = 'middleware-build-manifest';
|
||||
// server/middleware-react-loadable-manifest.js
|
||||
export const MIDDLEWARE_REACT_LOADABLE_MANIFEST = 'middleware-react-loadable-manifest';
|
||||
// server/interception-route-rewrite-manifest.js
|
||||
export const INTERCEPTION_ROUTE_REWRITE_MANIFEST = 'interception-route-rewrite-manifest';
|
||||
// server/dynamic-css-manifest.js
|
||||
export const DYNAMIC_CSS_MANIFEST = 'dynamic-css-manifest';
|
||||
// static/runtime/main.js
|
||||
export const CLIENT_STATIC_FILES_RUNTIME_MAIN = "main";
|
||||
export const CLIENT_STATIC_FILES_RUNTIME_MAIN_APP = "" + CLIENT_STATIC_FILES_RUNTIME_MAIN + "-app";
|
||||
// next internal client components chunk for layouts
|
||||
export const APP_CLIENT_INTERNALS = 'app-pages-internals';
|
||||
// static/runtime/react-refresh.js
|
||||
export const CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH = "react-refresh";
|
||||
// static/runtime/amp.js
|
||||
export const CLIENT_STATIC_FILES_RUNTIME_AMP = "amp";
|
||||
// static/runtime/webpack.js
|
||||
export const CLIENT_STATIC_FILES_RUNTIME_WEBPACK = "webpack";
|
||||
// static/runtime/polyfills.js
|
||||
export const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS = 'polyfills';
|
||||
export const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL = Symbol(CLIENT_STATIC_FILES_RUNTIME_POLYFILLS);
|
||||
export const DEFAULT_RUNTIME_WEBPACK = 'webpack-runtime';
|
||||
export const EDGE_RUNTIME_WEBPACK = 'edge-runtime-webpack';
|
||||
export const STATIC_PROPS_ID = '__N_SSG';
|
||||
export const SERVER_PROPS_ID = '__N_SSP';
|
||||
export const DEFAULT_SERIF_FONT = {
|
||||
name: 'Times New Roman',
|
||||
xAvgCharWidth: 821,
|
||||
azAvgWidth: 854.3953488372093,
|
||||
unitsPerEm: 2048
|
||||
};
|
||||
export const DEFAULT_SANS_SERIF_FONT = {
|
||||
name: 'Arial',
|
||||
xAvgCharWidth: 904,
|
||||
azAvgWidth: 934.5116279069767,
|
||||
unitsPerEm: 2048
|
||||
};
|
||||
export const STATIC_STATUS_PAGES = [
|
||||
'/500'
|
||||
];
|
||||
export const TRACE_OUTPUT_VERSION = 1;
|
||||
// in `MB`
|
||||
export const TURBO_TRACE_DEFAULT_MEMORY_LIMIT = 6000;
|
||||
export const RSC_MODULE_TYPES = {
|
||||
client: 'client',
|
||||
server: 'server'
|
||||
};
|
||||
// comparing
|
||||
// https://nextjs.org/docs/api-reference/edge-runtime
|
||||
// with
|
||||
// https://nodejs.org/docs/latest/api/globals.html
|
||||
export const EDGE_UNSUPPORTED_NODE_APIS = [
|
||||
'clearImmediate',
|
||||
'setImmediate',
|
||||
'BroadcastChannel',
|
||||
'ByteLengthQueuingStrategy',
|
||||
'CompressionStream',
|
||||
'CountQueuingStrategy',
|
||||
'DecompressionStream',
|
||||
'DomException',
|
||||
'MessageChannel',
|
||||
'MessageEvent',
|
||||
'MessagePort',
|
||||
'ReadableByteStreamController',
|
||||
'ReadableStreamBYOBRequest',
|
||||
'ReadableStreamDefaultController',
|
||||
'TransformStreamDefaultController',
|
||||
'WritableStreamDefaultController'
|
||||
];
|
||||
export const SYSTEM_ENTRYPOINTS = new Set([
|
||||
CLIENT_STATIC_FILES_RUNTIME_MAIN,
|
||||
CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,
|
||||
CLIENT_STATIC_FILES_RUNTIME_AMP,
|
||||
CLIENT_STATIC_FILES_RUNTIME_MAIN_APP
|
||||
]);
|
||||
|
||||
//# sourceMappingURL=constants.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/constants.ts"],"sourcesContent":["import MODERN_BROWSERSLIST_TARGET from './modern-browserslist-target'\n\nexport { MODERN_BROWSERSLIST_TARGET }\n\nexport type ValueOf<T> = Required<T>[keyof T]\n\nexport const COMPILER_NAMES = {\n client: 'client',\n server: 'server',\n edgeServer: 'edge-server',\n} as const\n\nexport type CompilerNameValues = ValueOf<typeof COMPILER_NAMES>\n\nexport const COMPILER_INDEXES: {\n [compilerKey in CompilerNameValues]: number\n} = {\n [COMPILER_NAMES.client]: 0,\n [COMPILER_NAMES.server]: 1,\n [COMPILER_NAMES.edgeServer]: 2,\n} as const\n\nexport const UNDERSCORE_NOT_FOUND_ROUTE = '/_not-found'\nexport const UNDERSCORE_NOT_FOUND_ROUTE_ENTRY = `${UNDERSCORE_NOT_FOUND_ROUTE}/page`\nexport const PHASE_EXPORT = 'phase-export'\nexport const PHASE_PRODUCTION_BUILD = 'phase-production-build'\nexport const PHASE_PRODUCTION_SERVER = 'phase-production-server'\nexport const PHASE_DEVELOPMENT_SERVER = 'phase-development-server'\nexport const PHASE_TEST = 'phase-test'\nexport const PHASE_INFO = 'phase-info'\nexport const PAGES_MANIFEST = 'pages-manifest.json'\nexport const WEBPACK_STATS = 'webpack-stats.json'\nexport const APP_PATHS_MANIFEST = 'app-paths-manifest.json'\nexport const APP_PATH_ROUTES_MANIFEST = 'app-path-routes-manifest.json'\nexport const BUILD_MANIFEST = 'build-manifest.json'\nexport const APP_BUILD_MANIFEST = 'app-build-manifest.json'\nexport const FUNCTIONS_CONFIG_MANIFEST = 'functions-config-manifest.json'\nexport const SUBRESOURCE_INTEGRITY_MANIFEST = 'subresource-integrity-manifest'\nexport const NEXT_FONT_MANIFEST = 'next-font-manifest'\nexport const EXPORT_MARKER = 'export-marker.json'\nexport const EXPORT_DETAIL = 'export-detail.json'\nexport const PRERENDER_MANIFEST = 'prerender-manifest.json'\nexport const ROUTES_MANIFEST = 'routes-manifest.json'\nexport const IMAGES_MANIFEST = 'images-manifest.json'\nexport const SERVER_FILES_MANIFEST = 'required-server-files.json'\nexport const DEV_CLIENT_PAGES_MANIFEST = '_devPagesManifest.json'\nexport const MIDDLEWARE_MANIFEST = 'middleware-manifest.json'\nexport const TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST =\n '_clientMiddlewareManifest.json'\nexport const DEV_CLIENT_MIDDLEWARE_MANIFEST = '_devMiddlewareManifest.json'\nexport const REACT_LOADABLE_MANIFEST = 'react-loadable-manifest.json'\nexport const SERVER_DIRECTORY = 'server'\nexport const CONFIG_FILES = [\n 'next.config.js',\n 'next.config.mjs',\n 'next.config.ts',\n]\nexport const BUILD_ID_FILE = 'BUILD_ID'\nexport const BLOCKED_PAGES = ['/_document', '/_app', '/_error']\nexport const CLIENT_PUBLIC_FILES_PATH = 'public'\nexport const CLIENT_STATIC_FILES_PATH = 'static'\nexport const STRING_LITERAL_DROP_BUNDLE = '__NEXT_DROP_CLIENT_FILE__'\nexport const NEXT_BUILTIN_DOCUMENT = '__NEXT_BUILTIN_DOCUMENT__'\nexport const BARREL_OPTIMIZATION_PREFIX = '__barrel_optimize__'\n\n// server/[entry]/page_client-reference-manifest.js\nexport const CLIENT_REFERENCE_MANIFEST = 'client-reference-manifest'\n// server/server-reference-manifest\nexport const SERVER_REFERENCE_MANIFEST = 'server-reference-manifest'\n// server/middleware-build-manifest.js\nexport const MIDDLEWARE_BUILD_MANIFEST = 'middleware-build-manifest'\n// server/middleware-react-loadable-manifest.js\nexport const MIDDLEWARE_REACT_LOADABLE_MANIFEST =\n 'middleware-react-loadable-manifest'\n// server/interception-route-rewrite-manifest.js\nexport const INTERCEPTION_ROUTE_REWRITE_MANIFEST =\n 'interception-route-rewrite-manifest'\n// server/dynamic-css-manifest.js\nexport const DYNAMIC_CSS_MANIFEST = 'dynamic-css-manifest'\n\n// static/runtime/main.js\nexport const CLIENT_STATIC_FILES_RUNTIME_MAIN = `main`\nexport const CLIENT_STATIC_FILES_RUNTIME_MAIN_APP = `${CLIENT_STATIC_FILES_RUNTIME_MAIN}-app`\n// next internal client components chunk for layouts\nexport const APP_CLIENT_INTERNALS = 'app-pages-internals'\n// static/runtime/react-refresh.js\nexport const CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH = `react-refresh`\n// static/runtime/amp.js\nexport const CLIENT_STATIC_FILES_RUNTIME_AMP = `amp`\n// static/runtime/webpack.js\nexport const CLIENT_STATIC_FILES_RUNTIME_WEBPACK = `webpack`\n// static/runtime/polyfills.js\nexport const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS = 'polyfills'\nexport const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL = Symbol(\n CLIENT_STATIC_FILES_RUNTIME_POLYFILLS\n)\nexport const DEFAULT_RUNTIME_WEBPACK = 'webpack-runtime'\nexport const EDGE_RUNTIME_WEBPACK = 'edge-runtime-webpack'\nexport const STATIC_PROPS_ID = '__N_SSG'\nexport const SERVER_PROPS_ID = '__N_SSP'\nexport const DEFAULT_SERIF_FONT = {\n name: 'Times New Roman',\n xAvgCharWidth: 821,\n azAvgWidth: 854.3953488372093,\n unitsPerEm: 2048,\n}\nexport const DEFAULT_SANS_SERIF_FONT = {\n name: 'Arial',\n xAvgCharWidth: 904,\n azAvgWidth: 934.5116279069767,\n unitsPerEm: 2048,\n}\nexport const STATIC_STATUS_PAGES = ['/500']\nexport const TRACE_OUTPUT_VERSION = 1\n// in Line truncated
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Recursively freezes an object and all of its properties. This prevents the
|
||||
* object from being modified at runtime. When the JS runtime is running in
|
||||
* strict mode, any attempts to modify a frozen object will throw an error.
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
|
||||
* @param obj The object to freeze.
|
||||
*/ export function deepFreeze(obj) {
|
||||
// If the object is already frozen, there's no need to freeze it again.
|
||||
if (Object.isFrozen(obj)) return obj;
|
||||
// An array is an object, but we also want to freeze each element in the array
|
||||
// as well.
|
||||
if (Array.isArray(obj)) {
|
||||
for (const item of obj){
|
||||
if (!item || typeof item !== 'object') continue;
|
||||
deepFreeze(item);
|
||||
}
|
||||
return Object.freeze(obj);
|
||||
}
|
||||
for (const value of Object.values(obj)){
|
||||
if (!value || typeof value !== 'object') continue;
|
||||
deepFreeze(value);
|
||||
}
|
||||
return Object.freeze(obj);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=deep-freeze.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/deep-freeze.ts"],"sourcesContent":["import type { DeepReadonly } from './deep-readonly'\n\n/**\n * Recursively freezes an object and all of its properties. This prevents the\n * object from being modified at runtime. When the JS runtime is running in\n * strict mode, any attempts to modify a frozen object will throw an error.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n * @param obj The object to freeze.\n */\nexport function deepFreeze<T extends object>(obj: T): DeepReadonly<T> {\n // If the object is already frozen, there's no need to freeze it again.\n if (Object.isFrozen(obj)) return obj as DeepReadonly<T>\n\n // An array is an object, but we also want to freeze each element in the array\n // as well.\n if (Array.isArray(obj)) {\n for (const item of obj) {\n if (!item || typeof item !== 'object') continue\n deepFreeze(item)\n }\n\n return Object.freeze(obj) as DeepReadonly<T>\n }\n\n for (const value of Object.values(obj)) {\n if (!value || typeof value !== 'object') continue\n deepFreeze(value)\n }\n\n return Object.freeze(obj) as DeepReadonly<T>\n}\n"],"names":["deepFreeze","obj","Object","isFrozen","Array","isArray","item","freeze","value","values"],"mappings":"AAEA;;;;;;;CAOC,GACD,OAAO,SAASA,WAA6BC,GAAM;IACjD,uEAAuE;IACvE,IAAIC,OAAOC,QAAQ,CAACF,MAAM,OAAOA;IAEjC,8EAA8E;IAC9E,WAAW;IACX,IAAIG,MAAMC,OAAO,CAACJ,MAAM;QACtB,KAAK,MAAMK,QAAQL,IAAK;YACtB,IAAI,CAACK,QAAQ,OAAOA,SAAS,UAAU;YACvCN,WAAWM;QACb;QAEA,OAAOJ,OAAOK,MAAM,CAACN;IACvB;IAEA,KAAK,MAAMO,SAASN,OAAOO,MAAM,CAACR,KAAM;QACtC,IAAI,CAACO,SAAS,OAAOA,UAAU,UAAU;QACzCR,WAAWQ;IACb;IAEA,OAAON,OAAOK,MAAM,CAACN;AACvB"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* A type that represents a deeply readonly object. This is similar to
|
||||
* TypeScript's `Readonly` type, but it recursively applies the `readonly`
|
||||
* modifier to all properties of an object and all elements of arrays.
|
||||
*/ export { };
|
||||
|
||||
//# sourceMappingURL=deep-readonly.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/deep-readonly.ts"],"sourcesContent":["/**\n * A type that represents a deeply readonly object. This is similar to\n * TypeScript's `Readonly` type, but it recursively applies the `readonly`\n * modifier to all properties of an object and all elements of arrays.\n */\nexport type DeepReadonly<T> = T extends (infer R)[]\n ? ReadonlyArray<DeepReadonly<R>>\n : T extends object\n ? {\n readonly [K in keyof T]: DeepReadonly<T[K]>\n }\n : T\n"],"names":[],"mappings":"AAAA;;;;CAIC,GACD,WAMO"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export function dset<T extends object, V>(
|
||||
obj: T,
|
||||
keys: string | ArrayLike<string | number>,
|
||||
value: V
|
||||
): void
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/ // This file is based on https://github.com/lukeed/dset/blob/v3.1.3/src/index.js
|
||||
// It's been edited for the needs of this script
|
||||
// See the LICENSE at the top of the file
|
||||
export function dset(obj, keys, val) {
|
||||
keys.split && (keys = keys.split('.'));
|
||||
var i = 0, l = keys.length, t = obj, x, k;
|
||||
while(i < l){
|
||||
k = keys[i++];
|
||||
if (k === '__proto__' || k === 'constructor' || k === 'prototype') break;
|
||||
t = t[k] = i === l ? val : typeof (x = t[k]) === typeof keys ? x : keys[i] * 0 !== 0 || !!~('' + keys[i]).indexOf('.') ? {} : [];
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dset.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/dset.js"],"sourcesContent":["/*\nThe MIT License (MIT)\n\nCopyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n*/\n\n// This file is based on https://github.com/lukeed/dset/blob/v3.1.3/src/index.js\n// It's been edited for the needs of this script\n// See the LICENSE at the top of the file\n\nexport function dset(obj, keys, val) {\n keys.split && (keys = keys.split('.'))\n var i = 0,\n l = keys.length,\n t = obj,\n x,\n k\n while (i < l) {\n k = keys[i++]\n if (k === '__proto__' || k === 'constructor' || k === 'prototype') break\n t = t[k] =\n i === l\n ? val\n : typeof (x = t[k]) === typeof keys\n ? x\n : keys[i] * 0 !== 0 || !!~('' + keys[i]).indexOf('.')\n ? {}\n : []\n }\n}\n"],"names":["dset","obj","keys","val","split","i","l","length","t","x","k","indexOf"],"mappings":"AAAA;;;;;;;;;;AAUA,GAEA,gFAAgF;AAChF,gDAAgD;AAChD,yCAAyC;AAEzC,OAAO,SAASA,KAAKC,GAAG,EAAEC,IAAI,EAAEC,GAAG;IACjCD,KAAKE,KAAK,IAAKF,CAAAA,OAAOA,KAAKE,KAAK,CAAC,IAAG;IACpC,IAAIC,IAAI,GACNC,IAAIJ,KAAKK,MAAM,EACfC,IAAIP,KACJQ,GACAC;IACF,MAAOL,IAAIC,EAAG;QACZI,IAAIR,IAAI,CAACG,IAAI;QACb,IAAIK,MAAM,eAAeA,MAAM,iBAAiBA,MAAM,aAAa;QACnEF,IAAIA,CAAC,CAACE,EAAE,GACNL,MAAMC,IACFH,MACA,OAAQM,CAAAA,IAAID,CAAC,CAACE,EAAE,AAAD,MAAO,OAAOR,OAC3BO,IACAP,IAAI,CAACG,EAAE,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,AAAC,CAAA,KAAKH,IAAI,CAACG,EAAE,AAAD,EAAGM,OAAO,CAAC,OAC7C,CAAC,IACD,EAAE;IACd;AACF"}
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
||||
import React from 'react';
|
||||
import Loadable from './loadable.shared-runtime';
|
||||
const isServerSide = typeof window === 'undefined';
|
||||
// Normalize loader to return the module as form { default: Component } for `React.lazy`.
|
||||
// Also for backward compatible since next/dynamic allows to resolve a component directly with loader
|
||||
// Client component reference proxy need to be converted to a module.
|
||||
function convertModule(mod) {
|
||||
return {
|
||||
default: (mod == null ? void 0 : mod.default) || mod
|
||||
};
|
||||
}
|
||||
export function noSSR(LoadableInitializer, loadableOptions) {
|
||||
// Removing webpack and modules means react-loadable won't try preloading
|
||||
delete loadableOptions.webpack;
|
||||
delete loadableOptions.modules;
|
||||
// This check is necessary to prevent react-loadable from initializing on the server
|
||||
if (!isServerSide) {
|
||||
return LoadableInitializer(loadableOptions);
|
||||
}
|
||||
const Loading = loadableOptions.loading;
|
||||
// This will only be rendered on the server side
|
||||
return ()=>/*#__PURE__*/ _jsx(Loading, {
|
||||
error: null,
|
||||
isLoading: true,
|
||||
pastDelay: false,
|
||||
timedOut: false
|
||||
});
|
||||
}
|
||||
/**
|
||||
* This function lets you dynamically import a component.
|
||||
* It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.
|
||||
*
|
||||
* Read more: [Next.js Docs: `next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic)
|
||||
*/ export default function dynamic(dynamicOptions, options) {
|
||||
let loadableFn = Loadable;
|
||||
let loadableOptions = {
|
||||
// A loading component is not required, so we default it
|
||||
loading: (param)=>{
|
||||
let { error, isLoading, pastDelay } = param;
|
||||
if (!pastDelay) return null;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (isLoading) {
|
||||
return null;
|
||||
}
|
||||
if (error) {
|
||||
return /*#__PURE__*/ _jsxs("p", {
|
||||
children: [
|
||||
error.message,
|
||||
/*#__PURE__*/ _jsx("br", {}),
|
||||
error.stack
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
// Support for direct import(), eg: dynamic(import('../hello-world'))
|
||||
// Note that this is only kept for the edge case where someone is passing in a promise as first argument
|
||||
// The react-loadable babel plugin will turn dynamic(import('../hello-world')) into dynamic(() => import('../hello-world'))
|
||||
// To make sure we don't execute the import without rendering first
|
||||
if (dynamicOptions instanceof Promise) {
|
||||
loadableOptions.loader = ()=>dynamicOptions;
|
||||
// Support for having import as a function, eg: dynamic(() => import('../hello-world'))
|
||||
} else if (typeof dynamicOptions === 'function') {
|
||||
loadableOptions.loader = dynamicOptions;
|
||||
// Support for having first argument being options, eg: dynamic({loader: import('../hello-world')})
|
||||
} else if (typeof dynamicOptions === 'object') {
|
||||
loadableOptions = {
|
||||
...loadableOptions,
|
||||
...dynamicOptions
|
||||
};
|
||||
}
|
||||
// Support for passing options, eg: dynamic(import('../hello-world'), {loading: () => <p>Loading something</p>})
|
||||
loadableOptions = {
|
||||
...loadableOptions,
|
||||
...options
|
||||
};
|
||||
const loaderFn = loadableOptions.loader;
|
||||
const loader = ()=>loaderFn != null ? loaderFn().then(convertModule) : Promise.resolve(convertModule(()=>null));
|
||||
// coming from build/babel/plugins/react-loadable-plugin.js
|
||||
if (loadableOptions.loadableGenerated) {
|
||||
loadableOptions = {
|
||||
...loadableOptions,
|
||||
...loadableOptions.loadableGenerated
|
||||
};
|
||||
delete loadableOptions.loadableGenerated;
|
||||
}
|
||||
// support for disabling server side rendering, eg: dynamic(() => import('../hello-world'), {ssr: false}).
|
||||
if (typeof loadableOptions.ssr === 'boolean' && !loadableOptions.ssr) {
|
||||
delete loadableOptions.webpack;
|
||||
delete loadableOptions.modules;
|
||||
return noSSR(loadableFn, loadableOptions);
|
||||
}
|
||||
return loadableFn({
|
||||
...loadableOptions,
|
||||
loader: loader
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dynamic.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/dynamic.tsx"],"sourcesContent":["import React from 'react'\nimport Loadable from './loadable.shared-runtime'\n\nconst isServerSide = typeof window === 'undefined'\n\ntype ComponentModule<P = {}> = { default: React.ComponentType<P> }\n\nexport declare type LoaderComponent<P = {}> = Promise<\n React.ComponentType<P> | ComponentModule<P>\n>\n\nexport declare type Loader<P = {}> =\n | (() => LoaderComponent<P>)\n | LoaderComponent<P>\n\nexport type LoaderMap = { [module: string]: () => Loader<any> }\n\nexport type LoadableGeneratedOptions = {\n webpack?(): any\n modules?(): LoaderMap\n}\n\nexport type DynamicOptionsLoadingProps = {\n error?: Error | null\n isLoading?: boolean\n pastDelay?: boolean\n retry?: () => void\n timedOut?: boolean\n}\n\n// Normalize loader to return the module as form { default: Component } for `React.lazy`.\n// Also for backward compatible since next/dynamic allows to resolve a component directly with loader\n// Client component reference proxy need to be converted to a module.\nfunction convertModule<P>(mod: React.ComponentType<P> | ComponentModule<P>) {\n return { default: (mod as ComponentModule<P>)?.default || mod }\n}\n\nexport type DynamicOptions<P = {}> = LoadableGeneratedOptions & {\n loading?: (loadingProps: DynamicOptionsLoadingProps) => React.ReactNode\n loader?: Loader<P> | LoaderMap\n loadableGenerated?: LoadableGeneratedOptions\n ssr?: boolean\n}\n\nexport type LoadableOptions<P = {}> = DynamicOptions<P>\n\nexport type LoadableFn<P = {}> = (\n opts: LoadableOptions<P>\n) => React.ComponentType<P>\n\nexport type LoadableComponent<P = {}> = React.ComponentType<P>\n\nexport function noSSR<P = {}>(\n LoadableInitializer: LoadableFn<P>,\n loadableOptions: DynamicOptions<P>\n): React.ComponentType<P> {\n // Removing webpack and modules means react-loadable won't try preloading\n delete loadableOptions.webpack\n delete loadableOptions.modules\n\n // This check is necessary to prevent react-loadable from initializing on the server\n if (!isServerSide) {\n return LoadableInitializer(loadableOptions)\n }\n\n const Loading = loadableOptions.loading!\n // This will only be rendered on the server side\n return () => (\n <Loading error={null} isLoading pastDelay={false} timedOut={false} />\n )\n}\n\n/**\n * This function lets you dynamically import a component.\n * It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.\n *\n * Read more: [Next.js Docs: `next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic)\n */\nexport default function dynamic<P = {}>(\n dynamicOptions: DynamicOptions<P> | Loader<P>,\n options?: DynamicOptions<P>\n): React.ComponentType<P> {\n let loadableFn = Loadable as LoadableFn<P>\n\n let loadableOptions: LoadableOptions<P> = {\n // A loading component is not required, so we default it\n loading: ({ error, isLoading, pastDelay }) => {\n if (!pastDelay) return null\n if (process.env.NODE_ENV !== 'production') {\n if (isLoading) {\n return null\n }\n if (error) {\n return (\n <p>\n {error.message}\n <br />\n {error.stack}\n </p>\n )\n }\n }\n return null\n },\n }\n\n // Support for direct import(), eg: dynamic(import('../hello-world'))\n // Note that this is only kept for the edge case where someone is passing in a promise as first argument\n // The react-loadable babel plugin will turn dynamic(import('../hello-world')) into dynamic(() => import('../hello-world'))\n // To make sure we don't execute the import without rendering first\n if (dynamicOptions instanceof Promise) {\n loadableOptions.loader = () => dynamicOptions\n // Support for having import as a function, eg: dynamic(() => import('../hello-world'))\n } else if (typeof dynamicOptions === 'function') {\n loadableOptions.loader = dynamicOptions\n // Support for having first argument being options, eg: dynamic({loader: import('../hello-world')})\n } else if (typeof dynamicOptions === 'object') {\n loadableOptions = { ...loadableOptions, ...dynamicOptions }\n }\n\n // Support for passing options, eg: dynamic(import('../hello-world'), {loading: () => <p>Loading something</p>})\n loadableOptions = { ...loadableOptions, ...options }\n\n const loaderFn = loadableOptions.loader as () => LoaderComponent<P>\n const loader = () =>\n loaderFn != null\n ? loaderFn().then(convertModule)\n : Promise.resolve(convertModule(() => null))\n\n // coming from build/babel/plugins/react-loadable-plugin.js\n if (loadableOptions.loadableGenerated) {\n loadableOptions = {\n ...loadableOptions,\n ...loadableOptions.loadableGenerated,\n }\n delete loadableOptions.loadableGenerated\n }\n\n // support for disablLine truncated
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export function encodeURIPath(file) {
|
||||
return file.split('/').map((p)=>encodeURIComponent(p)).join('/');
|
||||
}
|
||||
|
||||
//# sourceMappingURL=encode-uri-path.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/encode-uri-path.ts"],"sourcesContent":["export function encodeURIPath(file: string) {\n return file\n .split('/')\n .map((p) => encodeURIComponent(p))\n .join('/')\n}\n"],"names":["encodeURIPath","file","split","map","p","encodeURIComponent","join"],"mappings":"AAAA,OAAO,SAASA,cAAcC,IAAY;IACxC,OAAOA,KACJC,KAAK,CAAC,KACNC,GAAG,CAAC,CAACC,IAAMC,mBAAmBD,IAC9BE,IAAI,CAAC;AACV"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
const symbolError = Symbol.for('NextjsError');
|
||||
export function getErrorSource(error) {
|
||||
return error[symbolError] || null;
|
||||
}
|
||||
export function decorateServerError(error, type) {
|
||||
Object.defineProperty(error, symbolError, {
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
value: type
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=error-source.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/error-source.ts"],"sourcesContent":["const symbolError = Symbol.for('NextjsError')\n\nexport function getErrorSource(error: Error): 'server' | 'edge-server' | null {\n return (error as any)[symbolError] || null\n}\n\nexport type ErrorSourceType = 'edge-server' | 'server'\n\nexport function decorateServerError(error: Error, type: ErrorSourceType) {\n Object.defineProperty(error, symbolError, {\n writable: false,\n enumerable: false,\n configurable: false,\n value: type,\n })\n}\n"],"names":["symbolError","Symbol","for","getErrorSource","error","decorateServerError","type","Object","defineProperty","writable","enumerable","configurable","value"],"mappings":"AAAA,MAAMA,cAAcC,OAAOC,GAAG,CAAC;AAE/B,OAAO,SAASC,eAAeC,KAAY;IACzC,OAAO,AAACA,KAAa,CAACJ,YAAY,IAAI;AACxC;AAIA,OAAO,SAASK,oBAAoBD,KAAY,EAAEE,IAAqB;IACrEC,OAAOC,cAAc,CAACJ,OAAOJ,aAAa;QACxCS,UAAU;QACVC,YAAY;QACZC,cAAc;QACdC,OAAON;IACT;AACF"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export const MISSING_ROOT_TAGS_ERROR = 'NEXT_MISSING_ROOT_TAGS';
|
||||
|
||||
//# sourceMappingURL=constants.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/errors/constants.ts"],"sourcesContent":["export const MISSING_ROOT_TAGS_ERROR = 'NEXT_MISSING_ROOT_TAGS'\n"],"names":["MISSING_ROOT_TAGS_ERROR"],"mappings":"AAAA,OAAO,MAAMA,0BAA0B,yBAAwB"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// regexp is based on https://github.com/sindresorhus/escape-string-regexp
|
||||
const reHasRegExp = /[|\\{}()[\]^$+*?.-]/;
|
||||
const reReplaceRegExp = /[|\\{}()[\]^$+*?.-]/g;
|
||||
export function escapeStringRegexp(str) {
|
||||
// see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23
|
||||
if (reHasRegExp.test(str)) {
|
||||
return str.replace(reReplaceRegExp, '\\$&');
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=escape-regexp.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/escape-regexp.ts"],"sourcesContent":["// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g\n\nexport function escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&')\n }\n return str\n}\n"],"names":["reHasRegExp","reReplaceRegExp","escapeStringRegexp","str","test","replace"],"mappings":"AAAA,0EAA0E;AAC1E,MAAMA,cAAc;AACpB,MAAMC,kBAAkB;AAExB,OAAO,SAASC,mBAAmBC,GAAW;IAC5C,+GAA+G;IAC/G,IAAIH,YAAYI,IAAI,CAACD,MAAM;QACzB,OAAOA,IAAIE,OAAO,CAACJ,iBAAiB;IACtC;IACA,OAAOE;AACT"}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// source: https://github.com/sindresorhus/fnv1a
|
||||
// FNV_PRIMES and FNV_OFFSETS from
|
||||
// http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param
|
||||
/* eslint-disable @typescript-eslint/no-loss-of-precision */ const FNV_PRIMES = {
|
||||
32: BigInt(16777619),
|
||||
64: BigInt(1099511628211),
|
||||
128: BigInt(309485009821345068724781371),
|
||||
256: BigInt(374144419156711147060143317175368453031918731002211),
|
||||
512: BigInt(35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759),
|
||||
1024: BigInt(5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573)
|
||||
};
|
||||
const FNV_OFFSETS = {
|
||||
32: BigInt(2166136261),
|
||||
64: BigInt(14695981039346656037),
|
||||
128: BigInt(144066263297769815596495629667062367629),
|
||||
256: BigInt(100029257958052580907070968620625704837092796014241193945225284501741471925557),
|
||||
512: BigInt(9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785),
|
||||
1024: BigInt(14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915)
|
||||
};
|
||||
export default function fnv1a(inputString, param) {
|
||||
let { size = 32, seed = 0 } = param === void 0 ? {} : param;
|
||||
if (!FNV_PRIMES[size]) {
|
||||
throw Object.defineProperty(new Error('The `size` option must be one of 32, 64, 128, 256, 512, or 1024'), "__NEXT_ERROR_CODE", {
|
||||
value: "E462",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
let hash = FNV_OFFSETS[size] ^ BigInt(seed);
|
||||
const fnvPrime = FNV_PRIMES[size];
|
||||
// Handle Unicode code points > 0x7f
|
||||
let isUnicoded = false;
|
||||
for(let index = 0; index < inputString.length; index++){
|
||||
let characterCode = inputString.charCodeAt(index);
|
||||
// Non-ASCII characters trigger the Unicode escape logic
|
||||
if (characterCode > 0x7f && !isUnicoded) {
|
||||
inputString = unescape(encodeURIComponent(inputString));
|
||||
characterCode = inputString.charCodeAt(index);
|
||||
isUnicoded = true;
|
||||
}
|
||||
hash ^= BigInt(characterCode);
|
||||
hash = BigInt.asUintN(size, hash * fnvPrime);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=fnv1a.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/fnv1a.ts"],"sourcesContent":["// source: https://github.com/sindresorhus/fnv1a\n// FNV_PRIMES and FNV_OFFSETS from\n// http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param\n/* eslint-disable @typescript-eslint/no-loss-of-precision */\n\nconst FNV_PRIMES = {\n 32: BigInt(16_777_619),\n 64: BigInt(1_099_511_628_211),\n 128: BigInt(309_485_009_821_345_068_724_781_371),\n 256: BigInt(\n 374_144_419_156_711_147_060_143_317_175_368_453_031_918_731_002_211\n ),\n 512: BigInt(\n 35_835_915_874_844_867_368_919_076_489_095_108_449_946_327_955_754_392_558_399_825_615_420_669_938_882_575_126_094_039_892_345_713_852_759\n ),\n 1024: BigInt(\n 5_016_456_510_113_118_655_434_598_811_035_278_955_030_765_345_404_790_744_303_017_523_831_112_055_108_147_451_509_157_692_220_295_382_716_162_651_878_526_895_249_385_292_291_816_524_375_083_746_691_371_804_094_271_873_160_484_737_966_720_260_389_217_684_476_157_468_082_573\n ),\n} as const\n\nconst FNV_OFFSETS = {\n 32: BigInt(2_166_136_261),\n 64: BigInt(14_695_981_039_346_656_037),\n 128: BigInt(144_066_263_297_769_815_596_495_629_667_062_367_629),\n 256: BigInt(\n 100_029_257_958_052_580_907_070_968_620_625_704_837_092_796_014_241_193_945_225_284_501_741_471_925_557\n ),\n 512: BigInt(\n 9_659_303_129_496_669_498_009_435_400_716_310_466_090_418_745_672_637_896_108_374_329_434_462_657_994_582_932_197_716_438_449_813_051_892_206_539_805_784_495_328_239_340_083_876_191_928_701_583_869_517_785\n ),\n 1024: BigInt(\n 14_197_795_064_947_621_068_722_070_641_403_218_320_880_622_795_441_933_960_878_474_914_617_582_723_252_296_732_303_717_722_150_864_096_521_202_355_549_365_628_174_669_108_571_814_760_471_015_076_148_029_755_969_804_077_320_157_692_458_563_003_215_304_957_150_157_403_644_460_363_550_505_412_711_285_966_361_610_267_868_082_893_823_963_790_439_336_411_086_884_584_107_735_010_676_915\n ),\n} as const\n\nexport default function fnv1a(\n inputString: string,\n {\n size = 32,\n seed = 0,\n }: {\n size?: keyof typeof FNV_PRIMES\n seed?: number\n } = {}\n) {\n if (!FNV_PRIMES[size]) {\n throw new Error(\n 'The `size` option must be one of 32, 64, 128, 256, 512, or 1024'\n )\n }\n\n let hash: bigint = FNV_OFFSETS[size] ^ BigInt(seed)\n const fnvPrime = FNV_PRIMES[size]\n\n // Handle Unicode code points > 0x7f\n let isUnicoded = false\n\n for (let index = 0; index < inputString.length; index++) {\n let characterCode = inputString.charCodeAt(index)\n\n // Non-ASCII characters trigger the Unicode escape logic\n if (characterCode > 0x7f && !isUnicoded) {\n inputString = unescape(encodeURIComponent(inputString))\n characterCode = inputString.charCodeAt(index)\n isUnicoded = true\n }\n\n hash ^= BigInt(characterCode)\n hash = BigInt.asUintN(size, hash * fnvPrime)\n }\n\n return hash\n}\n"],"names":["FNV_PRIMES","BigInt","FNV_OFFSETS","fnv1a","inputString","size","seed","Error","hash","fnvPrime","isUnicoded","index","length","characterCode","charCodeAt","unescape","encodeURIComponent","asUintN"],"mappings":"AAAA,gDAAgD;AAChD,kCAAkC;AAClC,iEAAiE;AACjE,0DAA0D,GAE1D,MAAMA,aAAa;IACjB,IAAIC,OAAO;IACX,IAAIA,OAAO;IACX,KAAKA,OAAO;IACZ,KAAKA,OACH;IAEF,KAAKA,OACH;IAEF,MAAMA,OACJ;AAEJ;AAEA,MAAMC,cAAc;IAClB,IAAID,OAAO;IACX,IAAIA,OAAO;IACX,KAAKA,OAAO;IACZ,KAAKA,OACH;IAEF,KAAKA,OACH;IAEF,MAAMA,OACJ;AAEJ;AAEA,eAAe,SAASE,MACtBC,WAAmB,EACnB;IAAA,IAAA,EACEC,OAAO,EAAE,EACTC,OAAO,CAAC,EAIT,GAND,mBAMI,CAAC,IANL;IAQA,IAAI,CAACN,UAAU,CAACK,KAAK,EAAE;QACrB,MAAM,qBAEL,CAFK,IAAIE,MACR,oEADI,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,IAAIC,OAAeN,WAAW,CAACG,KAAK,GAAGJ,OAAOK;IAC9C,MAAMG,WAAWT,UAAU,CAACK,KAAK;IAEjC,oCAAoC;IACpC,IAAIK,aAAa;IAEjB,IAAK,IAAIC,QAAQ,GAAGA,QAAQP,YAAYQ,MAAM,EAAED,QAAS;QACvD,IAAIE,gBAAgBT,YAAYU,UAAU,CAACH;QAE3C,wDAAwD;QACxD,IAAIE,gBAAgB,QAAQ,CAACH,YAAY;YACvCN,cAAcW,SAASC,mBAAmBZ;YAC1CS,gBAAgBT,YAAYU,UAAU,CAACH;YACvCD,aAAa;QACf;QAEAF,QAAQP,OAAOY;QACfL,OAAOP,OAAOgB,OAAO,CAACZ,MAAMG,OAAOC;IACrC;IAEA,OAAOD;AACT"}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Takes an object with a hostname property (like a parsed URL) and some
|
||||
* headers that may contain Host and returns the preferred hostname.
|
||||
* @param parsed An object containing a hostname property.
|
||||
* @param headers A dictionary with headers containing a `host`.
|
||||
*/ export function getHostname(parsed, headers) {
|
||||
// Get the hostname from the headers if it exists, otherwise use the parsed
|
||||
// hostname.
|
||||
let hostname;
|
||||
if ((headers == null ? void 0 : headers.host) && !Array.isArray(headers.host)) {
|
||||
hostname = headers.host.toString().split(':', 1)[0];
|
||||
} else if (parsed.hostname) {
|
||||
hostname = parsed.hostname;
|
||||
} else return;
|
||||
return hostname.toLowerCase();
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-hostname.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/get-hostname.ts"],"sourcesContent":["import type { OutgoingHttpHeaders } from 'http'\n\n/**\n * Takes an object with a hostname property (like a parsed URL) and some\n * headers that may contain Host and returns the preferred hostname.\n * @param parsed An object containing a hostname property.\n * @param headers A dictionary with headers containing a `host`.\n */\nexport function getHostname(\n parsed: { hostname?: string | null },\n headers?: OutgoingHttpHeaders\n): string | undefined {\n // Get the hostname from the headers if it exists, otherwise use the parsed\n // hostname.\n let hostname: string\n if (headers?.host && !Array.isArray(headers.host)) {\n hostname = headers.host.toString().split(':', 1)[0]\n } else if (parsed.hostname) {\n hostname = parsed.hostname\n } else return\n\n return hostname.toLowerCase()\n}\n"],"names":["getHostname","parsed","headers","hostname","host","Array","isArray","toString","split","toLowerCase"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,SAASA,YACdC,MAAoC,EACpCC,OAA6B;IAE7B,2EAA2E;IAC3E,YAAY;IACZ,IAAIC;IACJ,IAAID,CAAAA,2BAAAA,QAASE,IAAI,KAAI,CAACC,MAAMC,OAAO,CAACJ,QAAQE,IAAI,GAAG;QACjDD,WAAWD,QAAQE,IAAI,CAACG,QAAQ,GAAGC,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE;IACrD,OAAO,IAAIP,OAAOE,QAAQ,EAAE;QAC1BA,WAAWF,OAAOE,QAAQ;IAC5B,OAAO;IAEP,OAAOA,SAASM,WAAW;AAC7B"}
|
||||
+540
@@ -0,0 +1,540 @@
|
||||
import { warnOnce } from './utils/warn-once';
|
||||
import { getImageBlurSvg } from './image-blur-svg';
|
||||
import { imageConfigDefault } from './image-config';
|
||||
const VALID_LOADING_VALUES = [
|
||||
'lazy',
|
||||
'eager',
|
||||
undefined
|
||||
];
|
||||
// Object-fit values that are not valid background-size values
|
||||
const INVALID_BACKGROUND_SIZE_VALUES = [
|
||||
'-moz-initial',
|
||||
'fill',
|
||||
'none',
|
||||
'scale-down',
|
||||
undefined
|
||||
];
|
||||
function isStaticRequire(src) {
|
||||
return src.default !== undefined;
|
||||
}
|
||||
function isStaticImageData(src) {
|
||||
return src.src !== undefined;
|
||||
}
|
||||
function isStaticImport(src) {
|
||||
return !!src && typeof src === 'object' && (isStaticRequire(src) || isStaticImageData(src));
|
||||
}
|
||||
const allImgs = new Map();
|
||||
let perfObserver;
|
||||
function getInt(x) {
|
||||
if (typeof x === 'undefined') {
|
||||
return x;
|
||||
}
|
||||
if (typeof x === 'number') {
|
||||
return Number.isFinite(x) ? x : NaN;
|
||||
}
|
||||
if (typeof x === 'string' && /^[0-9]+$/.test(x)) {
|
||||
return parseInt(x, 10);
|
||||
}
|
||||
return NaN;
|
||||
}
|
||||
function getWidths(param, width, sizes) {
|
||||
let { deviceSizes, allSizes } = param;
|
||||
if (sizes) {
|
||||
// Find all the "vw" percent sizes used in the sizes prop
|
||||
const viewportWidthRe = /(^|\s)(1?\d?\d)vw/g;
|
||||
const percentSizes = [];
|
||||
for(let match; match = viewportWidthRe.exec(sizes); match){
|
||||
percentSizes.push(parseInt(match[2]));
|
||||
}
|
||||
if (percentSizes.length) {
|
||||
const smallestRatio = Math.min(...percentSizes) * 0.01;
|
||||
return {
|
||||
widths: allSizes.filter((s)=>s >= deviceSizes[0] * smallestRatio),
|
||||
kind: 'w'
|
||||
};
|
||||
}
|
||||
return {
|
||||
widths: allSizes,
|
||||
kind: 'w'
|
||||
};
|
||||
}
|
||||
if (typeof width !== 'number') {
|
||||
return {
|
||||
widths: deviceSizes,
|
||||
kind: 'w'
|
||||
};
|
||||
}
|
||||
const widths = [
|
||||
...new Set(// > This means that most OLED screens that say they are 3x resolution,
|
||||
// > are actually 3x in the green color, but only 1.5x in the red and
|
||||
// > blue colors. Showing a 3x resolution image in the app vs a 2x
|
||||
// > resolution image will be visually the same, though the 3x image
|
||||
// > takes significantly more data. Even true 3x resolution screens are
|
||||
// > wasteful as the human eye cannot see that level of detail without
|
||||
// > something like a magnifying glass.
|
||||
// https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/capping-image-fidelity-on-ultra-high-resolution-devices.html
|
||||
[
|
||||
width,
|
||||
width * 2 /*, width * 3*/
|
||||
].map((w)=>allSizes.find((p)=>p >= w) || allSizes[allSizes.length - 1]))
|
||||
];
|
||||
return {
|
||||
widths,
|
||||
kind: 'x'
|
||||
};
|
||||
}
|
||||
function generateImgAttrs(param) {
|
||||
let { config, src, unoptimized, width, quality, sizes, loader } = param;
|
||||
if (unoptimized) {
|
||||
return {
|
||||
src,
|
||||
srcSet: undefined,
|
||||
sizes: undefined
|
||||
};
|
||||
}
|
||||
const { widths, kind } = getWidths(config, width, sizes);
|
||||
const last = widths.length - 1;
|
||||
return {
|
||||
sizes: !sizes && kind === 'w' ? '100vw' : sizes,
|
||||
srcSet: widths.map((w, i)=>loader({
|
||||
config,
|
||||
src,
|
||||
quality,
|
||||
width: w
|
||||
}) + " " + (kind === 'w' ? w : i + 1) + kind).join(', '),
|
||||
// It's intended to keep `src` the last attribute because React updates
|
||||
// attributes in order. If we keep `src` the first one, Safari will
|
||||
// immediately start to fetch `src`, before `sizes` and `srcSet` are even
|
||||
// updated by React. That causes multiple unnecessary requests if `srcSet`
|
||||
// and `sizes` are defined.
|
||||
// This bug cannot be reproduced in Chrome or Firefox.
|
||||
src: loader({
|
||||
config,
|
||||
src,
|
||||
quality,
|
||||
width: widths[last]
|
||||
})
|
||||
};
|
||||
}
|
||||
/**
|
||||
* A shared function, used on both client and server, to generate the props for <img>.
|
||||
*/ export function getImgProps(param, _state) {
|
||||
let { src, sizes, unoptimized = false, priority = false, loading, className, quality, width, height, fill = false, style, overrideSrc, onLoad, onLoadingComplete, placeholder = 'empty', blurDataURL, fetchPriority, decoding = 'async', layout, objectFit, objectPosition, lazyBoundary, lazyRoot, ...rest } = param;
|
||||
const { imgConf, showAltText, blurComplete, defaultLoader } = _state;
|
||||
let config;
|
||||
let c = imgConf || imageConfigDefault;
|
||||
if ('allSizes' in c) {
|
||||
config = c;
|
||||
} else {
|
||||
var _c_qualities;
|
||||
const allSizes = [
|
||||
...c.deviceSizes,
|
||||
...c.imageSizes
|
||||
].sort((a, b)=>a - b);
|
||||
const deviceSizes = c.deviceSizes.sort((a, b)=>a - b);
|
||||
const qualities = (_c_qualities = c.qualities) == null ? void 0 : _c_qualities.sort((a, b)=>a - b);
|
||||
config = {
|
||||
...c,
|
||||
allSizes,
|
||||
deviceSizes,
|
||||
qualities
|
||||
};
|
||||
}
|
||||
if (typeof defaultLoader === 'undefined') {
|
||||
throw Object.defineProperty(new Error('images.loaderFile detected but the file is missing default export.\nRead more: https://nextjs.org/docs/messages/invalid-images-config'), "__NEXT_ERROR_CODE", {
|
||||
value: "E163",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
let loader = rest.loader || defaultLoader;
|
||||
// Remove property so it's not spread on <img> element
|
||||
delete rest.loader;
|
||||
delete rest.srcSet;
|
||||
// This special value indicates that the user
|
||||
// didn't define a "loader" prop or "loader" config.
|
||||
const isDefaultLoader = '__next_img_default' in loader;
|
||||
if (isDefaultLoader) {
|
||||
if (config.loader === 'custom') {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" is missing "loader" prop.' + "\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader"), "__NEXT_ERROR_CODE", {
|
||||
value: "E252",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// The user defined a "loader" prop or config.
|
||||
// Since the config object is internal only, we
|
||||
// must not pass it to the user-defined "loader".
|
||||
const customImageLoader = loader;
|
||||
loader = (obj)=>{
|
||||
const { config: _, ...opts } = obj;
|
||||
return customImageLoader(opts);
|
||||
};
|
||||
}
|
||||
if (layout) {
|
||||
if (layout === 'fill') {
|
||||
fill = true;
|
||||
}
|
||||
const layoutToStyle = {
|
||||
intrinsic: {
|
||||
maxWidth: '100%',
|
||||
height: 'auto'
|
||||
},
|
||||
responsive: {
|
||||
width: '100%',
|
||||
height: 'auto'
|
||||
}
|
||||
};
|
||||
const layoutToSizes = {
|
||||
responsive: '100vw',
|
||||
fill: '100vw'
|
||||
};
|
||||
const layoutStyle = layoutToStyle[layout];
|
||||
if (layoutStyle) {
|
||||
style = {
|
||||
...style,
|
||||
...layoutStyle
|
||||
};
|
||||
}
|
||||
const layoutSizes = layoutToSizes[layout];
|
||||
if (layoutSizes && !sizes) {
|
||||
sizes = layoutSizes;
|
||||
}
|
||||
}
|
||||
let staticSrc = '';
|
||||
let widthInt = getInt(width);
|
||||
let heightInt = getInt(height);
|
||||
let blurWidth;
|
||||
let blurHeight;
|
||||
if (isStaticImport(src)) {
|
||||
const staticImageData = isStaticRequire(src) ? src.default : src;
|
||||
if (!staticImageData.src) {
|
||||
throw Object.defineProperty(new Error("An object should only be passed to the image component src parameter if it comes from a static image import. It must include src. Received " + JSON.stringify(staticImageData)), "__NEXT_ERROR_CODE", {
|
||||
value: "E460",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (!staticImageData.height || !staticImageData.width) {
|
||||
throw Object.defineProperty(new Error("An object should only be passed to the image component src parameter if it comes from a static image import. It must include height and width. Received " + JSON.stringify(staticImageData)), "__NEXT_ERROR_CODE", {
|
||||
value: "E48",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
blurWidth = staticImageData.blurWidth;
|
||||
blurHeight = staticImageData.blurHeight;
|
||||
blurDataURL = blurDataURL || staticImageData.blurDataURL;
|
||||
staticSrc = staticImageData.src;
|
||||
if (!fill) {
|
||||
if (!widthInt && !heightInt) {
|
||||
widthInt = staticImageData.width;
|
||||
heightInt = staticImageData.height;
|
||||
} else if (widthInt && !heightInt) {
|
||||
const ratio = widthInt / staticImageData.width;
|
||||
heightInt = Math.round(staticImageData.height * ratio);
|
||||
} else if (!widthInt && heightInt) {
|
||||
const ratio = heightInt / staticImageData.height;
|
||||
widthInt = Math.round(staticImageData.width * ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
src = typeof src === 'string' ? src : staticSrc;
|
||||
let isLazy = !priority && (loading === 'lazy' || typeof loading === 'undefined');
|
||||
if (!src || src.startsWith('data:') || src.startsWith('blob:')) {
|
||||
// https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
|
||||
unoptimized = true;
|
||||
isLazy = false;
|
||||
}
|
||||
if (config.unoptimized) {
|
||||
unoptimized = true;
|
||||
}
|
||||
if (isDefaultLoader && !config.dangerouslyAllowSVG && src.split('?', 1)[0].endsWith('.svg')) {
|
||||
// Special case to make svg serve as-is to avoid proxying
|
||||
// through the built-in Image Optimization API.
|
||||
unoptimized = true;
|
||||
}
|
||||
const qualityInt = getInt(quality);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (config.output === 'export' && isDefaultLoader && !unoptimized) {
|
||||
throw Object.defineProperty(new Error("Image Optimization using the default loader is not compatible with `{ output: 'export' }`.\n Possible solutions:\n - Remove `{ output: 'export' }` and run \"next start\" to run server mode including the Image Optimization API.\n - Configure `{ images: { unoptimized: true } }` in `next.config.js` to disable the Image Optimization API.\n Read more: https://nextjs.org/docs/messages/export-image-api"), "__NEXT_ERROR_CODE", {
|
||||
value: "E500",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (!src) {
|
||||
// React doesn't show the stack trace and there's
|
||||
// no `src` to help identify which image, so we
|
||||
// instead console.error(ref) during mount.
|
||||
unoptimized = true;
|
||||
} else {
|
||||
if (fill) {
|
||||
if (width) {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has both "width" and "fill" properties. Only one should be used.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E96",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (height) {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has both "height" and "fill" properties. Only one should be used.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E115",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if ((style == null ? void 0 : style.position) && style.position !== 'absolute') {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has both "fill" and "style.position" properties. Images with "fill" always use position absolute - it cannot be modified.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E216",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if ((style == null ? void 0 : style.width) && style.width !== '100%') {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has both "fill" and "style.width" properties. Images with "fill" always use width 100% - it cannot be modified.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E73",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if ((style == null ? void 0 : style.height) && style.height !== '100%') {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has both "fill" and "style.height" properties. Images with "fill" always use height 100% - it cannot be modified.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E404",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (typeof widthInt === 'undefined') {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" is missing required "width" property.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E451",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else if (isNaN(widthInt)) {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has invalid "width" property. Expected a numeric value in pixels but received "' + width + '".'), "__NEXT_ERROR_CODE", {
|
||||
value: "E66",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (typeof heightInt === 'undefined') {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" is missing required "height" property.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E397",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else if (isNaN(heightInt)) {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has invalid "height" property. Expected a numeric value in pixels but received "' + height + '".'), "__NEXT_ERROR_CODE", {
|
||||
value: "E444",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line no-control-regex
|
||||
if (/^[\x00-\x20]/.test(src)) {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" cannot start with a space or control character. Use src.trimStart() to remove it or encodeURIComponent(src) to keep it.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E176",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line no-control-regex
|
||||
if (/[\x00-\x20]$/.test(src)) {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" cannot end with a space or control character. Use src.trimEnd() to remove it or encodeURIComponent(src) to keep it.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E21",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!VALID_LOADING_VALUES.includes(loading)) {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has invalid "loading" property. Provided "' + loading + '" should be one of ' + VALID_LOADING_VALUES.map(String).join(',') + "."), "__NEXT_ERROR_CODE", {
|
||||
value: "E357",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (priority && loading === 'lazy') {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has both "priority" and "loading=\'lazy\'" properties. Only one should be used.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E218",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (placeholder !== 'empty' && placeholder !== 'blur' && !placeholder.startsWith('data:image/')) {
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has invalid "placeholder" property "' + placeholder + '".'), "__NEXT_ERROR_CODE", {
|
||||
value: "E431",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (placeholder !== 'empty') {
|
||||
if (widthInt && heightInt && widthInt * heightInt < 1600) {
|
||||
warnOnce('Image with src "' + src + '" is smaller than 40x40. Consider removing the "placeholder" property to improve performance.');
|
||||
}
|
||||
}
|
||||
if (placeholder === 'blur' && !blurDataURL) {
|
||||
const VALID_BLUR_EXT = [
|
||||
'jpeg',
|
||||
'png',
|
||||
'webp',
|
||||
'avif'
|
||||
] // should match next-image-loader
|
||||
;
|
||||
throw Object.defineProperty(new Error('Image with src "' + src + '" has "placeholder=\'blur\'" property but is missing the "blurDataURL" property.\n Possible solutions:\n - Add a "blurDataURL" property, the contents should be a small Data URL to represent the image\n - Change the "src" property to a static import with one of the supported file types: ' + VALID_BLUR_EXT.join(',') + ' (animated images not supported)\n - Remove the "placeholder" property, effectively no blur effect\n Read more: https://nextjs.org/docs/messages/placeholder-blur-data-url'), "__NEXT_ERROR_CODE", {
|
||||
value: "E371",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if ('ref' in rest) {
|
||||
warnOnce('Image with src "' + src + '" is using unsupported "ref" property. Consider using the "onLoad" property instead.');
|
||||
}
|
||||
if (!unoptimized && !isDefaultLoader) {
|
||||
const urlStr = loader({
|
||||
config,
|
||||
src,
|
||||
width: widthInt || 400,
|
||||
quality: qualityInt || 75
|
||||
});
|
||||
let url;
|
||||
try {
|
||||
url = new URL(urlStr);
|
||||
} catch (err) {}
|
||||
if (urlStr === src || url && url.pathname === src && !url.search) {
|
||||
warnOnce('Image with src "' + src + '" has a "loader" property that does not implement width. Please implement it or use the "unoptimized" property instead.' + "\nRead more: https://nextjs.org/docs/messages/next-image-missing-loader-width");
|
||||
}
|
||||
}
|
||||
if (onLoadingComplete) {
|
||||
warnOnce('Image with src "' + src + '" is using deprecated "onLoadingComplete" property. Please use the "onLoad" property instead.');
|
||||
}
|
||||
for (const [legacyKey, legacyValue] of Object.entries({
|
||||
layout,
|
||||
objectFit,
|
||||
objectPosition,
|
||||
lazyBoundary,
|
||||
lazyRoot
|
||||
})){
|
||||
if (legacyValue) {
|
||||
warnOnce('Image with src "' + src + '" has legacy prop "' + legacyKey + '". Did you forget to run the codemod?' + "\nRead more: https://nextjs.org/docs/messages/next-image-upgrade-to-13");
|
||||
}
|
||||
}
|
||||
if (typeof window !== 'undefined' && !perfObserver && window.PerformanceObserver) {
|
||||
perfObserver = new PerformanceObserver((entryList)=>{
|
||||
for (const entry of entryList.getEntries()){
|
||||
var _entry_element;
|
||||
// @ts-ignore - missing "LargestContentfulPaint" class with "element" prop
|
||||
const imgSrc = (entry == null ? void 0 : (_entry_element = entry.element) == null ? void 0 : _entry_element.src) || '';
|
||||
const lcpImage = allImgs.get(imgSrc);
|
||||
if (lcpImage && !lcpImage.priority && lcpImage.placeholder === 'empty' && !lcpImage.src.startsWith('data:') && !lcpImage.src.startsWith('blob:')) {
|
||||
// https://web.dev/lcp/#measure-lcp-in-javascript
|
||||
warnOnce('Image with src "' + lcpImage.src + '" was detected as the Largest Contentful Paint (LCP). Please add the "priority" property if this image is above the fold.' + "\nRead more: https://nextjs.org/docs/api-reference/next/image#priority");
|
||||
}
|
||||
}
|
||||
});
|
||||
try {
|
||||
perfObserver.observe({
|
||||
type: 'largest-contentful-paint',
|
||||
buffered: true
|
||||
});
|
||||
} catch (err) {
|
||||
// Log error but don't crash the app
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
const imgStyle = Object.assign(fill ? {
|
||||
position: 'absolute',
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
left: 0,
|
||||
top: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
objectFit,
|
||||
objectPosition
|
||||
} : {}, showAltText ? {} : {
|
||||
color: 'transparent'
|
||||
}, style);
|
||||
const backgroundImage = !blurComplete && placeholder !== 'empty' ? placeholder === 'blur' ? 'url("data:image/svg+xml;charset=utf-8,' + getImageBlurSvg({
|
||||
widthInt,
|
||||
heightInt,
|
||||
blurWidth,
|
||||
blurHeight,
|
||||
blurDataURL: blurDataURL || '',
|
||||
objectFit: imgStyle.objectFit
|
||||
}) + '")' : 'url("' + placeholder + '")' // assume `data:image/`
|
||||
: null;
|
||||
const backgroundSize = !INVALID_BACKGROUND_SIZE_VALUES.includes(imgStyle.objectFit) ? imgStyle.objectFit : imgStyle.objectFit === 'fill' ? '100% 100%' // the background-size equivalent of `fill`
|
||||
: 'cover';
|
||||
let placeholderStyle = backgroundImage ? {
|
||||
backgroundSize,
|
||||
backgroundPosition: imgStyle.objectPosition || '50% 50%',
|
||||
backgroundRepeat: 'no-repeat',
|
||||
backgroundImage
|
||||
} : {};
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (placeholderStyle.backgroundImage && placeholder === 'blur' && (blurDataURL == null ? void 0 : blurDataURL.startsWith('/'))) {
|
||||
// During `next dev`, we don't want to generate blur placeholders with webpack
|
||||
// because it can delay starting the dev server. Instead, `next-image-loader.js`
|
||||
// will inline a special url to lazily generate the blur placeholder at request time.
|
||||
placeholderStyle.backgroundImage = 'url("' + blurDataURL + '")';
|
||||
}
|
||||
}
|
||||
const imgAttributes = generateImgAttrs({
|
||||
config,
|
||||
src,
|
||||
unoptimized,
|
||||
width: widthInt,
|
||||
quality: qualityInt,
|
||||
sizes,
|
||||
loader
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (typeof window !== 'undefined') {
|
||||
let fullUrl;
|
||||
try {
|
||||
fullUrl = new URL(imgAttributes.src);
|
||||
} catch (e) {
|
||||
fullUrl = new URL(imgAttributes.src, window.location.href);
|
||||
}
|
||||
allImgs.set(fullUrl.href, {
|
||||
src,
|
||||
priority,
|
||||
placeholder
|
||||
});
|
||||
}
|
||||
}
|
||||
const props = {
|
||||
...rest,
|
||||
loading: isLazy ? 'lazy' : loading,
|
||||
fetchPriority,
|
||||
width: widthInt,
|
||||
height: heightInt,
|
||||
decoding,
|
||||
className,
|
||||
style: {
|
||||
...imgStyle,
|
||||
...placeholderStyle
|
||||
},
|
||||
sizes: imgAttributes.sizes,
|
||||
srcSet: imgAttributes.srcSet,
|
||||
src: overrideSrc || imgAttributes.src
|
||||
};
|
||||
const meta = {
|
||||
unoptimized,
|
||||
priority,
|
||||
placeholder,
|
||||
fill
|
||||
};
|
||||
return {
|
||||
props,
|
||||
meta
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-img-props.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/get-img-props.ts"],"sourcesContent":["import { warnOnce } from './utils/warn-once'\nimport { getImageBlurSvg } from './image-blur-svg'\nimport { imageConfigDefault } from './image-config'\nimport type {\n ImageConfigComplete,\n ImageLoaderProps,\n ImageLoaderPropsWithConfig,\n} from './image-config'\n\nimport type { CSSProperties, JSX } from 'react'\n\nexport interface StaticImageData {\n src: string\n height: number\n width: number\n blurDataURL?: string\n blurWidth?: number\n blurHeight?: number\n}\n\nexport interface StaticRequire {\n default: StaticImageData\n}\n\nexport type StaticImport = StaticRequire | StaticImageData\n\nexport type ImageProps = Omit<\n JSX.IntrinsicElements['img'],\n 'src' | 'srcSet' | 'ref' | 'alt' | 'width' | 'height' | 'loading'\n> & {\n src: string | StaticImport\n alt: string\n width?: number | `${number}`\n height?: number | `${number}`\n fill?: boolean\n loader?: ImageLoader\n quality?: number | `${number}`\n priority?: boolean\n loading?: LoadingValue\n placeholder?: PlaceholderValue\n blurDataURL?: string\n unoptimized?: boolean\n overrideSrc?: string\n /**\n * @deprecated Use `onLoad` instead.\n * @see https://nextjs.org/docs/app/api-reference/components/image#onload\n */\n onLoadingComplete?: OnLoadingComplete\n /**\n * @deprecated Use `fill` prop instead of `layout=\"fill\"` or change import to `next/legacy/image`.\n * @see https://nextjs.org/docs/api-reference/next/legacy/image\n */\n layout?: string\n /**\n * @deprecated Use `style` prop instead.\n */\n objectFit?: string\n /**\n * @deprecated Use `style` prop instead.\n */\n objectPosition?: string\n /**\n * @deprecated This prop does not do anything.\n */\n lazyBoundary?: string\n /**\n * @deprecated This prop does not do anything.\n */\n lazyRoot?: string\n}\n\nexport type ImgProps = Omit<ImageProps, 'src' | 'loader'> & {\n loading: LoadingValue\n width: number | undefined\n height: number | undefined\n style: NonNullable<JSX.IntrinsicElements['img']['style']>\n sizes: string | undefined\n srcSet: string | undefined\n src: string\n}\n\nconst VALID_LOADING_VALUES = ['lazy', 'eager', undefined] as const\n\n// Object-fit values that are not valid background-size values\nconst INVALID_BACKGROUND_SIZE_VALUES = [\n '-moz-initial',\n 'fill',\n 'none',\n 'scale-down',\n undefined,\n]\ntype LoadingValue = (typeof VALID_LOADING_VALUES)[number]\ntype ImageConfig = ImageConfigComplete & {\n allSizes: number[]\n output?: 'standalone' | 'export'\n}\n\nexport type ImageLoader = (p: ImageLoaderProps) => string\n\n// Do not export - this is an internal type only\n// because `next.config.js` is only meant for the\n// built-in loaders, not for a custom loader() prop.\ntype ImageLoaderWithConfig = (p: ImageLoaderPropsWithConfig) => string\n\nexport type PlaceholderValue = 'blur' | 'empty' | `data:image/${string}`\nexport type OnLoad = React.ReactEventHandler<HTMLImageElement> | undefined\nexport type OnLoadingComplete = (img: HTMLImageElement) => void\n\nexport type PlaceholderStyle = Partial<\n Pick<\n CSSProperties,\n | 'backgroundSize'\n | 'backgroundPosition'\n | 'backgroundRepeat'\n | 'backgroundImage'\n >\n>\n\nfunction isStaticRequire(\n src: StaticRequire | StaticImageData\n): src is StaticRequire {\n return (src as StaticRequire).default !== undefined\n}\n\nfunction isStaticImageData(\n src: StaticRequire | StaticImageData\n): src is StaticImageData {\n return (src as StaticImageData).src !== undefined\n}\n\nfunction isStaticImport(src: string | StaticImport): src is StaticImport {\n return (\n !!src &&\n typeof src === 'object' &&\n (isStaticRequire(src as StaticImport) ||\n isStaticImageData(src as StaticImport))\n )\n}\n\nconst allImgs = new Map<\n string,\n { src: string; priority: boolean; placeholder: PlaceholderValue }\n>()\nlet perfObserver: PerformanceObserver | undefined\n\nfunction getInt(x: unknown): number | undefined {\n if (typeof x === 'undefined') {\n return x\n }\n if (typeof x === 'number') {\n return Number.isFinite(x) ? x : NaN\n }\n if (typeof x === 'string' && /^[0-9]+$/.test(x)) {\n return parseInt(x, 10)\n }\n return NaN\n}\n\nfunction getWidths(\n { deviceSizes, allSizes }: ImageConfig,\n width: number | undefined,\n sizes: string | undefined\n): { widths: number[]; kind: 'w' | 'x' } {\n if (sizes) {\n // Find all the \"vw\" percent sizes used in the sizes prop\n const viewportWidthRe = /(^|\\s)(1?\\d?\\d)vw/g\n const percentSizes = []\n for (let match; (match = viewportWidthRe.exec(sizes)); match) {\n percentSizes.push(parseInt(match[2]))\n }\n if (percentSizes.length) {\n const smallestRatio = Math.min(...percentSizes) * 0.01\n return {\n widths: allSizes.filter((s) => s >= deviceSizes[0] * smallestRatio),\n kind: 'w',\n }\n }\n return { widths: allSizes, kLine truncated
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import { warnOnce } from '../../build/output/log';
|
||||
export function getRspackCore() {
|
||||
warnRspack();
|
||||
try {
|
||||
const paths = [
|
||||
require.resolve('next-rspack')
|
||||
];
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
return require(require.resolve('@rspack/core', {
|
||||
paths
|
||||
}));
|
||||
} catch (e) {
|
||||
if (e instanceof Error && 'code' in e && e.code === 'MODULE_NOT_FOUND') {
|
||||
throw Object.defineProperty(new Error('@rspack/core is not available. Please make sure `next-rspack` is correctly installed.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E647",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
export function getRspackReactRefresh() {
|
||||
warnRspack();
|
||||
try {
|
||||
const paths = [
|
||||
require.resolve('next-rspack')
|
||||
];
|
||||
// eslint-disable-next-line import/no-extraneous-dependencies
|
||||
const plugin = require(require.resolve('@rspack/plugin-react-refresh', {
|
||||
paths
|
||||
}));
|
||||
const entry = require.resolve('@rspack/plugin-react-refresh/react-refresh-entry', {
|
||||
paths
|
||||
});
|
||||
plugin.entry = entry;
|
||||
return plugin;
|
||||
} catch (e) {
|
||||
if (e instanceof Error && 'code' in e && e.code === 'MODULE_NOT_FOUND') {
|
||||
throw Object.defineProperty(new Error('@rspack/plugin-react-refresh is not available. Please make sure `next-rspack` is correctly installed.'), "__NEXT_ERROR_CODE", {
|
||||
value: "E648",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
function warnRspack() {
|
||||
warnOnce("`next-rspack` is currently experimental. It's not an official Next.js plugin, and is supported by the Rspack team in partnership with Next.js. Help improve Next.js and Rspack by providing feedback at https://github.com/vercel/next.js/discussions/77800");
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-rspack.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/get-rspack.ts"],"sourcesContent":["import { warnOnce } from '../../build/output/log'\n\nexport function getRspackCore() {\n warnRspack()\n try {\n const paths = [require.resolve('next-rspack')]\n // eslint-disable-next-line import/no-extraneous-dependencies\n return require(require.resolve('@rspack/core', { paths }))\n } catch (e) {\n if (e instanceof Error && 'code' in e && e.code === 'MODULE_NOT_FOUND') {\n throw new Error(\n '@rspack/core is not available. Please make sure `next-rspack` is correctly installed.'\n )\n }\n\n throw e\n }\n}\n\nexport function getRspackReactRefresh() {\n warnRspack()\n try {\n const paths = [require.resolve('next-rspack')]\n // eslint-disable-next-line import/no-extraneous-dependencies\n const plugin = require(\n require.resolve('@rspack/plugin-react-refresh', { paths })\n )\n const entry = require.resolve(\n '@rspack/plugin-react-refresh/react-refresh-entry',\n { paths }\n )\n plugin.entry = entry\n return plugin\n } catch (e) {\n if (e instanceof Error && 'code' in e && e.code === 'MODULE_NOT_FOUND') {\n throw new Error(\n '@rspack/plugin-react-refresh is not available. Please make sure `next-rspack` is correctly installed.'\n )\n }\n\n throw e\n }\n}\n\nfunction warnRspack() {\n warnOnce(\n `\\`next-rspack\\` is currently experimental. It's not an official Next.js plugin, and is supported by the Rspack team in partnership with Next.js. Help improve Next.js and Rspack by providing feedback at https://github.com/vercel/next.js/discussions/77800`\n )\n}\n"],"names":["warnOnce","getRspackCore","warnRspack","paths","require","resolve","e","Error","code","getRspackReactRefresh","plugin","entry"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,yBAAwB;AAEjD,OAAO,SAASC;IACdC;IACA,IAAI;QACF,MAAMC,QAAQ;YAACC,QAAQC,OAAO,CAAC;SAAe;QAC9C,6DAA6D;QAC7D,OAAOD,QAAQA,QAAQC,OAAO,CAAC,gBAAgB;YAAEF;QAAM;IACzD,EAAE,OAAOG,GAAG;QACV,IAAIA,aAAaC,SAAS,UAAUD,KAAKA,EAAEE,IAAI,KAAK,oBAAoB;YACtE,MAAM,qBAEL,CAFK,IAAID,MACR,0FADI,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF;QAEA,MAAMD;IACR;AACF;AAEA,OAAO,SAASG;IACdP;IACA,IAAI;QACF,MAAMC,QAAQ;YAACC,QAAQC,OAAO,CAAC;SAAe;QAC9C,6DAA6D;QAC7D,MAAMK,SAASN,QACbA,QAAQC,OAAO,CAAC,gCAAgC;YAAEF;QAAM;QAE1D,MAAMQ,QAAQP,QAAQC,OAAO,CAC3B,oDACA;YAAEF;QAAM;QAEVO,OAAOC,KAAK,GAAGA;QACf,OAAOD;IACT,EAAE,OAAOJ,GAAG;QACV,IAAIA,aAAaC,SAAS,UAAUD,KAAKA,EAAEE,IAAI,KAAK,oBAAoB;YACtE,MAAM,qBAEL,CAFK,IAAID,MACR,0GADI,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF;QAEA,MAAMD;IACR;AACF;AAEA,SAASJ;IACPF,SACG;AAEL"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import { webpack } from 'next/dist/compiled/webpack/webpack';
|
||||
import { getRspackCore } from './get-rspack';
|
||||
/**
|
||||
* Depending on if Rspack is active or not, returns the appropriate set of
|
||||
* webpack-compatible api.
|
||||
*
|
||||
* @returns webpack bundler
|
||||
*/ export default function getWebpackBundler() {
|
||||
return process.env.NEXT_RSPACK ? getRspackCore() : webpack;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-webpack-bundler.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/get-webpack-bundler.ts"],"sourcesContent":["import { webpack } from 'next/dist/compiled/webpack/webpack'\nimport { getRspackCore } from './get-rspack'\n\n/**\n * Depending on if Rspack is active or not, returns the appropriate set of\n * webpack-compatible api.\n *\n * @returns webpack bundler\n */\nexport default function getWebpackBundler(): typeof webpack {\n return process.env.NEXT_RSPACK ? getRspackCore() : webpack\n}\n"],"names":["webpack","getRspackCore","getWebpackBundler","process","env","NEXT_RSPACK"],"mappings":"AAAA,SAASA,OAAO,QAAQ,qCAAoC;AAC5D,SAASC,aAAa,QAAQ,eAAc;AAE5C;;;;;CAKC,GACD,eAAe,SAASC;IACtB,OAAOC,QAAQC,GAAG,CAACC,WAAW,GAAGJ,kBAAkBD;AACrD"}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// http://www.cse.yorku.ca/~oz/hash.html
|
||||
// More specifically, 32-bit hash via djbxor
|
||||
// (ref: https://gist.github.com/eplawless/52813b1d8ad9af510d85?permalink_comment_id=3367765#gistcomment-3367765)
|
||||
// This is due to number type differences between rust for turbopack to js number types,
|
||||
// where rust does not have easy way to repreesnt js's 53-bit float number type for the matching
|
||||
// overflow behavior. This is more `correct` in terms of having canonical hash across different runtime / implementation
|
||||
// as can gaurantee determinstic output from 32bit hash.
|
||||
export function djb2Hash(str) {
|
||||
let hash = 5381;
|
||||
for(let i = 0; i < str.length; i++){
|
||||
const char = str.charCodeAt(i);
|
||||
hash = (hash << 5) + hash + char & 0xffffffff;
|
||||
}
|
||||
return hash >>> 0;
|
||||
}
|
||||
export function hexHash(str) {
|
||||
return djb2Hash(str).toString(36).slice(0, 5);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=hash.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/hash.ts"],"sourcesContent":["// http://www.cse.yorku.ca/~oz/hash.html\n// More specifically, 32-bit hash via djbxor\n// (ref: https://gist.github.com/eplawless/52813b1d8ad9af510d85?permalink_comment_id=3367765#gistcomment-3367765)\n// This is due to number type differences between rust for turbopack to js number types,\n// where rust does not have easy way to repreesnt js's 53-bit float number type for the matching\n// overflow behavior. This is more `correct` in terms of having canonical hash across different runtime / implementation\n// as can gaurantee determinstic output from 32bit hash.\nexport function djb2Hash(str: string) {\n let hash = 5381\n for (let i = 0; i < str.length; i++) {\n const char = str.charCodeAt(i)\n hash = ((hash << 5) + hash + char) & 0xffffffff\n }\n return hash >>> 0\n}\n\nexport function hexHash(str: string) {\n return djb2Hash(str).toString(36).slice(0, 5)\n}\n"],"names":["djb2Hash","str","hash","i","length","char","charCodeAt","hexHash","toString","slice"],"mappings":"AAAA,wCAAwC;AACxC,4CAA4C;AAC5C,iHAAiH;AACjH,wFAAwF;AACxF,gGAAgG;AAChG,wHAAwH;AACxH,wDAAwD;AACxD,OAAO,SAASA,SAASC,GAAW;IAClC,IAAIC,OAAO;IACX,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIG,MAAM,EAAED,IAAK;QACnC,MAAME,OAAOJ,IAAIK,UAAU,CAACH;QAC5BD,OAAO,AAAEA,CAAAA,QAAQ,CAAA,IAAKA,OAAOG,OAAQ;IACvC;IACA,OAAOH,SAAS;AAClB;AAEA,OAAO,SAASK,QAAQN,GAAW;IACjC,OAAOD,SAASC,KAAKO,QAAQ,CAAC,IAAIC,KAAK,CAAC,GAAG;AAC7C"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import React from 'react';
|
||||
export const HeadManagerContext = React.createContext({});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
HeadManagerContext.displayName = 'HeadManagerContext';
|
||||
}
|
||||
|
||||
//# sourceMappingURL=head-manager-context.shared-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/head-manager-context.shared-runtime.ts"],"sourcesContent":["import React from 'react'\n\nexport const HeadManagerContext: React.Context<{\n updateHead?: (state: any) => void\n mountedInstances?: any\n updateScripts?: (state: any) => void\n scripts?: any\n getIsSsr?: () => boolean\n\n // Used in app directory, to render script tags as server components.\n appDir?: boolean\n nonce?: string\n}> = React.createContext({})\n\nif (process.env.NODE_ENV !== 'production') {\n HeadManagerContext.displayName = 'HeadManagerContext'\n}\n"],"names":["React","HeadManagerContext","createContext","process","env","NODE_ENV","displayName"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AAEzB,OAAO,MAAMC,qBAURD,MAAME,aAAa,CAAC,CAAC,GAAE;AAE5B,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzCJ,mBAAmBK,WAAW,GAAG;AACnC"}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
'use client';
|
||||
import { jsx as _jsx } from "react/jsx-runtime";
|
||||
import React, { useContext } from 'react';
|
||||
import Effect from './side-effect';
|
||||
import { AmpStateContext } from './amp-context.shared-runtime';
|
||||
import { HeadManagerContext } from './head-manager-context.shared-runtime';
|
||||
import { isInAmpMode } from './amp-mode';
|
||||
import { warnOnce } from './utils/warn-once';
|
||||
export function defaultHead(inAmpMode) {
|
||||
if (inAmpMode === void 0) inAmpMode = false;
|
||||
const head = [
|
||||
/*#__PURE__*/ _jsx("meta", {
|
||||
charSet: "utf-8"
|
||||
}, "charset")
|
||||
];
|
||||
if (!inAmpMode) {
|
||||
head.push(/*#__PURE__*/ _jsx("meta", {
|
||||
name: "viewport",
|
||||
content: "width=device-width"
|
||||
}, "viewport"));
|
||||
}
|
||||
return head;
|
||||
}
|
||||
function onlyReactElement(list, child) {
|
||||
// React children can be "string" or "number" in this case we ignore them for backwards compat
|
||||
if (typeof child === 'string' || typeof child === 'number') {
|
||||
return list;
|
||||
}
|
||||
// Adds support for React.Fragment
|
||||
if (child.type === React.Fragment) {
|
||||
return list.concat(// @ts-expect-error @types/react does not remove fragments but this could also return ReactPortal[]
|
||||
React.Children.toArray(child.props.children).reduce(// @ts-expect-error @types/react does not remove fragments but this could also return ReactPortal[]
|
||||
(fragmentList, fragmentChild)=>{
|
||||
if (typeof fragmentChild === 'string' || typeof fragmentChild === 'number') {
|
||||
return fragmentList;
|
||||
}
|
||||
return fragmentList.concat(fragmentChild);
|
||||
}, []));
|
||||
}
|
||||
return list.concat(child);
|
||||
}
|
||||
const METATYPES = [
|
||||
'name',
|
||||
'httpEquiv',
|
||||
'charSet',
|
||||
'itemProp'
|
||||
];
|
||||
/*
|
||||
returns a function for filtering head child elements
|
||||
which shouldn't be duplicated, like <title/>
|
||||
Also adds support for deduplicated `key` properties
|
||||
*/ function unique() {
|
||||
const keys = new Set();
|
||||
const tags = new Set();
|
||||
const metaTypes = new Set();
|
||||
const metaCategories = {};
|
||||
return (h)=>{
|
||||
let isUnique = true;
|
||||
let hasKey = false;
|
||||
if (h.key && typeof h.key !== 'number' && h.key.indexOf('$') > 0) {
|
||||
hasKey = true;
|
||||
const key = h.key.slice(h.key.indexOf('$') + 1);
|
||||
if (keys.has(key)) {
|
||||
isUnique = false;
|
||||
} else {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line default-case
|
||||
switch(h.type){
|
||||
case 'title':
|
||||
case 'base':
|
||||
if (tags.has(h.type)) {
|
||||
isUnique = false;
|
||||
} else {
|
||||
tags.add(h.type);
|
||||
}
|
||||
break;
|
||||
case 'meta':
|
||||
for(let i = 0, len = METATYPES.length; i < len; i++){
|
||||
const metatype = METATYPES[i];
|
||||
if (!h.props.hasOwnProperty(metatype)) continue;
|
||||
if (metatype === 'charSet') {
|
||||
if (metaTypes.has(metatype)) {
|
||||
isUnique = false;
|
||||
} else {
|
||||
metaTypes.add(metatype);
|
||||
}
|
||||
} else {
|
||||
const category = h.props[metatype];
|
||||
const categories = metaCategories[metatype] || new Set();
|
||||
if ((metatype !== 'name' || !hasKey) && categories.has(category)) {
|
||||
isUnique = false;
|
||||
} else {
|
||||
categories.add(category);
|
||||
metaCategories[metatype] = categories;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return isUnique;
|
||||
};
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param headChildrenElements List of children of <Head>
|
||||
*/ function reduceComponents(headChildrenElements, props) {
|
||||
const { inAmpMode } = props;
|
||||
return headChildrenElements.reduce(onlyReactElement, []).reverse().concat(defaultHead(inAmpMode).reverse()).filter(unique()).reverse().map((c, i)=>{
|
||||
const key = c.key || i;
|
||||
if (process.env.NODE_ENV !== 'development' && process.env.__NEXT_OPTIMIZE_FONTS && !inAmpMode) {
|
||||
if (c.type === 'link' && c.props['href'] && // TODO(prateekbh@): Replace this with const from `constants` when the tree shaking works.
|
||||
[
|
||||
'https://fonts.googleapis.com/css',
|
||||
'https://use.typekit.net/'
|
||||
].some((url)=>c.props['href'].startsWith(url))) {
|
||||
const newProps = {
|
||||
...c.props || {}
|
||||
};
|
||||
newProps['data-href'] = newProps['href'];
|
||||
newProps['href'] = undefined;
|
||||
// Add this attribute to make it easy to identify optimized tags
|
||||
newProps['data-optimized-fonts'] = true;
|
||||
return /*#__PURE__*/ React.cloneElement(c, newProps);
|
||||
}
|
||||
}
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
// omit JSON-LD structured data snippets from the warning
|
||||
if (c.type === 'script' && c.props['type'] !== 'application/ld+json') {
|
||||
const srcMessage = c.props['src'] ? '<script> tag with src="' + c.props['src'] + '"' : "inline <script>";
|
||||
warnOnce("Do not add <script> tags using next/head (see " + srcMessage + "). Use next/script instead. \nSee more info here: https://nextjs.org/docs/messages/no-script-tags-in-head-component");
|
||||
} else if (c.type === 'link' && c.props['rel'] === 'stylesheet') {
|
||||
warnOnce('Do not add stylesheets using next/head (see <link rel="stylesheet"> tag with href="' + c.props['href'] + '"). Use Document instead. \nSee more info here: https://nextjs.org/docs/messages/no-stylesheets-in-head-component');
|
||||
}
|
||||
}
|
||||
return /*#__PURE__*/ React.cloneElement(c, {
|
||||
key
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* This component injects elements to `<head>` of your page.
|
||||
* To avoid duplicated `tags` in `<head>` you can use the `key` property, which will make sure every tag is only rendered once.
|
||||
*/ function Head(param) {
|
||||
let { children } = param;
|
||||
const ampState = useContext(AmpStateContext);
|
||||
const headManager = useContext(HeadManagerContext);
|
||||
return /*#__PURE__*/ _jsx(Effect, {
|
||||
reduceComponentsToState: reduceComponents,
|
||||
headManager: headManager,
|
||||
inAmpMode: isInAmpMode(ampState),
|
||||
children: children
|
||||
});
|
||||
}
|
||||
export default Head;
|
||||
|
||||
//# sourceMappingURL=head.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/head.tsx"],"sourcesContent":["'use client'\n\nimport React, { useContext, type JSX } from 'react'\nimport Effect from './side-effect'\nimport { AmpStateContext } from './amp-context.shared-runtime'\nimport { HeadManagerContext } from './head-manager-context.shared-runtime'\nimport { isInAmpMode } from './amp-mode'\nimport { warnOnce } from './utils/warn-once'\n\ntype WithInAmpMode = {\n inAmpMode?: boolean\n}\n\nexport function defaultHead(inAmpMode = false): JSX.Element[] {\n const head = [<meta charSet=\"utf-8\" key=\"charset\" />]\n if (!inAmpMode) {\n head.push(\n <meta name=\"viewport\" content=\"width=device-width\" key=\"viewport\" />\n )\n }\n return head\n}\n\nfunction onlyReactElement(\n list: Array<React.ReactElement<any>>,\n child: React.ReactElement | number | string\n): Array<React.ReactElement<any>> {\n // React children can be \"string\" or \"number\" in this case we ignore them for backwards compat\n if (typeof child === 'string' || typeof child === 'number') {\n return list\n }\n // Adds support for React.Fragment\n if (child.type === React.Fragment) {\n return list.concat(\n // @ts-expect-error @types/react does not remove fragments but this could also return ReactPortal[]\n React.Children.toArray(child.props.children).reduce(\n // @ts-expect-error @types/react does not remove fragments but this could also return ReactPortal[]\n (\n fragmentList: Array<React.ReactElement<any>>,\n fragmentChild: React.ReactElement | number | string\n ): Array<React.ReactElement<any>> => {\n if (\n typeof fragmentChild === 'string' ||\n typeof fragmentChild === 'number'\n ) {\n return fragmentList\n }\n return fragmentList.concat(fragmentChild)\n },\n []\n )\n )\n }\n return list.concat(child)\n}\n\nconst METATYPES = ['name', 'httpEquiv', 'charSet', 'itemProp']\n\n/*\n returns a function for filtering head child elements\n which shouldn't be duplicated, like <title/>\n Also adds support for deduplicated `key` properties\n*/\nfunction unique() {\n const keys = new Set()\n const tags = new Set()\n const metaTypes = new Set()\n const metaCategories: { [metatype: string]: Set<string> } = {}\n\n return (h: React.ReactElement<any>) => {\n let isUnique = true\n let hasKey = false\n\n if (h.key && typeof h.key !== 'number' && h.key.indexOf('$') > 0) {\n hasKey = true\n const key = h.key.slice(h.key.indexOf('$') + 1)\n if (keys.has(key)) {\n isUnique = false\n } else {\n keys.add(key)\n }\n }\n\n // eslint-disable-next-line default-case\n switch (h.type) {\n case 'title':\n case 'base':\n if (tags.has(h.type)) {\n isUnique = false\n } else {\n tags.add(h.type)\n }\n break\n case 'meta':\n for (let i = 0, len = METATYPES.length; i < len; i++) {\n const metatype = METATYPES[i]\n if (!h.props.hasOwnProperty(metatype)) continue\n\n if (metatype === 'charSet') {\n if (metaTypes.has(metatype)) {\n isUnique = false\n } else {\n metaTypes.add(metatype)\n }\n } else {\n const category = h.props[metatype]\n const categories = metaCategories[metatype] || new Set()\n if ((metatype !== 'name' || !hasKey) && categories.has(category)) {\n isUnique = false\n } else {\n categories.add(category)\n metaCategories[metatype] = categories\n }\n }\n }\n break\n }\n\n return isUnique\n }\n}\n\n/**\n *\n * @param headChildrenElements List of children of <Head>\n */\nfunction reduceComponents<T extends {} & WithInAmpMode>(\n headChildrenElements: Array<React.ReactElement<any>>,\n props: T\n) {\n const { inAmpMode } = props\n return headChildrenElements\n .reduce(onlyReactElement, [])\n .reverse()\n .concat(defaultHead(inAmpMode).reverse())\n .filter(unique())\n .reverse()\n .map((c: React.ReactElement<any>, i: number) => {\n const key = c.key || i\n if (\n process.env.NODE_ENV !== 'development' &&\n process.env.__NEXT_OPTIMIZE_FONTS &&\n !inAmpMode\n ) {\n if (\n c.type === 'link' &&\n c.props['href'] &&\n // TODO(prateekbh@): Replace this with const from `constants` when the tree shaking works.\n ['https://fonts.googleapis.com/css', 'https://use.typekit.net/'].some(\n (url) => c.props['href'].startsWith(url)\n )\n ) {\n const newProps = { ...(c.props || {}) }\n newProps['data-href'] = newProps['href']\n newProps['href'] = undefined\n\n // Add this attribute to make it easy to identify optimized tags\n newProps['Line truncated
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
'use client';
|
||||
import { createContext } from 'react';
|
||||
export const SearchParamsContext = createContext(null);
|
||||
export const PathnameContext = createContext(null);
|
||||
export const PathParamsContext = createContext(null);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
SearchParamsContext.displayName = 'SearchParamsContext';
|
||||
PathnameContext.displayName = 'PathnameContext';
|
||||
PathParamsContext.displayName = 'PathParamsContext';
|
||||
}
|
||||
|
||||
//# sourceMappingURL=hooks-client-context.shared-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/hooks-client-context.shared-runtime.ts"],"sourcesContent":["'use client'\n\nimport { createContext } from 'react'\nimport type { Params } from '../../server/request/params'\n\nexport const SearchParamsContext = createContext<URLSearchParams | null>(null)\nexport const PathnameContext = createContext<string | null>(null)\nexport const PathParamsContext = createContext<Params | null>(null)\n\nif (process.env.NODE_ENV !== 'production') {\n SearchParamsContext.displayName = 'SearchParamsContext'\n PathnameContext.displayName = 'PathnameContext'\n PathParamsContext.displayName = 'PathParamsContext'\n}\n"],"names":["createContext","SearchParamsContext","PathnameContext","PathParamsContext","process","env","NODE_ENV","displayName"],"mappings":"AAAA;AAEA,SAASA,aAAa,QAAQ,QAAO;AAGrC,OAAO,MAAMC,sBAAsBD,cAAsC,MAAK;AAC9E,OAAO,MAAME,kBAAkBF,cAA6B,MAAK;AACjE,OAAO,MAAMG,oBAAoBH,cAA6B,MAAK;AAEnE,IAAII,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzCL,oBAAoBM,WAAW,GAAG;IAClCL,gBAAgBK,WAAW,GAAG;IAC9BJ,kBAAkBI,WAAW,GAAG;AAClC"}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
export const HtmlContext = createContext(undefined);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
HtmlContext.displayName = 'HtmlContext';
|
||||
}
|
||||
export function useHtmlContext() {
|
||||
const context = useContext(HtmlContext);
|
||||
if (!context) {
|
||||
throw Object.defineProperty(new Error("<Html> should not be imported outside of pages/_document.\n" + 'Read more: https://nextjs.org/docs/messages/no-document-import-in-page'), "__NEXT_ERROR_CODE", {
|
||||
value: "E67",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=html-context.shared-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/html-context.shared-runtime.ts"],"sourcesContent":["import type { BuildManifest } from '../../server/get-page-files'\nimport type { ServerRuntime } from '../../types'\nimport type { NEXT_DATA } from './utils'\nimport type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin'\nimport type { DeepReadonly } from './deep-readonly'\n\nimport { createContext, useContext, type JSX } from 'react'\n\nexport type HtmlProps = {\n __NEXT_DATA__: NEXT_DATA\n strictNextHead: boolean\n dangerousAsPath: string\n docComponentsRendered: {\n Html?: boolean\n Main?: boolean\n Head?: boolean\n NextScript?: boolean\n }\n buildManifest: BuildManifest\n ampPath: string\n inAmpMode: boolean\n hybridAmp: boolean\n isDevelopment: boolean\n dynamicImports: string[]\n /**\n * This manifest is only needed for Pages dir, Production, Webpack\n * @see https://github.com/vercel/next.js/pull/72959\n */\n dynamicCssManifest: Set<string>\n assetPrefix?: string\n canonicalBase: string\n headTags: any[]\n unstable_runtimeJS?: false\n unstable_JsPreload?: false\n assetQueryString: string\n scriptLoader: {\n afterInteractive?: string[]\n beforeInteractive?: any[]\n worker?: any[]\n }\n locale?: string\n disableOptimizedLoading?: boolean\n styles?: React.ReactElement[] | Iterable<React.ReactNode>\n head?: Array<JSX.Element | null>\n crossOrigin?: 'anonymous' | 'use-credentials' | '' | undefined\n optimizeCss?: any\n nextConfigOutput?: 'standalone' | 'export'\n nextScriptWorkers?: boolean\n runtime?: ServerRuntime\n hasConcurrentFeatures?: boolean\n largePageDataBytes?: number\n nextFontManifest?: DeepReadonly<NextFontManifest>\n experimentalClientTraceMetadata?: string[]\n}\n\nexport const HtmlContext = createContext<HtmlProps | undefined>(undefined)\nif (process.env.NODE_ENV !== 'production') {\n HtmlContext.displayName = 'HtmlContext'\n}\n\nexport function useHtmlContext() {\n const context = useContext(HtmlContext)\n\n if (!context) {\n throw new Error(\n `<Html> should not be imported outside of pages/_document.\\n` +\n 'Read more: https://nextjs.org/docs/messages/no-document-import-in-page'\n )\n }\n\n return context\n}\n"],"names":["createContext","useContext","HtmlContext","undefined","process","env","NODE_ENV","displayName","useHtmlContext","context","Error"],"mappings":"AAMA,SAASA,aAAa,EAAEC,UAAU,QAAkB,QAAO;AAiD3D,OAAO,MAAMC,cAAcF,cAAqCG,WAAU;AAC1E,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzCJ,YAAYK,WAAW,GAAG;AAC5B;AAEA,OAAO,SAASC;IACd,MAAMC,UAAUR,WAAWC;IAE3B,IAAI,CAACO,SAAS;QACZ,MAAM,qBAGL,CAHK,IAAIC,MACR,AAAC,gEACC,2EAFE,qBAAA;mBAAA;wBAAA;0BAAA;QAGN;IACF;IAEA,OAAOD;AACT"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
export function detectDomainLocale(domainItems, hostname, detectedLocale) {
|
||||
if (!domainItems) return;
|
||||
if (detectedLocale) {
|
||||
detectedLocale = detectedLocale.toLowerCase();
|
||||
}
|
||||
for (const item of domainItems){
|
||||
var _item_domain, _item_locales;
|
||||
// remove port if present
|
||||
const domainHostname = (_item_domain = item.domain) == null ? void 0 : _item_domain.split(':', 1)[0].toLowerCase();
|
||||
if (hostname === domainHostname || detectedLocale === item.defaultLocale.toLowerCase() || ((_item_locales = item.locales) == null ? void 0 : _item_locales.some((locale)=>locale.toLowerCase() === detectedLocale))) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=detect-domain-locale.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/i18n/detect-domain-locale.ts"],"sourcesContent":["import type { DomainLocale } from '../../../server/config-shared'\n\nexport function detectDomainLocale(\n domainItems?: readonly DomainLocale[],\n hostname?: string,\n detectedLocale?: string\n) {\n if (!domainItems) return\n\n if (detectedLocale) {\n detectedLocale = detectedLocale.toLowerCase()\n }\n\n for (const item of domainItems) {\n // remove port if present\n const domainHostname = item.domain?.split(':', 1)[0].toLowerCase()\n if (\n hostname === domainHostname ||\n detectedLocale === item.defaultLocale.toLowerCase() ||\n item.locales?.some((locale) => locale.toLowerCase() === detectedLocale)\n ) {\n return item\n }\n }\n}\n"],"names":["detectDomainLocale","domainItems","hostname","detectedLocale","toLowerCase","item","domainHostname","domain","split","defaultLocale","locales","some","locale"],"mappings":"AAEA,OAAO,SAASA,mBACdC,WAAqC,EACrCC,QAAiB,EACjBC,cAAuB;IAEvB,IAAI,CAACF,aAAa;IAElB,IAAIE,gBAAgB;QAClBA,iBAAiBA,eAAeC,WAAW;IAC7C;IAEA,KAAK,MAAMC,QAAQJ,YAAa;YAEPI,cAIrBA;QALF,yBAAyB;QACzB,MAAMC,kBAAiBD,eAAAA,KAAKE,MAAM,qBAAXF,aAAaG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAACJ,WAAW;QAChE,IACEF,aAAaI,kBACbH,mBAAmBE,KAAKI,aAAa,CAACL,WAAW,QACjDC,gBAAAA,KAAKK,OAAO,qBAAZL,cAAcM,IAAI,CAAC,CAACC,SAAWA,OAAOR,WAAW,OAAOD,kBACxD;YACA,OAAOE;QACT;IACF;AACF"}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import { acceptLanguage } from '../../../server/accept-header';
|
||||
import { denormalizePagePath } from '../page-path/denormalize-page-path';
|
||||
import { detectDomainLocale } from './detect-domain-locale';
|
||||
import { formatUrl } from '../router/utils/format-url';
|
||||
import { getCookieParser } from '../../../server/api-utils/get-cookie-parser';
|
||||
function getLocaleFromCookie(i18n, headers) {
|
||||
if (headers === void 0) headers = {};
|
||||
var _getCookieParser_NEXT_LOCALE, _getCookieParser;
|
||||
const nextLocale = (_getCookieParser = getCookieParser(headers || {})()) == null ? void 0 : (_getCookieParser_NEXT_LOCALE = _getCookieParser.NEXT_LOCALE) == null ? void 0 : _getCookieParser_NEXT_LOCALE.toLowerCase();
|
||||
return nextLocale ? i18n.locales.find((locale)=>nextLocale === locale.toLowerCase()) : undefined;
|
||||
}
|
||||
function detectLocale(param) {
|
||||
let { i18n, headers, domainLocale, preferredLocale, pathLocale } = param;
|
||||
return pathLocale || (domainLocale == null ? void 0 : domainLocale.defaultLocale) || getLocaleFromCookie(i18n, headers) || preferredLocale || i18n.defaultLocale;
|
||||
}
|
||||
function getAcceptPreferredLocale(i18n, headers) {
|
||||
if ((headers == null ? void 0 : headers['accept-language']) && !Array.isArray(headers['accept-language'])) {
|
||||
try {
|
||||
return acceptLanguage(headers['accept-language'], i18n.locales);
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
export function getLocaleRedirect(param) {
|
||||
let { defaultLocale, domainLocale, pathLocale, headers, nextConfig, urlParsed } = param;
|
||||
if (nextConfig.i18n && nextConfig.i18n.localeDetection !== false && denormalizePagePath(urlParsed.pathname) === '/') {
|
||||
const preferredLocale = getAcceptPreferredLocale(nextConfig.i18n, headers);
|
||||
const detectedLocale = detectLocale({
|
||||
i18n: nextConfig.i18n,
|
||||
preferredLocale,
|
||||
headers,
|
||||
pathLocale,
|
||||
domainLocale
|
||||
});
|
||||
const preferredDomain = detectDomainLocale(nextConfig.i18n.domains, undefined, preferredLocale);
|
||||
if (domainLocale && preferredDomain) {
|
||||
const isPDomain = preferredDomain.domain === domainLocale.domain;
|
||||
const isPLocale = preferredDomain.defaultLocale === preferredLocale;
|
||||
if (!isPDomain || !isPLocale) {
|
||||
const scheme = "http" + (preferredDomain.http ? '' : 's');
|
||||
const rlocale = isPLocale ? '' : preferredLocale;
|
||||
return scheme + "://" + preferredDomain.domain + "/" + rlocale;
|
||||
}
|
||||
}
|
||||
if (detectedLocale.toLowerCase() !== defaultLocale.toLowerCase()) {
|
||||
return formatUrl({
|
||||
...urlParsed,
|
||||
pathname: (nextConfig.basePath || '') + "/" + detectedLocale + (nextConfig.trailingSlash ? '/' : '')
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=get-locale-redirect.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/i18n/get-locale-redirect.ts"],"sourcesContent":["import type { DomainLocale } from '../../../server/config'\nimport type { I18NConfig } from '../../../server/config-shared'\nimport { acceptLanguage } from '../../../server/accept-header'\nimport { denormalizePagePath } from '../page-path/denormalize-page-path'\nimport { detectDomainLocale } from './detect-domain-locale'\nimport { formatUrl } from '../router/utils/format-url'\nimport { getCookieParser } from '../../../server/api-utils/get-cookie-parser'\n\ninterface Options {\n defaultLocale: string\n domainLocale?: DomainLocale\n headers?: { [key: string]: string | string[] | undefined }\n nextConfig: {\n basePath?: string\n i18n?: I18NConfig | null\n trailingSlash?: boolean\n }\n pathLocale?: string\n urlParsed: { hostname?: string | null; pathname: string }\n}\n\nfunction getLocaleFromCookie(\n i18n: I18NConfig,\n headers: { [key: string]: string | string[] | undefined } = {}\n) {\n const nextLocale = getCookieParser(\n headers || {}\n )()?.NEXT_LOCALE?.toLowerCase()\n return nextLocale\n ? i18n.locales.find((locale) => nextLocale === locale.toLowerCase())\n : undefined\n}\n\nfunction detectLocale({\n i18n,\n headers,\n domainLocale,\n preferredLocale,\n pathLocale,\n}: {\n i18n: I18NConfig\n preferredLocale?: string\n headers?: { [key: string]: string | string[] | undefined }\n domainLocale?: DomainLocale\n pathLocale?: string\n}) {\n return (\n pathLocale ||\n domainLocale?.defaultLocale ||\n getLocaleFromCookie(i18n, headers) ||\n preferredLocale ||\n i18n.defaultLocale\n )\n}\n\nfunction getAcceptPreferredLocale(\n i18n: I18NConfig,\n headers?: { [key: string]: string | string[] | undefined }\n) {\n if (\n headers?.['accept-language'] &&\n !Array.isArray(headers['accept-language'])\n ) {\n try {\n return acceptLanguage(headers['accept-language'], i18n.locales)\n } catch (err) {}\n }\n}\n\nexport function getLocaleRedirect({\n defaultLocale,\n domainLocale,\n pathLocale,\n headers,\n nextConfig,\n urlParsed,\n}: Options) {\n if (\n nextConfig.i18n &&\n nextConfig.i18n.localeDetection !== false &&\n denormalizePagePath(urlParsed.pathname) === '/'\n ) {\n const preferredLocale = getAcceptPreferredLocale(nextConfig.i18n, headers)\n const detectedLocale = detectLocale({\n i18n: nextConfig.i18n,\n preferredLocale,\n headers,\n pathLocale,\n domainLocale,\n })\n\n const preferredDomain = detectDomainLocale(\n nextConfig.i18n.domains,\n undefined,\n preferredLocale\n )\n\n if (domainLocale && preferredDomain) {\n const isPDomain = preferredDomain.domain === domainLocale.domain\n const isPLocale = preferredDomain.defaultLocale === preferredLocale\n if (!isPDomain || !isPLocale) {\n const scheme = `http${preferredDomain.http ? '' : 's'}`\n const rlocale = isPLocale ? '' : preferredLocale\n return `${scheme}://${preferredDomain.domain}/${rlocale}`\n }\n }\n\n if (detectedLocale.toLowerCase() !== defaultLocale.toLowerCase()) {\n return formatUrl({\n ...urlParsed,\n pathname: `${nextConfig.basePath || ''}/${detectedLocale}${\n nextConfig.trailingSlash ? '/' : ''\n }`,\n })\n }\n }\n}\n"],"names":["acceptLanguage","denormalizePagePath","detectDomainLocale","formatUrl","getCookieParser","getLocaleFromCookie","i18n","headers","nextLocale","NEXT_LOCALE","toLowerCase","locales","find","locale","undefined","detectLocale","domainLocale","preferredLocale","pathLocale","defaultLocale","getAcceptPreferredLocale","Array","isArray","err","getLocaleRedirect","nextConfig","urlParsed","localeDetection","pathname","detectedLocale","preferredDomain","domains","isPDomain","domain","isPLocale","scheme","http","rlocale","basePath","trailingSlash"],"mappings":"AAEA,SAASA,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,SAAS,QAAQ,6BAA4B;AACtD,SAASC,eAAe,QAAQ,8CAA6C;AAe7E,SAASC,oBACPC,IAAgB,EAChBC,OAA8D;IAA9DA,IAAAA,oBAAAA,UAA4D,CAAC;QAE1CH,8BAAAA;IAAnB,MAAMI,cAAaJ,mBAAAA,gBACjBG,WAAW,CAAC,0BADKH,+BAAAA,iBAEdK,WAAW,qBAFGL,6BAEDM,WAAW;IAC7B,OAAOF,aACHF,KAAKK,OAAO,CAACC,IAAI,CAAC,CAACC,SAAWL,eAAeK,OAAOH,WAAW,MAC/DI;AACN;AAEA,SAASC,aAAa,KAYrB;IAZqB,IAAA,EACpBT,IAAI,EACJC,OAAO,EACPS,YAAY,EACZC,eAAe,EACfC,UAAU,EAOX,GAZqB;IAapB,OACEA,eACAF,gCAAAA,aAAcG,aAAa,KAC3Bd,oBAAoBC,MAAMC,YAC1BU,mBACAX,KAAKa,aAAa;AAEtB;AAEA,SAASC,yBACPd,IAAgB,EAChBC,OAA0D;IAE1D,IACEA,CAAAA,2BAAAA,OAAS,CAAC,kBAAkB,KAC5B,CAACc,MAAMC,OAAO,CAACf,OAAO,CAAC,kBAAkB,GACzC;QACA,IAAI;YACF,OAAOP,eAAeO,OAAO,CAAC,kBAAkB,EAAED,KAAKK,OAAO;QAChE,EAAE,OAAOY,KAAK,CAAC;IACjB;AACF;AAEA,OAAO,SAASC,kBAAkB,KAOxB;IAPwB,IAAA,EAChCL,aAAa,EACbH,YAAY,EACZE,UAAU,EACVX,OAAO,EACPkB,UAAU,EACVC,SAAS,EACD,GAPwB;IAQhC,IACED,WAAWnB,IAAI,IACfmB,WAAWnB,IAAI,CAACqB,eAAe,KAAK,SACpC1B,oBAAoByB,UAAUE,QAAQ,MAAM,KAC5C;QACA,MAAMX,kLine truncated
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* A cache of lowercased locales for each list of locales. This is stored as a
|
||||
* WeakMap so if the locales are garbage collected, the cache entry will be
|
||||
* removed as well.
|
||||
*/ const cache = new WeakMap();
|
||||
/**
|
||||
* For a pathname that may include a locale from a list of locales, it
|
||||
* removes the locale from the pathname returning it alongside with the
|
||||
* detected locale.
|
||||
*
|
||||
* @param pathname A pathname that may include a locale.
|
||||
* @param locales A list of locales.
|
||||
* @returns The detected locale and pathname without locale
|
||||
*/ export function normalizeLocalePath(pathname, locales) {
|
||||
// If locales is undefined, return the pathname as is.
|
||||
if (!locales) return {
|
||||
pathname
|
||||
};
|
||||
// Get the cached lowercased locales or create a new cache entry.
|
||||
let lowercasedLocales = cache.get(locales);
|
||||
if (!lowercasedLocales) {
|
||||
lowercasedLocales = locales.map((locale)=>locale.toLowerCase());
|
||||
cache.set(locales, lowercasedLocales);
|
||||
}
|
||||
let detectedLocale;
|
||||
// The first segment will be empty, because it has a leading `/`. If
|
||||
// there is no further segment, there is no locale (or it's the default).
|
||||
const segments = pathname.split('/', 2);
|
||||
// If there's no second segment (ie, the pathname is just `/`), there's no
|
||||
// locale.
|
||||
if (!segments[1]) return {
|
||||
pathname
|
||||
};
|
||||
// The second segment will contain the locale part if any.
|
||||
const segment = segments[1].toLowerCase();
|
||||
// See if the segment matches one of the locales. If it doesn't, there is
|
||||
// no locale (or it's the default).
|
||||
const index = lowercasedLocales.indexOf(segment);
|
||||
if (index < 0) return {
|
||||
pathname
|
||||
};
|
||||
// Return the case-sensitive locale.
|
||||
detectedLocale = locales[index];
|
||||
// Remove the `/${locale}` part of the pathname.
|
||||
pathname = pathname.slice(detectedLocale.length + 1) || '/';
|
||||
return {
|
||||
pathname,
|
||||
detectedLocale
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=normalize-locale-path.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/i18n/normalize-locale-path.ts"],"sourcesContent":["export interface PathLocale {\n detectedLocale?: string\n pathname: string\n}\n\n/**\n * A cache of lowercased locales for each list of locales. This is stored as a\n * WeakMap so if the locales are garbage collected, the cache entry will be\n * removed as well.\n */\nconst cache = new WeakMap<readonly string[], readonly string[]>()\n\n/**\n * For a pathname that may include a locale from a list of locales, it\n * removes the locale from the pathname returning it alongside with the\n * detected locale.\n *\n * @param pathname A pathname that may include a locale.\n * @param locales A list of locales.\n * @returns The detected locale and pathname without locale\n */\nexport function normalizeLocalePath(\n pathname: string,\n locales?: readonly string[]\n): PathLocale {\n // If locales is undefined, return the pathname as is.\n if (!locales) return { pathname }\n\n // Get the cached lowercased locales or create a new cache entry.\n let lowercasedLocales = cache.get(locales)\n if (!lowercasedLocales) {\n lowercasedLocales = locales.map((locale) => locale.toLowerCase())\n cache.set(locales, lowercasedLocales)\n }\n\n let detectedLocale: string | undefined\n\n // The first segment will be empty, because it has a leading `/`. If\n // there is no further segment, there is no locale (or it's the default).\n const segments = pathname.split('/', 2)\n\n // If there's no second segment (ie, the pathname is just `/`), there's no\n // locale.\n if (!segments[1]) return { pathname }\n\n // The second segment will contain the locale part if any.\n const segment = segments[1].toLowerCase()\n\n // See if the segment matches one of the locales. If it doesn't, there is\n // no locale (or it's the default).\n const index = lowercasedLocales.indexOf(segment)\n if (index < 0) return { pathname }\n\n // Return the case-sensitive locale.\n detectedLocale = locales[index]\n\n // Remove the `/${locale}` part of the pathname.\n pathname = pathname.slice(detectedLocale.length + 1) || '/'\n\n return { pathname, detectedLocale }\n}\n"],"names":["cache","WeakMap","normalizeLocalePath","pathname","locales","lowercasedLocales","get","map","locale","toLowerCase","set","detectedLocale","segments","split","segment","index","indexOf","slice","length"],"mappings":"AAKA;;;;CAIC,GACD,MAAMA,QAAQ,IAAIC;AAElB;;;;;;;;CAQC,GACD,OAAO,SAASC,oBACdC,QAAgB,EAChBC,OAA2B;IAE3B,sDAAsD;IACtD,IAAI,CAACA,SAAS,OAAO;QAAED;IAAS;IAEhC,iEAAiE;IACjE,IAAIE,oBAAoBL,MAAMM,GAAG,CAACF;IAClC,IAAI,CAACC,mBAAmB;QACtBA,oBAAoBD,QAAQG,GAAG,CAAC,CAACC,SAAWA,OAAOC,WAAW;QAC9DT,MAAMU,GAAG,CAACN,SAASC;IACrB;IAEA,IAAIM;IAEJ,oEAAoE;IACpE,yEAAyE;IACzE,MAAMC,WAAWT,SAASU,KAAK,CAAC,KAAK;IAErC,0EAA0E;IAC1E,UAAU;IACV,IAAI,CAACD,QAAQ,CAAC,EAAE,EAAE,OAAO;QAAET;IAAS;IAEpC,0DAA0D;IAC1D,MAAMW,UAAUF,QAAQ,CAAC,EAAE,CAACH,WAAW;IAEvC,yEAAyE;IACzE,mCAAmC;IACnC,MAAMM,QAAQV,kBAAkBW,OAAO,CAACF;IACxC,IAAIC,QAAQ,GAAG,OAAO;QAAEZ;IAAS;IAEjC,oCAAoC;IACpCQ,iBAAiBP,OAAO,CAACW,MAAM;IAE/B,gDAAgD;IAChDZ,WAAWA,SAASc,KAAK,CAACN,eAAeO,MAAM,GAAG,MAAM;IAExD,OAAO;QAAEf;QAAUQ;IAAe;AACpC"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* A shared function, used on both client and server, to generate a SVG blur placeholder.
|
||||
*/ export function getImageBlurSvg(param) {
|
||||
let { widthInt, heightInt, blurWidth, blurHeight, blurDataURL, objectFit } = param;
|
||||
const std = 20;
|
||||
const svgWidth = blurWidth ? blurWidth * 40 : widthInt;
|
||||
const svgHeight = blurHeight ? blurHeight * 40 : heightInt;
|
||||
const viewBox = svgWidth && svgHeight ? "viewBox='0 0 " + svgWidth + " " + svgHeight + "'" : '';
|
||||
const preserveAspectRatio = viewBox ? 'none' : objectFit === 'contain' ? 'xMidYMid' : objectFit === 'cover' ? 'xMidYMid slice' : 'none';
|
||||
return "%3Csvg xmlns='http://www.w3.org/2000/svg' " + viewBox + "%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='" + std + "'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='" + std + "'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='" + preserveAspectRatio + "' style='filter: url(%23b);' href='" + blurDataURL + "'/%3E%3C/svg%3E";
|
||||
}
|
||||
|
||||
//# sourceMappingURL=image-blur-svg.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/image-blur-svg.ts"],"sourcesContent":["/**\n * A shared function, used on both client and server, to generate a SVG blur placeholder.\n */\nexport function getImageBlurSvg({\n widthInt,\n heightInt,\n blurWidth,\n blurHeight,\n blurDataURL,\n objectFit,\n}: {\n widthInt?: number\n heightInt?: number\n blurWidth?: number\n blurHeight?: number\n blurDataURL: string\n objectFit?: string\n}): string {\n const std = 20\n const svgWidth = blurWidth ? blurWidth * 40 : widthInt\n const svgHeight = blurHeight ? blurHeight * 40 : heightInt\n\n const viewBox =\n svgWidth && svgHeight ? `viewBox='0 0 ${svgWidth} ${svgHeight}'` : ''\n const preserveAspectRatio = viewBox\n ? 'none'\n : objectFit === 'contain'\n ? 'xMidYMid'\n : objectFit === 'cover'\n ? 'xMidYMid slice'\n : 'none'\n\n return `%3Csvg xmlns='http://www.w3.org/2000/svg' ${viewBox}%3E%3Cfilter id='b' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='${std}'/%3E%3CfeColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/%3E%3CfeFlood x='0' y='0' width='100%25' height='100%25'/%3E%3CfeComposite operator='out' in='s'/%3E%3CfeComposite in2='SourceGraphic'/%3E%3CfeGaussianBlur stdDeviation='${std}'/%3E%3C/filter%3E%3Cimage width='100%25' height='100%25' x='0' y='0' preserveAspectRatio='${preserveAspectRatio}' style='filter: url(%23b);' href='${blurDataURL}'/%3E%3C/svg%3E`\n}\n"],"names":["getImageBlurSvg","widthInt","heightInt","blurWidth","blurHeight","blurDataURL","objectFit","std","svgWidth","svgHeight","viewBox","preserveAspectRatio"],"mappings":"AAAA;;CAEC,GACD,OAAO,SAASA,gBAAgB,KAc/B;IAd+B,IAAA,EAC9BC,QAAQ,EACRC,SAAS,EACTC,SAAS,EACTC,UAAU,EACVC,WAAW,EACXC,SAAS,EAQV,GAd+B;IAe9B,MAAMC,MAAM;IACZ,MAAMC,WAAWL,YAAYA,YAAY,KAAKF;IAC9C,MAAMQ,YAAYL,aAAaA,aAAa,KAAKF;IAEjD,MAAMQ,UACJF,YAAYC,YAAY,AAAC,kBAAeD,WAAS,MAAGC,YAAU,MAAK;IACrE,MAAME,sBAAsBD,UACxB,SACAJ,cAAc,YACZ,aACAA,cAAc,UACZ,mBACA;IAER,OAAO,AAAC,+CAA4CI,UAAQ,8FAA2FH,MAAI,oQAAiQA,MAAI,gGAA6FI,sBAAoB,wCAAqCN,cAAY;AACpkB"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import React from 'react';
|
||||
import { imageConfigDefault } from './image-config';
|
||||
export const ImageConfigContext = React.createContext(imageConfigDefault);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
ImageConfigContext.displayName = 'ImageConfigContext';
|
||||
}
|
||||
|
||||
//# sourceMappingURL=image-config-context.shared-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/image-config-context.shared-runtime.ts"],"sourcesContent":["import React from 'react'\nimport type { ImageConfigComplete } from './image-config'\nimport { imageConfigDefault } from './image-config'\n\nexport const ImageConfigContext =\n React.createContext<ImageConfigComplete>(imageConfigDefault)\n\nif (process.env.NODE_ENV !== 'production') {\n ImageConfigContext.displayName = 'ImageConfigContext'\n}\n"],"names":["React","imageConfigDefault","ImageConfigContext","createContext","process","env","NODE_ENV","displayName"],"mappings":"AAAA,OAAOA,WAAW,QAAO;AAEzB,SAASC,kBAAkB,QAAQ,iBAAgB;AAEnD,OAAO,MAAMC,qBACXF,MAAMG,aAAa,CAAsBF,oBAAmB;AAE9D,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzCJ,mBAAmBK,WAAW,GAAG;AACnC"}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
export const VALID_LOADERS = [
|
||||
'default',
|
||||
'imgix',
|
||||
'cloudinary',
|
||||
'akamai',
|
||||
'custom'
|
||||
];
|
||||
export const imageConfigDefault = {
|
||||
deviceSizes: [
|
||||
640,
|
||||
750,
|
||||
828,
|
||||
1080,
|
||||
1200,
|
||||
1920,
|
||||
2048,
|
||||
3840
|
||||
],
|
||||
imageSizes: [
|
||||
16,
|
||||
32,
|
||||
48,
|
||||
64,
|
||||
96,
|
||||
128,
|
||||
256,
|
||||
384
|
||||
],
|
||||
path: '/_next/image',
|
||||
loader: 'default',
|
||||
loaderFile: '',
|
||||
domains: [],
|
||||
disableStaticImages: false,
|
||||
minimumCacheTTL: 60,
|
||||
formats: [
|
||||
'image/webp'
|
||||
],
|
||||
dangerouslyAllowSVG: false,
|
||||
contentSecurityPolicy: "script-src 'none'; frame-src 'none'; sandbox;",
|
||||
contentDispositionType: 'attachment',
|
||||
localPatterns: undefined,
|
||||
remotePatterns: [],
|
||||
qualities: undefined,
|
||||
unoptimized: false
|
||||
};
|
||||
|
||||
//# sourceMappingURL=image-config.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/image-config.ts"],"sourcesContent":["export const VALID_LOADERS = [\n 'default',\n 'imgix',\n 'cloudinary',\n 'akamai',\n 'custom',\n] as const\n\nexport type LoaderValue = (typeof VALID_LOADERS)[number]\n\nexport type ImageLoaderProps = {\n src: string\n width: number\n quality?: number\n}\n\nexport type ImageLoaderPropsWithConfig = ImageLoaderProps & {\n config: Readonly<ImageConfig>\n}\n\nexport type LocalPattern = {\n /**\n * Can be literal or wildcard.\n * Single `*` matches a single path segment.\n * Double `**` matches any number of path segments.\n */\n pathname?: string\n\n /**\n * Can be literal query string such as `?v=1` or\n * empty string meaning no query string.\n */\n search?: string\n}\n\nexport type RemotePattern = {\n /**\n * Must be `http` or `https`.\n */\n protocol?: 'http' | 'https'\n\n /**\n * Can be literal or wildcard.\n * Single `*` matches a single subdomain.\n * Double `**` matches any number of subdomains.\n */\n hostname: string\n\n /**\n * Can be literal port such as `8080` or empty string\n * meaning no port.\n */\n port?: string\n\n /**\n * Can be literal or wildcard.\n * Single `*` matches a single path segment.\n * Double `**` matches any number of path segments.\n */\n pathname?: string\n\n /**\n * Can be literal query string such as `?v=1` or\n * empty string meaning no query string.\n */\n search?: string\n}\n\ntype ImageFormat = 'image/avif' | 'image/webp'\n\n/**\n * Image configurations\n *\n * @see [Image configuration options](https://nextjs.org/docs/api-reference/next/image#configuration-options)\n */\nexport type ImageConfigComplete = {\n /** @see [Device sizes documentation](https://nextjs.org/docs/api-reference/next/image#device-sizes) */\n deviceSizes: number[]\n\n /** @see [Image sizing documentation](https://nextjs.org/docs/app/building-your-application/optimizing/images#image-sizing) */\n imageSizes: number[]\n\n /** @see [Image loaders configuration](https://nextjs.org/docs/api-reference/next/legacy/image#loader) */\n loader: LoaderValue\n\n /** @see [Image loader configuration](https://nextjs.org/docs/api-reference/next/legacy/image#loader-configuration) */\n path: string\n\n /** @see [Image loader configuration](https://nextjs.org/docs/api-reference/next/image#loader-configuration) */\n loaderFile: string\n\n /**\n * @deprecated Use `remotePatterns` instead.\n */\n domains: string[]\n\n /** @see [Disable static image import configuration](https://nextjs.org/docs/api-reference/next/image#disable-static-imports) */\n disableStaticImages: boolean\n\n /** @see [Cache behavior](https://nextjs.org/docs/api-reference/next/image#caching-behavior) */\n minimumCacheTTL: number\n\n /** @see [Acceptable formats](https://nextjs.org/docs/api-reference/next/image#acceptable-formats) */\n formats: ImageFormat[]\n\n /** @see [Dangerously Allow SVG](https://nextjs.org/docs/api-reference/next/image#dangerously-allow-svg) */\n dangerouslyAllowSVG: boolean\n\n /** @see [Dangerously Allow SVG](https://nextjs.org/docs/api-reference/next/image#dangerously-allow-svg) */\n contentSecurityPolicy: string\n\n /** @see [Dangerously Allow SVG](https://nextjs.org/docs/api-reference/next/image#dangerously-allow-svg) */\n contentDispositionType: 'inline' | 'attachment'\n\n /** @see [Remote Patterns](https://nextjs.org/docs/api-reference/next/image#remotepatterns) */\n remotePatterns: Array<URL | RemotePattern>\n\n /** @see [Remote Patterns](https://nextjs.org/docs/api-reference/next/image#localPatterns) */\n localPatterns: LocalPattern[] | undefined\n\n /** @see [Qualities](https://nextjs.org/docs/api-reference/next/image#qualities) */\n qualities: number[] | undefined\n\n /** @see [Unoptimized](https://nextjs.org/docs/api-reference/next/image#unoptimized) */\n unoptimized: boolean\n}\n\nexport type ImageConfig = Partial<ImageConfigComplete>\n\nexport const imageConfigDefault: ImageConfigComplete = {\n deviceSizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840],\n imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],\n path: '/_next/image',\n loader: 'default',\n loaderFile: '',\n domains: [],\n disableStaticImages: false,\n minimumCacheTTL: 60,\n formats: ['image/webp'],\n dangerouslyAllowSVG: false,\n contentSecurityPolicy: `script-src 'none'; frame-src 'none'; sandbox;`,\n contentDispositionType: 'attachment',\n localPatterns: undefined, // default: allow all local images\n remotePatterns: [], // default: allow no remote images\n qualities: undefined, // default: allow all qualities\n unoptimized: false,\n}\n"],"names":["VALID_LOADERS","imageConfigDefault","deviceSizes","imageSizes","path","loader","loaderFile","domains","disableStaticImages","minimumCacheTTL","formats","dangerouslyAllowSVG","contentSecurityPolicy","contentDispositionType","localPatterns","undefined","remotePatterns","qualities","unoptimized"],"mappings":"Line truncated
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
import { getImgProps } from './get-img-props';
|
||||
import { Image } from '../../client/image-component';
|
||||
// @ts-ignore - This is replaced by webpack alias
|
||||
import defaultLoader from 'next/dist/shared/lib/image-loader';
|
||||
/**
|
||||
* For more advanced use cases, you can call `getImageProps()`
|
||||
* to get the props that would be passed to the underlying `<img>` element,
|
||||
* and instead pass to them to another component, style, canvas, etc.
|
||||
*
|
||||
* Read more: [Next.js docs: `getImageProps`](https://nextjs.org/docs/app/api-reference/components/image#getimageprops)
|
||||
*/ export function getImageProps(imgProps) {
|
||||
const { props } = getImgProps(imgProps, {
|
||||
defaultLoader,
|
||||
// This is replaced by webpack define plugin
|
||||
imgConf: process.env.__NEXT_IMAGE_OPTS
|
||||
});
|
||||
// Normally we don't care about undefined props because we pass to JSX,
|
||||
// but this exported function could be used by the end user for anything
|
||||
// so we delete undefined props to clean it up a little.
|
||||
for (const [key, value] of Object.entries(props)){
|
||||
if (value === undefined) {
|
||||
delete props[key];
|
||||
}
|
||||
}
|
||||
return {
|
||||
props
|
||||
};
|
||||
}
|
||||
export default Image;
|
||||
|
||||
//# sourceMappingURL=image-external.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/image-external.tsx"],"sourcesContent":["import type { ImageConfigComplete, ImageLoaderProps } from './image-config'\nimport type { ImageProps, ImageLoader, StaticImageData } from './get-img-props'\n\nimport { getImgProps } from './get-img-props'\nimport { Image } from '../../client/image-component'\n\n// @ts-ignore - This is replaced by webpack alias\nimport defaultLoader from 'next/dist/shared/lib/image-loader'\n\n/**\n * For more advanced use cases, you can call `getImageProps()`\n * to get the props that would be passed to the underlying `<img>` element,\n * and instead pass to them to another component, style, canvas, etc.\n *\n * Read more: [Next.js docs: `getImageProps`](https://nextjs.org/docs/app/api-reference/components/image#getimageprops)\n */\nexport function getImageProps(imgProps: ImageProps) {\n const { props } = getImgProps(imgProps, {\n defaultLoader,\n // This is replaced by webpack define plugin\n imgConf: process.env.__NEXT_IMAGE_OPTS as any as ImageConfigComplete,\n })\n // Normally we don't care about undefined props because we pass to JSX,\n // but this exported function could be used by the end user for anything\n // so we delete undefined props to clean it up a little.\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined) {\n delete props[key as keyof typeof props]\n }\n }\n return { props }\n}\n\nexport default Image\n\nexport type { ImageProps, ImageLoaderProps, ImageLoader, StaticImageData }\n"],"names":["getImgProps","Image","defaultLoader","getImageProps","imgProps","props","imgConf","process","env","__NEXT_IMAGE_OPTS","key","value","Object","entries","undefined"],"mappings":"AAGA,SAASA,WAAW,QAAQ,kBAAiB;AAC7C,SAASC,KAAK,QAAQ,+BAA8B;AAEpD,iDAAiD;AACjD,OAAOC,mBAAmB,oCAAmC;AAE7D;;;;;;CAMC,GACD,OAAO,SAASC,cAAcC,QAAoB;IAChD,MAAM,EAAEC,KAAK,EAAE,GAAGL,YAAYI,UAAU;QACtCF;QACA,4CAA4C;QAC5CI,SAASC,QAAQC,GAAG,CAACC,iBAAiB;IACxC;IACA,uEAAuE;IACvE,wEAAwE;IACxE,wDAAwD;IACxD,KAAK,MAAM,CAACC,KAAKC,MAAM,IAAIC,OAAOC,OAAO,CAACR,OAAQ;QAChD,IAAIM,UAAUG,WAAW;YACvB,OAAOT,KAAK,CAACK,IAA0B;QACzC;IACF;IACA,OAAO;QAAEL;IAAM;AACjB;AAEA,eAAeJ,MAAK"}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
const DEFAULT_Q = 75;
|
||||
function defaultLoader(param) {
|
||||
let { config, src, width, quality } = param;
|
||||
var _config_qualities;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
const missingValues = [];
|
||||
// these should always be provided but make sure they are
|
||||
if (!src) missingValues.push('src');
|
||||
if (!width) missingValues.push('width');
|
||||
if (missingValues.length > 0) {
|
||||
throw Object.defineProperty(new Error("Next Image Optimization requires " + missingValues.join(', ') + " to be provided. Make sure you pass them as props to the `next/image` component. Received: " + JSON.stringify({
|
||||
src,
|
||||
width,
|
||||
quality
|
||||
})), "__NEXT_ERROR_CODE", {
|
||||
value: "E188",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (src.startsWith('//')) {
|
||||
throw Object.defineProperty(new Error('Failed to parse src "' + src + '" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'), "__NEXT_ERROR_CODE", {
|
||||
value: "E360",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (src.startsWith('/') && config.localPatterns) {
|
||||
if (process.env.NODE_ENV !== 'test' && // micromatch isn't compatible with edge runtime
|
||||
process.env.NEXT_RUNTIME !== 'edge') {
|
||||
// We use dynamic require because this should only error in development
|
||||
const { hasLocalMatch } = require('./match-local-pattern');
|
||||
if (!hasLocalMatch(config.localPatterns, src)) {
|
||||
throw Object.defineProperty(new Error("Invalid src prop (" + src + ") on `next/image` does not match `images.localPatterns` configured in your `next.config.js`\n" + "See more info: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns"), "__NEXT_ERROR_CODE", {
|
||||
value: "E426",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!src.startsWith('/') && (config.domains || config.remotePatterns)) {
|
||||
let parsedSrc;
|
||||
try {
|
||||
parsedSrc = new URL(src);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
throw Object.defineProperty(new Error('Failed to parse src "' + src + '" on `next/image`, if using relative image it must start with a leading slash "/" or be an absolute URL (http:// or https://)'), "__NEXT_ERROR_CODE", {
|
||||
value: "E63",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
if (process.env.NODE_ENV !== 'test' && // micromatch isn't compatible with edge runtime
|
||||
process.env.NEXT_RUNTIME !== 'edge') {
|
||||
// We use dynamic require because this should only error in development
|
||||
const { hasRemoteMatch } = require('./match-remote-pattern');
|
||||
if (!hasRemoteMatch(config.domains, config.remotePatterns, parsedSrc)) {
|
||||
throw Object.defineProperty(new Error("Invalid src prop (" + src + ') on `next/image`, hostname "' + parsedSrc.hostname + '" is not configured under images in your `next.config.js`\n' + "See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host"), "__NEXT_ERROR_CODE", {
|
||||
value: "E231",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (quality && config.qualities && !config.qualities.includes(quality)) {
|
||||
throw Object.defineProperty(new Error("Invalid quality prop (" + quality + ") on `next/image` does not match `images.qualities` configured in your `next.config.js`\n" + "See more info: https://nextjs.org/docs/messages/next-image-unconfigured-qualities"), "__NEXT_ERROR_CODE", {
|
||||
value: "E623",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
}
|
||||
const q = quality || ((_config_qualities = config.qualities) == null ? void 0 : _config_qualities.reduce((prev, cur)=>Math.abs(cur - DEFAULT_Q) < Math.abs(prev - DEFAULT_Q) ? cur : prev)) || DEFAULT_Q;
|
||||
return config.path + "?url=" + encodeURIComponent(src) + "&w=" + width + "&q=" + q + (src.startsWith('/_next/static/media/') && process.env.NEXT_DEPLOYMENT_ID ? "&dpl=" + process.env.NEXT_DEPLOYMENT_ID : '');
|
||||
}
|
||||
// We use this to determine if the import is the default loader
|
||||
// or a custom loader defined by the user in next.config.js
|
||||
defaultLoader.__next_img_default = true;
|
||||
export default defaultLoader;
|
||||
|
||||
//# sourceMappingURL=image-loader.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/image-loader.ts"],"sourcesContent":["import type { ImageLoaderPropsWithConfig } from './image-config'\n\nconst DEFAULT_Q = 75\n\nfunction defaultLoader({\n config,\n src,\n width,\n quality,\n}: ImageLoaderPropsWithConfig): string {\n if (process.env.NODE_ENV !== 'production') {\n const missingValues = []\n\n // these should always be provided but make sure they are\n if (!src) missingValues.push('src')\n if (!width) missingValues.push('width')\n\n if (missingValues.length > 0) {\n throw new Error(\n `Next Image Optimization requires ${missingValues.join(\n ', '\n )} to be provided. Make sure you pass them as props to the \\`next/image\\` component. Received: ${JSON.stringify(\n { src, width, quality }\n )}`\n )\n }\n\n if (src.startsWith('//')) {\n throw new Error(\n `Failed to parse src \"${src}\" on \\`next/image\\`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)`\n )\n }\n\n if (src.startsWith('/') && config.localPatterns) {\n if (\n process.env.NODE_ENV !== 'test' &&\n // micromatch isn't compatible with edge runtime\n process.env.NEXT_RUNTIME !== 'edge'\n ) {\n // We use dynamic require because this should only error in development\n const { hasLocalMatch } = require('./match-local-pattern')\n if (!hasLocalMatch(config.localPatterns, src)) {\n throw new Error(\n `Invalid src prop (${src}) on \\`next/image\\` does not match \\`images.localPatterns\\` configured in your \\`next.config.js\\`\\n` +\n `See more info: https://nextjs.org/docs/messages/next-image-unconfigured-localpatterns`\n )\n }\n }\n }\n\n if (!src.startsWith('/') && (config.domains || config.remotePatterns)) {\n let parsedSrc: URL\n try {\n parsedSrc = new URL(src)\n } catch (err) {\n console.error(err)\n throw new Error(\n `Failed to parse src \"${src}\" on \\`next/image\\`, if using relative image it must start with a leading slash \"/\" or be an absolute URL (http:// or https://)`\n )\n }\n\n if (\n process.env.NODE_ENV !== 'test' &&\n // micromatch isn't compatible with edge runtime\n process.env.NEXT_RUNTIME !== 'edge'\n ) {\n // We use dynamic require because this should only error in development\n const { hasRemoteMatch } = require('./match-remote-pattern')\n if (!hasRemoteMatch(config.domains, config.remotePatterns, parsedSrc)) {\n throw new Error(\n `Invalid src prop (${src}) on \\`next/image\\`, hostname \"${parsedSrc.hostname}\" is not configured under images in your \\`next.config.js\\`\\n` +\n `See more info: https://nextjs.org/docs/messages/next-image-unconfigured-host`\n )\n }\n }\n }\n\n if (quality && config.qualities && !config.qualities.includes(quality)) {\n throw new Error(\n `Invalid quality prop (${quality}) on \\`next/image\\` does not match \\`images.qualities\\` configured in your \\`next.config.js\\`\\n` +\n `See more info: https://nextjs.org/docs/messages/next-image-unconfigured-qualities`\n )\n }\n }\n\n const q =\n quality ||\n config.qualities?.reduce((prev, cur) =>\n Math.abs(cur - DEFAULT_Q) < Math.abs(prev - DEFAULT_Q) ? cur : prev\n ) ||\n DEFAULT_Q\n\n return `${config.path}?url=${encodeURIComponent(src)}&w=${width}&q=${q}${\n src.startsWith('/_next/static/media/') && process.env.NEXT_DEPLOYMENT_ID\n ? `&dpl=${process.env.NEXT_DEPLOYMENT_ID}`\n : ''\n }`\n}\n\n// We use this to determine if the import is the default loader\n// or a custom loader defined by the user in next.config.js\ndefaultLoader.__next_img_default = true\n\nexport default defaultLoader\n"],"names":["DEFAULT_Q","defaultLoader","config","src","width","quality","process","env","NODE_ENV","missingValues","push","length","Error","join","JSON","stringify","startsWith","localPatterns","NEXT_RUNTIME","hasLocalMatch","require","domains","remotePatterns","parsedSrc","URL","err","console","error","hasRemoteMatch","hostname","qualities","includes","q","reduce","prev","cur","Math","abs","path","encodeURIComponent","NEXT_DEPLOYMENT_ID","__next_img_default"],"mappings":"AAEA,MAAMA,YAAY;AAElB,SAASC,cAAc,KAKM;IALN,IAAA,EACrBC,MAAM,EACNC,GAAG,EACHC,KAAK,EACLC,OAAO,EACoB,GALN;QAmFnBH;IA7EF,IAAII,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,MAAMC,gBAAgB,EAAE;QAExB,yDAAyD;QACzD,IAAI,CAACN,KAAKM,cAAcC,IAAI,CAAC;QAC7B,IAAI,CAACN,OAAOK,cAAcC,IAAI,CAAC;QAE/B,IAAID,cAAcE,MAAM,GAAG,GAAG;YAC5B,MAAM,qBAML,CANK,IAAIC,MACR,AAAC,sCAAmCH,cAAcI,IAAI,CACpD,QACA,gGAA+FC,KAAKC,SAAS,CAC7G;gBAAEZ;gBAAKC;gBAAOC;YAAQ,KAJpB,qBAAA;uBAAA;4BAAA;8BAAA;YAMN;QACF;QAEA,IAAIF,IAAIa,UAAU,CAAC,OAAO;YACxB,MAAM,qBAEL,CAFK,IAAIJ,MACR,AAAC,0BAAuBT,MAAI,2GADxB,qBAAA;uBAAA;4BAAALine truncated
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
export class InvariantError extends Error {
|
||||
constructor(message, options){
|
||||
super("Invariant: " + (message.endsWith('.') ? message : message + '.') + " This is a bug in Next.js.", options);
|
||||
this.name = 'InvariantError';
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=invariant-error.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/invariant-error.ts"],"sourcesContent":["export class InvariantError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(\n `Invariant: ${message.endsWith('.') ? message : message + '.'} This is a bug in Next.js.`,\n options\n )\n this.name = 'InvariantError'\n }\n}\n"],"names":["InvariantError","Error","constructor","message","options","endsWith","name"],"mappings":"AAAA,OAAO,MAAMA,uBAAuBC;IAClCC,YAAYC,OAAe,EAAEC,OAAsB,CAAE;QACnD,KAAK,CACH,AAAC,gBAAaD,CAAAA,QAAQE,QAAQ,CAAC,OAAOF,UAAUA,UAAU,GAAE,IAAE,8BAC9DC;QAEF,IAAI,CAACE,IAAI,GAAG;IACd;AACF"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/** React that's compiled with `next`. Used by App Router. */ export const reactVendoredRe = /[\\/]next[\\/]dist[\\/]compiled[\\/](react|react-dom|react-server-dom-(webpack|turbopack)|scheduler)[\\/]/;
|
||||
/** React the user installed. Used by Pages Router, or user imports in App Router. */ export const reactNodeModulesRe = /node_modules[\\/](react|react-dom|scheduler)[\\/]/;
|
||||
export const nextInternalsRe = /(node_modules[\\/]next[\\/]|[\\/].next[\\/]static[\\/]chunks[\\/]webpack\.js$|(edge-runtime-webpack|webpack-runtime)\.js$)/;
|
||||
export default function isInternal(file) {
|
||||
if (!file) return false;
|
||||
return nextInternalsRe.test(file) || reactVendoredRe.test(file) || reactNodeModulesRe.test(file);
|
||||
}
|
||||
|
||||
//# sourceMappingURL=is-internal.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/is-internal.ts"],"sourcesContent":["/** React that's compiled with `next`. Used by App Router. */\nexport const reactVendoredRe =\n /[\\\\/]next[\\\\/]dist[\\\\/]compiled[\\\\/](react|react-dom|react-server-dom-(webpack|turbopack)|scheduler)[\\\\/]/\n\n/** React the user installed. Used by Pages Router, or user imports in App Router. */\nexport const reactNodeModulesRe =\n /node_modules[\\\\/](react|react-dom|scheduler)[\\\\/]/\n\nexport const nextInternalsRe =\n /(node_modules[\\\\/]next[\\\\/]|[\\\\/].next[\\\\/]static[\\\\/]chunks[\\\\/]webpack\\.js$|(edge-runtime-webpack|webpack-runtime)\\.js$)/\n\nexport default function isInternal(file: string | null) {\n if (!file) return false\n\n return (\n nextInternalsRe.test(file) ||\n reactVendoredRe.test(file) ||\n reactNodeModulesRe.test(file)\n )\n}\n"],"names":["reactVendoredRe","reactNodeModulesRe","nextInternalsRe","isInternal","file","test"],"mappings":"AAAA,2DAA2D,GAC3D,OAAO,MAAMA,kBACX,4GAA2G;AAE7G,mFAAmF,GACnF,OAAO,MAAMC,qBACX,oDAAmD;AAErD,OAAO,MAAMC,kBACX,6HAA4H;AAE9H,eAAe,SAASC,WAAWC,IAAmB;IACpD,IAAI,CAACA,MAAM,OAAO;IAElB,OACEF,gBAAgBG,IAAI,CAACD,SACrBJ,gBAAgBK,IAAI,CAACD,SACrBH,mBAAmBI,IAAI,CAACD;AAE5B"}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
export function getObjectClassLabel(value) {
|
||||
return Object.prototype.toString.call(value);
|
||||
}
|
||||
export function isPlainObject(value) {
|
||||
if (getObjectClassLabel(value) !== '[object Object]') {
|
||||
return false;
|
||||
}
|
||||
const prototype = Object.getPrototypeOf(value);
|
||||
/**
|
||||
* this used to be previously:
|
||||
*
|
||||
* `return prototype === null || prototype === Object.prototype`
|
||||
*
|
||||
* but Edge Runtime expose Object from vm, being that kind of type-checking wrongly fail.
|
||||
*
|
||||
* It was changed to the current implementation since it's resilient to serialization.
|
||||
*/ return prototype === null || prototype.hasOwnProperty('isPrototypeOf');
|
||||
}
|
||||
|
||||
//# sourceMappingURL=is-plain-object.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/is-plain-object.ts"],"sourcesContent":["export function getObjectClassLabel(value: any): string {\n return Object.prototype.toString.call(value)\n}\n\nexport function isPlainObject(value: any): boolean {\n if (getObjectClassLabel(value) !== '[object Object]') {\n return false\n }\n\n const prototype = Object.getPrototypeOf(value)\n\n /**\n * this used to be previously:\n *\n * `return prototype === null || prototype === Object.prototype`\n *\n * but Edge Runtime expose Object from vm, being that kind of type-checking wrongly fail.\n *\n * It was changed to the current implementation since it's resilient to serialization.\n */\n return prototype === null || prototype.hasOwnProperty('isPrototypeOf')\n}\n"],"names":["getObjectClassLabel","value","Object","prototype","toString","call","isPlainObject","getPrototypeOf","hasOwnProperty"],"mappings":"AAAA,OAAO,SAASA,oBAAoBC,KAAU;IAC5C,OAAOC,OAAOC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACJ;AACxC;AAEA,OAAO,SAASK,cAAcL,KAAU;IACtC,IAAID,oBAAoBC,WAAW,mBAAmB;QACpD,OAAO;IACT;IAEA,MAAME,YAAYD,OAAOK,cAAc,CAACN;IAExC;;;;;;;;GAQC,GACD,OAAOE,cAAc,QAAQA,UAAUK,cAAc,CAAC;AACxD"}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Check to see if a value is Thenable.
|
||||
*
|
||||
* @param promise the maybe-thenable value
|
||||
* @returns true if the value is thenable
|
||||
*/ export function isThenable(promise) {
|
||||
return promise !== null && typeof promise === 'object' && 'then' in promise && typeof promise.then === 'function';
|
||||
}
|
||||
|
||||
//# sourceMappingURL=is-thenable.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/is-thenable.ts"],"sourcesContent":["/**\n * Check to see if a value is Thenable.\n *\n * @param promise the maybe-thenable value\n * @returns true if the value is thenable\n */\nexport function isThenable<T = unknown>(\n promise: Promise<T> | T\n): promise is Promise<T> {\n return (\n promise !== null &&\n typeof promise === 'object' &&\n 'then' in promise &&\n typeof promise.then === 'function'\n )\n}\n"],"names":["isThenable","promise","then"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,SAASA,WACdC,OAAuB;IAEvB,OACEA,YAAY,QACZ,OAAOA,YAAY,YACnB,UAAUA,WACV,OAAOA,QAAQC,IAAI,KAAK;AAE5B"}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export { default } from 'path'
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* This module is for next.js server internal usage of path module.
|
||||
* It will use native path module for nodejs runtime.
|
||||
* It will use path-browserify polyfill for edge runtime.
|
||||
*/ let path;
|
||||
if (process.env.NEXT_RUNTIME === 'edge') {
|
||||
path = require('next/dist/compiled/path-browserify');
|
||||
} else {
|
||||
path = require('path');
|
||||
}
|
||||
module.exports = path;
|
||||
|
||||
//# sourceMappingURL=path.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/isomorphic/path.js"],"sourcesContent":["/**\n * This module is for next.js server internal usage of path module.\n * It will use native path module for nodejs runtime.\n * It will use path-browserify polyfill for edge runtime.\n */\nlet path\n\nif (process.env.NEXT_RUNTIME === 'edge') {\n path = require('next/dist/compiled/path-browserify')\n} else {\n path = require('path')\n}\n\nmodule.exports = path\n"],"names":["path","process","env","NEXT_RUNTIME","require","module","exports"],"mappings":"AAAA;;;;CAIC,GACD,IAAIA;AAEJ,IAAIC,QAAQC,GAAG,CAACC,YAAY,KAAK,QAAQ;IACvCH,OAAOI,QAAQ;AACjB,OAAO;IACLJ,OAAOI,QAAQ;AACjB;AAEAC,OAAOC,OAAO,GAAGN"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// This has to be a shared module which is shared between client component error boundary and dynamic component
|
||||
const BAILOUT_TO_CSR = 'BAILOUT_TO_CLIENT_SIDE_RENDERING';
|
||||
/** An error that should be thrown when we want to bail out to client-side rendering. */ export class BailoutToCSRError extends Error {
|
||||
constructor(reason){
|
||||
super("Bail out to client-side rendering: " + reason), this.reason = reason, this.digest = BAILOUT_TO_CSR;
|
||||
}
|
||||
}
|
||||
/** Checks if a passed argument is an error that is thrown if we want to bail out to client-side rendering. */ export function isBailoutToCSRError(err) {
|
||||
if (typeof err !== 'object' || err === null || !('digest' in err)) {
|
||||
return false;
|
||||
}
|
||||
return err.digest === BAILOUT_TO_CSR;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=bailout-to-csr.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/lazy-dynamic/bailout-to-csr.ts"],"sourcesContent":["// This has to be a shared module which is shared between client component error boundary and dynamic component\nconst BAILOUT_TO_CSR = 'BAILOUT_TO_CLIENT_SIDE_RENDERING'\n\n/** An error that should be thrown when we want to bail out to client-side rendering. */\nexport class BailoutToCSRError extends Error {\n public readonly digest = BAILOUT_TO_CSR\n\n constructor(public readonly reason: string) {\n super(`Bail out to client-side rendering: ${reason}`)\n }\n}\n\n/** Checks if a passed argument is an error that is thrown if we want to bail out to client-side rendering. */\nexport function isBailoutToCSRError(err: unknown): err is BailoutToCSRError {\n if (typeof err !== 'object' || err === null || !('digest' in err)) {\n return false\n }\n\n return err.digest === BAILOUT_TO_CSR\n}\n"],"names":["BAILOUT_TO_CSR","BailoutToCSRError","Error","constructor","reason","digest","isBailoutToCSRError","err"],"mappings":"AAAA,+GAA+G;AAC/G,MAAMA,iBAAiB;AAEvB,sFAAsF,GACtF,OAAO,MAAMC,0BAA0BC;IAGrCC,YAAY,AAAgBC,MAAc,CAAE;QAC1C,KAAK,CAAC,AAAC,wCAAqCA,cADlBA,SAAAA,aAFZC,SAASL;IAIzB;AACF;AAEA,4GAA4G,GAC5G,OAAO,SAASM,oBAAoBC,GAAY;IAC9C,IAAI,OAAOA,QAAQ,YAAYA,QAAQ,QAAQ,CAAE,CAAA,YAAYA,GAAE,GAAI;QACjE,OAAO;IACT;IAEA,OAAOA,IAAIF,MAAM,KAAKL;AACxB"}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
'use client';
|
||||
import { BailoutToCSRError } from './bailout-to-csr';
|
||||
/**
|
||||
* If rendered on the server, this component throws an error
|
||||
* to signal Next.js that it should bail out to client-side rendering instead.
|
||||
*/ export function BailoutToCSR(param) {
|
||||
let { reason, children } = param;
|
||||
if (typeof window === 'undefined') {
|
||||
throw Object.defineProperty(new BailoutToCSRError(reason), "__NEXT_ERROR_CODE", {
|
||||
value: "E394",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=dynamic-bailout-to-csr.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/lazy-dynamic/dynamic-bailout-to-csr.tsx"],"sourcesContent":["'use client'\n\nimport type { ReactElement } from 'react'\nimport { BailoutToCSRError } from './bailout-to-csr'\n\ninterface BailoutToCSRProps {\n reason: string\n children: ReactElement\n}\n\n/**\n * If rendered on the server, this component throws an error\n * to signal Next.js that it should bail out to client-side rendering instead.\n */\nexport function BailoutToCSR({ reason, children }: BailoutToCSRProps) {\n if (typeof window === 'undefined') {\n throw new BailoutToCSRError(reason)\n }\n\n return children\n}\n"],"names":["BailoutToCSRError","BailoutToCSR","reason","children","window"],"mappings":"AAAA;AAGA,SAASA,iBAAiB,QAAQ,mBAAkB;AAOpD;;;CAGC,GACD,OAAO,SAASC,aAAa,KAAuC;IAAvC,IAAA,EAAEC,MAAM,EAAEC,QAAQ,EAAqB,GAAvC;IAC3B,IAAI,OAAOC,WAAW,aAAa;QACjC,MAAM,qBAA6B,CAA7B,IAAIJ,kBAAkBE,SAAtB,qBAAA;mBAAA;wBAAA;0BAAA;QAA4B;IACpC;IAEA,OAAOC;AACT"}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
||||
import { Suspense, Fragment, lazy } from 'react';
|
||||
import { BailoutToCSR } from './dynamic-bailout-to-csr';
|
||||
import { PreloadChunks } from './preload-chunks';
|
||||
// Normalize loader to return the module as form { default: Component } for `React.lazy`.
|
||||
// Also for backward compatible since next/dynamic allows to resolve a component directly with loader
|
||||
// Client component reference proxy need to be converted to a module.
|
||||
function convertModule(mod) {
|
||||
// Check "default" prop before accessing it, as it could be client reference proxy that could break it reference.
|
||||
// Cases:
|
||||
// mod: { default: Component }
|
||||
// mod: Component
|
||||
// mod: { default: proxy(Component) }
|
||||
// mod: proxy(Component)
|
||||
const hasDefault = mod && 'default' in mod;
|
||||
return {
|
||||
default: hasDefault ? mod.default : mod
|
||||
};
|
||||
}
|
||||
const defaultOptions = {
|
||||
loader: ()=>Promise.resolve(convertModule(()=>null)),
|
||||
loading: null,
|
||||
ssr: true
|
||||
};
|
||||
function Loadable(options) {
|
||||
const opts = {
|
||||
...defaultOptions,
|
||||
...options
|
||||
};
|
||||
const Lazy = /*#__PURE__*/ lazy(()=>opts.loader().then(convertModule));
|
||||
const Loading = opts.loading;
|
||||
function LoadableComponent(props) {
|
||||
const fallbackElement = Loading ? /*#__PURE__*/ _jsx(Loading, {
|
||||
isLoading: true,
|
||||
pastDelay: true,
|
||||
error: null
|
||||
}) : null;
|
||||
// If it's non-SSR or provided a loading component, wrap it in a suspense boundary
|
||||
const hasSuspenseBoundary = !opts.ssr || !!opts.loading;
|
||||
const Wrap = hasSuspenseBoundary ? Suspense : Fragment;
|
||||
const wrapProps = hasSuspenseBoundary ? {
|
||||
fallback: fallbackElement
|
||||
} : {};
|
||||
const children = opts.ssr ? /*#__PURE__*/ _jsxs(_Fragment, {
|
||||
children: [
|
||||
typeof window === 'undefined' ? /*#__PURE__*/ _jsx(PreloadChunks, {
|
||||
moduleIds: opts.modules
|
||||
}) : null,
|
||||
/*#__PURE__*/ _jsx(Lazy, {
|
||||
...props
|
||||
})
|
||||
]
|
||||
}) : /*#__PURE__*/ _jsx(BailoutToCSR, {
|
||||
reason: "next/dynamic",
|
||||
children: /*#__PURE__*/ _jsx(Lazy, {
|
||||
...props
|
||||
})
|
||||
});
|
||||
return /*#__PURE__*/ _jsx(Wrap, {
|
||||
...wrapProps,
|
||||
children: children
|
||||
});
|
||||
}
|
||||
LoadableComponent.displayName = 'LoadableComponent';
|
||||
return LoadableComponent;
|
||||
}
|
||||
export default Loadable;
|
||||
|
||||
//# sourceMappingURL=loadable.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/lazy-dynamic/loadable.tsx"],"sourcesContent":["import { Suspense, Fragment, lazy } from 'react'\nimport { BailoutToCSR } from './dynamic-bailout-to-csr'\nimport type { ComponentModule } from './types'\nimport { PreloadChunks } from './preload-chunks'\n\n// Normalize loader to return the module as form { default: Component } for `React.lazy`.\n// Also for backward compatible since next/dynamic allows to resolve a component directly with loader\n// Client component reference proxy need to be converted to a module.\nfunction convertModule<P>(\n mod: React.ComponentType<P> | ComponentModule<P> | undefined\n): {\n default: React.ComponentType<P>\n} {\n // Check \"default\" prop before accessing it, as it could be client reference proxy that could break it reference.\n // Cases:\n // mod: { default: Component }\n // mod: Component\n // mod: { default: proxy(Component) }\n // mod: proxy(Component)\n const hasDefault = mod && 'default' in mod\n return {\n default: hasDefault\n ? (mod as ComponentModule<P>).default\n : (mod as React.ComponentType<P>),\n }\n}\n\nconst defaultOptions = {\n loader: () => Promise.resolve(convertModule(() => null)),\n loading: null,\n ssr: true,\n}\n\ninterface LoadableOptions {\n loader?: () => Promise<React.ComponentType<any> | ComponentModule<any>>\n loading?: React.ComponentType<any> | null\n ssr?: boolean\n modules?: string[]\n}\n\nfunction Loadable(options: LoadableOptions) {\n const opts = { ...defaultOptions, ...options }\n const Lazy = lazy(() => opts.loader().then(convertModule))\n const Loading = opts.loading\n\n function LoadableComponent(props: any) {\n const fallbackElement = Loading ? (\n <Loading isLoading={true} pastDelay={true} error={null} />\n ) : null\n\n // If it's non-SSR or provided a loading component, wrap it in a suspense boundary\n const hasSuspenseBoundary = !opts.ssr || !!opts.loading\n const Wrap = hasSuspenseBoundary ? Suspense : Fragment\n const wrapProps = hasSuspenseBoundary ? { fallback: fallbackElement } : {}\n const children = opts.ssr ? (\n <>\n {/* During SSR, we need to preload the CSS from the dynamic component to avoid flash of unstyled content */}\n {typeof window === 'undefined' ? (\n <PreloadChunks moduleIds={opts.modules} />\n ) : null}\n <Lazy {...props} />\n </>\n ) : (\n <BailoutToCSR reason=\"next/dynamic\">\n <Lazy {...props} />\n </BailoutToCSR>\n )\n\n return <Wrap {...wrapProps}>{children}</Wrap>\n }\n\n LoadableComponent.displayName = 'LoadableComponent'\n\n return LoadableComponent\n}\n\nexport default Loadable\n"],"names":["Suspense","Fragment","lazy","BailoutToCSR","PreloadChunks","convertModule","mod","hasDefault","default","defaultOptions","loader","Promise","resolve","loading","ssr","Loadable","options","opts","Lazy","then","Loading","LoadableComponent","props","fallbackElement","isLoading","pastDelay","error","hasSuspenseBoundary","Wrap","wrapProps","fallback","children","window","moduleIds","modules","reason","displayName"],"mappings":";AAAA,SAASA,QAAQ,EAAEC,QAAQ,EAAEC,IAAI,QAAQ,QAAO;AAChD,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,SAASC,aAAa,QAAQ,mBAAkB;AAEhD,yFAAyF;AACzF,qGAAqG;AACrG,qEAAqE;AACrE,SAASC,cACPC,GAA4D;IAI5D,iHAAiH;IACjH,SAAS;IACT,8BAA8B;IAC9B,iBAAiB;IACjB,qCAAqC;IACrC,wBAAwB;IACxB,MAAMC,aAAaD,OAAO,aAAaA;IACvC,OAAO;QACLE,SAASD,aACL,AAACD,IAA2BE,OAAO,GAClCF;IACP;AACF;AAEA,MAAMG,iBAAiB;IACrBC,QAAQ,IAAMC,QAAQC,OAAO,CAACP,cAAc,IAAM;IAClDQ,SAAS;IACTC,KAAK;AACP;AASA,SAASC,SAASC,OAAwB;IACxC,MAAMC,OAAO;QAAE,GAAGR,cAAc;QAAE,GAAGO,OAAO;IAAC;IAC7C,MAAME,qBAAOhB,KAAK,IAAMe,KAAKP,MAAM,GAAGS,IAAI,CAACd;IAC3C,MAAMe,UAAUH,KAAKJ,OAAO;IAE5B,SAASQ,kBAAkBC,KAAU;QACnC,MAAMC,kBAAkBH,wBACtB,KAACA;YAAQI,WAAW;YAAMC,WAAW;YAAMC,OAAO;aAChD;QAEJ,kFAAkF;QAClF,MAAMC,sBAAsB,CAACV,KAAKH,GAAG,IAAI,CAAC,CAACG,KAAKJ,OAAO;QACvD,MAAMe,OAAOD,sBAAsB3B,WAAWC;QAC9C,MAAM4B,YAAYF,sBAAsB;YAAEG,UAAUP;QAAgB,IAAI,CAAC;QACzE,MAAMQ,WAAWd,KAAKH,GAAG,iBACvB;;gBAEG,OAAOkB,WAAW,4BACjB,KAAC5B;oBAAc6B,WAAWhB,KAAKiB,OAAO;qBACpC;8BACJ,KAAChB;oBAAM,GAAGI,KAAK;;;2BAGjB,KAACnB;YAAagC,QAAO;sBACnB,cAAA,KAACjB;gBAAM,GAAGI,KAAK;;;QAInB,qBAAO,KAACM;YAAM,GAAGC,SAAS;sBAAGE;;IAC/B;IAEAV,kBAAkBe,WAAW,GAAG;IAEhC,OAAOf;AACT;AAEA,eAAeN,SAAQ"}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
'use client';
|
||||
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
||||
import { preload } from 'react-dom';
|
||||
import { workAsyncStorage } from '../../../server/app-render/work-async-storage.external';
|
||||
import { encodeURIPath } from '../encode-uri-path';
|
||||
export function PreloadChunks(param) {
|
||||
let { moduleIds } = param;
|
||||
// Early return in client compilation and only load requestStore on server side
|
||||
if (typeof window !== 'undefined') {
|
||||
return null;
|
||||
}
|
||||
const workStore = workAsyncStorage.getStore();
|
||||
if (workStore === undefined) {
|
||||
return null;
|
||||
}
|
||||
const allFiles = [];
|
||||
// Search the current dynamic call unique key id in react loadable manifest,
|
||||
// and find the corresponding CSS files to preload
|
||||
if (workStore.reactLoadableManifest && moduleIds) {
|
||||
const manifest = workStore.reactLoadableManifest;
|
||||
for (const key of moduleIds){
|
||||
if (!manifest[key]) continue;
|
||||
const chunks = manifest[key].files;
|
||||
allFiles.push(...chunks);
|
||||
}
|
||||
}
|
||||
if (allFiles.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const dplId = process.env.NEXT_DEPLOYMENT_ID ? "?dpl=" + process.env.NEXT_DEPLOYMENT_ID : '';
|
||||
return /*#__PURE__*/ _jsx(_Fragment, {
|
||||
children: allFiles.map((chunk)=>{
|
||||
const href = workStore.assetPrefix + "/_next/" + encodeURIPath(chunk) + dplId;
|
||||
const isCss = chunk.endsWith('.css');
|
||||
// If it's stylesheet we use `precedence` o help hoist with React Float.
|
||||
// For stylesheets we actually need to render the CSS because nothing else is going to do it so it needs to be part of the component tree.
|
||||
// The `preload` for stylesheet is not optional.
|
||||
if (isCss) {
|
||||
return /*#__PURE__*/ _jsx("link", {
|
||||
// @ts-ignore
|
||||
precedence: "dynamic",
|
||||
href: href,
|
||||
rel: "stylesheet",
|
||||
as: "style"
|
||||
}, chunk);
|
||||
} else {
|
||||
// If it's script we use ReactDOM.preload to preload the resources
|
||||
preload(href, {
|
||||
as: 'script',
|
||||
fetchPriority: 'low'
|
||||
});
|
||||
return null;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
//# sourceMappingURL=preload-chunks.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/lazy-dynamic/preload-chunks.tsx"],"sourcesContent":["'use client'\n\nimport { preload } from 'react-dom'\n\nimport { workAsyncStorage } from '../../../server/app-render/work-async-storage.external'\nimport { encodeURIPath } from '../encode-uri-path'\n\nexport function PreloadChunks({\n moduleIds,\n}: {\n moduleIds: string[] | undefined\n}) {\n // Early return in client compilation and only load requestStore on server side\n if (typeof window !== 'undefined') {\n return null\n }\n\n const workStore = workAsyncStorage.getStore()\n if (workStore === undefined) {\n return null\n }\n\n const allFiles = []\n\n // Search the current dynamic call unique key id in react loadable manifest,\n // and find the corresponding CSS files to preload\n if (workStore.reactLoadableManifest && moduleIds) {\n const manifest = workStore.reactLoadableManifest\n for (const key of moduleIds) {\n if (!manifest[key]) continue\n const chunks = manifest[key].files\n allFiles.push(...chunks)\n }\n }\n\n if (allFiles.length === 0) {\n return null\n }\n\n const dplId = process.env.NEXT_DEPLOYMENT_ID\n ? `?dpl=${process.env.NEXT_DEPLOYMENT_ID}`\n : ''\n\n return (\n <>\n {allFiles.map((chunk) => {\n const href = `${workStore.assetPrefix}/_next/${encodeURIPath(chunk)}${dplId}`\n const isCss = chunk.endsWith('.css')\n // If it's stylesheet we use `precedence` o help hoist with React Float.\n // For stylesheets we actually need to render the CSS because nothing else is going to do it so it needs to be part of the component tree.\n // The `preload` for stylesheet is not optional.\n if (isCss) {\n return (\n <link\n key={chunk}\n // @ts-ignore\n precedence=\"dynamic\"\n href={href}\n rel=\"stylesheet\"\n as=\"style\"\n />\n )\n } else {\n // If it's script we use ReactDOM.preload to preload the resources\n preload(href, {\n as: 'script',\n fetchPriority: 'low',\n })\n return null\n }\n })}\n </>\n )\n}\n"],"names":["preload","workAsyncStorage","encodeURIPath","PreloadChunks","moduleIds","window","workStore","getStore","undefined","allFiles","reactLoadableManifest","manifest","key","chunks","files","push","length","dplId","process","env","NEXT_DEPLOYMENT_ID","map","chunk","href","assetPrefix","isCss","endsWith","link","precedence","rel","as","fetchPriority"],"mappings":"AAAA;;AAEA,SAASA,OAAO,QAAQ,YAAW;AAEnC,SAASC,gBAAgB,QAAQ,yDAAwD;AACzF,SAASC,aAAa,QAAQ,qBAAoB;AAElD,OAAO,SAASC,cAAc,KAI7B;IAJ6B,IAAA,EAC5BC,SAAS,EAGV,GAJ6B;IAK5B,+EAA+E;IAC/E,IAAI,OAAOC,WAAW,aAAa;QACjC,OAAO;IACT;IAEA,MAAMC,YAAYL,iBAAiBM,QAAQ;IAC3C,IAAID,cAAcE,WAAW;QAC3B,OAAO;IACT;IAEA,MAAMC,WAAW,EAAE;IAEnB,4EAA4E;IAC5E,kDAAkD;IAClD,IAAIH,UAAUI,qBAAqB,IAAIN,WAAW;QAChD,MAAMO,WAAWL,UAAUI,qBAAqB;QAChD,KAAK,MAAME,OAAOR,UAAW;YAC3B,IAAI,CAACO,QAAQ,CAACC,IAAI,EAAE;YACpB,MAAMC,SAASF,QAAQ,CAACC,IAAI,CAACE,KAAK;YAClCL,SAASM,IAAI,IAAIF;QACnB;IACF;IAEA,IAAIJ,SAASO,MAAM,KAAK,GAAG;QACzB,OAAO;IACT;IAEA,MAAMC,QAAQC,QAAQC,GAAG,CAACC,kBAAkB,GACxC,AAAC,UAAOF,QAAQC,GAAG,CAACC,kBAAkB,GACtC;IAEJ,qBACE;kBACGX,SAASY,GAAG,CAAC,CAACC;YACb,MAAMC,OAAO,AAAGjB,UAAUkB,WAAW,GAAC,YAAStB,cAAcoB,SAASL;YACtE,MAAMQ,QAAQH,MAAMI,QAAQ,CAAC;YAC7B,wEAAwE;YACxE,0IAA0I;YAC1I,gDAAgD;YAChD,IAAID,OAAO;gBACT,qBACE,KAACE;oBAEC,aAAa;oBACbC,YAAW;oBACXL,MAAMA;oBACNM,KAAI;oBACJC,IAAG;mBALER;YAQX,OAAO;gBACL,kEAAkE;gBAClEtB,QAAQuB,MAAM;oBACZO,IAAI;oBACJC,eAAe;gBACjB;gBACA,OAAO;YACT;QACF;;AAGN"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export { };
|
||||
|
||||
//# sourceMappingURL=types.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/shared/lib/lazy-dynamic/types.ts"],"sourcesContent":["export type ComponentModule<P = {}> = { default: React.ComponentType<P> }\n\nexport declare type LoaderComponent<P = {}> = Promise<\n React.ComponentType<P> | ComponentModule<P>\n>\n\nexport declare type Loader<P = {}> = () => LoaderComponent<P>\n\nexport type LoadableGeneratedOptions = {\n modules?: string[]\n}\n\nexport type DynamicOptionsLoadingProps = {\n error?: Error | null\n isLoading?: boolean\n pastDelay?: boolean\n retry?: () => void\n timedOut?: boolean\n}\n"],"names":[],"mappings":"AAYA,WAMC"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
'use client';
|
||||
import React from 'react';
|
||||
export const LoadableContext = React.createContext(null);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
LoadableContext.displayName = 'LoadableContext';
|
||||
}
|
||||
|
||||
//# sourceMappingURL=loadable-context.shared-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/loadable-context.shared-runtime.ts"],"sourcesContent":["'use client'\n\nimport React from 'react'\n\ntype CaptureFn = (moduleName: string) => void\n\nexport const LoadableContext = React.createContext<CaptureFn | null>(null)\n\nif (process.env.NODE_ENV !== 'production') {\n LoadableContext.displayName = 'LoadableContext'\n}\n"],"names":["React","LoadableContext","createContext","process","env","NODE_ENV","displayName"],"mappings":"AAAA;AAEA,OAAOA,WAAW,QAAO;AAIzB,OAAO,MAAMC,kBAAkBD,MAAME,aAAa,CAAmB,MAAK;AAE1E,IAAIC,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzCJ,gBAAgBK,WAAW,GAAG;AAChC"}
|
||||
+237
@@ -0,0 +1,237 @@
|
||||
// TODO: Remove use of `any` type.
|
||||
/**
|
||||
@copyright (c) 2017-present James Kyle <me@thejameskyle.com>
|
||||
MIT License
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
||||
*/ // https://github.com/jamiebuilds/react-loadable/blob/v5.5.0/src/index.js
|
||||
// Modified to be compatible with webpack 4 / Next.js
|
||||
import React from 'react';
|
||||
import { LoadableContext } from './loadable-context.shared-runtime';
|
||||
function resolve(obj) {
|
||||
return obj && obj.default ? obj.default : obj;
|
||||
}
|
||||
const ALL_INITIALIZERS = [];
|
||||
const READY_INITIALIZERS = [];
|
||||
let initialized = false;
|
||||
function load(loader) {
|
||||
let promise = loader();
|
||||
let state = {
|
||||
loading: true,
|
||||
loaded: null,
|
||||
error: null
|
||||
};
|
||||
state.promise = promise.then((loaded)=>{
|
||||
state.loading = false;
|
||||
state.loaded = loaded;
|
||||
return loaded;
|
||||
}).catch((err)=>{
|
||||
state.loading = false;
|
||||
state.error = err;
|
||||
throw err;
|
||||
});
|
||||
return state;
|
||||
}
|
||||
function createLoadableComponent(loadFn, options) {
|
||||
let opts = Object.assign({
|
||||
loader: null,
|
||||
loading: null,
|
||||
delay: 200,
|
||||
timeout: null,
|
||||
webpack: null,
|
||||
modules: null
|
||||
}, options);
|
||||
/** @type LoadableSubscription */ let subscription = null;
|
||||
function init() {
|
||||
if (!subscription) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
const sub = new LoadableSubscription(loadFn, opts);
|
||||
subscription = {
|
||||
getCurrentValue: sub.getCurrentValue.bind(sub),
|
||||
subscribe: sub.subscribe.bind(sub),
|
||||
retry: sub.retry.bind(sub),
|
||||
promise: sub.promise.bind(sub)
|
||||
};
|
||||
}
|
||||
return subscription.promise();
|
||||
}
|
||||
// Server only
|
||||
if (typeof window === 'undefined') {
|
||||
ALL_INITIALIZERS.push(init);
|
||||
}
|
||||
// Client only
|
||||
if (!initialized && typeof window !== 'undefined') {
|
||||
// require.resolveWeak check is needed for environments that don't have it available like Jest
|
||||
const moduleIds = opts.webpack && typeof require.resolveWeak === 'function' ? opts.webpack() : opts.modules;
|
||||
if (moduleIds) {
|
||||
READY_INITIALIZERS.push((ids)=>{
|
||||
for (const moduleId of moduleIds){
|
||||
if (ids.includes(moduleId)) {
|
||||
return init();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function useLoadableModule() {
|
||||
init();
|
||||
const context = React.useContext(LoadableContext);
|
||||
if (context && Array.isArray(opts.modules)) {
|
||||
opts.modules.forEach((moduleName)=>{
|
||||
context(moduleName);
|
||||
});
|
||||
}
|
||||
}
|
||||
function LoadableComponent(props, ref) {
|
||||
useLoadableModule();
|
||||
const state = React.useSyncExternalStore(subscription.subscribe, subscription.getCurrentValue, subscription.getCurrentValue);
|
||||
React.useImperativeHandle(ref, ()=>({
|
||||
retry: subscription.retry
|
||||
}), []);
|
||||
return React.useMemo(()=>{
|
||||
if (state.loading || state.error) {
|
||||
return /*#__PURE__*/ React.createElement(opts.loading, {
|
||||
isLoading: state.loading,
|
||||
pastDelay: state.pastDelay,
|
||||
timedOut: state.timedOut,
|
||||
error: state.error,
|
||||
retry: subscription.retry
|
||||
});
|
||||
} else if (state.loaded) {
|
||||
return /*#__PURE__*/ React.createElement(resolve(state.loaded), props);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}, [
|
||||
props,
|
||||
state
|
||||
]);
|
||||
}
|
||||
LoadableComponent.preload = ()=>init();
|
||||
LoadableComponent.displayName = 'LoadableComponent';
|
||||
return /*#__PURE__*/ React.forwardRef(LoadableComponent);
|
||||
}
|
||||
class LoadableSubscription {
|
||||
promise() {
|
||||
return this._res.promise;
|
||||
}
|
||||
retry() {
|
||||
this._clearTimeouts();
|
||||
this._res = this._loadFn(this._opts.loader);
|
||||
this._state = {
|
||||
pastDelay: false,
|
||||
timedOut: false
|
||||
};
|
||||
const { _res: res, _opts: opts } = this;
|
||||
if (res.loading) {
|
||||
if (typeof opts.delay === 'number') {
|
||||
if (opts.delay === 0) {
|
||||
this._state.pastDelay = true;
|
||||
} else {
|
||||
this._delay = setTimeout(()=>{
|
||||
this._update({
|
||||
pastDelay: true
|
||||
});
|
||||
}, opts.delay);
|
||||
}
|
||||
}
|
||||
if (typeof opts.timeout === 'number') {
|
||||
this._timeout = setTimeout(()=>{
|
||||
this._update({
|
||||
timedOut: true
|
||||
});
|
||||
}, opts.timeout);
|
||||
}
|
||||
}
|
||||
this._res.promise.then(()=>{
|
||||
this._update({});
|
||||
this._clearTimeouts();
|
||||
}).catch((_err)=>{
|
||||
this._update({});
|
||||
this._clearTimeouts();
|
||||
});
|
||||
this._update({});
|
||||
}
|
||||
_update(partial) {
|
||||
this._state = {
|
||||
...this._state,
|
||||
error: this._res.error,
|
||||
loaded: this._res.loaded,
|
||||
loading: this._res.loading,
|
||||
...partial
|
||||
};
|
||||
this._callbacks.forEach((callback)=>callback());
|
||||
}
|
||||
_clearTimeouts() {
|
||||
clearTimeout(this._delay);
|
||||
clearTimeout(this._timeout);
|
||||
}
|
||||
getCurrentValue() {
|
||||
return this._state;
|
||||
}
|
||||
subscribe(callback) {
|
||||
this._callbacks.add(callback);
|
||||
return ()=>{
|
||||
this._callbacks.delete(callback);
|
||||
};
|
||||
}
|
||||
constructor(loadFn, opts){
|
||||
this._loadFn = loadFn;
|
||||
this._opts = opts;
|
||||
this._callbacks = new Set();
|
||||
this._delay = null;
|
||||
this._timeout = null;
|
||||
this.retry();
|
||||
}
|
||||
}
|
||||
function Loadable(opts) {
|
||||
return createLoadableComponent(load, opts);
|
||||
}
|
||||
function flushInitializers(initializers, ids) {
|
||||
let promises = [];
|
||||
while(initializers.length){
|
||||
let init = initializers.pop();
|
||||
promises.push(init(ids));
|
||||
}
|
||||
return Promise.all(promises).then(()=>{
|
||||
if (initializers.length) {
|
||||
return flushInitializers(initializers, ids);
|
||||
}
|
||||
});
|
||||
}
|
||||
Loadable.preloadAll = ()=>{
|
||||
return new Promise((resolveInitializers, reject)=>{
|
||||
flushInitializers(ALL_INITIALIZERS).then(resolveInitializers, reject);
|
||||
});
|
||||
};
|
||||
Loadable.preloadReady = (ids)=>{
|
||||
if (ids === void 0) ids = [];
|
||||
return new Promise((resolvePreload)=>{
|
||||
const res = ()=>{
|
||||
initialized = true;
|
||||
return resolvePreload();
|
||||
};
|
||||
// We always will resolve, errors should be handled within loading UIs.
|
||||
flushInitializers(READY_INITIALIZERS, ids).then(res, res);
|
||||
});
|
||||
};
|
||||
if (typeof window !== 'undefined') {
|
||||
window.__NEXT_PRELOADREADY = Loadable.preloadReady;
|
||||
}
|
||||
export default Loadable;
|
||||
|
||||
//# sourceMappingURL=loadable.shared-runtime.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/loadable.shared-runtime.tsx"],"sourcesContent":["// TODO: Remove use of `any` type.\n/**\n@copyright (c) 2017-present James Kyle <me@thejameskyle.com>\n MIT License\n Permission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n The above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE\n*/\n// https://github.com/jamiebuilds/react-loadable/blob/v5.5.0/src/index.js\n// Modified to be compatible with webpack 4 / Next.js\n\nimport React from 'react'\nimport { LoadableContext } from './loadable-context.shared-runtime'\n\nfunction resolve(obj: any) {\n return obj && obj.default ? obj.default : obj\n}\n\nconst ALL_INITIALIZERS: any[] = []\nconst READY_INITIALIZERS: any[] = []\nlet initialized = false\n\nfunction load(loader: any) {\n let promise = loader()\n\n let state: any = {\n loading: true,\n loaded: null,\n error: null,\n }\n\n state.promise = promise\n .then((loaded: any) => {\n state.loading = false\n state.loaded = loaded\n return loaded\n })\n .catch((err: any) => {\n state.loading = false\n state.error = err\n throw err\n })\n\n return state\n}\n\nfunction createLoadableComponent(loadFn: any, options: any) {\n let opts = Object.assign(\n {\n loader: null,\n loading: null,\n delay: 200,\n timeout: null,\n webpack: null,\n modules: null,\n },\n options\n )\n\n /** @type LoadableSubscription */\n let subscription: any = null\n function init() {\n if (!subscription) {\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n const sub = new LoadableSubscription(loadFn, opts)\n subscription = {\n getCurrentValue: sub.getCurrentValue.bind(sub),\n subscribe: sub.subscribe.bind(sub),\n retry: sub.retry.bind(sub),\n promise: sub.promise.bind(sub),\n }\n }\n return subscription.promise()\n }\n\n // Server only\n if (typeof window === 'undefined') {\n ALL_INITIALIZERS.push(init)\n }\n\n // Client only\n if (!initialized && typeof window !== 'undefined') {\n // require.resolveWeak check is needed for environments that don't have it available like Jest\n const moduleIds =\n opts.webpack && typeof (require as any).resolveWeak === 'function'\n ? opts.webpack()\n : opts.modules\n if (moduleIds) {\n READY_INITIALIZERS.push((ids: any) => {\n for (const moduleId of moduleIds) {\n if (ids.includes(moduleId)) {\n return init()\n }\n }\n })\n }\n }\n\n function useLoadableModule() {\n init()\n\n const context = React.useContext(LoadableContext)\n if (context && Array.isArray(opts.modules)) {\n opts.modules.forEach((moduleName: any) => {\n context(moduleName)\n })\n }\n }\n\n function LoadableComponent(props: any, ref: any) {\n useLoadableModule()\n\n const state = (React as any).useSyncExternalStore(\n subscription.subscribe,\n subscription.getCurrentValue,\n subscription.getCurrentValue\n )\n\n React.useImperativeHandle(\n ref,\n () => ({\n retry: subscription.retry,\n }),\n []\n )\n\n return React.useMemo(() => {\n if (state.loading || state.error) {\n return React.createElement(opts.loading, {\n isLoading: state.loading,\n pastDelay: state.pastDelay,\n timedOut: state.timedOut,\n error: state.error,\n retry: subscription.retry,\n })\n } else if (state.loaded) {\n return React.createElement(resolve(state.loaded), props)\n } else {\n return null\n }\n }, [props, state])\n }\n\n LoadableComponent.preload = () => init()\n LoadableComponent.displayName = 'LoadableComponent'\n\n return React.forwardRef(LoadableComponent)\n}\n\nclass LoadableSubscription {\n _loadFn: any\n _opts: any\n _callbacks: any\n _delay: any\n _timeout: any\n _res: any\n _state: any\n constructor(loadFn: any, opts: any) {\n this._loadFn = loadLine truncated
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
function decodeHex(hexStr) {
|
||||
if (hexStr.trim() === '') {
|
||||
throw Object.defineProperty(new Error("can't decode empty hex"), "__NEXT_ERROR_CODE", {
|
||||
value: "E19",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
const num = parseInt(hexStr, 16);
|
||||
if (isNaN(num)) {
|
||||
throw Object.defineProperty(new Error("invalid hex: `" + hexStr + "`"), "__NEXT_ERROR_CODE", {
|
||||
value: "E293",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
return String.fromCodePoint(num);
|
||||
}
|
||||
;
|
||||
const DECODE_REGEX = /^__TURBOPACK__([a-zA-Z0-9_$]+)__$/;
|
||||
export function decodeMagicIdentifier(identifier) {
|
||||
const matches = identifier.match(DECODE_REGEX);
|
||||
if (!matches) {
|
||||
return identifier;
|
||||
}
|
||||
const inner = matches[1];
|
||||
let output = '';
|
||||
let mode = 0;
|
||||
let buffer = '';
|
||||
for(let i = 0; i < inner.length; i++){
|
||||
const char = inner[i];
|
||||
if (mode === 0) {
|
||||
if (char === '_') {
|
||||
mode = 1;
|
||||
} else if (char === '$') {
|
||||
mode = 2;
|
||||
} else {
|
||||
output += char;
|
||||
}
|
||||
} else if (mode === 1) {
|
||||
if (char === '_') {
|
||||
output += ' ';
|
||||
mode = 0;
|
||||
} else if (char === '$') {
|
||||
output += '_';
|
||||
mode = 2;
|
||||
} else {
|
||||
output += char;
|
||||
mode = 0;
|
||||
}
|
||||
} else if (mode === 2) {
|
||||
if (buffer.length === 2) {
|
||||
output += decodeHex(buffer);
|
||||
buffer = '';
|
||||
}
|
||||
if (char === '_') {
|
||||
if (buffer !== '') {
|
||||
throw Object.defineProperty(new Error("invalid hex: `" + buffer + "`"), "__NEXT_ERROR_CODE", {
|
||||
value: "E293",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
mode = 3;
|
||||
} else if (char === '$') {
|
||||
if (buffer !== '') {
|
||||
throw Object.defineProperty(new Error("invalid hex: `" + buffer + "`"), "__NEXT_ERROR_CODE", {
|
||||
value: "E293",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
}
|
||||
mode = 0;
|
||||
} else {
|
||||
buffer += char;
|
||||
}
|
||||
} else if (mode === 3) {
|
||||
if (char === '_') {
|
||||
throw Object.defineProperty(new Error("invalid hex: `" + (buffer + char) + "`"), "__NEXT_ERROR_CODE", {
|
||||
value: "E244",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else if (char === '$') {
|
||||
output += decodeHex(buffer);
|
||||
buffer = '';
|
||||
mode = 0;
|
||||
} else {
|
||||
buffer += char;
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
export const MAGIC_IDENTIFIER_REGEX = /__TURBOPACK__[a-zA-Z0-9_$]+__/g;
|
||||
|
||||
//# sourceMappingURL=magic-identifier.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/magic-identifier.ts"],"sourcesContent":["function decodeHex(hexStr: string): string {\n if (hexStr.trim() === '') {\n throw new Error(\"can't decode empty hex\")\n }\n\n const num = parseInt(hexStr, 16)\n if (isNaN(num)) {\n throw new Error(`invalid hex: \\`${hexStr}\\``)\n }\n\n return String.fromCodePoint(num)\n}\n\nconst enum Mode {\n Text,\n Underscore,\n Hex,\n LongHex,\n}\n\nconst DECODE_REGEX = /^__TURBOPACK__([a-zA-Z0-9_$]+)__$/\n\nexport function decodeMagicIdentifier(identifier: string): string {\n const matches = identifier.match(DECODE_REGEX)\n if (!matches) {\n return identifier\n }\n\n const inner = matches[1]\n\n let output = ''\n\n let mode: Mode = Mode.Text\n let buffer = ''\n for (let i = 0; i < inner.length; i++) {\n const char = inner[i]\n\n if (mode === Mode.Text) {\n if (char === '_') {\n mode = Mode.Underscore\n } else if (char === '$') {\n mode = Mode.Hex\n } else {\n output += char\n }\n } else if (mode === Mode.Underscore) {\n if (char === '_') {\n output += ' '\n mode = Mode.Text\n } else if (char === '$') {\n output += '_'\n mode = Mode.Hex\n } else {\n output += char\n mode = Mode.Text\n }\n } else if (mode === Mode.Hex) {\n if (buffer.length === 2) {\n output += decodeHex(buffer)\n buffer = ''\n }\n\n if (char === '_') {\n if (buffer !== '') {\n throw new Error(`invalid hex: \\`${buffer}\\``)\n }\n\n mode = Mode.LongHex\n } else if (char === '$') {\n if (buffer !== '') {\n throw new Error(`invalid hex: \\`${buffer}\\``)\n }\n\n mode = Mode.Text\n } else {\n buffer += char\n }\n } else if (mode === Mode.LongHex) {\n if (char === '_') {\n throw new Error(`invalid hex: \\`${buffer + char}\\``)\n } else if (char === '$') {\n output += decodeHex(buffer)\n buffer = ''\n\n mode = Mode.Text\n } else {\n buffer += char\n }\n }\n }\n\n return output\n}\n\nexport const MAGIC_IDENTIFIER_REGEX = /__TURBOPACK__[a-zA-Z0-9_$]+__/g\n"],"names":["decodeHex","hexStr","trim","Error","num","parseInt","isNaN","String","fromCodePoint","DECODE_REGEX","decodeMagicIdentifier","identifier","matches","match","inner","output","mode","buffer","i","length","char","MAGIC_IDENTIFIER_REGEX"],"mappings":"AAAA,SAASA,UAAUC,MAAc;IAC/B,IAAIA,OAAOC,IAAI,OAAO,IAAI;QACxB,MAAM,qBAAmC,CAAnC,IAAIC,MAAM,2BAAV,qBAAA;mBAAA;wBAAA;0BAAA;QAAkC;IAC1C;IAEA,MAAMC,MAAMC,SAASJ,QAAQ;IAC7B,IAAIK,MAAMF,MAAM;QACd,MAAM,qBAAuC,CAAvC,IAAID,MAAM,AAAC,mBAAiBF,SAAO,MAAnC,qBAAA;mBAAA;wBAAA;0BAAA;QAAsC;IAC9C;IAEA,OAAOM,OAAOC,aAAa,CAACJ;AAC9B;;AASA,MAAMK,eAAe;AAErB,OAAO,SAASC,sBAAsBC,UAAkB;IACtD,MAAMC,UAAUD,WAAWE,KAAK,CAACJ;IACjC,IAAI,CAACG,SAAS;QACZ,OAAOD;IACT;IAEA,MAAMG,QAAQF,OAAO,CAAC,EAAE;IAExB,IAAIG,SAAS;IAEb,IAAIC;IACJ,IAAIC,SAAS;IACb,IAAK,IAAIC,IAAI,GAAGA,IAAIJ,MAAMK,MAAM,EAAED,IAAK;QACrC,MAAME,OAAON,KAAK,CAACI,EAAE;QAErB,IAAIF,YAAoB;YACtB,IAAII,SAAS,KAAK;gBAChBJ;YACF,OAAO,IAAII,SAAS,KAAK;gBACvBJ;YACF,OAAO;gBACLD,UAAUK;YACZ;QACF,OAAO,IAAIJ,YAA0B;YACnC,IAAII,SAAS,KAAK;gBAChBL,UAAU;gBACVC;YACF,OAAO,IAAII,SAAS,KAAK;gBACvBL,UAAU;gBACVC;YACF,OAAO;gBACLD,UAAUK;gBACVJ;YACF;QACF,OAAO,IAAIA,YAAmB;YAC5B,IAAIC,OAAOE,MAAM,KAAK,GAAG;gBACvBJ,UAAUf,UAAUiB;gBACpBA,SAAS;YACX;YAEA,IAAIG,SAAS,KAAK;gBAChB,IAAIH,WAAW,IAAI;oBACjB,MAAM,qBAAuC,CAAvC,IAAId,MAAM,AAAC,mBAAiBc,SAAO,MAAnC,qBAAA;+BAAA;oCAAA;sCAAA;oBAAsC;gBAC9C;gBAEAD;YACF,OAAO,IAAII,SAAS,KAAK;gBACvB,IAAIH,WAAW,IAAI;oBACjB,MAAM,qBAAuC,CAAvC,IAAId,MAAM,AAAC,mBAAiBc,SAAO,MAAnC,qBAAA;+BAAA;oCAAA;sCAAA;oBAAsC;gBAC9C;gBAEAD;YACF,OAAO;gBACLC,UAAUG;YACZ;QACF,OAAO,IAAIJ,YAAuB;YAChC,IAAII,SAAS,KAAK;gBAChB,MAAM,qBAA8C,CAA9C,IAAIjB,MAAM,AAAC,mBAAiBc,CAAAA,SAASG,IAAG,IAAE,MAA1C,qBAAA;2BAAA;gCAAA;kCAAA;gBAA6C;YACrD,OAAO,IAAIA,SAAS,KAAK;gBACvBL,UAAUf,UAAUiB;gBACpBA,SAAS;gBAETD;YACF,OAAO;gBACLC,UAAUG;YACZ;QACF;IACF;IAEA,OAAOL;AACT;AAEA,OAAO,MAAMM,yBAAyB,iCAAgC"}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { makeRe } from 'next/dist/compiled/picomatch';
|
||||
// Modifying this function should also modify writeImagesManifest()
|
||||
export function matchLocalPattern(pattern, url) {
|
||||
if (pattern.search !== undefined) {
|
||||
if (pattern.search !== url.search) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var _pattern_pathname;
|
||||
if (!makeRe((_pattern_pathname = pattern.pathname) != null ? _pattern_pathname : '**', {
|
||||
dot: true
|
||||
}).test(url.pathname)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
export function hasLocalMatch(localPatterns, urlPathAndQuery) {
|
||||
if (!localPatterns) {
|
||||
// if the user didn't define "localPatterns", we allow all local images
|
||||
return true;
|
||||
}
|
||||
const url = new URL(urlPathAndQuery, 'http://n');
|
||||
return localPatterns.some((p)=>matchLocalPattern(p, url));
|
||||
}
|
||||
|
||||
//# sourceMappingURL=match-local-pattern.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/match-local-pattern.ts"],"sourcesContent":["import type { LocalPattern } from './image-config'\nimport { makeRe } from 'next/dist/compiled/picomatch'\n\n// Modifying this function should also modify writeImagesManifest()\nexport function matchLocalPattern(pattern: LocalPattern, url: URL): boolean {\n if (pattern.search !== undefined) {\n if (pattern.search !== url.search) {\n return false\n }\n }\n\n if (!makeRe(pattern.pathname ?? '**', { dot: true }).test(url.pathname)) {\n return false\n }\n\n return true\n}\n\nexport function hasLocalMatch(\n localPatterns: LocalPattern[] | undefined,\n urlPathAndQuery: string\n): boolean {\n if (!localPatterns) {\n // if the user didn't define \"localPatterns\", we allow all local images\n return true\n }\n const url = new URL(urlPathAndQuery, 'http://n')\n return localPatterns.some((p) => matchLocalPattern(p, url))\n}\n"],"names":["makeRe","matchLocalPattern","pattern","url","search","undefined","pathname","dot","test","hasLocalMatch","localPatterns","urlPathAndQuery","URL","some","p"],"mappings":"AACA,SAASA,MAAM,QAAQ,+BAA8B;AAErD,mEAAmE;AACnE,OAAO,SAASC,kBAAkBC,OAAqB,EAAEC,GAAQ;IAC/D,IAAID,QAAQE,MAAM,KAAKC,WAAW;QAChC,IAAIH,QAAQE,MAAM,KAAKD,IAAIC,MAAM,EAAE;YACjC,OAAO;QACT;IACF;QAEYF;IAAZ,IAAI,CAACF,OAAOE,CAAAA,oBAAAA,QAAQI,QAAQ,YAAhBJ,oBAAoB,MAAM;QAAEK,KAAK;IAAK,GAAGC,IAAI,CAACL,IAAIG,QAAQ,GAAG;QACvE,OAAO;IACT;IAEA,OAAO;AACT;AAEA,OAAO,SAASG,cACdC,aAAyC,EACzCC,eAAuB;IAEvB,IAAI,CAACD,eAAe;QAClB,uEAAuE;QACvE,OAAO;IACT;IACA,MAAMP,MAAM,IAAIS,IAAID,iBAAiB;IACrC,OAAOD,cAAcG,IAAI,CAAC,CAACC,IAAMb,kBAAkBa,GAAGX;AACxD"}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { makeRe } from 'next/dist/compiled/picomatch';
|
||||
// Modifying this function should also modify writeImagesManifest()
|
||||
export function matchRemotePattern(pattern, url) {
|
||||
if (pattern.protocol !== undefined) {
|
||||
if (pattern.protocol.replace(/:$/, '') !== url.protocol.replace(/:$/, '')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (pattern.port !== undefined) {
|
||||
if (pattern.port !== url.port) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (pattern.hostname === undefined) {
|
||||
throw Object.defineProperty(new Error("Pattern should define hostname but found\n" + JSON.stringify(pattern)), "__NEXT_ERROR_CODE", {
|
||||
value: "E410",
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
||||
} else {
|
||||
if (!makeRe(pattern.hostname).test(url.hostname)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (pattern.search !== undefined) {
|
||||
if (pattern.search !== url.search) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var _pattern_pathname;
|
||||
// Should be the same as writeImagesManifest()
|
||||
if (!makeRe((_pattern_pathname = pattern.pathname) != null ? _pattern_pathname : '**', {
|
||||
dot: true
|
||||
}).test(url.pathname)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
export function hasRemoteMatch(domains, remotePatterns, url) {
|
||||
return domains.some((domain)=>url.hostname === domain) || remotePatterns.some((p)=>matchRemotePattern(p, url));
|
||||
}
|
||||
|
||||
//# sourceMappingURL=match-remote-pattern.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/shared/lib/match-remote-pattern.ts"],"sourcesContent":["import type { RemotePattern } from './image-config'\nimport { makeRe } from 'next/dist/compiled/picomatch'\n\n// Modifying this function should also modify writeImagesManifest()\nexport function matchRemotePattern(\n pattern: RemotePattern | URL,\n url: URL\n): boolean {\n if (pattern.protocol !== undefined) {\n if (pattern.protocol.replace(/:$/, '') !== url.protocol.replace(/:$/, '')) {\n return false\n }\n }\n if (pattern.port !== undefined) {\n if (pattern.port !== url.port) {\n return false\n }\n }\n\n if (pattern.hostname === undefined) {\n throw new Error(\n `Pattern should define hostname but found\\n${JSON.stringify(pattern)}`\n )\n } else {\n if (!makeRe(pattern.hostname).test(url.hostname)) {\n return false\n }\n }\n\n if (pattern.search !== undefined) {\n if (pattern.search !== url.search) {\n return false\n }\n }\n\n // Should be the same as writeImagesManifest()\n if (!makeRe(pattern.pathname ?? '**', { dot: true }).test(url.pathname)) {\n return false\n }\n\n return true\n}\n\nexport function hasRemoteMatch(\n domains: string[],\n remotePatterns: Array<RemotePattern | URL>,\n url: URL\n): boolean {\n return (\n domains.some((domain) => url.hostname === domain) ||\n remotePatterns.some((p) => matchRemotePattern(p, url))\n )\n}\n"],"names":["makeRe","matchRemotePattern","pattern","url","protocol","undefined","replace","port","hostname","Error","JSON","stringify","test","search","pathname","dot","hasRemoteMatch","domains","remotePatterns","some","domain","p"],"mappings":"AACA,SAASA,MAAM,QAAQ,+BAA8B;AAErD,mEAAmE;AACnE,OAAO,SAASC,mBACdC,OAA4B,EAC5BC,GAAQ;IAER,IAAID,QAAQE,QAAQ,KAAKC,WAAW;QAClC,IAAIH,QAAQE,QAAQ,CAACE,OAAO,CAAC,MAAM,QAAQH,IAAIC,QAAQ,CAACE,OAAO,CAAC,MAAM,KAAK;YACzE,OAAO;QACT;IACF;IACA,IAAIJ,QAAQK,IAAI,KAAKF,WAAW;QAC9B,IAAIH,QAAQK,IAAI,KAAKJ,IAAII,IAAI,EAAE;YAC7B,OAAO;QACT;IACF;IAEA,IAAIL,QAAQM,QAAQ,KAAKH,WAAW;QAClC,MAAM,qBAEL,CAFK,IAAII,MACR,AAAC,+CAA4CC,KAAKC,SAAS,CAACT,WADxD,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF,OAAO;QACL,IAAI,CAACF,OAAOE,QAAQM,QAAQ,EAAEI,IAAI,CAACT,IAAIK,QAAQ,GAAG;YAChD,OAAO;QACT;IACF;IAEA,IAAIN,QAAQW,MAAM,KAAKR,WAAW;QAChC,IAAIH,QAAQW,MAAM,KAAKV,IAAIU,MAAM,EAAE;YACjC,OAAO;QACT;IACF;QAGYX;IADZ,8CAA8C;IAC9C,IAAI,CAACF,OAAOE,CAAAA,oBAAAA,QAAQY,QAAQ,YAAhBZ,oBAAoB,MAAM;QAAEa,KAAK;IAAK,GAAGH,IAAI,CAACT,IAAIW,QAAQ,GAAG;QACvE,OAAO;IACT;IAEA,OAAO;AACT;AAEA,OAAO,SAASE,eACdC,OAAiB,EACjBC,cAA0C,EAC1Cf,GAAQ;IAER,OACEc,QAAQE,IAAI,CAAC,CAACC,SAAWjB,IAAIK,QAAQ,KAAKY,WAC1CF,eAAeC,IAAI,CAAC,CAACE,IAAMpB,mBAAmBoB,GAAGlB;AAErD"}
|
||||
Loaded 100 of 9079 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user