@granite-js/vitest 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +283 -0
- package/dist/assets-DoucBOz0.js +16 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +524 -0
- package/dist/reactNativeRuntime.d.ts +9 -0
- package/dist/reactNativeRuntime.js +1711 -0
- package/dist/runtimeBootstrap-CHWitCG1.js +291 -0
- package/dist/setup.d.ts +1 -0
- package/dist/setup.js +48 -0
- package/package.json +64 -0
|
@@ -0,0 +1,1711 @@
|
|
|
1
|
+
import { n as REACT_NATIVE_ASSET_MODULE_ID_PATTERN } from "./assets-DoucBOz0.js";
|
|
2
|
+
import { n as installNativeModuleProxy, r as installReactNativeGlobals, t as defineGlobalProperty } from "./runtimeBootstrap-CHWitCG1.js";
|
|
3
|
+
import Module, { createRequire } from "node:module";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import "@react-native/js-polyfills/error-guard";
|
|
7
|
+
import { vi } from "vitest";
|
|
8
|
+
|
|
9
|
+
//#region src/reactNativeRuntime.ts
|
|
10
|
+
const runtimeGlobals = globalThis;
|
|
11
|
+
const runtimeDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const runtimeRequire = createRequire(import.meta.url);
|
|
13
|
+
function resolveReactNativeMirrorRoot() {
|
|
14
|
+
if (typeof globalThis.__GRANITE_VITEST_RN_CACHE_ROOT__ === "string" && globalThis.__GRANITE_VITEST_RN_CACHE_ROOT__.length > 0) return path.resolve(globalThis.__GRANITE_VITEST_RN_CACHE_ROOT__);
|
|
15
|
+
throw new Error("[@granite-js/vitest] reactNativeRuntime requires reactNative() in vitest.config to set __GRANITE_VITEST_RN_CACHE_ROOT__.");
|
|
16
|
+
}
|
|
17
|
+
const reactNativeMirrorRoot = resolveReactNativeMirrorRoot();
|
|
18
|
+
let nextNativeTag = 1;
|
|
19
|
+
function createMockNativeMethods() {
|
|
20
|
+
return {
|
|
21
|
+
blur: vi.fn(),
|
|
22
|
+
focus: vi.fn(),
|
|
23
|
+
measure: vi.fn(),
|
|
24
|
+
measureInWindow: vi.fn(),
|
|
25
|
+
measureLayout: vi.fn(),
|
|
26
|
+
setNativeProps: vi.fn()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function createMockHostComponent(React, displayName, hostType, instanceMethods = {}, realComponent) {
|
|
30
|
+
const resolvedRealComponent = realComponent ?? null;
|
|
31
|
+
const superClass = typeof resolvedRealComponent === "function" && (resolvedRealComponent.prototype instanceof React.Component || resolvedRealComponent.prototype?.isReactComponent != null) ? resolvedRealComponent : React.Component;
|
|
32
|
+
const resolvedName = resolvedRealComponent?.displayName || resolvedRealComponent?.name || resolvedRealComponent?.render?.displayName || resolvedRealComponent?.render?.name || displayName;
|
|
33
|
+
const resolvedHostType = hostType || resolvedName.replace(/^(RCT|RK)/, "");
|
|
34
|
+
class Component extends superClass {
|
|
35
|
+
render() {
|
|
36
|
+
const sourceProps = this.props;
|
|
37
|
+
const props = { ...resolvedRealComponent?.defaultProps ?? {} };
|
|
38
|
+
Object.keys(sourceProps).forEach((propName) => {
|
|
39
|
+
if (sourceProps[propName] !== void 0) props[propName] = sourceProps[propName];
|
|
40
|
+
});
|
|
41
|
+
return React.createElement(resolvedHostType, props, props.children);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (resolvedRealComponent != null) Object.keys(resolvedRealComponent).forEach((classStatic) => {
|
|
45
|
+
Component[classStatic] = resolvedRealComponent[classStatic];
|
|
46
|
+
});
|
|
47
|
+
Object.assign(Component.prototype, instanceMethods);
|
|
48
|
+
Object.defineProperty(Component, "name", {
|
|
49
|
+
configurable: true,
|
|
50
|
+
enumerable: false,
|
|
51
|
+
value: resolvedName,
|
|
52
|
+
writable: false
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(Component, "displayName", {
|
|
55
|
+
configurable: true,
|
|
56
|
+
enumerable: true,
|
|
57
|
+
value: resolvedHostType,
|
|
58
|
+
writable: true
|
|
59
|
+
});
|
|
60
|
+
return Component;
|
|
61
|
+
}
|
|
62
|
+
function createMockNativeComponent(React, viewName) {
|
|
63
|
+
const hostName = viewName === "RCTView" ? "View" : viewName;
|
|
64
|
+
class Component extends React.Component {
|
|
65
|
+
_nativeTag = nextNativeTag++;
|
|
66
|
+
render() {
|
|
67
|
+
const props = this.props;
|
|
68
|
+
return React.createElement(hostName, props, props.children);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
Object.assign(Component.prototype, createMockNativeMethods());
|
|
72
|
+
Object.defineProperty(Component, "displayName", {
|
|
73
|
+
configurable: true,
|
|
74
|
+
enumerable: true,
|
|
75
|
+
value: hostName,
|
|
76
|
+
writable: true
|
|
77
|
+
});
|
|
78
|
+
return Component;
|
|
79
|
+
}
|
|
80
|
+
function createAccessibilityInfoMockModule() {
|
|
81
|
+
return {
|
|
82
|
+
__esModule: true,
|
|
83
|
+
default: {
|
|
84
|
+
addEventListener: vi.fn(() => ({ remove: vi.fn() })),
|
|
85
|
+
announceForAccessibility: vi.fn(),
|
|
86
|
+
announceForAccessibilityWithOptions: vi.fn(),
|
|
87
|
+
getRecommendedTimeoutMillis: vi.fn(() => Promise.resolve(false)),
|
|
88
|
+
isAccessibilityServiceEnabled: vi.fn(() => Promise.resolve(false)),
|
|
89
|
+
isBoldTextEnabled: vi.fn(() => Promise.resolve(false)),
|
|
90
|
+
isDarkerSystemColorsEnabled: vi.fn(() => Promise.resolve(false)),
|
|
91
|
+
isGrayscaleEnabled: vi.fn(() => Promise.resolve(false)),
|
|
92
|
+
isHighTextContrastEnabled: vi.fn(() => Promise.resolve(false)),
|
|
93
|
+
isInvertColorsEnabled: vi.fn(() => Promise.resolve(false)),
|
|
94
|
+
isReduceMotionEnabled: vi.fn(() => Promise.resolve(false)),
|
|
95
|
+
isReduceTransparencyEnabled: vi.fn(() => Promise.resolve(false)),
|
|
96
|
+
isScreenReaderEnabled: vi.fn(() => Promise.resolve(false)),
|
|
97
|
+
prefersCrossFadeTransitions: vi.fn(() => Promise.resolve(false)),
|
|
98
|
+
sendAccessibilityEvent: vi.fn(),
|
|
99
|
+
setAccessibilityFocus: vi.fn()
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function createClipboardMockModule() {
|
|
104
|
+
return {
|
|
105
|
+
__esModule: true,
|
|
106
|
+
default: {
|
|
107
|
+
getString: vi.fn(() => ""),
|
|
108
|
+
setString: vi.fn()
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function createRefreshControlMockModule() {
|
|
113
|
+
const React = runtimeRequire("react");
|
|
114
|
+
const RCTRefreshControl = createMockNativeComponent(React, "RCTRefreshControl");
|
|
115
|
+
class RefreshControlMock extends React.Component {
|
|
116
|
+
static latestRef;
|
|
117
|
+
componentDidMount() {
|
|
118
|
+
RefreshControlMock.latestRef = this;
|
|
119
|
+
}
|
|
120
|
+
render() {
|
|
121
|
+
return React.createElement(RCTRefreshControl);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
__esModule: true,
|
|
126
|
+
default: RefreshControlMock
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function createActivityIndicatorMockModule() {
|
|
130
|
+
return {
|
|
131
|
+
__esModule: true,
|
|
132
|
+
default: createMockHostComponent(runtimeRequire("react"), "ActivityIndicator", "ActivityIndicator")
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function createImageMockModule() {
|
|
136
|
+
return {
|
|
137
|
+
__esModule: true,
|
|
138
|
+
default: createMockHostComponent(runtimeRequire("react"), "Image", "Image")
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function createTextMockModule() {
|
|
142
|
+
return {
|
|
143
|
+
__esModule: true,
|
|
144
|
+
default: createMockHostComponent(runtimeRequire("react"), "Text", "Text", createMockNativeMethods())
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function createTextInputMockModule() {
|
|
148
|
+
return {
|
|
149
|
+
__esModule: true,
|
|
150
|
+
default: createMockHostComponent(runtimeRequire("react"), "TextInput", "TextInput", {
|
|
151
|
+
...createMockNativeMethods(),
|
|
152
|
+
clear: vi.fn(),
|
|
153
|
+
getNativeRef: vi.fn(function getNativeRef() {
|
|
154
|
+
return this;
|
|
155
|
+
}),
|
|
156
|
+
isFocused: vi.fn(() => false)
|
|
157
|
+
})
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function createModalMockModule() {
|
|
161
|
+
const React = runtimeRequire("react");
|
|
162
|
+
const BaseComponent = createMockHostComponent(React, "Modal", "Modal");
|
|
163
|
+
class ModalMock extends BaseComponent {
|
|
164
|
+
render() {
|
|
165
|
+
const props = this.props;
|
|
166
|
+
if (props.visible === false) return null;
|
|
167
|
+
return React.createElement(BaseComponent, props, props.children);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
Object.defineProperty(ModalMock, "displayName", {
|
|
171
|
+
configurable: true,
|
|
172
|
+
enumerable: true,
|
|
173
|
+
value: "Modal",
|
|
174
|
+
writable: true
|
|
175
|
+
});
|
|
176
|
+
return {
|
|
177
|
+
__esModule: true,
|
|
178
|
+
default: ModalMock
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function createViewMockModule() {
|
|
182
|
+
return {
|
|
183
|
+
__esModule: true,
|
|
184
|
+
default: createMockHostComponent(runtimeRequire("react"), "View", "View", createMockNativeMethods())
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function createScrollViewMockModule(sharedView) {
|
|
188
|
+
const React = runtimeRequire("react");
|
|
189
|
+
const BaseComponent = createMockHostComponent(React, "ScrollView", "ScrollView", {
|
|
190
|
+
...createMockNativeMethods(),
|
|
191
|
+
flashScrollIndicators: vi.fn(),
|
|
192
|
+
getInnerViewNode: vi.fn(),
|
|
193
|
+
getInnerViewRef: vi.fn(),
|
|
194
|
+
getNativeScrollRef: vi.fn(),
|
|
195
|
+
getScrollResponder: vi.fn(),
|
|
196
|
+
getScrollableNode: vi.fn(),
|
|
197
|
+
scrollResponderScrollNativeHandleToKeyboard: vi.fn(),
|
|
198
|
+
scrollResponderZoomTo: vi.fn(),
|
|
199
|
+
scrollTo: vi.fn(),
|
|
200
|
+
scrollToEnd: vi.fn()
|
|
201
|
+
});
|
|
202
|
+
const View = sharedView ?? createViewMockModule().default;
|
|
203
|
+
const RCTScrollView = createMockNativeComponent(React, "RCTScrollView");
|
|
204
|
+
class ScrollViewMock extends BaseComponent {
|
|
205
|
+
render() {
|
|
206
|
+
const props = this.props;
|
|
207
|
+
return React.createElement(RCTScrollView, props, props.refreshControl, React.createElement(View, null, props.children));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
Object.defineProperty(ScrollViewMock, "displayName", {
|
|
211
|
+
configurable: true,
|
|
212
|
+
enumerable: true,
|
|
213
|
+
value: "ScrollView",
|
|
214
|
+
writable: true
|
|
215
|
+
});
|
|
216
|
+
return {
|
|
217
|
+
__esModule: true,
|
|
218
|
+
default: ScrollViewMock
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function createAppStateMockModule() {
|
|
222
|
+
return {
|
|
223
|
+
__esModule: true,
|
|
224
|
+
default: {
|
|
225
|
+
addEventListener: vi.fn(() => ({ remove: vi.fn() })),
|
|
226
|
+
currentState: "active",
|
|
227
|
+
removeEventListener: vi.fn()
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function createLinkingMockModule() {
|
|
232
|
+
return {
|
|
233
|
+
__esModule: true,
|
|
234
|
+
default: {
|
|
235
|
+
addEventListener: vi.fn(() => ({ remove: vi.fn() })),
|
|
236
|
+
canOpenURL: vi.fn(() => Promise.resolve(true)),
|
|
237
|
+
getInitialURL: vi.fn(() => Promise.resolve()),
|
|
238
|
+
openSettings: vi.fn(),
|
|
239
|
+
openURL: vi.fn(),
|
|
240
|
+
sendIntent: vi.fn()
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function createVibrationMockModule() {
|
|
245
|
+
return {
|
|
246
|
+
__esModule: true,
|
|
247
|
+
default: {
|
|
248
|
+
cancel: vi.fn(),
|
|
249
|
+
vibrate: vi.fn()
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function createViewNativeComponentMockModule() {
|
|
254
|
+
return {
|
|
255
|
+
__esModule: true,
|
|
256
|
+
default: createMockHostComponent(runtimeRequire("react"), "View", "View")
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
function createUseColorSchemeMockModule() {
|
|
260
|
+
return {
|
|
261
|
+
__esModule: true,
|
|
262
|
+
default: vi.fn().mockReturnValue("light")
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function createPlatformMockModule() {
|
|
266
|
+
const platformConstants = runtimeGlobals.nativeModuleProxy?.PlatformConstants?.getConstants?.() ?? {
|
|
267
|
+
forceTouchAvailable: false,
|
|
268
|
+
interfaceIdiom: "phone",
|
|
269
|
+
isDisableAnimations: false,
|
|
270
|
+
isMacCatalyst: false,
|
|
271
|
+
isTesting: true,
|
|
272
|
+
osVersion: "17.0",
|
|
273
|
+
reactNativeVersion: {
|
|
274
|
+
major: 0,
|
|
275
|
+
minor: 79,
|
|
276
|
+
patch: 5,
|
|
277
|
+
prerelease: void 0
|
|
278
|
+
},
|
|
279
|
+
systemName: "iOS"
|
|
280
|
+
};
|
|
281
|
+
const platform = {
|
|
282
|
+
OS: "ios",
|
|
283
|
+
select: (spec) => "ios" in spec ? spec.ios : "native" in spec ? spec.native : spec.default,
|
|
284
|
+
get Version() {
|
|
285
|
+
return platformConstants.osVersion;
|
|
286
|
+
},
|
|
287
|
+
get constants() {
|
|
288
|
+
return platformConstants;
|
|
289
|
+
},
|
|
290
|
+
get isPad() {
|
|
291
|
+
return platformConstants.interfaceIdiom === "pad";
|
|
292
|
+
},
|
|
293
|
+
get isTV() {
|
|
294
|
+
return platformConstants.interfaceIdiom === "tv";
|
|
295
|
+
},
|
|
296
|
+
get isVision() {
|
|
297
|
+
return platformConstants.interfaceIdiom === "vision";
|
|
298
|
+
},
|
|
299
|
+
get isTesting() {
|
|
300
|
+
return runtimeGlobals.__DEV__ ? platformConstants.isTesting : false;
|
|
301
|
+
},
|
|
302
|
+
get isDisableAnimations() {
|
|
303
|
+
return platformConstants.isDisableAnimations ?? platform.isTesting;
|
|
304
|
+
},
|
|
305
|
+
get isMacCatalyst() {
|
|
306
|
+
return platformConstants.isMacCatalyst ?? false;
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
return {
|
|
310
|
+
__esModule: true,
|
|
311
|
+
default: platform
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
function createStyleSheetMockModule() {
|
|
315
|
+
const styleSheet = {
|
|
316
|
+
absoluteFill: {
|
|
317
|
+
bottom: 0,
|
|
318
|
+
left: 0,
|
|
319
|
+
position: "absolute",
|
|
320
|
+
right: 0,
|
|
321
|
+
top: 0
|
|
322
|
+
},
|
|
323
|
+
absoluteFillObject: {
|
|
324
|
+
bottom: 0,
|
|
325
|
+
left: 0,
|
|
326
|
+
position: "absolute",
|
|
327
|
+
right: 0,
|
|
328
|
+
top: 0
|
|
329
|
+
},
|
|
330
|
+
compose: vi.fn((left, right) => {
|
|
331
|
+
if (left == null) return right;
|
|
332
|
+
if (right == null) return left;
|
|
333
|
+
return [left, right];
|
|
334
|
+
}),
|
|
335
|
+
create: vi.fn((styles) => styles),
|
|
336
|
+
flatten: vi.fn((style) => {
|
|
337
|
+
if (!Array.isArray(style)) return style ?? {};
|
|
338
|
+
return style.filter(Boolean).reduce((accumulator, value) => {
|
|
339
|
+
if (typeof value === "object" && value != null && !Array.isArray(value)) Object.assign(accumulator, value);
|
|
340
|
+
return accumulator;
|
|
341
|
+
}, {});
|
|
342
|
+
}),
|
|
343
|
+
hairlineWidth: 1,
|
|
344
|
+
setStyleAttributePreprocessor: vi.fn()
|
|
345
|
+
};
|
|
346
|
+
return {
|
|
347
|
+
__esModule: true,
|
|
348
|
+
...styleSheet,
|
|
349
|
+
default: styleSheet
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function createInitializeCoreMockModule() {
|
|
353
|
+
return {
|
|
354
|
+
__esModule: true,
|
|
355
|
+
default: {}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function createNativeExceptionsManagerMockModule() {
|
|
359
|
+
const nativeExceptionsManager = {
|
|
360
|
+
dismissRedbox: vi.fn(),
|
|
361
|
+
reportException: vi.fn(),
|
|
362
|
+
updateExceptionMessage: vi.fn()
|
|
363
|
+
};
|
|
364
|
+
return {
|
|
365
|
+
__esModule: true,
|
|
366
|
+
default: nativeExceptionsManager,
|
|
367
|
+
...nativeExceptionsManager
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
function createRendererProxyMockModule() {
|
|
371
|
+
const rendererProxy = {
|
|
372
|
+
dispatchCommand: vi.fn(),
|
|
373
|
+
findHostInstance_DEPRECATED: vi.fn((component) => component ?? null),
|
|
374
|
+
findNodeHandle: vi.fn((component) => {
|
|
375
|
+
if (component == null) return null;
|
|
376
|
+
return component._nativeTag ?? 1;
|
|
377
|
+
}),
|
|
378
|
+
getNodeFromInternalInstanceHandle: vi.fn((handle) => handle ?? null),
|
|
379
|
+
getPublicInstanceFromInternalInstanceHandle: vi.fn((handle) => handle ?? null),
|
|
380
|
+
getPublicInstanceFromRootTag: vi.fn((rootTag) => rootTag ?? null),
|
|
381
|
+
isChildPublicInstance: vi.fn(() => false),
|
|
382
|
+
isProfilingRenderer: vi.fn(() => false),
|
|
383
|
+
renderElement: vi.fn(),
|
|
384
|
+
sendAccessibilityEvent: vi.fn(),
|
|
385
|
+
unstable_batchedUpdates: vi.fn((callback, ...args) => callback(...args)),
|
|
386
|
+
unmountComponentAtNodeAndRemoveContainer: vi.fn()
|
|
387
|
+
};
|
|
388
|
+
return {
|
|
389
|
+
__esModule: true,
|
|
390
|
+
...rendererProxy,
|
|
391
|
+
default: rendererProxy
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function createUIManagerMockModule() {
|
|
395
|
+
return {
|
|
396
|
+
__esModule: true,
|
|
397
|
+
default: runtimeGlobals.nativeModuleProxy?.UIManager ?? {}
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function createNativeModulesMockModule() {
|
|
401
|
+
return {
|
|
402
|
+
__esModule: true,
|
|
403
|
+
default: runtimeGlobals.nativeModuleProxy ?? {}
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
function createNativeComponentRegistryMockModule() {
|
|
407
|
+
const registry = {
|
|
408
|
+
get: vi.fn((name) => createMockNativeComponent(runtimeRequire("react"), name)),
|
|
409
|
+
getWithFallback_DEPRECATED: vi.fn((name) => createMockNativeComponent(runtimeRequire("react"), name)),
|
|
410
|
+
setRuntimeConfigProvider: vi.fn(),
|
|
411
|
+
unstable_hasStaticViewConfig: vi.fn(() => false)
|
|
412
|
+
};
|
|
413
|
+
return {
|
|
414
|
+
__esModule: true,
|
|
415
|
+
...registry,
|
|
416
|
+
default: registry
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
function createRequireNativeComponentMockModule() {
|
|
420
|
+
return {
|
|
421
|
+
__esModule: true,
|
|
422
|
+
default: vi.fn((name) => createMockNativeComponent(runtimeRequire("react"), name))
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
function createCodegenNativeComponentMockModule() {
|
|
426
|
+
return {
|
|
427
|
+
__esModule: true,
|
|
428
|
+
default: vi.fn((componentName, options) => {
|
|
429
|
+
const { requireNativeComponentModule, uiManagerModule } = getSharedReactNativeMockModules();
|
|
430
|
+
const requireNativeComponent = requireNativeComponentModule.default ?? requireNativeComponentModule;
|
|
431
|
+
const uiManager = uiManagerModule.default ?? uiManagerModule;
|
|
432
|
+
let componentNameInUse = options?.paperComponentName != null ? options.paperComponentName : componentName;
|
|
433
|
+
if (options?.paperComponentNameDeprecated != null && typeof uiManager?.hasViewManagerConfig === "function") {
|
|
434
|
+
if (uiManager.hasViewManagerConfig(componentName)) componentNameInUse = componentName;
|
|
435
|
+
else if (uiManager.hasViewManagerConfig(options.paperComponentNameDeprecated)) componentNameInUse = options.paperComponentNameDeprecated;
|
|
436
|
+
}
|
|
437
|
+
return requireNativeComponent(componentNameInUse);
|
|
438
|
+
})
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function createCodegenNativeCommandsMockModule() {
|
|
442
|
+
return {
|
|
443
|
+
__esModule: true,
|
|
444
|
+
default: vi.fn((options) => {
|
|
445
|
+
const { rendererProxyModule } = getSharedReactNativeMockModules();
|
|
446
|
+
const rendererProxy = rendererProxyModule.default ?? rendererProxyModule;
|
|
447
|
+
const commandObject = {};
|
|
448
|
+
for (const command of options.supportedCommands ?? []) commandObject[command] = vi.fn((ref, ...args) => {
|
|
449
|
+
rendererProxy.dispatchCommand(ref, command, args);
|
|
450
|
+
});
|
|
451
|
+
return commandObject;
|
|
452
|
+
})
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
let sharedReactNativeMockModules = null;
|
|
456
|
+
let sharedReactNativeExports = null;
|
|
457
|
+
function getSharedReactNativeMockModules() {
|
|
458
|
+
if (sharedReactNativeMockModules != null) return sharedReactNativeMockModules;
|
|
459
|
+
const viewModule = createViewMockModule();
|
|
460
|
+
sharedReactNativeMockModules = {
|
|
461
|
+
accessibilityInfoModule: createAccessibilityInfoMockModule(),
|
|
462
|
+
activityIndicatorModule: createActivityIndicatorMockModule(),
|
|
463
|
+
appStateModule: createAppStateMockModule(),
|
|
464
|
+
clipboardModule: createClipboardMockModule(),
|
|
465
|
+
codegenNativeCommandsModule: createCodegenNativeCommandsMockModule(),
|
|
466
|
+
codegenNativeComponentModule: createCodegenNativeComponentMockModule(),
|
|
467
|
+
imageModule: createImageMockModule(),
|
|
468
|
+
initializeCoreModule: createInitializeCoreMockModule(),
|
|
469
|
+
linkingModule: createLinkingMockModule(),
|
|
470
|
+
modalModule: createModalMockModule(),
|
|
471
|
+
nativeComponentRegistryModule: createNativeComponentRegistryMockModule(),
|
|
472
|
+
nativeExceptionsManagerModule: createNativeExceptionsManagerMockModule(),
|
|
473
|
+
nativeModulesModule: createNativeModulesMockModule(),
|
|
474
|
+
platformModule: createPlatformMockModule(),
|
|
475
|
+
refreshControlModule: createRefreshControlMockModule(),
|
|
476
|
+
rendererProxyModule: createRendererProxyMockModule(),
|
|
477
|
+
requireNativeComponentModule: createRequireNativeComponentMockModule(),
|
|
478
|
+
scrollViewModule: createScrollViewMockModule(viewModule.default),
|
|
479
|
+
styleSheetModule: createStyleSheetMockModule(),
|
|
480
|
+
textInputModule: createTextInputMockModule(),
|
|
481
|
+
textModule: createTextMockModule(),
|
|
482
|
+
uiManagerModule: createUIManagerMockModule(),
|
|
483
|
+
useColorSchemeModule: createUseColorSchemeMockModule(),
|
|
484
|
+
vibrationModule: createVibrationMockModule(),
|
|
485
|
+
viewModule,
|
|
486
|
+
viewNativeComponentModule: createViewNativeComponentMockModule()
|
|
487
|
+
};
|
|
488
|
+
return sharedReactNativeMockModules;
|
|
489
|
+
}
|
|
490
|
+
function getSharedReactNativeExports() {
|
|
491
|
+
if (sharedReactNativeExports != null) return sharedReactNativeExports;
|
|
492
|
+
const React = runtimeRequire("react");
|
|
493
|
+
const { accessibilityInfoModule, activityIndicatorModule, appStateModule, clipboardModule, codegenNativeCommandsModule, codegenNativeComponentModule, imageModule, linkingModule, modalModule, nativeComponentRegistryModule, nativeModulesModule, platformModule, refreshControlModule, rendererProxyModule, requireNativeComponentModule, scrollViewModule, styleSheetModule, textInputModule, textModule, uiManagerModule, useColorSchemeModule, vibrationModule, viewModule, viewNativeComponentModule } = getSharedReactNativeMockModules();
|
|
494
|
+
let dimensionsState = runtimeGlobals.nativeModuleProxy?.DeviceInfo?.getConstants?.().Dimensions ?? {
|
|
495
|
+
screen: {
|
|
496
|
+
fontScale: 2,
|
|
497
|
+
height: 1334,
|
|
498
|
+
scale: 2,
|
|
499
|
+
width: 750
|
|
500
|
+
},
|
|
501
|
+
window: {
|
|
502
|
+
fontScale: 2,
|
|
503
|
+
height: 1334,
|
|
504
|
+
scale: 2,
|
|
505
|
+
width: 750
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
const dimensionListeners = /* @__PURE__ */ new Set();
|
|
509
|
+
const Dimensions = {
|
|
510
|
+
addEventListener: vi.fn((type, handler) => {
|
|
511
|
+
if (type === "change") dimensionListeners.add(handler);
|
|
512
|
+
return { remove: () => dimensionListeners.delete(handler) };
|
|
513
|
+
}),
|
|
514
|
+
get: vi.fn((name) => dimensionsState[name]),
|
|
515
|
+
set: vi.fn((nextDimensions) => {
|
|
516
|
+
dimensionsState = {
|
|
517
|
+
...dimensionsState,
|
|
518
|
+
...nextDimensions
|
|
519
|
+
};
|
|
520
|
+
dimensionListeners.forEach((listener) => listener(dimensionsState));
|
|
521
|
+
})
|
|
522
|
+
};
|
|
523
|
+
const useWindowDimensions = () => Dimensions.get("window");
|
|
524
|
+
const createEventEmitter = () => {
|
|
525
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
526
|
+
return {
|
|
527
|
+
addListener: vi.fn((eventType, listener) => {
|
|
528
|
+
const eventListeners = listeners.get(eventType) ?? /* @__PURE__ */ new Set();
|
|
529
|
+
eventListeners.add(listener);
|
|
530
|
+
listeners.set(eventType, eventListeners);
|
|
531
|
+
return { remove: () => eventListeners.delete(listener) };
|
|
532
|
+
}),
|
|
533
|
+
emit: vi.fn((eventType, ...args) => {
|
|
534
|
+
listeners.get(eventType)?.forEach((listener) => listener(...args));
|
|
535
|
+
}),
|
|
536
|
+
removeAllListeners: vi.fn((eventType) => {
|
|
537
|
+
if (eventType == null) {
|
|
538
|
+
listeners.clear();
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
listeners.delete(eventType);
|
|
542
|
+
}),
|
|
543
|
+
listenerCount: vi.fn((eventType) => listeners.get(eventType)?.size ?? 0)
|
|
544
|
+
};
|
|
545
|
+
};
|
|
546
|
+
const DeviceInfo = runtimeGlobals.nativeModuleProxy?.DeviceInfo ?? { getConstants: vi.fn(() => ({ Dimensions: dimensionsState })) };
|
|
547
|
+
const DevSettings = {
|
|
548
|
+
...runtimeGlobals.nativeModuleProxy?.DevSettings ?? {},
|
|
549
|
+
addMenuItem: vi.fn(),
|
|
550
|
+
onFastRefresh: vi.fn(),
|
|
551
|
+
reload: vi.fn()
|
|
552
|
+
};
|
|
553
|
+
const i18nConstants = runtimeGlobals.nativeModuleProxy?.I18nManager?.getConstants?.() ?? {
|
|
554
|
+
doLeftAndRightSwapInRTL: true,
|
|
555
|
+
isRTL: false,
|
|
556
|
+
localeIdentifier: "en_US"
|
|
557
|
+
};
|
|
558
|
+
const I18nManager = {
|
|
559
|
+
allowRTL: vi.fn((shouldAllow) => runtimeGlobals.nativeModuleProxy?.I18nManager?.allowRTL?.(shouldAllow)),
|
|
560
|
+
doLeftAndRightSwapInRTL: i18nConstants.doLeftAndRightSwapInRTL,
|
|
561
|
+
forceRTL: vi.fn((shouldForce) => runtimeGlobals.nativeModuleProxy?.I18nManager?.forceRTL?.(shouldForce)),
|
|
562
|
+
getConstants: vi.fn(() => i18nConstants),
|
|
563
|
+
isRTL: i18nConstants.isRTL,
|
|
564
|
+
swapLeftAndRightInRTL: vi.fn((shouldSwap) => runtimeGlobals.nativeModuleProxy?.I18nManager?.swapLeftAndRightInRTL?.(shouldSwap))
|
|
565
|
+
};
|
|
566
|
+
const PlatformColor = (...names) => ({ semantic: names });
|
|
567
|
+
const processColor = vi.fn((color) => color);
|
|
568
|
+
const turboModuleLookup = (name) => runtimeGlobals.__turboModuleProxy?.(name) ?? runtimeGlobals.nativeModuleProxy?.[name] ?? null;
|
|
569
|
+
const TurboModuleRegistry = {
|
|
570
|
+
get: vi.fn((name) => turboModuleLookup(name)),
|
|
571
|
+
getEnforcing: vi.fn((name) => {
|
|
572
|
+
const module = turboModuleLookup(name);
|
|
573
|
+
if (module == null) throw new Error(`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found.`);
|
|
574
|
+
return module;
|
|
575
|
+
})
|
|
576
|
+
};
|
|
577
|
+
const ActionSheetIOS = {
|
|
578
|
+
dismissActionSheet: vi.fn(),
|
|
579
|
+
showActionSheetWithOptions: vi.fn((_options, callback) => callback(0)),
|
|
580
|
+
showShareActionSheetWithOptions: vi.fn((_options, _failureCallback, successCallback) => successCallback(true, null))
|
|
581
|
+
};
|
|
582
|
+
const Alert = {
|
|
583
|
+
alert: vi.fn(),
|
|
584
|
+
prompt: vi.fn()
|
|
585
|
+
};
|
|
586
|
+
let appearanceColorScheme = "light";
|
|
587
|
+
const appearanceListeners = /* @__PURE__ */ new Set();
|
|
588
|
+
const Appearance = {
|
|
589
|
+
addChangeListener: vi.fn((listener) => {
|
|
590
|
+
appearanceListeners.add(listener);
|
|
591
|
+
return { remove: () => appearanceListeners.delete(listener) };
|
|
592
|
+
}),
|
|
593
|
+
getColorScheme: vi.fn(() => appearanceColorScheme),
|
|
594
|
+
setColorScheme: vi.fn((nextColorScheme) => {
|
|
595
|
+
appearanceColorScheme = nextColorScheme;
|
|
596
|
+
appearanceListeners.forEach((listener) => listener({ colorScheme: appearanceColorScheme }));
|
|
597
|
+
})
|
|
598
|
+
};
|
|
599
|
+
const backPressSubscriptions = /* @__PURE__ */ new Set();
|
|
600
|
+
const BackHandler = {
|
|
601
|
+
addEventListener: vi.fn((_eventName, handler) => {
|
|
602
|
+
backPressSubscriptions.add(handler);
|
|
603
|
+
return { remove: () => backPressSubscriptions.delete(handler) };
|
|
604
|
+
}),
|
|
605
|
+
exitApp: vi.fn()
|
|
606
|
+
};
|
|
607
|
+
const DeviceEventEmitter = createEventEmitter();
|
|
608
|
+
const NativeAppEventEmitter = DeviceEventEmitter;
|
|
609
|
+
const Keyboard = {
|
|
610
|
+
...createEventEmitter(),
|
|
611
|
+
dismiss: vi.fn(),
|
|
612
|
+
isVisible: vi.fn(() => false),
|
|
613
|
+
metrics: vi.fn(() => null),
|
|
614
|
+
scheduleLayoutAnimation: vi.fn()
|
|
615
|
+
};
|
|
616
|
+
const PixelRatio = {
|
|
617
|
+
get: vi.fn(() => Dimensions.get("window").scale),
|
|
618
|
+
getFontScale: vi.fn(() => Dimensions.get("window").fontScale || Dimensions.get("window").scale),
|
|
619
|
+
getPixelSizeForLayoutSize: vi.fn((layoutSize) => Math.round(layoutSize * Dimensions.get("window").scale)),
|
|
620
|
+
roundToNearestPixel: vi.fn((layoutSize) => {
|
|
621
|
+
const ratio = Dimensions.get("window").scale;
|
|
622
|
+
return Math.round(layoutSize * ratio) / ratio;
|
|
623
|
+
}),
|
|
624
|
+
startDetecting: vi.fn()
|
|
625
|
+
};
|
|
626
|
+
const settingsSubscriptions = [];
|
|
627
|
+
const Settings = {
|
|
628
|
+
_settings: {},
|
|
629
|
+
clearWatch: vi.fn((watchId) => {
|
|
630
|
+
if (watchId < settingsSubscriptions.length) settingsSubscriptions[watchId] = {
|
|
631
|
+
callback: null,
|
|
632
|
+
keys: []
|
|
633
|
+
};
|
|
634
|
+
}),
|
|
635
|
+
get: vi.fn((key) => Settings._settings[key]),
|
|
636
|
+
set: vi.fn((nextSettings) => {
|
|
637
|
+
Settings._settings = {
|
|
638
|
+
...Settings._settings,
|
|
639
|
+
...nextSettings
|
|
640
|
+
};
|
|
641
|
+
Object.keys(nextSettings).forEach((key) => {
|
|
642
|
+
settingsSubscriptions.forEach((subscription) => {
|
|
643
|
+
if (subscription.callback && subscription.keys.includes(key)) subscription.callback();
|
|
644
|
+
});
|
|
645
|
+
});
|
|
646
|
+
}),
|
|
647
|
+
watchKeys: vi.fn((keys, callback) => {
|
|
648
|
+
const normalizedKeys = Array.isArray(keys) ? keys : [keys];
|
|
649
|
+
const watchId = settingsSubscriptions.length;
|
|
650
|
+
settingsSubscriptions.push({
|
|
651
|
+
callback,
|
|
652
|
+
keys: normalizedKeys
|
|
653
|
+
});
|
|
654
|
+
return watchId;
|
|
655
|
+
})
|
|
656
|
+
};
|
|
657
|
+
const Share = {
|
|
658
|
+
dismissedAction: "dismissedAction",
|
|
659
|
+
share: vi.fn(async () => ({
|
|
660
|
+
action: "sharedAction",
|
|
661
|
+
activityType: null
|
|
662
|
+
})),
|
|
663
|
+
sharedAction: "sharedAction"
|
|
664
|
+
};
|
|
665
|
+
const callableModules = runtimeGlobals.__rntlCallableModules ?? {
|
|
666
|
+
callable: {},
|
|
667
|
+
lazy: {}
|
|
668
|
+
};
|
|
669
|
+
defineGlobalProperty(runtimeGlobals, "__rntlCallableModules", callableModules);
|
|
670
|
+
const registerCallableModule = vi.fn((name, moduleOrFactory) => {
|
|
671
|
+
if (runtimeGlobals.RN$Bridgeless === true && typeof runtimeGlobals.RN$registerCallableModule === "function") {
|
|
672
|
+
if (typeof moduleOrFactory === "function") {
|
|
673
|
+
runtimeGlobals.RN$registerCallableModule(name, moduleOrFactory);
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
runtimeGlobals.RN$registerCallableModule(name, () => moduleOrFactory);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
if (typeof moduleOrFactory === "function") {
|
|
680
|
+
callableModules.lazy[name] = moduleOrFactory;
|
|
681
|
+
delete callableModules.callable[name];
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
callableModules.callable[name] = moduleOrFactory;
|
|
685
|
+
delete callableModules.lazy[name];
|
|
686
|
+
});
|
|
687
|
+
const Button = ({ accessibilityState, disabled, title, ...props }) => React.createElement("View", {
|
|
688
|
+
...props,
|
|
689
|
+
accessibilityRole: "button",
|
|
690
|
+
accessibilityState: {
|
|
691
|
+
...accessibilityState ?? {},
|
|
692
|
+
disabled: Boolean(disabled)
|
|
693
|
+
},
|
|
694
|
+
accessible: props.accessible ?? true
|
|
695
|
+
}, React.createElement("Text", null, platformModule.default?.OS === "android" ? title.toUpperCase() : title));
|
|
696
|
+
Button.displayName = "Button";
|
|
697
|
+
class DrawerLayoutAndroid extends React.Component {
|
|
698
|
+
closeDrawer = vi.fn();
|
|
699
|
+
openDrawer = vi.fn();
|
|
700
|
+
render() {
|
|
701
|
+
const props = this.props;
|
|
702
|
+
return React.createElement("AndroidDrawerLayout", props, props.children);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
Object.assign(DrawerLayoutAndroid.prototype, createMockNativeMethods());
|
|
706
|
+
Object.defineProperty(DrawerLayoutAndroid, "displayName", {
|
|
707
|
+
configurable: true,
|
|
708
|
+
enumerable: true,
|
|
709
|
+
value: "DrawerLayoutAndroid",
|
|
710
|
+
writable: true
|
|
711
|
+
});
|
|
712
|
+
const createListSeparators = () => ({
|
|
713
|
+
highlight: vi.fn(),
|
|
714
|
+
unhighlight: vi.fn(),
|
|
715
|
+
updateProps: vi.fn()
|
|
716
|
+
});
|
|
717
|
+
const getItemKey = (item, index, keyExtractor) => keyExtractor?.(item, index) ?? item?.key ?? String(index);
|
|
718
|
+
class FlatList extends React.PureComponent {
|
|
719
|
+
flashScrollIndicators = vi.fn();
|
|
720
|
+
getNativeScrollRef = vi.fn(() => this.scrollViewRef);
|
|
721
|
+
getScrollResponder = vi.fn(() => this.scrollViewRef);
|
|
722
|
+
getScrollableNode = vi.fn(() => this.scrollViewRef);
|
|
723
|
+
recordInteraction = vi.fn();
|
|
724
|
+
scrollToEnd = vi.fn();
|
|
725
|
+
scrollToIndex = vi.fn();
|
|
726
|
+
scrollToItem = vi.fn();
|
|
727
|
+
scrollToOffset = vi.fn();
|
|
728
|
+
setNativeProps = vi.fn();
|
|
729
|
+
scrollViewRef = null;
|
|
730
|
+
setScrollViewRef = (ref) => {
|
|
731
|
+
this.scrollViewRef = ref;
|
|
732
|
+
};
|
|
733
|
+
render() {
|
|
734
|
+
const { data, keyExtractor, renderItem, ...props } = this.props;
|
|
735
|
+
const ScrollViewComponent = scrollViewModule.default ?? scrollViewModule;
|
|
736
|
+
const items = Array.isArray(data) ? data : [];
|
|
737
|
+
return React.createElement(ScrollViewComponent, {
|
|
738
|
+
...props,
|
|
739
|
+
ref: this.setScrollViewRef
|
|
740
|
+
}, items.map((item, index) => React.createElement(React.Fragment, { key: getItemKey(item, index, keyExtractor) }, renderItem?.({
|
|
741
|
+
index,
|
|
742
|
+
item,
|
|
743
|
+
separators: createListSeparators()
|
|
744
|
+
}))));
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
Object.defineProperty(FlatList, "displayName", {
|
|
748
|
+
configurable: true,
|
|
749
|
+
enumerable: true,
|
|
750
|
+
value: "FlatList",
|
|
751
|
+
writable: true
|
|
752
|
+
});
|
|
753
|
+
class VirtualizedList extends React.PureComponent {
|
|
754
|
+
flashScrollIndicators = vi.fn();
|
|
755
|
+
getNativeScrollRef = vi.fn(() => this.scrollViewRef);
|
|
756
|
+
getScrollResponder = vi.fn(() => this.scrollViewRef);
|
|
757
|
+
getScrollableNode = vi.fn(() => this.scrollViewRef);
|
|
758
|
+
recordInteraction = vi.fn();
|
|
759
|
+
scrollToEnd = vi.fn();
|
|
760
|
+
scrollToIndex = vi.fn();
|
|
761
|
+
scrollToOffset = vi.fn();
|
|
762
|
+
setNativeProps = vi.fn();
|
|
763
|
+
scrollViewRef = null;
|
|
764
|
+
setScrollViewRef = (ref) => {
|
|
765
|
+
this.scrollViewRef = ref;
|
|
766
|
+
};
|
|
767
|
+
render() {
|
|
768
|
+
const { data, getItem, getItemCount, renderItem, ...props } = this.props;
|
|
769
|
+
const ScrollViewComponent = scrollViewModule.default ?? scrollViewModule;
|
|
770
|
+
const itemCount = getItemCount?.(data) ?? 0;
|
|
771
|
+
return React.createElement(ScrollViewComponent, {
|
|
772
|
+
...props,
|
|
773
|
+
ref: this.setScrollViewRef
|
|
774
|
+
}, Array.from({ length: itemCount }, (_, index) => {
|
|
775
|
+
const item = getItem?.(data, index);
|
|
776
|
+
return React.createElement(React.Fragment, { key: getItemKey(item, index) }, renderItem?.({
|
|
777
|
+
index,
|
|
778
|
+
item,
|
|
779
|
+
separators: createListSeparators()
|
|
780
|
+
}));
|
|
781
|
+
}));
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
Object.defineProperty(VirtualizedList, "displayName", {
|
|
785
|
+
configurable: true,
|
|
786
|
+
enumerable: true,
|
|
787
|
+
value: "VirtualizedList",
|
|
788
|
+
writable: true
|
|
789
|
+
});
|
|
790
|
+
class ImageBackground extends React.Component {
|
|
791
|
+
viewRef = null;
|
|
792
|
+
setNativeProps = vi.fn((props) => {
|
|
793
|
+
this.viewRef?.setNativeProps?.(props);
|
|
794
|
+
});
|
|
795
|
+
captureViewRef = (ref) => {
|
|
796
|
+
this.viewRef = ref;
|
|
797
|
+
};
|
|
798
|
+
render() {
|
|
799
|
+
const { children, imageRef, imageStyle, style, ...props } = this.props;
|
|
800
|
+
const ViewComponent = viewModule.default ?? viewModule;
|
|
801
|
+
const ImageComponent = imageModule.default ?? imageModule;
|
|
802
|
+
return React.createElement(ViewComponent, {
|
|
803
|
+
accessibilityIgnoresInvertColors: true,
|
|
804
|
+
ref: this.captureViewRef,
|
|
805
|
+
style
|
|
806
|
+
}, React.createElement(ImageComponent, {
|
|
807
|
+
...props,
|
|
808
|
+
ref: imageRef,
|
|
809
|
+
style: imageStyle
|
|
810
|
+
}), children);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
Object.defineProperty(ImageBackground, "displayName", {
|
|
814
|
+
configurable: true,
|
|
815
|
+
enumerable: true,
|
|
816
|
+
value: "ImageBackground",
|
|
817
|
+
writable: true
|
|
818
|
+
});
|
|
819
|
+
const InputAccessoryView = ({ children, ...props }) => {
|
|
820
|
+
if (React.Children.count(children) === 0) return null;
|
|
821
|
+
return React.createElement("InputAccessoryView", props, children);
|
|
822
|
+
};
|
|
823
|
+
InputAccessoryView.displayName = "InputAccessoryView";
|
|
824
|
+
const LayoutConformance = createMockHostComponent(React, "LayoutConformance", "LayoutConformance");
|
|
825
|
+
const KeyboardAvoidingView = createMockHostComponent(React, "KeyboardAvoidingView", "KeyboardAvoidingView", createMockNativeMethods());
|
|
826
|
+
const ProgressBarAndroid = createMockHostComponent(React, "ProgressBarAndroid", "ProgressBarAndroid");
|
|
827
|
+
class StatusBar extends React.Component {
|
|
828
|
+
static currentHeight = runtimeGlobals.nativeModuleProxy?.StatusBarManager?.getConstants?.().HEIGHT ?? 0;
|
|
829
|
+
static setBackgroundColor = vi.fn((color, animated) => runtimeGlobals.nativeModuleProxy?.StatusBarManager?.setBackgroundColor?.(color, animated));
|
|
830
|
+
static setBarStyle = vi.fn((style, animated) => runtimeGlobals.nativeModuleProxy?.StatusBarManager?.setStyle?.(style, animated));
|
|
831
|
+
static setHidden = vi.fn((hidden, animation) => runtimeGlobals.nativeModuleProxy?.StatusBarManager?.setHidden?.(hidden, animation));
|
|
832
|
+
static setNetworkActivityIndicatorVisible = vi.fn((visible) => runtimeGlobals.nativeModuleProxy?.StatusBarManager?.setNetworkActivityIndicatorVisible?.(visible));
|
|
833
|
+
static setTranslucent = vi.fn((translucent) => runtimeGlobals.nativeModuleProxy?.StatusBarManager?.setTranslucent?.(translucent));
|
|
834
|
+
render() {
|
|
835
|
+
return null;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
Object.defineProperty(StatusBar, "displayName", {
|
|
839
|
+
configurable: true,
|
|
840
|
+
enumerable: true,
|
|
841
|
+
value: "StatusBar",
|
|
842
|
+
writable: true
|
|
843
|
+
});
|
|
844
|
+
const Switch = createMockHostComponent(React, "Switch", "Switch", createMockNativeMethods());
|
|
845
|
+
const createTouchableComponent = (displayName) => {
|
|
846
|
+
class TouchableComponent extends React.Component {
|
|
847
|
+
render() {
|
|
848
|
+
const props = {
|
|
849
|
+
...this.props,
|
|
850
|
+
accessible: this.props.accessible ?? true
|
|
851
|
+
};
|
|
852
|
+
return React.createElement("View", props, props.children);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
Object.assign(TouchableComponent.prototype, createMockNativeMethods());
|
|
856
|
+
Object.defineProperty(TouchableComponent, "displayName", {
|
|
857
|
+
configurable: true,
|
|
858
|
+
enumerable: true,
|
|
859
|
+
value: displayName,
|
|
860
|
+
writable: true
|
|
861
|
+
});
|
|
862
|
+
return TouchableComponent;
|
|
863
|
+
};
|
|
864
|
+
const Touchable = createTouchableComponent("Touchable");
|
|
865
|
+
const TouchableHighlight = createTouchableComponent("TouchableHighlight");
|
|
866
|
+
const TouchableNativeFeedback = createTouchableComponent("TouchableNativeFeedback");
|
|
867
|
+
const TouchableOpacity = createTouchableComponent("TouchableOpacity");
|
|
868
|
+
const TouchableWithoutFeedback = createTouchableComponent("TouchableWithoutFeedback");
|
|
869
|
+
const appRegistryRunnables = {};
|
|
870
|
+
const appRegistrySections = {};
|
|
871
|
+
const AppRegistry = {
|
|
872
|
+
getAppKeys: vi.fn(() => Object.keys(appRegistryRunnables)),
|
|
873
|
+
getRegistry: vi.fn(() => ({
|
|
874
|
+
runnables: { ...appRegistryRunnables },
|
|
875
|
+
sections: Object.keys(appRegistrySections)
|
|
876
|
+
})),
|
|
877
|
+
getRunnable: vi.fn((appKey) => appRegistryRunnables[appKey]),
|
|
878
|
+
getSectionKeys: vi.fn(() => Object.keys(appRegistrySections)),
|
|
879
|
+
getSections: vi.fn(() => ({ ...appRegistrySections })),
|
|
880
|
+
registerComponent: vi.fn((appKey, componentProvider, section) => {
|
|
881
|
+
const runnable = vi.fn(() => componentProvider());
|
|
882
|
+
appRegistryRunnables[appKey] = runnable;
|
|
883
|
+
if (section) appRegistrySections[appKey] = runnable;
|
|
884
|
+
return appKey;
|
|
885
|
+
}),
|
|
886
|
+
registerConfig: vi.fn((configs) => {
|
|
887
|
+
configs.forEach((config) => {
|
|
888
|
+
if (typeof config.run === "function" && typeof config.appKey === "string") {
|
|
889
|
+
AppRegistry.registerRunnable(config.appKey, config.run);
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
if (typeof config.appKey === "string" && typeof config.component === "function") AppRegistry.registerComponent(config.appKey, config.component, Boolean(config.section));
|
|
893
|
+
});
|
|
894
|
+
}),
|
|
895
|
+
registerRunnable: vi.fn((appKey, run) => {
|
|
896
|
+
appRegistryRunnables[appKey] = run;
|
|
897
|
+
return appKey;
|
|
898
|
+
}),
|
|
899
|
+
registerSection: vi.fn((appKey, componentProvider) => {
|
|
900
|
+
AppRegistry.registerComponent(appKey, componentProvider, true);
|
|
901
|
+
}),
|
|
902
|
+
setRootViewStyleProvider: vi.fn(),
|
|
903
|
+
setWrapperComponentProvider: vi.fn()
|
|
904
|
+
};
|
|
905
|
+
const Easing = {
|
|
906
|
+
back: vi.fn((s = 1.70158) => (t) => t * t * ((s + 1) * t - s)),
|
|
907
|
+
bezier: vi.fn(() => (t) => t),
|
|
908
|
+
bounce: vi.fn((t) => t * t),
|
|
909
|
+
circle: vi.fn((t) => 1 - Math.sqrt(1 - t * t)),
|
|
910
|
+
cubic: vi.fn((t) => t * t * t),
|
|
911
|
+
ease: vi.fn((t) => t * t * (3 - 2 * t)),
|
|
912
|
+
elastic: vi.fn((bounciness = 1) => (t) => 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * bounciness * Math.PI)),
|
|
913
|
+
exp: vi.fn((t) => Math.pow(2, 10 * (t - 1))),
|
|
914
|
+
in: vi.fn((easing) => (t) => easing(t)),
|
|
915
|
+
inOut: vi.fn((easing) => (t) => t < .5 ? easing(t * 2) / 2 : 1 - easing((1 - t) * 2) / 2),
|
|
916
|
+
linear: vi.fn((t) => t),
|
|
917
|
+
out: vi.fn((easing) => (t) => 1 - easing(1 - t)),
|
|
918
|
+
poly: vi.fn((n) => (t) => Math.pow(t, n)),
|
|
919
|
+
quad: vi.fn((t) => t * t),
|
|
920
|
+
sin: vi.fn((t) => 1 - Math.cos(t * Math.PI / 2)),
|
|
921
|
+
step0: vi.fn((n) => n > 0 ? 1 : 0),
|
|
922
|
+
step1: vi.fn((n) => n >= 1 ? 1 : 0)
|
|
923
|
+
};
|
|
924
|
+
const interactionEventEmitter = createEventEmitter();
|
|
925
|
+
let nextInteractionHandle = 1;
|
|
926
|
+
const InteractionManager = {
|
|
927
|
+
Events: {
|
|
928
|
+
interactionComplete: "interactionComplete",
|
|
929
|
+
interactionStart: "interactionStart"
|
|
930
|
+
},
|
|
931
|
+
addListener: interactionEventEmitter.addListener,
|
|
932
|
+
clearInteractionHandle: vi.fn(() => void 0),
|
|
933
|
+
createInteractionHandle: vi.fn(() => nextInteractionHandle++),
|
|
934
|
+
runAfterInteractions: vi.fn((task) => {
|
|
935
|
+
let cancelled = false;
|
|
936
|
+
const promise = Promise.resolve().then(() => {
|
|
937
|
+
if (cancelled) return;
|
|
938
|
+
if (typeof task === "function") {
|
|
939
|
+
task();
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
942
|
+
task?.run?.();
|
|
943
|
+
});
|
|
944
|
+
return {
|
|
945
|
+
cancel: () => {
|
|
946
|
+
cancelled = true;
|
|
947
|
+
},
|
|
948
|
+
then: promise.then.bind(promise)
|
|
949
|
+
};
|
|
950
|
+
}),
|
|
951
|
+
setDeadline: vi.fn()
|
|
952
|
+
};
|
|
953
|
+
let layoutAnimationEnabled = true;
|
|
954
|
+
const layoutAnimationTypes = {
|
|
955
|
+
easeInEaseOut: "easeInEaseOut",
|
|
956
|
+
easeIn: "easeIn",
|
|
957
|
+
easeOut: "easeOut",
|
|
958
|
+
keyboard: "keyboard",
|
|
959
|
+
linear: "linear",
|
|
960
|
+
spring: "spring"
|
|
961
|
+
};
|
|
962
|
+
const layoutAnimationProperties = {
|
|
963
|
+
opacity: "opacity",
|
|
964
|
+
scaleX: "scaleX",
|
|
965
|
+
scaleXY: "scaleXY",
|
|
966
|
+
scaleY: "scaleY"
|
|
967
|
+
};
|
|
968
|
+
const createLayoutAnimationConfig = (duration, type, property) => ({
|
|
969
|
+
create: {
|
|
970
|
+
property,
|
|
971
|
+
type
|
|
972
|
+
},
|
|
973
|
+
delete: {
|
|
974
|
+
property,
|
|
975
|
+
type
|
|
976
|
+
},
|
|
977
|
+
duration,
|
|
978
|
+
update: { type }
|
|
979
|
+
});
|
|
980
|
+
const layoutAnimationPresets = {
|
|
981
|
+
easeInEaseOut: createLayoutAnimationConfig(300, "easeInEaseOut", "opacity"),
|
|
982
|
+
linear: createLayoutAnimationConfig(500, "linear", "opacity"),
|
|
983
|
+
spring: {
|
|
984
|
+
create: {
|
|
985
|
+
property: "opacity",
|
|
986
|
+
type: "linear"
|
|
987
|
+
},
|
|
988
|
+
delete: {
|
|
989
|
+
property: "opacity",
|
|
990
|
+
type: "linear"
|
|
991
|
+
},
|
|
992
|
+
duration: 700,
|
|
993
|
+
update: {
|
|
994
|
+
springDamping: .4,
|
|
995
|
+
type: "spring"
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
const LayoutAnimation = {
|
|
1000
|
+
Properties: layoutAnimationProperties,
|
|
1001
|
+
Presets: layoutAnimationPresets,
|
|
1002
|
+
Types: layoutAnimationTypes,
|
|
1003
|
+
checkConfig: vi.fn(),
|
|
1004
|
+
configureNext: vi.fn((_config, onAnimationDidEnd, _onAnimationDidFail) => {
|
|
1005
|
+
if (layoutAnimationEnabled) onAnimationDidEnd?.();
|
|
1006
|
+
}),
|
|
1007
|
+
create: vi.fn(createLayoutAnimationConfig),
|
|
1008
|
+
easeInEaseOut: vi.fn((onAnimationDidEnd) => LayoutAnimation.configureNext(layoutAnimationPresets.easeInEaseOut, onAnimationDidEnd)),
|
|
1009
|
+
linear: vi.fn((onAnimationDidEnd) => LayoutAnimation.configureNext(layoutAnimationPresets.linear, onAnimationDidEnd)),
|
|
1010
|
+
setEnabled: vi.fn((value) => {
|
|
1011
|
+
layoutAnimationEnabled = value;
|
|
1012
|
+
}),
|
|
1013
|
+
spring: vi.fn((onAnimationDidEnd) => LayoutAnimation.configureNext(layoutAnimationPresets.spring, onAnimationDidEnd))
|
|
1014
|
+
};
|
|
1015
|
+
const NativeDialogManagerAndroid = {
|
|
1016
|
+
getConstants: vi.fn(() => ({
|
|
1017
|
+
buttonClicked: "buttonClicked",
|
|
1018
|
+
buttonNegative: "buttonNegative",
|
|
1019
|
+
buttonNeutral: "buttonNeutral",
|
|
1020
|
+
buttonPositive: "buttonPositive",
|
|
1021
|
+
dismissed: "dismissed"
|
|
1022
|
+
})),
|
|
1023
|
+
showAlert: vi.fn((_config, _onError, onAction) => onAction("buttonClicked", "buttonPositive"))
|
|
1024
|
+
};
|
|
1025
|
+
const networkingEventEmitter = createEventEmitter();
|
|
1026
|
+
const Networking = {
|
|
1027
|
+
abortRequest: vi.fn(),
|
|
1028
|
+
addListener: networkingEventEmitter.addListener,
|
|
1029
|
+
clearCookies: vi.fn((callback) => callback(true)),
|
|
1030
|
+
sendRequest: vi.fn((_method, _trackingName, _url, _headers, _data, _responseType, _incrementalUpdates, _timeout, callback) => callback(1))
|
|
1031
|
+
};
|
|
1032
|
+
const permissionsResults = {
|
|
1033
|
+
DENIED: "denied",
|
|
1034
|
+
GRANTED: "granted",
|
|
1035
|
+
NEVER_ASK_AGAIN: "never_ask_again"
|
|
1036
|
+
};
|
|
1037
|
+
const PermissionsAndroid = {
|
|
1038
|
+
PERMISSIONS: { CAMERA: "android.permission.CAMERA" },
|
|
1039
|
+
RESULTS: permissionsResults,
|
|
1040
|
+
check: vi.fn(async () => true),
|
|
1041
|
+
request: vi.fn(async () => permissionsResults.GRANTED),
|
|
1042
|
+
requestMultiple: vi.fn(async (requestedPermissions) => Object.fromEntries(requestedPermissions.map((permission) => [permission, permissionsResults.GRANTED]))),
|
|
1043
|
+
shouldShowRequestPermissionRationale: vi.fn(async () => false)
|
|
1044
|
+
};
|
|
1045
|
+
const ToastAndroid = {
|
|
1046
|
+
BOTTOM: 80,
|
|
1047
|
+
CENTER: 17,
|
|
1048
|
+
LONG: 1,
|
|
1049
|
+
SHORT: 0,
|
|
1050
|
+
TOP: 49,
|
|
1051
|
+
show: vi.fn(),
|
|
1052
|
+
showWithGravity: vi.fn(),
|
|
1053
|
+
showWithGravityAndOffset: vi.fn()
|
|
1054
|
+
};
|
|
1055
|
+
const DevMenu = { show: vi.fn() };
|
|
1056
|
+
const LogBox = {
|
|
1057
|
+
ignoreAllLogs: vi.fn(),
|
|
1058
|
+
ignoreLogs: vi.fn(),
|
|
1059
|
+
install: vi.fn(),
|
|
1060
|
+
uninstall: vi.fn()
|
|
1061
|
+
};
|
|
1062
|
+
class NativeEventEmitter {
|
|
1063
|
+
nativeModule;
|
|
1064
|
+
constructor(nativeModule) {
|
|
1065
|
+
if (platformModule.default?.OS === "ios" && nativeModule == null) throw new Error("NativeEventEmitter requires a non-null argument.");
|
|
1066
|
+
if (nativeModule && typeof nativeModule.addListener === "function" && typeof nativeModule.removeListeners === "function") this.nativeModule = nativeModule;
|
|
1067
|
+
}
|
|
1068
|
+
addListener(eventType, listener) {
|
|
1069
|
+
this.nativeModule?.addListener?.(eventType);
|
|
1070
|
+
let subscription = DeviceEventEmitter.addListener(eventType, listener);
|
|
1071
|
+
return { remove: () => {
|
|
1072
|
+
if (subscription != null) {
|
|
1073
|
+
this.nativeModule?.removeListeners?.(1);
|
|
1074
|
+
subscription.remove();
|
|
1075
|
+
subscription = null;
|
|
1076
|
+
}
|
|
1077
|
+
} };
|
|
1078
|
+
}
|
|
1079
|
+
emit(eventType, ...args) {
|
|
1080
|
+
DeviceEventEmitter.emit(eventType, ...args);
|
|
1081
|
+
}
|
|
1082
|
+
removeAllListeners(eventType) {
|
|
1083
|
+
if (eventType == null) throw new Error("NativeEventEmitter.removeAllListeners requires a non-null argument.");
|
|
1084
|
+
this.nativeModule?.removeListeners?.(DeviceEventEmitter.listenerCount(eventType));
|
|
1085
|
+
DeviceEventEmitter.removeAllListeners(eventType);
|
|
1086
|
+
}
|
|
1087
|
+
listenerCount(eventType) {
|
|
1088
|
+
return DeviceEventEmitter.listenerCount(eventType);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
const PanResponder = { create: vi.fn((callbacks = {}) => {
|
|
1092
|
+
const gestureState = {
|
|
1093
|
+
_accountsForMovesUpTo: 0,
|
|
1094
|
+
dx: 0,
|
|
1095
|
+
dy: 0,
|
|
1096
|
+
moveX: 0,
|
|
1097
|
+
moveY: 0,
|
|
1098
|
+
numberActiveTouches: 0,
|
|
1099
|
+
stateID: 0,
|
|
1100
|
+
vx: 0,
|
|
1101
|
+
vy: 0,
|
|
1102
|
+
x0: 0,
|
|
1103
|
+
y0: 0
|
|
1104
|
+
};
|
|
1105
|
+
return {
|
|
1106
|
+
getInteractionHandle: vi.fn(() => null),
|
|
1107
|
+
panHandlers: {
|
|
1108
|
+
onMoveShouldSetResponder: (...args) => callbacks.onMoveShouldSetPanResponder?.(...args, gestureState) ?? false,
|
|
1109
|
+
onMoveShouldSetResponderCapture: (...args) => callbacks.onMoveShouldSetPanResponderCapture?.(...args, gestureState) ?? false,
|
|
1110
|
+
onResponderEnd: (...args) => callbacks.onPanResponderEnd?.(...args, gestureState),
|
|
1111
|
+
onResponderGrant: (...args) => callbacks.onPanResponderGrant?.(...args, gestureState) ?? false,
|
|
1112
|
+
onResponderMove: (...args) => callbacks.onPanResponderMove?.(...args, gestureState),
|
|
1113
|
+
onResponderReject: (...args) => callbacks.onPanResponderReject?.(...args, gestureState),
|
|
1114
|
+
onResponderRelease: (...args) => callbacks.onPanResponderRelease?.(...args, gestureState),
|
|
1115
|
+
onResponderStart: (...args) => callbacks.onPanResponderStart?.(...args, gestureState),
|
|
1116
|
+
onResponderTerminate: (...args) => callbacks.onPanResponderTerminate?.(...args, gestureState),
|
|
1117
|
+
onResponderTerminationRequest: (...args) => callbacks.onPanResponderTerminationRequest?.(...args, gestureState) ?? true,
|
|
1118
|
+
onStartShouldSetResponder: (...args) => callbacks.onStartShouldSetPanResponder?.(...args, gestureState) ?? false,
|
|
1119
|
+
onStartShouldSetResponderCapture: (...args) => callbacks.onStartShouldSetPanResponderCapture?.(...args, gestureState) ?? false
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
}) };
|
|
1123
|
+
const pushNotificationManager = runtimeGlobals.nativeModuleProxy?.PushNotificationManager;
|
|
1124
|
+
const PushNotificationIOS = {
|
|
1125
|
+
abandonPermissions: vi.fn(() => pushNotificationManager?.abandonPermissions?.()),
|
|
1126
|
+
addEventListener: vi.fn(),
|
|
1127
|
+
getApplicationIconBadgeNumber: vi.fn((callback) => pushNotificationManager?.getApplicationIconBadgeNumber?.(callback)),
|
|
1128
|
+
presentLocalNotification: vi.fn((notification) => pushNotificationManager?.presentLocalNotification?.(notification)),
|
|
1129
|
+
removeAllDeliveredNotifications: vi.fn(() => pushNotificationManager?.removeAllDeliveredNotifications?.()),
|
|
1130
|
+
removeEventListener: vi.fn(),
|
|
1131
|
+
requestPermissions: vi.fn(() => pushNotificationManager?.requestPermissions?.())
|
|
1132
|
+
};
|
|
1133
|
+
let systraceEnabled = false;
|
|
1134
|
+
let systraceCookie = 0;
|
|
1135
|
+
const Systrace = {
|
|
1136
|
+
beginAsyncEvent: vi.fn(() => systraceCookie++),
|
|
1137
|
+
beginEvent: vi.fn(),
|
|
1138
|
+
counterEvent: vi.fn(),
|
|
1139
|
+
endAsyncEvent: vi.fn(),
|
|
1140
|
+
endEvent: vi.fn(),
|
|
1141
|
+
isEnabled: vi.fn(() => systraceEnabled),
|
|
1142
|
+
setEnabled: vi.fn((enabled) => {
|
|
1143
|
+
systraceEnabled = enabled;
|
|
1144
|
+
})
|
|
1145
|
+
};
|
|
1146
|
+
const UTFSequence = Object.freeze({
|
|
1147
|
+
BOM: "",
|
|
1148
|
+
BULLET: "•",
|
|
1149
|
+
BULLET_SP: "\xA0•\xA0",
|
|
1150
|
+
MDASH: "—",
|
|
1151
|
+
MDASH_SP: "\xA0—\xA0",
|
|
1152
|
+
MIDDOT: "·",
|
|
1153
|
+
MIDDOT_KATAKANA: "・",
|
|
1154
|
+
MIDDOT_SP: "\xA0·\xA0",
|
|
1155
|
+
NBSP: "\xA0",
|
|
1156
|
+
NDASH: "–",
|
|
1157
|
+
NDASH_SP: "\xA0–\xA0",
|
|
1158
|
+
NEWLINE: "\n",
|
|
1159
|
+
PIZZA: "🍕",
|
|
1160
|
+
TRIANGLE_LEFT: "◀",
|
|
1161
|
+
TRIANGLE_RIGHT: "▶"
|
|
1162
|
+
});
|
|
1163
|
+
const DynamicColorIOS = vi.fn(() => {
|
|
1164
|
+
throw new Error("DynamicColorIOS is not available on this platform.");
|
|
1165
|
+
});
|
|
1166
|
+
class SectionList extends React.PureComponent {
|
|
1167
|
+
flashScrollIndicators = vi.fn();
|
|
1168
|
+
getScrollResponder = vi.fn(() => this.scrollViewRef);
|
|
1169
|
+
getScrollableNode = vi.fn(() => this.scrollViewRef);
|
|
1170
|
+
recordInteraction = vi.fn();
|
|
1171
|
+
scrollToLocation = vi.fn();
|
|
1172
|
+
setNativeProps = vi.fn();
|
|
1173
|
+
scrollViewRef = null;
|
|
1174
|
+
setScrollViewRef = (ref) => {
|
|
1175
|
+
this.scrollViewRef = ref;
|
|
1176
|
+
};
|
|
1177
|
+
render() {
|
|
1178
|
+
const { renderItem, renderSectionHeader, sections, ...props } = this.props;
|
|
1179
|
+
const ScrollViewComponent = scrollViewModule.default ?? scrollViewModule;
|
|
1180
|
+
return React.createElement(ScrollViewComponent, {
|
|
1181
|
+
...props,
|
|
1182
|
+
ref: this.setScrollViewRef
|
|
1183
|
+
}, (sections ?? []).map((section, sectionIndex) => React.createElement(React.Fragment, { key: String(section.key ?? section.title ?? sectionIndex) }, renderSectionHeader?.({ section }), (section.data ?? []).map((item, itemIndex) => React.createElement(React.Fragment, { key: getItemKey(item, itemIndex, section.keyExtractor) }, renderItem?.({
|
|
1184
|
+
index: itemIndex,
|
|
1185
|
+
item,
|
|
1186
|
+
section,
|
|
1187
|
+
separators: createListSeparators()
|
|
1188
|
+
}))))));
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
Object.defineProperty(SectionList, "displayName", {
|
|
1192
|
+
configurable: true,
|
|
1193
|
+
enumerable: true,
|
|
1194
|
+
value: "SectionList",
|
|
1195
|
+
writable: true
|
|
1196
|
+
});
|
|
1197
|
+
class VirtualizedSectionList extends SectionList {}
|
|
1198
|
+
Object.defineProperty(VirtualizedSectionList, "displayName", {
|
|
1199
|
+
configurable: true,
|
|
1200
|
+
enumerable: true,
|
|
1201
|
+
value: "VirtualizedSectionList",
|
|
1202
|
+
writable: true
|
|
1203
|
+
});
|
|
1204
|
+
const RootTagContext = React.createContext(0);
|
|
1205
|
+
RootTagContext.displayName = "RootTagContext";
|
|
1206
|
+
const TextAncestorContext = React.createContext(false);
|
|
1207
|
+
TextAncestorContext.displayName = "TextAncestorContext";
|
|
1208
|
+
const sharedNativeMethods = createMockNativeMethods();
|
|
1209
|
+
const NativeText = createMockNativeComponent(React, "RCTText");
|
|
1210
|
+
const SafeAreaView = createMockHostComponent(React, "SafeAreaView", "View", sharedNativeMethods);
|
|
1211
|
+
const VirtualView = createMockHostComponent(React, "VirtualView", "VirtualView", sharedNativeMethods);
|
|
1212
|
+
const VirtualViewMode = Object.freeze({
|
|
1213
|
+
Hidden: 2,
|
|
1214
|
+
Prerender: 1,
|
|
1215
|
+
Visible: 0
|
|
1216
|
+
});
|
|
1217
|
+
class Pressable extends React.Component {
|
|
1218
|
+
render() {
|
|
1219
|
+
const props = {
|
|
1220
|
+
...this.props,
|
|
1221
|
+
accessible: this.props.accessible ?? true
|
|
1222
|
+
};
|
|
1223
|
+
return React.createElement("View", props, props.children);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
Object.assign(Pressable.prototype, sharedNativeMethods);
|
|
1227
|
+
Object.defineProperty(Pressable, "displayName", {
|
|
1228
|
+
configurable: true,
|
|
1229
|
+
enumerable: true,
|
|
1230
|
+
value: "Pressable",
|
|
1231
|
+
writable: true
|
|
1232
|
+
});
|
|
1233
|
+
class AnimatedNode {
|
|
1234
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1235
|
+
value;
|
|
1236
|
+
constructor(initialValue) {
|
|
1237
|
+
this.value = initialValue;
|
|
1238
|
+
}
|
|
1239
|
+
__getValue() {
|
|
1240
|
+
return this.value;
|
|
1241
|
+
}
|
|
1242
|
+
addListener(listener) {
|
|
1243
|
+
const wrapped = (value) => listener({ value });
|
|
1244
|
+
this.listeners.add(wrapped);
|
|
1245
|
+
return { remove: () => this.listeners.delete(wrapped) };
|
|
1246
|
+
}
|
|
1247
|
+
removeAllListeners() {
|
|
1248
|
+
this.listeners.clear();
|
|
1249
|
+
}
|
|
1250
|
+
emitValue(nextValue) {
|
|
1251
|
+
this.value = nextValue;
|
|
1252
|
+
this.listeners.forEach((listener) => listener(nextValue));
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
class AnimatedValue extends AnimatedNode {
|
|
1256
|
+
setValue(nextValue) {
|
|
1257
|
+
this.emitValue(nextValue);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
class AnimatedValueXY extends AnimatedNode {
|
|
1261
|
+
x;
|
|
1262
|
+
y;
|
|
1263
|
+
constructor(initialValue) {
|
|
1264
|
+
super(initialValue);
|
|
1265
|
+
this.x = new AnimatedValue(initialValue.x);
|
|
1266
|
+
this.y = new AnimatedValue(initialValue.y);
|
|
1267
|
+
}
|
|
1268
|
+
setValue(nextValue) {
|
|
1269
|
+
this.x.setValue(nextValue.x);
|
|
1270
|
+
this.y.setValue(nextValue.y);
|
|
1271
|
+
this.emitValue({
|
|
1272
|
+
x: nextValue.x,
|
|
1273
|
+
y: nextValue.y
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
class AnimatedInterpolation extends AnimatedNode {}
|
|
1278
|
+
class AnimatedColor extends AnimatedNode {}
|
|
1279
|
+
const createAnimatedNode = (initialValue) => new AnimatedNode(initialValue);
|
|
1280
|
+
const toAnimatedValue = (value) => value instanceof AnimatedNode ? value.__getValue() : value;
|
|
1281
|
+
const createAnimation = (startImpl) => ({
|
|
1282
|
+
reset: vi.fn(),
|
|
1283
|
+
start: (callback) => {
|
|
1284
|
+
startImpl(callback);
|
|
1285
|
+
},
|
|
1286
|
+
stop: vi.fn()
|
|
1287
|
+
});
|
|
1288
|
+
const runValueAnimation = (value, nextValue, duration, callback) => {
|
|
1289
|
+
setTimeout(() => {
|
|
1290
|
+
value.setValue(nextValue);
|
|
1291
|
+
callback?.({ finished: true });
|
|
1292
|
+
}, duration ?? 0);
|
|
1293
|
+
};
|
|
1294
|
+
function resolveAnimatedStyle(style) {
|
|
1295
|
+
if (style instanceof AnimatedNode) return style.__getValue();
|
|
1296
|
+
if (Array.isArray(style)) return style.map((value) => resolveAnimatedStyle(value));
|
|
1297
|
+
if (style && typeof style === "object") return Object.fromEntries(Object.entries(style).map(([key, value]) => [key, resolveAnimatedStyle(value)]));
|
|
1298
|
+
return style;
|
|
1299
|
+
}
|
|
1300
|
+
class AnimatedView extends React.Component {
|
|
1301
|
+
subscriptions = [];
|
|
1302
|
+
componentDidMount() {
|
|
1303
|
+
this.subscribe(this.props.style);
|
|
1304
|
+
}
|
|
1305
|
+
componentDidUpdate(previousProps) {
|
|
1306
|
+
if (previousProps.style !== this.props.style) {
|
|
1307
|
+
this.unsubscribe();
|
|
1308
|
+
this.subscribe(this.props.style);
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
componentWillUnmount() {
|
|
1312
|
+
this.unsubscribe();
|
|
1313
|
+
}
|
|
1314
|
+
forceAnimatedUpdate = () => {
|
|
1315
|
+
this.setState((state) => ({
|
|
1316
|
+
...state ?? {},
|
|
1317
|
+
animatedTick: Date.now()
|
|
1318
|
+
}));
|
|
1319
|
+
};
|
|
1320
|
+
subscribe(style) {
|
|
1321
|
+
const queue = [style];
|
|
1322
|
+
while (queue.length > 0) {
|
|
1323
|
+
const current = queue.shift();
|
|
1324
|
+
if (current instanceof AnimatedNode) {
|
|
1325
|
+
this.subscriptions.push(current.addListener(this.forceAnimatedUpdate));
|
|
1326
|
+
continue;
|
|
1327
|
+
}
|
|
1328
|
+
if (Array.isArray(current)) {
|
|
1329
|
+
queue.push(...current);
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (current && typeof current === "object") queue.push(...Object.values(current));
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
unsubscribe() {
|
|
1336
|
+
this.subscriptions.forEach((subscription) => subscription.remove());
|
|
1337
|
+
this.subscriptions = [];
|
|
1338
|
+
}
|
|
1339
|
+
render() {
|
|
1340
|
+
const resolvedStyle = resolveAnimatedStyle(this.props.style);
|
|
1341
|
+
return React.createElement("View", {
|
|
1342
|
+
...this.props,
|
|
1343
|
+
style: resolvedStyle
|
|
1344
|
+
}, this.props.children);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
class AnimatedEvent {
|
|
1348
|
+
__isNative;
|
|
1349
|
+
handler;
|
|
1350
|
+
constructor(_argMapping, config) {
|
|
1351
|
+
this.__isNative = Boolean(config?.useNativeDriver);
|
|
1352
|
+
this.handler = (...args) => {
|
|
1353
|
+
config?.listener?.(...args);
|
|
1354
|
+
};
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
const createAnimatedComputation = (value) => createAnimatedNode(value);
|
|
1358
|
+
const createCombinedHandler = (baseHandler, nextHandler) => Object.assign((...args) => {
|
|
1359
|
+
baseHandler?.(...args);
|
|
1360
|
+
nextHandler?.(...args);
|
|
1361
|
+
}, {
|
|
1362
|
+
__rntlBaseHandler: baseHandler,
|
|
1363
|
+
__rntlExtraHandler: nextHandler
|
|
1364
|
+
});
|
|
1365
|
+
const Animated = {
|
|
1366
|
+
Color: AnimatedColor,
|
|
1367
|
+
Event: AnimatedEvent,
|
|
1368
|
+
Interpolation: AnimatedInterpolation,
|
|
1369
|
+
Node: AnimatedNode,
|
|
1370
|
+
Value: AnimatedValue,
|
|
1371
|
+
ValueXY: AnimatedValueXY,
|
|
1372
|
+
add: (left, right) => createAnimatedComputation(Number(toAnimatedValue(left)) + Number(toAnimatedValue(right))),
|
|
1373
|
+
attachNativeEvent: vi.fn(() => ({ detach: vi.fn() })),
|
|
1374
|
+
View: AnimatedView,
|
|
1375
|
+
createAnimatedComponent: (component) => component,
|
|
1376
|
+
decay: (value, config) => createAnimation((callback) => runValueAnimation(value, value.__getValue() + Number(config.velocity ?? 0), 0, callback)),
|
|
1377
|
+
delay: (duration) => createAnimation((callback) => {
|
|
1378
|
+
setTimeout(() => callback?.({ finished: true }), duration);
|
|
1379
|
+
}),
|
|
1380
|
+
diffClamp: (value, min, max) => createAnimatedComputation(Math.max(min, Math.min(max, Number(toAnimatedValue(value))))),
|
|
1381
|
+
divide: (left, right) => createAnimatedComputation(Number(toAnimatedValue(left)) / Number(toAnimatedValue(right))),
|
|
1382
|
+
event: (argMapping, config) => new AnimatedEvent(argMapping, config).handler,
|
|
1383
|
+
forkEvent: (event, listener) => createCombinedHandler(event, listener),
|
|
1384
|
+
loop: (animation, config) => createAnimation((callback) => {
|
|
1385
|
+
const iterations = config?.iterations ?? -1;
|
|
1386
|
+
let runCount = 0;
|
|
1387
|
+
const run = () => {
|
|
1388
|
+
animation.start(() => {
|
|
1389
|
+
runCount += 1;
|
|
1390
|
+
if (iterations > 0 && runCount >= iterations) {
|
|
1391
|
+
callback?.({ finished: true });
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
run();
|
|
1395
|
+
});
|
|
1396
|
+
};
|
|
1397
|
+
run();
|
|
1398
|
+
}),
|
|
1399
|
+
modulo: (left, right) => createAnimatedComputation(Number(toAnimatedValue(left)) % Number(toAnimatedValue(right))),
|
|
1400
|
+
multiply: (left, right) => createAnimatedComputation(Number(toAnimatedValue(left)) * Number(toAnimatedValue(right))),
|
|
1401
|
+
parallel: (animations) => createAnimation((callback) => {
|
|
1402
|
+
if (animations.length === 0) {
|
|
1403
|
+
callback?.({ finished: true });
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
let completed = 0;
|
|
1407
|
+
animations.forEach((animation) => {
|
|
1408
|
+
animation.start(() => {
|
|
1409
|
+
completed += 1;
|
|
1410
|
+
if (completed === animations.length) callback?.({ finished: true });
|
|
1411
|
+
});
|
|
1412
|
+
});
|
|
1413
|
+
}),
|
|
1414
|
+
sequence: (animations) => createAnimation((callback) => {
|
|
1415
|
+
let index = 0;
|
|
1416
|
+
const run = () => {
|
|
1417
|
+
if (index >= animations.length) {
|
|
1418
|
+
callback?.({ finished: true });
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
animations[index].start(() => {
|
|
1422
|
+
index += 1;
|
|
1423
|
+
run();
|
|
1424
|
+
});
|
|
1425
|
+
};
|
|
1426
|
+
run();
|
|
1427
|
+
}),
|
|
1428
|
+
spring: (value, config) => createAnimation((callback) => runValueAnimation(value, config.toValue, 0, callback)),
|
|
1429
|
+
stagger: (time, animations) => createAnimation((callback) => {
|
|
1430
|
+
if (animations.length === 0) {
|
|
1431
|
+
callback?.({ finished: true });
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
let completed = 0;
|
|
1435
|
+
animations.forEach((animation, index) => {
|
|
1436
|
+
setTimeout(() => {
|
|
1437
|
+
animation.start(() => {
|
|
1438
|
+
completed += 1;
|
|
1439
|
+
if (completed === animations.length) callback?.({ finished: true });
|
|
1440
|
+
});
|
|
1441
|
+
}, index * time);
|
|
1442
|
+
});
|
|
1443
|
+
}),
|
|
1444
|
+
subtract: (left, right) => createAnimatedComputation(Number(toAnimatedValue(left)) - Number(toAnimatedValue(right))),
|
|
1445
|
+
timing: (value, config) => createAnimation((callback) => runValueAnimation(value, config.toValue, config.duration, callback)),
|
|
1446
|
+
unforkEvent: (event, _listener) => event.__rntlBaseHandler ?? event
|
|
1447
|
+
};
|
|
1448
|
+
const useAnimatedValue = (initialValue) => {
|
|
1449
|
+
const ref = React.useRef(null);
|
|
1450
|
+
if (ref.current == null) ref.current = new Animated.Value(initialValue);
|
|
1451
|
+
return ref.current;
|
|
1452
|
+
};
|
|
1453
|
+
const reactNativeVersion = platformModule.default?.constants?.reactNativeVersion ?? {
|
|
1454
|
+
major: 0,
|
|
1455
|
+
minor: 0,
|
|
1456
|
+
patch: 0,
|
|
1457
|
+
prerelease: null
|
|
1458
|
+
};
|
|
1459
|
+
class ReactNativeVersion {
|
|
1460
|
+
static major = reactNativeVersion.major ?? 0;
|
|
1461
|
+
static minor = reactNativeVersion.minor ?? 0;
|
|
1462
|
+
static patch = reactNativeVersion.patch ?? 0;
|
|
1463
|
+
static prerelease = reactNativeVersion.prerelease ?? null;
|
|
1464
|
+
static getVersionString() {
|
|
1465
|
+
const prereleaseSuffix = ReactNativeVersion.prerelease != null ? `-${ReactNativeVersion.prerelease}` : "";
|
|
1466
|
+
return `${ReactNativeVersion.major}.${ReactNativeVersion.minor}.${ReactNativeVersion.patch}${prereleaseSuffix}`;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
const usePressability = vi.fn((config) => {
|
|
1470
|
+
if (config == null) return null;
|
|
1471
|
+
return Object.fromEntries(Object.entries(config).filter(([key, value]) => key.startsWith("on") && typeof value === "function"));
|
|
1472
|
+
});
|
|
1473
|
+
const reactNativeExports = {
|
|
1474
|
+
__esModule: true,
|
|
1475
|
+
AccessibilityInfo: accessibilityInfoModule.default ?? accessibilityInfoModule,
|
|
1476
|
+
ActivityIndicator: activityIndicatorModule.default ?? activityIndicatorModule,
|
|
1477
|
+
ActionSheetIOS,
|
|
1478
|
+
Alert,
|
|
1479
|
+
Animated,
|
|
1480
|
+
Appearance,
|
|
1481
|
+
AppRegistry,
|
|
1482
|
+
AppState: appStateModule.default ?? appStateModule,
|
|
1483
|
+
BackHandler,
|
|
1484
|
+
Button,
|
|
1485
|
+
Clipboard: clipboardModule.default ?? clipboardModule,
|
|
1486
|
+
codegenNativeCommands: codegenNativeCommandsModule.default ?? codegenNativeCommandsModule,
|
|
1487
|
+
codegenNativeComponent: codegenNativeComponentModule.default ?? codegenNativeComponentModule,
|
|
1488
|
+
DevMenu,
|
|
1489
|
+
DevSettings,
|
|
1490
|
+
DeviceEventEmitter,
|
|
1491
|
+
DeviceInfo,
|
|
1492
|
+
DynamicColorIOS,
|
|
1493
|
+
Dimensions,
|
|
1494
|
+
DrawerLayoutAndroid,
|
|
1495
|
+
findNodeHandle: rendererProxyModule.findNodeHandle,
|
|
1496
|
+
FlatList,
|
|
1497
|
+
I18nManager,
|
|
1498
|
+
Image: imageModule.default ?? imageModule,
|
|
1499
|
+
ImageBackground,
|
|
1500
|
+
InputAccessoryView,
|
|
1501
|
+
InteractionManager,
|
|
1502
|
+
Keyboard,
|
|
1503
|
+
KeyboardAvoidingView,
|
|
1504
|
+
LayoutAnimation,
|
|
1505
|
+
Linking: linkingModule.default ?? linkingModule,
|
|
1506
|
+
LogBox,
|
|
1507
|
+
Modal: modalModule.default ?? modalModule,
|
|
1508
|
+
NativeComponentRegistry: nativeComponentRegistryModule.default ?? nativeComponentRegistryModule,
|
|
1509
|
+
NativeDialogManagerAndroid,
|
|
1510
|
+
NativeEventEmitter,
|
|
1511
|
+
NativeModules: nativeModulesModule.default ?? nativeModulesModule,
|
|
1512
|
+
NativeAppEventEmitter,
|
|
1513
|
+
Networking,
|
|
1514
|
+
PanResponder,
|
|
1515
|
+
Platform: platformModule.default ?? platformModule,
|
|
1516
|
+
PlatformColor,
|
|
1517
|
+
PixelRatio,
|
|
1518
|
+
PermissionsAndroid,
|
|
1519
|
+
Pressable,
|
|
1520
|
+
processColor,
|
|
1521
|
+
ProgressBarAndroid,
|
|
1522
|
+
PushNotificationIOS,
|
|
1523
|
+
RefreshControl: refreshControlModule.default ?? refreshControlModule,
|
|
1524
|
+
ReactNativeVersion,
|
|
1525
|
+
registerCallableModule,
|
|
1526
|
+
requireNativeComponent: requireNativeComponentModule.default ?? requireNativeComponentModule,
|
|
1527
|
+
RootTagContext,
|
|
1528
|
+
SafeAreaView,
|
|
1529
|
+
ScrollView: scrollViewModule.default ?? scrollViewModule,
|
|
1530
|
+
SectionList,
|
|
1531
|
+
Settings,
|
|
1532
|
+
Share,
|
|
1533
|
+
StatusBar,
|
|
1534
|
+
StyleSheet: styleSheetModule.default ?? styleSheetModule,
|
|
1535
|
+
Switch,
|
|
1536
|
+
Systrace,
|
|
1537
|
+
Text: textModule.default ?? textModule,
|
|
1538
|
+
TextInput: textInputModule.default ?? textInputModule,
|
|
1539
|
+
Touchable,
|
|
1540
|
+
TouchableHighlight,
|
|
1541
|
+
TouchableNativeFeedback,
|
|
1542
|
+
TouchableOpacity,
|
|
1543
|
+
TouchableWithoutFeedback,
|
|
1544
|
+
TurboModuleRegistry,
|
|
1545
|
+
UIManager: uiManagerModule.default ?? uiManagerModule,
|
|
1546
|
+
UTFSequence,
|
|
1547
|
+
unstable_batchedUpdates: rendererProxyModule.unstable_batchedUpdates,
|
|
1548
|
+
unstable_NativeText: NativeText,
|
|
1549
|
+
unstable_NativeView: viewNativeComponentModule.default ?? viewNativeComponentModule,
|
|
1550
|
+
unstable_TextAncestorContext: TextAncestorContext,
|
|
1551
|
+
unstable_VirtualView: VirtualView,
|
|
1552
|
+
useAnimatedValue,
|
|
1553
|
+
useColorScheme: useColorSchemeModule.default ?? useColorSchemeModule,
|
|
1554
|
+
usePressability,
|
|
1555
|
+
useWindowDimensions,
|
|
1556
|
+
Vibration: vibrationModule.default ?? vibrationModule,
|
|
1557
|
+
View: viewModule.default ?? viewModule,
|
|
1558
|
+
VirtualViewMode,
|
|
1559
|
+
VirtualizedList,
|
|
1560
|
+
VirtualizedSectionList,
|
|
1561
|
+
ToastAndroid,
|
|
1562
|
+
Easing,
|
|
1563
|
+
experimental_LayoutConformance: LayoutConformance
|
|
1564
|
+
};
|
|
1565
|
+
for (const exportedName of [
|
|
1566
|
+
"ART",
|
|
1567
|
+
"ListView",
|
|
1568
|
+
"SwipeableListView",
|
|
1569
|
+
"WebView",
|
|
1570
|
+
"NetInfo",
|
|
1571
|
+
"CameraRoll",
|
|
1572
|
+
"ImageStore",
|
|
1573
|
+
"ImageEditor",
|
|
1574
|
+
"TimePickerAndroid",
|
|
1575
|
+
"ToolbarAndroid",
|
|
1576
|
+
"ViewPagerAndroid",
|
|
1577
|
+
"CheckBox",
|
|
1578
|
+
"SegmentedControlIOS",
|
|
1579
|
+
"StatusBarIOS",
|
|
1580
|
+
"PickerIOS",
|
|
1581
|
+
"Picker",
|
|
1582
|
+
"DatePickerAndroid",
|
|
1583
|
+
"MaskedViewIOS",
|
|
1584
|
+
"AsyncStorage",
|
|
1585
|
+
"ImagePickerIOS",
|
|
1586
|
+
"ProgressViewIOS",
|
|
1587
|
+
"DatePickerIOS",
|
|
1588
|
+
"Slider"
|
|
1589
|
+
]) Object.defineProperty(reactNativeExports, exportedName, {
|
|
1590
|
+
configurable: true,
|
|
1591
|
+
get() {
|
|
1592
|
+
throw new Error(`${exportedName} has been removed from React Native.`);
|
|
1593
|
+
}
|
|
1594
|
+
});
|
|
1595
|
+
sharedReactNativeExports = reactNativeExports;
|
|
1596
|
+
return sharedReactNativeExports;
|
|
1597
|
+
}
|
|
1598
|
+
vi.mock("react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo", () => getSharedReactNativeMockModules().accessibilityInfoModule);
|
|
1599
|
+
vi.mock("react-native/Libraries/Core/InitializeCore", () => getSharedReactNativeMockModules().initializeCoreModule);
|
|
1600
|
+
vi.mock("react-native/Libraries/Core/NativeExceptionsManager", () => getSharedReactNativeMockModules().nativeExceptionsManagerModule);
|
|
1601
|
+
vi.mock("react-native/Libraries/Components/Clipboard/Clipboard", () => getSharedReactNativeMockModules().clipboardModule);
|
|
1602
|
+
vi.mock("react-native/Libraries/Utilities/codegenNativeCommands", () => getSharedReactNativeMockModules().codegenNativeCommandsModule);
|
|
1603
|
+
vi.mock("react-native/Libraries/Utilities/codegenNativeComponent", () => getSharedReactNativeMockModules().codegenNativeComponentModule);
|
|
1604
|
+
vi.mock("react-native/Libraries/Components/RefreshControl/RefreshControl", () => getSharedReactNativeMockModules().refreshControlModule);
|
|
1605
|
+
vi.mock("react-native/Libraries/Components/ActivityIndicator/ActivityIndicator", () => getSharedReactNativeMockModules().activityIndicatorModule);
|
|
1606
|
+
vi.mock("react-native/Libraries/Image/Image", () => getSharedReactNativeMockModules().imageModule);
|
|
1607
|
+
vi.mock("react-native/Libraries/Text/Text", () => getSharedReactNativeMockModules().textModule);
|
|
1608
|
+
vi.mock("react-native/Libraries/Components/TextInput/TextInput", () => getSharedReactNativeMockModules().textInputModule);
|
|
1609
|
+
vi.mock("react-native/Libraries/Modal/Modal", () => getSharedReactNativeMockModules().modalModule);
|
|
1610
|
+
vi.mock("react-native/Libraries/Components/View/View", () => getSharedReactNativeMockModules().viewModule);
|
|
1611
|
+
vi.mock("react-native/Libraries/Components/ScrollView/ScrollView", () => getSharedReactNativeMockModules().scrollViewModule);
|
|
1612
|
+
vi.mock("react-native/Libraries/BatchedBridge/NativeModules", () => getSharedReactNativeMockModules().nativeModulesModule);
|
|
1613
|
+
vi.mock("react-native/Libraries/ReactNative/UIManager", () => getSharedReactNativeMockModules().uiManagerModule);
|
|
1614
|
+
vi.mock("react-native/Libraries/AppState/AppState", () => getSharedReactNativeMockModules().appStateModule);
|
|
1615
|
+
vi.mock("react-native/Libraries/Linking/Linking", () => getSharedReactNativeMockModules().linkingModule);
|
|
1616
|
+
vi.mock("react-native/Libraries/Vibration/Vibration", () => getSharedReactNativeMockModules().vibrationModule);
|
|
1617
|
+
vi.mock("react-native/Libraries/NativeComponent/NativeComponentRegistry", () => getSharedReactNativeMockModules().nativeComponentRegistryModule);
|
|
1618
|
+
vi.mock("react-native/Libraries/ReactNative/requireNativeComponent", () => getSharedReactNativeMockModules().requireNativeComponentModule);
|
|
1619
|
+
vi.mock("react-native/Libraries/Components/View/ViewNativeComponent", () => getSharedReactNativeMockModules().viewNativeComponentModule);
|
|
1620
|
+
vi.mock("react-native/Libraries/StyleSheet/StyleSheet", () => getSharedReactNativeMockModules().styleSheetModule);
|
|
1621
|
+
vi.mock("react-native/Libraries/Utilities/useColorScheme", () => getSharedReactNativeMockModules().useColorSchemeModule);
|
|
1622
|
+
vi.mock("react-native/Libraries/Utilities/Platform", () => getSharedReactNativeMockModules().platformModule);
|
|
1623
|
+
vi.mock("react-native/Libraries/ReactNative/RendererProxy", () => getSharedReactNativeMockModules().rendererProxyModule);
|
|
1624
|
+
function patchReactNativeResolution() {
|
|
1625
|
+
if (runtimeGlobals.__rntlVitestRnResolverPatched__ === true) return;
|
|
1626
|
+
const moduleWithPrivateResolver = Module;
|
|
1627
|
+
const originalResolveFilename = moduleWithPrivateResolver._resolveFilename;
|
|
1628
|
+
const originalLoad = moduleWithPrivateResolver._load;
|
|
1629
|
+
const reactNativeIndexPath = path.join(reactNativeMirrorRoot, "react-native", "index.js");
|
|
1630
|
+
const nativeComponentRegistryMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "NativeComponent", "NativeComponentRegistry.js");
|
|
1631
|
+
const requireNativeComponentMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "ReactNative", "requireNativeComponent.js");
|
|
1632
|
+
const initializeCoreMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Core", "InitializeCore.js");
|
|
1633
|
+
const nativeExceptionsManagerMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Core", "NativeExceptionsManager.js");
|
|
1634
|
+
const accessibilityInfoMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Components", "AccessibilityInfo", "AccessibilityInfo.js");
|
|
1635
|
+
const clipboardMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Components", "Clipboard", "Clipboard.js");
|
|
1636
|
+
const codegenNativeCommandsMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Utilities", "codegenNativeCommands.js");
|
|
1637
|
+
const codegenNativeComponentMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Utilities", "codegenNativeComponent.js");
|
|
1638
|
+
const refreshControlMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Components", "RefreshControl", "RefreshControl.js");
|
|
1639
|
+
const activityIndicatorMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Components", "ActivityIndicator", "ActivityIndicator.js");
|
|
1640
|
+
const imageMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Image", "Image.js");
|
|
1641
|
+
const textMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Text", "Text.js");
|
|
1642
|
+
const textInputMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Components", "TextInput", "TextInput.js");
|
|
1643
|
+
const modalMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Modal", "Modal.js");
|
|
1644
|
+
const viewMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Components", "View", "View.js");
|
|
1645
|
+
const scrollViewMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Components", "ScrollView", "ScrollView.js");
|
|
1646
|
+
const nativeModulesMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "BatchedBridge", "NativeModules.js");
|
|
1647
|
+
const uiManagerMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "ReactNative", "UIManager.js");
|
|
1648
|
+
const appStateMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "AppState", "AppState.js");
|
|
1649
|
+
const linkingMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Linking", "Linking.js");
|
|
1650
|
+
const vibrationMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Vibration", "Vibration.js");
|
|
1651
|
+
const viewNativeComponentMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Components", "View", "ViewNativeComponent.js");
|
|
1652
|
+
const useColorSchemeMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Utilities", "useColorScheme.js");
|
|
1653
|
+
const platformMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "Utilities", "Platform.js");
|
|
1654
|
+
const styleSheetMockPath = path.join(reactNativeMirrorRoot, "react-native", "Libraries", "StyleSheet", "StyleSheet.js");
|
|
1655
|
+
const sharedMockModules = getSharedReactNativeMockModules();
|
|
1656
|
+
const tryResolveMirroredPackageRequest = (request) => {
|
|
1657
|
+
if (request === "jest-react-native") return path.join(reactNativeMirrorRoot, "jest-react-native");
|
|
1658
|
+
if (request.startsWith("jest-react-native/")) return path.join(reactNativeMirrorRoot, "jest-react-native", request.slice(18));
|
|
1659
|
+
if (request.startsWith("@react-native-community/")) return path.join(reactNativeMirrorRoot, ...request.split("/"));
|
|
1660
|
+
return null;
|
|
1661
|
+
};
|
|
1662
|
+
const isMirroredPackageManifestRequest = (request) => request === "react-native/package.json" || request === "jest-react-native/package.json" || request.startsWith("@react-native/") && request.endsWith("/package.json") || request.startsWith("@react-native-community/") && request.endsWith("/package.json");
|
|
1663
|
+
moduleWithPrivateResolver._resolveFilename = function patchedResolveFilename(request, parent, isMain, options) {
|
|
1664
|
+
if (isMirroredPackageManifestRequest(request)) return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
1665
|
+
if (request === "react-native") return originalResolveFilename.call(this, reactNativeIndexPath, parent, isMain, options);
|
|
1666
|
+
if (request.startsWith("react-native/")) return originalResolveFilename.call(this, path.join(reactNativeMirrorRoot, "react-native", request.slice(13)), parent, isMain, options);
|
|
1667
|
+
if (request.startsWith("@react-native/")) return originalResolveFilename.call(this, path.join(reactNativeMirrorRoot, request), parent, isMain, options);
|
|
1668
|
+
const mirroredPackageRequest = tryResolveMirroredPackageRequest(request);
|
|
1669
|
+
if (mirroredPackageRequest != null) return originalResolveFilename.call(this, mirroredPackageRequest, parent, isMain, options);
|
|
1670
|
+
return originalResolveFilename.call(this, request, parent, isMain, options);
|
|
1671
|
+
};
|
|
1672
|
+
moduleWithPrivateResolver._load = function patchedLoad(request, parent, isMain) {
|
|
1673
|
+
const resolved = moduleWithPrivateResolver._resolveFilename(request, parent, isMain);
|
|
1674
|
+
if (resolved === reactNativeIndexPath) return getSharedReactNativeExports();
|
|
1675
|
+
if (resolved === nativeComponentRegistryMockPath) return sharedMockModules.nativeComponentRegistryModule;
|
|
1676
|
+
if (resolved === requireNativeComponentMockPath) return sharedMockModules.requireNativeComponentModule;
|
|
1677
|
+
if (resolved === initializeCoreMockPath) return sharedMockModules.initializeCoreModule;
|
|
1678
|
+
if (resolved === nativeExceptionsManagerMockPath) return sharedMockModules.nativeExceptionsManagerModule;
|
|
1679
|
+
if (resolved === accessibilityInfoMockPath) return sharedMockModules.accessibilityInfoModule;
|
|
1680
|
+
if (resolved === clipboardMockPath) return sharedMockModules.clipboardModule;
|
|
1681
|
+
if (resolved === codegenNativeCommandsMockPath) return sharedMockModules.codegenNativeCommandsModule;
|
|
1682
|
+
if (resolved === codegenNativeComponentMockPath) return sharedMockModules.codegenNativeComponentModule;
|
|
1683
|
+
if (resolved === refreshControlMockPath) return sharedMockModules.refreshControlModule;
|
|
1684
|
+
if (resolved === activityIndicatorMockPath) return sharedMockModules.activityIndicatorModule;
|
|
1685
|
+
if (resolved === imageMockPath) return sharedMockModules.imageModule;
|
|
1686
|
+
if (resolved === textMockPath) return sharedMockModules.textModule;
|
|
1687
|
+
if (resolved === textInputMockPath) return sharedMockModules.textInputModule;
|
|
1688
|
+
if (resolved === modalMockPath) return sharedMockModules.modalModule;
|
|
1689
|
+
if (resolved === viewMockPath) return sharedMockModules.viewModule;
|
|
1690
|
+
if (resolved === scrollViewMockPath) return sharedMockModules.scrollViewModule;
|
|
1691
|
+
if (resolved === nativeModulesMockPath) return sharedMockModules.nativeModulesModule;
|
|
1692
|
+
if (resolved === uiManagerMockPath) return sharedMockModules.uiManagerModule;
|
|
1693
|
+
if (resolved === appStateMockPath) return sharedMockModules.appStateModule;
|
|
1694
|
+
if (resolved === linkingMockPath) return sharedMockModules.linkingModule;
|
|
1695
|
+
if (resolved === vibrationMockPath) return sharedMockModules.vibrationModule;
|
|
1696
|
+
if (resolved === viewNativeComponentMockPath) return sharedMockModules.viewNativeComponentModule;
|
|
1697
|
+
if (resolved === useColorSchemeMockPath) return sharedMockModules.useColorSchemeModule;
|
|
1698
|
+
if (resolved === platformMockPath) return sharedMockModules.platformModule;
|
|
1699
|
+
if (resolved === styleSheetMockPath) return sharedMockModules.styleSheetModule;
|
|
1700
|
+
if (REACT_NATIVE_ASSET_MODULE_ID_PATTERN.test(resolved)) return { testUri: path.relative(runtimeDirectory, resolved.replace(/[?#].*$/, "")).replace(/\\/g, "/") };
|
|
1701
|
+
return originalLoad.call(this, request, parent, isMain);
|
|
1702
|
+
};
|
|
1703
|
+
runtimeGlobals.__rntlVitestRnResolverPatched__ = true;
|
|
1704
|
+
}
|
|
1705
|
+
vi.mock("react-native", () => getSharedReactNativeExports());
|
|
1706
|
+
installReactNativeGlobals(runtimeGlobals);
|
|
1707
|
+
installNativeModuleProxy(runtimeGlobals);
|
|
1708
|
+
patchReactNativeResolution();
|
|
1709
|
+
|
|
1710
|
+
//#endregion
|
|
1711
|
+
export { createMockHostComponent, createMockNativeComponent };
|