react-native-lumen 1.0.1 → 1.1.1
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/README.md +770 -231
- package/lib/module/components/TourOverlay.js +45 -45
- package/lib/module/components/TourOverlay.js.map +1 -1
- package/lib/module/components/TourProvider.js +345 -80
- package/lib/module/components/TourProvider.js.map +1 -1
- package/lib/module/components/TourTooltip.js +113 -73
- package/lib/module/components/TourTooltip.js.map +1 -1
- package/lib/module/components/TourZone.js +229 -125
- package/lib/module/components/TourZone.js.map +1 -1
- package/lib/module/constants/defaults.js +43 -0
- package/lib/module/constants/defaults.js.map +1 -1
- package/lib/module/context/TourContext.js +5 -0
- package/lib/module/context/TourContext.js.map +1 -0
- package/lib/module/hooks/useTour.js +1 -1
- package/lib/module/hooks/useTour.js.map +1 -1
- package/lib/module/hooks/useTourScrollView.js +74 -0
- package/lib/module/hooks/useTourScrollView.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/storage.js +188 -0
- package/lib/module/utils/storage.js.map +1 -0
- package/lib/typescript/src/components/TourOverlay.d.ts.map +1 -1
- package/lib/typescript/src/components/TourProvider.d.ts +21 -4
- package/lib/typescript/src/components/TourProvider.d.ts.map +1 -1
- package/lib/typescript/src/components/TourTooltip.d.ts.map +1 -1
- package/lib/typescript/src/components/TourZone.d.ts +19 -1
- package/lib/typescript/src/components/TourZone.d.ts.map +1 -1
- package/lib/typescript/src/constants/defaults.d.ts +10 -0
- package/lib/typescript/src/constants/defaults.d.ts.map +1 -1
- package/lib/typescript/src/context/TourContext.d.ts +3 -0
- package/lib/typescript/src/context/TourContext.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useTourScrollView.d.ts +76 -0
- package/lib/typescript/src/hooks/useTourScrollView.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +316 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/storage.d.ts +51 -0
- package/lib/typescript/src/utils/storage.d.ts.map +1 -0
- package/package.json +169 -171
- package/src/components/TourOverlay.tsx +0 -153
- package/src/components/TourProvider.tsx +0 -361
- package/src/components/TourTooltip.tsx +0 -256
- package/src/components/TourZone.tsx +0 -371
- package/src/constants/animations.ts +0 -71
- package/src/constants/defaults.ts +0 -15
- package/src/hooks/useTour.ts +0 -10
- package/src/index.tsx +0 -8
- package/src/types/index.ts +0 -142
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
import type { WithSpringConfig, SharedValue } from 'react-native-reanimated';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { ViewStyle, TextStyle } from 'react-native';
|
|
4
|
+
/**
|
|
5
|
+
* Shape variants for the zone cutout.
|
|
6
|
+
*/
|
|
7
|
+
export type ZoneShape = 'rounded-rect' | 'circle' | 'pill';
|
|
8
|
+
/**
|
|
9
|
+
* Customization options for the zone appearance.
|
|
10
|
+
* Can be set globally via TourConfig or per-step via TourStep/TourZone.
|
|
11
|
+
*/
|
|
12
|
+
export interface ZoneStyle {
|
|
13
|
+
/**
|
|
14
|
+
* Uniform padding around the highlighted element.
|
|
15
|
+
* @default 0
|
|
16
|
+
*/
|
|
17
|
+
padding?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Top padding (overrides `padding` for top side).
|
|
20
|
+
*/
|
|
21
|
+
paddingTop?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Right padding (overrides `padding` for right side).
|
|
24
|
+
*/
|
|
25
|
+
paddingRight?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Bottom padding (overrides `padding` for bottom side).
|
|
28
|
+
*/
|
|
29
|
+
paddingBottom?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Left padding (overrides `padding` for left side).
|
|
32
|
+
*/
|
|
33
|
+
paddingLeft?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Border radius of the zone (for 'rounded-rect' shape).
|
|
36
|
+
* @default 10
|
|
37
|
+
*/
|
|
38
|
+
borderRadius?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Shape of the zone cutout.
|
|
41
|
+
* - 'rounded-rect': Standard rounded rectangle (default)
|
|
42
|
+
* - 'circle': Circular zone that encompasses the element
|
|
43
|
+
* - 'pill': Pill/capsule shape with fully rounded ends
|
|
44
|
+
* @default 'rounded-rect'
|
|
45
|
+
*/
|
|
46
|
+
shape?: ZoneShape;
|
|
47
|
+
/**
|
|
48
|
+
* Width of the border around the zone.
|
|
49
|
+
* Set to 0 to disable.
|
|
50
|
+
* @default 0
|
|
51
|
+
*/
|
|
52
|
+
borderWidth?: number;
|
|
53
|
+
/**
|
|
54
|
+
* Color of the border.
|
|
55
|
+
* @default 'transparent'
|
|
56
|
+
*/
|
|
57
|
+
borderColor?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Color of the outer glow effect. Applied only if `enableGlow` is true in `TourConfig`.
|
|
60
|
+
* @default '#FFFFFF'
|
|
61
|
+
*/
|
|
62
|
+
glowColor?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Blur radius for the glow effect. Applied only if `enableGlow` is true in `TourConfig`.
|
|
65
|
+
* @default 10
|
|
66
|
+
*/
|
|
67
|
+
glowRadius?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Spread radius for the glow effect. Applied only if `enableGlow` is true in `TourConfig`.
|
|
70
|
+
* @default 5
|
|
71
|
+
*/
|
|
72
|
+
glowSpread?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Horizontal offset for the glow effect.
|
|
75
|
+
* @default 0
|
|
76
|
+
*/
|
|
77
|
+
glowOffsetX?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Vertical offset for the glow effect.
|
|
80
|
+
* @default 0
|
|
81
|
+
*/
|
|
82
|
+
glowOffsetY?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Spring damping for zone animations (per-step override).
|
|
85
|
+
*/
|
|
86
|
+
springDamping?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Spring stiffness for zone animations (per-step override).
|
|
89
|
+
*/
|
|
90
|
+
springStiffness?: number;
|
|
91
|
+
}
|
|
3
92
|
export interface TourStep {
|
|
4
93
|
/**
|
|
5
94
|
* Unique key for this step.
|
|
@@ -26,6 +115,36 @@ export interface TourStep {
|
|
|
26
115
|
* If false, interactions are blocked (default behavior depends on global config).
|
|
27
116
|
*/
|
|
28
117
|
clickable?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* If true, prevents interaction with the underlying app for this specific step.
|
|
120
|
+
* Overrides the global preventInteraction setting from TourConfig.
|
|
121
|
+
* @default undefined (uses global setting)
|
|
122
|
+
*/
|
|
123
|
+
preventInteraction?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* If true, the skip button is hidden for this step (user must complete or press next).
|
|
126
|
+
* @default false
|
|
127
|
+
*/
|
|
128
|
+
required?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Controls whether the next/finish button is enabled.
|
|
131
|
+
* - `undefined`: No enforcement, next button always enabled (default).
|
|
132
|
+
* - `false`: Next button is disabled (grayed out, non-pressable).
|
|
133
|
+
* - `true`: Next button is enabled.
|
|
134
|
+
*
|
|
135
|
+
* Use this to gate progression until the user completes an action.
|
|
136
|
+
*/
|
|
137
|
+
completed?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Per-step zone style overrides.
|
|
140
|
+
* Merged with global zoneStyle from TourConfig.
|
|
141
|
+
*/
|
|
142
|
+
zoneStyle?: ZoneStyle;
|
|
143
|
+
/**
|
|
144
|
+
* Custom render function for this step's tooltip/card.
|
|
145
|
+
* Overrides the global renderCard from TourConfig.
|
|
146
|
+
*/
|
|
147
|
+
renderCustomCard?: (props: CardProps) => React.ReactNode;
|
|
29
148
|
}
|
|
30
149
|
export interface MeasureResult {
|
|
31
150
|
x: number;
|
|
@@ -34,12 +153,80 @@ export interface MeasureResult {
|
|
|
34
153
|
height: number;
|
|
35
154
|
}
|
|
36
155
|
export type StepMap = Record<string, TourStep>;
|
|
156
|
+
/**
|
|
157
|
+
* Steps order can be either:
|
|
158
|
+
* - A flat array of step keys (single-screen tour): `['bio', 'prompt', 'poll']`
|
|
159
|
+
* - A screen-grouped object (multi-screen tour): `{ ProfileSelf: ['bio', 'prompt'], HomeSwipe: ['filters'] }`
|
|
160
|
+
*/
|
|
161
|
+
export type StepsOrder = string[] | Record<string, string[]>;
|
|
37
162
|
export interface TourLabels {
|
|
38
163
|
next?: string;
|
|
39
164
|
previous?: string;
|
|
40
165
|
finish?: string;
|
|
41
166
|
skip?: string;
|
|
42
167
|
}
|
|
168
|
+
export interface TooltipStyles {
|
|
169
|
+
/**
|
|
170
|
+
* Background color of the tooltip
|
|
171
|
+
*/
|
|
172
|
+
backgroundColor?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Border radius of the tooltip (for shape customization)
|
|
175
|
+
*/
|
|
176
|
+
borderRadius?: number;
|
|
177
|
+
/**
|
|
178
|
+
* Text color for the title
|
|
179
|
+
*/
|
|
180
|
+
titleColor?: string;
|
|
181
|
+
/**
|
|
182
|
+
* Text color for the description
|
|
183
|
+
*/
|
|
184
|
+
descriptionColor?: string;
|
|
185
|
+
/**
|
|
186
|
+
* Background color for the primary button
|
|
187
|
+
*/
|
|
188
|
+
primaryButtonColor?: string;
|
|
189
|
+
/**
|
|
190
|
+
* Text color for the primary button
|
|
191
|
+
*/
|
|
192
|
+
primaryButtonTextColor?: string;
|
|
193
|
+
/**
|
|
194
|
+
* Border radius for the primary button
|
|
195
|
+
*/
|
|
196
|
+
primaryButtonBorderRadius?: number;
|
|
197
|
+
/**
|
|
198
|
+
* Text color for the skip button
|
|
199
|
+
*/
|
|
200
|
+
skipButtonTextColor?: string;
|
|
201
|
+
/**
|
|
202
|
+
* Custom style for the tooltip container
|
|
203
|
+
*/
|
|
204
|
+
containerStyle?: ViewStyle;
|
|
205
|
+
/**
|
|
206
|
+
* Custom style for the title text
|
|
207
|
+
*/
|
|
208
|
+
titleStyle?: TextStyle;
|
|
209
|
+
/**
|
|
210
|
+
* Custom style for the description text
|
|
211
|
+
*/
|
|
212
|
+
descriptionStyle?: TextStyle;
|
|
213
|
+
/**
|
|
214
|
+
* Custom style for the primary button
|
|
215
|
+
*/
|
|
216
|
+
primaryButtonStyle?: ViewStyle;
|
|
217
|
+
/**
|
|
218
|
+
* Custom style for the primary button text
|
|
219
|
+
*/
|
|
220
|
+
primaryButtonTextStyle?: TextStyle;
|
|
221
|
+
/**
|
|
222
|
+
* Custom style for the skip button
|
|
223
|
+
*/
|
|
224
|
+
skipButtonStyle?: ViewStyle;
|
|
225
|
+
/**
|
|
226
|
+
* Custom style for the skip button text
|
|
227
|
+
*/
|
|
228
|
+
skipButtonTextStyle?: TextStyle;
|
|
229
|
+
}
|
|
43
230
|
export interface CardProps {
|
|
44
231
|
step: TourStep;
|
|
45
232
|
currentStepIndex: number;
|
|
@@ -50,10 +237,70 @@ export interface CardProps {
|
|
|
50
237
|
isFirst: boolean;
|
|
51
238
|
isLast: boolean;
|
|
52
239
|
labels?: TourLabels;
|
|
240
|
+
/**
|
|
241
|
+
* Whether the step is required (skip button should be hidden).
|
|
242
|
+
*/
|
|
243
|
+
required?: boolean;
|
|
244
|
+
/**
|
|
245
|
+
* Whether the step's completion condition is met.
|
|
246
|
+
* - `undefined`: No enforcement, next button always enabled.
|
|
247
|
+
* - `false`: Next button should be disabled.
|
|
248
|
+
* - `true`: Next button should be enabled.
|
|
249
|
+
*/
|
|
250
|
+
completed?: boolean;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Storage adapter interface for tour persistence.
|
|
254
|
+
* Compatible with MMKV v4 and AsyncStorage APIs.
|
|
255
|
+
*/
|
|
256
|
+
export interface StorageAdapter {
|
|
257
|
+
getItem: (key: string) => Promise<string | null> | string | null;
|
|
258
|
+
setItem: (key: string, value: string) => Promise<void> | void;
|
|
259
|
+
removeItem: (key: string) => Promise<void> | void;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Configuration for tour progress persistence.
|
|
263
|
+
*/
|
|
264
|
+
export interface TourPersistenceConfig {
|
|
265
|
+
/**
|
|
266
|
+
* Enable persistence. When true, the library will auto-detect available storage
|
|
267
|
+
* (MMKV v4 or AsyncStorage) and save/restore tour progress.
|
|
268
|
+
* @default false
|
|
269
|
+
*/
|
|
270
|
+
enabled: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Unique identifier for this tour. Used as the storage key.
|
|
273
|
+
* Required when persistence is enabled.
|
|
274
|
+
* @example 'onboarding-tour' or 'feature-tour-v2'
|
|
275
|
+
*/
|
|
276
|
+
tourId: string;
|
|
277
|
+
/**
|
|
278
|
+
* Custom storage adapter. If not provided, the library will auto-detect
|
|
279
|
+
* MMKV v4 or AsyncStorage.
|
|
280
|
+
*/
|
|
281
|
+
storage?: StorageAdapter;
|
|
282
|
+
/**
|
|
283
|
+
* If true, automatically resume the tour from the saved step when start() is called
|
|
284
|
+
* without a specific step key.
|
|
285
|
+
* @default true
|
|
286
|
+
*/
|
|
287
|
+
autoResume?: boolean;
|
|
288
|
+
/**
|
|
289
|
+
* If true, clear saved progress when the tour is completed (reaches the last step).
|
|
290
|
+
* @default true
|
|
291
|
+
*/
|
|
292
|
+
clearOnComplete?: boolean;
|
|
293
|
+
/**
|
|
294
|
+
* Maximum age (in milliseconds) for saved progress. Progress older than this
|
|
295
|
+
* will be ignored and cleared.
|
|
296
|
+
* @default undefined (no expiration)
|
|
297
|
+
* @example 7 * 24 * 60 * 60 * 1000 // 7 days
|
|
298
|
+
*/
|
|
299
|
+
maxAge?: number;
|
|
53
300
|
}
|
|
54
301
|
export interface TourConfig {
|
|
55
302
|
/**
|
|
56
|
-
* Animation configuration for the
|
|
303
|
+
* Animation configuration for the zone movement.
|
|
57
304
|
*/
|
|
58
305
|
springConfig?: WithSpringConfig;
|
|
59
306
|
/**
|
|
@@ -73,14 +320,35 @@ export interface TourConfig {
|
|
|
73
320
|
* Backdrop opacity. Default 0.5
|
|
74
321
|
*/
|
|
75
322
|
backdropOpacity?: number;
|
|
323
|
+
/**
|
|
324
|
+
* Custom styles for the tooltip appearance
|
|
325
|
+
*/
|
|
326
|
+
tooltipStyles?: TooltipStyles;
|
|
327
|
+
/**
|
|
328
|
+
* Global zone style settings.
|
|
329
|
+
* Can be overridden per-step via TourStep.zoneStyle or TourZone props.
|
|
330
|
+
*/
|
|
331
|
+
zoneStyle?: ZoneStyle;
|
|
332
|
+
/**
|
|
333
|
+
* Persistence configuration for saving/restoring tour progress.
|
|
334
|
+
* Supports MMKV v4 and AsyncStorage out of the box.
|
|
335
|
+
*/
|
|
336
|
+
persistence?: TourPersistenceConfig;
|
|
337
|
+
/**
|
|
338
|
+
* Defines whether to apply a shadow/glow effect to the active tour zone highlight.
|
|
339
|
+
* @default false
|
|
340
|
+
*/
|
|
341
|
+
enableGlow?: boolean;
|
|
76
342
|
}
|
|
77
343
|
export interface TourContextType {
|
|
78
344
|
/**
|
|
79
345
|
* Starts the tour at the first step or a specific step (by key).
|
|
346
|
+
* If persistence is enabled and autoResume is true, will resume from saved progress.
|
|
80
347
|
*/
|
|
81
348
|
start: (stepKey?: string) => void;
|
|
82
349
|
/**
|
|
83
350
|
* Stops the tour and hides the overlay.
|
|
351
|
+
* Does NOT clear saved progress (use clearProgress for that).
|
|
84
352
|
*/
|
|
85
353
|
stop: () => void;
|
|
86
354
|
/**
|
|
@@ -117,9 +385,38 @@ export interface TourContextType {
|
|
|
117
385
|
*/
|
|
118
386
|
config?: TourConfig;
|
|
119
387
|
/**
|
|
388
|
+
* Animated ref to attach to your ScrollView for auto-scrolling.
|
|
389
|
+
* Use this ref directly on your ScrollView/Animated.ScrollView component.
|
|
390
|
+
* For custom scroll view components, use the useTourScrollView hook instead.
|
|
391
|
+
*/
|
|
392
|
+
scrollViewRef: React.RefObject<any>;
|
|
393
|
+
/**
|
|
394
|
+
* @deprecated Use scrollViewRef directly instead.
|
|
120
395
|
* Registers the main ScrollView ref for auto-scrolling
|
|
121
396
|
*/
|
|
122
397
|
setScrollViewRef: (ref: any) => void;
|
|
398
|
+
/**
|
|
399
|
+
* Clears any saved tour progress from storage.
|
|
400
|
+
* Only available when persistence is enabled.
|
|
401
|
+
*/
|
|
402
|
+
clearProgress: () => Promise<void>;
|
|
403
|
+
/**
|
|
404
|
+
* Whether there is saved progress available to resume.
|
|
405
|
+
* Only meaningful when persistence is enabled.
|
|
406
|
+
*/
|
|
407
|
+
hasSavedProgress: boolean;
|
|
408
|
+
/**
|
|
409
|
+
* The full ordered list of step keys for this tour.
|
|
410
|
+
* Derived from stepsOrder prop or step registration order.
|
|
411
|
+
* Includes all steps across all screens (for multi-screen tours).
|
|
412
|
+
*/
|
|
413
|
+
orderedStepKeys: string[];
|
|
414
|
+
/**
|
|
415
|
+
* Call this from the ScrollView's onMomentumScrollEnd event to signal that
|
|
416
|
+
* a programmatic scroll has finished. The library uses this to fire the
|
|
417
|
+
* final accurate measurement instead of relying on a fixed-duration timeout.
|
|
418
|
+
*/
|
|
419
|
+
triggerScrollEnd: () => void;
|
|
123
420
|
}
|
|
124
421
|
export interface InternalTourContextType extends TourContextType {
|
|
125
422
|
targetX: SharedValue<number>;
|
|
@@ -128,8 +425,26 @@ export interface InternalTourContextType extends TourContextType {
|
|
|
128
425
|
targetHeight: SharedValue<number>;
|
|
129
426
|
targetRadius: SharedValue<number>;
|
|
130
427
|
opacity: SharedValue<number>;
|
|
428
|
+
/** Border width for the zone glow ring */
|
|
429
|
+
zoneBorderWidth: SharedValue<number>;
|
|
131
430
|
containerRef: React.RefObject<any>;
|
|
132
431
|
scrollViewRef: React.RefObject<any>;
|
|
133
432
|
setScrollViewRef: (ref: any) => void;
|
|
433
|
+
/** Resolved zone style for the current step */
|
|
434
|
+
currentZoneStyle: ZoneStyle | null;
|
|
435
|
+
/**
|
|
436
|
+
* Registers a one-shot callback that fires once when triggerScrollEnd is called.
|
|
437
|
+
* TourZone uses this to know when the programmatic scroll animation has settled.
|
|
438
|
+
*/
|
|
439
|
+
registerScrollEndCallback: (cb: () => void) => void;
|
|
440
|
+
/** Clears any pending scroll-end callback (called on effect cleanup). */
|
|
441
|
+
unregisterScrollEndCallback: () => void;
|
|
442
|
+
/** Fires the registered scroll-end callback (if any) and clears it. */
|
|
443
|
+
triggerScrollEnd: () => void;
|
|
444
|
+
/**
|
|
445
|
+
* The configured backdrop opacity (0–1). TourZone reads this so it can
|
|
446
|
+
* fade the overlay back to the correct level after a scroll-induced fade-out.
|
|
447
|
+
*/
|
|
448
|
+
backdropOpacity: number;
|
|
134
449
|
}
|
|
135
450
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzD;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3D;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC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G;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACjC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,0CAA0C;IAC1C,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACnC,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IACpC,gBAAgB,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,+CAA+C;IAC/C,gBAAgB,EAAE,SAAS,GAAG,IAAI,CAAC;IACnC;;;OAGG;IACH,yBAAyB,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IACpD,yEAAyE;IACzE,2BAA2B,EAAE,MAAM,IAAI,CAAC;IACxC,uEAAuE;IACvE,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B;;;OAGG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage adapter for tour persistence.
|
|
3
|
+
* Auto-detects available storage (MMKV v4 or AsyncStorage) and provides a unified interface.
|
|
4
|
+
*/
|
|
5
|
+
export type StorageType = 'mmkv' | 'async-storage' | 'custom' | 'none';
|
|
6
|
+
export interface StorageAdapter {
|
|
7
|
+
getItem: (key: string) => Promise<string | null> | string | null;
|
|
8
|
+
setItem: (key: string, value: string) => Promise<void> | void;
|
|
9
|
+
removeItem: (key: string) => Promise<void> | void;
|
|
10
|
+
}
|
|
11
|
+
export interface TourStorageState {
|
|
12
|
+
tourId: string;
|
|
13
|
+
currentStepKey: string;
|
|
14
|
+
stepIndex: number;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Detects the available storage type and returns an adapter.
|
|
19
|
+
* Priority: MMKV v4 > AsyncStorage > none
|
|
20
|
+
*/
|
|
21
|
+
export declare function detectStorage(): {
|
|
22
|
+
type: StorageType;
|
|
23
|
+
adapter: StorageAdapter | null;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Clears the cached storage detection result.
|
|
27
|
+
* Useful for testing or when storage availability changes.
|
|
28
|
+
*/
|
|
29
|
+
export declare function clearStorageCache(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Generates a storage key for a specific tour.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getTourStorageKey(tourId: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Saves the current tour progress to storage.
|
|
36
|
+
*/
|
|
37
|
+
export declare function saveTourProgress(adapter: StorageAdapter, tourId: string, currentStepKey: string, stepIndex: number): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Loads the saved tour progress from storage.
|
|
40
|
+
* Returns null if no progress is saved or if the data is invalid.
|
|
41
|
+
*/
|
|
42
|
+
export declare function loadTourProgress(adapter: StorageAdapter, tourId: string): Promise<TourStorageState | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Clears the saved tour progress from storage.
|
|
45
|
+
*/
|
|
46
|
+
export declare function clearTourProgress(adapter: StorageAdapter, tourId: string): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if there is saved progress for a tour.
|
|
49
|
+
*/
|
|
50
|
+
export declare function hasTourProgress(adapter: StorageAdapter, tourId: string): Promise<boolean>;
|
|
51
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../../src/utils/storage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,eAAe,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACjE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9D,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACnD;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAyED;;;GAGG;AACH,wBAAgB,aAAa,IAAI;IAC/B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CAChC,CA0BA;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAGxC;AAMD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAExD;AAID;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,OAAO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