vitest-native 0.2.0 → 0.3.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 +20 -0
- package/README.md +31 -1
- 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.cjs +58 -28
- package/dist/index.mjs +57 -28
- package/dist/{preset-map-D224CC5w.mjs → preset-map-BTpoNH3G.mjs} +1 -0
- package/dist/{preset-map-Bt4dXkZO.cjs → preset-map-DxU6UgYS.cjs} +1 -0
- package/dist/{presets-D4jrt194.cjs → presets-B-spxZz7.cjs} +431 -75
- package/dist/{presets-C9tAPD15.mjs → presets-DvrcfEPz.mjs} +431 -75
- package/dist/presets.cjs +1 -1
- package/dist/presets.mjs +1 -1
- package/dist/setup.cjs +719 -85
- package/dist/setup.mjs +719 -85
- package/package.json +4 -1
|
@@ -44,6 +44,10 @@ function reanimated() {
|
|
|
44
44
|
"useDerivedValue",
|
|
45
45
|
"useAnimatedScrollHandler",
|
|
46
46
|
"useAnimatedGestureHandler",
|
|
47
|
+
"useAnimatedReaction",
|
|
48
|
+
"useAnimatedKeyboard",
|
|
49
|
+
"useReducedMotion",
|
|
50
|
+
"useFrameCallback",
|
|
47
51
|
"withTiming",
|
|
48
52
|
"withSpring",
|
|
49
53
|
"withDecay",
|
|
@@ -56,15 +60,69 @@ function reanimated() {
|
|
|
56
60
|
"Easing",
|
|
57
61
|
"FadeIn",
|
|
58
62
|
"FadeOut",
|
|
63
|
+
"FadeInDown",
|
|
64
|
+
"FadeInUp",
|
|
65
|
+
"FadeInLeft",
|
|
66
|
+
"FadeInRight",
|
|
67
|
+
"FadeOutDown",
|
|
68
|
+
"FadeOutUp",
|
|
69
|
+
"FadeOutLeft",
|
|
70
|
+
"FadeOutRight",
|
|
59
71
|
"SlideInRight",
|
|
72
|
+
"SlideInLeft",
|
|
73
|
+
"SlideInUp",
|
|
74
|
+
"SlideInDown",
|
|
75
|
+
"SlideOutRight",
|
|
60
76
|
"SlideOutLeft",
|
|
77
|
+
"SlideOutUp",
|
|
78
|
+
"SlideOutDown",
|
|
79
|
+
"ZoomIn",
|
|
80
|
+
"ZoomOut",
|
|
81
|
+
"BounceIn",
|
|
82
|
+
"BounceOut",
|
|
83
|
+
"BounceInDown",
|
|
84
|
+
"BounceInUp",
|
|
85
|
+
"BounceInLeft",
|
|
86
|
+
"BounceInRight",
|
|
87
|
+
"FlipInEasyX",
|
|
88
|
+
"FlipInEasyY",
|
|
89
|
+
"FlipOutEasyX",
|
|
90
|
+
"FlipOutEasyY",
|
|
91
|
+
"LightSpeedInLeft",
|
|
92
|
+
"LightSpeedInRight",
|
|
93
|
+
"LightSpeedOutLeft",
|
|
94
|
+
"LightSpeedOutRight",
|
|
95
|
+
"PinwheelIn",
|
|
96
|
+
"PinwheelOut",
|
|
97
|
+
"StretchInX",
|
|
98
|
+
"StretchInY",
|
|
99
|
+
"StretchOutX",
|
|
100
|
+
"StretchOutY",
|
|
101
|
+
"RotateInDownLeft",
|
|
102
|
+
"RotateInDownRight",
|
|
103
|
+
"RotateInUpLeft",
|
|
104
|
+
"RotateInUpRight",
|
|
105
|
+
"RotateOutDownLeft",
|
|
106
|
+
"RotateOutDownRight",
|
|
107
|
+
"RotateOutUpLeft",
|
|
108
|
+
"RotateOutUpRight",
|
|
61
109
|
"Layout",
|
|
110
|
+
"LinearTransition",
|
|
111
|
+
"SequencedTransition",
|
|
112
|
+
"FadingTransition",
|
|
113
|
+
"JumpingTransition",
|
|
114
|
+
"CurvedTransition",
|
|
115
|
+
"EntryExitTransition",
|
|
62
116
|
"interpolate",
|
|
63
117
|
"Extrapolation",
|
|
64
118
|
"useAnimatedRef",
|
|
65
119
|
"measure",
|
|
66
120
|
"scrollTo",
|
|
67
|
-
"cancelAnimation"
|
|
121
|
+
"cancelAnimation",
|
|
122
|
+
"makeMutable",
|
|
123
|
+
"SharedTransition",
|
|
124
|
+
"ReduceMotion",
|
|
125
|
+
"KeyboardState"
|
|
68
126
|
],
|
|
69
127
|
factory: () => {
|
|
70
128
|
function createSharedValue(init) {
|
|
@@ -109,6 +167,23 @@ function reanimated() {
|
|
|
109
167
|
function useAnimatedGestureHandler(_handler) {
|
|
110
168
|
return vitest.vi.fn();
|
|
111
169
|
}
|
|
170
|
+
function useAnimatedReaction(_prepare, _react, _deps) {}
|
|
171
|
+
function useAnimatedKeyboard() {
|
|
172
|
+
return {
|
|
173
|
+
state: createSharedValue(0),
|
|
174
|
+
height: createSharedValue(0)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function useReducedMotion() {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
function useFrameCallback(_callback, _autostart) {
|
|
181
|
+
return {
|
|
182
|
+
setActive: vitest.vi.fn(),
|
|
183
|
+
isActive: false,
|
|
184
|
+
callbackId: 0
|
|
185
|
+
};
|
|
186
|
+
}
|
|
112
187
|
function withTiming(toValue, _config, callback) {
|
|
113
188
|
callback?.({
|
|
114
189
|
finished: true,
|
|
@@ -155,6 +230,24 @@ function reanimated() {
|
|
|
155
230
|
Animated.displayName = `Animated(${component.displayName || component.name || "Component"})`;
|
|
156
231
|
return Animated;
|
|
157
232
|
}
|
|
233
|
+
function createLayoutAnim() {
|
|
234
|
+
const obj = {};
|
|
235
|
+
obj.duration = vitest.vi.fn().mockReturnValue(obj);
|
|
236
|
+
obj.delay = vitest.vi.fn().mockReturnValue(obj);
|
|
237
|
+
obj.easing = vitest.vi.fn().mockReturnValue(obj);
|
|
238
|
+
obj.damping = vitest.vi.fn().mockReturnValue(obj);
|
|
239
|
+
obj.stiffness = vitest.vi.fn().mockReturnValue(obj);
|
|
240
|
+
obj.mass = vitest.vi.fn().mockReturnValue(obj);
|
|
241
|
+
obj.overshootClamping = vitest.vi.fn().mockReturnValue(obj);
|
|
242
|
+
obj.restDisplacementThreshold = vitest.vi.fn().mockReturnValue(obj);
|
|
243
|
+
obj.restSpeedThreshold = vitest.vi.fn().mockReturnValue(obj);
|
|
244
|
+
obj.springify = vitest.vi.fn().mockReturnValue(obj);
|
|
245
|
+
obj.withCallback = vitest.vi.fn().mockReturnValue(obj);
|
|
246
|
+
obj.withInitialValues = vitest.vi.fn().mockReturnValue(obj);
|
|
247
|
+
obj.randomDelay = vitest.vi.fn().mockReturnValue(obj);
|
|
248
|
+
obj.build = vitest.vi.fn();
|
|
249
|
+
return obj;
|
|
250
|
+
}
|
|
158
251
|
return {
|
|
159
252
|
default: { createAnimatedComponent },
|
|
160
253
|
useSharedValue,
|
|
@@ -163,6 +256,10 @@ function reanimated() {
|
|
|
163
256
|
useDerivedValue,
|
|
164
257
|
useAnimatedScrollHandler,
|
|
165
258
|
useAnimatedGestureHandler,
|
|
259
|
+
useAnimatedReaction,
|
|
260
|
+
useAnimatedKeyboard,
|
|
261
|
+
useReducedMotion,
|
|
262
|
+
useFrameCallback,
|
|
166
263
|
withTiming,
|
|
167
264
|
withSpring,
|
|
168
265
|
withDecay,
|
|
@@ -182,28 +279,61 @@ function reanimated() {
|
|
|
182
279
|
out: vitest.vi.fn((fn) => fn),
|
|
183
280
|
inOut: vitest.vi.fn((fn) => fn)
|
|
184
281
|
},
|
|
185
|
-
FadeIn:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
SlideInRight:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
282
|
+
FadeIn: createLayoutAnim(),
|
|
283
|
+
FadeOut: createLayoutAnim(),
|
|
284
|
+
FadeInDown: createLayoutAnim(),
|
|
285
|
+
FadeInUp: createLayoutAnim(),
|
|
286
|
+
FadeInLeft: createLayoutAnim(),
|
|
287
|
+
FadeInRight: createLayoutAnim(),
|
|
288
|
+
FadeOutDown: createLayoutAnim(),
|
|
289
|
+
FadeOutUp: createLayoutAnim(),
|
|
290
|
+
FadeOutLeft: createLayoutAnim(),
|
|
291
|
+
FadeOutRight: createLayoutAnim(),
|
|
292
|
+
SlideInRight: createLayoutAnim(),
|
|
293
|
+
SlideInLeft: createLayoutAnim(),
|
|
294
|
+
SlideInUp: createLayoutAnim(),
|
|
295
|
+
SlideInDown: createLayoutAnim(),
|
|
296
|
+
SlideOutRight: createLayoutAnim(),
|
|
297
|
+
SlideOutLeft: createLayoutAnim(),
|
|
298
|
+
SlideOutUp: createLayoutAnim(),
|
|
299
|
+
SlideOutDown: createLayoutAnim(),
|
|
300
|
+
ZoomIn: createLayoutAnim(),
|
|
301
|
+
ZoomOut: createLayoutAnim(),
|
|
302
|
+
BounceIn: createLayoutAnim(),
|
|
303
|
+
BounceOut: createLayoutAnim(),
|
|
304
|
+
BounceInDown: createLayoutAnim(),
|
|
305
|
+
BounceInUp: createLayoutAnim(),
|
|
306
|
+
BounceInLeft: createLayoutAnim(),
|
|
307
|
+
BounceInRight: createLayoutAnim(),
|
|
308
|
+
FlipInEasyX: createLayoutAnim(),
|
|
309
|
+
FlipInEasyY: createLayoutAnim(),
|
|
310
|
+
FlipOutEasyX: createLayoutAnim(),
|
|
311
|
+
FlipOutEasyY: createLayoutAnim(),
|
|
312
|
+
LightSpeedInLeft: createLayoutAnim(),
|
|
313
|
+
LightSpeedInRight: createLayoutAnim(),
|
|
314
|
+
LightSpeedOutLeft: createLayoutAnim(),
|
|
315
|
+
LightSpeedOutRight: createLayoutAnim(),
|
|
316
|
+
PinwheelIn: createLayoutAnim(),
|
|
317
|
+
PinwheelOut: createLayoutAnim(),
|
|
318
|
+
StretchInX: createLayoutAnim(),
|
|
319
|
+
StretchInY: createLayoutAnim(),
|
|
320
|
+
StretchOutX: createLayoutAnim(),
|
|
321
|
+
StretchOutY: createLayoutAnim(),
|
|
322
|
+
RotateInDownLeft: createLayoutAnim(),
|
|
323
|
+
RotateInDownRight: createLayoutAnim(),
|
|
324
|
+
RotateInUpLeft: createLayoutAnim(),
|
|
325
|
+
RotateInUpRight: createLayoutAnim(),
|
|
326
|
+
RotateOutDownLeft: createLayoutAnim(),
|
|
327
|
+
RotateOutDownRight: createLayoutAnim(),
|
|
328
|
+
RotateOutUpLeft: createLayoutAnim(),
|
|
329
|
+
RotateOutUpRight: createLayoutAnim(),
|
|
330
|
+
Layout: createLayoutAnim(),
|
|
331
|
+
LinearTransition: createLayoutAnim(),
|
|
332
|
+
SequencedTransition: createLayoutAnim(),
|
|
333
|
+
FadingTransition: createLayoutAnim(),
|
|
334
|
+
JumpingTransition: createLayoutAnim(),
|
|
335
|
+
CurvedTransition: createLayoutAnim(),
|
|
336
|
+
EntryExitTransition: createLayoutAnim(),
|
|
207
337
|
interpolate: vitest.vi.fn((_value, input, output) => output[0]),
|
|
208
338
|
Extrapolation: {
|
|
209
339
|
CLAMP: "clamp",
|
|
@@ -220,7 +350,26 @@ function reanimated() {
|
|
|
220
350
|
pageY: 0
|
|
221
351
|
})),
|
|
222
352
|
scrollTo: vitest.vi.fn(),
|
|
223
|
-
cancelAnimation: vitest.vi.fn()
|
|
353
|
+
cancelAnimation: vitest.vi.fn(),
|
|
354
|
+
makeMutable: vitest.vi.fn((init) => createSharedValue(init)),
|
|
355
|
+
SharedTransition: {
|
|
356
|
+
duration: vitest.vi.fn().mockReturnThis(),
|
|
357
|
+
custom: vitest.vi.fn().mockReturnThis(),
|
|
358
|
+
progressAnimation: vitest.vi.fn().mockReturnThis(),
|
|
359
|
+
defaultTransitionType: vitest.vi.fn().mockReturnThis()
|
|
360
|
+
},
|
|
361
|
+
ReduceMotion: {
|
|
362
|
+
System: "system",
|
|
363
|
+
Always: "always",
|
|
364
|
+
Never: "never"
|
|
365
|
+
},
|
|
366
|
+
KeyboardState: {
|
|
367
|
+
UNKNOWN: 0,
|
|
368
|
+
OPENING: 1,
|
|
369
|
+
OPEN: 2,
|
|
370
|
+
CLOSING: 3,
|
|
371
|
+
CLOSED: 4
|
|
372
|
+
}
|
|
224
373
|
};
|
|
225
374
|
}
|
|
226
375
|
} }
|
|
@@ -399,19 +548,25 @@ function safeAreaContext() {
|
|
|
399
548
|
"Metrics"
|
|
400
549
|
],
|
|
401
550
|
factory: () => {
|
|
551
|
+
const defaultInsets = {
|
|
552
|
+
top: 47,
|
|
553
|
+
right: 0,
|
|
554
|
+
bottom: 34,
|
|
555
|
+
left: 0
|
|
556
|
+
};
|
|
557
|
+
const defaultFrame = {
|
|
558
|
+
x: 0,
|
|
559
|
+
y: 0,
|
|
560
|
+
width: 390,
|
|
561
|
+
height: 844
|
|
562
|
+
};
|
|
563
|
+
const state = {
|
|
564
|
+
insets: { ...defaultInsets },
|
|
565
|
+
frame: { ...defaultFrame }
|
|
566
|
+
};
|
|
402
567
|
const initialMetrics = {
|
|
403
|
-
frame:
|
|
404
|
-
|
|
405
|
-
y: 0,
|
|
406
|
-
width: 390,
|
|
407
|
-
height: 844
|
|
408
|
-
},
|
|
409
|
-
insets: {
|
|
410
|
-
top: 47,
|
|
411
|
-
right: 0,
|
|
412
|
-
bottom: 34,
|
|
413
|
-
left: 0
|
|
414
|
-
}
|
|
568
|
+
frame: state.frame,
|
|
569
|
+
insets: state.insets
|
|
415
570
|
};
|
|
416
571
|
const SafeAreaProvider = react.default.forwardRef((props, ref) => react.default.createElement("SafeAreaProvider", {
|
|
417
572
|
...props,
|
|
@@ -423,19 +578,19 @@ function safeAreaContext() {
|
|
|
423
578
|
ref
|
|
424
579
|
}, props.children));
|
|
425
580
|
SafeAreaView.displayName = "SafeAreaView";
|
|
426
|
-
const SafeAreaInsetsContext = react.default.createContext(
|
|
427
|
-
const SafeAreaFrameContext = react.default.createContext(
|
|
581
|
+
const SafeAreaInsetsContext = react.default.createContext(state.insets);
|
|
582
|
+
const SafeAreaFrameContext = react.default.createContext(state.frame);
|
|
428
583
|
function useSafeAreaInsets() {
|
|
429
|
-
return
|
|
584
|
+
return state.insets;
|
|
430
585
|
}
|
|
431
586
|
function useSafeAreaFrame() {
|
|
432
|
-
return
|
|
587
|
+
return state.frame;
|
|
433
588
|
}
|
|
434
589
|
function withSafeAreaInsets(WrappedComponent) {
|
|
435
590
|
const WithSafeAreaInsets = react.default.forwardRef((props, ref) => react.default.createElement(WrappedComponent, {
|
|
436
591
|
...props,
|
|
437
592
|
ref,
|
|
438
|
-
insets:
|
|
593
|
+
insets: state.insets
|
|
439
594
|
}));
|
|
440
595
|
WithSafeAreaInsets.displayName = `withSafeAreaInsets(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
|
|
441
596
|
return WithSafeAreaInsets;
|
|
@@ -453,10 +608,17 @@ function safeAreaContext() {
|
|
|
453
608
|
useSafeAreaFrame,
|
|
454
609
|
withSafeAreaInsets,
|
|
455
610
|
initialWindowMetrics: initialMetrics,
|
|
456
|
-
initialWindowSafeAreaInsets:
|
|
611
|
+
initialWindowSafeAreaInsets: state.insets,
|
|
457
612
|
EdgeInsets: vitest.vi.fn(),
|
|
458
613
|
Rect: vitest.vi.fn(),
|
|
459
|
-
Metrics: vitest.vi.fn()
|
|
614
|
+
Metrics: vitest.vi.fn(),
|
|
615
|
+
_setInsets: (insets) => {
|
|
616
|
+
Object.assign(state.insets, insets);
|
|
617
|
+
},
|
|
618
|
+
_reset: () => {
|
|
619
|
+
Object.assign(state.insets, defaultInsets);
|
|
620
|
+
Object.assign(state.frame, defaultFrame);
|
|
621
|
+
}
|
|
460
622
|
};
|
|
461
623
|
}
|
|
462
624
|
} }
|
|
@@ -464,27 +626,123 @@ function safeAreaContext() {
|
|
|
464
626
|
}
|
|
465
627
|
//#endregion
|
|
466
628
|
//#region src/presets/navigation.ts
|
|
629
|
+
/** Builds a minimal navigation prop matching useNavigation()'s shape. */
|
|
630
|
+
function createMockNavigation() {
|
|
631
|
+
return {
|
|
632
|
+
navigate: vitest.vi.fn(),
|
|
633
|
+
goBack: vitest.vi.fn(),
|
|
634
|
+
reset: vitest.vi.fn(),
|
|
635
|
+
setParams: vitest.vi.fn(),
|
|
636
|
+
setOptions: vitest.vi.fn(),
|
|
637
|
+
dispatch: vitest.vi.fn(),
|
|
638
|
+
canGoBack: vitest.vi.fn(() => false),
|
|
639
|
+
getParent: vitest.vi.fn(() => void 0),
|
|
640
|
+
getState: vitest.vi.fn(() => ({
|
|
641
|
+
index: 0,
|
|
642
|
+
key: "root",
|
|
643
|
+
routeNames: [],
|
|
644
|
+
routes: [],
|
|
645
|
+
type: "stack",
|
|
646
|
+
stale: false
|
|
647
|
+
})),
|
|
648
|
+
isFocused: vitest.vi.fn(() => true),
|
|
649
|
+
addListener: vitest.vi.fn(() => vitest.vi.fn()),
|
|
650
|
+
removeListener: vitest.vi.fn(),
|
|
651
|
+
getId: vitest.vi.fn(() => void 0)
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Creates a Screen component mock that handles all three React Navigation patterns:
|
|
656
|
+
* 1. <Screen component={Comp} /> — renders Comp with route & navigation props
|
|
657
|
+
* 2. <Screen>{(props) => <Comp />}</Screen> — calls render function
|
|
658
|
+
* 3. <Screen><Something /></Screen> — passes children through
|
|
659
|
+
*
|
|
660
|
+
* Accepts NavigationContext and NavigationRouteContext so that hooks like
|
|
661
|
+
* useNavigation() and useRoute() inside the screen component return values
|
|
662
|
+
* consistent with the route/navigation props passed to the component.
|
|
663
|
+
*/
|
|
664
|
+
function createMockScreen(NavContext, RouteContext) {
|
|
665
|
+
const Screen = react.default.forwardRef(({ component: Component, children, ...rest }, ref) => {
|
|
666
|
+
const route = {
|
|
667
|
+
key: rest.name ?? "",
|
|
668
|
+
name: rest.name ?? "",
|
|
669
|
+
params: rest.initialParams
|
|
670
|
+
};
|
|
671
|
+
const nav = createMockNavigation();
|
|
672
|
+
const content = Component ? react.default.createElement(Component, {
|
|
673
|
+
route,
|
|
674
|
+
navigation: nav
|
|
675
|
+
}) : typeof children === "function" ? children({
|
|
676
|
+
route,
|
|
677
|
+
navigation: nav
|
|
678
|
+
}) : children;
|
|
679
|
+
return react.default.createElement("Screen", {
|
|
680
|
+
...rest,
|
|
681
|
+
ref
|
|
682
|
+
}, react.default.createElement(NavContext.Provider, { value: nav }, react.default.createElement(RouteContext.Provider, { value: route }, content)));
|
|
683
|
+
});
|
|
684
|
+
Screen.displayName = "Screen";
|
|
685
|
+
return Screen;
|
|
686
|
+
}
|
|
467
687
|
function navigation() {
|
|
688
|
+
const NavigationContext = react.default.createContext(null);
|
|
689
|
+
const NavigationRouteContext = react.default.createContext(null);
|
|
690
|
+
const NavigationContainerRefContext = react.default.createContext(null);
|
|
691
|
+
const NavigationHelpersContext = react.default.createContext(null);
|
|
692
|
+
const CurrentRenderContext = react.default.createContext(void 0);
|
|
693
|
+
const ThemeContext = react.default.createContext({
|
|
694
|
+
dark: false,
|
|
695
|
+
colors: {}
|
|
696
|
+
});
|
|
697
|
+
const PreventRemoveContext = react.default.createContext(null);
|
|
698
|
+
const Screen = createMockScreen(NavigationContext, NavigationRouteContext);
|
|
468
699
|
return {
|
|
469
700
|
name: "navigation",
|
|
470
701
|
modules: {
|
|
471
702
|
"@react-navigation/native": {
|
|
472
703
|
exports: [
|
|
473
704
|
"NavigationContainer",
|
|
705
|
+
"useLinkTo",
|
|
706
|
+
"Link",
|
|
474
707
|
"useNavigation",
|
|
475
708
|
"useRoute",
|
|
476
709
|
"useFocusEffect",
|
|
477
710
|
"useIsFocused",
|
|
478
711
|
"useNavigationState",
|
|
712
|
+
"useScrollToTop",
|
|
713
|
+
"useNavigationContainerRef",
|
|
479
714
|
"createNavigationContainerRef",
|
|
715
|
+
"createNavigatorFactory",
|
|
716
|
+
"useNavigationBuilder",
|
|
480
717
|
"NavigationContext",
|
|
481
718
|
"NavigationRouteContext",
|
|
719
|
+
"NavigationContainerRefContext",
|
|
720
|
+
"NavigationHelpersContext",
|
|
721
|
+
"CurrentRenderContext",
|
|
722
|
+
"ThemeContext",
|
|
723
|
+
"ThemeProvider",
|
|
724
|
+
"useTheme",
|
|
725
|
+
"NavigationIndependentTree",
|
|
726
|
+
"useNavigationIndependentTree",
|
|
727
|
+
"PreventRemoveContext",
|
|
728
|
+
"PreventRemoveProvider",
|
|
729
|
+
"usePreventRemove",
|
|
730
|
+
"usePreventRemoveContext",
|
|
482
731
|
"CommonActions",
|
|
483
732
|
"StackActions",
|
|
484
733
|
"TabActions",
|
|
485
734
|
"DrawerActions",
|
|
486
|
-
"
|
|
487
|
-
"
|
|
735
|
+
"findFocusedRoute",
|
|
736
|
+
"getFocusedRouteNameFromRoute",
|
|
737
|
+
"getActionFromState",
|
|
738
|
+
"getPathFromState",
|
|
739
|
+
"getStateFromPath",
|
|
740
|
+
"useStateForPath",
|
|
741
|
+
"validatePathConfig",
|
|
742
|
+
"BaseNavigationContainer",
|
|
743
|
+
"createComponentForStaticNavigation",
|
|
744
|
+
"createPathConfigForStaticNavigation",
|
|
745
|
+
"BaseRouter"
|
|
488
746
|
],
|
|
489
747
|
factory: () => {
|
|
490
748
|
const NavigationContainer = react.default.forwardRef((props, ref) => react.default.createElement("NavigationContainer", {
|
|
@@ -508,29 +766,39 @@ function navigation() {
|
|
|
508
766
|
type: "stack",
|
|
509
767
|
stale: false
|
|
510
768
|
}));
|
|
769
|
+
const defaultNavigation = {
|
|
770
|
+
navigate,
|
|
771
|
+
goBack,
|
|
772
|
+
reset,
|
|
773
|
+
setParams,
|
|
774
|
+
setOptions,
|
|
775
|
+
dispatch,
|
|
776
|
+
canGoBack,
|
|
777
|
+
getParent,
|
|
778
|
+
getState,
|
|
779
|
+
isFocused: vitest.vi.fn(() => true),
|
|
780
|
+
addListener: vitest.vi.fn(() => vitest.vi.fn()),
|
|
781
|
+
removeListener: vitest.vi.fn(),
|
|
782
|
+
getId: vitest.vi.fn(() => void 0)
|
|
783
|
+
};
|
|
784
|
+
const defaultRoute = {
|
|
785
|
+
key: "test-route-key",
|
|
786
|
+
name: "TestScreen",
|
|
787
|
+
params: {}
|
|
788
|
+
};
|
|
511
789
|
function useNavigation() {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
setOptions,
|
|
518
|
-
dispatch,
|
|
519
|
-
canGoBack,
|
|
520
|
-
getParent,
|
|
521
|
-
getState,
|
|
522
|
-
isFocused: vitest.vi.fn(() => true),
|
|
523
|
-
addListener: vitest.vi.fn(() => vitest.vi.fn()),
|
|
524
|
-
removeListener: vitest.vi.fn(),
|
|
525
|
-
getId: vitest.vi.fn(() => void 0)
|
|
526
|
-
};
|
|
790
|
+
try {
|
|
791
|
+
const ctx = react.default.useContext(NavigationContext);
|
|
792
|
+
if (ctx) return ctx;
|
|
793
|
+
} catch {}
|
|
794
|
+
return defaultNavigation;
|
|
527
795
|
}
|
|
528
796
|
function useRoute() {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
797
|
+
try {
|
|
798
|
+
const ctx = react.default.useContext(NavigationRouteContext);
|
|
799
|
+
if (ctx) return ctx;
|
|
800
|
+
} catch {}
|
|
801
|
+
return defaultRoute;
|
|
534
802
|
}
|
|
535
803
|
function useFocusEffect(callback) {
|
|
536
804
|
react.default.useEffect(callback, []);
|
|
@@ -560,8 +828,40 @@ function navigation() {
|
|
|
560
828
|
addListener: vitest.vi.fn(() => vitest.vi.fn())
|
|
561
829
|
};
|
|
562
830
|
}
|
|
563
|
-
|
|
564
|
-
|
|
831
|
+
function useNavigationContainerRef() {
|
|
832
|
+
return createNavigationContainerRef();
|
|
833
|
+
}
|
|
834
|
+
const defaultTheme = {
|
|
835
|
+
dark: false,
|
|
836
|
+
colors: {
|
|
837
|
+
primary: "rgb(0, 122, 255)",
|
|
838
|
+
background: "rgb(242, 242, 242)",
|
|
839
|
+
card: "rgb(255, 255, 255)",
|
|
840
|
+
text: "rgb(28, 28, 30)",
|
|
841
|
+
border: "rgb(216, 216, 216)",
|
|
842
|
+
notification: "rgb(255, 59, 48)"
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
function ThemeProvider({ value, children }) {
|
|
846
|
+
return react.default.createElement(ThemeContext.Provider, { value: value ?? defaultTheme }, children);
|
|
847
|
+
}
|
|
848
|
+
function useTheme() {
|
|
849
|
+
return defaultTheme;
|
|
850
|
+
}
|
|
851
|
+
function NavigationIndependentTree({ children }) {
|
|
852
|
+
return children;
|
|
853
|
+
}
|
|
854
|
+
function useNavigationIndependentTree() {
|
|
855
|
+
return true;
|
|
856
|
+
}
|
|
857
|
+
function PreventRemoveProvider({ children }) {
|
|
858
|
+
return children;
|
|
859
|
+
}
|
|
860
|
+
const BaseNavigationContainer = react.default.forwardRef((props, ref) => react.default.createElement("BaseNavigationContainer", {
|
|
861
|
+
...props,
|
|
862
|
+
ref
|
|
863
|
+
}, props.children));
|
|
864
|
+
BaseNavigationContainer.displayName = "BaseNavigationContainer";
|
|
565
865
|
return {
|
|
566
866
|
default: { NavigationContainer },
|
|
567
867
|
NavigationContainer,
|
|
@@ -570,9 +870,29 @@ function navigation() {
|
|
|
570
870
|
useFocusEffect,
|
|
571
871
|
useIsFocused,
|
|
572
872
|
useNavigationState,
|
|
873
|
+
useNavigationContainerRef,
|
|
573
874
|
createNavigationContainerRef,
|
|
875
|
+
createNavigatorFactory: vitest.vi.fn(() => vitest.vi.fn()),
|
|
876
|
+
useNavigationBuilder: vitest.vi.fn(() => ({
|
|
877
|
+
state: getState(),
|
|
878
|
+
navigation: useNavigation(),
|
|
879
|
+
descriptors: {},
|
|
880
|
+
NavigationContent: ({ children }) => children
|
|
881
|
+
})),
|
|
574
882
|
NavigationContext,
|
|
575
883
|
NavigationRouteContext,
|
|
884
|
+
NavigationContainerRefContext,
|
|
885
|
+
NavigationHelpersContext,
|
|
886
|
+
CurrentRenderContext,
|
|
887
|
+
ThemeContext,
|
|
888
|
+
ThemeProvider,
|
|
889
|
+
useTheme,
|
|
890
|
+
NavigationIndependentTree,
|
|
891
|
+
useNavigationIndependentTree,
|
|
892
|
+
PreventRemoveContext,
|
|
893
|
+
PreventRemoveProvider,
|
|
894
|
+
usePreventRemove: vitest.vi.fn(),
|
|
895
|
+
usePreventRemoveContext: vitest.vi.fn(() => null),
|
|
576
896
|
CommonActions: {
|
|
577
897
|
navigate: vitest.vi.fn(),
|
|
578
898
|
reset: vitest.vi.fn(),
|
|
@@ -592,6 +912,25 @@ function navigation() {
|
|
|
592
912
|
toggleDrawer: vitest.vi.fn(),
|
|
593
913
|
jumpTo: vitest.vi.fn()
|
|
594
914
|
},
|
|
915
|
+
findFocusedRoute: vitest.vi.fn((state) => state?.routes?.[state?.index ?? 0]),
|
|
916
|
+
getFocusedRouteNameFromRoute: vitest.vi.fn((route) => route?.state?.routes?.[route?.state?.index ?? 0]?.name),
|
|
917
|
+
getActionFromState: vitest.vi.fn(() => void 0),
|
|
918
|
+
getPathFromState: vitest.vi.fn(() => "/"),
|
|
919
|
+
getStateFromPath: vitest.vi.fn(() => void 0),
|
|
920
|
+
useStateForPath: vitest.vi.fn(() => void 0),
|
|
921
|
+
validatePathConfig: vitest.vi.fn(),
|
|
922
|
+
BaseNavigationContainer,
|
|
923
|
+
createComponentForStaticNavigation: vitest.vi.fn(() => () => null),
|
|
924
|
+
createPathConfigForStaticNavigation: vitest.vi.fn(() => ({})),
|
|
925
|
+
BaseRouter: {
|
|
926
|
+
getInitialState: vitest.vi.fn(() => getState()),
|
|
927
|
+
getRehydratedState: vitest.vi.fn((state) => state),
|
|
928
|
+
getStateForRouteNamesChange: vitest.vi.fn((state) => state),
|
|
929
|
+
getStateForRouteFocus: vitest.vi.fn((state) => state),
|
|
930
|
+
getStateForAction: vitest.vi.fn((state) => state),
|
|
931
|
+
shouldActionChangeFocus: vitest.vi.fn(() => false)
|
|
932
|
+
},
|
|
933
|
+
useScrollToTop: vitest.vi.fn(),
|
|
595
934
|
useLinkTo: vitest.vi.fn(() => vitest.vi.fn()),
|
|
596
935
|
Link: react.default.forwardRef((props, ref) => react.default.createElement("Link", {
|
|
597
936
|
...props,
|
|
@@ -609,10 +948,7 @@ function navigation() {
|
|
|
609
948
|
...props,
|
|
610
949
|
ref
|
|
611
950
|
}, props.children)),
|
|
612
|
-
Screen
|
|
613
|
-
...props,
|
|
614
|
-
ref
|
|
615
|
-
}, props.children)),
|
|
951
|
+
Screen,
|
|
616
952
|
Group: react.default.forwardRef((props, ref) => react.default.createElement("Group", {
|
|
617
953
|
...props,
|
|
618
954
|
ref
|
|
@@ -634,10 +970,29 @@ function navigation() {
|
|
|
634
970
|
...props,
|
|
635
971
|
ref
|
|
636
972
|
}, props.children)),
|
|
637
|
-
Screen
|
|
973
|
+
Screen,
|
|
974
|
+
Group: react.default.forwardRef((props, ref) => react.default.createElement("Group", {
|
|
975
|
+
...props,
|
|
976
|
+
ref
|
|
977
|
+
}, props.children))
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
return {
|
|
981
|
+
default: { createBottomTabNavigator },
|
|
982
|
+
createBottomTabNavigator
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
},
|
|
986
|
+
"@react-navigation/drawer": {
|
|
987
|
+
exports: ["createDrawerNavigator"],
|
|
988
|
+
factory: () => {
|
|
989
|
+
function createDrawerNavigator() {
|
|
990
|
+
return {
|
|
991
|
+
Navigator: react.default.forwardRef((props, ref) => react.default.createElement("DrawerNavigator", {
|
|
638
992
|
...props,
|
|
639
993
|
ref
|
|
640
994
|
}, props.children)),
|
|
995
|
+
Screen,
|
|
641
996
|
Group: react.default.forwardRef((props, ref) => react.default.createElement("Group", {
|
|
642
997
|
...props,
|
|
643
998
|
ref
|
|
@@ -645,8 +1000,8 @@ function navigation() {
|
|
|
645
1000
|
};
|
|
646
1001
|
}
|
|
647
1002
|
return {
|
|
648
|
-
default: {
|
|
649
|
-
|
|
1003
|
+
default: { createDrawerNavigator },
|
|
1004
|
+
createDrawerNavigator
|
|
650
1005
|
};
|
|
651
1006
|
}
|
|
652
1007
|
},
|
|
@@ -781,7 +1136,8 @@ function asyncStorage() {
|
|
|
781
1136
|
else store.set(key, value);
|
|
782
1137
|
});
|
|
783
1138
|
}),
|
|
784
|
-
flushGetRequests: vitest.vi.fn(() => {})
|
|
1139
|
+
flushGetRequests: vitest.vi.fn(() => {}),
|
|
1140
|
+
_resetStore: () => store.clear()
|
|
785
1141
|
};
|
|
786
1142
|
return {
|
|
787
1143
|
...exports,
|