expo 55.0.0-canary-20251008-6acbc1c → 55.0.0-canary-20251009-9919e08

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.
@@ -8,7 +8,6 @@
8
8
  * Based on this but with web support:
9
9
  * https://github.com/facebook/react-native/blob/086714b02b0fb838dee5a66c5bcefe73b53cf3df/Libraries/Utilities/HMRClient.js
10
10
  */
11
- import { parseWebHmrBuildErrors, type MetroBuildError } from '@expo/log-box/utils';
12
11
  import MetroHMRClient from '@expo/metro/metro-runtime/modules/HMRClient';
13
12
  import prettyFormat, { plugins } from 'pretty-format';
14
13
  import { DeviceEventEmitter } from 'react-native';
@@ -29,9 +28,17 @@ const pendingEntryPoints: string[] = [];
29
28
  // @ts-expect-error: Account for multiple versions of pretty-format inside of a monorepo.
30
29
  const prettyFormatFunc = typeof prettyFormat === 'function' ? prettyFormat : prettyFormat.default;
31
30
 
32
- let hmrClient: MetroHMRClient | null = null;
31
+ type HMRClientType = {
32
+ send: (msg: string) => void;
33
+ isEnabled: () => boolean;
34
+ disable: () => void;
35
+ enable: () => void;
36
+ hasPendingUpdates: () => boolean;
37
+ };
38
+
39
+ let hmrClient: HMRClientType | null = null;
33
40
  let hmrUnavailableReason: string | null = null;
34
- const buildErrorQueue = new Set<MetroBuildError>();
41
+ let currentCompileErrorMessage: string | null = null;
35
42
  let didConnect: boolean = false;
36
43
  const pendingLogs: [LogLevel, any[]][] = [];
37
44
 
@@ -46,6 +53,14 @@ type LogLevel =
46
53
  | 'groupEnd'
47
54
  | 'debug';
48
55
 
56
+ export type HMRClientNativeInterface = {
57
+ enable(): void;
58
+ disable(): void;
59
+ registerBundle(requestUrl: string): void;
60
+ log(level: LogLevel, data: any[]): void;
61
+ setup(props: { isEnabled: boolean }): void;
62
+ };
63
+
49
64
  function assert(foo: any, msg: string): asserts foo {
50
65
  if (!foo) throw new Error(msg);
51
66
  }
