@expo/metro-runtime 0.0.1 → 1.0.1

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.
Files changed (116) hide show
  1. package/build/HMRClient.d.ts +2 -2
  2. package/build/HMRClient.d.ts.map +1 -1
  3. package/build/HMRClient.js +27 -4
  4. package/build/HMRClient.js.map +1 -1
  5. package/build/HMRClient.native.js +1 -0
  6. package/build/HMRClient.native.js.map +1 -1
  7. package/build/LoadingView.native.js +1 -0
  8. package/build/LoadingView.native.js.map +1 -1
  9. package/build/async-require/buildAsyncRequire.d.ts +6 -7
  10. package/build/async-require/buildAsyncRequire.d.ts.map +1 -1
  11. package/build/async-require/buildAsyncRequire.js +22 -20
  12. package/build/async-require/buildAsyncRequire.js.map +1 -1
  13. package/build/async-require/buildUrlForBundle.d.ts.map +1 -1
  14. package/build/async-require/buildUrlForBundle.js +6 -0
  15. package/build/async-require/buildUrlForBundle.js.map +1 -1
  16. package/build/async-require/buildUrlForBundle.native.d.ts.map +1 -1
  17. package/build/async-require/buildUrlForBundle.native.js +6 -0
  18. package/build/async-require/buildUrlForBundle.native.js.map +1 -1
  19. package/build/async-require/fetchAsync.d.ts.map +1 -1
  20. package/build/async-require/fetchAsync.js +6 -0
  21. package/build/async-require/fetchAsync.js.map +1 -1
  22. package/build/async-require/fetchAsync.native.d.ts.map +1 -1
  23. package/build/async-require/fetchAsync.native.js +4 -3
  24. package/build/async-require/fetchAsync.native.js.map +1 -1
  25. package/build/async-require/fetchThenEval.d.ts.map +1 -1
  26. package/build/async-require/fetchThenEval.js +8 -2
  27. package/build/async-require/fetchThenEval.js.map +1 -1
  28. package/build/async-require/fetchThenEval.web.d.ts +6 -0
  29. package/build/async-require/fetchThenEval.web.d.ts.map +1 -1
  30. package/build/async-require/fetchThenEval.web.js +6 -1
  31. package/build/async-require/fetchThenEval.web.js.map +1 -1
  32. package/build/async-require/index.js +6 -0
  33. package/build/async-require/index.js.map +1 -1
  34. package/build/async-require/loadBundle.android.d.ts.map +1 -1
  35. package/build/async-require/loadBundle.android.js +7 -0
  36. package/build/async-require/loadBundle.android.js.map +1 -1
  37. package/build/async-require/loadBundle.d.ts +6 -0
  38. package/build/async-require/loadBundle.d.ts.map +1 -1
  39. package/build/async-require/loadBundle.js +6 -0
  40. package/build/async-require/loadBundle.js.map +1 -1
  41. package/build/async-require/loadBundlePolyfill.d.ts.map +1 -1
  42. package/build/async-require/loadBundlePolyfill.js +8 -2
  43. package/build/async-require/loadBundlePolyfill.js.map +1 -1
  44. package/build/effects.native.js +1 -0
  45. package/build/error-overlay/Data/LogBoxData.d.ts +8 -8
  46. package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -1
  47. package/build/error-overlay/Data/LogBoxData.js +2 -2
  48. package/build/error-overlay/Data/LogBoxData.js.map +1 -1
  49. package/build/error-overlay/Data/LogBoxLog.d.ts +4 -4
  50. package/build/error-overlay/Data/LogBoxLog.d.ts.map +1 -1
  51. package/build/error-overlay/Data/LogBoxSymbolication.d.ts +3 -3
  52. package/build/error-overlay/Data/LogBoxSymbolication.d.ts.map +1 -1
  53. package/build/error-overlay/Data/parseLogBoxLog.d.ts +6 -6
  54. package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -1
  55. package/build/error-overlay/Data/parseLogBoxLog.js +1 -0
  56. package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -1
  57. package/build/error-overlay/LogBox.web.js +4 -4
  58. package/build/error-overlay/LogBox.web.js.map +1 -1
  59. package/build/error-overlay/UI/AnsiHighlight.js.map +1 -1
  60. package/build/error-overlay/UI/LogBoxButton.d.ts +1 -1
  61. package/build/error-overlay/UI/LogBoxButton.d.ts.map +1 -1
  62. package/build/error-overlay/UI/LogBoxMessage.d.ts +1 -1
  63. package/build/error-overlay/UI/LogBoxMessage.d.ts.map +1 -1
  64. package/build/error-overlay/modules/ExceptionsManager/index.d.ts +1 -1
  65. package/build/error-overlay/modules/ExceptionsManager/index.d.ts.map +1 -1
  66. package/build/error-overlay/modules/ExceptionsManager/index.native.js +1 -0
  67. package/build/error-overlay/modules/ExceptionsManager/index.native.js.map +1 -1
  68. package/build/error-overlay/modules/NativeLogBox/index.native.d.ts.map +1 -1
  69. package/build/error-overlay/modules/NativeLogBox/index.native.js +1 -0
  70. package/build/error-overlay/modules/NativeLogBox/index.native.js.map +1 -1
  71. package/build/error-overlay/modules/openFileInEditor/index.native.d.ts.map +1 -1
  72. package/build/error-overlay/modules/openFileInEditor/index.native.js +1 -0
  73. package/build/error-overlay/modules/openFileInEditor/index.native.js.map +1 -1
  74. package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts +2 -2
  75. package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts.map +1 -1
  76. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -1
  77. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +1 -1
  78. package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -1
  79. package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts +1 -1
  80. package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts.map +1 -1
  81. package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts +1 -1
  82. package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts.map +1 -1
  83. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts +1 -1
  84. package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts.map +1 -1
  85. package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts +10 -2
  86. package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts.map +1 -1
  87. package/build/error-overlay/overlay/LogBoxInspectorSection.js.map +1 -1
  88. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts +1 -1
  89. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts.map +1 -1
  90. package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js.map +1 -1
  91. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts +1 -1
  92. package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts.map +1 -1
  93. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts +1 -1
  94. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -1
  95. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +3 -3
  96. package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js.map +1 -1
  97. package/build/error-overlay/toast/ErrorToast.d.ts +1 -1
  98. package/build/error-overlay/toast/ErrorToast.d.ts.map +1 -1
  99. package/build/error-overlay/toast/ErrorToast.js +1 -1
  100. package/build/error-overlay/toast/ErrorToast.js.map +1 -1
  101. package/build/error-overlay/toast/ErrorToastContainer.d.ts +4 -3
  102. package/build/error-overlay/toast/ErrorToastContainer.d.ts.map +1 -1
  103. package/build/error-overlay/toast/ErrorToastContainer.js +6 -2
  104. package/build/error-overlay/toast/ErrorToastContainer.js.map +1 -1
  105. package/build/error-overlay/toast/ErrorToastContainer.web.js +1 -1
  106. package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -1
  107. package/build/error-overlay/useRejectionHandler.js.map +1 -1
  108. package/build/getDevServer.native.js +1 -0
  109. package/build/getDevServer.native.js.map +1 -1
  110. package/build/messageSocket.js +1 -0
  111. package/build/messageSocket.js.map +1 -1
  112. package/build/setupFastRefresh.js +2 -0
  113. package/build/setupFastRefresh.js.map +1 -1
  114. package/build/setupHMR.js +23 -1
  115. package/build/setupHMR.js.map +1 -1
  116. package/package.json +4 -1
