@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.
@@ -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, type: 'load' | 'refresh'): void;
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,IAAI,EAAE,MAAM,GAAG,SAAS,QAI7D;AAED,iBAAS,IAAI,SAEZ;;;;;AAED,wBAGE"}
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"}
@@ -1 +1,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=effects.d.ts.map
@@ -1 +1,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=effects.native.d.ts.map
@@ -1,3 +1,3 @@
1
1
  export declare function install(): void;
2
- export declare function setLocationHref(href: string): void;
2
+ export declare function setLocationHref(_href: string): void;
3
3
  //# sourceMappingURL=Location.d.ts.map
@@ -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,IAAI,EAAE,MAAM,QAAI"}
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,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=install.d.ts.map
@@ -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;AAqCd,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"}
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"}
@@ -1,3 +1,2 @@
1
- declare const protocol: string;
2
- declare const messageSocket: WebSocket;
1
+ export {};
3
2
  //# sourceMappingURL=messageSocket.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messageSocket.d.ts","sourceRoot":"","sources":["../src/messageSocket.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,QAAQ,QAAuD,CAAC;AACtE,QAAA,MAAM,aAAa,WAAiE,CAAC"}
1
+ {"version":3,"file":"messageSocket.d.ts","sourceRoot":"","sources":["../src/messageSocket.ts"],"names":[],"mappings":""}
@@ -1,2 +1,2 @@
1
- declare function createWebSocketConnection(path?: string): any;
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":"AAEA,iBAAS,yBAAyB,CAAC,IAAI,GAAE,MAAmB,OAW3D"}
1
+ {"version":3,"file":"messageSocket.native.d.ts","sourceRoot":"","sources":["../src/messageSocket.native.ts"],"names":[],"mappings":""}
@@ -1,10 +1,2 @@
1
- declare const ReactRefreshRuntime: any;
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":"AAEA,QAAA,MAAM,mBAAmB,KAAmC,CAAC;AAG7D,QAAA,MAAM,OAAO;;;;;;;CAoBZ,CAAC"}
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.1",
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": "1914bb35d23af23078da37e70988261844436505"
40
+ "gitHead": "a639a661a5329e58f916cf69b8f1a7718bbdd26e"
41
41
  }
@@ -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, type: 'load' | 'refresh') {
11
+ function showMessage(message: string, _type: 'load' | 'refresh') {
12
12
  DeviceEventEmitter.emit('devLoadingView:showMessage', {
13
13
  message,
14
14
  });
@@ -361,7 +361,7 @@ export function withSubscription(WrappedComponent: React.FC<object>): React.Comp
361
361
  return { hasError: true };
362
362
  }
363
363
 
364
- constructor(props) {
364
+ constructor(props: object) {
365
365
  super(props);
366
366
 
367
367
  if (process.env.NODE_ENV === 'development') {
@@ -27,11 +27,11 @@ const LogBox: ILogBox = {
27
27
  return false;
28
28
  },
29
29
 
30
- ignoreLogs(patterns: readonly IgnorePattern[]): void {
30
+ ignoreLogs(_patterns: readonly IgnorePattern[]): void {
31
31
  // Do nothing.
32
32
  },
33
33
 
34
- ignoreAllLogs(value?: boolean): void {
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(log: LogData): void {
42
+ addLog(_log: LogData): void {
43
43
  // Do nothing.
44
44
  },
45
45
 
46
- addException(ex: ExtendedExceptionData): void {
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(patterns: readonly IgnorePattern[]): void {},
167
- ignoreAllLogs(value?: boolean): void {},
166
+ ignoreLogs(_patterns: readonly IgnorePattern[]): void {},
167
+ ignoreAllLogs(_value?: boolean): void {},
168
168
  clearAllLogs(): void {},
169
- addLog(log: LogData): void {},
170
- addException(ex: ExtendedExceptionData): void {},
169
+ addLog(_log: LogData): void {},
170
+ addException(_ex: ExtendedExceptionData): void {},
171
171
  };
172
172
  }
173
173
 
@@ -1,3 +1,3 @@
1
1
  export function install() {}
2
2
 
3
- export function setLocationHref(href: string) {}
3
+ export function setLocationHref(_href: string) {}
@@ -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
- const manifest = Constants.expoConfig as Record<string, any> | null;
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
- manifest?.extra?.router?.origin ??
31
+ extra?.router?.origin ??
25
32
  // Written automatically during release builds.
26
- manifest?.extra?.router?.generatedOrigin
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
- // Add a well-known shared symbol that doesn't show up in iteration or inspection
68
- // this can be used to detect if the global object abides by the Expo team's documented
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
- function createWebSocketConnection(path: string = '/message') {
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) {
@@ -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
- ['trace', 'info', 'warn', 'error', 'log', 'group', 'groupCollapsed', 'groupEnd', 'debug'].forEach(
11
- (level) => {
12
- const originalFunction = console[level];
13
- console[level] = function (...args: readonly any[]) {
14
- HMRClient.log(
15
- // @ts-expect-error
16
- level,
17
- args
18
- );
19
- originalFunction.apply(console, args);
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,3 @@
1
+ declare module 'react-native-web' {
2
+ export { DeviceEventEmitter } from 'react-native';
3
+ }
@@ -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
+ }