@@ -54,7 +69,7 @@ function assert(foo: any, msg: string): asserts foo {
54
69
  * HMR Client that receives from the server HMR updates and propagates them
55
70
  * runtime to reflects those changes.
56
71
  */
57
- const HMRClient = {
72
+ const HMRClient: HMRClientNativeInterface = {
58
73
  enable() {
59
74
  if (hmrUnavailableReason !== null) {
60
75
  // If HMR became unavailable while you weren't using it,
@@ -166,10 +181,10 @@ const HMRClient = {
166
181
  );
167
182
 
168
183
  client.on('connection-error', (e: Error) => {
169
- let error = `Cannot connect to Expo CLI.
184
+ let error = `Cannot connect to Metro.
170
185
 
171
186
  Try the following to fix the issue:
172
- - Ensure the Expo dev server is running and available on the same network as this device`;
187
+ - Ensure the Metro dev server is running and available on the same network as this device`;
173
188
  error += `
174
189
 
175
190
  URL: ${window.location.host}
@@ -180,7 +195,7 @@ const HMRClient = {
180
195
  });
181
196
 
182
197
  client.on('update-start', ({ isInitialUpdate }: { isInitialUpdate?: boolean }) => {
183
- buildErrorQueue.clear();
198
+ currentCompileErrorMessage = null;
184
199
  didConnect = true;
185
200
 
186
201
  if (client.isEnabled() && !isInitialUpdate) {
@@ -190,11 +205,10 @@ const HMRClient = {
190
205
 
191
206
  client.on('update', ({ isInitialUpdate }: { isInitialUpdate?: boolean }) => {
192
207
  if (client.isEnabled() && !isInitialUpdate) {
193
- // dismissRedbox();
208
+ dismissRedbox();
194
209
  // @ts-expect-error
195
210
  globalThis.__expo_dev_resetErrors?.();
196
211
  // LogBox.clearAllLogs();
197
- // dismissGlobalErrorOverlay();
198
212
  }
199
213
  });
200
214
 
@@ -202,7 +216,22 @@ const HMRClient = {
202
216
  hideLoading();
203
217
  });
204
218
 
205
- client.on('error', (data) => this._onMetroError(data));
219
+ client.on('error', (data: { type: string; message: string }) => {
220
+ hideLoading();
221
+
222
+ if (data.type === 'GraphNotFoundError') {
223
+ client.close();
224
+ setHMRUnavailableReason('Metro has restarted since the last edit. Reload to reconnect.');
225
+ } else if (data.type === 'RevisionNotFoundError') {
226
+ client.close();
227
+ setHMRUnavailableReason('Metro and the client are out of sync. Reload to reconnect.');
228
+ } else {
229
+ currentCompileErrorMessage = `${data.type} ${data.message}`;
230
+ if (client.isEnabled()) {
231
+ showCompileError();
232
+ }
233
+ }
234
+ });
206
235
 
207
236
  client.on('close', (closeEvent: { code: number; reason: string }) => {
208
237
  hideLoading();
@@ -213,19 +242,19 @@ const HMRClient = {
213
242
  closeEvent == null ||
214
243
  closeEvent.code === 1000 ||
215
244
  closeEvent.code === 1005 ||
216
- closeEvent.code === 1006 ||
217
245
  closeEvent.code == null;
218
246
 
219
247
  setHMRUnavailableReason(
220
248
  `${
221
249
  isNormalOrUnsetCloseReason
222
- ? 'Disconnected from Expo CLI.'
223
- : `Disconnected from Expo CLI (${closeEvent.code}: "${closeEvent.reason}").`
250
+ ? 'Disconnected from Metro.'
251
+ : `Disconnected from Metro (${closeEvent.code}: "${closeEvent.reason}").`
224
252
  }
225
253
 
226
254
  To reconnect:
227
- - Start the dev server with: npx expo
228
- - Reload the ${process.env.EXPO_OS === 'web' ? 'page' : 'app'}`
255
+ - Ensure that Metro is running and available on the same network
256
+ - Reload this app (will trigger further help if Metro cannot be connected to)
257
+ `
229
258
  );
230
259
  });
231
260
 
@@ -238,41 +267,6 @@ To reconnect:
238
267
  registerBundleEntryPoints(hmrClient);
239
268
  flushEarlyLogs();
240
269
  },
241
-
242
- _onMetroError(data: unknown) {
243
- if (!hmrClient) {
244
- return;
245
- }
246
-
247
- assert(typeof data === 'object' && data != null, 'Expected data to be an object');
248
-
249
- hideLoading();
250
-
251
- if ('type' in data) {
252
- if (data.type === 'GraphNotFoundError') {
253
- hmrClient.close();
254
- setHMRUnavailableReason('Expo CLI has restarted since the last edit. Reload to reconnect.');
255
- return;
256
- } else if (data.type === 'RevisionNotFoundError') {
257
- hmrClient.close();
258
- setHMRUnavailableReason(
259
- `Expo CLI and the ${process.env.EXPO_OS} client are out of sync. Reload to reconnect.`
260
- );
261
- return;
262
- }
263
- }
264
-
265
- // Fallback for resolution errors which don't return a type
266
- // https://github.com/facebook/metro/blob/a3fac645dc377f78bd4182ca0ca73629b2707d5b/packages/metro/src/lib/formatBundlingError.js#L65-L73
267
- // https://github.com/facebook/metro/pull/1487
268
- const error = parseWebHmrBuildErrors(data);
269
-
270
- buildErrorQueue.add(error);
271
-
272
- if (hmrClient.isEnabled()) {
273
- showCompileError();
274
- }
275
- },
276
270
  };
277
271
 
278
272
  function setHMRUnavailableReason(reason: string) {
@@ -292,7 +286,7 @@ function setHMRUnavailableReason(reason: string) {
292
286
  }
293
287
  }
294
288
 
295
- function registerBundleEntryPoints(client: MetroHMRClient | null) {
289
+ function registerBundleEntryPoints(client: HMRClientType | null) {
296
290
  if (hmrUnavailableReason != null) {
297
291
  // "Bundle Splitting – Metro disconnected"
298
292
  window.location.reload();
@@ -320,17 +314,27 @@ function flushEarlyLogs() {
320
314
  }
321
315
  }
322
316
 
317
+ function dismissRedbox() {
318
+ // TODO(EvanBacon): Error overlay for web.
319
+ }
320
+
323
321
  function showCompileError() {
324
- if (buildErrorQueue.size === 0) {
322
+ if (currentCompileErrorMessage === null) {
325
323
  return;
326
324
  }
327
325
 
328
326
  // Even if there is already a redbox, syntax errors are more important.
329
327
  // Otherwise you risk seeing a stale runtime error while a syntax error is more recent.
330
- // dismissGlobalErrorOverlay();
328
+ dismissRedbox();
329
+
330
+ const message = currentCompileErrorMessage;
331
+ currentCompileErrorMessage = null;
331
332
 
332
- const error = buildErrorQueue.values().next().value;
333
- buildErrorQueue.clear();
333
+ const error = new Error(message);
334
+ // Symbolicating compile errors is wasted effort
335
+ // because the stack trace is meaningless:
336
+ // @ts-expect-error
337
+ error.preventSymbolication = true;
334
338
  throw error;
335
339
  }
336
340
 
@@ -1,15 +1,15 @@
1
1
  // Entry file for a DOM Component.
2
2
  import '@expo/metro-runtime';
3
3
 
4
+ import { withErrorOverlay } from '@expo/metro-runtime/error-overlay';
4
5
  import React from 'react';
5
6
 
6
7
  import { JSONValue } from './dom.types';
7
8
  import { addEventListener, getActionsObject } from './marshal';
8
9
  import registerRootComponent from '../launch/registerRootComponent';
9
- import { useLogBox } from '@expo/log-box';
10
10
 
11
11
  interface MarshalledProps {
12
- name: string[];
12
+ names: string[];
13
13
  props: Record<string, JSONValue>;
14
14
  [key: string]: undefined | JSONValue;
15
15
  }
@@ -92,7 +92,7 @@ export function registerDOMComponent(AppModule: any) {
92
92
  // Create a named map { [name: string]: ProxyFunction }
93
93
  // TODO(@kitten): Unclear how this is typed or shaped
94
94
  return Object.fromEntries(
95
- (marshalledProps.names as string[]).map((key: string) => {
95
+ marshalledProps.names.map((key: string) => {
96
96
  return [key, ACTIONS[key]];
97
97
  })
98
98
  );
@@ -102,12 +102,12 @@ export function registerDOMComponent(AppModule: any) {
102
102
  }
103
103
 
104
104
  try {
105
- if (process.env.NODE_ENV !== 'production') {
106
- useLogBox();
107
- }
108
-
109
105
  React.startTransition(() => {
110
- registerRootComponent(DOMComponentRoot);
106
+ if (process.env.NODE_ENV !== 'production') {
107
+ registerRootComponent(withErrorOverlay(DOMComponentRoot));
108
+ } else {
109
+ registerRootComponent(DOMComponentRoot);
110
+ }
111
111
  });
112
112
  } catch (e) {
113
113
  const error = convertError(e);
@@ -1,7 +1,5 @@
1
1
  export { default as WebView } from './webview-wrapper';
2
2
 
3
- export * from './dom-internal.types';
4
-
5
3
  // Skip all dom-only functions to give 'undefined is not a function' errors.
6
4
  export const registerDOMComponent: undefined | typeof import('./dom-entry').registerDOMComponent =
7
5
  undefined;
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  import { AppState } from 'react-native';
4
4
 
5
5
  import { getBaseURL } from './base';
6
- import type { BridgeMessage, WebViewProps, WebViewRef } from './dom.types';
6
+ import type { BridgeMessage, DOMProps, WebViewProps, WebViewRef } from './dom.types';
7
7
  import { _emitGlobalEvent } from './global-events';
8
8
  import {
9
9
  getInjectBodySizeObserverScript,
@@ -16,14 +16,13 @@ import {
16
16
  import ExpoDomWebView from './webview/ExpoDOMWebView';
17
17
  import RNWebView from './webview/RNWebView';
18
18
  import { useDebugZeroHeight } from './webview/useDebugZeroHeight';
19
- import { DOMPropsInternal } from './dom-internal.types';
20
19
 
21
20
  type RawWebViewProps = React.ComponentProps<Exclude<typeof ExpoDomWebView, undefined>> &
22
21
  React.ComponentProps<Exclude<typeof RNWebView, undefined>>;
23
22
 
24
23
  interface Props {
25
24
  children?: any;
26
- dom?: DOMPropsInternal;
25
+ dom?: DOMProps;
27
26
  filePath: string;
28
27
  ref: React.Ref<object>;
29
28
  [propName: string]: unknown;
@@ -31,8 +30,6 @@ interface Props {
31
30
 
32
31
  const RawWebView = React.forwardRef<object, Props>((props, ref) => {
33
32
  const { children, dom, filePath, ref: _ref, ...marshalProps } = props as Props;
34
- const { sourceOverride, ...domProps } = dom || {};
35
-
36
33
  if (__DEV__) {
37
34
  if (children !== undefined) {
38
35
  throw new Error(
@@ -69,7 +66,7 @@ const RawWebView = React.forwardRef<object, Props>((props, ref) => {
69
66
  const webView = resolveWebView(dom?.useExpoDOMWebView ?? false);
70
67
  const webviewRef = React.useRef<WebViewRef>(null);
71
68
  const domImperativeHandlePropsRef = React.useRef<string[]>([]);
72
- const source = sourceOverride ?? { uri: `${getBaseURL()}/${filePath}` };
69
+ const source = { uri: `${getBaseURL()}/${filePath}` };
73
70
  const [containerStyle, setContainerStyle] = React.useState<WebViewProps['containerStyle']>(null);
74
71
 
75
72
  const { debugZeroHeightStyle, debugOnLayout } = useDebugZeroHeight(dom);
@@ -132,7 +129,7 @@ const RawWebView = React.forwardRef<object, Props>((props, ref) => {
132
129
  subscription.remove();
133
130
  });
134
131
  },
135
- ...domProps,
132
+ ...dom,
136
133
  containerStyle: [containerStyle, debugZeroHeightStyle, dom?.containerStyle],
137
134
  onLayout: __DEV__ ? debugOnLayout : dom?.onLayout,
138
135
  injectedJavaScriptBeforeContentLoaded: [
package/template.tgz CHANGED
Binary file
@@ -1,135 +0,0 @@
1
- /*
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- package expo.modules
9
-
10
- import android.content.Context
11
- import com.facebook.react.bridge.ReadableArray
12
- import com.facebook.react.bridge.UiThreadUtil
13
- import com.facebook.react.common.SurfaceDelegate
14
- import com.facebook.react.common.SurfaceDelegateFactory
15
- import com.facebook.react.devsupport.DevSupportManagerBase
16
- import com.facebook.react.devsupport.ReactInstanceDevHelper
17
- import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener
18
- import com.facebook.react.devsupport.interfaces.DevLoadingViewManager
19
- import com.facebook.react.devsupport.interfaces.DevSupportManager
20
- import com.facebook.react.devsupport.interfaces.PausedInDebuggerOverlayManager
21
- import com.facebook.react.devsupport.interfaces.RedBoxHandler
22
- import com.facebook.react.packagerconnection.RequestHandler
23
- import expo.modules.logbox.ExpoLogBoxSurfaceDelegate
24
- import com.facebook.react.devsupport.StackTraceHelper.convertJavaStackTrace
25
- import com.facebook.react.devsupport.StackTraceHelper.convertJsStackTrace
26
- import com.facebook.react.devsupport.interfaces.StackFrame
27
-
28
- /**
29
- * An implementation of [DevSupportManager] that extends the functionality in
30
- * [DevSupportManagerBase] with some additional, more flexible APIs for asynchronously loading the
31
- * JS bundle.
32
- *
33
- * @constructor The primary constructor mirrors the same constructor we have for
34
- * [BridgeDevSupportManager] and
35
- * * is kept for backward compatibility.
36
- */
37
- internal open class ExpoBridgelessDevSupportManager(
38
- applicationContext: Context,
39
- reactInstanceManagerHelper: ReactInstanceDevHelper,
40
- packagerPathForJSBundleName: String?,
41
- enableOnCreate: Boolean,
42
- redBoxHandler: RedBoxHandler?,
43
- devBundleDownloadListener: DevBundleDownloadListener?,
44
- minNumShakes: Int,
45
- customPackagerCommandHandlers: Map<String, RequestHandler>?,
46
- surfaceDelegateFactory: SurfaceDelegateFactory?,
47
- devLoadingViewManager: DevLoadingViewManager?,
48
- pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?
49
- ) :
50
- DevSupportManagerBase(
51
- applicationContext,
52
- reactInstanceManagerHelper,
53
- packagerPathForJSBundleName,
54
- enableOnCreate,
55
- redBoxHandler,
56
- devBundleDownloadListener,
57
- minNumShakes,
58
- customPackagerCommandHandlers,
59
- surfaceDelegateFactory,
60
- devLoadingViewManager,
61
- pausedInDebuggerOverlayManager) {
62
-
63
- override val uniqueTag: String
64
- get() = "Bridgeless"
65
-
66
- override fun handleReloadJS() {
67
- UiThreadUtil.assertOnUiThread()
68
- // dismiss redbox if exists
69
- hideRedboxDialog()
70
- reactInstanceDevHelper.reload("BridgelessDevSupportManager.handleReloadJS()")
71
- }
72
- }
73
-
74
- internal class ExpoDevSupportManagerWithLogBoxOverride(
75
- applicationContext: Context,
76
- reactInstanceManagerHelper: ReactInstanceDevHelper,
77
- packagerPathForJSBundleName: String?,
78
- enableOnCreate: Boolean,
79
- redBoxHandler: RedBoxHandler?,
80
- devBundleDownloadListener: DevBundleDownloadListener?,
81
- minNumShakes: Int,
82
- customPackagerCommandHandlers: Map<String, RequestHandler>?,
83
- surfaceDelegateFactory: SurfaceDelegateFactory?,
84
- devLoadingViewManager: DevLoadingViewManager?,
85
- pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?
86
- ) :
87
- ExpoBridgelessDevSupportManager(
88
- applicationContext,
89
- reactInstanceManagerHelper,
90
- packagerPathForJSBundleName,
91
- enableOnCreate,
92
- redBoxHandler,
93
- devBundleDownloadListener,
94
- minNumShakes,
95
- customPackagerCommandHandlers,
96
- surfaceDelegateFactory,
97
- devLoadingViewManager,
98
- pausedInDebuggerOverlayManager) {
99
-
100
- private var redBoxSurfaceDelegate: SurfaceDelegate? = null
101
-
102
- override fun hideRedboxDialog() {
103
- redBoxSurfaceDelegate?.hide()
104
- }
105
-
106
- override fun showNewJavaError(message: String?, e: Throwable) {
107
- showNewError(message, convertJavaStackTrace(e))
108
- }
109
-
110
- override fun showNewJSError(message: String?, details: ReadableArray?, errorCookie: Int) {
111
- showNewError(message, convertJsStackTrace(details))
112
- }
113
-
114
- private fun showNewError(message: String?, stack: Array<StackFrame>) {
115
- UiThreadUtil.runOnUiThread {
116
- lastErrorTitle = message
117
- lastErrorStack = stack
118
-
119
- if (redBoxSurfaceDelegate == null) {
120
- this.redBoxSurfaceDelegate =
121
- createSurfaceDelegate("RedBox")
122
- ?: ExpoLogBoxSurfaceDelegate(this@ExpoDevSupportManagerWithLogBoxOverride).apply {
123
- createContentView("RedBox")
124
- }
125
- }
126
-
127
- if (redBoxSurfaceDelegate?.isShowing() == true) {
128
- // Sometimes errors cause multiple errors to be thrown in JS in quick succession. Only
129
- // show the first and most actionable one.
130
- return@runOnUiThread
131
- }
132
- redBoxSurfaceDelegate?.show()
133
- }
134
- }
135
- }
@@ -1,145 +0,0 @@
1
- /*
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- package expo.modules
9
-
10
- import android.content.Context
11
- import com.facebook.react.common.SurfaceDelegateFactory
12
- import com.facebook.react.common.build.ReactBuildConfig
13
- import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener
14
- import com.facebook.react.devsupport.interfaces.DevLoadingViewManager
15
- import com.facebook.react.devsupport.interfaces.DevSupportManager
16
- import com.facebook.react.devsupport.interfaces.PausedInDebuggerOverlayManager
17
- import com.facebook.react.devsupport.interfaces.RedBoxHandler
18
- import com.facebook.react.packagerconnection.RequestHandler
19
- import java.lang.StringBuilder
20
- import com.facebook.react.devsupport.DevSupportManagerFactory
21
- import com.facebook.react.devsupport.ReactInstanceDevHelper
22
- import com.facebook.react.devsupport.ReleaseDevSupportManager
23
-
24
- /**
25
- * A simple factory that creates instances of [DevSupportManager] implementations. Uses reflection
26
- * to create BridgeDevSupportManager if it exists. This allows ProGuard to strip that class and its
27
- * dependencies in release builds. If the class isn't found, [PerftestDevSupportManager] is returned
28
- * instead.
29
- */
30
- internal class ExpoDefaultDevSupportManagerFactory : DevSupportManagerFactory {
31
-
32
- override fun create(
33
- applicationContext: Context,
34
- reactInstanceManagerHelper: ReactInstanceDevHelper,
35
- packagerPathForJSBundleName: String?,
36
- enableOnCreate: Boolean,
37
- redBoxHandler: RedBoxHandler?,
38
- devBundleDownloadListener: DevBundleDownloadListener?,
39
- minNumShakes: Int,
40
- customPackagerCommandHandlers: Map<String, RequestHandler>?,
41
- surfaceDelegateFactory: SurfaceDelegateFactory?,
42
- devLoadingViewManager: DevLoadingViewManager?,
43
- pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?
44
- ): DevSupportManager {
45
- return if (!enableOnCreate) {
46
- ReleaseDevSupportManager()
47
- } else
48
- try {
49
- // Developer support is enabled, we now must choose whether to return a DevSupportManager,
50
- // or a more lean profiling-only PerftestDevSupportManager. We make the choice by first
51
- // trying to return the full support DevSupportManager and if it fails, then just
52
- // return PerftestDevSupportManager.
53
-
54
- // ProGuard is surprisingly smart in this case and will keep a class if it detects a call
55
- // to
56
- // Class.forName() with a static string. So instead we generate a quasi-dynamic string to
57
- // confuse it.
58
- val className =
59
- StringBuilder(DEVSUPPORT_IMPL_PACKAGE)
60
- .append(".")
61
- .append(DEVSUPPORT_IMPL_CLASS)
62
- .toString()
63
- val devSupportManagerClass = Class.forName(className)
64
- val constructor =
65
- devSupportManagerClass.getConstructor(
66
- Context::class.java,
67
- ReactInstanceDevHelper::class.java,
68
- String::class.java,
69
- Boolean::class.javaPrimitiveType,
70
- RedBoxHandler::class.java,
71
- DevBundleDownloadListener::class.java,
72
- Int::class.javaPrimitiveType,
73
- MutableMap::class.java,
74
- SurfaceDelegateFactory::class.java,
75
- DevLoadingViewManager::class.java,
76
- PausedInDebuggerOverlayManager::class.java)
77
- constructor.newInstance(
78
- applicationContext,
79
- reactInstanceManagerHelper,
80
- packagerPathForJSBundleName,
81
- true,
82
- redBoxHandler,
83
- devBundleDownloadListener,
84
- minNumShakes,
85
- customPackagerCommandHandlers,
86
- surfaceDelegateFactory,
87
- devLoadingViewManager,
88
- pausedInDebuggerOverlayManager) as DevSupportManager
89
- } catch (e: Exception) {
90
- throw e
91
- // Original implementation
92
- // https://github.com/facebook/react-native/blob/50273758510a6d756494d05dc91055516c2a6aca/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevSupportManagerFactory.kt#L95
93
-
94
- // React Native implementation fallback is PerftestDevSupportManager(applicationContext)
95
- // but that's internal class we would have to vendor, so this impl re-throws.
96
- // https://github.com/facebook/react-native/blob/50273758510a6d756494d05dc91055516c2a6aca/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt#L17
97
- }
98
- }
99
-
100
- override fun create(
101
- applicationContext: Context,
102
- reactInstanceManagerHelper: ReactInstanceDevHelper,
103
- packagerPathForJSBundleName: String?,
104
- enableOnCreate: Boolean,
105
- redBoxHandler: RedBoxHandler?,
106
- devBundleDownloadListener: DevBundleDownloadListener?,
107
- minNumShakes: Int,
108
- customPackagerCommandHandlers: Map<String, RequestHandler>?,
109
- surfaceDelegateFactory: SurfaceDelegateFactory?,
110
- devLoadingViewManager: DevLoadingViewManager?,
111
- pausedInDebuggerOverlayManager: PausedInDebuggerOverlayManager?,
112
- useDevSupport: Boolean
113
- ): DevSupportManager =
114
- if (ReactBuildConfig.UNSTABLE_ENABLE_FUSEBOX_RELEASE) {
115
- // Should never happen as ExpoDefaultDevSupportManagerFactory is only used if useDevSupport = true
116
- throw Error("ExpoDefaultDevSupportManagerFactory supports debug builds only. ReactBuildConfig.UNSTABLE_ENABLE_FUSEBOX_RELEASE is unsupported.")
117
-
118
- // Original implementation
119
- // https://github.com/facebook/react-native/blob/50273758510a6d756494d05dc91055516c2a6aca/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/DefaultDevSupportManagerFactory.kt#L114
120
-
121
- // React Native implementation uses PerftestDevSupportManager(applicationContext)
122
- // but that's internal class we would have to vendor, so this impl re-throws.
123
- // https://github.com/facebook/react-native/blob/50273758510a6d756494d05dc91055516c2a6aca/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PerftestDevSupportManager.kt#L17
124
- } else if (useDevSupport) {
125
- ExpoDevSupportManagerWithLogBoxOverride(
126
- applicationContext,
127
- reactInstanceManagerHelper,
128
- packagerPathForJSBundleName,
129
- enableOnCreate,
130
- redBoxHandler,
131
- devBundleDownloadListener,
132
- minNumShakes,
133
- customPackagerCommandHandlers,
134
- surfaceDelegateFactory,
135
- devLoadingViewManager,
136
- pausedInDebuggerOverlayManager)
137
- } else {
138
- ReleaseDevSupportManager()
139
- }
140
-
141
- private companion object {
142
- private const val DEVSUPPORT_IMPL_PACKAGE = "com.facebook.react.devsupport"
143
- private const val DEVSUPPORT_IMPL_CLASS = "BridgeDevSupportManager"
144
- }
145
- }
@@ -1,51 +0,0 @@
1
- package expo.modules
2
-
3
- import android.app.Application
4
- import android.content.Context
5
- import com.facebook.react.ReactHost
6
- import com.facebook.react.ReactNativeHost
7
- import com.facebook.react.ReactPackageTurboModuleManagerDelegate
8
- import com.facebook.react.bridge.UIManagerProvider
9
- import com.facebook.react.common.SurfaceDelegateFactory
10
- import com.facebook.react.devsupport.DevSupportManagerFactory
11
- import com.facebook.react.devsupport.interfaces.RedBoxHandler
12
-
13
- class ReactNativeHostWrapper(
14
- application: Application,
15
- host: ReactNativeHost
16
- ) : ReactNativeHostWrapperBase(application, host) {
17
- override fun getDevSupportManagerFactory(): DevSupportManagerFactory? {
18
- return reactNativeHostHandlers
19
- .asSequence()
20
- .mapNotNull { it.devSupportManagerFactory }
21
- .firstOrNull() as DevSupportManagerFactory?
22
- ?: invokeDelegateMethod("getDevSupportManagerFactory")
23
- }
24
-
25
- override fun getReactPackageTurboModuleManagerDelegateBuilder(): ReactPackageTurboModuleManagerDelegate.Builder? {
26
- return invokeDelegateMethod("getReactPackageTurboModuleManagerDelegateBuilder")
27
- }
28
-
29
- override fun getUIManagerProvider(): UIManagerProvider? {
30
- return invokeDelegateMethod("getUIManagerProvider")
31
- }
32
-
33
- override fun getShouldRequireActivity(): Boolean {
34
- return host.shouldRequireActivity
35
- }
36
-
37
- override fun getSurfaceDelegateFactory(): SurfaceDelegateFactory {
38
- return host.surfaceDelegateFactory
39
- }
40
-
41
- override fun getRedBoxHandler(): RedBoxHandler? {
42
- return invokeDelegateMethod("getRedBoxHandler")
43
- }
44
-
45
- companion object {
46
- @JvmStatic
47
- fun createReactHost(context: Context, reactNativeHost: ReactNativeHost): ReactHost {
48
- return ExpoReactHostFactory.createFromReactNativeHost(context, reactNativeHost)
49
- }
50
- }
51
- }