@expo/metro-runtime 2.1.1 → 2.1.2
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.
|
@@ -20,7 +20,7 @@ function warnProductionOriginNotConfigured(requestUrl) {
|
|
|
20
20
|
}
|
|
21
21
|
hasWarned = true;
|
|
22
22
|
if (!((_b = (_a = manifest === null || manifest === void 0 ? void 0 : manifest.extra) === null || _a === void 0 ? void 0 : _a.router) === null || _b === void 0 ? void 0 : _b.origin)) {
|
|
23
|
-
console.warn(`The relative fetch request "${requestUrl}" will not work in production until the Expo
|
|
23
|
+
console.warn(`The relative fetch request "${requestUrl}" will not work in production until the Expo Router Config Plugin (app.json) is configured with the \`origin\` prop set to the base URL of your web server, e.g. \`{ plugins: [["expo-router", { origin: "..." }]] }\`. [Learn more](https://expo.github.io/router/docs/lab/runtime-location)`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
// TODO: This would be better if native and tied as close to the JS engine as possible, i.e. it should
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.native.js","sourceRoot":"","sources":["../../src/location/install.native.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAuC;AACvC,0DAA4B;AAE5B,mEAA2C;AAC3C,yCAAsD;AAEtD,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,MAAM,QAAQ,GAAG,CAAC,MAAA,MAAA,wBAAS,CAAC,QAAQ,mCAClC,wBAAS,CAAC,SAAS,mCACnB,wBAAS,CAAC,UAAU,CAA+B,CAAC;AAEtD,mEAAmE;AACnE,uEAAuE;AACvE,2EAA2E;AAC3E,SAAS,iCAAiC,CAAC,UAAkB;;IAC3D,IAAI,SAAS,EAAE;QACb,OAAO;KACR;IACD,SAAS,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,CAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,0CAAE,MAAM,0CAAE,MAAM,CAAA,EAAE;Q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AK,CAAC,GAAG,KAAK,CAAC,CAAC;IACzB,CAAC,CAAC;IAEF,MAAM,CAAC,0BAA0B,GAAG,IAAI,CAAC;IAEzC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,IAAI,CAAA,MAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,0CAAE,MAAM,0CAAE,MAAM,MAAK,KAAK,EAAE;IAC7C,+CAA+C;IAC/C,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrD,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;QACzB,IAAI,GAAG,EAAE;YACP,IAAA,0BAAe,EAAC,GAAG,CAAC,CAAC;YACrB,IAAA,kBAAO,GAAE,CAAC;SACX;KACF;IACD,iDAAiD;IACjD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE;QACrC,KAAK,EAAE,2BAA2B,CAAC,KAAK,CAAC;KAC1C,CAAC,CAAC;CACJ","sourcesContent":["import Constants from \"expo-constants\";\nimport URL from \"url-parse\";\n\nimport getDevServer from \"../getDevServer\";\nimport { install, setLocationHref } from \"./Location\";\n\nlet hasWarned = false;\n\nconst manifest = (Constants.manifest ??\n Constants.manifest2 ??\n Constants.expoConfig) as Record<string, any> | null;\n\n// Add a development warning for fetch requests with relative paths\n// to ensure developers are aware of the need to configure a production\n// base URL in the Expo config (app.json) under `expo.extra.router.origin`.\nfunction warnProductionOriginNotConfigured(requestUrl: string) {\n if (hasWarned) {\n return;\n }\n hasWarned = true;\n if (!manifest?.extra?.router?.origin) {\n console.warn(\n `The relative fetch request \"${requestUrl}\" will not work in production until the Expo Router Config Plugin (app.json) is configured with the \\`origin\\` prop set to the base URL of your web server, e.g. \\`{ plugins: [[\"expo-router\", { origin: \"...\" }]] }\\`. [Learn more](https://expo.github.io/router/docs/lab/runtime-location)`\n );\n }\n}\n\n// TODO: This would be better if native and tied as close to the JS engine as possible, i.e. it should\n// reflect the exact location of the JS file that was executed.\nfunction getBaseUrl() {\n if (process.env.NODE_ENV !== \"production\") {\n // e.g. http://localhost:19006\n return getDevServer().url?.replace(/\\/$/, \"\");\n }\n\n // TODO: Make it official by moving out of `extra`\n const productionBaseUrl = manifest?.extra?.router?.origin;\n\n if (!productionBaseUrl) {\n return null;\n }\n\n // Ensure no trailing slash\n return productionBaseUrl?.replace(/\\/$/, \"\");\n}\n\nfunction wrapFetchWithWindowLocation(\n fetch: Function & { __EXPO_BASE_URL_POLYFILLED?: boolean }\n) {\n if (fetch.__EXPO_BASE_URL_POLYFILLED) {\n return fetch;\n }\n\n const _fetch = (...props: any[]) => {\n if (props[0] && typeof props[0] === \"string\" && props[0].startsWith(\"/\")) {\n if (process.env.NODE_ENV !== \"production\") {\n warnProductionOriginNotConfigured(props[0]);\n }\n\n props[0] = new URL(props[0], window.location?.origin).toString();\n } else if (props[0] && typeof props[0] === \"object\") {\n if (\n props[0].url &&\n typeof props[0].url === \"string\" &&\n props[0].url.startsWith(\"/\")\n ) {\n if (process.env.NODE_ENV !== \"production\") {\n warnProductionOriginNotConfigured(props[0]);\n }\n\n props[0].url = new URL(\n props[0].url,\n window.location?.origin\n ).toString();\n }\n }\n return fetch(...props);\n };\n\n _fetch.__EXPO_BASE_URL_POLYFILLED = true;\n\n return _fetch;\n}\n\nif (manifest?.extra?.router?.origin !== false) {\n // Polyfill window.location in native runtimes.\n if (typeof window !== \"undefined\" && !window.location) {\n const url = getBaseUrl();\n if (url) {\n setLocationHref(url);\n install();\n }\n }\n // Polyfill native fetch to support relative URLs\n Object.defineProperty(global, \"fetch\", {\n value: wrapFetchWithWindowLocation(fetch),\n });\n}\n"]}
|
package/package.json
CHANGED