@expo/router-server 58.0.21 → 58.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/getServerManifest.d.ts +1 -1
- package/build/getServerManifest.js +6 -0
- package/build/getServerManifest.js.map +1 -1
- package/build/server/render.d.ts +4 -0
- package/build/server/render.js +35 -0
- package/build/server/render.js.map +1 -0
- package/build/utils/html.d.ts +1 -55
- package/build/utils/html.js +19 -65
- package/build/utils/html.js.map +1 -1
- package/node/render.js +1 -1
- package/package.json +5 -5
- package/build/static/renderStaticContent.d.ts +0 -25
- package/build/static/renderStaticContent.js +0 -232
- package/build/static/renderStaticContent.js.map +0 -1
|
@@ -10,6 +10,6 @@ export interface RouteRegex {
|
|
|
10
10
|
groups: Record<string, Group>;
|
|
11
11
|
re: RegExp;
|
|
12
12
|
}
|
|
13
|
-
type GetServerManifestOptions = Pick<Options, 'headers' | 'pageHeaders'>;
|
|
13
|
+
type GetServerManifestOptions = Pick<Options, 'origin' | 'headers' | 'pageHeaders'>;
|
|
14
14
|
export declare function getServerManifest(route: RouteNode | null, options?: GetServerManifestOptions): RoutesManifest<string>;
|
|
15
15
|
export {};
|
|
@@ -96,6 +96,12 @@ function getServerManifest(route, options) {
|
|
|
96
96
|
file: route.middleware.contextKey
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
+
if (typeof options?.origin === 'string') {
|
|
100
|
+
const origin = URL.canParse(options.origin) ? new URL(options.origin).origin : options.origin.trim();
|
|
101
|
+
if (origin && origin !== 'null') {
|
|
102
|
+
manifest.origin = origin;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
99
105
|
if (options?.headers) {
|
|
100
106
|
manifest.headers = options.headers;
|
|
101
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["getServerManifest.ts"],"sourcesContent":[null],"names":["getServerManifest","isNotFoundRoute","route","dynamic","length","notFound","uniqueBy","arr","key","seen","Set","filter","item","id","has","add","options","getFlatNodes","parentRoute","absoluteRoute","Boolean","join","children","map","child","flat","type","includes","getNormalizedContextKey","contextKey","normalizedContextKey","absoluteRoutePath","sort","a","b","sortRoutes","reverse","apiRoutes","otherRoutes","methods","undefined","redirects","redirect","shouldLinkExternally","destinationContextKey","find","rewrites","rewrite","standardRoutes","notFoundRoutes","manifest","getMatchableManifestForPaths","htmlRoutes","middleware","file","headers","pageHeaders","getMatchableManifestForPageHeaders","source","prefixedSource","startsWith","normalizedSource","replace","namedParameterizedRoute","getNamedParametrizedRoute","namedRegex","paths","matcher","getNamedRouteRegex","generated","permanent","normalizedRoute","page","result","routeKeys","getContextKey"],"mappings":";;;;+BAmDgBA;;;eAAAA;;;;yBA9CT;;;;;;;yBAC8B;;;;;;2CAGK;AAc1C,SAASC,gBAAgBC,KAAgB;IACvC,OAAOA,MAAMC,OAAO,IAAI,QAASD,CAAAA,MAAMC,OAAO,CAACD,MAAMC,OAAO,CAACC,MAAM,GAAG,EAAE,EAAEC,YAAY,KAAI;AAC5F;AAEA,SAASC,SAAYC,GAAQ,EAAEC,GAAwB;IACrD,MAAMC,OAAO,IAAIC;IACjB,OAAOH,IAAII,MAAM,CAAC,CAACC;QACjB,MAAMC,KAAKL,IAAII;QACf,IAAIH,KAAKK,GAAG,CAACD,KAAK;YAChB,OAAO;QACT;QACAJ,KAAKM,GAAG,CAACF;QACT,OAAO;IACT;AACF;AAcO,SAASb,kBACdE,KAAuB,EACvBc,OAAkC;IAElC,SAASC,aAAaf,KAAgB,EAAEgB,cAAsB,EAAE;QAC9D,kGAAkG;QAClG,MAAMC,gBAAgB;YAACD;YAAahB,MAAMA,KAAK;SAAC,CAACS,MAAM,CAACS,SAASC,IAAI,CAAC;QAEtE,IAAInB,MAAMoB,QAAQ,CAAClB,MAAM,EAAE;YACzB,OAAOF,MAAMoB,QAAQ,CAACC,GAAG,CAAC,CAACC,QAAUP,aAAaO,OAAOL,gBAAgBM,IAAI;QAC/E;QAEA,0FAA0F;QAC1F,mGAAm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AAKoB,IAAI,CAAC,CAAC,EAAE3C,KAAK,EAAE,GAAKA,MAAM2B,UAAU,KAAKa,SAASxC,KAAK,CAAC0C,qBAAqB,GAC9Ed,wBAAwB;QAChC;QAEA,OAAOY;IACT,GACCN,OAAO;IAEV,MAAMU,WAAWxC,SACfmB,KAAKd,MAAM,CAAC,CAAC,EAAET,KAAK,EAAE,GAAKA,MAAMwB,IAAI,KAAK,YAC1C,CAAC,EAAEI,oBAAoB,EAAE,GAAKA,sBAE7BP,GAAG,CAAC,CAACwB;QACJA,QAAQhB,iBAAiB,GACvBN,KAAKoB,IAAI,CAAC,CAAC,EAAE3C,KAAK,EAAE,GAAKA,MAAM2B,UAAU,KAAKkB,QAAQ7C,KAAK,CAAC0C,qBAAqB,GAC7Ed,wBAAwB;QAE9B,OAAOiB;IACT,GACCX,OAAO;IAEV,MAAMY,iBAAiBV,YAAY3B,MAAM,CAAC,CAAC,EAAET,KAAK,EAAE,GAAK,CAACD,gBAAgBC;IAC1E,MAAM+C,iBAAiBX,YAAY3B,MAAM,CAAC,CAAC,EAAET,KAAK,EAAE,GAAKD,gBAAgBC;IAEzE,MAAMgD,WAAmC;QACvCb,WAAWc,6BAA6Bd;QACxCe,YAAYD,6BAA6BH;QACzCC,gBAAgBE,6BAA6BF;QAC7CR,WAAWU,6BAA6BV;QACxCK,UAAUK,6BAA6BL;IACzC;IAEA,IAAI5C,OAAOmD,YAAY;QACrBH,SAASG,UAAU,GAAG;YACpBC,MAAMpD,MAAMmD,UAAU,CAACxB,UAAU;QACnC;IACF;IAEA,
|
|
1
|
+
{"version":3,"sources":["getServerManifest.ts"],"sourcesContent":[null],"names":["getServerManifest","isNotFoundRoute","route","dynamic","length","notFound","uniqueBy","arr","key","seen","Set","filter","item","id","has","add","options","getFlatNodes","parentRoute","absoluteRoute","Boolean","join","children","map","child","flat","type","includes","getNormalizedContextKey","contextKey","normalizedContextKey","absoluteRoutePath","sort","a","b","sortRoutes","reverse","apiRoutes","otherRoutes","methods","undefined","redirects","redirect","shouldLinkExternally","destinationContextKey","find","rewrites","rewrite","standardRoutes","notFoundRoutes","manifest","getMatchableManifestForPaths","htmlRoutes","middleware","file","origin","URL","canParse","trim","headers","pageHeaders","getMatchableManifestForPageHeaders","source","prefixedSource","startsWith","normalizedSource","replace","namedParameterizedRoute","getNamedParametrizedRoute","namedRegex","paths","matcher","getNamedRouteRegex","generated","permanent","normalizedRoute","page","result","routeKeys","getContextKey"],"mappings":";;;;+BAmDgBA;;;eAAAA;;;;yBA9CT;;;;;;;yBAC8B;;;;;;2CAGK;AAc1C,SAASC,gBAAgBC,KAAgB;IACvC,OAAOA,MAAMC,OAAO,IAAI,QAASD,CAAAA,MAAMC,OAAO,CAACD,MAAMC,OAAO,CAACC,MAAM,GAAG,EAAE,EAAEC,YAAY,KAAI;AAC5F;AAEA,SAASC,SAAYC,GAAQ,EAAEC,GAAwB;IACrD,MAAMC,OAAO,IAAIC;IACjB,OAAOH,IAAII,MAAM,CAAC,CAACC;QACjB,MAAMC,KAAKL,IAAII;QACf,IAAIH,KAAKK,GAAG,CAACD,KAAK;YAChB,OAAO;QACT;QACAJ,KAAKM,GAAG,CAACF;QACT,OAAO;IACT;AACF;AAcO,SAASb,kBACdE,KAAuB,EACvBc,OAAkC;IAElC,SAASC,aAAaf,KAAgB,EAAEgB,cAAsB,EAAE;QAC9D,kGAAkG;QAClG,MAAMC,gBAAgB;YAACD;YAAahB,MAAMA,KAAK;SAAC,CAACS,MAAM,CAACS,SAASC,IAAI,CAAC;QAEtE,IAAInB,MAAMoB,QAAQ,CAAClB,MAAM,EAAE;YACzB,OAAOF,MAAMoB,QAAQ,CAACC,GAAG,CAAC,CAACC,QAAUP,aAAaO,OAAOL,gBAAgBM,IAAI;QAC/E;QAEA,0FAA0F;QAC1F,mGAAmG;QACnG,qGAAqG;QACrG,IAAIjB;QACJ,IAAIN,MAAMwB,IAAI,CAACC,QAAQ,CAAC,QAAQ;YAC9BnB,MAAMoB,wBAAwB1B,MAAM2B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
|
|
1
|
+
/** Entry module for the web renderer. */
|
|
2
|
+
import '@expo/metro-runtime';
|
|
3
|
+
export { getBuildTimeServerManifestAsync, getManifest } from '../static/getServerManifest';
|
|
4
|
+
export { getStreamingContent, resolveMetadata, type GetStreamingContentOptions, } from './renderStreamingContent';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Entry module for the web renderer. */ "use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
0 && (module.exports = {
|
|
6
|
+
getBuildTimeServerManifestAsync: null,
|
|
7
|
+
getManifest: null,
|
|
8
|
+
getStreamingContent: null,
|
|
9
|
+
resolveMetadata: null
|
|
10
|
+
});
|
|
11
|
+
function _export(target, all) {
|
|
12
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_export(exports, {
|
|
18
|
+
get getBuildTimeServerManifestAsync () {
|
|
19
|
+
return _getServerManifest.getBuildTimeServerManifestAsync;
|
|
20
|
+
},
|
|
21
|
+
get getManifest () {
|
|
22
|
+
return _getServerManifest.getManifest;
|
|
23
|
+
},
|
|
24
|
+
get getStreamingContent () {
|
|
25
|
+
return _renderStreamingContent.getStreamingContent;
|
|
26
|
+
},
|
|
27
|
+
get resolveMetadata () {
|
|
28
|
+
return _renderStreamingContent.resolveMetadata;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
require("@expo/metro-runtime");
|
|
32
|
+
const _getServerManifest = require("../static/getServerManifest");
|
|
33
|
+
const _renderStreamingContent = require("./renderStreamingContent");
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["server/render.ts"],"sourcesContent":[null],"names":["getBuildTimeServerManifestAsync","getManifest","getStreamingContent","resolveMetadata"],"mappings":"AAAA,uCAAuC;;;;;;;;;;;;;;;;;QAG9BA;eAAAA,kDAA+B;;QAAEC;eAAAA,8BAAW;;QAEnDC;eAAAA,2CAAmB;;QACnBC;eAAAA,uCAAe;;;QALV;mCAEsD;wCAKtD"}
|
package/build/utils/html.d.ts
CHANGED
|
@@ -5,32 +5,8 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { type AssetInfo } from 'expo-server/private';
|
|
8
|
-
/**
|
|
9
|
-
* Replaces unsafe characters in a string with their escaped equivalents. This is to safely
|
|
10
|
-
* embed data in an HTML context to prevent XSS.
|
|
11
|
-
*/
|
|
12
|
-
export declare function escapeUnsafeCharacters(str: string): string;
|
|
13
|
-
/**
|
|
14
|
-
* Returns a newline-separated `<link rel="preload">` and `<link rel="stylesheet">` pair for each
|
|
15
|
-
* CSS href.
|
|
16
|
-
*
|
|
17
|
-
* Used by both `renderStaticContent()` and `serializeHtml()` to inject CSS bundles into the HTML
|
|
18
|
-
* document's `<body>` element.
|
|
19
|
-
*/
|
|
20
|
-
export declare function createInjectedCssAsString(hrefs: string[]): string;
|
|
21
|
-
/**
|
|
22
|
-
* Returns newline-separated `<script defer>` HTML strings for each JavaScript source URL.
|
|
23
|
-
*
|
|
24
|
-
* Used by both `renderStaticContent()` and `serializeHtml()` to inject JavaScript bundles into the
|
|
25
|
-
* HTML document's `<body>` element.
|
|
26
|
-
*/
|
|
27
|
-
export declare function createInjectedScriptsAsString(srcs: string[]): string;
|
|
28
8
|
/**
|
|
29
9
|
* Returns a `<link rel="icon" />` HTML string for the given favicon href.
|
|
30
|
-
*
|
|
31
|
-
* Used by the SPA export path, which splices into a pre-rendered template instead of a React
|
|
32
|
-
* tree. Output must stay byte-equivalent to `createFaviconAsNode` (rendered to static markup)
|
|
33
|
-
* so both rendering paths agree on the tag shape.
|
|
34
10
|
*/
|
|
35
11
|
export declare function createFaviconAsString(href: string): string;
|
|
36
12
|
/**
|
|
@@ -40,33 +16,14 @@ export declare function createFaviconAsString(href: string): string;
|
|
|
40
16
|
* @see {@link getHydrationFlagScriptAsString} for the full `<script>` tag wrapper.
|
|
41
17
|
*/
|
|
42
18
|
export declare function getHydrationFlagScriptContents(): string;
|
|
43
|
-
/**
|
|
44
|
-
* Returns a module script that sets the `__EXPO_ROUTER_HYDRATE__` global flag, which tells the
|
|
45
|
-
* client-side Expo Router entrypoint to hydrate the server-rendered markup instead of performing
|
|
46
|
-
* a full client render.
|
|
47
|
-
*
|
|
48
|
-
* @see packages/expo/src/launch/registerRootComponent.tsx
|
|
49
|
-
*/
|
|
50
|
-
export declare function getHydrationFlagScriptAsString(): string;
|
|
51
19
|
/**
|
|
52
20
|
* Returns the string content of the loader data script, which sets
|
|
53
21
|
* `globalThis.__EXPO_ROUTER_LOADER_DATA__` to the given data using double-serialized JSON.
|
|
54
22
|
*
|
|
55
|
-
* @see {@link createLoaderDataScriptAsString} for the full `<script>` tag wrapper.
|
|
56
|
-
*/
|
|
57
|
-
export declare function getLoaderDataScriptContents(data: Record<string, unknown>): string;
|
|
58
|
-
/**
|
|
59
|
-
* Returns a synchronous inline `<script>` that sets `globalThis.__EXPO_ROUTER_LOADER_DATA__`
|
|
60
|
-
* with the given data, safely embedded as JSON.
|
|
61
|
-
*
|
|
62
23
|
* Uses double-serialization so the client can fast-parse via native `JSON.parse()`.
|
|
63
24
|
* @see https://v8.dev/blog/cost-of-javascript-2019#json
|
|
64
25
|
*/
|
|
65
|
-
export declare function
|
|
66
|
-
export declare function createExternalCssLinkAsString({ href, media, }: {
|
|
67
|
-
href: string;
|
|
68
|
-
media?: string;
|
|
69
|
-
}): string;
|
|
26
|
+
export declare function getLoaderDataScriptContents(data: Record<string, unknown>): string;
|
|
70
27
|
/**
|
|
71
28
|
* Injects favicon, hydration flag, and CSS (in that order) before `</head>`, and deferred scripts
|
|
72
29
|
* before `</body>`.
|
|
@@ -75,14 +32,3 @@ export declare function injectAssetsIntoHtml(html: string, { assets, hydrate }:
|
|
|
75
32
|
assets?: AssetInfo;
|
|
76
33
|
hydrate?: boolean;
|
|
77
34
|
}): string;
|
|
78
|
-
/**
|
|
79
|
-
* Extracts head tags and document attributes from a `react-helmet-async` helmet instance.
|
|
80
|
-
*
|
|
81
|
-
* `<head>` keys are serialized in document order: title, priority, meta, link, script, style.
|
|
82
|
-
* Returns empty strings when `helmet` is `null`/`undefined`.
|
|
83
|
-
*/
|
|
84
|
-
export declare function serializeHelmetToHtml(helmet: any): {
|
|
85
|
-
headTags: string;
|
|
86
|
-
htmlAttributes: string;
|
|
87
|
-
bodyAttributes: string;
|
|
88
|
-
};
|
package/build/utils/html.js
CHANGED
|
@@ -8,17 +8,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
0 && (module.exports = {
|
|
11
|
-
createExternalCssLinkAsString: null,
|
|
12
11
|
createFaviconAsString: null,
|
|
13
|
-
createInjectedCssAsString: null,
|
|
14
|
-
createInjectedScriptsAsString: null,
|
|
15
|
-
createLoaderDataScriptAsString: null,
|
|
16
|
-
escapeUnsafeCharacters: null,
|
|
17
|
-
getHydrationFlagScriptAsString: null,
|
|
18
12
|
getHydrationFlagScriptContents: null,
|
|
19
13
|
getLoaderDataScriptContents: null,
|
|
20
|
-
injectAssetsIntoHtml: null
|
|
21
|
-
serializeHelmetToHtml: null
|
|
14
|
+
injectAssetsIntoHtml: null
|
|
22
15
|
});
|
|
23
16
|
function _export(target, all) {
|
|
24
17
|
for(var name in all)Object.defineProperty(target, name, {
|
|
@@ -27,27 +20,9 @@ function _export(target, all) {
|
|
|
27
20
|
});
|
|
28
21
|
}
|
|
29
22
|
_export(exports, {
|
|
30
|
-
get createExternalCssLinkAsString () {
|
|
31
|
-
return createExternalCssLinkAsString;
|
|
32
|
-
},
|
|
33
23
|
get createFaviconAsString () {
|
|
34
24
|
return createFaviconAsString;
|
|
35
25
|
},
|
|
36
|
-
get createInjectedCssAsString () {
|
|
37
|
-
return createInjectedCssAsString;
|
|
38
|
-
},
|
|
39
|
-
get createInjectedScriptsAsString () {
|
|
40
|
-
return createInjectedScriptsAsString;
|
|
41
|
-
},
|
|
42
|
-
get createLoaderDataScriptAsString () {
|
|
43
|
-
return createLoaderDataScriptAsString;
|
|
44
|
-
},
|
|
45
|
-
get escapeUnsafeCharacters () {
|
|
46
|
-
return escapeUnsafeCharacters;
|
|
47
|
-
},
|
|
48
|
-
get getHydrationFlagScriptAsString () {
|
|
49
|
-
return getHydrationFlagScriptAsString;
|
|
50
|
-
},
|
|
51
26
|
get getHydrationFlagScriptContents () {
|
|
52
27
|
return getHydrationFlagScriptContents;
|
|
53
28
|
},
|
|
@@ -56,9 +31,6 @@ _export(exports, {
|
|
|
56
31
|
},
|
|
57
32
|
get injectAssetsIntoHtml () {
|
|
58
33
|
return injectAssetsIntoHtml;
|
|
59
|
-
},
|
|
60
|
-
get serializeHelmetToHtml () {
|
|
61
|
-
return serializeHelmetToHtml;
|
|
62
34
|
}
|
|
63
35
|
});
|
|
64
36
|
function _private() {
|
|
@@ -80,13 +52,19 @@ const ESCAPED_CHARACTERS = {
|
|
|
80
52
|
'\u2028': '\\u2028',
|
|
81
53
|
'\u2029': '\\u2029'
|
|
82
54
|
};
|
|
83
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Replaces unsafe characters in a string with their escaped equivalents. This is to safely
|
|
57
|
+
* embed data in an HTML context to prevent XSS.
|
|
58
|
+
*/ function escapeUnsafeCharacters(str) {
|
|
84
59
|
return str.replace(UNSAFE_CHARACTERS_REGEX, (match)=>ESCAPED_CHARACTERS[match] ?? match);
|
|
85
60
|
}
|
|
86
61
|
function escapeHtmlAttribute(value) {
|
|
87
62
|
return value.replace(/&/g, '&').replace(/"/g, '"');
|
|
88
63
|
}
|
|
89
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Returns a newline-separated `<link rel="preload">` and `<link rel="stylesheet">` pair for each
|
|
66
|
+
* CSS href.
|
|
67
|
+
*/ function createInjectedCssAsString(hrefs) {
|
|
90
68
|
return hrefs.flatMap((href)=>{
|
|
91
69
|
const safeHref = escapeHtmlAttribute(href);
|
|
92
70
|
return [
|
|
@@ -95,7 +73,9 @@ function createInjectedCssAsString(hrefs) {
|
|
|
95
73
|
];
|
|
96
74
|
}).join('\n');
|
|
97
75
|
}
|
|
98
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Returns newline-separated `<script defer>` HTML strings for each JavaScript source URL.
|
|
78
|
+
*/ function createInjectedScriptsAsString(srcs) {
|
|
99
79
|
return srcs.map((src)=>`<script src="${escapeHtmlAttribute(src)}" defer></script>`).join('\n');
|
|
100
80
|
}
|
|
101
81
|
function createFaviconAsString(href) {
|
|
@@ -104,16 +84,19 @@ function createFaviconAsString(href) {
|
|
|
104
84
|
function getHydrationFlagScriptContents() {
|
|
105
85
|
return `globalThis.__EXPO_ROUTER_HYDRATE__=true;`;
|
|
106
86
|
}
|
|
107
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Returns a module script that sets the `__EXPO_ROUTER_HYDRATE__` global flag, which tells the
|
|
89
|
+
* client-side Expo Router entrypoint to hydrate the server-rendered markup instead of performing
|
|
90
|
+
* a full client render.
|
|
91
|
+
*
|
|
92
|
+
* @see packages/expo/src/launch/registerRootComponent.tsx
|
|
93
|
+
*/ function getHydrationFlagScriptAsString() {
|
|
108
94
|
return `<script type="module">${getHydrationFlagScriptContents()}</script>`;
|
|
109
95
|
}
|
|
110
96
|
function getLoaderDataScriptContents(data) {
|
|
111
97
|
const safeJson = escapeUnsafeCharacters(JSON.stringify(data));
|
|
112
98
|
return `globalThis.__EXPO_ROUTER_LOADER_DATA__ = JSON.parse(${JSON.stringify(safeJson)});`;
|
|
113
99
|
}
|
|
114
|
-
function createLoaderDataScriptAsString(data) {
|
|
115
|
-
return `<script id="expo-router-data">${getLoaderDataScriptContents(data)}</script>`;
|
|
116
|
-
}
|
|
117
100
|
function createExternalCssLinkAsString({ href, media }) {
|
|
118
101
|
let link = `<link rel="stylesheet" href="${escapeHtmlAttribute(href)}"`;
|
|
119
102
|
if (media) {
|
|
@@ -156,34 +139,5 @@ function injectAssetsIntoHtml(html, { assets, hydrate }) {
|
|
|
156
139
|
}
|
|
157
140
|
return html;
|
|
158
141
|
}
|
|
159
|
-
const HELMET_HEAD_KEYS = [
|
|
160
|
-
'title',
|
|
161
|
-
'priority',
|
|
162
|
-
'meta',
|
|
163
|
-
'link',
|
|
164
|
-
'script',
|
|
165
|
-
'style'
|
|
166
|
-
];
|
|
167
|
-
function serializeHelmetToHtml(helmet) {
|
|
168
|
-
if (!helmet) {
|
|
169
|
-
return {
|
|
170
|
-
headTags: '',
|
|
171
|
-
htmlAttributes: '',
|
|
172
|
-
bodyAttributes: ''
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
const headParts = [];
|
|
176
|
-
for (const key of HELMET_HEAD_KEYS){
|
|
177
|
-
const result = helmet[key]?.toString();
|
|
178
|
-
if (result) {
|
|
179
|
-
headParts.push(result);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
headTags: headParts.join(''),
|
|
184
|
-
htmlAttributes: helmet.htmlAttributes?.toString() ?? '',
|
|
185
|
-
bodyAttributes: helmet.bodyAttributes?.toString() ?? ''
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
142
|
|
|
189
143
|
//# sourceMappingURL=html.js.map
|
package/build/utils/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils/html.ts"],"sourcesContent":[null],"names":["
|
|
1
|
+
{"version":3,"sources":["utils/html.ts"],"sourcesContent":[null],"names":["createFaviconAsString","getHydrationFlagScriptContents","getLoaderDataScriptContents","injectAssetsIntoHtml","UNSAFE_CHARACTERS_REGEX","ESCAPED_CHARACTERS","escapeUnsafeCharacters","str","replace","match","escapeHtmlAttribute","value","createInjectedCssAsString","hrefs","flatMap","href","safeHref","join","createInjectedScriptsAsString","srcs","map","src","getHydrationFlagScriptAsString","data","safeJson","JSON","stringify","createExternalCssLinkAsString","media","link","html","assets","hydrate","favicon","styleString","normalizeCssAssets","entry","type","hmrAttribute","hmrId","undefined","source","scripts","js"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;;;;;;;QAyDeA;eAAAA;;QAUAC;eAAAA;;QAsBAC;eAAAA;;QAiBAC;eAAAA;;;;yBAxGmC;;;;;;AAEnD,mIAAmI;AACnI,sGAAsG;AAEtG,iEAAiE;AACjE,uGAAuG;AAEvG,MAAMC,0BAA0B;AAChC,MAAMC,qBAAkD;IACtD,KAAK;IACL,KAAK;IACL,KAAK;IACL,UAAU;IACV,UAAU;AACZ;AAEA;;;CAGC,GACD,SAASC,uBAAuBC,GAAW;IACzC,OAAOA,IAAIC,OAAO,CAACJ,yBAAyB,CAACK,QAAUJ,kBAAkB,CAACI,MAAM,IAAIA;AACtF;AAEA,SAASC,oBAAoBC,KAAa;IACxC,OAAOA,MAAMH,OAAO,CAAC,MAAM,SAASA,OAAO,CAAC,MAAM;AACpD;AAEA;;;CAGC,GACD,SAASI,0BAA0BC,KAAe;IAChD,OAAOA,MACJC,OAAO,CAAC,CAACC;QACR,MAAMC,WAAWN,oBAAoBK;QACrC,OAAO;YACL,CAAC,0BAA0B,EAAEC,SAAS,aAAa,CAAC;YACpD,CAAC,6BAA6B,EAAEA,SAAS,EAAE,CAAC;SAC7C;IACH,GACCC,IAAI,CAAC;AACV;AAEA;;CAEC,GACD,SAASC,8BAA8BC,IAAc;IACnD,OAAOA,KAAKC,GAAG,CAAC,CAACC,MAAQ,CAAC,aAAa,EAAEX,oBAAoBW,KAAK,iBAAiB,CAAC,EAAEJ,IAAI,CAAC;AAC7F;AAKO,SAASjB,sBAAsBe,IAAY;IAChD,OAAO,CAAC,uBAAuB,EAAEL,oBAAoBK,MAAM,GAAG,CAAC;AACjE;AAQO,SAASd;IACd,OAAO,CAAC,wCAAwC,CAAC;AACnD;AAEA;;;;;;CAMC,GACD,SAASqB;IACP,OAAO,CAAC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A,KAAKtB,OAAO,CAAC,WAAW,GAAG0B,YAAY,OAAO,CAAC;QACxD;QAEA,MAAMQ,UAAUX,OAAOY,EAAE,CAACvB,GAAG,CAAC,CAACC,MAAQH,8BAA8B;gBAACG;aAAI,GAAGJ,IAAI,CAAC;QAClF,IAAIyB,SAAS;YACXZ,OAAOA,KAAKtB,OAAO,CAAC,WAAW,GAAGkC,QAAQ,SAAS,CAAC;QACtD;IACF;IAEA,OAAOZ;AACT"}
|
package/node/render.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('../build/
|
|
1
|
+
module.exports = require('../build/server/render');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/router-server",
|
|
3
|
-
"version": "58.0.
|
|
3
|
+
"version": "58.0.22",
|
|
4
4
|
"description": "Expo Router is a file-based router for React Native and web applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expo",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"@types/react-dom": "^19.1.7",
|
|
39
39
|
"@typescript/vfs": "^1.6.4",
|
|
40
40
|
"expect-type": "^1.3.0",
|
|
41
|
-
"expo-router": "58.0.
|
|
41
|
+
"expo-router": "58.0.31",
|
|
42
42
|
"node-html-parser": "^6.1.5",
|
|
43
43
|
"react-server-dom-webpack": "~19.0.8"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@expo/metro-runtime": "^58.0.17",
|
|
47
47
|
"expo": "*",
|
|
48
|
-
"expo-constants": "^58.0.
|
|
49
|
-
"expo-font": "^58.0.
|
|
48
|
+
"expo-constants": "^58.0.16",
|
|
49
|
+
"expo-font": "^58.0.12",
|
|
50
50
|
"expo-router": "*",
|
|
51
|
-
"expo-server": "^58.0
|
|
51
|
+
"expo-server": "^58.1.0",
|
|
52
52
|
"react": "*",
|
|
53
53
|
"react-dom": "*",
|
|
54
54
|
"react-server-dom-webpack": "~19.0.1 || ~19.1.2 || ~19.2.1 || ~19.3.0"
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright © 2026 650 Industries.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
import '@expo/metro-runtime';
|
|
8
|
-
import type { AssetInfo, MatchedRoute } from 'expo-server/private';
|
|
9
|
-
export type GetStaticContentOptions = {
|
|
10
|
-
loader?: {
|
|
11
|
-
data?: any;
|
|
12
|
-
/** Unique key for the route. Derived from the route's contextKey */
|
|
13
|
-
key: string;
|
|
14
|
-
};
|
|
15
|
-
request?: Request;
|
|
16
|
-
/** The route the server matched for `location`. */
|
|
17
|
-
route: MatchedRoute;
|
|
18
|
-
/** The params the server captured for `route`. */
|
|
19
|
-
params?: Record<string, string | string[]>;
|
|
20
|
-
hydrate?: boolean;
|
|
21
|
-
assets?: AssetInfo;
|
|
22
|
-
};
|
|
23
|
-
export declare function getStaticContent(location: URL, options: GetStaticContentOptions): Promise<string>;
|
|
24
|
-
export { getStreamingContent, resolveMetadata } from '../server/renderStreamingContent';
|
|
25
|
-
export { getBuildTimeServerManifestAsync, getManifest } from './getServerManifest';
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright © 2026 650 Industries.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/ "use strict";
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
0 && (module.exports = {
|
|
11
|
-
getBuildTimeServerManifestAsync: null,
|
|
12
|
-
getManifest: null,
|
|
13
|
-
getStaticContent: null,
|
|
14
|
-
getStreamingContent: null,
|
|
15
|
-
resolveMetadata: null
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
get getBuildTimeServerManifestAsync () {
|
|
25
|
-
return _getServerManifest.getBuildTimeServerManifestAsync;
|
|
26
|
-
},
|
|
27
|
-
get getManifest () {
|
|
28
|
-
return _getServerManifest.getManifest;
|
|
29
|
-
},
|
|
30
|
-
get getStaticContent () {
|
|
31
|
-
return getStaticContent;
|
|
32
|
-
},
|
|
33
|
-
get getStreamingContent () {
|
|
34
|
-
return _renderStreamingContent.getStreamingContent;
|
|
35
|
-
},
|
|
36
|
-
get resolveMetadata () {
|
|
37
|
-
return _renderStreamingContent.resolveMetadata;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
function _jsxruntime() {
|
|
41
|
-
const data = require("react/jsx-runtime");
|
|
42
|
-
_jsxruntime = function() {
|
|
43
|
-
return data;
|
|
44
|
-
};
|
|
45
|
-
return data;
|
|
46
|
-
}
|
|
47
|
-
require("@expo/metro-runtime");
|
|
48
|
-
function _server() {
|
|
49
|
-
const data = /*#__PURE__*/ _interop_require_wildcard(require("expo-font/build/server"));
|
|
50
|
-
_server = function() {
|
|
51
|
-
return data;
|
|
52
|
-
};
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
function _exporouter() {
|
|
56
|
-
const data = require("expo-router");
|
|
57
|
-
_exporouter = function() {
|
|
58
|
-
return data;
|
|
59
|
-
};
|
|
60
|
-
return data;
|
|
61
|
-
}
|
|
62
|
-
function _ctx() {
|
|
63
|
-
const data = require("expo-router/_ctx");
|
|
64
|
-
_ctx = function() {
|
|
65
|
-
return data;
|
|
66
|
-
};
|
|
67
|
-
return data;
|
|
68
|
-
}
|
|
69
|
-
function _head() {
|
|
70
|
-
const data = /*#__PURE__*/ _interop_require_default(require("expo-router/head"));
|
|
71
|
-
_head = function() {
|
|
72
|
-
return data;
|
|
73
|
-
};
|
|
74
|
-
return data;
|
|
75
|
-
}
|
|
76
|
-
function _static() {
|
|
77
|
-
const data = require("expo-router/internal/static");
|
|
78
|
-
_static = function() {
|
|
79
|
-
return data;
|
|
80
|
-
};
|
|
81
|
-
return data;
|
|
82
|
-
}
|
|
83
|
-
function _react() {
|
|
84
|
-
const data = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
85
|
-
_react = function() {
|
|
86
|
-
return data;
|
|
87
|
-
};
|
|
88
|
-
return data;
|
|
89
|
-
}
|
|
90
|
-
function _server1() {
|
|
91
|
-
const data = /*#__PURE__*/ _interop_require_default(require("react-dom/server"));
|
|
92
|
-
_server1 = function() {
|
|
93
|
-
return data;
|
|
94
|
-
};
|
|
95
|
-
return data;
|
|
96
|
-
}
|
|
97
|
-
const _debug = require("../utils/debug");
|
|
98
|
-
const _html = require("../utils/html");
|
|
99
|
-
const _getRootComponent = require("./getRootComponent");
|
|
100
|
-
const _renderStreamingContent = require("../server/renderStreamingContent");
|
|
101
|
-
const _getServerManifest = require("./getServerManifest");
|
|
102
|
-
function _interop_require_default(obj) {
|
|
103
|
-
return obj && obj.__esModule ? obj : {
|
|
104
|
-
default: obj
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
108
|
-
if (typeof WeakMap !== "function") return null;
|
|
109
|
-
var cacheBabelInterop = new WeakMap();
|
|
110
|
-
var cacheNodeInterop = new WeakMap();
|
|
111
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
112
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
113
|
-
})(nodeInterop);
|
|
114
|
-
}
|
|
115
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
116
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
117
|
-
return obj;
|
|
118
|
-
}
|
|
119
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
120
|
-
return {
|
|
121
|
-
default: obj
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
125
|
-
if (cache && cache.has(obj)) {
|
|
126
|
-
return cache.get(obj);
|
|
127
|
-
}
|
|
128
|
-
var newObj = {
|
|
129
|
-
__proto__: null
|
|
130
|
-
};
|
|
131
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
132
|
-
for(var key in obj){
|
|
133
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
134
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
135
|
-
if (desc && (desc.get || desc.set)) {
|
|
136
|
-
Object.defineProperty(newObj, key, desc);
|
|
137
|
-
} else {
|
|
138
|
-
newObj[key] = obj[key];
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
newObj.default = obj;
|
|
143
|
-
if (cache) {
|
|
144
|
-
cache.set(obj, newObj);
|
|
145
|
-
}
|
|
146
|
-
return newObj;
|
|
147
|
-
}
|
|
148
|
-
const debug = (0, _debug.createDebug)('expo:router:server:renderStaticContent');
|
|
149
|
-
function resetReactNavigationContexts() {
|
|
150
|
-
// https://github.com/expo/router/discussions/588
|
|
151
|
-
// https://github.com/react-navigation/react-navigation/blob/9fe34b445fcb86e5666f61e144007d7540f014fa/packages/elements/src/getNamedContext.tsx#LL3C1-L4C1
|
|
152
|
-
// React Navigation is storing providers in a global, this is fine for the first static render
|
|
153
|
-
// but subsequent static renders of Stack or Tabs will cause React to throw a warning. To prevent this warning, we'll reset the globals before rendering.
|
|
154
|
-
const contexts = '__react_navigation__elements_contexts';
|
|
155
|
-
globalThis[contexts] = new Map();
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Shared setup for both `getStaticContent()` and `getStreamingContent()`. Creates the React element
|
|
159
|
-
* tree, resets server contexts, and computes loader data.
|
|
160
|
-
*/ function prepareRenderContext(location, options) {
|
|
161
|
-
const headContext = {};
|
|
162
|
-
const Root = (0, _getRootComponent.getRootComponent)();
|
|
163
|
-
const { pathname, params, searchParams } = (0, _static().getRouteInfoForMatchedRoute)(options.route, options.params ?? {}, location);
|
|
164
|
-
const { // NOTE: The `element` that's returned adds two extra Views and
|
|
165
|
-
// the seemingly unused `RootTagContext.Provider`.
|
|
166
|
-
element, getStyleElement } = (0, _static().registerStaticRootComponent)(_exporouter().ExpoRoot, {
|
|
167
|
-
location,
|
|
168
|
-
context: _ctx().ctx,
|
|
169
|
-
wrapper: ({ children })=>/*#__PURE__*/ (0, _jsxruntime().jsx)(Root, {
|
|
170
|
-
pathname: pathname,
|
|
171
|
-
params: params,
|
|
172
|
-
children: /*#__PURE__*/ (0, _jsxruntime().jsx)("div", {
|
|
173
|
-
id: "root",
|
|
174
|
-
children: children
|
|
175
|
-
})
|
|
176
|
-
})
|
|
177
|
-
});
|
|
178
|
-
// This MUST be run before `ReactDOMServer.renderToString` to prevent
|
|
179
|
-
// "Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."
|
|
180
|
-
resetReactNavigationContexts();
|
|
181
|
-
const search = searchParams.toString();
|
|
182
|
-
const loaderKey = options.loader ? options.loader.key + (search ? `?${search}` : '') : null;
|
|
183
|
-
const loadedData = loaderKey ? {
|
|
184
|
-
[loaderKey]: options.loader?.data ?? null
|
|
185
|
-
} : null;
|
|
186
|
-
return {
|
|
187
|
-
headContext,
|
|
188
|
-
element,
|
|
189
|
-
getStyleElement,
|
|
190
|
-
loadedData
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
async function getStaticContent(location, options) {
|
|
194
|
-
return _server().withServerContext(()=>{
|
|
195
|
-
const { headContext, element, getStyleElement, loadedData } = prepareRenderContext(location, options);
|
|
196
|
-
const html = _server1().default.renderToString(/*#__PURE__*/ (0, _jsxruntime().jsx)(_head().default.Provider, {
|
|
197
|
-
context: headContext,
|
|
198
|
-
children: /*#__PURE__*/ (0, _jsxruntime().jsx)(_static().InnerRoot, {
|
|
199
|
-
loadedData: loadedData,
|
|
200
|
-
children: element
|
|
201
|
-
})
|
|
202
|
-
}));
|
|
203
|
-
// Eval the CSS after the HTML is rendered so that the CSS is in the same order
|
|
204
|
-
const css = _server1().default.renderToStaticMarkup(getStyleElement());
|
|
205
|
-
let output = mixHeadComponentsWithStaticResults(headContext.helmet, html);
|
|
206
|
-
output = output.replace('</head>', `${css}</head>`);
|
|
207
|
-
const fonts = _server().getServerResources();
|
|
208
|
-
debug(`Pushing static fonts: (count: ${fonts.length})`, fonts);
|
|
209
|
-
// Inject static fonts loaded with expo-font
|
|
210
|
-
output = output.replace('</head>', `${fonts.join('')}</head>`);
|
|
211
|
-
if (loadedData) {
|
|
212
|
-
output = output.replace('</head>', `${(0, _html.createLoaderDataScriptAsString)(loadedData)}</head>`);
|
|
213
|
-
}
|
|
214
|
-
output = (0, _html.injectAssetsIntoHtml)(output, {
|
|
215
|
-
assets: options.assets,
|
|
216
|
-
hydrate: options.hydrate
|
|
217
|
-
});
|
|
218
|
-
return '<!DOCTYPE html>' + output;
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
function mixHeadComponentsWithStaticResults(helmet, html) {
|
|
222
|
-
const { headTags, htmlAttributes, bodyAttributes } = (0, _html.serializeHelmetToHtml)(helmet);
|
|
223
|
-
if (headTags) {
|
|
224
|
-
html = html.replace('<head>', `<head>${headTags}`);
|
|
225
|
-
}
|
|
226
|
-
// attributes
|
|
227
|
-
html = html.replace('<html ', `<html ${htmlAttributes} `);
|
|
228
|
-
html = html.replace('<body ', `<body ${bodyAttributes} `);
|
|
229
|
-
return html;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
//# sourceMappingURL=renderStaticContent.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["static/renderStaticContent.tsx"],"sourcesContent":[null],"names":["getBuildTimeServerManifestAsync","getManifest","getStaticContent","getStreamingContent","resolveMetadata","debug","createDebug","resetReactNavigationContexts","contexts","globalThis","Map","prepareRenderContext","location","options","headContext","Root","getRootComponent","pathname","params","searchParams","getRouteInfoForMatchedRoute","route","element","getStyleElement","registerStaticRootComponent","ExpoRoot","context","ctx","wrapper","children","div","id","search","toString","loaderKey","loader","key","loadedData","data","Font","withServerContext","html","ReactDOMServer","renderToString","Head","Provider","InnerRoot","css","renderToStaticMarkup","output","mixHeadComponentsWithStaticResults","helmet","replace","fonts","getServerResources","length","join","createLoaderDataScriptAsString","injectAssetsIntoHtml","assets","hydrate","headTags","htmlAttributes","bodyAttributes","serializeHelmetToHtml"],"mappings":"AAAA;;;;;CAKC;;;;;;;;;;;;;;;;;;QAmJQA;eAAAA,kDAA+B;;QAAEC;eAAAA,8BAAW;;QArD/BC;eAAAA;;QAoDbC;eAAAA,2CAAmB;;QAAEC;eAAAA,uCAAe;;;;;;;;;;QAjJtC;;iEACe;;;;;;;yBACG;;;;;;;yBACL;;;;;;;gEACH;;;;;;;yBAKV;;;;;;;gEAEW;;;;;;;gEACS;;;;;;uBAEC;sBAKrB;kCAC0B;wCA6HoB;mCACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA5H7D,MAAMC,QAAQC,IAAAA,kBAAW,EAAC;AAE1B,SAASC;IACP,iDAAiD;IACjD,0JAA0J;IAE1J,8FAA8F;IAC9F,yJAAyJ;IACzJ,MAAMC,WAAW;IAChBC,UAAkB,CAACD,SAAS,GAAG,IAAIE;AACtC;AAiBA;;;CAGC,GACD,SAASC,qBAAqBC,QAAa,EAAEC,OAAgC;IAC3E,MAAMC,cAAgC,CAAC;IACvC,MAAMC,OAAOC,IAAAA,kCAAgB;IAC7B,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,YAAY,EAAE,GAAGC,IAAAA,qCAA2B,EACpEP,QAAQQ,KAAK,EACbR,QAAQK,MAAM,IAAI,CAAC,GACnBN;IAGF,MAAM,EACJ,+DAA+D;IAC/D,kDA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