@expo/metro-runtime 2.2.7 → 3.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.
- package/README.md +17 -1
- package/async-require.d.ts +1 -1
- package/async-require.js +1 -1
- package/build/HMRClient.d.ts +1 -1
- package/build/HMRClient.d.ts.map +1 -1
- package/build/HMRClient.js +27 -27
- package/build/HMRClient.js.map +1 -1
- package/build/HMRClient.native.js +1 -1
- package/build/HMRClient.native.js.map +1 -1
- package/build/LoadingView.d.ts +1 -1
- package/build/LoadingView.d.ts.map +1 -1
- package/build/LoadingView.js +2 -6
- package/build/LoadingView.js.map +1 -1
- package/build/LoadingView.native.d.ts +2 -0
- package/build/LoadingView.native.d.ts.map +1 -1
- package/build/LoadingView.native.js +6 -1
- package/build/LoadingView.native.js.map +1 -1
- package/build/async-require/buildAsyncRequire.js.map +1 -1
- package/build/async-require/buildUrlForBundle.js +1 -1
- package/build/async-require/buildUrlForBundle.js.map +1 -1
- package/build/async-require/buildUrlForBundle.native.js +5 -4
- package/build/async-require/buildUrlForBundle.native.js.map +1 -1
- package/build/async-require/fetchAsync.d.ts.map +1 -1
- package/build/async-require/fetchAsync.js +2 -2
- package/build/async-require/fetchAsync.js.map +1 -1
- package/build/async-require/fetchAsync.native.d.ts +1 -1
- package/build/async-require/fetchAsync.native.d.ts.map +1 -1
- package/build/async-require/fetchAsync.native.js +10 -10
- package/build/async-require/fetchAsync.native.js.map +1 -1
- package/build/async-require/fetchThenEval.d.ts.map +1 -1
- package/build/async-require/fetchThenEval.js +2 -3
- package/build/async-require/fetchThenEval.js.map +1 -1
- package/build/async-require/fetchThenEval.web.d.ts.map +1 -1
- package/build/async-require/fetchThenEval.web.js +13 -22
- package/build/async-require/fetchThenEval.web.js.map +1 -1
- package/build/async-require/index.js +1 -3
- package/build/async-require/index.js.map +1 -1
- package/build/async-require/loadBundle.d.ts.map +1 -1
- package/build/async-require/loadBundle.js +8 -8
- package/build/async-require/loadBundle.js.map +1 -1
- package/build/effects.js +10 -10
- package/build/effects.js.map +1 -1
- package/build/effects.native.js +0 -1
- package/build/error-overlay/Data/LogBoxData.d.ts +5 -5
- package/build/error-overlay/Data/LogBoxData.d.ts.map +1 -1
- package/build/error-overlay/Data/LogBoxData.js +46 -48
- package/build/error-overlay/Data/LogBoxData.js.map +1 -1
- package/build/error-overlay/Data/LogBoxLog.d.ts +10 -10
- package/build/error-overlay/Data/LogBoxLog.d.ts.map +1 -1
- package/build/error-overlay/Data/LogBoxLog.js +44 -40
- package/build/error-overlay/Data/LogBoxLog.js.map +1 -1
- package/build/error-overlay/Data/LogBoxSymbolication.d.ts +2 -2
- package/build/error-overlay/Data/LogBoxSymbolication.js +5 -5
- package/build/error-overlay/Data/LogBoxSymbolication.js.map +1 -1
- package/build/error-overlay/Data/LogContext.d.ts +2 -2
- package/build/error-overlay/Data/LogContext.d.ts.map +1 -1
- package/build/error-overlay/Data/LogContext.js +4 -4
- package/build/error-overlay/Data/LogContext.js.map +1 -1
- package/build/error-overlay/Data/parseLogBoxLog.d.ts +2 -2
- package/build/error-overlay/Data/parseLogBoxLog.d.ts.map +1 -1
- package/build/error-overlay/Data/parseLogBoxLog.js +26 -31
- package/build/error-overlay/Data/parseLogBoxLog.js.map +1 -1
- package/build/error-overlay/ErrorOverlay.d.ts +10 -3
- package/build/error-overlay/ErrorOverlay.d.ts.map +1 -1
- package/build/error-overlay/ErrorOverlay.js +22 -21
- package/build/error-overlay/ErrorOverlay.js.map +1 -1
- package/build/error-overlay/LogBox.d.ts +2 -2
- package/build/error-overlay/LogBox.d.ts.map +1 -1
- package/build/error-overlay/LogBox.js +0 -1
- package/build/error-overlay/LogBox.js.map +1 -1
- package/build/error-overlay/LogBox.web.d.ts +3 -3
- package/build/error-overlay/LogBox.web.d.ts.map +1 -1
- package/build/error-overlay/LogBox.web.js +9 -12
- package/build/error-overlay/LogBox.web.js.map +1 -1
- package/build/error-overlay/UI/AnsiHighlight.d.ts +2 -2
- package/build/error-overlay/UI/AnsiHighlight.d.ts.map +1 -1
- package/build/error-overlay/UI/AnsiHighlight.js +21 -22
- package/build/error-overlay/UI/AnsiHighlight.js.map +1 -1
- package/build/error-overlay/UI/LogBoxButton.d.ts +1 -1
- package/build/error-overlay/UI/LogBoxButton.d.ts.map +1 -1
- package/build/error-overlay/UI/LogBoxButton.js +3 -5
- package/build/error-overlay/UI/LogBoxButton.js.map +1 -1
- package/build/error-overlay/UI/LogBoxMessage.d.ts +2 -2
- package/build/error-overlay/UI/LogBoxMessage.d.ts.map +1 -1
- package/build/error-overlay/UI/LogBoxMessage.js +4 -4
- package/build/error-overlay/UI/LogBoxMessage.js.map +1 -1
- package/build/error-overlay/UI/LogBoxStyle.d.ts +1 -1
- package/build/error-overlay/UI/LogBoxStyle.js +1 -1
- package/build/error-overlay/UI/LogBoxStyle.js.map +1 -1
- package/build/error-overlay/UI/constants.js +3 -3
- package/build/error-overlay/UI/constants.js.map +1 -1
- package/build/error-overlay/formatProjectFilePath.d.ts +1 -1
- package/build/error-overlay/formatProjectFilePath.d.ts.map +1 -1
- package/build/error-overlay/formatProjectFilePath.js +5 -7
- package/build/error-overlay/formatProjectFilePath.js.map +1 -1
- package/build/error-overlay/index.d.ts +1 -1
- package/build/error-overlay/index.d.ts.map +1 -1
- package/build/error-overlay/index.js +6 -5
- package/build/error-overlay/index.js.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.d.ts +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.d.ts.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.js +9 -14
- package/build/error-overlay/modules/ExceptionsManager/index.js.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts +2 -1
- package/build/error-overlay/modules/ExceptionsManager/index.native.d.ts.map +1 -1
- package/build/error-overlay/modules/ExceptionsManager/index.native.js +7 -2
- package/build/error-overlay/modules/ExceptionsManager/index.native.js.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.d.ts.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.js +5 -5
- package/build/error-overlay/modules/NativeLogBox/index.js.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.native.d.ts +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.native.d.ts.map +1 -1
- package/build/error-overlay/modules/NativeLogBox/index.native.js +0 -1
- package/build/error-overlay/modules/NativeLogBox/index.native.js.map +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.js +4 -4
- package/build/error-overlay/modules/openFileInEditor/index.js.map +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.native.d.ts +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.native.d.ts.map +1 -1
- package/build/error-overlay/modules/openFileInEditor/index.native.js +0 -1
- package/build/error-overlay/modules/openFileInEditor/index.native.js.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/index.d.ts +1 -1
- package/build/error-overlay/modules/parseErrorStack/index.d.ts.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/index.js +5 -5
- package/build/error-overlay/modules/parseErrorStack/index.js.map +1 -1
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.d.ts +1 -1
- package/build/error-overlay/modules/parseErrorStack/parseHermesStack.js.map +1 -1
- package/build/error-overlay/modules/stringifySafe/index.d.ts +1 -1
- package/build/error-overlay/modules/stringifySafe/index.d.ts.map +1 -1
- package/build/error-overlay/modules/stringifySafe/index.js +14 -16
- package/build/error-overlay/modules/stringifySafe/index.js.map +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts +2 -2
- package/build/error-overlay/modules/symbolicateStackTrace/index.d.ts.map +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.js +5 -5
- package/build/error-overlay/modules/symbolicateStackTrace/index.js.map +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.d.ts +1 -1
- package/build/error-overlay/modules/symbolicateStackTrace/index.native.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js +10 -11
- package/build/error-overlay/overlay/LogBoxInspectorCodeFrame.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorFooter.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js +27 -24
- package/build/error-overlay/overlay/LogBoxInspectorFooter.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorHeader.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js +18 -18
- package/build/error-overlay/overlay/LogBoxInspectorHeader.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js +6 -6
- package/build/error-overlay/overlay/LogBoxInspectorMessageHeader.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorSection.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorSection.js +4 -4
- package/build/error-overlay/overlay/LogBoxInspectorSection.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js +13 -13
- package/build/error-overlay/overlay/LogBoxInspectorSourceMapStatus.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js +9 -9
- package/build/error-overlay/overlay/LogBoxInspectorStackFrame.js.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts +2 -2
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.d.ts.map +1 -1
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js +24 -27
- package/build/error-overlay/overlay/LogBoxInspectorStackFrames.js.map +1 -1
- package/build/error-overlay/toast/ErrorToast.d.ts +2 -2
- package/build/error-overlay/toast/ErrorToast.d.ts.map +1 -1
- package/build/error-overlay/toast/ErrorToast.js +35 -34
- package/build/error-overlay/toast/ErrorToast.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.d.ts +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts +2 -2
- package/build/error-overlay/toast/ErrorToastContainer.web.d.ts.map +1 -1
- package/build/error-overlay/toast/ErrorToastContainer.web.js +6 -5
- package/build/error-overlay/toast/ErrorToastContainer.web.js.map +1 -1
- package/build/error-overlay/toast/ErrorToastMessage.d.ts +1 -1
- package/build/error-overlay/toast/ErrorToastMessage.d.ts.map +1 -1
- package/build/error-overlay/toast/ErrorToastMessage.js +4 -4
- package/build/error-overlay/toast/ErrorToastMessage.js.map +1 -1
- package/build/error-overlay/useRejectionHandler.d.ts +1 -1
- package/build/error-overlay/useRejectionHandler.d.ts.map +1 -1
- package/build/error-overlay/useRejectionHandler.js +11 -12
- package/build/error-overlay/useRejectionHandler.js.map +1 -1
- package/build/getDevServer.d.ts.map +1 -1
- package/build/getDevServer.js +4 -5
- package/build/getDevServer.js.map +1 -1
- package/build/getDevServer.native.d.ts +2 -0
- package/build/getDevServer.native.d.ts.map +1 -1
- package/build/getDevServer.native.js +6 -1
- package/build/getDevServer.native.js.map +1 -1
- package/build/index.d.ts +1 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -4
- package/build/index.js.map +1 -1
- package/build/location/Location.native.d.ts.map +1 -1
- package/build/location/Location.native.js +21 -20
- package/build/location/Location.native.js.map +1 -1
- package/build/location/install.js +0 -1
- package/build/location/install.native.d.ts +1 -1
- package/build/location/install.native.js +16 -22
- package/build/location/install.native.js.map +1 -1
- package/build/messageSocket.d.ts.map +1 -1
- package/build/messageSocket.js +5 -6
- package/build/messageSocket.js.map +1 -1
- package/build/setupFastRefresh.d.ts.map +1 -1
- package/build/setupFastRefresh.js +2 -4
- package/build/setupFastRefresh.js.map +1 -1
- package/build/setupHMR.js +1 -3
- package/build/setupHMR.js.map +1 -1
- package/build/symbolicate.d.ts +3 -3
- package/build/symbolicate.js.map +1 -1
- package/error-overlay.d.ts +1 -1
- package/error-overlay.js +1 -1
- package/package.json +25 -14
- package/LICENSE +0 -13
package/README.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
1
|
# @expo/metro-runtime
|
|
2
2
|
|
|
3
|
-
Injects runtime code for
|
|
3
|
+
Injects runtime code required for advanced Metro bundling features in the Expo ecosystem.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
> `expo-router` users do not need to install this package, it is already included.
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
yarn add @expo/metro-runtime
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Import this somewhere in the initial bundle. For example, the `App.js`:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import '@expo/metro-config';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`expo/metro-config` will automatically move this import to be first in the bundle.
|
package/async-require.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './build/async-require/index';
|
package/async-require.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require(
|
|
1
|
+
module.exports = require('./build/async-require');
|
package/build/HMRClient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type LogLevel =
|
|
1
|
+
type LogLevel = 'trace' | 'info' | 'warn' | 'error' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';
|
|
2
2
|
export type HMRClientNativeInterface = {
|
|
3
3
|
enable(): void;
|
|
4
4
|
disable(): void;
|
package/build/HMRClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,wBAwLhB,CAAC;AAuEF,eAAe,SAAS,CAAC"}
|
package/build/HMRClient.js
CHANGED
|
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
/**
|
|
30
|
-
* Copyright (c)
|
|
30
|
+
* Copyright (c) 650 Industries.
|
|
31
31
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
32
32
|
*
|
|
33
33
|
* This source code is licensed under the MIT license found in the
|
|
@@ -40,7 +40,7 @@ const pretty_format_1 = __importStar(require("pretty-format"));
|
|
|
40
40
|
const LoadingView_1 = __importDefault(require("./LoadingView"));
|
|
41
41
|
const LogBox_1 = __importDefault(require("./error-overlay/LogBox"));
|
|
42
42
|
const getDevServer_1 = __importDefault(require("./getDevServer"));
|
|
43
|
-
const MetroHMRClient = require(
|
|
43
|
+
const MetroHMRClient = require('metro-runtime/src/modules/HMRClient');
|
|
44
44
|
const pendingEntryPoints = [];
|
|
45
45
|
let hmrClient = null;
|
|
46
46
|
let hmrUnavailableReason = null;
|
|
@@ -64,15 +64,15 @@ const HMRClient = {
|
|
|
64
64
|
// in response to a direct user action.
|
|
65
65
|
throw new Error(hmrUnavailableReason);
|
|
66
66
|
}
|
|
67
|
-
assert(hmrClient,
|
|
67
|
+
assert(hmrClient, 'Expected HMRClient.setup() call at startup.');
|
|
68
68
|
// We use this for internal logging only.
|
|
69
69
|
// It doesn't affect the logic.
|
|
70
|
-
hmrClient.send(JSON.stringify({ type:
|
|
70
|
+
hmrClient.send(JSON.stringify({ type: 'log-opt-in' }));
|
|
71
71
|
// When toggling Fast Refresh on, we might already have some stashed updates.
|
|
72
72
|
// Since they'll get applied now, we'll show a banner.
|
|
73
73
|
const hasUpdates = hmrClient.hasPendingUpdates();
|
|
74
74
|
if (hasUpdates) {
|
|
75
|
-
LoadingView_1.default.showMessage(
|
|
75
|
+
LoadingView_1.default.showMessage('Refreshing...', 'refresh');
|
|
76
76
|
}
|
|
77
77
|
try {
|
|
78
78
|
hmrClient.enable();
|
|
@@ -87,11 +87,11 @@ const HMRClient = {
|
|
|
87
87
|
showCompileError();
|
|
88
88
|
},
|
|
89
89
|
disable() {
|
|
90
|
-
assert(hmrClient,
|
|
90
|
+
assert(hmrClient, 'Expected HMRClient.setup() call at startup.');
|
|
91
91
|
hmrClient.disable();
|
|
92
92
|
},
|
|
93
93
|
registerBundle(requestUrl) {
|
|
94
|
-
assert(hmrClient,
|
|
94
|
+
assert(hmrClient, 'Expected HMRClient.setup() call at startup.');
|
|
95
95
|
pendingEntryPoints.push(requestUrl);
|
|
96
96
|
registerBundleEntryPoints(hmrClient);
|
|
97
97
|
},
|
|
@@ -107,10 +107,10 @@ const HMRClient = {
|
|
|
107
107
|
}
|
|
108
108
|
try {
|
|
109
109
|
hmrClient.send(JSON.stringify({
|
|
110
|
-
type:
|
|
110
|
+
type: 'log',
|
|
111
111
|
level,
|
|
112
|
-
mode:
|
|
113
|
-
data: data.map((item) => typeof item ===
|
|
112
|
+
mode: 'BRIDGE',
|
|
113
|
+
data: data.map((item) => typeof item === 'string'
|
|
114
114
|
? item
|
|
115
115
|
: (0, pretty_format_1.default)(item, {
|
|
116
116
|
escapeString: true,
|
|
@@ -129,8 +129,8 @@ const HMRClient = {
|
|
|
129
129
|
// Called once by the bridge on startup, even if Fast Refresh is off.
|
|
130
130
|
// It creates the HMR client but doesn't actually set up the socket yet.
|
|
131
131
|
setup({ isEnabled }) {
|
|
132
|
-
assert(!hmrClient,
|
|
133
|
-
const serverScheme = window.location.protocol ===
|
|
132
|
+
assert(!hmrClient, 'Cannot initialize hmrClient twice');
|
|
133
|
+
const serverScheme = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
|
134
134
|
const client = new MetroHMRClient(`${serverScheme}://${window.location.host}/hot`);
|
|
135
135
|
hmrClient = client;
|
|
136
136
|
const { fullBundleUrl } = (0, getDevServer_1.default)();
|
|
@@ -139,7 +139,7 @@ const HMRClient = {
|
|
|
139
139
|
// there are any important URL parameters we can't reconstruct from
|
|
140
140
|
// `setup()`'s arguments.
|
|
141
141
|
fullBundleUrl);
|
|
142
|
-
client.on(
|
|
142
|
+
client.on('connection-error', (e) => {
|
|
143
143
|
let error = `Cannot connect to Metro.
|
|
144
144
|
|
|
145
145
|
Try the following to fix the issue:
|
|
@@ -151,31 +151,31 @@ const HMRClient = {
|
|
|
151
151
|
Error: ${e.message}`;
|
|
152
152
|
setHMRUnavailableReason(error);
|
|
153
153
|
});
|
|
154
|
-
client.on(
|
|
154
|
+
client.on('update-start', ({ isInitialUpdate }) => {
|
|
155
155
|
currentCompileErrorMessage = null;
|
|
156
156
|
didConnect = true;
|
|
157
157
|
if (client.isEnabled() && !isInitialUpdate) {
|
|
158
|
-
LoadingView_1.default.showMessage(
|
|
158
|
+
LoadingView_1.default.showMessage('Refreshing...', 'refresh');
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
|
-
client.on(
|
|
161
|
+
client.on('update', ({ isInitialUpdate }) => {
|
|
162
162
|
if (client.isEnabled() && !isInitialUpdate) {
|
|
163
163
|
dismissRedbox();
|
|
164
164
|
LogBox_1.default.clearAllLogs();
|
|
165
165
|
}
|
|
166
166
|
});
|
|
167
|
-
client.on(
|
|
167
|
+
client.on('update-done', () => {
|
|
168
168
|
LoadingView_1.default.hide();
|
|
169
169
|
});
|
|
170
|
-
client.on(
|
|
170
|
+
client.on('error', (data) => {
|
|
171
171
|
LoadingView_1.default.hide();
|
|
172
|
-
if (data.type ===
|
|
172
|
+
if (data.type === 'GraphNotFoundError') {
|
|
173
173
|
client.close();
|
|
174
|
-
setHMRUnavailableReason(
|
|
174
|
+
setHMRUnavailableReason('Metro has restarted since the last edit. Reload to reconnect.');
|
|
175
175
|
}
|
|
176
|
-
else if (data.type ===
|
|
176
|
+
else if (data.type === 'RevisionNotFoundError') {
|
|
177
177
|
client.close();
|
|
178
|
-
setHMRUnavailableReason(
|
|
178
|
+
setHMRUnavailableReason('Metro and the client are out of sync. Reload to reconnect.');
|
|
179
179
|
}
|
|
180
180
|
else {
|
|
181
181
|
currentCompileErrorMessage = `${data.type} ${data.message}`;
|
|
@@ -184,7 +184,7 @@ const HMRClient = {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
});
|
|
187
|
-
client.on(
|
|
187
|
+
client.on('close', (closeEvent) => {
|
|
188
188
|
LoadingView_1.default.hide();
|
|
189
189
|
// https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1
|
|
190
190
|
// https://www.rfc-editor.org/rfc/rfc6455.html#section-7.1.5
|
|
@@ -193,7 +193,7 @@ const HMRClient = {
|
|
|
193
193
|
closeEvent.code === 1005 ||
|
|
194
194
|
closeEvent.code == null;
|
|
195
195
|
setHMRUnavailableReason(`${isNormalOrUnsetCloseReason
|
|
196
|
-
?
|
|
196
|
+
? 'Disconnected from Metro.'
|
|
197
197
|
: `Disconnected from Metro (${closeEvent.code}: "${closeEvent.reason}").`}
|
|
198
198
|
|
|
199
199
|
To reconnect:
|
|
@@ -212,7 +212,7 @@ To reconnect:
|
|
|
212
212
|
},
|
|
213
213
|
};
|
|
214
214
|
function setHMRUnavailableReason(reason) {
|
|
215
|
-
assert(hmrClient,
|
|
215
|
+
assert(hmrClient, 'Expected HMRClient.setup() call at startup.');
|
|
216
216
|
if (hmrUnavailableReason !== null) {
|
|
217
217
|
// Don't show more than one warning.
|
|
218
218
|
return;
|
|
@@ -233,8 +233,8 @@ function registerBundleEntryPoints(client) {
|
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
235
|
if (pendingEntryPoints.length > 0) {
|
|
236
|
-
client
|
|
237
|
-
type:
|
|
236
|
+
client?.send(JSON.stringify({
|
|
237
|
+
type: 'register-entrypoints',
|
|
238
238
|
entryPoints: pendingEntryPoints,
|
|
239
239
|
}));
|
|
240
240
|
pendingEntryPoints.length = 0;
|
package/build/HMRClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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;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, { 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
|
+
{"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;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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,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) 650 Industries.\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(`${serverScheme}://${window.location.host}/hot`);\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('update-start', ({ isInitialUpdate }: { isInitialUpdate?: boolean }) => {\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 }: { isInitialUpdate?: boolean }) => {\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: { type: string; message: string }) => {\n LoadingView.hide();\n\n if (data.type === 'GraphNotFoundError') {\n client.close();\n setHMRUnavailableReason('Metro has restarted since the last edit. Reload to reconnect.');\n } else if (data.type === 'RevisionNotFoundError') {\n client.close();\n setHMRUnavailableReason('Metro and the client are out of sync. Reload to reconnect.');\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,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const HMRClient = require(
|
|
3
|
+
const HMRClient = require('react-native/Libraries/Utilities/HMRClient');
|
|
4
4
|
exports.default = HMRClient;
|
|
5
5
|
//# sourceMappingURL=HMRClient.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HMRClient.native.js","sourceRoot":"","sources":["../src/HMRClient.native.ts"],"names":[],"mappings":";;AAAA,MAAM,SAAS,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC;AAExE,kBAAe,SAAS,CAAC","sourcesContent":["const HMRClient = require(
|
|
1
|
+
{"version":3,"file":"HMRClient.native.js","sourceRoot":"","sources":["../src/HMRClient.native.ts"],"names":[],"mappings":";;AAAA,MAAM,SAAS,GAAG,OAAO,CAAC,4CAA4C,CAAC,CAAC;AAExE,kBAAe,SAAS,CAAC","sourcesContent":["const HMRClient = require('react-native/Libraries/Utilities/HMRClient');\n\nexport default HMRClient;\n"]}
|
package/build/LoadingView.d.ts
CHANGED
|
@@ -1 +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;;;;;
|
|
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;;;;;AAED,wBAGE"}
|
package/build/LoadingView.js
CHANGED
|
@@ -3,17 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const expo_modules_core_1 = require("expo-modules-core");
|
|
4
4
|
// Ensure events are sent so custom Fast Refresh views are shown.
|
|
5
5
|
function showMessage(message, type) {
|
|
6
|
-
expo_modules_core_1.SyntheticPlatformEmitter.emit(
|
|
6
|
+
expo_modules_core_1.SyntheticPlatformEmitter.emit('devLoadingView:showMessage', {
|
|
7
7
|
message,
|
|
8
8
|
});
|
|
9
9
|
}
|
|
10
10
|
function hide() {
|
|
11
|
-
expo_modules_core_1.SyntheticPlatformEmitter.emit(
|
|
11
|
+
expo_modules_core_1.SyntheticPlatformEmitter.emit('devLoadingView:hide', {});
|
|
12
12
|
}
|
|
13
|
-
module.exports = {
|
|
14
|
-
showMessage,
|
|
15
|
-
hide,
|
|
16
|
-
};
|
|
17
13
|
exports.default = {
|
|
18
14
|
showMessage,
|
|
19
15
|
hide,
|
package/build/LoadingView.js.map
CHANGED
|
@@ -1 +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,
|
|
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,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\nexport default {\n showMessage,\n hide,\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingView.native.d.ts","sourceRoot":"","sources":["../src/LoadingView.native.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"LoadingView.native.d.ts","sourceRoot":"","sources":["../src/LoadingView.native.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,8CAA8C,CAAC;AAEvE,eAAe,WAAW,CAAC"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
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
|
+
const LoadingView_1 = __importDefault(require("react-native/Libraries/Utilities/LoadingView"));
|
|
7
|
+
exports.default = LoadingView_1.default;
|
|
3
8
|
//# sourceMappingURL=LoadingView.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingView.native.js","sourceRoot":"","sources":["../src/LoadingView.native.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"LoadingView.native.js","sourceRoot":"","sources":["../src/LoadingView.native.ts"],"names":[],"mappings":";;;;;AAAA,+FAAuE;AAEvE,kBAAe,qBAAW,CAAC","sourcesContent":["import LoadingView from 'react-native/Libraries/Utilities/LoadingView';\n\nexport default LoadingView;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAsyncRequire.js","sourceRoot":"","sources":["../../src/async-require/buildAsyncRequire.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6CAA+C;AAQ/C,oFAAoF;AACpF,SAAgB,iBAAiB;IAC/B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE/C,OAAO,KAAK,UAAU,yBAAyB,CAAC,IAAY;QAC1D,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACnB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;SACzB;QAED,MAAM,OAAO,GAAG,IAAA,4BAAe,EAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACpD,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACnB,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEzB,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC;AAjBD,8CAiBC","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\nimport { loadBundleAsync } from
|
|
1
|
+
{"version":3,"file":"buildAsyncRequire.js","sourceRoot":"","sources":["../../src/async-require/buildAsyncRequire.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,6CAA+C;AAQ/C,oFAAoF;AACpF,SAAgB,iBAAiB;IAC/B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE/C,OAAO,KAAK,UAAU,yBAAyB,CAAC,IAAY;QAC1D,IAAI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YACnB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;SACzB;QAED,MAAM,OAAO,GAAG,IAAA,4BAAe,EAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACpD,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACnB,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAEzB,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;AACJ,CAAC;AAjBD,8CAiBC","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\nimport { loadBundleAsync } from './loadBundle';\n\n/**\n * Must satisfy the requirements of the Metro bundler.\n * https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0605-lazy-bundling.md#__loadbundleasync-in-metro\n */\ntype AsyncRequire = (path: string) => Promise<void>;\n\n/** Create an `loadBundleAsync` function in the expected shape for Metro bundler. */\nexport function buildAsyncRequire(): AsyncRequire {\n const cache = new Map<string, Promise<void>>();\n\n return async function universal_loadBundleAsync(path: string): Promise<void> {\n if (cache.has(path)) {\n return cache.get(path)!;\n }\n\n const promise = loadBundleAsync(path).catch((error) => {\n cache.delete(path);\n throw error;\n });\n\n cache.set(path, promise);\n\n return promise;\n };\n}\n"]}
|
|
@@ -16,7 +16,7 @@ exports.buildUrlForBundle = void 0;
|
|
|
16
16
|
function buildUrlForBundle(bundlePath) {
|
|
17
17
|
// NOTE(EvanBacon): This must come from the window origin (at least in dev mode).
|
|
18
18
|
// Otherwise Metro will crash from attempting to load a bundle that doesn't exist.
|
|
19
|
-
return
|
|
19
|
+
return '/' + bundlePath.replace(/^\/+/, '');
|
|
20
20
|
}
|
|
21
21
|
exports.buildUrlForBundle = buildUrlForBundle;
|
|
22
22
|
//# sourceMappingURL=buildUrlForBundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUrlForBundle.js","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,UAAkB;IAClD,iFAAiF;IACjF,kFAAkF;IAClF,OAAO,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAJD,8CAIC","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\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(bundlePath: string): 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 return
|
|
1
|
+
{"version":3,"file":"buildUrlForBundle.js","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,UAAkB;IAClD,iFAAiF;IACjF,kFAAkF;IAClF,OAAO,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAJD,8CAIC","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\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(bundlePath: string): 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 return '/' + bundlePath.replace(/^\\/+/, '');\n}\n"]}
|
|
@@ -8,20 +8,21 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.buildUrlForBundle = void 0;
|
|
10
10
|
function buildUrlForBundle(bundlePath) {
|
|
11
|
-
if (process.env.NODE_ENV ===
|
|
12
|
-
if (typeof location !==
|
|
11
|
+
if (process.env.NODE_ENV === 'production') {
|
|
12
|
+
if (typeof location !== 'undefined') {
|
|
13
13
|
return joinComponents(location.origin, bundlePath);
|
|
14
14
|
}
|
|
15
15
|
throw new Error('Unable to determine the production URL where additional JavaScript chunks are hosted because the global "location" variable is not defined.');
|
|
16
16
|
}
|
|
17
17
|
else {
|
|
18
|
-
const getDevServer = require(
|
|
18
|
+
const getDevServer = require('../getDevServer')
|
|
19
|
+
.default;
|
|
19
20
|
const { url: serverUrl } = getDevServer();
|
|
20
21
|
return joinComponents(serverUrl, bundlePath);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
exports.buildUrlForBundle = buildUrlForBundle;
|
|
24
25
|
function joinComponents(prefix, suffix) {
|
|
25
|
-
return prefix.replace(/\/+$/,
|
|
26
|
+
return prefix.replace(/\/+$/, '') + '/' + suffix.replace(/^\/+/, '');
|
|
26
27
|
}
|
|
27
28
|
//# sourceMappingURL=buildUrlForBundle.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildUrlForBundle.native.js","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.native.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,SAAgB,iBAAiB,CAAC,UAAkB;IAClD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;YACnC,OAAO,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;SACpD;QACD,MAAM,IAAI,KAAK,CACb,6IAA6I,CAC9I,CAAC;KACH;SAAM;QACL,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"buildUrlForBundle.native.js","sourceRoot":"","sources":["../../src/async-require/buildUrlForBundle.native.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,SAAgB,iBAAiB,CAAC,UAAkB;IAClD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;YACnC,OAAO,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;SACpD;QACD,MAAM,IAAI,KAAK,CACb,6IAA6I,CAC9I,CAAC;KACH;SAAM;QACL,MAAM,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC;aAC5C,OAAmD,CAAC;QAEvD,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,YAAY,EAAE,CAAC;QAE1C,OAAO,cAAc,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;KAC9C;AACH,CAAC;AAhBD,8CAgBC;AAED,SAAS,cAAc,CAAC,MAAc,EAAE,MAAc;IACpD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACvE,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 */\n\nexport function buildUrlForBundle(bundlePath: string): string {\n if (process.env.NODE_ENV === 'production') {\n if (typeof location !== 'undefined') {\n return joinComponents(location.origin, bundlePath);\n }\n throw new Error(\n 'Unable to determine the production URL where additional JavaScript chunks are hosted because the global \"location\" variable is not defined.'\n );\n } else {\n const getDevServer = require('../getDevServer')\n .default as typeof import('../getDevServer').default;\n\n const { url: serverUrl } = getDevServer();\n\n return joinComponents(serverUrl, bundlePath);\n }\n}\n\nfunction joinComponents(prefix: string, suffix: string): string {\n return prefix.replace(/\\/+$/, '') + '/' + suffix.replace(/^\\/+/, '');\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchAsync.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchAsync.ts"],"names":[],"mappings":"AAQA,wBAAsB,UAAU,
|
|
1
|
+
{"version":3,"file":"fetchAsync.d.ts","sourceRoot":"","sources":["../../src/async-require/fetchAsync.ts"],"names":[],"mappings":"AAQA,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAYzF"}
|
|
@@ -10,10 +10,10 @@ exports.fetchAsync = void 0;
|
|
|
10
10
|
const react_native_1 = require("react-native");
|
|
11
11
|
async function fetchAsync(url) {
|
|
12
12
|
const response = await fetch(url, {
|
|
13
|
-
method:
|
|
13
|
+
method: 'GET',
|
|
14
14
|
headers: {
|
|
15
15
|
// No real reason for this but we try to use this format for everything.
|
|
16
|
-
|
|
16
|
+
'expo-platform': react_native_1.Platform.OS,
|
|
17
17
|
},
|
|
18
18
|
});
|
|
19
19
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchAsync.js","sourceRoot":"","sources":["../../src/async-require/fetchAsync.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+CAAwC;AAEjC,KAAK,UAAU,UAAU,
|
|
1
|
+
{"version":3,"file":"fetchAsync.js","sourceRoot":"","sources":["../../src/async-require/fetchAsync.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,+CAAwC;AAEjC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,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;AAZD,gCAYC","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(url: string): 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;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,
|
|
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,CAuD5D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 650 Industries.
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
@@ -23,17 +23,17 @@ function fetchAsync(url) {
|
|
|
23
23
|
let responseListener = null;
|
|
24
24
|
return new Promise((resolve, reject) => {
|
|
25
25
|
const addListener = RCTNetworking_1.default.addListener;
|
|
26
|
-
dataListener = addListener(
|
|
26
|
+
dataListener = addListener('didReceiveNetworkData', ([requestId, response]) => {
|
|
27
27
|
if (requestId === id) {
|
|
28
28
|
responseText = response;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
responseListener = addListener(
|
|
31
|
+
responseListener = addListener('didReceiveNetworkResponse', ([requestId, status, responseHeaders]) => {
|
|
32
32
|
if (requestId === id) {
|
|
33
33
|
headers = responseHeaders;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
completeListener = addListener(
|
|
36
|
+
completeListener = addListener('didCompleteNetworkResponse', ([requestId, error]) => {
|
|
37
37
|
if (requestId === id) {
|
|
38
38
|
if (error) {
|
|
39
39
|
reject(error);
|
|
@@ -43,15 +43,15 @@ function fetchAsync(url) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
|
-
RCTNetworking_1.default.sendRequest(
|
|
47
|
-
|
|
48
|
-
},
|
|
46
|
+
RCTNetworking_1.default.sendRequest('GET', 'asyncRequest', url, {
|
|
47
|
+
'expo-platform': react_native_1.Platform.OS,
|
|
48
|
+
}, '', 'text', false, 0, (requestId) => {
|
|
49
49
|
id = requestId;
|
|
50
50
|
}, true);
|
|
51
51
|
}).finally(() => {
|
|
52
|
-
dataListener
|
|
53
|
-
completeListener
|
|
54
|
-
responseListener
|
|
52
|
+
dataListener?.remove();
|
|
53
|
+
completeListener?.remove();
|
|
54
|
+
responseListener?.remove();
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
exports.fetchAsync = fetchAsync;
|
|
@@ -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;AAItE,SAAgB,UAAU,CACxB,GAAW;IAEX,IAAI,EAAE,GAAkB,IAAI,CAAC;IAC7B,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,OAAO,GAA2B,EAAE,CAAC;IACzC,IAAI,YAAY,GAAsB,IAAI,CAAC;IAC3C,IAAI,gBAAgB,GAAsB,IAAI,CAAC;IAC/C,IAAI,gBAAgB,GAAsB,IAAI,CAAC;IAC/C,OAAO,IAAI,OAAO,
|
|
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;AAItE,SAAgB,UAAU,CACxB,GAAW;IAEX,IAAI,EAAE,GAAkB,IAAI,CAAC;IAC7B,IAAI,YAAY,GAAkB,IAAI,CAAC;IACvC,IAAI,OAAO,GAA2B,EAAE,CAAC;IACzC,IAAI,YAAY,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AY,EAAE,MAAM,EAAE,CAAC;QACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAC3B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC;AAzDD,gCAyDC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\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> }>((resolve, reject) => {\n const addListener = Networking.addListener as (\n event: string,\n callback: (props: [string, any, any]) => any\n ) => Subscriber;\n dataListener = addListener('didReceiveNetworkData', ([requestId, response]) => {\n if (requestId === id) {\n responseText = response;\n }\n });\n responseListener = addListener(\n 'didReceiveNetworkResponse',\n ([requestId, status, responseHeaders]) => {\n if (requestId === id) {\n headers = responseHeaders;\n }\n }\n );\n completeListener = addListener('didCompleteNetworkResponse', ([requestId, error]) => {\n if (requestId === id) {\n if (error) {\n reject(error);\n } else {\n resolve({ body: responseText!, headers });\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 }).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":"AAYA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
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,CAqB7D"}
|
|
@@ -15,9 +15,8 @@ const fetchAsync_1 = require("./fetchAsync");
|
|
|
15
15
|
*/
|
|
16
16
|
function fetchThenEvalAsync(url) {
|
|
17
17
|
return (0, fetchAsync_1.fetchAsync)(url).then(({ body, headers }) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
headers.get("Content-Type").includes("application/json")) {
|
|
18
|
+
if (headers?.has?.('Content-Type') != null &&
|
|
19
|
+
headers.get('Content-Type').includes('application/json')) {
|
|
21
20
|
// Errors are returned as JSON.
|
|
22
21
|
throw new Error(JSON.parse(body).message || `Unknown error fetching '${url}'`);
|
|
23
22
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,IAAI;YACtC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EACzD;YACA,+BAA+B;YAC/B,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,IAAI,2BAA2B,GAAG,GAAG,CAAC,CAAC;SAChF;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;AArBD,gDAqBC","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(JSON.parse(body).message || `Unknown error fetching '${url}'`);\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 +1 @@
|
|
|
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,
|
|
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,CAiDf"}
|