@@ -1,5 +1,5 @@
1
- declare type LogLevel = "trace" | "info" | "warn" | "error" | "log" | "group" | "groupCollapsed" | "groupEnd" | "debug";
2
- export declare type HMRClientNativeInterface = {
1
+ type LogLevel = "trace" | "info" | "warn" | "error" | "log" | "group" | "groupCollapsed" | "groupEnd" | "debug";
2
+ export type HMRClientNativeInterface = {
3
3
  enable(): void;
4
4
  disable(): void;
5
5
  registerBundle(requestUrl: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"HMRClient.d.ts","sourceRoot":"","sources":["../src/HMRClient.ts"],"names":[],"mappings":"AA+BA,aAAK,QAAQ,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,gBAAgB,GAChB,UAAU,GACV,OAAO,CAAC;AAEZ,oBAAY,wBAAwB,GAAG;IACrC,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;IAChB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACxC,KAAK,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAC5C,CAAC;AAMF;;;GAGG;AACH,QAAA,MAAM,SAAS,EAAE,wBA8LhB,CAAC;AAuEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"HMRClient.d.ts","sourceRoot":"","sources":["../src/HMRClient.ts"],"names":[],"mappings":"AAiCA,KAAK,QAAQ,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,OAAO,GACP,KAAK,GACL,OAAO,GACP,gBAAgB,GAChB,UAAU,GACV,OAAO,CAAC;AAEZ,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,IAAI,IAAI,CAAC;IACf,OAAO,IAAI,IAAI,CAAC;IAChB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IACxC,KAAK,CAAC,KAAK,EAAE;QAAE,SAAS,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAC5C,CAAC;AAMF;;;GAGG;AACH,QAAA,MAAM,SAAS,EAAE,wBAoMhB,CAAC;AAuEF,eAAe,SAAS,CAAC"}
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
@@ -13,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
36
  * Based on this but with web support:
14
37
  * https://github.com/facebook/react-native/blob/086714b02b0fb838dee5a66c5bcefe73b53cf3df/Libraries/Utilities/HMRClient.js
15
38
  */
16
- const pretty_format_1 = __importDefault(require("pretty-format"));
39
+ const pretty_format_1 = __importStar(require("pretty-format"));
17
40
  const LoadingView_1 = __importDefault(require("./LoadingView"));
18
41
  const LogBox_1 = __importDefault(require("./error-overlay/LogBox"));
19
42
  const getDevServer_1 = __importDefault(require("./getDevServer"));
@@ -86,7 +109,7 @@ const HMRClient = {
86
109
  hmrClient.send(JSON.stringify({
87
110
  type: "log",
88
111
  level,
89
- mode: global.RN$Bridgeless === true ? "NOBRIDGE" : "BRIDGE",
112
+ mode: "BRIDGE",
90
113
  data: data.map((item) => typeof item === "string"
91
114
  ? item
92
115
  : (0, pretty_format_1.default)(item, {
@@ -94,7 +117,7 @@ const HMRClient = {
94
117
  highlight: true,
95
118
  maxDepth: 3,
96
119
  min: true,
97
- plugins: [pretty_format_1.default.plugins.ReactElement],
120
+ plugins: [pretty_format_1.plugins.ReactElement],
98
121
  })),
99
122
  }));
100
123
  }
@@ -210,7 +233,7 @@ function registerBundleEntryPoints(client) {
210
233
  return;
211
234
  }
212
235
  if (pendingEntryPoints.length > 0) {
213
- client.send(JSON.stringify({
236
+ client === null || client === void 0 ? void 0 : client.send(JSON.stringify({
214
237
  type: "register-entrypoints",
215
238
  entryPoints: pendingEntryPoints,
216
239
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"HMRClient.js","sourceRoot":"","sources":["../src/HMRClient.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;GASG;AACH,kEAAyC;AAEzC,gEAAwC;AACxC,oEAA4C;AAC5C,kEAA0C;AAE1C,MAAM,cAAc,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACtE,MAAM,kBAAkB,GAAa,EAAE,CAAC;AAExC,IAAI,SAAS,GAMF,IAAI,CAAC;AAChB,IAAI,oBAAoB,GAAkB,IAAI,CAAC;AAC/C,IAAI,0BAA0B,GAAkB,IAAI,CAAC;AACrD,IAAI,UAAU,GAAY,KAAK,CAAC;AAChC,MAAM,WAAW,GAAwB,EAAE,CAAC;AAqB5C,SAAS,MAAM,CAAC,GAAQ,EAAE,GAAW;IACnC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,SAAS,GAA6B;IAC1C,MAAM;QACJ,IAAI,oBAAoB,KAAK,IAAI,EAAE;YACjC,wDAAwD;YACxD,0CAA0C;YAC1C,2DAA2D;YAC3D,uCAAuC;YACvC,MAAM,IAAI,KAAK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QAChC,0CAA0C;QAC1C,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACzB,OAAO;KACR;IAED,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;QACjC,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,sBAAsB;YAC5B,WAAW,EAAE,kBAAkB;SAChC,CAAC,CACH,CAAC;QACF,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC;KAC/B;AACH,CAAC;AAED,SAAS,cAAc;IACrB,IAAI;QACF,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;YACpC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;KACJ;YAAS;QACR,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;KACxB;AACH,CAAC;AAED,SAAS,aAAa;IACpB,0CAA0C;AAC5C,CAAC;AAED,SAAS,gBAAgB;IACvB,IAAI,0BAA0B,KAAK,IAAI,EAAE;QACvC,OAAO;KACR;IAED,uEAAuE;IACvE,uFAAuF;IACvF,aAAa,EAAE,CAAC;IAEhB,MAAM,OAAO,GAAG,0BAA0B,CAAC;IAC3C,0BAA0B,GAAG,IAAI,CAAC;IAElC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,gDAAgD;IAChD,0CAA0C;IAC1C,mBAAmB;IACnB,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAClC,MAAM,KAAK,CAAC;AACd,CAAC;AAED,kBAAe,SAAS,CAAC","sourcesContent":["/**\n * Copyright (c) Evan Bacon.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on this but with web support:\n * https://github.com/facebook/react-native/blob/086714b02b0fb838dee5a66c5bcefe73b53cf3df/Libraries/Utilities/HMRClient.js\n */\nimport prettyFormat from \"pretty-format\";\n\nimport LoadingView from \"./LoadingView\";\nimport LogBox from \"./error-overlay/LogBox\";\nimport getDevServer from \"./getDevServer\";\n\nconst MetroHMRClient = require(\"metro-runtime/src/modules/HMRClient\");\nconst pendingEntryPoints: string[] = [];\n\nlet hmrClient: {\n send: (msg: string) => void;\n isEnabled: () => boolean;\n disable: () => void;\n enable: () => void;\n hasPendingUpdates: () => boolean;\n} | null = null;\nlet hmrUnavailableReason: string | null = null;\nlet currentCompileErrorMessage: string | null = null;\nlet didConnect: boolean = false;\nconst pendingLogs: [LogLevel, any[]][] = [];\n\ntype LogLevel =\n | \"trace\"\n | \"info\"\n | \"warn\"\n | \"error\"\n | \"log\"\n | \"group\"\n | \"groupCollapsed\"\n | \"groupEnd\"\n | \"debug\";\n\nexport type HMRClientNativeInterface = {\n enable(): void;\n disable(): void;\n registerBundle(requestUrl: string): void;\n log(level: LogLevel, data: any[]): void;\n setup(props: { isEnabled: boolean }): void;\n};\n\nfunction assert(foo: any, msg: string): asserts foo {\n if (!foo) throw new Error(msg);\n}\n\n/**\n * HMR Client that receives from the server HMR updates and propagates them\n * runtime to reflects those changes.\n */\nconst HMRClient: HMRClientNativeInterface = {\n enable() {\n if (hmrUnavailableReason !== null) {\n // If HMR became unavailable while you weren't using it,\n // explain why when you try to turn it on.\n // This is an error (and not a warning) because it is shown\n // in response to a direct user action.\n throw new Error(hmrUnavailableReason);\n }\n\n assert(hmrClient, \"Expected HMRClient.setup() call at startup.\");\n\n // We use this for internal logging only.\n // It doesn't affect the logic.\n hmrClient.send(JSON.stringify({ type: \"log-opt-in\" }));\n\n // When toggling Fast Refresh on, we might already have some stashed updates.\n // Since they'll get applied now, we'll show a banner.\n const hasUpdates = hmrClient!.hasPendingUpdates();\n\n if (hasUpdates) {\n LoadingView.showMessage(\"Refreshing...\", \"refresh\");\n }\n try {\n hmrClient.enable();\n } finally {\n if (hasUpdates) {\n LoadingView.hide();\n }\n }\n\n // There could be a compile error while Fast Refresh was off,\n // but we ignored it at the time. Show it now.\n showCompileError();\n },\n\n disable() {\n assert(hmrClient, \"Expected HMRClient.setup() call at startup.\");\n hmrClient.disable();\n },\n\n registerBundle(requestUrl: string) {\n assert(hmrClient, \"Expected HMRClient.setup() call at startup.\");\n pendingEntryPoints.push(requestUrl);\n registerBundleEntryPoints(hmrClient);\n },\n\n log(level: LogLevel, data: any[]) {\n if (!hmrClient) {\n // Catch a reasonable number of early logs\n // in case hmrClient gets initialized later.\n pendingLogs.push([level, data]);\n if (pendingLogs.length > 100) {\n pendingLogs.shift();\n }\n return;\n }\n try {\n hmrClient.send(\n JSON.stringify({\n type: \"log\",\n level,\n mode: global.RN$Bridgeless === true ? \"NOBRIDGE\" : \"BRIDGE\",\n data: data.map((item) =>\n typeof item === \"string\"\n ? item\n : prettyFormat(item, {\n escapeString: true,\n highlight: true,\n maxDepth: 3,\n min: true,\n plugins: [prettyFormat.plugins.ReactElement],\n })\n ),\n })\n );\n } catch {\n // If sending logs causes any failures we want to silently ignore them\n // to ensure we do not cause infinite-logging loops.\n }\n },\n\n // Called once by the bridge on startup, even if Fast Refresh is off.\n // It creates the HMR client but doesn't actually set up the socket yet.\n setup({ isEnabled }: { isEnabled: boolean }) {\n assert(!hmrClient, \"Cannot initialize hmrClient twice\");\n\n const serverScheme = window.location.protocol === \"https:\" ? \"wss\" : \"ws\";\n const client = new MetroHMRClient(\n `${serverScheme}://${window.location.host}/hot`\n );\n hmrClient = client;\n\n const { fullBundleUrl } = getDevServer();\n pendingEntryPoints.push(\n // HMRServer understands regular bundle URLs, so prefer that in case\n // there are any important URL parameters we can't reconstruct from\n // `setup()`'s arguments.\n fullBundleUrl\n );\n\n client.on(\"connection-error\", (e) => {\n let error = `Cannot connect to Metro.\n \n Try the following to fix the issue:\n - Ensure the Metro dev server is running and available on the same network as this device`;\n error += `\n \n URL: ${window.location.host}\n \n Error: ${e.message}`;\n\n setHMRUnavailableReason(error);\n });\n\n client.on(\"update-start\", ({ isInitialUpdate }) => {\n currentCompileErrorMessage = null;\n didConnect = true;\n\n if (client.isEnabled() && !isInitialUpdate) {\n LoadingView.showMessage(\"Refreshing...\", \"refresh\");\n }\n });\n\n client.on(\"update\", ({ isInitialUpdate }) => {\n if (client.isEnabled() && !isInitialUpdate) {\n dismissRedbox();\n LogBox.clearAllLogs();\n }\n });\n\n client.on(\"update-done\", () => {\n LoadingView.hide();\n });\n\n client.on(\"error\", (data) => {\n LoadingView.hide();\n\n if (data.type === \"GraphNotFoundError\") {\n client.close();\n setHMRUnavailableReason(\n \"Metro has restarted since the last edit. Reload to reconnect.\"\n );\n } else if (data.type === \"RevisionNotFoundError\") {\n client.close();\n setHMRUnavailableReason(\n \"Metro and the client are out of sync. Reload to reconnect.\"\n );\n } else {\n currentCompileErrorMessage = `${data.type} ${data.message}`;\n if (client.isEnabled()) {\n showCompileError();\n }\n }\n });\n\n client.on(\"close\", (closeEvent) => {\n LoadingView.hide();\n\n // https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1\n // https://www.rfc-editor.org/rfc/rfc6455.html#section-7.1.5\n const isNormalOrUnsetCloseReason =\n closeEvent == null ||\n closeEvent.code === 1000 ||\n closeEvent.code === 1005 ||\n closeEvent.code == null;\n\n setHMRUnavailableReason(\n `${\n isNormalOrUnsetCloseReason\n ? \"Disconnected from Metro.\"\n : `Disconnected from Metro (${closeEvent.code}: \"${closeEvent.reason}\").`\n }\n\nTo reconnect:\n- Ensure that Metro is running and available on the same network\n- Reload this app (will trigger further help if Metro cannot be connected to)\n `\n );\n });\n\n if (isEnabled) {\n HMRClient.enable();\n } else {\n HMRClient.disable();\n }\n\n registerBundleEntryPoints(hmrClient);\n flushEarlyLogs();\n },\n};\n\nfunction setHMRUnavailableReason(reason) {\n assert(hmrClient, \"Expected HMRClient.setup() call at startup.\");\n if (hmrUnavailableReason !== null) {\n // Don't show more than one warning.\n return;\n }\n hmrUnavailableReason = reason;\n\n // We only want to show a warning if Fast Refresh is on *and* if we ever\n // previously managed to connect successfully. We don't want to show\n // the warning to native engineers who use cached bundles without Metro.\n if (hmrClient.isEnabled() && didConnect) {\n console.warn(reason);\n // (Not using the `warning` module to prevent a Buck cycle.)\n }\n}\n\nfunction registerBundleEntryPoints(client) {\n if (hmrUnavailableReason != null) {\n // \"Bundle Splitting – Metro disconnected\"\n window.location.reload();\n return;\n }\n\n if (pendingEntryPoints.length > 0) {\n client.send(\n JSON.stringify({\n type: \"register-entrypoints\",\n entryPoints: pendingEntryPoints,\n })\n );\n pendingEntryPoints.length = 0;\n }\n}\n\nfunction flushEarlyLogs() {\n try {\n pendingLogs.forEach(([level, data]) => {\n HMRClient.log(level, data);\n });\n } finally {\n pendingLogs.length = 0;\n }\n}\n\nfunction dismissRedbox() {\n // TODO(EvanBacon): Error overlay for web.\n}\n\nfunction showCompileError() {\n if (currentCompileErrorMessage === null) {\n return;\n }\n\n // Even if there is already a redbox, syntax errors are more important.\n // Otherwise you risk seeing a stale runtime error while a syntax error is more recent.\n dismissRedbox();\n\n const message = currentCompileErrorMessage;\n currentCompileErrorMessage = null;\n\n const error = new Error(message);\n // Symbolicating compile errors is wasted effort\n // because the stack trace is meaningless:\n // @ts-expect-error\n error.preventSymbolication = true;\n throw error;\n}\n\nexport default HMRClient;\n"]}
1
+ {"version":3,"file":"HMRClient.js","sourceRoot":"","sources":["../src/HMRClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACH,+DAAsD;AAEtD,gEAAwC;AACxC,oEAA4C;AAC5C,kEAA0C;AAE1C,MAAM,cAAc,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACtE,MAAM,kBAAkB,GAAa,EAAE,CAAC;AAUxC,IAAI,SAAS,GAAyB,IAAI,CAAC;AAC3C,IAAI,oBAAoB,GAAkB,IAAI,CAAC;AAC/C,IAAI,0BAA0B,GAAkB,IAAI,CAAC;AACrD,IAAI,UAAU,GAAY,KAAK,CAAC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AoB,GAAG,IAAI,CAAC;IAClC,MAAM,KAAK,CAAC;AACd,CAAC;AAED,kBAAe,SAAS,CAAC","sourcesContent":["/**\n * Copyright (c) Evan Bacon.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Based on this but with web support:\n * https://github.com/facebook/react-native/blob/086714b02b0fb838dee5a66c5bcefe73b53cf3df/Libraries/Utilities/HMRClient.js\n */\nimport prettyFormat, { plugins } from \"pretty-format\";\n\nimport LoadingView from \"./LoadingView\";\nimport LogBox from \"./error-overlay/LogBox\";\nimport getDevServer from \"./getDevServer\";\n\nconst MetroHMRClient = require(\"metro-runtime/src/modules/HMRClient\");\nconst pendingEntryPoints: string[] = [];\n\ntype HMRClientType = {\n send: (msg: string) => void;\n isEnabled: () => boolean;\n disable: () => void;\n enable: () => void;\n hasPendingUpdates: () => boolean;\n};\n\nlet hmrClient: HMRClientType | null = null;\nlet hmrUnavailableReason: string | null = null;\nlet currentCompileErrorMessage: string | null = null;\nlet didConnect: boolean = false;\nconst pendingLogs: [LogLevel, any[]][] = [];\n\ntype LogLevel =\n | \"trace\"\n | \"info\"\n | \"warn\"\n | \"error\"\n | \"log\"\n | \"group\"\n | \"groupCollapsed\"\n | \"groupEnd\"\n | \"debug\";\n\nexport type HMRClientNativeInterface = {\n enable(): void;\n disable(): void;\n registerBundle(requestUrl: string): void;\n log(level: LogLevel, data: any[]): void;\n setup(props: { isEnabled: boolean }): void;\n};\n\nfunction assert(foo: any, msg: string): asserts foo {\n if (!foo) throw new Error(msg);\n}\n\n/**\n * HMR Client that receives from the server HMR updates and propagates them\n * runtime to reflects those changes.\n */\nconst HMRClient: HMRClientNativeInterface = {\n enable() {\n if (hmrUnavailableReason !== null) {\n // If HMR became unavailable while you weren't using it,\n // explain why when you try to turn it on.\n // This is an error (and not a warning) because it is shown\n // in response to a direct user action.\n throw new Error(hmrUnavailableReason);\n }\n\n assert(hmrClient, \"Expected HMRClient.setup() call at startup.\");\n\n // We use this for internal logging only.\n // It doesn't affect the logic.\n hmrClient.send(JSON.stringify({ type: \"log-opt-in\" }));\n\n // When toggling Fast Refresh on, we might already have some stashed updates.\n // Since they'll get applied now, we'll show a banner.\n const hasUpdates = hmrClient!.hasPendingUpdates();\n\n if (hasUpdates) {\n LoadingView.showMessage(\"Refreshing...\", \"refresh\");\n }\n try {\n hmrClient.enable();\n } finally {\n if (hasUpdates) {\n LoadingView.hide();\n }\n }\n\n // There could be a compile error while Fast Refresh was off,\n // but we ignored it at the time. Show it now.\n showCompileError();\n },\n\n disable() {\n assert(hmrClient, \"Expected HMRClient.setup() call at startup.\");\n hmrClient.disable();\n },\n\n registerBundle(requestUrl: string) {\n assert(hmrClient, \"Expected HMRClient.setup() call at startup.\");\n pendingEntryPoints.push(requestUrl);\n registerBundleEntryPoints(hmrClient);\n },\n\n log(level: LogLevel, data: any[]) {\n if (!hmrClient) {\n // Catch a reasonable number of early logs\n // in case hmrClient gets initialized later.\n pendingLogs.push([level, data]);\n if (pendingLogs.length > 100) {\n pendingLogs.shift();\n }\n return;\n }\n try {\n hmrClient.send(\n JSON.stringify({\n type: \"log\",\n level,\n mode: \"BRIDGE\",\n data: data.map((item) =>\n typeof item === \"string\"\n ? item\n : prettyFormat(item, {\n escapeString: true,\n highlight: true,\n maxDepth: 3,\n min: true,\n plugins: [plugins.ReactElement],\n })\n ),\n })\n );\n } catch {\n // If sending logs causes any failures we want to silently ignore them\n // to ensure we do not cause infinite-logging loops.\n }\n },\n\n // Called once by the bridge on startup, even if Fast Refresh is off.\n // It creates the HMR client but doesn't actually set up the socket yet.\n setup({ isEnabled }: { isEnabled: boolean }) {\n assert(!hmrClient, \"Cannot initialize hmrClient twice\");\n\n const serverScheme = window.location.protocol === \"https:\" ? \"wss\" : \"ws\";\n const client = new MetroHMRClient(\n `${serverScheme}://${window.location.host}/hot`\n );\n hmrClient = client;\n\n const { fullBundleUrl } = getDevServer();\n pendingEntryPoints.push(\n // HMRServer understands regular bundle URLs, so prefer that in case\n // there are any important URL parameters we can't reconstruct from\n // `setup()`'s arguments.\n fullBundleUrl\n );\n\n client.on(\"connection-error\", (e: Error) => {\n let error = `Cannot connect to Metro.\n \n Try the following to fix the issue:\n - Ensure the Metro dev server is running and available on the same network as this device`;\n error += `\n \n URL: ${window.location.host}\n \n Error: ${e.message}`;\n\n setHMRUnavailableReason(error);\n });\n\n client.on(\n \"update-start\",\n ({ isInitialUpdate }: { isInitialUpdate?: boolean }) => {\n currentCompileErrorMessage = null;\n didConnect = true;\n\n if (client.isEnabled() && !isInitialUpdate) {\n LoadingView.showMessage(\"Refreshing...\", \"refresh\");\n }\n }\n );\n\n client.on(\n \"update\",\n ({ isInitialUpdate }: { isInitialUpdate?: boolean }) => {\n if (client.isEnabled() && !isInitialUpdate) {\n dismissRedbox();\n LogBox.clearAllLogs();\n }\n }\n );\n\n client.on(\"update-done\", () => {\n LoadingView.hide();\n });\n\n client.on(\"error\", (data: { type: string; message: string }) => {\n LoadingView.hide();\n\n if (data.type === \"GraphNotFoundError\") {\n client.close();\n setHMRUnavailableReason(\n \"Metro has restarted since the last edit. Reload to reconnect.\"\n );\n } else if (data.type === \"RevisionNotFoundError\") {\n client.close();\n setHMRUnavailableReason(\n \"Metro and the client are out of sync. Reload to reconnect.\"\n );\n } else {\n currentCompileErrorMessage = `${data.type} ${data.message}`;\n if (client.isEnabled()) {\n showCompileError();\n }\n }\n });\n\n client.on(\"close\", (closeEvent: { code: number; reason: string }) => {\n LoadingView.hide();\n\n // https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1\n // https://www.rfc-editor.org/rfc/rfc6455.html#section-7.1.5\n const isNormalOrUnsetCloseReason =\n closeEvent == null ||\n closeEvent.code === 1000 ||\n closeEvent.code === 1005 ||\n closeEvent.code == null;\n\n setHMRUnavailableReason(\n `${\n isNormalOrUnsetCloseReason\n ? \"Disconnected from Metro.\"\n : `Disconnected from Metro (${closeEvent.code}: \"${closeEvent.reason}\").`\n }\n\nTo reconnect:\n- Ensure that Metro is running and available on the same network\n- Reload this app (will trigger further help if Metro cannot be connected to)\n `\n );\n });\n\n if (isEnabled) {\n HMRClient.enable();\n } else {\n HMRClient.disable();\n }\n\n registerBundleEntryPoints(hmrClient);\n flushEarlyLogs();\n },\n};\n\nfunction setHMRUnavailableReason(reason: string) {\n assert(hmrClient, \"Expected HMRClient.setup() call at startup.\");\n if (hmrUnavailableReason !== null) {\n // Don't show more than one warning.\n return;\n }\n hmrUnavailableReason = reason;\n\n // We only want to show a warning if Fast Refresh is on *and* if we ever\n // previously managed to connect successfully. We don't want to show\n // the warning to native engineers who use cached bundles without Metro.\n if (hmrClient.isEnabled() && didConnect) {\n console.warn(reason);\n // (Not using the `warning` module to prevent a Buck cycle.)\n }\n}\n\nfunction registerBundleEntryPoints(client: HMRClientType | null) {\n if (hmrUnavailableReason != null) {\n // \"Bundle Splitting – Metro disconnected\"\n window.location.reload();\n return;\n }\n\n if (pendingEntryPoints.length > 0) {\n client?.send(\n JSON.stringify({\n type: \"register-entrypoints\",\n entryPoints: pendingEntryPoints,\n })\n );\n pendingEntryPoints.length = 0;\n }\n}\n\nfunction flushEarlyLogs() {\n try {\n pendingLogs.forEach(([level, data]) => {\n HMRClient.log(level, data);\n });\n } finally {\n pendingLogs.length = 0;\n }\n}\n\nfunction dismissRedbox() {\n // TODO(EvanBacon): Error overlay for web.\n}\n\nfunction showCompileError() {\n if (currentCompileErrorMessage === null) {\n return;\n }\n\n // Even if there is already a redbox, syntax errors are more important.\n // Otherwise you risk seeing a stale runtime error while a syntax error is more recent.\n dismissRedbox();\n\n const message = currentCompileErrorMessage;\n currentCompileErrorMessage = null;\n\n const error = new Error(message);\n // Symbolicating compile errors is wasted effort\n // because the stack trace is meaningless:\n // @ts-expect-error\n error.preventSymbolication = true;\n throw error;\n}\n\nexport default HMRClient;\n"]}
@@ -1,2 +1,3 @@
1
+ "use strict";
1
2
  module.exports = require("react-native/Libraries/Utilities/HMRClient");
2
3
  //# sourceMappingURL=HMRClient.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HMRClient.native.js","sourceRoot":"","sources":["../src/HMRClient.native.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC","sourcesContent":["module.exports = require(\"react-native/Libraries/Utilities/HMRClient\");\n"]}
1
+ {"version":3,"file":"HMRClient.native.js","sourceRoot":"","sources":["../src/HMRClient.native.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC","sourcesContent":["module.exports = require(\"react-native/Libraries/Utilities/HMRClient\");\n"]}
@@ -1,2 +1,3 @@
1
+ "use strict";
1
2
  module.exports = require("react-native/Libraries/Utilities/LoadingView");
2
3
  //# sourceMappingURL=LoadingView.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LoadingView.native.js","sourceRoot":"","sources":["../src/LoadingView.native.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,8CAA8C,CAAC,CAAC","sourcesContent":["module.exports = require(\"react-native/Libraries/Utilities/LoadingView\");\n"]}
1
+ {"version":3,"file":"LoadingView.native.js","sourceRoot":"","sources":["../src/LoadingView.native.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC,8CAA8C,CAAC,CAAC","sourcesContent":["module.exports = require(\"react-native/Libraries/Utilities/LoadingView\");\n"]}
@@ -1,4 +1,5 @@
1
- declare type MetroRequire = {
1
+ type ImportBundleNames = Record<string, string>;
2
+ type MetroRequire = {
2
3
  (id: number): any;
3
4
  importAll: (id: number) => any;
4
5
  };
@@ -8,15 +9,13 @@ declare type MetroRequire = {
8
9
  *
9
10
  * And https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/getAppendScripts.js#L54-L56
10
11
  */
11
- declare type AsyncRequire = {
12
- <TModule>(moduleID: number, moduleName?: string, options?: {
12
+ type AsyncRequire = {
13
+ <TModule>(moduleID: number, moduleName: string, paths: ImportBundleNames, options?: {
13
14
  isPrefetchOnly: boolean;
14
15
  }): Promise<TModule | void> | TModule;
15
- prefetch(moduleID: number, moduleName: string): void;
16
+ prefetch(moduleID: number, moduleName: string, paths: ImportBundleNames): void;
16
17
  /** NOTE(EvanBacon): Unclear what this should return `__jsResource` ?? */
17
- resource(moduleID: number, moduleName: string): never;
18
- /** Register the 'moduleID<>bundle path' that can be loaded via `asyncRequire(moduleID)` */
19
- addImportBundleNames(names: Record<string, string>): void;
18
+ resource(moduleID: number, moduleName: string, paths: ImportBundleNames): never;
20
19
  };
21
20
  /** Create an `asyncRequire` function in the expected shape for Metro bundler. */
22
21
  export declare function buildAsyncRequire(metroRequire: MetroRequire): AsyncRequire;
@@ -1 +1 @@
1
- {"version":3,"file":"buildAsyncRequire.d.ts","sourceRoot":"","sources":["../../src/async-require/buildAsyncRequire.ts"],"names":[],"mappings":"AAMA,aAAK,YAAY,GAAG;IAClB,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC;CAChC,CAAC;AAMF;;;;;GAKG;AACH,aAAK,YAAY,GAAG;IAClB,CAAC,OAAO,EACN,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QAAE,cAAc,EAAE,OAAO,CAAA;KAAE,GACpC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC;IAEtD,2FAA2F;IAC3F,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC3D,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,CAoE1E"}
1
+ {"version":3,"file":"buildAsyncRequire.d.ts","sourceRoot":"","sources":["../../src/async-require/buildAsyncRequire.ts"],"names":[],"mappings":"AAQA,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEhD,KAAK,YAAY,GAAG;IAClB,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC;IAClB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,GAAG,CAAC;CAChC,CAAC;AAMF;;;;;GAKG;AACH,KAAK,YAAY,GAAG;IAClB,CAAC,OAAO,EACN,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,iBAAiB,EACxB,OAAO,CAAC,EAAE;QAAE,cAAc,EAAE,OAAO,CAAA;KAAE,GACpC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC;IACrC,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,iBAAiB,GACvB,IAAI,CAAC;IACR,yEAAyE;IACzE,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,iBAAiB,GACvB,KAAK,CAAC;CACV,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,CAiE1E"}
@@ -1,22 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildAsyncRequire = void 0;
4
+ /**
5
+ * Copyright © 2022 650 Industries.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
4
10
  const loadBundle_1 = require("./loadBundle");
5
11
  /** Create an `asyncRequire` function in the expected shape for Metro bundler. */
6
12
  function buildAsyncRequire(metroRequire) {
7
- const importBundleNames = Object.create(null);
8
13
  const importBundlePromises = Object.create(null);
9
- // This is basically `__webpack_require__.u` -> returns the bundle path for a numeric moduleID
10
- function getBundlePath(moduleID) {
11
- return importBundleNames[moduleID];
12
- }
13
- function asyncRequire(moduleID, moduleName = "", options = { isPrefetchOnly: false }) {
14
- console.log("async require:", moduleID, moduleName, options);
14
+ function asyncRequire(moduleID, moduleName, paths, options = { isPrefetchOnly: false }) {
15
+ if (process.env.NODE_ENV === "production") {
16
+ // TODO: Don't disable in production
17
+ return Promise.resolve().then(() => metroRequire.importAll(moduleID));
18
+ }
15
19
  if (options.isPrefetchOnly) {
16
20
  return Promise.resolve();
17
21
  }
18
22
  const stringModuleID = String(moduleID);
19
- const bundlePath = getBundlePath(stringModuleID);
23
+ // This is basically `__webpack_require__.u` -> returns the bundle path for a numeric moduleID
24
+ const bundlePath = paths[stringModuleID];
20
25
  if (bundlePath) {
21
26
  // Prevent loading the same module more than once.
22
27
  if (!importBundlePromises[stringModuleID]) {
@@ -27,24 +32,21 @@ function buildAsyncRequire(metroRequire) {
27
32
  }
28
33
  return metroRequire.importAll(moduleID);
29
34
  }
30
- asyncRequire.prefetch = function (moduleID, moduleName) {
31
- const result = asyncRequire(moduleID, moduleName, { isPrefetchOnly: true });
35
+ asyncRequire.prefetch = function (moduleID, moduleName, paths) {
36
+ // TODO: Don't disable in production
37
+ if (process.env.NODE_ENV === "production") {
38
+ return;
39
+ }
40
+ const result = asyncRequire(moduleID, moduleName, paths, {
41
+ isPrefetchOnly: true,
42
+ });
32
43
  if (result instanceof Promise) {
33
44
  result.then(() => { }, () => { });
34
45
  }
35
46
  };
36
- asyncRequire.resource = function (moduleID, moduleName) {
47
+ asyncRequire.resource = function (moduleID, moduleName, paths) {
37
48
  throw new Error("Unimplemented Metro runtime feature");
38
49
  };
39
- /**
40
- * Register modules that can be loaded async.
41
- * Key is a numeric string and value is a string denoting the bundle path.
42
- *
43
- * @example { '1': 'Second' }
44
- */
45
- asyncRequire.addImportBundleNames = function (names) {
46
- Object.assign(importBundleNames, names);
47
- };
48
50
  return asyncRequire;
49
51
  }
50
52
  exports.buildAsyncRequire = buildAsyncRequire;
@@ -1 +1 @@
1
- {"version":3,"file":"buildAsyncRequire.js","sourceRoot":"","sources":["../../src/async-require/buildAsyncRequire.ts"],"names":[],"mappings":";;;AAAA,6CAA+C;AAmC/C,iFAAiF;AACjF,SAAgB,iBAAiB,CAAC,YAA0B;IAC1D,MAAM,iBAAiB,GAAsB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjE,MAAM,oBAAoB,GAAyB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEvE,8FAA8F;IAC9F,SAAS,aAAa,CAAC,QAAgB;QACrC,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,SAAS,YAAY,CACnB,QAAgB,EAChB,aAAqB,EAAE,EACvB,UAAuC,EAAE,cAAc,EAAE,KAAK,EAAE;QAEhE,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAC7D,IAAI,OAAO,CAAC,cAAc,EAAE;YAC1B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;QAED,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,MAAM,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;QACjD,IAAI,UAAU,EAAE;YACd,kDAAkD;YAClD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE;gBACzC,oBAAoB,CAAC,cAAc,CAAC,GAAG,IAAA,4BAAe,EAAC,UAAU,CAAC,CAAC,IAAI,CACrE,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAC7B,CAAC;aACH;YACD,kCAAkC;YAClC,OAAO,oBAAoB,CAAC,cAAc,CAAC,CAAC;SAC7C;QAED,OAAO,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,YAAY,CAAC,QAAQ,GAAG,UACtB,QAAgB,EAChB,UAAkB;QAElB,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5E,IAAI,MAAM,YAAY,OAAO,EAAE;YAC7B,MAAM,CAAC,IAAI,CACT,GAAG,EAAE,GAAE,CAAC,EACR,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;SACH;IACH,CAAC,CAAC;IAEF,YAAY,CAAC,QAAQ,GAAG,UACtB,QAAgB,EAChB,UAAkB;QAElB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC,CAAC;IAEF;;;;;OAKG;IACH,YAAY,CAAC,oBAAoB,GAAG,UAClC,KAA6B;QAE7B,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC;AApED,8CAoEC","sourcesContent":["import { loadBundleAsync } from \"./loadBundle\";\n\ntype ImportBundleNames = Record<string, string> & {\n __proto__: null;\n};\n\ntype MetroRequire = {\n (id: number): any;\n importAll: (id: number) => any;\n};\n\ntype ImportBundlePromises = Record<string, Promise<any>> & {\n __proto__?: null;\n};\n\n/**\n * Must satisfy the requirements of the Metro bundler.\n * https://github.com/facebook/metro/blob/f9fe277986ff7e7e53ae0418040f3aa1eb1c7056/packages/metro/src/ModuleGraph/worker/collectDependencies.js#L629-L639\n *\n * And https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/getAppendScripts.js#L54-L56\n */\ntype AsyncRequire = {\n <TModule>(\n moduleID: number,\n moduleName?: string,\n options?: { isPrefetchOnly: boolean }\n ): Promise<TModule | void> | TModule;\n prefetch(moduleID: number, moduleName: string): void;\n /** NOTE(EvanBacon): Unclear what this should return `__jsResource` ?? */\n resource(moduleID: number, moduleName: string): never;\n\n /** Register the 'moduleID<>bundle path' that can be loaded via `asyncRequire(moduleID)` */\n addImportBundleNames(names: Record<string, string>): void;\n};\n\n/** Create an `asyncRequire` function in the expected shape for Metro bundler. */\nexport function buildAsyncRequire(metroRequire: MetroRequire): AsyncRequire {\n const importBundleNames: ImportBundleNames = Object.create(null);\n const importBundlePromises: ImportBundlePromises = Object.create(null);\n\n // This is basically `__webpack_require__.u` -> returns the bundle path for a numeric moduleID\n function getBundlePath(moduleID: string): string | undefined {\n return importBundleNames[moduleID];\n }\n\n function asyncRequire<TModule>(\n moduleID: number,\n moduleName: string = \"\",\n options: { isPrefetchOnly: boolean } = { isPrefetchOnly: false }\n ): Promise<TModule | void> | TModule {\n console.log(\"async require:\", moduleID, moduleName, options);\n if (options.isPrefetchOnly) {\n return Promise.resolve();\n }\n\n const stringModuleID = String(moduleID);\n const bundlePath = getBundlePath(stringModuleID);\n if (bundlePath) {\n // Prevent loading the same module more than once.\n if (!importBundlePromises[stringModuleID]) {\n importBundlePromises[stringModuleID] = loadBundleAsync(bundlePath).then(\n () => metroRequire(moduleID)\n );\n }\n // Return for the user to resolve.\n return importBundlePromises[stringModuleID];\n }\n\n return metroRequire.importAll(moduleID);\n }\n\n asyncRequire.prefetch = function (\n moduleID: number,\n moduleName: string\n ): void {\n const result = asyncRequire(moduleID, moduleName, { isPrefetchOnly: true });\n if (result instanceof Promise) {\n result.then(\n () => {},\n () => {}\n );\n }\n };\n\n asyncRequire.resource = function (\n moduleID: number,\n moduleName: string\n ): never {\n throw new Error(\"Unimplemented Metro runtime feature\");\n };\n\n /**\n * Register modules that can be loaded async.\n * Key is a numeric string and value is a string denoting the bundle path.\n *\n * @example { '1': 'Second' }\n */\n asyncRequire.addImportBundleNames = function (\n names: Record<string, string>\n ): void {\n Object.assign(importBundleNames, names);\n };\n\n return asyncRequire;\n}\n"]}
1
+ {"version":3,"file":"buildAsyncRequire.js","sourceRoot":"","sources":["../../src/async-require/buildAsyncRequire.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6CAA+C;AAuC/C,iFAAiF;AACjF,SAAgB,iBAAiB,CAAC,YAA0B;IAC1D,MAAM,oBAAoB,GAAyB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEvE,SAAS,YAAY,CACnB,QAAgB,EAChB,UAAkB,EAClB,KAAwB,EACxB,UAAuC,EAAE,cAAc,EAAE,KAAK,EAAE;QAEhE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;YACzC,oCAAoC;YAEpC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;SACvE;QAED,IAAI,OAAO,CAAC,cAAc,EAAE;YAC1B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;QAED,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QACxC,8FAA8F;QAC9F,MAAM,UAAU,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;QACzC,IAAI,UAAU,EAAE;YACd,kDAAkD;YAClD,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE;gBACzC,oBAAoB,CAAC,cAAc,CAAC,GAAG,IAAA,4BAAe,EAAC,UAAU,CAAC,CAAC,IAAI,CACrE,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAC7B,CAAC;aACH;YACD,kCAAkC;YAClC,OAAO,oBAAoB,CAAC,cAAc,CAAC,CAAC;SAC7C;QAED,OAAO,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,YAAY,CAAC,QAAQ,GAAG,UACtB,QAAgB,EAChB,UAAkB,EAClB,KAAwB;QAExB,oCAAoC;QACpC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;YACzC,OAAO;SACR;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE;YACvD,cAAc,EAAE,IAAI;SACrB,CAAC,CAAC;QACH,IAAI,MAAM,YAAY,OAAO,EAAE;YAC7B,MAAM,CAAC,IAAI,CACT,GAAG,EAAE,GAAE,CAAC,EACR,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;SACH;IACH,CAAC,CAAC;IAEF,YAAY,CAAC,QAAQ,GAAG,UACtB,QAAgB,EAChB,UAAkB,EAClB,KAAwB;QAExB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC,CAAC;IAEF,OAAO,YAAY,CAAC;AACtB,CAAC;AAjED,8CAiEC","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { loadBundleAsync } from \"./loadBundle\";\n\ntype ImportBundleNames = Record<string, string>;\n\ntype MetroRequire = {\n (id: number): any;\n importAll: (id: number) => any;\n};\n\ntype ImportBundlePromises = Record<string, Promise<any>> & {\n __proto__?: null;\n};\n\n/**\n * Must satisfy the requirements of the Metro bundler.\n * https://github.com/facebook/metro/blob/f9fe277986ff7e7e53ae0418040f3aa1eb1c7056/packages/metro/src/ModuleGraph/worker/collectDependencies.js#L629-L639\n *\n * And https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/getAppendScripts.js#L54-L56\n */\ntype AsyncRequire = {\n <TModule>(\n moduleID: number,\n moduleName: string,\n paths: ImportBundleNames,\n options?: { isPrefetchOnly: boolean }\n ): Promise<TModule | void> | TModule;\n prefetch(\n moduleID: number,\n moduleName: string,\n paths: ImportBundleNames\n ): void;\n /** NOTE(EvanBacon): Unclear what this should return `__jsResource` ?? */\n resource(\n moduleID: number,\n moduleName: string,\n paths: ImportBundleNames\n ): never;\n};\n\n/** Create an `asyncRequire` function in the expected shape for Metro bundler. */\nexport function buildAsyncRequire(metroRequire: MetroRequire): AsyncRequire {\n const importBundlePromises: ImportBundlePromises = Object.create(null);\n\n function asyncRequire<TModule>(\n moduleID: number,\n moduleName: string,\n paths: ImportBundleNames,\n options: { isPrefetchOnly: boolean } = { isPrefetchOnly: false }\n ): Promise<TModule | void> | TModule {\n if (process.env.NODE_ENV === \"production\") {\n // TODO: Don't disable in production\n\n return Promise.resolve().then(() => metroRequire.importAll(moduleID));\n }\n\n if (options.isPrefetchOnly) {\n return Promise.resolve();\n }\n\n const stringModuleID = String(moduleID);\n // This is basically `__webpack_require__.u` -> returns the bundle path for a numeric moduleID\n const bundlePath = paths[stringModuleID];\n if (bundlePath) {\n // Prevent loading the same module more than once.\n if (!importBundlePromises[stringModuleID]) {\n importBundlePromises[stringModuleID] = loadBundleAsync(bundlePath).then(\n () => metroRequire(moduleID)\n );\n }\n // Return for the user to resolve.\n return importBundlePromises[stringModuleID];\n }\n\n return metroRequire.importAll(moduleID);\n }\n\n asyncRequire.prefetch = function (\n moduleID: number,\n moduleName: string,\n paths: ImportBundleNames\n ): void {\n // TODO: Don't disable in production\n if (process.env.NODE_ENV === \"production\") {\n return;\n }\n const result = asyncRequire(moduleID, moduleName, paths, {\n isPrefetchOnly: true,\n });\n if (result instanceof Promise) {\n result.then(\n () => {},\n () => {}\n );\n }\n };\n\n asyncRequire.resource = function (\n moduleID: number,\n moduleName: string,\n paths: ImportBundleNames\n ): never {\n throw new Error(\"Unimplemented Metro runtime feature\");\n };\n\n return asyncRequire;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildUrlForBundle.d.ts","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAM,GACzC,MAAM,CAaR"}
1
+ {"version":3,"file":"buildUrlForBundle.d.ts","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAM,GACzC,MAAM,CAaR"}
@@ -4,6 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.buildUrlForBundle = void 0;
7
+ /**
8
+ * Copyright © 2022 650 Industries.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
7
13
  const qs_1 = __importDefault(require("qs"));
8
14
  /**
9
15
  * Given a path and some optional additional query parameters, create the dev server bundle URL.
@@ -1 +1 @@
1
- {"version":3,"file":"buildUrlForBundle.js","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,UAAkB,EAClB,SAAwC,EAAE;IAE1C,iFAAiF;IACjF,kFAAkF;IAElF,IAAI,GAAG,GAAG,EAAE,CAAC;IAEb,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC/B,GAAG,IAAI,GAAG,CAAC;KACZ;IAED,MAAM,KAAK,GAAG,YAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,GAAG,GAAG,UAAU,GAAG,SAAS,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC;AAhBD,8CAgBC","sourcesContent":["import qs from \"qs\";\n\n/**\n * Given a path and some optional additional query parameters, create the dev server bundle URL.\n * @param bundlePath like `/foobar`\n * @param params like `{ platform: \"web\" }`\n * @returns a URL like \"/foobar.bundle?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null\"\n */\nexport function buildUrlForBundle(\n bundlePath: string,\n params: Record<string, string | null> = {}\n): string {\n // NOTE(EvanBacon): This must come from the window origin (at least in dev mode).\n // Otherwise Metro will crash from attempting to load a bundle that doesn't exist.\n\n let url = \"\";\n\n if (!bundlePath.startsWith(\"/\")) {\n url += \"/\";\n }\n\n const query = qs.stringify(params);\n\n return url + bundlePath + \".bundle\" + (query ? \"?\" + query : \"\");\n}\n"]}
1
+ {"version":3,"file":"buildUrlForBundle.js","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,4CAAoB;AAEpB;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,UAAkB,EAClB,SAAwC,EAAE;IAE1C,iFAAiF;IACjF,kFAAkF;IAElF,IAAI,GAAG,GAAG,EAAE,CAAC;IAEb,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAC/B,GAAG,IAAI,GAAG,CAAC;KACZ;IAED,MAAM,KAAK,GAAG,YAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,GAAG,GAAG,UAAU,GAAG,SAAS,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACnE,CAAC;AAhBD,8CAgBC","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport qs from \"qs\";\n\n/**\n * Given a path and some optional additional query parameters, create the dev server bundle URL.\n * @param bundlePath like `/foobar`\n * @param params like `{ platform: \"web\" }`\n * @returns a URL like \"/foobar.bundle?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null\"\n */\nexport function buildUrlForBundle(\n bundlePath: string,\n params: Record<string, string | null> = {}\n): string {\n // NOTE(EvanBacon): This must come from the window origin (at least in dev mode).\n // Otherwise Metro will crash from attempting to load a bundle that doesn't exist.\n\n let url = \"\";\n\n if (!bundlePath.startsWith(\"/\")) {\n url += \"/\";\n }\n\n const query = qs.stringify(params);\n\n return url + bundlePath + \".bundle\" + (query ? \"?\" + query : \"\");\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"buildUrlForBundle.native.d.ts","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.native.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAM,GACzC,MAAM,CAoBR"}
1
+ {"version":3,"file":"buildUrlForBundle.native.d.ts","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.native.ts"],"names":[],"mappings":"AAUA,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAM,GACzC,MAAM,CAoBR"}
@@ -4,6 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.buildUrlForBundle = void 0;
7
+ /**
8
+ * Copyright © 2022 650 Industries.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
7
13
  const qs_1 = __importDefault(require("qs"));
8
14
  const getDevServer_1 = __importDefault(require("../getDevServer"));
9
15
  function buildUrlForBundle(bundlePath, params = {}) {
@@ -1 +1 @@
1
- {"version":3,"file":"buildUrlForBundle.native.js","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.native.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AAEpB,mEAA2C;AAE3C,SAAgB,iBAAiB,CAC/B,UAAkB,EAClB,SAAwC,EAAE;IAE1C,MAAM,EACJ,aAAa,EACb,GAAG,EAAE,SAAS,EACd,sBAAsB,GACvB,GAAG,IAAA,sBAAY,GAAE,CAAC;IACnB,IAAI,CAAC,sBAAsB,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,6JAA6J,CAC9J,CAAC;KACH;IACD,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,aAAa,IAAI,IAAI,EAAE;QACzB,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;YACrB,KAAK,GAAG,YAAE,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF;IACD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,YAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAvBD,8CAuBC","sourcesContent":["import qs from \"qs\";\n\nimport getDevServer from \"../getDevServer\";\n\nexport function buildUrlForBundle(\n bundlePath: string,\n params: Record<string, string | null> = {}\n): string {\n const {\n fullBundleUrl,\n url: serverUrl,\n bundleLoadedFromServer,\n } = getDevServer();\n if (!bundleLoadedFromServer) {\n throw new Error(\n \"This bundle was compiled with 'transformer.experimentalImportBundleSupport' in the 'metro.config.js' and can only be used when connected to a Metro server.\"\n );\n }\n let query = {};\n if (fullBundleUrl != null) {\n const queryStart = fullBundleUrl.indexOf(\"?\");\n if (queryStart !== -1) {\n query = qs.parse(fullBundleUrl.substring(queryStart + 1));\n }\n }\n Object.assign(query, params);\n return serverUrl + bundlePath + \".bundle?\" + qs.stringify(query);\n}\n"]}
1
+ {"version":3,"file":"buildUrlForBundle.native.js","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.native.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,4CAAoB;AAEpB,mEAA2C;AAE3C,SAAgB,iBAAiB,CAC/B,UAAkB,EAClB,SAAwC,EAAE;IAE1C,MAAM,EACJ,aAAa,EACb,GAAG,EAAE,SAAS,EACd,sBAAsB,GACvB,GAAG,IAAA,sBAAY,GAAE,CAAC;IACnB,IAAI,CAAC,sBAAsB,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,6JAA6J,CAC9J,CAAC;KACH;IACD,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,aAAa,IAAI,IAAI,EAAE;QACzB,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;YACrB,KAAK,GAAG,YAAE,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF;IACD,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7B,OAAO,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,YAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAvBD,8CAuBC","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport qs from \"qs\";\n\nimport getDevServer from \"../getDevServer\";\n\nexport function buildUrlForBundle(\n bundlePath: string,\n params: Record<string, string | null> = {}\n): string {\n const {\n fullBundleUrl,\n url: serverUrl,\n bundleLoadedFromServer,\n } = getDevServer();\n if (!bundleLoadedFromServer) {\n throw new Error(\n \"This bundle was compiled with 'transformer.experimentalImportBundleSupport' in the 'metro.config.js' and can only be used when connected to a Metro server.\"\n );\n }\n let query = {};\n if (fullBundleUrl != null) {\n const queryStart = fullBundleUrl.indexOf(\"?\");\n if (queryStart !== -1) {\n query = qs.parse(fullBundleUrl.substring(queryStart + 1));\n }\n }\n Object.assign(query, params);\n return serverUrl + bundlePath + \".bundle?\" + qs.stringify(query);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchAsync.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchAsync.ts"],"names":[],"mappings":"AAEA,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAY7C"}
1
+ {"version":3,"file":"fetchAsync.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchAsync.ts"],"names":[],"mappings":"AAQA,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAY7C"}
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchAsync = void 0;
4
+ /**
5
+ * Copyright © 2022 650 Industries.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
4
10
  const react_native_1 = require("react-native");
5
11
  async function fetchAsync(url) {
6
12
  const response = await fetch(url, {
@@ -1 +1 @@
1
- {"version":3,"file":"fetchAsync.js","sourceRoot":"","sources":["../../src/async-require/fetchAsync.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAEjC,KAAK,UAAU,UAAU,CAC9B,GAAW;IAEX,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,wEAAwE;YACxE,eAAe,EAAE,uBAAQ,CAAC,EAAE;SAC7B;KACF,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE;QAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAC;AACJ,CAAC;AAdD,gCAcC","sourcesContent":["import { Platform } from \"react-native\";\n\nexport async function fetchAsync(\n url: string\n): Promise<{ body: string; headers: Headers }> {\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n // No real reason for this but we try to use this format for everything.\n \"expo-platform\": Platform.OS,\n },\n });\n return {\n body: await response.text(),\n headers: response.headers,\n };\n}\n"]}
1
+ {"version":3,"file":"fetchAsync.js","sourceRoot":"","sources":["../../src/async-require/fetchAsync.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+CAAwC;AAEjC,KAAK,UAAU,UAAU,CAC9B,GAAW;IAEX,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,wEAAwE;YACxE,eAAe,EAAE,uBAAQ,CAAC,EAAE;SAC7B;KACF,CAAC,CAAC;IACH,OAAO;QACL,IAAI,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE;QAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAC;AACJ,CAAC;AAdD,gCAcC","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { Platform } from \"react-native\";\n\nexport async function fetchAsync(\n url: string\n): Promise<{ body: string; headers: Headers }> {\n const response = await fetch(url, {\n method: \"GET\",\n headers: {\n // No real reason for this but we try to use this format for everything.\n \"expo-platform\": Platform.OS,\n },\n });\n return {\n body: await response.text(),\n headers: response.headers,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchAsync.native.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchAsync.native.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CA2D5D"}
1
+ {"version":3,"file":"fetchAsync.native.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchAsync.native.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,CA+D5D"}
@@ -22,17 +22,18 @@ function fetchAsync(url) {
22
22
  let completeListener = null;
23
23
  let responseListener = null;
24
24
  return new Promise((resolve, reject) => {
25
- dataListener = RCTNetworking_1.default.addListener("didReceiveNetworkData", ([requestId, response]) => {
25
+ const addListener = RCTNetworking_1.default.addListener;
26
+ dataListener = addListener("didReceiveNetworkData", ([requestId, response]) => {
26
27
  if (requestId === id) {
27
28
  responseText = response;
28
29
  }
29
30
  });
30
- responseListener = RCTNetworking_1.default.addListener("didReceiveNetworkResponse", ([requestId, status, responseHeaders]) => {
31
+ responseListener = addListener("didReceiveNetworkResponse", ([requestId, status, responseHeaders]) => {
31
32
  if (requestId === id) {
32
33
  headers = responseHeaders;
33
34
  }
34
35
  });
35
- completeListener = RCTNetworking_1.default.addListener("didCompleteNetworkResponse", ([requestId, error]) => {
36
+ completeListener = addListener("didCompleteNetworkResponse", ([requestId, error]) => {
36
37
  if (requestId === id) {
37
38
  if (error) {
38
39
  reject(error);
@@ -1 +1 @@
1
- {"version":3,"file":"fetchAsync.native.js","sourceRoot":"","sources":["../../src/async-require/fetchAsync.native.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;AAEH,+CAAwC;AACxC,mBAAmB;AACnB,iGAAsE;AAEtE,SAAgB,UAAU,CACxB,GAAW;IAEX,IAAI,EAAE,GAAkB,IAAI,CAAC;IAC7B,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,OAA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AAG,EAAE;QACb,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,EAAE,CAAC;QACvB,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,EAAE,CAAC;QAC3B,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AA7DD,gCA6DC","sourcesContent":["/**\n * Copyright (c) Evan Bacon.\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Platform } from \"react-native\";\n// @ts-expect-error\nimport Networking from \"react-native/Libraries/Network/RCTNetworking\";\n\nexport function fetchAsync(\n url: string\n): Promise<{ body: string; headers: Record<string, string> }> {\n let id: string | null = null;\n let responseText: string | null = null;\n let headers: Record<string, string> = {};\n let dataListener: { remove: () => void } | null = null;\n let completeListener: { remove: () => void } | null = null;\n let responseListener: { remove: () => void } | null = null;\n return new Promise<{ body: string; headers: Record<string, string> }>(\n (resolve, reject) => {\n dataListener = Networking.addListener(\n \"didReceiveNetworkData\",\n ([requestId, response]) => {\n if (requestId === id) {\n responseText = response;\n }\n }\n );\n responseListener = Networking.addListener(\n \"didReceiveNetworkResponse\",\n ([requestId, status, responseHeaders]) => {\n if (requestId === id) {\n headers = responseHeaders;\n }\n }\n );\n completeListener = Networking.addListener(\n \"didCompleteNetworkResponse\",\n ([requestId, error]) => {\n if (requestId === id) {\n if (error) {\n reject(error);\n } else {\n resolve({ body: responseText!, headers });\n }\n }\n }\n );\n Networking.sendRequest(\n \"GET\",\n \"asyncRequest\",\n url,\n {\n \"expo-platform\": Platform.OS,\n },\n \"\",\n \"text\",\n false,\n 0,\n (requestId) => {\n id = requestId;\n },\n true\n );\n }\n ).finally(() => {\n dataListener?.remove();\n completeListener?.remove();\n responseListener?.remove();\n });\n}\n"]}
1
+ {"version":3,"file":"fetchAsync.native.js","s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mB,CAC7B,KAAK,EACL,cAAc,EACd,GAAG,EACH;YACE,eAAe,EAAE,uBAAQ,CAAC,EAAE;SAC7B,EACD,EAAE,EACF,MAAM,EACN,KAAK,EACL,CAAC,EACD,CAAC,SAAiB,EAAE,EAAE;YACpB,EAAE,GAAG,SAAS,CAAC;QACjB,CAAC,EACD,IAAI,CACL,CAAC;IACJ,CAAC,CACF,CAAC,OAAO,CAAC,GAAG,EAAE;QACb,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,EAAE,CAAC;QACvB,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,EAAE,CAAC;QAC3B,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,MAAM,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAjED,gCAiEC","sourcesContent":["/**\n * Copyright (c) Evan Bacon.\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { Platform } from \"react-native\";\n// @ts-expect-error\nimport Networking from \"react-native/Libraries/Network/RCTNetworking\";\n\ntype Subscriber = { remove: () => void };\n\nexport function fetchAsync(\n url: string\n): Promise<{ body: string; headers: Record<string, string> }> {\n let id: string | null = null;\n let responseText: string | null = null;\n let headers: Record<string, string> = {};\n let dataListener: Subscriber | null = null;\n let completeListener: Subscriber | null = null;\n let responseListener: Subscriber | null = null;\n return new Promise<{ body: string; headers: Record<string, string> }>(\n (resolve, reject) => {\n const addListener = Networking.addListener as (\n event: string,\n callback: (props: [string, any, any]) => any\n ) => Subscriber;\n dataListener = addListener(\n \"didReceiveNetworkData\",\n ([requestId, response]) => {\n if (requestId === id) {\n responseText = response;\n }\n }\n );\n responseListener = addListener(\n \"didReceiveNetworkResponse\",\n ([requestId, status, responseHeaders]) => {\n if (requestId === id) {\n headers = responseHeaders;\n }\n }\n );\n completeListener = addListener(\n \"didCompleteNetworkResponse\",\n ([requestId, error]) => {\n if (requestId === id) {\n if (error) {\n reject(error);\n } else {\n resolve({ body: responseText!, headers });\n }\n }\n }\n );\n (Networking.sendRequest as any)(\n \"GET\",\n \"asyncRequest\",\n url,\n {\n \"expo-platform\": Platform.OS,\n },\n \"\",\n \"text\",\n false,\n 0,\n (requestId: string) => {\n id = requestId;\n },\n true\n );\n }\n ).finally(() => {\n dataListener?.remove();\n completeListener?.remove();\n responseListener?.remove();\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fetchThenEval.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB7D"}
1
+ {"version":3,"file":"fetchThenEval.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB7D"}
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchThenEvalAsync = void 0;
4
+ /**
5
+ * Copyright © 2022 650 Industries.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
4
10
  const fetchAsync_1 = require("./fetchAsync");
5
11
  /**
6
12
  * Load a bundle for a URL using fetch + eval on native and script tag injection on web.
@@ -9,8 +15,8 @@ const fetchAsync_1 = require("./fetchAsync");
9
15
  */
10
16
  function fetchThenEvalAsync(url) {
11
17
  return (0, fetchAsync_1.fetchAsync)(url).then(({ body, headers }) => {
12
- if (headers["Content-Type"] != null &&
13
- headers["Content-Type"].indexOf("application/json") >= 0) {
18
+ if (headers.has("Content-Type") != null &&
19
+ headers.get("Content-Type").includes("application/json")) {
14
20
  // Errors are returned as JSON.
15
21
  throw new Error(JSON.parse(body).message || `Unknown error fetching '${url}'`);
16
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetchThenEval.js","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAM1C;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,OAAO,IAAA,uBAAU,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,IACE,OAAO,CAAC,cAAc,CAAC,IAAI,IAAI;YAC/B,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACxD;YACA,+BAA+B;YAC/B,MAAM,IAAI,KAAK,CACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,2BAA2B,GAAG,GAAG,CAC9D,CAAC;SACH;QAED,gFAAgF;QAEhF,oEAAoE;QACpE,qEAAqE;QACrE,IAAI,MAAM,CAAC,uBAAuB,EAAE;YAClC,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC3C;aAAM;YACL,mCAAmC;YACnC,IAAI,CAAC,IAAI,CAAC,CAAC;SACZ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAvBD,gDAuBC","sourcesContent":["import { fetchAsync } from \"./fetchAsync\";\n\ndeclare let global: {\n globalEvalWithSourceUrl?: any;\n};\n\n/**\n * Load a bundle for a URL using fetch + eval on native and script tag injection on web.\n *\n * @param bundlePath Given a statement like `import('./Bacon')` `bundlePath` would be `Bacon`.\n */\nexport function fetchThenEvalAsync(url: string): Promise<void> {\n return fetchAsync(url).then(({ body, headers }) => {\n if (\n headers[\"Content-Type\"] != null &&\n headers[\"Content-Type\"].indexOf(\"application/json\") >= 0\n ) {\n // Errors are returned as JSON.\n throw new Error(\n JSON.parse(body).message || `Unknown error fetching '${url}'`\n );\n }\n\n // NOTE(EvanBacon): All of this code is ignored in development mode at the root.\n\n // Some engines do not support `sourceURL` as a comment. We expose a\n // `globalEvalWithSourceUrl` function to handle updates in that case.\n if (global.globalEvalWithSourceUrl) {\n global.globalEvalWithSourceUrl(body, url);\n } else {\n // eslint-disable-next-line no-eval\n eval(body);\n }\n });\n}\n"]}
1
+ {"version":3,"file":"fetchThenEval.js","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,6CAA0C;AAM1C;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,OAAO,IAAA,uBAAU,EAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE;QAChD,IACE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAI;YACnC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EACzD;YACA,+BAA+B;YAC/B,MAAM,IAAI,KAAK,CACb,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,2BAA2B,GAAG,GAAG,CAC9D,CAAC;SACH;QAED,gFAAgF;QAEhF,oEAAoE;QACpE,qEAAqE;QACrE,IAAI,MAAM,CAAC,uBAAuB,EAAE;YAClC,MAAM,CAAC,uBAAuB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;SAC3C;aAAM;YACL,mCAAmC;YACnC,IAAI,CAAC,IAAI,CAAC,CAAC;SACZ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAvBD,gDAuBC","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { fetchAsync } from \"./fetchAsync\";\n\ndeclare let global: {\n globalEvalWithSourceUrl?: any;\n};\n\n/**\n * Load a bundle for a URL using fetch + eval on native and script tag injection on web.\n *\n * @param bundlePath Given a statement like `import('./Bacon')` `bundlePath` would be `Bacon`.\n */\nexport function fetchThenEvalAsync(url: string): Promise<void> {\n return fetchAsync(url).then(({ body, headers }) => {\n if (\n headers.has(\"Content-Type\") != null &&\n headers.get(\"Content-Type\")!.includes(\"application/json\")\n ) {\n // Errors are returned as JSON.\n throw new Error(\n JSON.parse(body).message || `Unknown error fetching '${url}'`\n );\n }\n\n // NOTE(EvanBacon): All of this code is ignored in development mode at the root.\n\n // Some engines do not support `sourceURL` as a comment. We expose a\n // `globalEvalWithSourceUrl` function to handle updates in that case.\n if (global.globalEvalWithSourceUrl) {\n global.globalEvalWithSourceUrl(body, url);\n } else {\n // eslint-disable-next-line no-eval\n eval(body);\n }\n });\n}\n"]}
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Copyright © 2022 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
+ */
1
7
  export declare function fetchThenEvalAsync(url: string, { scriptType, nonce, crossOrigin, }?: {
2
8
  scriptType?: string;
3
9
  nonce?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"fetchThenEval.web.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.web.ts"],"names":[],"mappings":"AACA,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,EACE,UAAU,EACV,KAAK,EACL,WAAW,GACZ,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACpE,OAAO,CAAC,IAAI,CAAC,CAuDf"}
1
+ {"version":3,"file":"fetchThenEval.web.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.web.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,EACE,UAAU,EACV,KAAK,EACL,WAAW,GACZ,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACpE,OAAO,CAAC,IAAI,CAAC,CAsDf"}
@@ -1,6 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchThenEvalAsync = void 0;
4
+ /**
5
+ * Copyright © 2022 650 Industries.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
4
10
  // Basically `__webpack_require__.l`.
5
11
  function fetchThenEvalAsync(url, { scriptType, nonce, crossOrigin, } = {}) {
6
12
  return new Promise((resolve, reject) => {
@@ -53,7 +59,6 @@ function fetchThenEvalAsync(url, { scriptType, nonce, crossOrigin, } = {}) {
53
59
  reject(error);
54
60
  };
55
61
  document.head.appendChild(script);
56
- document.head.appendChild(script);
57
62
  });
58
63
  }
59
64
  exports.fetchThenEvalAsync = fetchThenEvalAsync;
@@ -1 +1 @@
1
- {"version":3,"file":"fetchThenEval.web.js","sourceRoot":"","sources":["../../src/async-require/fetchThenEval.web.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,SAAgB,kBAAkB,CAChC,GAAW,EACX,EACE,UAAU,EACV,KAAK,EACL,WAAW,MACsD,EAAE;IAErE,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,UAAU;YAAE,MAAM,CAAC,IAAI,GAAG,UAAU,CAAC;QACzC,IAAI,KAAK;YAAE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC/C,+CAA+C;QAC/C,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;QAEjB,IAAI,WAAW,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,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C;QAChB,CAAC,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAClC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AA9DD,gDA8DC;AAED,MAAM,iBAAkB,SAAQ,KAAK;IAArC;;QACW,SAAI,GAAG,mBAAmB,CAAC;IAGtC,CAAC;CAAA","sourcesContent":["// Basically `__webpack_require__.l`.\nexport function fetchThenEvalAsync(\n url: string,\n {\n scriptType,\n nonce,\n crossOrigin,\n }: { scriptType?: string; nonce?: string; crossOrigin?: string } = {}\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement(\"script\");\n if (scriptType) script.type = scriptType;\n if (nonce) script.setAttribute(\"nonce\", nonce);\n // script.setAttribute('data-expo-metro', ...);\n script.src = url;\n\n if (crossOrigin && script.src.indexOf(window.location.origin + \"/\") !== 0) {\n script.crossOrigin = crossOrigin;\n }\n\n script.onload = () => {\n script.parentNode && script.parentNode.removeChild(script);\n resolve();\n };\n // Create a new error object to preserve the original stack trace.\n const error = new AsyncRequireError();\n\n // Server error or network error.\n script.onerror = (ev) => {\n let event: Event;\n if (typeof ev === \"string\") {\n event = {\n type: \"error\",\n target: {\n // @ts-expect-error\n src: event,\n },\n };\n } else {\n event = ev;\n }\n\n const errorType =\n event && (event.type === \"load\" ? \"missing\" : event.type);\n // @ts-expect-error\n const realSrc = event?.target?.src;\n error.message =\n \"Loading module \" +\n url +\n \" failed.\\n(\" +\n errorType +\n \": \" +\n realSrc +\n \")\";\n error.type = errorType;\n error.request = realSrc;\n\n script.parentNode && script.parentNode.removeChild(script);\n reject(error);\n };\n document.head.appendChild(script);\n document.head.appendChild(script);\n });\n}\n\nclass AsyncRequireError extends Error {\n readonly name = \"AsyncRequireError\";\n type?: string;\n request?: string;\n}\n"]}
1
+ {"version":3,"file":"fetchThenEval.web.js","sourceRoot":"","sources":["../../src/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,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5D,mBAAmB;YACnB,MAAM,OAAO,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,0CAAE,GAAG,CAAC;YACnC,KAAK,CAAC,OAAO;gBACX,iBAAiB;oBACjB,GAAG;oBACH,aAAa;oBACb,SAAS;oBACT,IAAI;oBACJ,OAAO;oBACP,GAAG,CAAC;YACN,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;YACvB,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;YAExB,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC3D,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AA7DD,gDA6DC;AAED,MAAM,iBAAkB,SAAQ,KAAK;IAArC;;QACW,SAAI,GAAG,mBAAmB,CAAC;IAGtC,CAAC;CAAA","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n// Basically `__webpack_require__.l`.\nexport function fetchThenEvalAsync(\n url: string,\n {\n scriptType,\n nonce,\n crossOrigin,\n }: { scriptType?: string; nonce?: string; crossOrigin?: string } = {}\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n const script = document.createElement(\"script\");\n if (scriptType) script.type = scriptType;\n if (nonce) script.setAttribute(\"nonce\", nonce);\n // script.setAttribute('data-expo-metro', ...);\n script.src = url;\n\n if (crossOrigin && script.src.indexOf(window.location.origin + \"/\") !== 0) {\n script.crossOrigin = crossOrigin;\n }\n\n script.onload = () => {\n script.parentNode && script.parentNode.removeChild(script);\n resolve();\n };\n // Create a new error object to preserve the original stack trace.\n const error = new AsyncRequireError();\n\n // Server error or network error.\n script.onerror = (ev) => {\n let event: Event;\n if (typeof ev === \"string\") {\n event = {\n type: \"error\",\n target: {\n // @ts-expect-error\n src: event,\n },\n };\n } else {\n event = ev;\n }\n\n const errorType =\n event && (event.type === \"load\" ? \"missing\" : event.type);\n // @ts-expect-error\n const realSrc = event?.target?.src;\n error.message =\n \"Loading module \" +\n url +\n \" failed.\\n(\" +\n errorType +\n \": \" +\n realSrc +\n \")\";\n error.type = errorType;\n error.request = realSrc;\n\n script.parentNode && script.parentNode.removeChild(script);\n reject(error);\n };\n document.head.appendChild(script);\n });\n}\n\nclass AsyncRequireError extends Error {\n readonly name = \"AsyncRequireError\";\n type?: string;\n request?: string;\n}\n"]}
@@ -1,5 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Copyright © 2022 650 Industries.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
3
9
  const buildAsyncRequire_1 = require("./buildAsyncRequire");
4
10
  module.exports = (0, buildAsyncRequire_1.buildAsyncRequire)(require);
5
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/async-require/index.ts"],"names":[],"mappings":";;AAAA,2DAAwD;AAExD,MAAM,CAAC,OAAO,GAAG,IAAA,qCAAiB,EAAC,OAAc,CAAC,CAAC","sourcesContent":["import { buildAsyncRequire } from \"./buildAsyncRequire\";\n\nmodule.exports = buildAsyncRequire(require as any);\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/async-require/index.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,2DAAwD;AAExD,MAAM,CAAC,OAAO,GAAG,IAAA,qCAAiB,EAAC,OAAc,CAAC,CAAC","sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { buildAsyncRequire } from \"./buildAsyncRequire\";\n\nmodule.exports = buildAsyncRequire(require as any);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"loadBundle.android.d.ts","sourceRoot":"","sources":["../../src/async-require/loadBundle.android.ts"],"names":[],"mappings":"AAIA,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAYhE"}
1
+ {"version":3,"file":"loadBundle.android.d.ts","sourceRoot":"","sources":["../../src/async-require/loadBundle.android.ts"],"names":[],"mappings":"AAWA,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAchE"}
@@ -4,6 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.loadBundleAsync = void 0;
7
+ /**
8
+ * Copyright © 2022 650 Industries.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ */
13
+ // @ts-expect-error
7
14
  const NativeDevSplitBundleLoader_1 = __importDefault(require("react-native/Libraries/Utilities/NativeDevSplitBundleLoader"));
8
15
  const loadBundlePolyfill_1 = require("./loadBundlePolyfill");
9
16
  function loadBundleAsync(bundlePath) {