@expo/metro-runtime 0.0.0
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/LICENSE +13 -0
- package/README.md +3 -0
- package/assets/alert-triangle.png +0 -0
- package/assets/chevron-left.png +0 -0
- package/assets/chevron-right.png +0 -0
- package/assets/close.png +0 -0
- package/assets/loader.png +0 -0
- package/asyncRequire.js +1 -0
- package/build/HMRClient.d.ts +17 -0
- package/build/HMRClient.d.ts.map +1 -0
- package/build/HMRClient.js +250 -0
- package/build/HMRClient.js.map +1 -0
- package/build/HMRClient.native.d.ts +1 -0
- package/build/HMRClient.native.d.ts.map +1 -0
- package/build/HMRClient.native.js +2 -0
- package/build/HMRClient.native.js.map +1 -0
- package/build/LoadingView.d.ts +8 -0
- package/build/LoadingView.d.ts.map +1 -0
- package/build/LoadingView.js +21 -0
- package/build/LoadingView.js.map +1 -0
- package/build/LoadingView.native.d.ts +1 -0
- package/build/LoadingView.native.d.ts.map +1 -0
- package/build/LoadingView.native.js +2 -0
- package/build/LoadingView.native.js.map +1 -0
- package/build/asyncRequire/buildAsyncRequire.d.ts +24 -0
- package/build/asyncRequire/buildAsyncRequire.d.ts.map +1 -0
- package/build/asyncRequire/buildAsyncRequire.js +50 -0
- package/build/asyncRequire/buildAsyncRequire.js.map +1 -0
- package/build/asyncRequire/buildUrlForBundle.d.ts +8 -0
- package/build/asyncRequire/buildUrlForBundle.d.ts.map +1 -0
- package/build/asyncRequire/buildUrlForBundle.js +25 -0
- package/build/asyncRequire/buildUrlForBundle.js.map +1 -0
- package/build/asyncRequire/buildUrlForBundle.native.d.ts +2 -0
- package/build/asyncRequire/buildUrlForBundle.native.d.ts.map +1 -0
- package/build/asyncRequire/buildUrlForBundle.native.js +25 -0
- package/build/asyncRequire/buildUrlForBundle.native.js.map +1 -0
- package/build/asyncRequire/fetchAsync.d.ts +5 -0
- package/build/asyncRequire/fetchAsync.d.ts.map +1 -0
- package/build/asyncRequire/fetchAsync.js +19 -0
- package/build/asyncRequire/fetchAsync.js.map +1 -0
- package/build/asyncRequire/fetchAsync.native.d.ts +12 -0
- package/build/asyncRequire/fetchAsync.native.d.ts.map +1 -0
- package/build/asyncRequire/fetchAsync.native.js +57 -0
- package/build/asyncRequire/fetchAsync.native.js.map +1 -0
- package/build/asyncRequire/fetchThenEval.d.ts +7 -0
- package/build/asyncRequire/fetchThenEval.d.ts.map +1 -0
- package/build/asyncRequire/fetchThenEval.js +30 -0
- package/build/asyncRequire/fetchThenEval.js.map +1 -0
- package/build/asyncRequire/fetchThenEval.web.d.ts +6 -0
- package/build/asyncRequire/fetchThenEval.web.d.ts.map +1 -0
- package/build/asyncRequire/fetchThenEval.web.js +29 -0
- package/build/asyncRequire/fetchThenEval.web.js.map +1 -0
- package/build/asyncRequire/index.d.ts +2 -0
- package/build/asyncRequire/index.d.ts.map +1 -0
- package/build/asyncRequire/index.js +5 -0
- package/build/asyncRequire/index.js.map +1 -0
- package/build/asyncRequire/loadBundle.android.d.ts +2 -0
- package/build/asyncRequire/loadBundle.android.d.ts.map +1 -0
- package/build/asyncRequire/loadBundle.android.js +22 -0
- package/build/asyncRequire/loadBundle.android.js.map +1 -0
- package/build/asyncRequire/loadBundle.d.ts +2 -0
- package/build/asyncRequire/loadBundle.d.ts.map +1 -0
- package/build/asyncRequire/loadBundle.js +6 -0
- package/build/asyncRequire/loadBundle.js.map +1 -0
- package/build/asyncRequire/loadBundlePolyfill.d.ts +7 -0
- package/build/asyncRequire/loadBundlePolyfill.d.ts.map +1 -0
- package/build/asyncRequire/loadBundlePolyfill.js +40 -0
- package/build/asyncRequire/loadBundlePolyfill.js.map +1 -0
- package/build/effects.d.ts +2 -0
- package/build/effects.d.ts.map +1 -0
- package/build/effects.js +16 -0
- package/build/effects.js.map +1 -0
- package/build/effects.native.d.ts +1 -0
- package/build/effects.native.d.ts.map +1 -0
- package/build/effects.native.js +1 -0
- package/build/effects.native.js.map +1 -0
- package/build/error-overlay/Data/LogBoxData.d.ts +60 -0
- package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -0
- package/build/error-overlay/Data/LogBoxData.js +386 -0
- package/build/error-overlay/Data/LogBoxData.js.map +1 -0
- package/build/error-overlay/Data/LogBoxLog.d.ts +61 -0
- package/build/error-overlay/Data/LogBoxLog.d.ts.map +1 -0
- package/build/error-overlay/Data/LogBoxLog.js +148 -0
- package/build/error-overlay/Data/LogBoxLog.js.map +1 -0
- package/build/error-overlay/Data/LogBoxSymbolication.d.ts +17 -0
- package/build/error-overlay/Data/LogBoxSymbolication.d.ts.map +1 -0
- package/build/error-overlay/Data/LogBoxSymbolication.js +56 -0
- package/build/error-overlay/Data/LogBoxSymbolication.js.map +1 -0
- package/build/error-overlay/Data/LogContext.d.ts +14 -0
- package/build/error-overlay/Data/LogContext.d.ts.map +1 -0
- package/build/error-overlay/Data/LogContext.js +27 -0
- package/build/error-overlay/Data/LogContext.js.map +1 -0
- package/build/error-overlay/Data/parseLogBoxLog.d.ts +45 -0
- package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -0
- package/build/error-overlay/Data/parseLogBoxLog.js +286 -0
- package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -0
- package/build/error-overlay/ErrorOverlay.d.ts +18 -0
- package/build/error-overlay/ErrorOverlay.d.ts.map +1 -0
- package/build/error-overlay/ErrorOverlay.js +146 -0
- package/build/error-overlay/ErrorOverlay.js.map +1 -0
- package/build/error-overlay/LogBox.d.ts +16 -0
- package/build/error-overlay/LogBox.d.ts.map +1 -0
- package/build/error-overlay/LogBox.js +31 -0
- package/build/error-overlay/LogBox.js.map +1 -0
- package/build/error-overlay/LogBox.web.d.ts +23 -0
- package/build/error-overlay/LogBox.web.d.ts.map +1 -0
- package/build/error-overlay/LogBox.web.js +129 -0
- package/build/error-overlay/LogBox.web.js.map +1 -0
- package/build/error-overlay/UI/AnsiHighlight.d.ts +6 -0
- package/build/error-overlay/UI/AnsiHighlight.d.ts.map +1 -0
- package/build/error-overlay/UI/AnsiHighlight.js +86 -0
- package/build/error-overlay/UI/AnsiHighlight.js.map +1 -0
- package/build/error-overlay/UI/LogBoxButton.d.ts +14 -0
- package/build/error-overlay/UI/LogBoxButton.d.ts.map +1 -0
- package/build/error-overlay/UI/LogBoxButton.js +59 -0
- package/build/error-overlay/UI/LogBoxButton.js.map +1 -0
- package/build/error-overlay/UI/LogBoxMessage.d.ts +11 -0
- package/build/error-overlay/UI/LogBoxMessage.d.ts.map +1 -0
- package/build/error-overlay/UI/LogBoxMessage.js +53 -0
- package/build/error-overlay/UI/LogBoxMessage.js.map +1 -0
- package/build/error-overlay/UI/LogBoxStyle.d.ts +22 -0
- package/build/error-overlay/UI/LogBoxStyle.d.ts.map +1 -0
- package/build/error-overlay/UI/LogBoxStyle.js +68 -0
- package/build/error-overlay/UI/LogBoxStyle.js.map +1 -0
- package/build/error-overlay/UI/constants.d.ts +2 -0
- package/build/error-overlay/UI/constants.d.ts.map +1 -0
- package/build/error-overlay/UI/constants.js +10 -0
- package/build/error-overlay/UI/constants.js.map +1 -0
- package/build/error-overlay/formatProjectFilePath.d.ts +2 -0
- package/build/error-overlay/formatProjectFilePath.d.ts.map +1 -0
- package/build/error-overlay/formatProjectFilePath.js +27 -0
- package/build/error-overlay/formatProjectFilePath.js.map +1 -0
- package/build/error-overlay/index.d.ts +3 -0
- package/build/error-overlay/index.d.ts.map +1 -0
- package/build/error-overlay/index.js +30 -0
- package/build/error-overlay/index.js.map +1 -0
- package/build/error-overlay/modules/ExceptionsManager/index.d.ts +38 -0
- package/build/error-overlay/modules/ExceptionsManager/index.d.ts.map +1 -0
- package/build/error-overlay/modules/ExceptionsManager/index.js +80 -0
- package/build/error-overlay/modules/ExceptionsManager/index.js.map +1 -0
- package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts +2 -0
- package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts.map +1 -0
- package/build/error-overlay/modules/ExceptionsManager/index.native.js +3 -0
- package/build/error-overlay/modules/ExceptionsManager/index.native.js.map +1 -0
- package/build/error-overlay/modules/NativeLogBox/index.d.ts +6 -0
- package/build/error-overlay/modules/NativeLogBox/index.d.ts.map +1 -0
- package/build/error-overlay/modules/NativeLogBox/index.js +34 -0
- package/build/error-overlay/modules/NativeLogBox/index.js.map +1 -0
- package/build/error-overlay/modules/NativeLogBox/index.native.d.ts +3 -0
- package/build/error-overlay/modules/NativeLogBox/index.native.d.ts.map +1 -0
- package/build/error-overlay/modules/NativeLogBox/index.native.js +8 -0
- package/build/error-overlay/modules/NativeLogBox/index.native.js.map +1 -0
- package/build/error-overlay/modules/openFileInEditor/index.d.ts +3 -0
- package/build/error-overlay/modules/openFileInEditor/index.d.ts.map +1 -0
- package/build/error-overlay/modules/openFileInEditor/index.js +15 -0
- package/build/error-overlay/modules/openFileInEditor/index.js.map +1 -0
- package/build/error-overlay/modules/openFileInEditor/index.native.d.ts +3 -0
- package/build/error-overlay/modules/openFileInEditor/index.native.d.ts.map +1 -0
- package/build/error-overlay/modules/openFileInEditor/index.native.js +8 -0
- package/build/error-overlay/modules/openFileInEditor/index.native.js.map +1 -0
- package/build/error-overlay/modules/parseErrorStack/index.d.ts +6 -0
- package/build/error-overlay/modules/parseErrorStack/index.d.ts.map +1 -0
- package/build/error-overlay/modules/parseErrorStack/index.js +25 -0
- package/build/error-overlay/modules/parseErrorStack/index.js.map +1 -0
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts +3 -0
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts.map +1 -0
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js +9 -0
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js.map +1 -0
- package/build/error-overlay/modules/stringifySafe/index.d.ts +20 -0
- package/build/error-overlay/modules/stringifySafe/index.d.ts.map +1 -0
- package/build/error-overlay/modules/stringifySafe/index.js +117 -0
- package/build/error-overlay/modules/stringifySafe/index.js.map +1 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts +24 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts.map +1 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.js +19 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.js.map +1 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts +3 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts.map +1 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js +8 -0
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts +5 -0
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +113 -0
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts +7 -0
- package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js +111 -0
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts +8 -0
- package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js +139 -0
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts +12 -0
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js +116 -0
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts +8 -0
- package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorSection.js +70 -0
- package/build/error-overlay/overlay/LogBoxInspectorSection.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts +8 -0
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js +127 -0
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts +11 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js +103 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts +10 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +177 -0
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js.map +1 -0
- package/build/error-overlay/toast/ErrorToast.d.ts +11 -0
- package/build/error-overlay/toast/ErrorToast.d.ts.map +1 -0
- package/build/error-overlay/toast/ErrorToast.js +147 -0
- package/build/error-overlay/toast/ErrorToast.js.map +1 -0
- package/build/error-overlay/toast/ErrorToastContainer.d.ts +4 -0
- package/build/error-overlay/toast/ErrorToastContainer.d.ts.map +1 -0
- package/build/error-overlay/toast/ErrorToastContainer.js +7 -0
- package/build/error-overlay/toast/ErrorToastContainer.js.map +1 -0
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts +12 -0
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts.map +1 -0
- package/build/error-overlay/toast/ErrorToastContainer.web.js +83 -0
- package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -0
- package/build/error-overlay/toast/ErrorToastMessage.d.ts +5 -0
- package/build/error-overlay/toast/ErrorToastMessage.d.ts.map +1 -0
- package/build/error-overlay/toast/ErrorToastMessage.js +50 -0
- package/build/error-overlay/toast/ErrorToastMessage.js.map +1 -0
- package/build/error-overlay/useRejectionHandler.d.ts +3 -0
- package/build/error-overlay/useRejectionHandler.d.ts.map +1 -0
- package/build/error-overlay/useRejectionHandler.js +60 -0
- package/build/error-overlay/useRejectionHandler.js.map +1 -0
- package/build/getDevServer.d.ts +8 -0
- package/build/getDevServer.d.ts.map +1 -0
- package/build/getDevServer.js +37 -0
- package/build/getDevServer.js.map +1 -0
- package/build/getDevServer.native.d.ts +1 -0
- package/build/getDevServer.native.d.ts.map +1 -0
- package/build/getDevServer.native.js +2 -0
- package/build/getDevServer.native.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +4 -0
- package/build/index.js.map +1 -0
- package/build/messageSocket.d.ts +3 -0
- package/build/messageSocket.d.ts.map +1 -0
- package/build/messageSocket.js +24 -0
- package/build/messageSocket.js.map +1 -0
- package/build/setupFastRefresh.d.ts +10 -0
- package/build/setupFastRefresh.d.ts.map +1 -0
- package/build/setupFastRefresh.js +23 -0
- package/build/setupFastRefresh.js.map +1 -0
- package/build/setupHMR.d.ts +2 -0
- package/build/setupHMR.d.ts.map +1 -0
- package/build/setupHMR.js +14 -0
- package/build/setupHMR.js.map +1 -0
- package/error-overlay.d.ts +1 -0
- package/error-overlay.js +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
BSD-3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Evan Bacon
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
8
|
+
|
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
10
|
+
|
|
11
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
12
|
+
|
|
13
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/close.png
ADDED
|
Binary file
|
|
Binary file
|
package/asyncRequire.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./build/asyncRequire");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare type LogLevel = "trace" | "info" | "warn" | "error" | "log" | "group" | "groupCollapsed" | "groupEnd" | "debug";
|
|
2
|
+
export declare type HMRClientNativeInterface = {
|
|
3
|
+
enable(): void;
|
|
4
|
+
disable(): void;
|
|
5
|
+
registerBundle(requestUrl: string): void;
|
|
6
|
+
log(level: LogLevel, data: any[]): void;
|
|
7
|
+
setup(props: {
|
|
8
|
+
isEnabled: boolean;
|
|
9
|
+
}): void;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* HMR Client that receives from the server HMR updates and propagates them
|
|
13
|
+
* runtime to reflects those changes.
|
|
14
|
+
*/
|
|
15
|
+
declare const HMRClient: HMRClientNativeInterface;
|
|
16
|
+
export default HMRClient;
|
|
17
|
+
//# sourceMappingURL=HMRClient.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) Evan Bacon.
|
|
8
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
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
|
+
* Based on this but with web support:
|
|
14
|
+
* https://github.com/facebook/react-native/blob/086714b02b0fb838dee5a66c5bcefe73b53cf3df/Libraries/Utilities/HMRClient.js
|
|
15
|
+
*/
|
|
16
|
+
const pretty_format_1 = __importDefault(require("pretty-format"));
|
|
17
|
+
const LoadingView_1 = __importDefault(require("./LoadingView"));
|
|
18
|
+
const LogBox_1 = __importDefault(require("./error-overlay/LogBox"));
|
|
19
|
+
const getDevServer_1 = __importDefault(require("./getDevServer"));
|
|
20
|
+
const MetroHMRClient = require("metro-runtime/src/modules/HMRClient");
|
|
21
|
+
const pendingEntryPoints = [];
|
|
22
|
+
let hmrClient = null;
|
|
23
|
+
let hmrUnavailableReason = null;
|
|
24
|
+
let currentCompileErrorMessage = null;
|
|
25
|
+
let didConnect = false;
|
|
26
|
+
const pendingLogs = [];
|
|
27
|
+
function assert(foo, msg) {
|
|
28
|
+
if (!foo)
|
|
29
|
+
throw new Error(msg);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* HMR Client that receives from the server HMR updates and propagates them
|
|
33
|
+
* runtime to reflects those changes.
|
|
34
|
+
*/
|
|
35
|
+
const HMRClient = {
|
|
36
|
+
enable() {
|
|
37
|
+
if (hmrUnavailableReason !== null) {
|
|
38
|
+
// If HMR became unavailable while you weren't using it,
|
|
39
|
+
// explain why when you try to turn it on.
|
|
40
|
+
// This is an error (and not a warning) because it is shown
|
|
41
|
+
// in response to a direct user action.
|
|
42
|
+
throw new Error(hmrUnavailableReason);
|
|
43
|
+
}
|
|
44
|
+
assert(hmrClient, "Expected HMRClient.setup() call at startup.");
|
|
45
|
+
// We use this for internal logging only.
|
|
46
|
+
// It doesn't affect the logic.
|
|
47
|
+
hmrClient.send(JSON.stringify({ type: "log-opt-in" }));
|
|
48
|
+
// When toggling Fast Refresh on, we might already have some stashed updates.
|
|
49
|
+
// Since they'll get applied now, we'll show a banner.
|
|
50
|
+
const hasUpdates = hmrClient.hasPendingUpdates();
|
|
51
|
+
if (hasUpdates) {
|
|
52
|
+
LoadingView_1.default.showMessage("Refreshing...", "refresh");
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
hmrClient.enable();
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
if (hasUpdates) {
|
|
59
|
+
LoadingView_1.default.hide();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// There could be a compile error while Fast Refresh was off,
|
|
63
|
+
// but we ignored it at the time. Show it now.
|
|
64
|
+
showCompileError();
|
|
65
|
+
},
|
|
66
|
+
disable() {
|
|
67
|
+
assert(hmrClient, "Expected HMRClient.setup() call at startup.");
|
|
68
|
+
hmrClient.disable();
|
|
69
|
+
},
|
|
70
|
+
registerBundle(requestUrl) {
|
|
71
|
+
assert(hmrClient, "Expected HMRClient.setup() call at startup.");
|
|
72
|
+
pendingEntryPoints.push(requestUrl);
|
|
73
|
+
registerBundleEntryPoints(hmrClient);
|
|
74
|
+
},
|
|
75
|
+
log(level, data) {
|
|
76
|
+
if (!hmrClient) {
|
|
77
|
+
// Catch a reasonable number of early logs
|
|
78
|
+
// in case hmrClient gets initialized later.
|
|
79
|
+
pendingLogs.push([level, data]);
|
|
80
|
+
if (pendingLogs.length > 100) {
|
|
81
|
+
pendingLogs.shift();
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
hmrClient.send(JSON.stringify({
|
|
87
|
+
type: "log",
|
|
88
|
+
level,
|
|
89
|
+
mode: global.RN$Bridgeless === true ? "NOBRIDGE" : "BRIDGE",
|
|
90
|
+
data: data.map((item) => typeof item === "string"
|
|
91
|
+
? item
|
|
92
|
+
: (0, pretty_format_1.default)(item, {
|
|
93
|
+
escapeString: true,
|
|
94
|
+
highlight: true,
|
|
95
|
+
maxDepth: 3,
|
|
96
|
+
min: true,
|
|
97
|
+
plugins: [pretty_format_1.default.plugins.ReactElement],
|
|
98
|
+
})),
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// If sending logs causes any failures we want to silently ignore them
|
|
103
|
+
// to ensure we do not cause infinite-logging loops.
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
// Called once by the bridge on startup, even if Fast Refresh is off.
|
|
107
|
+
// It creates the HMR client but doesn't actually set up the socket yet.
|
|
108
|
+
setup({ isEnabled }) {
|
|
109
|
+
assert(!hmrClient, "Cannot initialize hmrClient twice");
|
|
110
|
+
const serverScheme = window.location.protocol === "https:" ? "wss" : "ws";
|
|
111
|
+
const client = new MetroHMRClient(`${serverScheme}://${window.location.host}/hot`);
|
|
112
|
+
hmrClient = client;
|
|
113
|
+
const { fullBundleUrl } = (0, getDevServer_1.default)();
|
|
114
|
+
pendingEntryPoints.push(
|
|
115
|
+
// HMRServer understands regular bundle URLs, so prefer that in case
|
|
116
|
+
// there are any important URL parameters we can't reconstruct from
|
|
117
|
+
// `setup()`'s arguments.
|
|
118
|
+
fullBundleUrl);
|
|
119
|
+
client.on("connection-error", (e) => {
|
|
120
|
+
let error = `Cannot connect to Metro.
|
|
121
|
+
|
|
122
|
+
Try the following to fix the issue:
|
|
123
|
+
- Ensure the Metro dev server is running and available on the same network as this device`;
|
|
124
|
+
error += `
|
|
125
|
+
|
|
126
|
+
URL: ${window.location.host}
|
|
127
|
+
|
|
128
|
+
Error: ${e.message}`;
|
|
129
|
+
setHMRUnavailableReason(error);
|
|
130
|
+
});
|
|
131
|
+
client.on("update-start", ({ isInitialUpdate }) => {
|
|
132
|
+
currentCompileErrorMessage = null;
|
|
133
|
+
didConnect = true;
|
|
134
|
+
if (client.isEnabled() && !isInitialUpdate) {
|
|
135
|
+
LoadingView_1.default.showMessage("Refreshing...", "refresh");
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
client.on("update", ({ isInitialUpdate }) => {
|
|
139
|
+
if (client.isEnabled() && !isInitialUpdate) {
|
|
140
|
+
dismissRedbox();
|
|
141
|
+
LogBox_1.default.clearAllLogs();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
client.on("update-done", () => {
|
|
145
|
+
LoadingView_1.default.hide();
|
|
146
|
+
});
|
|
147
|
+
client.on("error", (data) => {
|
|
148
|
+
LoadingView_1.default.hide();
|
|
149
|
+
if (data.type === "GraphNotFoundError") {
|
|
150
|
+
client.close();
|
|
151
|
+
setHMRUnavailableReason("Metro has restarted since the last edit. Reload to reconnect.");
|
|
152
|
+
}
|
|
153
|
+
else if (data.type === "RevisionNotFoundError") {
|
|
154
|
+
client.close();
|
|
155
|
+
setHMRUnavailableReason("Metro and the client are out of sync. Reload to reconnect.");
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
currentCompileErrorMessage = `${data.type} ${data.message}`;
|
|
159
|
+
if (client.isEnabled()) {
|
|
160
|
+
showCompileError();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
client.on("close", (closeEvent) => {
|
|
165
|
+
LoadingView_1.default.hide();
|
|
166
|
+
// https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1
|
|
167
|
+
// https://www.rfc-editor.org/rfc/rfc6455.html#section-7.1.5
|
|
168
|
+
const isNormalOrUnsetCloseReason = closeEvent == null ||
|
|
169
|
+
closeEvent.code === 1000 ||
|
|
170
|
+
closeEvent.code === 1005 ||
|
|
171
|
+
closeEvent.code == null;
|
|
172
|
+
setHMRUnavailableReason(`${isNormalOrUnsetCloseReason
|
|
173
|
+
? "Disconnected from Metro."
|
|
174
|
+
: `Disconnected from Metro (${closeEvent.code}: "${closeEvent.reason}").`}
|
|
175
|
+
|
|
176
|
+
To reconnect:
|
|
177
|
+
- Ensure that Metro is running and available on the same network
|
|
178
|
+
- Reload this app (will trigger further help if Metro cannot be connected to)
|
|
179
|
+
`);
|
|
180
|
+
});
|
|
181
|
+
if (isEnabled) {
|
|
182
|
+
HMRClient.enable();
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
HMRClient.disable();
|
|
186
|
+
}
|
|
187
|
+
registerBundleEntryPoints(hmrClient);
|
|
188
|
+
flushEarlyLogs();
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
function setHMRUnavailableReason(reason) {
|
|
192
|
+
assert(hmrClient, "Expected HMRClient.setup() call at startup.");
|
|
193
|
+
if (hmrUnavailableReason !== null) {
|
|
194
|
+
// Don't show more than one warning.
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
hmrUnavailableReason = reason;
|
|
198
|
+
// We only want to show a warning if Fast Refresh is on *and* if we ever
|
|
199
|
+
// previously managed to connect successfully. We don't want to show
|
|
200
|
+
// the warning to native engineers who use cached bundles without Metro.
|
|
201
|
+
if (hmrClient.isEnabled() && didConnect) {
|
|
202
|
+
console.warn(reason);
|
|
203
|
+
// (Not using the `warning` module to prevent a Buck cycle.)
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function registerBundleEntryPoints(client) {
|
|
207
|
+
if (hmrUnavailableReason != null) {
|
|
208
|
+
// "Bundle Splitting – Metro disconnected"
|
|
209
|
+
window.location.reload();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (pendingEntryPoints.length > 0) {
|
|
213
|
+
client.send(JSON.stringify({
|
|
214
|
+
type: "register-entrypoints",
|
|
215
|
+
entryPoints: pendingEntryPoints,
|
|
216
|
+
}));
|
|
217
|
+
pendingEntryPoints.length = 0;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
function flushEarlyLogs() {
|
|
221
|
+
try {
|
|
222
|
+
pendingLogs.forEach(([level, data]) => {
|
|
223
|
+
HMRClient.log(level, data);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
pendingLogs.length = 0;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function dismissRedbox() {
|
|
231
|
+
// TODO(EvanBacon): Error overlay for web.
|
|
232
|
+
}
|
|
233
|
+
function showCompileError() {
|
|
234
|
+
if (currentCompileErrorMessage === null) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
// Even if there is already a redbox, syntax errors are more important.
|
|
238
|
+
// Otherwise you risk seeing a stale runtime error while a syntax error is more recent.
|
|
239
|
+
dismissRedbox();
|
|
240
|
+
const message = currentCompileErrorMessage;
|
|
241
|
+
currentCompileErrorMessage = null;
|
|
242
|
+
const error = new Error(message);
|
|
243
|
+
// Symbolicating compile errors is wasted effort
|
|
244
|
+
// because the stack trace is meaningless:
|
|
245
|
+
// @ts-expect-error
|
|
246
|
+
error.preventSymbolication = true;
|
|
247
|
+
throw error;
|
|
248
|
+
}
|
|
249
|
+
exports.default = HMRClient;
|
|
250
|
+
//# sourceMappingURL=HMRClient.js.map
|
|
@@ -0,0 +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,CAAC,oBAAoB,CAAC,CAAC;SACvC;QAED,MAAM,CAAC,SAAS,EAAE,6CAA6C,CAAC,CAAC;QAEjE,yCAAyC;QACzC,+BAA+B;QAC/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,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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=HMRClient.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HMRClient.native.d.ts","sourceRoot":"","sources":["../src/HMRClient.native.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare function showMessage(message: string, type: "load" | "refresh"): void;
|
|
2
|
+
declare function hide(): void;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
showMessage: typeof showMessage;
|
|
5
|
+
hide: typeof hide;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
//# sourceMappingURL=LoadingView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingView.d.ts","sourceRoot":"","sources":["../src/LoadingView.ts"],"names":[],"mappings":"AAGA,iBAAS,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,QAI7D;AAED,iBAAS,IAAI,SAEZ;;;;;AAOD,wBAGE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const expo_modules_core_1 = require("expo-modules-core");
|
|
4
|
+
// Ensure events are sent so custom Fast Refresh views are shown.
|
|
5
|
+
function showMessage(message, type) {
|
|
6
|
+
expo_modules_core_1.SyntheticPlatformEmitter.emit("devLoadingView:showMessage", {
|
|
7
|
+
message,
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function hide() {
|
|
11
|
+
expo_modules_core_1.SyntheticPlatformEmitter.emit("devLoadingView:hide", {});
|
|
12
|
+
}
|
|
13
|
+
module.exports = {
|
|
14
|
+
showMessage,
|
|
15
|
+
hide,
|
|
16
|
+
};
|
|
17
|
+
exports.default = {
|
|
18
|
+
showMessage,
|
|
19
|
+
hide,
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=LoadingView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingView.js","sourceRoot":"","sources":["../src/LoadingView.ts"],"names":[],"mappings":";;AAAA,yDAA6D;AAE7D,iEAAiE;AACjE,SAAS,WAAW,CAAC,OAAe,EAAE,IAAwB;IAC5D,4CAAwB,CAAC,IAAI,CAAC,4BAA4B,EAAE;QAC1D,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAED,SAAS,IAAI;IACX,4CAAwB,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACf,WAAW;IACX,IAAI;CACL,CAAC;AAEF,kBAAe;IACb,WAAW;IACX,IAAI;CACL,CAAC","sourcesContent":["import { SyntheticPlatformEmitter } from \"expo-modules-core\";\n\n// Ensure events are sent so custom Fast Refresh views are shown.\nfunction showMessage(message: string, type: \"load\" | \"refresh\") {\n SyntheticPlatformEmitter.emit(\"devLoadingView:showMessage\", {\n message,\n });\n}\n\nfunction hide() {\n SyntheticPlatformEmitter.emit(\"devLoadingView:hide\", {});\n}\n\nmodule.exports = {\n showMessage,\n hide,\n};\n\nexport default {\n showMessage,\n hide,\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=LoadingView.native.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingView.native.d.ts","sourceRoot":"","sources":["../src/LoadingView.native.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare type MetroRequire = {
|
|
2
|
+
(id: number): any;
|
|
3
|
+
importAll: (id: number) => any;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Must satisfy the requirements of the Metro bundler.
|
|
7
|
+
* https://github.com/facebook/metro/blob/f9fe277986ff7e7e53ae0418040f3aa1eb1c7056/packages/metro/src/ModuleGraph/worker/collectDependencies.js#L629-L639
|
|
8
|
+
*
|
|
9
|
+
* And https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/getAppendScripts.js#L54-L56
|
|
10
|
+
*/
|
|
11
|
+
declare type AsyncRequire = {
|
|
12
|
+
<TModule>(moduleID: number, moduleName?: string, options?: {
|
|
13
|
+
isPrefetchOnly: boolean;
|
|
14
|
+
}): Promise<TModule | void> | TModule;
|
|
15
|
+
prefetch(moduleID: number, moduleName: string): void;
|
|
16
|
+
/** 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;
|
|
20
|
+
};
|
|
21
|
+
/** Create an `asyncRequire` function in the expected shape for Metro bundler. */
|
|
22
|
+
export declare function buildAsyncRequire(metroRequire: MetroRequire): AsyncRequire;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=buildAsyncRequire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildAsyncRequire.d.ts","sourceRoot":"","sources":["../../src/asyncRequire/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,CAmE1E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildAsyncRequire = void 0;
|
|
4
|
+
const loadBundle_1 = require("./loadBundle");
|
|
5
|
+
/** Create an `asyncRequire` function in the expected shape for Metro bundler. */
|
|
6
|
+
function buildAsyncRequire(metroRequire) {
|
|
7
|
+
const importBundleNames = Object.create(null);
|
|
8
|
+
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
|
+
if (options.isPrefetchOnly) {
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
}
|
|
17
|
+
const stringModuleID = String(moduleID);
|
|
18
|
+
const bundlePath = getBundlePath(stringModuleID);
|
|
19
|
+
if (bundlePath) {
|
|
20
|
+
// Prevent loading the same module more than once.
|
|
21
|
+
if (!importBundlePromises[stringModuleID]) {
|
|
22
|
+
importBundlePromises[stringModuleID] = (0, loadBundle_1.loadBundleAsync)(bundlePath).then(() => metroRequire(moduleID));
|
|
23
|
+
}
|
|
24
|
+
// Return for the user to resolve.
|
|
25
|
+
return importBundlePromises[stringModuleID];
|
|
26
|
+
}
|
|
27
|
+
return metroRequire.importAll(moduleID);
|
|
28
|
+
}
|
|
29
|
+
asyncRequire.prefetch = function (moduleID, moduleName) {
|
|
30
|
+
const result = asyncRequire(moduleID, moduleName, { isPrefetchOnly: true });
|
|
31
|
+
if (result instanceof Promise) {
|
|
32
|
+
result.then(() => { }, () => { });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
asyncRequire.resource = function (moduleID, moduleName) {
|
|
36
|
+
throw new Error("Unimplemented Metro runtime feature");
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Register modules that can be loaded async.
|
|
40
|
+
* Key is a numeric string and value is a string denoting the bundle path.
|
|
41
|
+
*
|
|
42
|
+
* @example { '1': 'Second' }
|
|
43
|
+
*/
|
|
44
|
+
asyncRequire.addImportBundleNames = function (names) {
|
|
45
|
+
Object.assign(importBundleNames, names);
|
|
46
|
+
};
|
|
47
|
+
return asyncRequire;
|
|
48
|
+
}
|
|
49
|
+
exports.buildAsyncRequire = buildAsyncRequire;
|
|
50
|
+
//# sourceMappingURL=buildAsyncRequire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildAsyncRequire.js","sourceRoot":"","sources":["../../src/asyncRequire/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,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;AAnED,8CAmEC","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 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"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given a path and some optional additional query parameters, create the dev server bundle URL.
|
|
3
|
+
* @param bundlePath like `/foobar`
|
|
4
|
+
* @param params like `{ platform: "web" }`
|
|
5
|
+
* @returns a URL like "/foobar.bundle?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null"
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildUrlForBundle(bundlePath: string, params?: Record<string, string | null>): string;
|
|
8
|
+
//# sourceMappingURL=buildUrlForBundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUrlForBundle.d.ts","sourceRoot":"","sources":["../../src/asyncRequire/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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildUrlForBundle = void 0;
|
|
7
|
+
const qs_1 = __importDefault(require("qs"));
|
|
8
|
+
/**
|
|
9
|
+
* Given a path and some optional additional query parameters, create the dev server bundle URL.
|
|
10
|
+
* @param bundlePath like `/foobar`
|
|
11
|
+
* @param params like `{ platform: "web" }`
|
|
12
|
+
* @returns a URL like "/foobar.bundle?platform=android&modulesOnly=true&runModule=false&runtimeBytecodeVersion=null"
|
|
13
|
+
*/
|
|
14
|
+
function buildUrlForBundle(bundlePath, params = {}) {
|
|
15
|
+
// NOTE(EvanBacon): This must come from the window origin (at least in dev mode).
|
|
16
|
+
// Otherwise Metro will crash from attempting to load a bundle that doesn't exist.
|
|
17
|
+
let url = "";
|
|
18
|
+
if (!bundlePath.startsWith("/")) {
|
|
19
|
+
url += "/";
|
|
20
|
+
}
|
|
21
|
+
const query = qs_1.default.stringify(params);
|
|
22
|
+
return url + bundlePath + ".bundle" + (query ? "?" + query : "");
|
|
23
|
+
}
|
|
24
|
+
exports.buildUrlForBundle = buildUrlForBundle;
|
|
25
|
+
//# sourceMappingURL=buildUrlForBundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUrlForBundle.js","sourceRoot":"","sources":["../../src/asyncRequire/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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUrlForBundle.native.d.ts","sourceRoot":"","sources":["../../src/asyncRequire/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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildUrlForBundle = void 0;
|
|
7
|
+
const qs_1 = __importDefault(require("qs"));
|
|
8
|
+
const getDevServer_1 = __importDefault(require("../getDevServer"));
|
|
9
|
+
function buildUrlForBundle(bundlePath, params = {}) {
|
|
10
|
+
const { fullBundleUrl, url: serverUrl, bundleLoadedFromServer, } = (0, getDevServer_1.default)();
|
|
11
|
+
if (!bundleLoadedFromServer) {
|
|
12
|
+
throw new Error("This bundle was compiled with 'transformer.experimentalImportBundleSupport' in the 'metro.config.js' and can only be used when connected to a Metro server.");
|
|
13
|
+
}
|
|
14
|
+
let query = {};
|
|
15
|
+
if (fullBundleUrl != null) {
|
|
16
|
+
const queryStart = fullBundleUrl.indexOf("?");
|
|
17
|
+
if (queryStart !== -1) {
|
|
18
|
+
query = qs_1.default.parse(fullBundleUrl.substring(queryStart + 1));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
Object.assign(query, params);
|
|
22
|
+
return serverUrl + bundlePath + ".bundle?" + qs_1.default.stringify(query);
|
|
23
|
+
}
|
|
24
|
+
exports.buildUrlForBundle = buildUrlForBundle;
|
|
25
|
+
//# sourceMappingURL=buildUrlForBundle.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildUrlForBundle.native.js","sourceRoot":"","sources":["../../src/asyncRequire/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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAsync.d.ts","sourceRoot":"","sources":["../../src/asyncRequire/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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchAsync = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
async function fetchAsync(url) {
|
|
6
|
+
const response = await fetch(url, {
|
|
7
|
+
method: "GET",
|
|
8
|
+
headers: {
|
|
9
|
+
// No real reason for this but we try to use this format for everything.
|
|
10
|
+
"expo-platform": react_native_1.Platform.OS,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
return {
|
|
14
|
+
body: await response.text(),
|
|
15
|
+
headers: response.headers,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.fetchAsync = fetchAsync;
|
|
19
|
+
//# sourceMappingURL=fetchAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAsync.js","sourceRoot":"","sources":["../../src/asyncRequire/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"]}
|