vitest-native 0.2.1 → 0.4.0
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/CHANGELOG.md +86 -0
- package/README.md +268 -9
- package/dist/chunk-CZWwpsFl.cjs +43 -0
- package/dist/helpers.cjs +10 -0
- package/dist/helpers.d.cts +7 -1
- package/dist/helpers.d.mts +7 -1
- package/dist/helpers.mjs +10 -1
- package/dist/{index-CJqS-y_M.d.cts → index-CJIhukN_.d.mts} +58 -4
- package/dist/{index-h4vpIkQO.d.mts → index-DEB7OFaJ.d.cts} +60 -2
- package/dist/index.cjs +296 -35
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +292 -33
- package/dist/jest-compat/interop.mjs +30 -0
- package/dist/jest-compat/jest-globals.d.mts +3 -0
- package/dist/jest-compat/jest-globals.mjs +9 -0
- package/dist/jest-compat/noop.d.mts +3 -0
- package/dist/jest-compat/noop.mjs +7 -0
- package/dist/jest-compat/setup.d.mts +3 -0
- package/dist/jest-compat/setup.mjs +41 -0
- package/dist/jest-compat.cjs +109 -0
- package/dist/jest-compat.d.cts +38 -0
- package/dist/jest-compat.d.mts +38 -0
- package/dist/jest-compat.mjs +104 -0
- package/dist/matchers.cjs +69 -0
- package/dist/matchers.d.cts +51 -0
- package/dist/matchers.d.mts +51 -0
- package/dist/matchers.mjs +66 -0
- package/dist/native/boundary.mjs +225 -0
- package/dist/native/globals.mjs +112 -0
- package/dist/native/hooks.mjs +85 -0
- package/dist/native/loader.mjs +123 -0
- package/dist/native/match.mjs +9 -0
- package/dist/native/reset.mjs +170 -0
- package/dist/native/resolve.mjs +22 -0
- package/dist/native/runner.mjs +18 -0
- package/dist/native/setup.mjs +134 -0
- package/dist/native/transform.mjs +79 -0
- package/dist/native/worker.mjs +96 -0
- package/dist/pool-B4mWN3N5.cjs +60 -0
- package/dist/pool-oPTZiSXU.mjs +58 -0
- package/dist/{preset-map-Bt4dXkZO.cjs → preset-map-C3jxnkiX.cjs} +6 -1
- package/dist/{preset-map-D224CC5w.mjs → preset-map-OJm5IWuL.mjs} +6 -1
- package/dist/{presets-9Y4ssfiH.cjs → presets-2I68Ipyl.cjs} +768 -122
- package/dist/{presets-CWH0gtM0.mjs → presets-DOGXQzYT.mjs} +732 -87
- package/dist/presets.cjs +5 -1
- package/dist/presets.d.cts +2 -2
- package/dist/presets.d.mts +2 -2
- package/dist/presets.mjs +2 -2
- package/dist/setup.cjs +903 -121
- package/dist/setup.mjs +899 -118
- package/docs/migrating-from-jest.md +123 -0
- package/docs/migrating-from-vitest-react-native.md +109 -0
- package/package.json +67 -8
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
import { vi } from "vitest";
|
|
3
|
-
import React from "react";
|
|
5
|
+
import React, { useState } from "react";
|
|
4
6
|
//#region src/presets/reanimated.ts
|
|
7
|
+
/**
|
|
8
|
+
* Resolve the *active* React Native module — the mock under `engine: 'mock'`
|
|
9
|
+
* (intercepted by the CJS bridge) or real RN under `engine: 'native'` (served by
|
|
10
|
+
* the Node loader hooks). Cached. Lets the reanimated mock's `Animated.View`
|
|
11
|
+
* &co. wrap whichever RN component set is live, so the preset is engine-agnostic.
|
|
12
|
+
*/
|
|
13
|
+
let _rnCache = null;
|
|
14
|
+
function getRN() {
|
|
15
|
+
if (_rnCache) return _rnCache;
|
|
16
|
+
try {
|
|
17
|
+
_rnCache = createRequire(path.join(process.env.VITEST_NATIVE_PROJECT_ROOT || process.cwd(), "package.json"))("react-native");
|
|
18
|
+
} catch {
|
|
19
|
+
_rnCache = {};
|
|
20
|
+
}
|
|
21
|
+
return _rnCache;
|
|
22
|
+
}
|
|
5
23
|
function reanimated() {
|
|
6
24
|
return {
|
|
7
25
|
name: "reanimated",
|
|
@@ -13,6 +31,10 @@ function reanimated() {
|
|
|
13
31
|
"useDerivedValue",
|
|
14
32
|
"useAnimatedScrollHandler",
|
|
15
33
|
"useAnimatedGestureHandler",
|
|
34
|
+
"useAnimatedReaction",
|
|
35
|
+
"useAnimatedKeyboard",
|
|
36
|
+
"useReducedMotion",
|
|
37
|
+
"useFrameCallback",
|
|
16
38
|
"withTiming",
|
|
17
39
|
"withSpring",
|
|
18
40
|
"withDecay",
|
|
@@ -22,18 +44,80 @@ function reanimated() {
|
|
|
22
44
|
"runOnJS",
|
|
23
45
|
"runOnUI",
|
|
24
46
|
"createAnimatedComponent",
|
|
47
|
+
"addWhitelistedUIProps",
|
|
48
|
+
"addWhitelistedNativeProps",
|
|
49
|
+
"configureProps",
|
|
50
|
+
"View",
|
|
51
|
+
"Text",
|
|
52
|
+
"Image",
|
|
53
|
+
"ScrollView",
|
|
54
|
+
"FlatList",
|
|
25
55
|
"Easing",
|
|
26
56
|
"FadeIn",
|
|
27
57
|
"FadeOut",
|
|
58
|
+
"FadeInDown",
|
|
59
|
+
"FadeInUp",
|
|
60
|
+
"FadeInLeft",
|
|
61
|
+
"FadeInRight",
|
|
62
|
+
"FadeOutDown",
|
|
63
|
+
"FadeOutUp",
|
|
64
|
+
"FadeOutLeft",
|
|
65
|
+
"FadeOutRight",
|
|
28
66
|
"SlideInRight",
|
|
67
|
+
"SlideInLeft",
|
|
68
|
+
"SlideInUp",
|
|
69
|
+
"SlideInDown",
|
|
70
|
+
"SlideOutRight",
|
|
29
71
|
"SlideOutLeft",
|
|
72
|
+
"SlideOutUp",
|
|
73
|
+
"SlideOutDown",
|
|
74
|
+
"ZoomIn",
|
|
75
|
+
"ZoomOut",
|
|
76
|
+
"BounceIn",
|
|
77
|
+
"BounceOut",
|
|
78
|
+
"BounceInDown",
|
|
79
|
+
"BounceInUp",
|
|
80
|
+
"BounceInLeft",
|
|
81
|
+
"BounceInRight",
|
|
82
|
+
"FlipInEasyX",
|
|
83
|
+
"FlipInEasyY",
|
|
84
|
+
"FlipOutEasyX",
|
|
85
|
+
"FlipOutEasyY",
|
|
86
|
+
"LightSpeedInLeft",
|
|
87
|
+
"LightSpeedInRight",
|
|
88
|
+
"LightSpeedOutLeft",
|
|
89
|
+
"LightSpeedOutRight",
|
|
90
|
+
"PinwheelIn",
|
|
91
|
+
"PinwheelOut",
|
|
92
|
+
"StretchInX",
|
|
93
|
+
"StretchInY",
|
|
94
|
+
"StretchOutX",
|
|
95
|
+
"StretchOutY",
|
|
96
|
+
"RotateInDownLeft",
|
|
97
|
+
"RotateInDownRight",
|
|
98
|
+
"RotateInUpLeft",
|
|
99
|
+
"RotateInUpRight",
|
|
100
|
+
"RotateOutDownLeft",
|
|
101
|
+
"RotateOutDownRight",
|
|
102
|
+
"RotateOutUpLeft",
|
|
103
|
+
"RotateOutUpRight",
|
|
30
104
|
"Layout",
|
|
105
|
+
"LinearTransition",
|
|
106
|
+
"SequencedTransition",
|
|
107
|
+
"FadingTransition",
|
|
108
|
+
"JumpingTransition",
|
|
109
|
+
"CurvedTransition",
|
|
110
|
+
"EntryExitTransition",
|
|
31
111
|
"interpolate",
|
|
32
112
|
"Extrapolation",
|
|
33
113
|
"useAnimatedRef",
|
|
34
114
|
"measure",
|
|
35
115
|
"scrollTo",
|
|
36
|
-
"cancelAnimation"
|
|
116
|
+
"cancelAnimation",
|
|
117
|
+
"makeMutable",
|
|
118
|
+
"SharedTransition",
|
|
119
|
+
"ReduceMotion",
|
|
120
|
+
"KeyboardState"
|
|
37
121
|
],
|
|
38
122
|
factory: () => {
|
|
39
123
|
function createSharedValue(init) {
|
|
@@ -78,6 +162,23 @@ function reanimated() {
|
|
|
78
162
|
function useAnimatedGestureHandler(_handler) {
|
|
79
163
|
return vi.fn();
|
|
80
164
|
}
|
|
165
|
+
function useAnimatedReaction(_prepare, _react, _deps) {}
|
|
166
|
+
function useAnimatedKeyboard() {
|
|
167
|
+
return {
|
|
168
|
+
state: createSharedValue(0),
|
|
169
|
+
height: createSharedValue(0)
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function useReducedMotion() {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
function useFrameCallback(_callback, _autostart) {
|
|
176
|
+
return {
|
|
177
|
+
setActive: vi.fn(),
|
|
178
|
+
isActive: false,
|
|
179
|
+
callbackId: 0
|
|
180
|
+
};
|
|
181
|
+
}
|
|
81
182
|
function withTiming(toValue, _config, callback) {
|
|
82
183
|
callback?.({
|
|
83
184
|
finished: true,
|
|
@@ -114,6 +215,9 @@ function reanimated() {
|
|
|
114
215
|
function runOnUI(fn) {
|
|
115
216
|
return fn;
|
|
116
217
|
}
|
|
218
|
+
function addWhitelistedUIProps(_props) {}
|
|
219
|
+
function addWhitelistedNativeProps(_props) {}
|
|
220
|
+
function configureProps() {}
|
|
117
221
|
function createAnimatedComponent(component) {
|
|
118
222
|
const Animated = React.forwardRef((props, ref) => {
|
|
119
223
|
return React.createElement(component, {
|
|
@@ -124,14 +228,71 @@ function reanimated() {
|
|
|
124
228
|
Animated.displayName = `Animated(${component.displayName || component.name || "Component"})`;
|
|
125
229
|
return Animated;
|
|
126
230
|
}
|
|
231
|
+
function makeAnimatedHost(name) {
|
|
232
|
+
const Comp = React.forwardRef((props, ref) => {
|
|
233
|
+
const Base = getRN()[name];
|
|
234
|
+
if (!Base) throw new Error(`[vitest-native] reanimated preset: react-native '${name}' is unavailable`);
|
|
235
|
+
return React.createElement(Base, {
|
|
236
|
+
...props,
|
|
237
|
+
ref
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
Comp.displayName = `Animated.${name}`;
|
|
241
|
+
return Comp;
|
|
242
|
+
}
|
|
243
|
+
const View = makeAnimatedHost("View");
|
|
244
|
+
const Text = makeAnimatedHost("Text");
|
|
245
|
+
const Image = makeAnimatedHost("Image");
|
|
246
|
+
const ScrollView = makeAnimatedHost("ScrollView");
|
|
247
|
+
const FlatList = makeAnimatedHost("FlatList");
|
|
248
|
+
function createLayoutAnim() {
|
|
249
|
+
const obj = {};
|
|
250
|
+
obj.duration = vi.fn().mockReturnValue(obj);
|
|
251
|
+
obj.delay = vi.fn().mockReturnValue(obj);
|
|
252
|
+
obj.easing = vi.fn().mockReturnValue(obj);
|
|
253
|
+
obj.damping = vi.fn().mockReturnValue(obj);
|
|
254
|
+
obj.stiffness = vi.fn().mockReturnValue(obj);
|
|
255
|
+
obj.mass = vi.fn().mockReturnValue(obj);
|
|
256
|
+
obj.overshootClamping = vi.fn().mockReturnValue(obj);
|
|
257
|
+
obj.restDisplacementThreshold = vi.fn().mockReturnValue(obj);
|
|
258
|
+
obj.restSpeedThreshold = vi.fn().mockReturnValue(obj);
|
|
259
|
+
obj.springify = vi.fn().mockReturnValue(obj);
|
|
260
|
+
obj.withCallback = vi.fn().mockReturnValue(obj);
|
|
261
|
+
obj.withInitialValues = vi.fn().mockReturnValue(obj);
|
|
262
|
+
obj.randomDelay = vi.fn().mockReturnValue(obj);
|
|
263
|
+
obj.build = vi.fn();
|
|
264
|
+
return obj;
|
|
265
|
+
}
|
|
127
266
|
return {
|
|
128
|
-
default: {
|
|
267
|
+
default: {
|
|
268
|
+
createAnimatedComponent,
|
|
269
|
+
View,
|
|
270
|
+
Text,
|
|
271
|
+
Image,
|
|
272
|
+
ScrollView,
|
|
273
|
+
FlatList,
|
|
274
|
+
addWhitelistedUIProps,
|
|
275
|
+
addWhitelistedNativeProps,
|
|
276
|
+
configureProps
|
|
277
|
+
},
|
|
278
|
+
addWhitelistedUIProps,
|
|
279
|
+
addWhitelistedNativeProps,
|
|
280
|
+
configureProps,
|
|
281
|
+
View,
|
|
282
|
+
Text,
|
|
283
|
+
Image,
|
|
284
|
+
ScrollView,
|
|
285
|
+
FlatList,
|
|
129
286
|
useSharedValue,
|
|
130
287
|
useAnimatedStyle,
|
|
131
288
|
useAnimatedProps,
|
|
132
289
|
useDerivedValue,
|
|
133
290
|
useAnimatedScrollHandler,
|
|
134
291
|
useAnimatedGestureHandler,
|
|
292
|
+
useAnimatedReaction,
|
|
293
|
+
useAnimatedKeyboard,
|
|
294
|
+
useReducedMotion,
|
|
295
|
+
useFrameCallback,
|
|
135
296
|
withTiming,
|
|
136
297
|
withSpring,
|
|
137
298
|
withDecay,
|
|
@@ -151,28 +312,61 @@ function reanimated() {
|
|
|
151
312
|
out: vi.fn((fn) => fn),
|
|
152
313
|
inOut: vi.fn((fn) => fn)
|
|
153
314
|
},
|
|
154
|
-
FadeIn:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
SlideInRight:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
315
|
+
FadeIn: createLayoutAnim(),
|
|
316
|
+
FadeOut: createLayoutAnim(),
|
|
317
|
+
FadeInDown: createLayoutAnim(),
|
|
318
|
+
FadeInUp: createLayoutAnim(),
|
|
319
|
+
FadeInLeft: createLayoutAnim(),
|
|
320
|
+
FadeInRight: createLayoutAnim(),
|
|
321
|
+
FadeOutDown: createLayoutAnim(),
|
|
322
|
+
FadeOutUp: createLayoutAnim(),
|
|
323
|
+
FadeOutLeft: createLayoutAnim(),
|
|
324
|
+
FadeOutRight: createLayoutAnim(),
|
|
325
|
+
SlideInRight: createLayoutAnim(),
|
|
326
|
+
SlideInLeft: createLayoutAnim(),
|
|
327
|
+
SlideInUp: createLayoutAnim(),
|
|
328
|
+
SlideInDown: createLayoutAnim(),
|
|
329
|
+
SlideOutRight: createLayoutAnim(),
|
|
330
|
+
SlideOutLeft: createLayoutAnim(),
|
|
331
|
+
SlideOutUp: createLayoutAnim(),
|
|
332
|
+
SlideOutDown: createLayoutAnim(),
|
|
333
|
+
ZoomIn: createLayoutAnim(),
|
|
334
|
+
ZoomOut: createLayoutAnim(),
|
|
335
|
+
BounceIn: createLayoutAnim(),
|
|
336
|
+
BounceOut: createLayoutAnim(),
|
|
337
|
+
BounceInDown: createLayoutAnim(),
|
|
338
|
+
BounceInUp: createLayoutAnim(),
|
|
339
|
+
BounceInLeft: createLayoutAnim(),
|
|
340
|
+
BounceInRight: createLayoutAnim(),
|
|
341
|
+
FlipInEasyX: createLayoutAnim(),
|
|
342
|
+
FlipInEasyY: createLayoutAnim(),
|
|
343
|
+
FlipOutEasyX: createLayoutAnim(),
|
|
344
|
+
FlipOutEasyY: createLayoutAnim(),
|
|
345
|
+
LightSpeedInLeft: createLayoutAnim(),
|
|
346
|
+
LightSpeedInRight: createLayoutAnim(),
|
|
347
|
+
LightSpeedOutLeft: createLayoutAnim(),
|
|
348
|
+
LightSpeedOutRight: createLayoutAnim(),
|
|
349
|
+
PinwheelIn: createLayoutAnim(),
|
|
350
|
+
PinwheelOut: createLayoutAnim(),
|
|
351
|
+
StretchInX: createLayoutAnim(),
|
|
352
|
+
StretchInY: createLayoutAnim(),
|
|
353
|
+
StretchOutX: createLayoutAnim(),
|
|
354
|
+
StretchOutY: createLayoutAnim(),
|
|
355
|
+
RotateInDownLeft: createLayoutAnim(),
|
|
356
|
+
RotateInDownRight: createLayoutAnim(),
|
|
357
|
+
RotateInUpLeft: createLayoutAnim(),
|
|
358
|
+
RotateInUpRight: createLayoutAnim(),
|
|
359
|
+
RotateOutDownLeft: createLayoutAnim(),
|
|
360
|
+
RotateOutDownRight: createLayoutAnim(),
|
|
361
|
+
RotateOutUpLeft: createLayoutAnim(),
|
|
362
|
+
RotateOutUpRight: createLayoutAnim(),
|
|
363
|
+
Layout: createLayoutAnim(),
|
|
364
|
+
LinearTransition: createLayoutAnim(),
|
|
365
|
+
SequencedTransition: createLayoutAnim(),
|
|
366
|
+
FadingTransition: createLayoutAnim(),
|
|
367
|
+
JumpingTransition: createLayoutAnim(),
|
|
368
|
+
CurvedTransition: createLayoutAnim(),
|
|
369
|
+
EntryExitTransition: createLayoutAnim(),
|
|
176
370
|
interpolate: vi.fn((_value, input, output) => output[0]),
|
|
177
371
|
Extrapolation: {
|
|
178
372
|
CLAMP: "clamp",
|
|
@@ -189,13 +383,66 @@ function reanimated() {
|
|
|
189
383
|
pageY: 0
|
|
190
384
|
})),
|
|
191
385
|
scrollTo: vi.fn(),
|
|
192
|
-
cancelAnimation: vi.fn()
|
|
386
|
+
cancelAnimation: vi.fn(),
|
|
387
|
+
makeMutable: vi.fn((init) => createSharedValue(init)),
|
|
388
|
+
SharedTransition: {
|
|
389
|
+
duration: vi.fn().mockReturnThis(),
|
|
390
|
+
custom: vi.fn().mockReturnThis(),
|
|
391
|
+
progressAnimation: vi.fn().mockReturnThis(),
|
|
392
|
+
defaultTransitionType: vi.fn().mockReturnThis()
|
|
393
|
+
},
|
|
394
|
+
ReduceMotion: {
|
|
395
|
+
System: "system",
|
|
396
|
+
Always: "always",
|
|
397
|
+
Never: "never"
|
|
398
|
+
},
|
|
399
|
+
KeyboardState: {
|
|
400
|
+
UNKNOWN: 0,
|
|
401
|
+
OPENING: 1,
|
|
402
|
+
OPEN: 2,
|
|
403
|
+
CLOSING: 3,
|
|
404
|
+
CLOSED: 4
|
|
405
|
+
}
|
|
193
406
|
};
|
|
194
407
|
}
|
|
195
408
|
} }
|
|
196
409
|
};
|
|
197
410
|
}
|
|
198
411
|
//#endregion
|
|
412
|
+
//#region src/mocks/components/pressableHost.ts
|
|
413
|
+
function buildPressableHostProps(props, ref) {
|
|
414
|
+
const { disabled, accessibilityState, onPress, onPressIn, onPressOut, onLongPress, ...rest } = props;
|
|
415
|
+
const mergedA11yState = disabled || accessibilityState ? {
|
|
416
|
+
...accessibilityState,
|
|
417
|
+
...disabled ? { disabled: true } : {}
|
|
418
|
+
} : void 0;
|
|
419
|
+
return {
|
|
420
|
+
accessible: true,
|
|
421
|
+
...disabled ? {} : {
|
|
422
|
+
onStartShouldSetResponder: () => true,
|
|
423
|
+
onResponderGrant: (e) => onPressIn?.(e),
|
|
424
|
+
onResponderRelease: (e) => {
|
|
425
|
+
onPress?.(e);
|
|
426
|
+
onPressOut?.(e);
|
|
427
|
+
},
|
|
428
|
+
onPress,
|
|
429
|
+
onPressIn,
|
|
430
|
+
onPressOut,
|
|
431
|
+
onLongPress
|
|
432
|
+
},
|
|
433
|
+
...rest,
|
|
434
|
+
...mergedA11yState ? { accessibilityState: mergedA11yState } : {},
|
|
435
|
+
ref
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region src/mocks/components/Pressable.ts
|
|
440
|
+
function createPressableMock() {
|
|
441
|
+
const Pressable = React.forwardRef((props, ref) => React.createElement("Pressable", buildPressableHostProps(props, ref)));
|
|
442
|
+
Pressable.displayName = "Pressable";
|
|
443
|
+
return Pressable;
|
|
444
|
+
}
|
|
445
|
+
//#endregion
|
|
199
446
|
//#region src/presets/gesture-handler.ts
|
|
200
447
|
function gestureHandler() {
|
|
201
448
|
return {
|
|
@@ -223,7 +470,13 @@ function gestureHandler() {
|
|
|
223
470
|
"TouchableOpacity",
|
|
224
471
|
"TouchableHighlight",
|
|
225
472
|
"TouchableWithoutFeedback",
|
|
226
|
-
"TouchableNativeFeedback"
|
|
473
|
+
"TouchableNativeFeedback",
|
|
474
|
+
"Pressable",
|
|
475
|
+
"RectButton",
|
|
476
|
+
"BaseButton",
|
|
477
|
+
"BorderlessButton",
|
|
478
|
+
"RawButton",
|
|
479
|
+
"PureNativeButton"
|
|
227
480
|
],
|
|
228
481
|
factory: () => {
|
|
229
482
|
const State = {
|
|
@@ -341,7 +594,13 @@ function gestureHandler() {
|
|
|
341
594
|
TouchableOpacity: createGestureHandler("GH-TouchableOpacity"),
|
|
342
595
|
TouchableHighlight: createGestureHandler("GH-TouchableHighlight"),
|
|
343
596
|
TouchableWithoutFeedback: createGestureHandler("GH-TouchableWithoutFeedback"),
|
|
344
|
-
TouchableNativeFeedback: createGestureHandler("GH-TouchableNativeFeedback")
|
|
597
|
+
TouchableNativeFeedback: createGestureHandler("GH-TouchableNativeFeedback"),
|
|
598
|
+
Pressable: createPressableMock(),
|
|
599
|
+
RectButton: createGestureHandler("RectButton"),
|
|
600
|
+
BaseButton: createGestureHandler("BaseButton"),
|
|
601
|
+
BorderlessButton: createGestureHandler("BorderlessButton"),
|
|
602
|
+
RawButton: createGestureHandler("RawButton"),
|
|
603
|
+
PureNativeButton: createGestureHandler("PureNativeButton")
|
|
345
604
|
};
|
|
346
605
|
}
|
|
347
606
|
} }
|
|
@@ -368,19 +627,25 @@ function safeAreaContext() {
|
|
|
368
627
|
"Metrics"
|
|
369
628
|
],
|
|
370
629
|
factory: () => {
|
|
630
|
+
const defaultInsets = {
|
|
631
|
+
top: 47,
|
|
632
|
+
right: 0,
|
|
633
|
+
bottom: 34,
|
|
634
|
+
left: 0
|
|
635
|
+
};
|
|
636
|
+
const defaultFrame = {
|
|
637
|
+
x: 0,
|
|
638
|
+
y: 0,
|
|
639
|
+
width: 390,
|
|
640
|
+
height: 844
|
|
641
|
+
};
|
|
642
|
+
const state = {
|
|
643
|
+
insets: { ...defaultInsets },
|
|
644
|
+
frame: { ...defaultFrame }
|
|
645
|
+
};
|
|
371
646
|
const initialMetrics = {
|
|
372
|
-
frame:
|
|
373
|
-
|
|
374
|
-
y: 0,
|
|
375
|
-
width: 390,
|
|
376
|
-
height: 844
|
|
377
|
-
},
|
|
378
|
-
insets: {
|
|
379
|
-
top: 47,
|
|
380
|
-
right: 0,
|
|
381
|
-
bottom: 34,
|
|
382
|
-
left: 0
|
|
383
|
-
}
|
|
647
|
+
frame: state.frame,
|
|
648
|
+
insets: state.insets
|
|
384
649
|
};
|
|
385
650
|
const SafeAreaProvider = React.forwardRef((props, ref) => React.createElement("SafeAreaProvider", {
|
|
386
651
|
...props,
|
|
@@ -392,19 +657,19 @@ function safeAreaContext() {
|
|
|
392
657
|
ref
|
|
393
658
|
}, props.children));
|
|
394
659
|
SafeAreaView.displayName = "SafeAreaView";
|
|
395
|
-
const SafeAreaInsetsContext = React.createContext(
|
|
396
|
-
const SafeAreaFrameContext = React.createContext(
|
|
660
|
+
const SafeAreaInsetsContext = React.createContext(state.insets);
|
|
661
|
+
const SafeAreaFrameContext = React.createContext(state.frame);
|
|
397
662
|
function useSafeAreaInsets() {
|
|
398
|
-
return
|
|
663
|
+
return state.insets;
|
|
399
664
|
}
|
|
400
665
|
function useSafeAreaFrame() {
|
|
401
|
-
return
|
|
666
|
+
return state.frame;
|
|
402
667
|
}
|
|
403
668
|
function withSafeAreaInsets(WrappedComponent) {
|
|
404
669
|
const WithSafeAreaInsets = React.forwardRef((props, ref) => React.createElement(WrappedComponent, {
|
|
405
670
|
...props,
|
|
406
671
|
ref,
|
|
407
|
-
insets:
|
|
672
|
+
insets: state.insets
|
|
408
673
|
}));
|
|
409
674
|
WithSafeAreaInsets.displayName = `withSafeAreaInsets(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
|
|
410
675
|
return WithSafeAreaInsets;
|
|
@@ -422,10 +687,17 @@ function safeAreaContext() {
|
|
|
422
687
|
useSafeAreaFrame,
|
|
423
688
|
withSafeAreaInsets,
|
|
424
689
|
initialWindowMetrics: initialMetrics,
|
|
425
|
-
initialWindowSafeAreaInsets:
|
|
690
|
+
initialWindowSafeAreaInsets: state.insets,
|
|
426
691
|
EdgeInsets: vi.fn(),
|
|
427
692
|
Rect: vi.fn(),
|
|
428
|
-
Metrics: vi.fn()
|
|
693
|
+
Metrics: vi.fn(),
|
|
694
|
+
_setInsets: (insets) => {
|
|
695
|
+
Object.assign(state.insets, insets);
|
|
696
|
+
},
|
|
697
|
+
_reset: () => {
|
|
698
|
+
Object.assign(state.insets, defaultInsets);
|
|
699
|
+
Object.assign(state.frame, defaultFrame);
|
|
700
|
+
}
|
|
429
701
|
};
|
|
430
702
|
}
|
|
431
703
|
} }
|
|
@@ -433,7 +705,76 @@ function safeAreaContext() {
|
|
|
433
705
|
}
|
|
434
706
|
//#endregion
|
|
435
707
|
//#region src/presets/navigation.ts
|
|
708
|
+
/** Builds a minimal navigation prop matching useNavigation()'s shape. */
|
|
709
|
+
function createMockNavigation() {
|
|
710
|
+
return {
|
|
711
|
+
navigate: vi.fn(),
|
|
712
|
+
goBack: vi.fn(),
|
|
713
|
+
reset: vi.fn(),
|
|
714
|
+
setParams: vi.fn(),
|
|
715
|
+
setOptions: vi.fn(),
|
|
716
|
+
dispatch: vi.fn(),
|
|
717
|
+
canGoBack: vi.fn(() => false),
|
|
718
|
+
getParent: vi.fn(() => void 0),
|
|
719
|
+
getState: vi.fn(() => ({
|
|
720
|
+
index: 0,
|
|
721
|
+
key: "root",
|
|
722
|
+
routeNames: [],
|
|
723
|
+
routes: [],
|
|
724
|
+
type: "stack",
|
|
725
|
+
stale: false
|
|
726
|
+
})),
|
|
727
|
+
isFocused: vi.fn(() => true),
|
|
728
|
+
addListener: vi.fn(() => vi.fn()),
|
|
729
|
+
removeListener: vi.fn(),
|
|
730
|
+
getId: vi.fn(() => void 0)
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Creates a Screen component mock that handles all three React Navigation patterns:
|
|
735
|
+
* 1. <Screen component={Comp} /> — renders Comp with route & navigation props
|
|
736
|
+
* 2. <Screen>{(props) => <Comp />}</Screen> — calls render function
|
|
737
|
+
* 3. <Screen><Something /></Screen> — passes children through
|
|
738
|
+
*
|
|
739
|
+
* Accepts NavigationContext and NavigationRouteContext so that hooks like
|
|
740
|
+
* useNavigation() and useRoute() inside the screen component return values
|
|
741
|
+
* consistent with the route/navigation props passed to the component.
|
|
742
|
+
*/
|
|
743
|
+
function createMockScreen(NavContext, RouteContext) {
|
|
744
|
+
const Screen = React.forwardRef(({ component: Component, children, ...rest }, ref) => {
|
|
745
|
+
const route = {
|
|
746
|
+
key: rest.name ?? "",
|
|
747
|
+
name: rest.name ?? "",
|
|
748
|
+
params: rest.initialParams
|
|
749
|
+
};
|
|
750
|
+
const nav = createMockNavigation();
|
|
751
|
+
const content = Component ? React.createElement(Component, {
|
|
752
|
+
route,
|
|
753
|
+
navigation: nav
|
|
754
|
+
}) : typeof children === "function" ? children({
|
|
755
|
+
route,
|
|
756
|
+
navigation: nav
|
|
757
|
+
}) : children;
|
|
758
|
+
return React.createElement("Screen", {
|
|
759
|
+
...rest,
|
|
760
|
+
ref
|
|
761
|
+
}, React.createElement(NavContext.Provider, { value: nav }, React.createElement(RouteContext.Provider, { value: route }, content)));
|
|
762
|
+
});
|
|
763
|
+
Screen.displayName = "Screen";
|
|
764
|
+
return Screen;
|
|
765
|
+
}
|
|
436
766
|
function navigation() {
|
|
767
|
+
const NavigationContext = React.createContext(null);
|
|
768
|
+
const NavigationRouteContext = React.createContext(null);
|
|
769
|
+
const NavigationContainerRefContext = React.createContext(null);
|
|
770
|
+
const NavigationHelpersContext = React.createContext(null);
|
|
771
|
+
const CurrentRenderContext = React.createContext(void 0);
|
|
772
|
+
const ThemeContext = React.createContext({
|
|
773
|
+
dark: false,
|
|
774
|
+
colors: {}
|
|
775
|
+
});
|
|
776
|
+
const PreventRemoveContext = React.createContext(null);
|
|
777
|
+
const Screen = createMockScreen(NavigationContext, NavigationRouteContext);
|
|
437
778
|
return {
|
|
438
779
|
name: "navigation",
|
|
439
780
|
modules: {
|
|
@@ -447,6 +788,7 @@ function navigation() {
|
|
|
447
788
|
"useFocusEffect",
|
|
448
789
|
"useIsFocused",
|
|
449
790
|
"useNavigationState",
|
|
791
|
+
"useScrollToTop",
|
|
450
792
|
"useNavigationContainerRef",
|
|
451
793
|
"createNavigationContainerRef",
|
|
452
794
|
"createNavigatorFactory",
|
|
@@ -503,29 +845,39 @@ function navigation() {
|
|
|
503
845
|
type: "stack",
|
|
504
846
|
stale: false
|
|
505
847
|
}));
|
|
848
|
+
const defaultNavigation = {
|
|
849
|
+
navigate,
|
|
850
|
+
goBack,
|
|
851
|
+
reset,
|
|
852
|
+
setParams,
|
|
853
|
+
setOptions,
|
|
854
|
+
dispatch,
|
|
855
|
+
canGoBack,
|
|
856
|
+
getParent,
|
|
857
|
+
getState,
|
|
858
|
+
isFocused: vi.fn(() => true),
|
|
859
|
+
addListener: vi.fn(() => vi.fn()),
|
|
860
|
+
removeListener: vi.fn(),
|
|
861
|
+
getId: vi.fn(() => void 0)
|
|
862
|
+
};
|
|
863
|
+
const defaultRoute = {
|
|
864
|
+
key: "test-route-key",
|
|
865
|
+
name: "TestScreen",
|
|
866
|
+
params: {}
|
|
867
|
+
};
|
|
506
868
|
function useNavigation() {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
setOptions,
|
|
513
|
-
dispatch,
|
|
514
|
-
canGoBack,
|
|
515
|
-
getParent,
|
|
516
|
-
getState,
|
|
517
|
-
isFocused: vi.fn(() => true),
|
|
518
|
-
addListener: vi.fn(() => vi.fn()),
|
|
519
|
-
removeListener: vi.fn(),
|
|
520
|
-
getId: vi.fn(() => void 0)
|
|
521
|
-
};
|
|
869
|
+
try {
|
|
870
|
+
const ctx = React.useContext(NavigationContext);
|
|
871
|
+
if (ctx) return ctx;
|
|
872
|
+
} catch {}
|
|
873
|
+
return defaultNavigation;
|
|
522
874
|
}
|
|
523
875
|
function useRoute() {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
876
|
+
try {
|
|
877
|
+
const ctx = React.useContext(NavigationRouteContext);
|
|
878
|
+
if (ctx) return ctx;
|
|
879
|
+
} catch {}
|
|
880
|
+
return defaultRoute;
|
|
529
881
|
}
|
|
530
882
|
function useFocusEffect(callback) {
|
|
531
883
|
React.useEffect(callback, []);
|
|
@@ -558,16 +910,6 @@ function navigation() {
|
|
|
558
910
|
function useNavigationContainerRef() {
|
|
559
911
|
return createNavigationContainerRef();
|
|
560
912
|
}
|
|
561
|
-
const NavigationContext = React.createContext(null);
|
|
562
|
-
const NavigationRouteContext = React.createContext(null);
|
|
563
|
-
const NavigationContainerRefContext = React.createContext(null);
|
|
564
|
-
const NavigationHelpersContext = React.createContext(null);
|
|
565
|
-
const CurrentRenderContext = React.createContext(void 0);
|
|
566
|
-
const ThemeContext = React.createContext({
|
|
567
|
-
dark: false,
|
|
568
|
-
colors: {}
|
|
569
|
-
});
|
|
570
|
-
const PreventRemoveContext = React.createContext(null);
|
|
571
913
|
const defaultTheme = {
|
|
572
914
|
dark: false,
|
|
573
915
|
colors: {
|
|
@@ -667,6 +1009,7 @@ function navigation() {
|
|
|
667
1009
|
getStateForAction: vi.fn((state) => state),
|
|
668
1010
|
shouldActionChangeFocus: vi.fn(() => false)
|
|
669
1011
|
},
|
|
1012
|
+
useScrollToTop: vi.fn(),
|
|
670
1013
|
useLinkTo: vi.fn(() => vi.fn()),
|
|
671
1014
|
Link: React.forwardRef((props, ref) => React.createElement("Link", {
|
|
672
1015
|
...props,
|
|
@@ -684,10 +1027,7 @@ function navigation() {
|
|
|
684
1027
|
...props,
|
|
685
1028
|
ref
|
|
686
1029
|
}, props.children)),
|
|
687
|
-
Screen
|
|
688
|
-
...props,
|
|
689
|
-
ref
|
|
690
|
-
}, props.children)),
|
|
1030
|
+
Screen,
|
|
691
1031
|
Group: React.forwardRef((props, ref) => React.createElement("Group", {
|
|
692
1032
|
...props,
|
|
693
1033
|
ref
|
|
@@ -709,10 +1049,29 @@ function navigation() {
|
|
|
709
1049
|
...props,
|
|
710
1050
|
ref
|
|
711
1051
|
}, props.children)),
|
|
712
|
-
Screen
|
|
1052
|
+
Screen,
|
|
1053
|
+
Group: React.forwardRef((props, ref) => React.createElement("Group", {
|
|
1054
|
+
...props,
|
|
1055
|
+
ref
|
|
1056
|
+
}, props.children))
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
return {
|
|
1060
|
+
default: { createBottomTabNavigator },
|
|
1061
|
+
createBottomTabNavigator
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
},
|
|
1065
|
+
"@react-navigation/drawer": {
|
|
1066
|
+
exports: ["createDrawerNavigator"],
|
|
1067
|
+
factory: () => {
|
|
1068
|
+
function createDrawerNavigator() {
|
|
1069
|
+
return {
|
|
1070
|
+
Navigator: React.forwardRef((props, ref) => React.createElement("DrawerNavigator", {
|
|
713
1071
|
...props,
|
|
714
1072
|
ref
|
|
715
1073
|
}, props.children)),
|
|
1074
|
+
Screen,
|
|
716
1075
|
Group: React.forwardRef((props, ref) => React.createElement("Group", {
|
|
717
1076
|
...props,
|
|
718
1077
|
ref
|
|
@@ -720,8 +1079,8 @@ function navigation() {
|
|
|
720
1079
|
};
|
|
721
1080
|
}
|
|
722
1081
|
return {
|
|
723
|
-
default: {
|
|
724
|
-
|
|
1082
|
+
default: { createDrawerNavigator },
|
|
1083
|
+
createDrawerNavigator
|
|
725
1084
|
};
|
|
726
1085
|
}
|
|
727
1086
|
},
|
|
@@ -856,7 +1215,8 @@ function asyncStorage() {
|
|
|
856
1215
|
else store.set(key, value);
|
|
857
1216
|
});
|
|
858
1217
|
}),
|
|
859
|
-
flushGetRequests: vi.fn(() => {})
|
|
1218
|
+
flushGetRequests: vi.fn(() => {}),
|
|
1219
|
+
_resetStore: () => store.clear()
|
|
860
1220
|
};
|
|
861
1221
|
return {
|
|
862
1222
|
...exports,
|
|
@@ -1094,15 +1454,300 @@ function expo() {
|
|
|
1094
1454
|
};
|
|
1095
1455
|
}
|
|
1096
1456
|
//#endregion
|
|
1457
|
+
//#region src/presets/device-info.ts
|
|
1458
|
+
const STRINGS = {
|
|
1459
|
+
getBrand: "Apple",
|
|
1460
|
+
getModel: "iPhone",
|
|
1461
|
+
getDeviceId: "iPhone14,2",
|
|
1462
|
+
getSystemName: "iOS",
|
|
1463
|
+
getSystemVersion: "17.0",
|
|
1464
|
+
getVersion: "1.0.0",
|
|
1465
|
+
getReadableVersion: "1.0.0.1",
|
|
1466
|
+
getBuildNumber: "1",
|
|
1467
|
+
getBundleId: "com.example.app",
|
|
1468
|
+
getApplicationName: "Example",
|
|
1469
|
+
getDeviceName: "iPhone",
|
|
1470
|
+
getUniqueId: "mock-unique-id",
|
|
1471
|
+
getInstallReferrer: "",
|
|
1472
|
+
getDeviceType: "Handset",
|
|
1473
|
+
getUserAgent: "vitest-native",
|
|
1474
|
+
getCarrier: "",
|
|
1475
|
+
getManufacturer: "Apple"
|
|
1476
|
+
};
|
|
1477
|
+
const BOOLEANS = {
|
|
1478
|
+
hasNotch: true,
|
|
1479
|
+
hasDynamicIsland: false,
|
|
1480
|
+
isTablet: false,
|
|
1481
|
+
isEmulator: false,
|
|
1482
|
+
isPinOrFingerprintSet: false,
|
|
1483
|
+
isCameraPresent: true,
|
|
1484
|
+
isLandscape: false,
|
|
1485
|
+
isLowBatteryLevel: false,
|
|
1486
|
+
isHeadphonesConnected: false
|
|
1487
|
+
};
|
|
1488
|
+
const NUMBERS = {
|
|
1489
|
+
getFontScale: 1,
|
|
1490
|
+
getBatteryLevel: 1,
|
|
1491
|
+
getTotalMemory: 4e9,
|
|
1492
|
+
getUsedMemory: 1e9,
|
|
1493
|
+
getApiLevel: 33
|
|
1494
|
+
};
|
|
1495
|
+
function deviceInfo() {
|
|
1496
|
+
const exports = [
|
|
1497
|
+
...Object.keys(STRINGS),
|
|
1498
|
+
...Object.keys(BOOLEANS),
|
|
1499
|
+
...Object.keys(NUMBERS),
|
|
1500
|
+
...Object.keys(STRINGS).map((k) => k + "Sync"),
|
|
1501
|
+
...Object.keys(BOOLEANS).map((k) => k + "Sync"),
|
|
1502
|
+
...Object.keys(NUMBERS).map((k) => k + "Sync")
|
|
1503
|
+
];
|
|
1504
|
+
return {
|
|
1505
|
+
name: "deviceInfo",
|
|
1506
|
+
modules: { "react-native-device-info": {
|
|
1507
|
+
exports,
|
|
1508
|
+
factory: () => {
|
|
1509
|
+
const api = {};
|
|
1510
|
+
for (const [k, v] of Object.entries({
|
|
1511
|
+
...STRINGS,
|
|
1512
|
+
...BOOLEANS,
|
|
1513
|
+
...NUMBERS
|
|
1514
|
+
})) {
|
|
1515
|
+
api[k] = () => Promise.resolve(v);
|
|
1516
|
+
api[k + "Sync"] = () => v;
|
|
1517
|
+
}
|
|
1518
|
+
for (const k of [
|
|
1519
|
+
"hasNotch",
|
|
1520
|
+
"hasDynamicIsland",
|
|
1521
|
+
"isTablet",
|
|
1522
|
+
"getDeviceType"
|
|
1523
|
+
]) {
|
|
1524
|
+
const src = {
|
|
1525
|
+
...STRINGS,
|
|
1526
|
+
...BOOLEANS
|
|
1527
|
+
};
|
|
1528
|
+
api[k] = () => src[k];
|
|
1529
|
+
}
|
|
1530
|
+
api.getUniqueIdSync = () => STRINGS.getUniqueId;
|
|
1531
|
+
return {
|
|
1532
|
+
__esModule: true,
|
|
1533
|
+
default: api,
|
|
1534
|
+
...api
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
} }
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1540
|
+
//#endregion
|
|
1541
|
+
//#region src/presets/mmkv.ts
|
|
1542
|
+
function mmkv() {
|
|
1543
|
+
return {
|
|
1544
|
+
name: "mmkv",
|
|
1545
|
+
modules: { "react-native-mmkv": {
|
|
1546
|
+
exports: [
|
|
1547
|
+
"MMKV",
|
|
1548
|
+
"createMMKV",
|
|
1549
|
+
"useMMKV",
|
|
1550
|
+
"useMMKVString",
|
|
1551
|
+
"useMMKVNumber",
|
|
1552
|
+
"useMMKVBoolean",
|
|
1553
|
+
"useMMKVObject",
|
|
1554
|
+
"useMMKVBuffer",
|
|
1555
|
+
"useMMKVListener",
|
|
1556
|
+
"Mode"
|
|
1557
|
+
],
|
|
1558
|
+
factory: () => {
|
|
1559
|
+
class MMKV {
|
|
1560
|
+
_store = /* @__PURE__ */ new Map();
|
|
1561
|
+
set(key, value) {
|
|
1562
|
+
this._store.set(key, value);
|
|
1563
|
+
}
|
|
1564
|
+
getString(key) {
|
|
1565
|
+
const v = this._store.get(key);
|
|
1566
|
+
return typeof v === "string" ? v : void 0;
|
|
1567
|
+
}
|
|
1568
|
+
getNumber(key) {
|
|
1569
|
+
const v = this._store.get(key);
|
|
1570
|
+
return typeof v === "number" ? v : void 0;
|
|
1571
|
+
}
|
|
1572
|
+
getBoolean(key) {
|
|
1573
|
+
const v = this._store.get(key);
|
|
1574
|
+
return typeof v === "boolean" ? v : void 0;
|
|
1575
|
+
}
|
|
1576
|
+
getBuffer(key) {
|
|
1577
|
+
const v = this._store.get(key);
|
|
1578
|
+
return v instanceof Uint8Array ? v : void 0;
|
|
1579
|
+
}
|
|
1580
|
+
contains(key) {
|
|
1581
|
+
return this._store.has(key);
|
|
1582
|
+
}
|
|
1583
|
+
delete(key) {
|
|
1584
|
+
this._store.delete(key);
|
|
1585
|
+
}
|
|
1586
|
+
getAllKeys() {
|
|
1587
|
+
return [...this._store.keys()];
|
|
1588
|
+
}
|
|
1589
|
+
clearAll() {
|
|
1590
|
+
this._store.clear();
|
|
1591
|
+
}
|
|
1592
|
+
recrypt() {}
|
|
1593
|
+
addOnValueChangedListener() {
|
|
1594
|
+
return { remove() {} };
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
const shared = new MMKV();
|
|
1598
|
+
const createMMKV = () => new MMKV();
|
|
1599
|
+
const useMMKV = () => shared;
|
|
1600
|
+
function makeHook(get) {
|
|
1601
|
+
return (key, instance) => {
|
|
1602
|
+
const m = instance ?? shared;
|
|
1603
|
+
const [value, setValue] = useState(get(m, key));
|
|
1604
|
+
const set = (v) => {
|
|
1605
|
+
if (v === void 0) m.delete(key);
|
|
1606
|
+
else m.set(key, v);
|
|
1607
|
+
setValue(v);
|
|
1608
|
+
};
|
|
1609
|
+
return [value, set];
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
return {
|
|
1613
|
+
__esModule: true,
|
|
1614
|
+
MMKV,
|
|
1615
|
+
createMMKV,
|
|
1616
|
+
useMMKV,
|
|
1617
|
+
useMMKVString: makeHook((m, k) => m.getString(k)),
|
|
1618
|
+
useMMKVNumber: makeHook((m, k) => m.getNumber(k)),
|
|
1619
|
+
useMMKVBoolean: makeHook((m, k) => m.getBoolean(k)),
|
|
1620
|
+
useMMKVBuffer: makeHook((m, k) => m.getBuffer(k)),
|
|
1621
|
+
useMMKVObject: (key, instance) => {
|
|
1622
|
+
const m = instance ?? shared;
|
|
1623
|
+
const raw = m.getString(key);
|
|
1624
|
+
const [value, setValue] = useState(raw ? JSON.parse(raw) : void 0);
|
|
1625
|
+
const set = (v) => {
|
|
1626
|
+
if (v === void 0) m.delete(key);
|
|
1627
|
+
else m.set(key, JSON.stringify(v));
|
|
1628
|
+
setValue(v);
|
|
1629
|
+
};
|
|
1630
|
+
return [value, set];
|
|
1631
|
+
},
|
|
1632
|
+
useMMKVListener: () => ({ remove() {} }),
|
|
1633
|
+
Mode: {
|
|
1634
|
+
SINGLE_PROCESS: 0,
|
|
1635
|
+
MULTI_PROCESS: 1
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
} }
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
//#endregion
|
|
1643
|
+
//#region src/presets/svg.ts
|
|
1644
|
+
const SVG_COMPONENTS = [
|
|
1645
|
+
"Svg",
|
|
1646
|
+
"Circle",
|
|
1647
|
+
"Ellipse",
|
|
1648
|
+
"G",
|
|
1649
|
+
"Text",
|
|
1650
|
+
"TSpan",
|
|
1651
|
+
"TextPath",
|
|
1652
|
+
"Path",
|
|
1653
|
+
"Polygon",
|
|
1654
|
+
"Polyline",
|
|
1655
|
+
"Line",
|
|
1656
|
+
"Rect",
|
|
1657
|
+
"Use",
|
|
1658
|
+
"Image",
|
|
1659
|
+
"Symbol",
|
|
1660
|
+
"Defs",
|
|
1661
|
+
"LinearGradient",
|
|
1662
|
+
"RadialGradient",
|
|
1663
|
+
"Stop",
|
|
1664
|
+
"ClipPath",
|
|
1665
|
+
"Pattern",
|
|
1666
|
+
"Mask",
|
|
1667
|
+
"Marker",
|
|
1668
|
+
"ForeignObject",
|
|
1669
|
+
"FeBlend",
|
|
1670
|
+
"FeColorMatrix",
|
|
1671
|
+
"FeGaussianBlur",
|
|
1672
|
+
"FeMerge",
|
|
1673
|
+
"FeOffset"
|
|
1674
|
+
];
|
|
1675
|
+
function svg() {
|
|
1676
|
+
return {
|
|
1677
|
+
name: "svg",
|
|
1678
|
+
modules: { "react-native-svg": {
|
|
1679
|
+
exports: [
|
|
1680
|
+
...SVG_COMPONENTS,
|
|
1681
|
+
"SvgXml",
|
|
1682
|
+
"SvgUri",
|
|
1683
|
+
"SvgCss",
|
|
1684
|
+
"SvgCssUri"
|
|
1685
|
+
],
|
|
1686
|
+
factory: () => {
|
|
1687
|
+
const make = (name) => {
|
|
1688
|
+
const C = React.forwardRef((props, ref) => React.createElement(name, {
|
|
1689
|
+
...props,
|
|
1690
|
+
ref
|
|
1691
|
+
}, props.children));
|
|
1692
|
+
C.displayName = name;
|
|
1693
|
+
return C;
|
|
1694
|
+
};
|
|
1695
|
+
const out = { __esModule: true };
|
|
1696
|
+
for (const name of SVG_COMPONENTS) out[name] = make(name);
|
|
1697
|
+
out.SvgXml = make("SvgXml");
|
|
1698
|
+
out.SvgUri = make("SvgUri");
|
|
1699
|
+
out.SvgCss = make("SvgCss");
|
|
1700
|
+
out.SvgCssUri = make("SvgCssUri");
|
|
1701
|
+
out.default = out.Svg;
|
|
1702
|
+
return out;
|
|
1703
|
+
}
|
|
1704
|
+
} }
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
//#endregion
|
|
1708
|
+
//#region src/presets/webview.ts
|
|
1709
|
+
function webview() {
|
|
1710
|
+
return {
|
|
1711
|
+
name: "webview",
|
|
1712
|
+
modules: { "react-native-webview": {
|
|
1713
|
+
exports: ["WebView"],
|
|
1714
|
+
factory: () => {
|
|
1715
|
+
const WebView = React.forwardRef((props, ref) => {
|
|
1716
|
+
React.useImperativeHandle(ref, () => ({
|
|
1717
|
+
reload: () => {},
|
|
1718
|
+
stopLoading: () => {},
|
|
1719
|
+
goBack: () => {},
|
|
1720
|
+
goForward: () => {},
|
|
1721
|
+
injectJavaScript: () => {},
|
|
1722
|
+
postMessage: () => {},
|
|
1723
|
+
clearCache: () => {}
|
|
1724
|
+
}));
|
|
1725
|
+
return React.createElement("WebView", props, props.children);
|
|
1726
|
+
});
|
|
1727
|
+
WebView.displayName = "WebView";
|
|
1728
|
+
return {
|
|
1729
|
+
__esModule: true,
|
|
1730
|
+
default: WebView,
|
|
1731
|
+
WebView
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
} }
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
//#endregion
|
|
1097
1738
|
//#region src/presets/index.ts
|
|
1098
1739
|
var presets_exports = /* @__PURE__ */ __exportAll({
|
|
1099
1740
|
asyncStorage: () => asyncStorage,
|
|
1741
|
+
deviceInfo: () => deviceInfo,
|
|
1100
1742
|
expo: () => expo,
|
|
1101
1743
|
gestureHandler: () => gestureHandler,
|
|
1744
|
+
mmkv: () => mmkv,
|
|
1102
1745
|
navigation: () => navigation,
|
|
1103
1746
|
reanimated: () => reanimated,
|
|
1104
1747
|
safeAreaContext: () => safeAreaContext,
|
|
1105
|
-
screens: () => screens
|
|
1748
|
+
screens: () => screens,
|
|
1749
|
+
svg: () => svg,
|
|
1750
|
+
webview: () => webview
|
|
1106
1751
|
});
|
|
1107
1752
|
//#endregion
|
|
1108
|
-
export {
|
|
1753
|
+
export { deviceInfo as a, asyncStorage as c, gestureHandler as d, createPressableMock as f, mmkv as i, navigation as l, reanimated as m, webview as n, expo as o, buildPressableHostProps as p, svg as r, screens as s, presets_exports as t, safeAreaContext as u };
|