@expo/metro-runtime 5.0.1 → 5.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/LoadingView.d.ts +1 -1
- package/build/LoadingView.d.ts.map +1 -1
- package/build/effects.d.ts +1 -0
- package/build/effects.native.d.ts +1 -0
- package/build/location/Location.d.ts +1 -1
- package/build/location/Location.d.ts.map +1 -1
- package/build/location/install.d.ts +1 -0
- package/build/location/install.native.d.ts.map +1 -1
- package/build/messageSocket.d.ts +1 -2
- package/build/messageSocket.d.ts.map +1 -1
- package/build/messageSocket.native.d.ts +1 -1
- package/build/messageSocket.native.d.ts.map +1 -1
- package/build/setupFastRefresh.d.ts +1 -9
- package/build/setupFastRefresh.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/LoadingView.ts +1 -1
- package/src/error-overlay/Data/LogBoxData.tsx +1 -1
- package/src/error-overlay/LogBox.ts +4 -4
- package/src/error-overlay/LogBox.web.ts +4 -4
- package/src/location/Location.ts +1 -1
- package/src/location/install.native.ts +13 -32
- package/src/messageSocket.native.ts +5 -1
- package/src/messageSocket.ts +4 -0
- package/src/setupHMR.ts +18 -13
- package/src/ts-declarations/metro-runtime.d.ts +22 -0
- package/src/ts-declarations/react-native-web.d.ts +3 -0
- package/src/ts-declarations/react-native.d.ts +42 -0
package/build/LoadingView.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
declare function showMessage(message: string,
|
|
7
|
+
declare function showMessage(message: string, _type: 'load' | 'refresh'): void;
|
|
8
8
|
declare function hide(): void;
|
|
9
9
|
declare const _default: {
|
|
10
10
|
showMessage: typeof showMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoadingView.d.ts","sourceRoot":"","sources":["../src/LoadingView.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,iBAAS,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"LoadingView.d.ts","sourceRoot":"","sources":["../src/LoadingView.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,iBAAS,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,QAI9D;AAED,iBAAS,IAAI,SAEZ;;;;;AAED,wBAGE"}
|
package/build/effects.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Location.d.ts","sourceRoot":"","sources":["../../src/location/Location.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,SAAK;AAE5B,wBAAgB,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"Location.d.ts","sourceRoot":"","sources":["../../src/location/Location.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,SAAK;AAE5B,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,QAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.native.d.ts","sourceRoot":"","sources":["../../src/location/install.native.ts"],"names":[],"mappings":"AACA,OAAO,4CAA4C,CAAC;AAGpD,OAAO,cAAc,CAAC;AAEtB,OAAO,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"install.native.d.ts","sourceRoot":"","sources":["../../src/location/install.native.ts"],"names":[],"mappings":"AACA,OAAO,4CAA4C,CAAC;AAGpD,OAAO,cAAc,CAAC;AAEtB,OAAO,MAAM,CAAC;AA4Cd,QAAA,MAAM,cAAc,eAAqD,CAAC;AAE1E,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,QAAQ,GAAG;IAAE,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAA;CAAE;uBAAT,OAAO;EAmBzF"}
|
package/build/messageSocket.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageSocket.d.ts","sourceRoot":"","sources":["../src/messageSocket.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messageSocket.d.ts","sourceRoot":"","sources":["../src/messageSocket.ts"],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=messageSocket.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageSocket.native.d.ts","sourceRoot":"","sources":["../src/messageSocket.native.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messageSocket.native.d.ts","sourceRoot":"","sources":["../src/messageSocket.native.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
declare const Refresh: {
|
|
3
|
-
performFullRefresh(): void;
|
|
4
|
-
createSignatureFunctionForTransform: any;
|
|
5
|
-
isLikelyComponentType: any;
|
|
6
|
-
getFamilyByType: any;
|
|
7
|
-
register: any;
|
|
8
|
-
performReactRefresh(): void;
|
|
9
|
-
};
|
|
1
|
+
export {};
|
|
10
2
|
//# sourceMappingURL=setupFastRefresh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupFastRefresh.d.ts","sourceRoot":"","sources":["../src/setupFastRefresh.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"setupFastRefresh.d.ts","sourceRoot":"","sources":["../src/setupFastRefresh.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/metro-runtime",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "Tools for making advanced Metro bundler features work",
|
|
5
5
|
"sideEffects": true,
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react-native": "*"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "a639a661a5329e58f916cf69b8f1a7718bbdd26e"
|
|
41
41
|
}
|
package/src/LoadingView.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { DeviceEventEmitter } from 'react-native-web';
|
|
9
9
|
|
|
10
10
|
// Ensure events are sent so custom Fast Refresh views are shown.
|
|
11
|
-
function showMessage(message: string,
|
|
11
|
+
function showMessage(message: string, _type: 'load' | 'refresh') {
|
|
12
12
|
DeviceEventEmitter.emit('devLoadingView:showMessage', {
|
|
13
13
|
message,
|
|
14
14
|
});
|
|
@@ -27,11 +27,11 @@ const LogBox: ILogBox = {
|
|
|
27
27
|
return false;
|
|
28
28
|
},
|
|
29
29
|
|
|
30
|
-
ignoreLogs(
|
|
30
|
+
ignoreLogs(_patterns: readonly IgnorePattern[]): void {
|
|
31
31
|
// Do nothing.
|
|
32
32
|
},
|
|
33
33
|
|
|
34
|
-
ignoreAllLogs(
|
|
34
|
+
ignoreAllLogs(_value?: boolean): void {
|
|
35
35
|
// Do nothing.
|
|
36
36
|
},
|
|
37
37
|
|
|
@@ -39,11 +39,11 @@ const LogBox: ILogBox = {
|
|
|
39
39
|
// Do nothing.
|
|
40
40
|
},
|
|
41
41
|
|
|
42
|
-
addLog(
|
|
42
|
+
addLog(_log: LogData): void {
|
|
43
43
|
// Do nothing.
|
|
44
44
|
},
|
|
45
45
|
|
|
46
|
-
addException(
|
|
46
|
+
addException(_ex: ExtendedExceptionData): void {
|
|
47
47
|
// Do nothing.
|
|
48
48
|
},
|
|
49
49
|
};
|
|
@@ -163,11 +163,11 @@ if (__DEV__) {
|
|
|
163
163
|
isInstalled(): boolean {
|
|
164
164
|
return false;
|
|
165
165
|
},
|
|
166
|
-
ignoreLogs(
|
|
167
|
-
ignoreAllLogs(
|
|
166
|
+
ignoreLogs(_patterns: readonly IgnorePattern[]): void {},
|
|
167
|
+
ignoreAllLogs(_value?: boolean): void {},
|
|
168
168
|
clearAllLogs(): void {},
|
|
169
|
-
addLog(
|
|
170
|
-
addException(
|
|
169
|
+
addLog(_log: LogData): void {},
|
|
170
|
+
addException(_ex: ExtendedExceptionData): void {},
|
|
171
171
|
};
|
|
172
172
|
}
|
|
173
173
|
|
package/src/location/Location.ts
CHANGED
|
@@ -8,22 +8,29 @@ import 'expo';
|
|
|
8
8
|
// This file configures the runtime environment to increase compatibility with WinterCG.
|
|
9
9
|
// https://wintercg.org/
|
|
10
10
|
import Constants from 'expo-constants';
|
|
11
|
-
import { polyfillGlobal as installGlobal } from 'react-native/Libraries/Utilities/PolyfillFunctions';
|
|
12
11
|
|
|
13
12
|
import { install, setLocationHref } from './Location';
|
|
14
13
|
import getDevServer from '../getDevServer';
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
interface ExpoExtraRouterConfig {
|
|
16
|
+
router?: {
|
|
17
|
+
origin?: any;
|
|
18
|
+
generatedOrigin?: any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const manifest = Constants.expoConfig;
|
|
17
23
|
|
|
18
24
|
function getOrigin() {
|
|
19
25
|
if (process.env.NODE_ENV !== 'production') {
|
|
20
26
|
// e.g. http://localhost:8081
|
|
21
27
|
return getDevServer().url;
|
|
22
28
|
}
|
|
29
|
+
const extra = manifest?.extra as ExpoExtraRouterConfig | null;
|
|
23
30
|
return (
|
|
24
|
-
|
|
31
|
+
extra?.router?.origin ??
|
|
25
32
|
// Written automatically during release builds.
|
|
26
|
-
|
|
33
|
+
extra?.router?.generatedOrigin
|
|
27
34
|
);
|
|
28
35
|
}
|
|
29
36
|
|
|
@@ -64,34 +71,8 @@ export function wrapFetchWithWindowLocation(fetch: Function & { [polyfillSymbol]
|
|
|
64
71
|
return _fetch;
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// built-in requirements.
|
|
70
|
-
const BUILTIN_SYMBOL = Symbol.for('expo.builtin');
|
|
71
|
-
|
|
72
|
-
function addBuiltinSymbol(obj: object) {
|
|
73
|
-
Object.defineProperty(obj, BUILTIN_SYMBOL, {
|
|
74
|
-
value: true,
|
|
75
|
-
enumerable: false,
|
|
76
|
-
configurable: false,
|
|
77
|
-
});
|
|
78
|
-
return obj;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function installBuiltin(name: string, getValue: () => any) {
|
|
82
|
-
installGlobal(name, () => addBuiltinSymbol(getValue()));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
try {
|
|
86
|
-
require('web-streams-polyfill');
|
|
87
|
-
// NOTE: Fetch is polyfilled in expo/metro-runtime
|
|
88
|
-
installBuiltin(
|
|
89
|
-
'ReadableStream',
|
|
90
|
-
() => require('web-streams-polyfill/ponyfill/es6').ReadableStream
|
|
91
|
-
);
|
|
92
|
-
} catch {}
|
|
93
|
-
|
|
94
|
-
if (manifest?.extra?.router?.origin !== false) {
|
|
74
|
+
const extra = manifest?.extra as ExpoExtraRouterConfig | null;
|
|
75
|
+
if (extra?.router?.origin !== false) {
|
|
95
76
|
// Polyfill window.location in native runtimes.
|
|
96
77
|
if (typeof window !== 'undefined' && !window.location) {
|
|
97
78
|
const url = getBaseUrl();
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
declare namespace globalThis {
|
|
4
|
+
const __EXPO_RSC_RELOAD_LISTENERS__: (() => unknown)[] | undefined;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function createWebSocketConnection(path: string = '/message'): WebSocket {
|
|
4
8
|
const getDevServer = require('react-native/Libraries/Core/Devtools/getDevServer').default;
|
|
5
9
|
const devServer = getDevServer();
|
|
6
10
|
if (!devServer.bundleLoadedFromServer) {
|
package/src/messageSocket.ts
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
// Setup websocket messages for reloading the page from the command line.
|
|
4
4
|
// This is normally setup on the native client.
|
|
5
5
|
|
|
6
|
+
declare namespace globalThis {
|
|
7
|
+
const __EXPO_RSC_RELOAD_LISTENERS__: (() => unknown)[] | undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
|
7
11
|
const messageSocket = new WebSocket(`${protocol}://${window.location.host}/message`);
|
|
8
12
|
messageSocket.onmessage = (message) => {
|
package/src/setupHMR.ts
CHANGED
|
@@ -7,19 +7,24 @@ if (
|
|
|
7
7
|
) {
|
|
8
8
|
// Sets up developer tools for web platforms when running in a webview. This ensures that logs are visible in the terminal.
|
|
9
9
|
// We assume full control over the console and send JavaScript logs to Metro.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
const LEVELS = [
|
|
11
|
+
'trace',
|
|
12
|
+
'info',
|
|
13
|
+
'warn',
|
|
14
|
+
'error',
|
|
15
|
+
'log',
|
|
16
|
+
'group',
|
|
17
|
+
'groupCollapsed',
|
|
18
|
+
'groupEnd',
|
|
19
|
+
'debug',
|
|
20
|
+
] as const;
|
|
21
|
+
LEVELS.forEach((level) => {
|
|
22
|
+
const originalFunction = console[level];
|
|
23
|
+
console[level] = function (...args: any[]) {
|
|
24
|
+
HMRClient.log(level, args);
|
|
25
|
+
originalFunction.apply(console, args);
|
|
26
|
+
};
|
|
27
|
+
});
|
|
23
28
|
HMRClient.log('log', [`[webview] Logs will also appear in the Safari/Chrome debug console`]);
|
|
24
29
|
} else {
|
|
25
30
|
HMRClient.log('log', [`[web] Logs will appear in the browser console`]);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// TODO(@kitten): Used in `src/HMRClient.ts`; move to using `metro-runtime/modules/HMRClient` import
|
|
2
|
+
declare module 'metro-runtime/src/modules/HMRClient' {
|
|
3
|
+
// NOTE(@kitten): These are inexact types, but we're just trying to vaguely match for now
|
|
4
|
+
class HMRClient {
|
|
5
|
+
constructor(uri: string);
|
|
6
|
+
|
|
7
|
+
send(msg: string): void;
|
|
8
|
+
isEnabled(): boolean;
|
|
9
|
+
disable(): void;
|
|
10
|
+
enable(): void;
|
|
11
|
+
close(): void;
|
|
12
|
+
hasPendingUpdates(): boolean;
|
|
13
|
+
|
|
14
|
+
on(name: 'connection-error', onEvent: (error: Error) => unknown): void;
|
|
15
|
+
on(name: 'update-start', onEvent: (event: { isInitialUpdate?: boolean }) => unknown): void;
|
|
16
|
+
on(name: 'update', onEvent: (event: { isInitialUpdate?: boolean }) => unknown): void;
|
|
17
|
+
on(name: 'update-done', onEvent: (event: unknown) => unknown): void;
|
|
18
|
+
on(name: 'error', onEvent: (event: { type: string; message: string }) => unknown): void;
|
|
19
|
+
on(name: 'close', onEvent: (event: { code: number; reason: string }) => unknown): void;
|
|
20
|
+
}
|
|
21
|
+
export = HMRClient;
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare module 'react-native/Libraries/Utilities/PolyfillFunctions' {
|
|
2
|
+
export function polyfillGlobal(): void;
|
|
3
|
+
export function polyfillGlobal(name: string, install: () => unknown): void;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module 'react-native/Libraries/Utilities/DevLoadingView' {
|
|
7
|
+
const LoadingView: any;
|
|
8
|
+
export default LoadingView;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module 'react-native/Libraries/Core/ExceptionsManager' {
|
|
12
|
+
declare class SyntheticError extends Error {}
|
|
13
|
+
const ExceptionsManager: {
|
|
14
|
+
parseException(e: any, isFatal: boolean): void;
|
|
15
|
+
handleException(e: any): void;
|
|
16
|
+
SyntheticError: typeof SyntheticError;
|
|
17
|
+
};
|
|
18
|
+
export default ExceptionsManager;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module 'react-native/Libraries/NativeModules/specs/NativeLogBox' {
|
|
22
|
+
const NativeLogBox: {
|
|
23
|
+
show(): void;
|
|
24
|
+
hide(): void;
|
|
25
|
+
};
|
|
26
|
+
export default NativeLogBox;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare module 'react-native/Libraries/Core/Devtools/getDevServer' {
|
|
30
|
+
interface DevServerInfo {
|
|
31
|
+
bundleLoadedFromServer: boolean;
|
|
32
|
+
fullBundleUrl: string;
|
|
33
|
+
url: string;
|
|
34
|
+
}
|
|
35
|
+
function getDevServer(): DevServerInfo;
|
|
36
|
+
export default getDevServer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
declare module 'react-native/Libraries/Core/Devtools/openFileInEditor' {
|
|
40
|
+
function openFileInEditor(file: string, lineNumber: number): void;
|
|
41
|
+
export default getDevServer;
|
|
42
|
+
}
|