Initial commit

This commit is contained in:
bilulib
2025-04-13 00:18:57 +02:00
parent cff009bb7c
commit d894249e61
18301 changed files with 2905442 additions and 3845 deletions

View File

@@ -0,0 +1,5 @@
import type { StreamingMetadataResolvedState } from './types';
export declare const AsyncMetadata: typeof import("./browser-resolved-metadata").BrowserResolvedMetadata;
export declare function AsyncMetadataOutlet({ promise, }: {
promise: Promise<StreamingMetadataResolvedState>;
}): import("react/jsx-runtime").JSX.Element;

View File

@@ -0,0 +1,57 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
AsyncMetadata: null,
AsyncMetadataOutlet: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
AsyncMetadata: function() {
return AsyncMetadata;
},
AsyncMetadataOutlet: function() {
return AsyncMetadataOutlet;
}
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const AsyncMetadata = typeof window === 'undefined' ? require('./server-inserted-metadata').ServerInsertMetadata : require('./browser-resolved-metadata').BrowserResolvedMetadata;
function MetadataOutlet(param) {
let { promise } = param;
const { error, digest } = (0, _react.use)(promise);
if (error) {
if (digest) {
// The error will lose its original digest after passing from server layer to client layer
// We recover the digest property here to override the React created one if original digest exists.
;
error.digest = digest;
}
throw error;
}
return null;
}
function AsyncMetadataOutlet(param) {
let { promise } = param;
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_react.Suspense, {
fallback: null,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(MetadataOutlet, {
promise: promise
})
});
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=async-metadata.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/metadata/async-metadata.tsx"],"sourcesContent":["'use client'\n\nimport { Suspense, use } from 'react'\nimport type { StreamingMetadataResolvedState } from './types'\n\nexport const AsyncMetadata =\n typeof window === 'undefined'\n ? (\n require('./server-inserted-metadata') as typeof import('./server-inserted-metadata')\n ).ServerInsertMetadata\n : (\n require('./browser-resolved-metadata') as typeof import('./browser-resolved-metadata')\n ).BrowserResolvedMetadata\n\nfunction MetadataOutlet({\n promise,\n}: {\n promise: Promise<StreamingMetadataResolvedState>\n}) {\n const { error, digest } = use(promise)\n if (error) {\n if (digest) {\n // The error will lose its original digest after passing from server layer to client layer\n // We recover the digest property here to override the React created one if original digest exists.\n ;(error as any).digest = digest\n }\n throw error\n }\n return null\n}\n\nexport function AsyncMetadataOutlet({\n promise,\n}: {\n promise: Promise<StreamingMetadataResolvedState>\n}) {\n return (\n <Suspense fallback={null}>\n <MetadataOutlet promise={promise} />\n </Suspense>\n )\n}\n"],"names":["AsyncMetadata","AsyncMetadataOutlet","window","require","ServerInsertMetadata","BrowserResolvedMetadata","MetadataOutlet","promise","error","digest","use","Suspense","fallback"],"mappings":"AAAA;;;;;;;;;;;;;;;;IAKaA,aAAa;eAAbA;;IA0BGC,mBAAmB;eAAnBA;;;;uBA7Bc;AAGvB,MAAMD,gBACX,OAAOE,WAAW,cACd,AACEC,QAAQ,8BACRC,oBAAoB,GACtB,AACED,QAAQ,+BACRE,uBAAuB;AAE/B,SAASC,eAAe,KAIvB;IAJuB,IAAA,EACtBC,OAAO,EAGR,GAJuB;IAKtB,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAAGC,IAAAA,UAAG,EAACH;IAC9B,IAAIC,OAAO;QACT,IAAIC,QAAQ;YACV,2FAA2F;YAC3F,mGAAmG;;YACjGD,MAAcC,MAAM,GAAGA;QAC3B;QACA,MAAMD;IACR;IACA,OAAO;AACT;AAEO,SAASP,oBAAoB,KAInC;IAJmC,IAAA,EAClCM,OAAO,EAGR,GAJmC;IAKlC,qBACE,qBAACI,eAAQ;QAACC,UAAU;kBAClB,cAAA,qBAACN;YAAeC,SAASA;;;AAG/B"}

View File

@@ -0,0 +1,4 @@
import type { StreamingMetadataResolvedState } from './types';
export declare function BrowserResolvedMetadata({ promise, }: {
promise: Promise<StreamingMetadataResolvedState>;
}): import("react").ReactNode;

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "BrowserResolvedMetadata", {
enumerable: true,
get: function() {
return BrowserResolvedMetadata;
}
});
const _react = require("react");
function BrowserResolvedMetadata(param) {
let { promise } = param;
const { metadata, error } = (0, _react.use)(promise);
// If there's metadata error on client, discard the browser metadata
// and let metadata outlet deal with the error. This will avoid the duplication metadata.
if (error) return null;
return metadata;
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=browser-resolved-metadata.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/metadata/browser-resolved-metadata.tsx"],"sourcesContent":["import { use } from 'react'\nimport type { StreamingMetadataResolvedState } from './types'\n\nexport function BrowserResolvedMetadata({\n promise,\n}: {\n promise: Promise<StreamingMetadataResolvedState>\n}) {\n const { metadata, error } = use(promise)\n // If there's metadata error on client, discard the browser metadata\n // and let metadata outlet deal with the error. This will avoid the duplication metadata.\n if (error) return null\n return metadata\n}\n"],"names":["BrowserResolvedMetadata","promise","metadata","error","use"],"mappings":";;;;+BAGgBA;;;eAAAA;;;uBAHI;AAGb,SAASA,wBAAwB,KAIvC;IAJuC,IAAA,EACtCC,OAAO,EAGR,GAJuC;IAKtC,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGC,IAAAA,UAAG,EAACH;IAChC,oEAAoE;IACpE,yFAAyF;IACzF,IAAIE,OAAO,OAAO;IAClB,OAAOD;AACT"}

View File

@@ -0,0 +1,9 @@
export declare const MetadataBoundary: ({ children, }: {
children: React.ReactNode;
}) => import("react").ReactNode;
export declare const ViewportBoundary: ({ children, }: {
children: React.ReactNode;
}) => import("react").ReactNode;
export declare const OutletBoundary: ({ children, }: {
children: React.ReactNode;
}) => import("react").ReactNode;

View File

@@ -0,0 +1,61 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
MetadataBoundary: null,
OutletBoundary: null,
ViewportBoundary: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
MetadataBoundary: function() {
return MetadataBoundary;
},
OutletBoundary: function() {
return OutletBoundary;
},
ViewportBoundary: function() {
return ViewportBoundary;
}
});
const _metadataconstants = require("../../../lib/metadata/metadata-constants");
// We use a namespace object to allow us to recover the name of the function
// at runtime even when production bundling/minification is used.
const NameSpace = {
[_metadataconstants.METADATA_BOUNDARY_NAME]: function(param) {
let { children } = param;
return children;
},
[_metadataconstants.VIEWPORT_BOUNDARY_NAME]: function(param) {
let { children } = param;
return children;
},
[_metadataconstants.OUTLET_BOUNDARY_NAME]: function(param) {
let { children } = param;
return children;
}
};
const MetadataBoundary = // We use slice(0) to trick the bundler into not inlining/minifying the function
// so it retains the name inferred from the namespace object
NameSpace[_metadataconstants.METADATA_BOUNDARY_NAME.slice(0)];
const ViewportBoundary = // We use slice(0) to trick the bundler into not inlining/minifying the function
// so it retains the name inferred from the namespace object
NameSpace[_metadataconstants.VIEWPORT_BOUNDARY_NAME.slice(0)];
const OutletBoundary = // We use slice(0) to trick the bundler into not inlining/minifying the function
// so it retains the name inferred from the namespace object
NameSpace[_metadataconstants.OUTLET_BOUNDARY_NAME.slice(0)];
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=metadata-boundary.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/metadata/metadata-boundary.tsx"],"sourcesContent":["'use client'\n\nimport {\n METADATA_BOUNDARY_NAME,\n VIEWPORT_BOUNDARY_NAME,\n OUTLET_BOUNDARY_NAME,\n} from '../../../lib/metadata/metadata-constants'\n\n// We use a namespace object to allow us to recover the name of the function\n// at runtime even when production bundling/minification is used.\nconst NameSpace = {\n [METADATA_BOUNDARY_NAME]: function ({\n children,\n }: {\n children: React.ReactNode\n }) {\n return children\n },\n [VIEWPORT_BOUNDARY_NAME]: function ({\n children,\n }: {\n children: React.ReactNode\n }) {\n return children\n },\n [OUTLET_BOUNDARY_NAME]: function ({\n children,\n }: {\n children: React.ReactNode\n }) {\n return children\n },\n}\n\nexport const MetadataBoundary =\n // We use slice(0) to trick the bundler into not inlining/minifying the function\n // so it retains the name inferred from the namespace object\n NameSpace[METADATA_BOUNDARY_NAME.slice(0) as typeof METADATA_BOUNDARY_NAME]\n\nexport const ViewportBoundary =\n // We use slice(0) to trick the bundler into not inlining/minifying the function\n // so it retains the name inferred from the namespace object\n NameSpace[VIEWPORT_BOUNDARY_NAME.slice(0) as typeof VIEWPORT_BOUNDARY_NAME]\n\nexport const OutletBoundary =\n // We use slice(0) to trick the bundler into not inlining/minifying the function\n // so it retains the name inferred from the namespace object\n NameSpace[OUTLET_BOUNDARY_NAME.slice(0) as typeof OUTLET_BOUNDARY_NAME]\n"],"names":["MetadataBoundary","OutletBoundary","ViewportBoundary","NameSpace","METADATA_BOUNDARY_NAME","children","VIEWPORT_BOUNDARY_NAME","OUTLET_BOUNDARY_NAME","slice"],"mappings":"AAAA;;;;;;;;;;;;;;;;;IAkCaA,gBAAgB;eAAhBA;;IAUAC,cAAc;eAAdA;;IALAC,gBAAgB;eAAhBA;;;mCAjCN;AAEP,4EAA4E;AAC5E,iEAAiE;AACjE,MAAMC,YAAY;IAChB,CAACC,yCAAsB,CAAC,EAAE,SAAU,KAInC;QAJmC,IAAA,EAClCC,QAAQ,EAGT,GAJmC;QAKlC,OAAOA;IACT;IACA,CAACC,yCAAsB,CAAC,EAAE,SAAU,KAInC;QAJmC,IAAA,EAClCD,QAAQ,EAGT,GAJmC;QAKlC,OAAOA;IACT;IACA,CAACE,uCAAoB,CAAC,EAAE,SAAU,KAIjC;QAJiC,IAAA,EAChCF,QAAQ,EAGT,GAJiC;QAKhC,OAAOA;IACT;AACF;AAEO,MAAML,mBACX,gFAAgF;AAChF,4DAA4D;AAC5DG,SAAS,CAACC,yCAAsB,CAACI,KAAK,CAAC,GAAoC;AAEtE,MAAMN,mBACX,gFAAgF;AAChF,4DAA4D;AAC5DC,SAAS,CAACG,yCAAsB,CAACE,KAAK,CAAC,GAAoC;AAEtE,MAAMP,iBACX,gFAAgF;AAChF,4DAA4D;AAC5DE,SAAS,CAACI,uCAAoB,CAACC,KAAK,CAAC,GAAkC"}

View File

@@ -0,0 +1,4 @@
import type { StreamingMetadataResolvedState } from './types';
export declare function ServerInsertMetadata({ promise, }: {
promise: Promise<StreamingMetadataResolvedState>;
}): null;

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "ServerInsertMetadata", {
enumerable: true,
get: function() {
return ServerInsertMetadata;
}
});
const _react = require("react");
const _serverinsertedmetadatasharedruntime = require("../../../shared/lib/server-inserted-metadata.shared-runtime");
// Receives a metadata resolver setter from the context, and will pass the metadata resolving promise to
// the context where we gonna use it to resolve the metadata, and render as string to append in <body>.
const useServerInsertedMetadata = (metadataResolver)=>{
const setMetadataResolver = (0, _react.useContext)(_serverinsertedmetadatasharedruntime.ServerInsertedMetadataContext);
if (setMetadataResolver) {
setMetadataResolver(metadataResolver);
}
};
function ServerInsertMetadata(param) {
let { promise } = param;
// Apply use() to the metadata promise to suspend the rendering in SSR.
const { metadata } = (0, _react.use)(promise);
// Insert metadata into the HTML stream through the `useServerInsertedMetadata`
useServerInsertedMetadata(()=>metadata);
return null;
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=server-inserted-metadata.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/metadata/server-inserted-metadata.tsx"],"sourcesContent":["import { use, useContext } from 'react'\nimport {\n type MetadataResolver,\n ServerInsertedMetadataContext,\n} from '../../../shared/lib/server-inserted-metadata.shared-runtime'\nimport type { StreamingMetadataResolvedState } from './types'\n\n// Receives a metadata resolver setter from the context, and will pass the metadata resolving promise to\n// the context where we gonna use it to resolve the metadata, and render as string to append in <body>.\nconst useServerInsertedMetadata = (metadataResolver: MetadataResolver) => {\n const setMetadataResolver = useContext(ServerInsertedMetadataContext)\n\n if (setMetadataResolver) {\n setMetadataResolver(metadataResolver)\n }\n}\n\nexport function ServerInsertMetadata({\n promise,\n}: {\n promise: Promise<StreamingMetadataResolvedState>\n}) {\n // Apply use() to the metadata promise to suspend the rendering in SSR.\n const { metadata } = use(promise)\n // Insert metadata into the HTML stream through the `useServerInsertedMetadata`\n useServerInsertedMetadata(() => metadata)\n\n return null\n}\n"],"names":["ServerInsertMetadata","useServerInsertedMetadata","metadataResolver","setMetadataResolver","useContext","ServerInsertedMetadataContext","promise","metadata","use"],"mappings":";;;;+BAiBgBA;;;eAAAA;;;uBAjBgB;qDAIzB;AAGP,wGAAwG;AACxG,uGAAuG;AACvG,MAAMC,4BAA4B,CAACC;IACjC,MAAMC,sBAAsBC,IAAAA,iBAAU,EAACC,kEAA6B;IAEpE,IAAIF,qBAAqB;QACvBA,oBAAoBD;IACtB;AACF;AAEO,SAASF,qBAAqB,KAIpC;IAJoC,IAAA,EACnCM,OAAO,EAGR,GAJoC;IAKnC,uEAAuE;IACvE,MAAM,EAAEC,QAAQ,EAAE,GAAGC,IAAAA,UAAG,EAACF;IACzB,+EAA+E;IAC/EL,0BAA0B,IAAMM;IAEhC,OAAO;AACT"}

View File

@@ -0,0 +1,5 @@
export type StreamingMetadataResolvedState = {
metadata: React.ReactNode;
error: unknown | null;
digest: string | undefined;
};

View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=types.js.map

View File

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