@expo/router-server 58.0.22 → 58.0.24
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/rsc/middleware.js +5 -3
- package/build/rsc/middleware.js.map +1 -1
- package/build/server/isCrawler.d.ts +1 -0
- package/build/server/isCrawler.js +22 -0
- package/build/server/isCrawler.js.map +1 -0
- package/build/server/renderStreamingContent.d.ts +1 -1
- package/build/server/renderStreamingContent.js +4 -1
- package/build/server/renderStreamingContent.js.map +1 -1
- package/package.json +2 -2
package/build/rsc/middleware.js
CHANGED
|
@@ -49,17 +49,19 @@ function _interop_require_default(obj) {
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
const debug = (0, _debug.createDebug)('expo:router:server:rsc-renderer');
|
|
52
|
+
// TODO(@kitten): Bundle RSC like the SSR renderer so the serializer handles chunking internally.
|
|
53
|
+
const serverOutputExtension = _nodepath().default.extname(__filename);
|
|
52
54
|
function serverRequire(...targetOutputModulePath) {
|
|
53
55
|
// NOTE(@kitten): This `__dirname` will be located in the output file system, e.g. `dist/server/*`
|
|
54
56
|
const filePath = _nodepath().default.join(__dirname, ...targetOutputModulePath);
|
|
55
57
|
return $$require_external(filePath);
|
|
56
58
|
}
|
|
57
59
|
function getServerActionManifest(_distFolder, platform) {
|
|
58
|
-
const filePath = `../../rsc/${platform}/action-manifest
|
|
60
|
+
const filePath = `../../rsc/${platform}/action-manifest${serverOutputExtension}`;
|
|
59
61
|
return serverRequire(filePath);
|
|
60
62
|
}
|
|
61
63
|
function getSSRManifest(_distFolder, platform) {
|
|
62
|
-
const filePath = `../../rsc/${platform}/ssr-manifest
|
|
64
|
+
const filePath = `../../rsc/${platform}/ssr-manifest${serverOutputExtension}`;
|
|
63
65
|
return serverRequire(filePath);
|
|
64
66
|
}
|
|
65
67
|
async function renderRscWithImportsAsync(distFolder, imports, { body, platform, searchParams, config, method, input, contentType, headers }) {
|
|
@@ -130,7 +132,7 @@ async function renderRscAsync(distFolder, args) {
|
|
|
130
132
|
return renderRscWithImportsAsync(distFolder, {
|
|
131
133
|
router: ()=>{
|
|
132
134
|
// NOTE(@kitten): [WORKAROUND] Assumes __dirname is at `dist/server/_expo/functions/_flight`
|
|
133
|
-
return serverRequire(`../../rsc/${platform}/router
|
|
135
|
+
return serverRequire(`../../rsc/${platform}/router${serverOutputExtension}`);
|
|
134
136
|
}
|
|
135
137
|
}, args);
|
|
136
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["rsc/middleware.ts"],"sourcesContent":[null],"names":["renderRscAsync","renderRscWithImportsAsync","debug","createDebug","serverRequire","targetOutputModulePath","filePath","
|
|
1
|
+
{"version":3,"sources":["rsc/middleware.ts"],"sourcesContent":[null],"names":["renderRscAsync","renderRscWithImportsAsync","debug","createDebug","serverOutputExtension","path","extname","__filename","serverRequire","targetOutputModulePath","filePath","join","__dirname","$$require_external","getServerActionManifest","_distFolder","platform","getSSRManifest","distFolder","imports","body","searchParams","config","method","input","contentType","headers","Error","context","__expo_requestHeaders","router","entries","default","redirects","Constants","expoConfig","extra","rewrites","ssrManifest","actionManifest","renderRsc","undefined","decodedBody","get","isExporting","resolveClientEntry","file","isServer","actionManifestFile","JSON","stringify","id","chunk","chunks","ssrManifestFile","loadServerModuleRsc","args"],"mappings":"AAAA;;;;;;CAMC,GACD,2GAA2G;;;;;;;;;;;;;;;;QAsIrFA;eAAAA;;QA3EAC;eAAAA;;;;gEA1DA;;;;;;;gEAEL;;;;;;uBAEW;6BACF;;;;;;AAI1B,MAAMC,QAAQC,IAAAA,kBAAW,EAAC;AAC1B,iGAAiG;AACjG,MAAMC,wBAAwBC,mBAAI,CAACC,OAAO,CAACC;AAE3C,SAASC,cAAuB,GAAGC,sBAAgC;IACjE,kGAAkG;IAClG,MAAMC,WAAWL,mBAAI,CAACM,IAAI,CAACC,cAAcH;IACzC,OAAOI,mBAAmBH;AAC5B;AAEA,SAASI,wBACPC,WAAmB,EACnBC,QAA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BAE/F;gBAEA,MAAM,CAACY,IAAIC,MAAM,GAAGJ;gBACpB,OAAO;oBACLG;oBACAE,QAAQD,QAAQ;wBAACA;qBAAM,GAAG,EAAE;gBAC9B;YACF;YAEA,MAAME,kBAAkBhB,WAAW,CAACQ,KAAK;YAEzC,IAAIQ,mBAAmB,MAAM;gBAC3B,MAAM,IAAI3B,MAAM,CAAC,qCAAqC,EAAEmB,MAAM;YAChE;YAEA,MAAM,CAACK,IAAIC,MAAM,GAAGE;YACpB,OAAO;gBACLH;gBACAE,QAAQD,QAAQ;oBAACA;iBAAM,GAAG,EAAE;YAC9B;QACF;QACA,MAAMG,qBAAoBT,IAAI;YAC5B5C,MAAM,uBAAuB4C;YAC7B,4FAA4F;YAC5F,OAAOtC,cAAc,aAAasC;QACpC;QAEAf,SAASA;IACX;AAEJ;AAEO,eAAe/B,eACpBkB,UAAkB,EAClBsC,IAAmB;IAEnB,MAAMxC,WAAWwC,KAAKxC,QAAQ;IAC9B,OAAOf,0BACLiB,YACA;QACEY,QAAQ;YACN,4FAA4F;YAC5F,OAAOtB,cAAc,CAAC,UAAU,EAAEQ,SAAS,OAAO,EAAEZ,uBAAuB;QAC7E;IACF,GACAoD;AAEJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isCrawler(userAgent: string): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "isCrawler", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return isCrawler;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
// Based on Next.js's bot detection:
|
|
12
|
+
// https://github.com/vercel/next.js/blob/502b6b7daf220f4516eb2d8b7e750ce6874ac201/packages/next/src/shared/lib/router/utils/is-bot.ts
|
|
13
|
+
// https://github.com/vercel/next.js/blob/502b6b7daf220f4516eb2d8b7e750ce6874ac201/packages/next/src/shared/lib/router/utils/html-bots.ts
|
|
14
|
+
const HEADLESS_BROWSER_BOT_USER_AGENT = /Googlebot(?!-)|Googlebot$/i;
|
|
15
|
+
const HTML_LIMITED_BOT_USER_AGENT = /[\w-]-Google|Google-[\w-]|Chrome-Lighthouse|Slurp|DuckDuckBot|baiduspider|yandex|sogou|bitlybot|tumblr|vkShare|quora link preview|redditbot|ia_archiver|Bingbot|BingPreview|applebot|facebookexternalhit|facebookcatalog|Twitterbot|LinkedInBot|Slackbot|Discordbot|WhatsApp|SkypeUriPreview|Yeti|googleweblight/i;
|
|
16
|
+
// Bound regex matching on the request header, as Next.js does.
|
|
17
|
+
const MAX_USER_AGENT_LENGTH = 1024;
|
|
18
|
+
function isCrawler(userAgent) {
|
|
19
|
+
return userAgent.length <= MAX_USER_AGENT_LENGTH && (HEADLESS_BROWSER_BOT_USER_AGENT.test(userAgent) || HTML_LIMITED_BOT_USER_AGENT.test(userAgent));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=isCrawler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["server/isCrawler.ts"],"sourcesContent":[null],"names":["isCrawler","HEADLESS_BROWSER_BOT_USER_AGENT","HTML_LIMITED_BOT_USER_AGENT","MAX_USER_AGENT_LENGTH","userAgent","length","test"],"mappings":";;;;+BAUgBA;;;eAAAA;;;AAVhB,oCAAoC;AACpC,sIAAsI;AACtI,yIAAyI;AACzI,MAAMC,kCAAkC;AACxC,MAAMC,8BACJ;AAEF,+DAA+D;AAC/D,MAAMC,wBAAwB;AAEvB,SAASH,UAAUI,SAAiB;IACzC,OACEA,UAAUC,MAAM,IAAIF,yBACnBF,CAAAA,gCAAgCK,IAAI,CAACF,cAAcF,4BAA4BI,IAAI,CAACF,UAAS;AAElG"}
|
|
@@ -28,7 +28,7 @@ export type GetStreamingContentOptions = {
|
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
30
|
* Renders the document using `renderToReadableStream`. Static output waits for Suspense
|
|
31
|
-
* and returns HTML; server output returns a
|
|
31
|
+
* and returns HTML; server output returns a stream, waiting for Suspense for known crawlers.
|
|
32
32
|
*/
|
|
33
33
|
export declare function getStreamingContent(location: URL, options: GetStreamingContentOptions & {
|
|
34
34
|
output: 'static';
|
|
@@ -100,6 +100,7 @@ function _server2() {
|
|
|
100
100
|
const _getRootComponent = require("../static/getRootComponent");
|
|
101
101
|
const _debug = require("../utils/debug");
|
|
102
102
|
const _react1 = require("../utils/react");
|
|
103
|
+
const _isCrawler = require("./isCrawler");
|
|
103
104
|
const _metadata = require("./metadata");
|
|
104
105
|
function _interop_require_default(obj) {
|
|
105
106
|
return obj && obj.__esModule ? obj : {
|
|
@@ -246,8 +247,10 @@ async function getStreamingContent(location, options) {
|
|
|
246
247
|
}
|
|
247
248
|
}
|
|
248
249
|
});
|
|
249
|
-
if (isStatic) {
|
|
250
|
+
if (isStatic || (0, _isCrawler.isCrawler)(options.request?.headers.get('user-agent') ?? '')) {
|
|
250
251
|
await stream.allReady;
|
|
252
|
+
}
|
|
253
|
+
if (isStatic) {
|
|
251
254
|
if (renderErrors.length > 0) {
|
|
252
255
|
throw renderErrors[0];
|
|
253
256
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["server/renderStreamingContent.tsx"],"sourcesContent":[null],"names":["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","FontResources","descriptors","Font","getServerResourceDescriptors","length","createInjectedFontsAsNodes","withServerContext","headNodes","cssNodes","createInjectedCssAsNodes","normalizeCssAssets","assets","faviconNode","favicon","createFaviconAsNode","undefined","headJsNodes","bodyNodes","bodyJsNodes","createInjectedScriptAsNodes","js","serverDocumentData","metadata","filter","Boolean","isStatic","output","renderErrors","stream","ReactDOMServer","renderToReadableStream","ServerDocument","Head","Provider","InnerRoot","progressiveChunkSize","Number","MAX_SAFE_INTEGER","bootstrapScriptContent","getBootstrapContents","hydrate","signal","request","onError","error","aborted","push","console","allReady","Response","text"],"mappings":"AAAA;;;;;CAKC,GACD,kEAAkE;AAClE,gCAAgC;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["server/renderStreamingContent.tsx"],"sourcesContent":[null],"names":["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","FontResources","descriptors","Font","getServerResourceDescriptors","length","createInjectedFontsAsNodes","withServerContext","headNodes","cssNodes","createInjectedCssAsNodes","normalizeCssAssets","assets","faviconNode","favicon","createFaviconAsNode","undefined","headJsNodes","bodyNodes","bodyJsNodes","createInjectedScriptAsNodes","js","serverDocumentData","metadata","filter","Boolean","isStatic","output","renderErrors","stream","ReactDOMServer","renderToReadableStream","ServerDocument","Head","Provider","InnerRoot","progressiveChunkSize","Number","MAX_SAFE_INTEGER","bootstrapScriptContent","getBootstrapContents","hydrate","signal","request","onError","error","aborted","push","console","isCrawler","headers","get","allReady","Response","text"],"mappings":"AAAA;;;;;CAKC,GACD,kEAAkE;AAClE,gCAAgC;;;;;;;;;;;;;;;;QAuHVA;eAAAA;;QA0EbC;eAAAA,yBAAe;;;;;;;;;;;iEA/LF;;;;;;;yBACG;;;;;;;yBACL;;;;;;;gEACH;;;;;;;yBACc;;;;;;;yBAKxB;;;;;;;yBAC+D;;;;;;;gEAChC;;;;;;;gEACX;;;;;;kCAEM;uBACL;wBAOrB;2BACmB;0BAwKM;;;;;;;;;;;;;;;;;;;;;;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AMiB;YACR0B,QAAQnE,QAAQoE,OAAO,EAAED;YACzBE,SAAQC,KAAK;gBACX,IAAItE,QAAQoE,OAAO,EAAED,OAAOI,SAAS;oBACnC;gBACF;gBAEA,IAAIpB,UAAU;oBACZE,aAAamB,IAAI,CAACF;gBACpB,OAAO;oBACLG,QAAQH,KAAK,CAAC,+BAA+BA;gBAC/C;YACF;QACF;QAEF,IAAInB,YAAYuB,IAAAA,oBAAS,EAAC1E,QAAQoE,OAAO,EAAEO,QAAQC,IAAI,iBAAiB,KAAK;YAC3E,MAAMtB,OAAOuB,QAAQ;QACvB;QACA,IAAI1B,UAAU;YACZ,IAAIE,aAAavB,MAAM,GAAG,GAAG;gBAC3B,MAAMuB,YAAY,CAAC,EAAE;YACvB;YACA,OAAO,IAAIyB,SAASxB,QAAQyB,IAAI;QAClC;QACA,OAAOzB;IACT;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/router-server",
|
|
3
|
-
"version": "58.0.
|
|
3
|
+
"version": "58.0.24",
|
|
4
4
|
"description": "Expo Router is a file-based router for React Native and web applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expo",
|
|
@@ -38,7 +38,7 @@
|
|
|
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.33",
|
|
42
42
|
"node-html-parser": "^6.1.5",
|
|
43
43
|
"react-server-dom-webpack": "~19.0.8"
|
|
44
44
|
},
|