@expo/router-server 58.0.22 → 58.0.23
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/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
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAtKhC,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;AAwBA,SAASC,qBAAqBC,QAAa,EAAEC,OAAmC;IAC9E,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;I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vB;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.23",
|
|
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.32",
|
|
42
42
|
"node-html-parser": "^6.1.5",
|
|
43
43
|
"react-server-dom-webpack": "~19.0.8"
|
|
44
44
|
},
|