@pgy-eu/react-native-tour-guide 0.0.0-stage → 2.0.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.
Files changed (161) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +993 -2
  3. package/lib/commonjs/SpotlightOverlay.js +712 -0
  4. package/lib/commonjs/SpotlightOverlay.js.map +1 -0
  5. package/lib/commonjs/Tooltip.js +593 -0
  6. package/lib/commonjs/Tooltip.js.map +1 -0
  7. package/lib/commonjs/TourGuideContext.js +535 -0
  8. package/lib/commonjs/TourGuideContext.js.map +1 -0
  9. package/lib/commonjs/TourGuideOverlay.js +1173 -0
  10. package/lib/commonjs/TourGuideOverlay.js.map +1 -0
  11. package/lib/commonjs/TourTarget.js +80 -0
  12. package/lib/commonjs/TourTarget.js.map +1 -0
  13. package/lib/commonjs/accessibility.js +49 -0
  14. package/lib/commonjs/accessibility.js.map +1 -0
  15. package/lib/commonjs/dev.js +48 -0
  16. package/lib/commonjs/dev.js.map +1 -0
  17. package/lib/commonjs/events.js +56 -0
  18. package/lib/commonjs/events.js.map +1 -0
  19. package/lib/commonjs/index.js +169 -0
  20. package/lib/commonjs/index.js.map +1 -0
  21. package/lib/commonjs/package.json +1 -0
  22. package/lib/commonjs/shapes.js +158 -0
  23. package/lib/commonjs/shapes.js.map +1 -0
  24. package/lib/commonjs/storage.js +116 -0
  25. package/lib/commonjs/storage.js.map +1 -0
  26. package/lib/commonjs/themes.js +86 -0
  27. package/lib/commonjs/themes.js.map +1 -0
  28. package/lib/commonjs/types.js +6 -0
  29. package/lib/commonjs/types.js.map +1 -0
  30. package/lib/commonjs/useTourPersistence.js +135 -0
  31. package/lib/commonjs/useTourPersistence.js.map +1 -0
  32. package/lib/commonjs/useTourScroll.js +46 -0
  33. package/lib/commonjs/useTourScroll.js.map +1 -0
  34. package/lib/commonjs/utils.js +372 -0
  35. package/lib/commonjs/utils.js.map +1 -0
  36. package/lib/commonjs/validation.js +143 -0
  37. package/lib/commonjs/validation.js.map +1 -0
  38. package/lib/module/SpotlightOverlay.js +707 -0
  39. package/lib/module/SpotlightOverlay.js.map +1 -0
  40. package/lib/module/Tooltip.js +588 -0
  41. package/lib/module/Tooltip.js.map +1 -0
  42. package/lib/module/TourGuideContext.js +529 -0
  43. package/lib/module/TourGuideContext.js.map +1 -0
  44. package/lib/module/TourGuideOverlay.js +1167 -0
  45. package/lib/module/TourGuideOverlay.js.map +1 -0
  46. package/lib/module/TourTarget.js +74 -0
  47. package/lib/module/TourTarget.js.map +1 -0
  48. package/lib/module/accessibility.js +43 -0
  49. package/lib/module/accessibility.js.map +1 -0
  50. package/lib/module/dev.js +40 -0
  51. package/lib/module/dev.js.map +1 -0
  52. package/lib/module/events.js +51 -0
  53. package/lib/module/events.js.map +1 -0
  54. package/lib/module/index.js +25 -0
  55. package/lib/module/index.js.map +1 -0
  56. package/lib/module/package.json +1 -0
  57. package/lib/module/shapes.js +152 -0
  58. package/lib/module/shapes.js.map +1 -0
  59. package/lib/module/storage.js +111 -0
  60. package/lib/module/storage.js.map +1 -0
  61. package/lib/module/themes.js +81 -0
  62. package/lib/module/themes.js.map +1 -0
  63. package/lib/module/types.js +4 -0
  64. package/lib/module/types.js.map +1 -0
  65. package/lib/module/useTourPersistence.js +130 -0
  66. package/lib/module/useTourPersistence.js.map +1 -0
  67. package/lib/module/useTourScroll.js +41 -0
  68. package/lib/module/useTourScroll.js.map +1 -0
  69. package/lib/module/utils.js +361 -0
  70. package/lib/module/utils.js.map +1 -0
  71. package/lib/module/validation.js +138 -0
  72. package/lib/module/validation.js.map +1 -0
  73. package/lib/typescript/commonjs/package.json +1 -0
  74. package/lib/typescript/commonjs/src/SpotlightOverlay.d.ts +46 -0
  75. package/lib/typescript/commonjs/src/SpotlightOverlay.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/src/Tooltip.d.ts +9 -0
  77. package/lib/typescript/commonjs/src/Tooltip.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/src/TourGuideContext.d.ts +46 -0
  79. package/lib/typescript/commonjs/src/TourGuideContext.d.ts.map +1 -0
  80. package/lib/typescript/commonjs/src/TourGuideOverlay.d.ts +22 -0
  81. package/lib/typescript/commonjs/src/TourGuideOverlay.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/src/TourTarget.d.ts +36 -0
  83. package/lib/typescript/commonjs/src/TourTarget.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/src/accessibility.d.ts +22 -0
  85. package/lib/typescript/commonjs/src/accessibility.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/src/dev.d.ts +22 -0
  87. package/lib/typescript/commonjs/src/dev.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/events.d.ts +57 -0
  89. package/lib/typescript/commonjs/src/events.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/index.d.ts +21 -0
  91. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/shapes.d.ts +50 -0
  93. package/lib/typescript/commonjs/src/shapes.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/storage.d.ts +15 -0
  95. package/lib/typescript/commonjs/src/storage.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/themes.d.ts +10 -0
  97. package/lib/typescript/commonjs/src/themes.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/types.d.ts +599 -0
  99. package/lib/typescript/commonjs/src/types.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/useTourPersistence.d.ts +63 -0
  101. package/lib/typescript/commonjs/src/useTourPersistence.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/useTourScroll.d.ts +36 -0
  103. package/lib/typescript/commonjs/src/useTourScroll.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/utils.d.ts +97 -0
  105. package/lib/typescript/commonjs/src/utils.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/validation.d.ts +11 -0
  107. package/lib/typescript/commonjs/src/validation.d.ts.map +1 -0
  108. package/lib/typescript/module/package.json +1 -0
  109. package/lib/typescript/module/src/SpotlightOverlay.d.ts +46 -0
  110. package/lib/typescript/module/src/SpotlightOverlay.d.ts.map +1 -0
  111. package/lib/typescript/module/src/Tooltip.d.ts +9 -0
  112. package/lib/typescript/module/src/Tooltip.d.ts.map +1 -0
  113. package/lib/typescript/module/src/TourGuideContext.d.ts +46 -0
  114. package/lib/typescript/module/src/TourGuideContext.d.ts.map +1 -0
  115. package/lib/typescript/module/src/TourGuideOverlay.d.ts +22 -0
  116. package/lib/typescript/module/src/TourGuideOverlay.d.ts.map +1 -0
  117. package/lib/typescript/module/src/TourTarget.d.ts +36 -0
  118. package/lib/typescript/module/src/TourTarget.d.ts.map +1 -0
  119. package/lib/typescript/module/src/accessibility.d.ts +22 -0
  120. package/lib/typescript/module/src/accessibility.d.ts.map +1 -0
  121. package/lib/typescript/module/src/dev.d.ts +22 -0
  122. package/lib/typescript/module/src/dev.d.ts.map +1 -0
  123. package/lib/typescript/module/src/events.d.ts +57 -0
  124. package/lib/typescript/module/src/events.d.ts.map +1 -0
  125. package/lib/typescript/module/src/index.d.ts +21 -0
  126. package/lib/typescript/module/src/index.d.ts.map +1 -0
  127. package/lib/typescript/module/src/shapes.d.ts +50 -0
  128. package/lib/typescript/module/src/shapes.d.ts.map +1 -0
  129. package/lib/typescript/module/src/storage.d.ts +15 -0
  130. package/lib/typescript/module/src/storage.d.ts.map +1 -0
  131. package/lib/typescript/module/src/themes.d.ts +10 -0
  132. package/lib/typescript/module/src/themes.d.ts.map +1 -0
  133. package/lib/typescript/module/src/types.d.ts +599 -0
  134. package/lib/typescript/module/src/types.d.ts.map +1 -0
  135. package/lib/typescript/module/src/useTourPersistence.d.ts +63 -0
  136. package/lib/typescript/module/src/useTourPersistence.d.ts.map +1 -0
  137. package/lib/typescript/module/src/useTourScroll.d.ts +36 -0
  138. package/lib/typescript/module/src/useTourScroll.d.ts.map +1 -0
  139. package/lib/typescript/module/src/utils.d.ts +97 -0
  140. package/lib/typescript/module/src/utils.d.ts.map +1 -0
  141. package/lib/typescript/module/src/validation.d.ts +11 -0
  142. package/lib/typescript/module/src/validation.d.ts.map +1 -0
  143. package/llms.txt +62 -0
  144. package/package.json +281 -4
  145. package/src/SpotlightOverlay.tsx +742 -0
  146. package/src/Tooltip.tsx +638 -0
  147. package/src/TourGuideContext.tsx +644 -0
  148. package/src/TourGuideOverlay.tsx +1382 -0
  149. package/src/TourTarget.tsx +74 -0
  150. package/src/accessibility.ts +60 -0
  151. package/src/dev.ts +39 -0
  152. package/src/events.ts +76 -0
  153. package/src/index.tsx +64 -0
  154. package/src/shapes.ts +184 -0
  155. package/src/storage.ts +114 -0
  156. package/src/themes.ts +83 -0
  157. package/src/types.ts +648 -0
  158. package/src/useTourPersistence.ts +147 -0
  159. package/src/useTourScroll.ts +60 -0
  160. package/src/utils.ts +401 -0
  161. package/src/validation.ts +248 -0
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.shapeInnerPath = exports.roundedRectPath = exports.resolvePadding = exports.computeShape = void 0;
7
+ /** Padding around the spotlight: uniform number or per-side values. */
8
+
9
+ /** Resolve a SpotlightPadding to explicit per-side values. */
10
+ const resolvePadding = padding => {
11
+ if (typeof padding === 'number') {
12
+ return {
13
+ top: padding,
14
+ right: padding,
15
+ bottom: padding,
16
+ left: padding
17
+ };
18
+ }
19
+ return {
20
+ top: padding?.top ?? 0,
21
+ right: padding?.right ?? 0,
22
+ bottom: padding?.bottom ?? 0,
23
+ left: padding?.left ?? 0
24
+ };
25
+ };
26
+
27
+ /**
28
+ * Internal type for border radius — number for uniform, object for per-corner.
29
+ * Users specify this via `targetStyle` (auto-extracted) or `spotlightBorderRadius` (number override).
30
+ */
31
+
32
+ // --- Result types ---
33
+ exports.resolvePadding = resolvePadding;
34
+ // --- Rect bounds computation ---
35
+
36
+ const computeRectBounds = (target, padding) => ({
37
+ x: target.x - padding.left,
38
+ y: target.y - padding.top,
39
+ width: target.width + padding.left + padding.right,
40
+ height: target.height + padding.top + padding.bottom
41
+ });
42
+
43
+ /**
44
+ * SVG subpath for a uniformly-rounded rectangle (clockwise, closed). Used for
45
+ * the spotlight cutout and for kept spotlights.
46
+ */
47
+ const roundedRectPath = (x, y, w, h, r) => {
48
+ const rr = Math.max(0, Math.min(r, Math.min(w, h) / 2));
49
+ if (rr <= 0) return `M${x},${y} H${x + w} V${y + h} H${x} Z`;
50
+ return `M${x + rr},${y} H${x + w - rr} A${rr},${rr} 0 0 1 ${x + w},${y + rr} ` + `V${y + h - rr} A${rr},${rr} 0 0 1 ${x + w - rr},${y + h} ` + `H${x + rr} A${rr},${rr} 0 0 1 ${x},${y + h - rr} ` + `V${y + rr} A${rr},${rr} 0 0 1 ${x + rr},${y} Z`;
51
+ };
52
+
53
+ /** The inner (hole) subpath for any shape result. */
54
+ exports.roundedRectPath = roundedRectPath;
55
+ const shapeInnerPath = result => result.kind === 'path' ? result.d : roundedRectPath(result.x, result.y, result.width, result.height, result.rx);
56
+
57
+ // --- Rounded rect with per-corner radii ---
58
+ exports.shapeInnerPath = shapeInnerPath;
59
+ const computeRoundedRectPath = (x, y, w, h, tl, tr, br, bl) => {
60
+ // Clamp radii so they don't exceed half the smallest dimension
61
+ const maxR = Math.min(w, h) / 2;
62
+ const rtl = Math.min(tl, maxR);
63
+ const rtr = Math.min(tr, maxR);
64
+ const rbr = Math.min(br, maxR);
65
+ const rbl = Math.min(bl, maxR);
66
+ return [`M${x + rtl},${y}`, `L${x + w - rtr},${y}`, rtr > 0 ? `A${rtr},${rtr},0,0,1,${x + w},${y + rtr}` : `L${x + w},${y}`, `L${x + w},${y + h - rbr}`, rbr > 0 ? `A${rbr},${rbr},0,0,1,${x + w - rbr},${y + h}` : `L${x + w},${y + h}`, `L${x + rbl},${y + h}`, rbl > 0 ? `A${rbl},${rbl},0,0,1,${x},${y + h - rbl}` : `L${x},${y + h}`, `L${x},${y + rtl}`, rtl > 0 ? `A${rtl},${rtl},0,0,1,${x + rtl},${y}` : `L${x},${y}`, 'Z'].join(' ');
67
+ };
68
+
69
+ // --- Public API ---
70
+
71
+ /**
72
+ * Adjust border radius for the larger spotlight bounds.
73
+ * Fully rounded elements (circle/pill) stay fully rounded at the new size.
74
+ * Partially rounded elements keep their exact original radius.
75
+ */
76
+ const adjustRadius = (radius, targetWidth, targetHeight, padding) => {
77
+ if (radius <= 0) return 0;
78
+ const minTarget = Math.min(targetWidth, targetHeight);
79
+ // Fully rounded (circle / pill) — stay fully rounded at the larger size
80
+ if (radius >= minTarget / 2) {
81
+ return Math.min(targetWidth + padding * 2, targetHeight + padding * 2) / 2;
82
+ }
83
+ // Partially rounded — keep exact same radius, only bounds grow
84
+ return radius;
85
+ };
86
+
87
+ /**
88
+ * Compute the spotlight shape for a target.
89
+ * Always produces a rounded rectangle matching the target's border radius.
90
+ * Border radii are scaled proportionally so circles stay circular with padding.
91
+ */
92
+ const computeShape = (target, padding = 0, customBorderRadius) => {
93
+ const pad = resolvePadding(padding);
94
+ const {
95
+ x,
96
+ y,
97
+ width,
98
+ height
99
+ } = computeRectBounds(target, pad);
100
+ // For radius scaling, treat the average per-axis padding as the uniform
101
+ // equivalent — exact for uniform padding, sensible for per-side.
102
+ const padScale = Math.max((pad.left + pad.right) / 2, (pad.top + pad.bottom) / 2);
103
+
104
+ // Per-corner border radius → generate path with individual corner arcs
105
+ if (typeof customBorderRadius === 'object' && customBorderRadius !== null) {
106
+ const {
107
+ topLeft = 0,
108
+ topRight = 0,
109
+ bottomRight = 0,
110
+ bottomLeft = 0
111
+ } = customBorderRadius;
112
+
113
+ // Scale each corner
114
+ const sTL = adjustRadius(topLeft, target.width, target.height, padScale);
115
+ const sTR = adjustRadius(topRight, target.width, target.height, padScale);
116
+ const sBR = adjustRadius(bottomRight, target.width, target.height, padScale);
117
+ const sBL = adjustRadius(bottomLeft, target.width, target.height, padScale);
118
+
119
+ // If all corners are the same, use rect for smooth animation
120
+ if (sTL === sTR && sTR === sBR && sBR === sBL) {
121
+ return {
122
+ kind: 'rect',
123
+ x,
124
+ y,
125
+ width,
126
+ height,
127
+ rx: sTL,
128
+ ry: sTL
129
+ };
130
+ }
131
+
132
+ // Different corners: use path
133
+ const d = computeRoundedRectPath(x, y, width, height, sTL, sTR, sBR, sBL);
134
+ return {
135
+ kind: 'path',
136
+ d,
137
+ bounds: {
138
+ x,
139
+ y,
140
+ width,
141
+ height
142
+ }
143
+ };
144
+ }
145
+ const br = typeof customBorderRadius === 'number' ? customBorderRadius : 12;
146
+ const scaledBr = adjustRadius(br, target.width, target.height, padScale);
147
+ return {
148
+ kind: 'rect',
149
+ x,
150
+ y,
151
+ width,
152
+ height,
153
+ rx: scaledBr,
154
+ ry: scaledBr
155
+ };
156
+ };
157
+ exports.computeShape = computeShape;
158
+ //# sourceMappingURL=shapes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["resolvePadding","padding","top","right","bottom","left","exports","computeRectBounds","target","x","y","width","height","roundedRectPath","w","h","r","rr","Math","max","min","shapeInnerPath","result","kind","d","rx","computeRoundedRectPath","tl","tr","br","bl","maxR","rtl","rtr","rbr","rbl","join","adjustRadius","radius","targetWidth","targetHeight","minTarget","computeShape","customBorderRadius","pad","padScale","topLeft","topRight","bottomRight","bottomLeft","sTL","sTR","sBR","sBL","ry","bounds","scaledBr"],"sourceRoot":"../../src","sources":["shapes.ts"],"mappings":";;;;;;AAEA;;AAGA;AACO,MAAMA,cAAc,GAAIC,OAAqC,IAAiB;EACnF,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAO;MAAEC,GAAG,EAAED,OAAO;MAAEE,KAAK,EAAEF,OAAO;MAAEG,MAAM,EAAEH,OAAO;MAAEI,IAAI,EAAEJ;IAAQ,CAAC;EACzE;EACA,OAAO;IACLC,GAAG,EAAED,OAAO,EAAEC,GAAG,IAAI,CAAC;IACtBC,KAAK,EAAEF,OAAO,EAAEE,KAAK,IAAI,CAAC;IAC1BC,M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AoC,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.detectStorage = exports.__resetStorageCache = void 0;
7
+ var _dev = require("./dev.js");
8
+ /** How persistence storage was resolved. */
9
+
10
+ let cached = null;
11
+
12
+ /**
13
+ * MMKV, both API generations:
14
+ * - v4: `createMMKV({ id })` factory
15
+ * - v2/v3: `new MMKV({ id })` class
16
+ */
17
+ const tryMMKV = () => {
18
+ try {
19
+ const mod = require('react-native-mmkv');
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ let instance = null;
22
+ if (typeof mod?.createMMKV === 'function') {
23
+ instance = mod.createMMKV({
24
+ id: 'react-native-tour-guide'
25
+ });
26
+ } else if (typeof mod?.MMKV === 'function') {
27
+ instance = new mod.MMKV({
28
+ id: 'react-native-tour-guide'
29
+ });
30
+ }
31
+ if (instance && typeof instance.getString === 'function' && typeof instance.set === 'function' && (typeof instance.remove === 'function' || typeof instance.delete === 'function')) {
32
+ const removeFn = (instance.remove ?? instance.delete).bind(instance);
33
+ return {
34
+ getItem: key => instance.getString(key) ?? null,
35
+ setItem: (key, value) => {
36
+ instance.set(key, value);
37
+ },
38
+ removeItem: key => {
39
+ removeFn(key);
40
+ }
41
+ };
42
+ }
43
+ return null;
44
+ } catch {
45
+ return null;
46
+ }
47
+ };
48
+ const tryAsyncStorage = () => {
49
+ try {
50
+ const mod = require('@react-native-async-storage/async-storage');
51
+ const AsyncStorage = mod?.default ?? mod;
52
+ if (AsyncStorage && typeof AsyncStorage.getItem === 'function' && typeof AsyncStorage.setItem === 'function' && typeof AsyncStorage.removeItem === 'function') {
53
+ return {
54
+ getItem: key => AsyncStorage.getItem(key),
55
+ setItem: (key, value) => AsyncStorage.setItem(key, value),
56
+ removeItem: key => AsyncStorage.removeItem(key)
57
+ };
58
+ }
59
+ return null;
60
+ } catch {
61
+ return null;
62
+ }
63
+ };
64
+
65
+ /** In-memory last resort: the tour still works, persistence just doesn't survive restarts. */
66
+ const createMemoryStorage = () => {
67
+ const store = new Map();
68
+ return {
69
+ getItem: key => store.get(key) ?? null,
70
+ setItem: (key, value) => {
71
+ store.set(key, value);
72
+ },
73
+ removeItem: key => {
74
+ store.delete(key);
75
+ }
76
+ };
77
+ };
78
+
79
+ /**
80
+ * Detect an available storage backend for tour persistence.
81
+ * Priority: MMKV (fastest) → AsyncStorage → in-memory fallback.
82
+ * The result is cached; the adapters are only probed once.
83
+ */
84
+ const detectStorage = () => {
85
+ if (cached) return cached;
86
+ const mmkv = tryMMKV();
87
+ if (mmkv) {
88
+ cached = {
89
+ type: 'mmkv',
90
+ adapter: mmkv
91
+ };
92
+ return cached;
93
+ }
94
+ const asyncStorage = tryAsyncStorage();
95
+ if (asyncStorage) {
96
+ cached = {
97
+ type: 'async-storage',
98
+ adapter: asyncStorage
99
+ };
100
+ return cached;
101
+ }
102
+ (0, _dev.warnOnce)('useTourPersistence found neither react-native-mmkv nor @react-native-async-storage/async-storage, so tour completion is only remembered until the app restarts.', 'Install one of them, or pass your own storage adapter: useTourPersistence(myStorage).');
103
+ cached = {
104
+ type: 'memory',
105
+ adapter: createMemoryStorage()
106
+ };
107
+ return cached;
108
+ };
109
+
110
+ /** Test-only: clear the detection cache. */
111
+ exports.detectStorage = detectStorage;
112
+ const __resetStorageCache = () => {
113
+ cached = null;
114
+ };
115
+ exports.__resetStorageCache = __resetStorageCache;
116
+ //# sourceMappingURL=storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dev","require","cached","tryMMKV","mod","instance","createMMKV","id","MMKV","getString","set","remove","delete","removeFn","bind","getItem","key","setItem","value","removeItem","tryAsyncStorage","AsyncStorage","default","createMemoryStorage","store","Map","get","detectStorage","mmkv","type","adapter","asyncStorage","warnOnce","exports","__resetStorageCache"],"sourceRoot":"../../src","sources":["storage.ts"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,OAAA;AAE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B,MAAM,GAAG;MAAE2B,IAAI,EAAE,MAAM;MAAEC,OAAO,EAAEF;IAAK,CAAC;IACxC,OAAO1B,MAAM;EACf;EAEA,MAAM6B,YAAY,GAAGX,eAAe,CAAC,CAAC;EACtC,IAAIW,YAAY,EAAE;IAChB7B,MAAM,GAAG;MAAE2B,IAAI,EAAE,eAAe;MAAEC,OAAO,EAAEC;IAAa,CAAC;IACzD,OAAO7B,MAAM;EACf;EAEA,IAAA8B,aAAQ,EACN,iKAAiK,EACjK,uFACF,CAAC;EACD9B,MAAM,GAAG;IAAE2B,IAAI,EAAE,QAAQ;IAAEC,OAAO,EAAEP,mBAAmB,CAAC;EAAE,CAAC;EAC3D,OAAOrB,MAAM;AACf,CAAC;;AAED;AAAA+B,OAAA,CAAAN,aAAA,GAAAA,aAAA;AACO,MAAMO,mBAAmB,GAAGA,CAAA,KAAM;EACvChC,MAAM,GAAG,IAAI;AACf,CAAC;AAAC+B,OAAA,CAAAC,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.vibrantTheme = exports.minimalTheme = exports.lightTheme = exports.darkTheme = exports.createTheme = void 0;
7
+ const darkTheme = exports.darkTheme = {
8
+ tooltipStyles: {
9
+ backgroundColor: '#2C2C2E',
10
+ titleColor: '#FFFFFF',
11
+ descriptionColor: '#EBEBF5',
12
+ buttonTextColor: '#FFFFFF',
13
+ primaryButtonColor: '#007AFF',
14
+ secondaryButtonColor: '#3A3A3C',
15
+ skipButtonColor: '#8E8E93',
16
+ borderRadius: 12
17
+ },
18
+ spotlightStyles: {
19
+ overlayColor: 'black',
20
+ overlayOpacity: 0.6
21
+ }
22
+ };
23
+ const lightTheme = exports.lightTheme = {
24
+ tooltipStyles: {
25
+ backgroundColor: '#FFFFFF',
26
+ titleColor: '#1C1C1E',
27
+ descriptionColor: '#3A3A3C',
28
+ buttonTextColor: '#FFFFFF',
29
+ primaryButtonColor: '#007AFF',
30
+ secondaryButtonColor: '#E5E5EA',
31
+ skipButtonColor: '#8E8E93',
32
+ borderRadius: 12
33
+ },
34
+ spotlightStyles: {
35
+ overlayColor: 'black',
36
+ overlayOpacity: 0.4
37
+ }
38
+ };
39
+ const minimalTheme = exports.minimalTheme = {
40
+ tooltipStyles: {
41
+ backgroundColor: '#FAFAFA',
42
+ titleColor: '#333333',
43
+ descriptionColor: '#666666',
44
+ buttonTextColor: '#FFFFFF',
45
+ primaryButtonColor: '#555555',
46
+ secondaryButtonColor: '#E0E0E0',
47
+ skipButtonColor: '#999999',
48
+ borderRadius: 8
49
+ },
50
+ spotlightStyles: {
51
+ overlayColor: 'black',
52
+ overlayOpacity: 0.3
53
+ }
54
+ };
55
+ const vibrantTheme = exports.vibrantTheme = {
56
+ tooltipStyles: {
57
+ backgroundColor: '#1A1A2E',
58
+ titleColor: '#EAEAEA',
59
+ descriptionColor: '#B0B0C0',
60
+ buttonTextColor: '#FFFFFF',
61
+ primaryButtonColor: '#E94560',
62
+ secondaryButtonColor: '#16213E',
63
+ skipButtonColor: '#8E8E93',
64
+ borderRadius: 16
65
+ },
66
+ spotlightStyles: {
67
+ overlayColor: '#0F0F23',
68
+ overlayOpacity: 0.7
69
+ }
70
+ };
71
+
72
+ /**
73
+ * Create a custom theme by deep-merging overrides onto the dark theme base.
74
+ */
75
+ const createTheme = overrides => ({
76
+ tooltipStyles: {
77
+ ...darkTheme.tooltipStyles,
78
+ ...overrides.tooltipStyles
79
+ },
80
+ spotlightStyles: {
81
+ ...darkTheme.spotlightStyles,
82
+ ...overrides.spotlightStyles
83
+ }
84
+ });
85
+ exports.createTheme = createTheme;
86
+ //# sourceMappingURL=themes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["darkTheme","exports","tooltipStyles","backgroundColor","titleColor","descriptionColor","buttonTextColor","primaryButtonColor","secondaryButtonColor","skipButtonColor","borderRadius","spotlightStyles","overlayColor","overlayOpacity","light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,YAAA,GAAG;EACrCd,aAAa,EAAE;IACbC,eAAe,EAAE,SAAS;IAC1BC,UAAU,EAAE,SAAS;IACrBC,gBAAgB,EAAE,SAAS;IAC3BC,eAAe,EAAE,SAAS;IAC1BC,kBAAkB,EAAE,SAAS;IAC7BC,oBAAoB,EAAE,SAAS;IAC/BC,eAAe,EAAE,SAAS;IAC1BC,YAAY,EAAE;EAChB,CAAC;EACDC,eAAe,EAAE;IACfC,YAAY,EAAE,SAAS;IACvBC,cAAc,EAAE;EAClB;AACF,CAAC;;AAED;AACA;AACA;AACO,MAAMI,WAAW,GAAIC,SAA6B,KAAiB;EACxEhB,aAAa,EAAE;IACb,GAAGF,SAAS,CAACE,aAAa;IAC1B,GAAGgB,SAAS,CAAChB;EACf,CAAC;EACDS,eAAe,EAAE;IACf,GAAGX,SAAS,CAACW,eAAe;IAC5B,GAAGO,SAAS,CAACP;EACf;AACF,CAAC,CAAC;AAACV,OAAA,CAAAgB,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["types.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTourPersistence = void 0;
7
+ var _react = require("react");
8
+ var _TourGuideContext = require("./TourGuideContext.js");
9
+ var _storage = require("./storage.js");
10
+ var _dev = require("./dev.js");
11
+ const STORAGE_PREFIX = '@tour_guide:';
12
+
13
+ /**
14
+ * Hook that adds "show only once" persistence to tours.
15
+ * Wraps `startTour` to check if a tour has been completed before,
16
+ * and automatically marks tours as completed when they finish.
17
+ *
18
+ * @param storage - Optional storage adapter. When omitted, MMKV or
19
+ * AsyncStorage is auto-detected (in that order); with neither installed, an
20
+ * in-memory fallback is used and a dev warning explains persistence won't
21
+ * survive restarts.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * import AsyncStorage from '@react-native-async-storage/async-storage';
26
+ * import { useTourPersistence } from '@wrack/react-native-tour-guide';
27
+ *
28
+ * const { startTour, resetTour, isTourCompleted } = useTourPersistence(AsyncStorage);
29
+ *
30
+ * // Only shows the tour if user hasn't seen it before
31
+ * startTour(steps, { tourId: 'onboarding' });
32
+ *
33
+ * // Force show again
34
+ * await resetTour('onboarding');
35
+ * startTour(steps, { tourId: 'onboarding' });
36
+ * ```
37
+ */
38
+ const useTourPersistence = storage => {
39
+ const tourGuide = (0, _TourGuideContext.useTourGuide)();
40
+ // No adapter passed → auto-detect MMKV or AsyncStorage (memory fallback with
41
+ // a dev warning when neither is installed).
42
+ const resolved = storage ?? (0, _storage.detectStorage)().adapter;
43
+ const storageRef = (0, _react.useRef)(resolved);
44
+ storageRef.current = resolved;
45
+
46
+ // Stable ref to the underlying startTour to avoid re-creating our wrapper on every render
47
+ const startTourRef = (0, _react.useRef)(tourGuide.startTour);
48
+ startTourRef.current = tourGuide.startTour;
49
+
50
+ /**
51
+ * Check if a tour has been completed
52
+ */
53
+ const isTourCompleted = (0, _react.useCallback)(async tourId => {
54
+ try {
55
+ const value = await storageRef.current.getItem(`${STORAGE_PREFIX}${tourId}`);
56
+ return value === 'completed';
57
+ } catch (error) {
58
+ // A storage backend that is unavailable (not yet initialised, quota, web
59
+ // private mode) must not decide whether the user sees the tour, and must
60
+ // not reject into the caller. Treat "unknown" as "not completed".
61
+ (0, _dev.warn)(`Could not read tour state for "${tourId}" from storage: ${String(error)}. Treating the tour as not yet completed.`, 'Check that the storage adapter is initialised before calling startTour().');
62
+ return false;
63
+ }
64
+ }, []);
65
+
66
+ /**
67
+ * Mark a tour as completed
68
+ */
69
+ const markCompleted = (0, _react.useCallback)(async tourId => {
70
+ try {
71
+ await storageRef.current.setItem(`${STORAGE_PREFIX}${tourId}`, 'completed');
72
+ } catch (error) {
73
+ (0, _dev.warn)(`Could not persist completion of tour "${tourId}": ${String(error)}. The tour will show again next launch.`, 'Check that the storage adapter is writable.');
74
+ }
75
+ }, []);
76
+
77
+ /**
78
+ * Reset a tour so it shows again
79
+ */
80
+ const resetTour = (0, _react.useCallback)(async tourId => {
81
+ try {
82
+ await storageRef.current.removeItem(`${STORAGE_PREFIX}${tourId}`);
83
+ } catch (error) {
84
+ (0, _dev.warn)(`Could not reset tour "${tourId}": ${String(error)}.`, 'Check that the storage adapter supports removeItem().');
85
+ }
86
+ }, []);
87
+
88
+ /**
89
+ * Start a tour only if it hasn't been completed.
90
+ * Automatically marks the tour as completed when finished.
91
+ * Requires `config.tourId` to be set.
92
+ *
93
+ * @param force - If true, show the tour even if previously completed
94
+ * @returns true if the tour was started, false if it was skipped
95
+ */
96
+ const startTour = (0, _react.useCallback)(async (steps, config, force = false) => {
97
+ const tourId = config?.tourId;
98
+ if (!tourId) {
99
+ (0, _dev.warn)('useTourPersistence.startTour() was called without config.tourId, so the tour cannot be remembered and will show every time.', "Pass a stable id: startTour(steps, { tourId: 'onboarding' }).");
100
+ startTourRef.current(steps, config);
101
+ return true;
102
+ }
103
+
104
+ // Check if already completed
105
+ if (!force) {
106
+ const completed = await isTourCompleted(tourId);
107
+ if (completed) return false;
108
+ }
109
+
110
+ // Wrap onTourEnd to mark as completed
111
+ const originalOnTourEnd = config?.onTourEnd;
112
+ const enhancedConfig = {
113
+ ...config,
114
+ onTourEnd: completed => {
115
+ if (completed) {
116
+ // Fire-and-forget, but never as an unhandled rejection: markCompleted
117
+ // already swallows and reports storage failures.
118
+ void markCompleted(tourId);
119
+ }
120
+ originalOnTourEnd?.(completed);
121
+ }
122
+ };
123
+ startTourRef.current(steps, enhancedConfig);
124
+ return true;
125
+ }, [isTourCompleted, markCompleted]);
126
+ return {
127
+ ...tourGuide,
128
+ startTour,
129
+ isTourCompleted,
130
+ resetTour,
131
+ markCompleted
132
+ };
133
+ };
134
+ exports.useTourPersistence = useTourPersistence;
135
+ //# sourceMappingURL=useTourPersistence.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_TourGuideContext","_storage","_dev","STORAGE_PREFIX","useTourPersistence","storage","tourGuide","useTourGuide","resolved","detectStorage","adapter","storageRef","useRef","current","startTourRef","startTour","isTourCompleted","useCallback","tourId","value","getItem","error","warn","String","markCompleted","setItem","resetTour","removeItem","steps","config","force","completed","originalOnTourEnd","onTourEnd","enhancedConfig","exports"],"sourceRoot":"../../src","sources":["useTourPersistence.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AAEA,MAAMI,cAAc,GAAG,cAAc;;AAErC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,kBAAkB,GAAIC,OAAqB,IAAK;EAC3D,MAAMC,SAAS,GAAG,IAAAC,8BAAY,EAAC,CAAC;EAChC;EACA;EACA,MAAMC,QAAQ,GAAGH,OAAO,IAAI,IAAAI,sBAAa,EAAC,CAAC,CAACC,OAAO;EACnD,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAACJ,QAAQ,CAAC;EACnCG,UAAU,CAACE,OAAO,GAAGL,QAAQ;;EAE7B;EACA,MAAMM,YAAY,GAAG,IAAAF,aAAM,EAACN,SAAS,CAACS,SAAS,CAAC;EAChDD,YAAY,CAACD,OAAO,GAAGP,SAAS,CAACS,SAAS;;EAE1C;AACF;AACA;EACE,MAAMC,eAAe,GAAG,IAAAC,kBAAW,EAAC,MAAOC,MAAc,IAAuB;IAC9E,IAAI;MACF,MAAMC,KAAK,GAAG,MAAMR,UAAU,CAACE,OAAO,CAACO,OAAO,CAAC,GAAGjB,cAAc,GAAGe,MAAM,EAAE,CAA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YAAY,CAACD,OAAO,CAACe,KAAK,EAAEC,MAAM,CAAC;MACnC,OAAO,IAAI;IACb;;IAEA;IACA,IAAI,CAACC,KAAK,EAAE;MACV,MAAMC,SAAS,GAAG,MAAMf,eAAe,CAACE,MAAM,CAAC;MAC/C,IAAIa,SAAS,EAAE,OAAO,KAAK;IAC7B;;IAEA;IACA,MAAMC,iBAAiB,GAAGH,MAAM,EAAEI,SAAS;IAC3C,MAAMC,cAA+B,GAAG;MACtC,GAAGL,MAAM;MACTI,SAAS,EAAGF,SAAkB,IAAK;QACjC,IAAIA,SAAS,EAAE;UACb;UACA;UACA,KAAKP,aAAa,CAACN,MAAM,CAAC;QAC5B;QACAc,iBAAiB,GAAGD,SAAS,CAAC;MAChC;IACF,CAAC;IAEDjB,YAAY,CAACD,OAAO,CAACe,KAAK,EAAEM,cAAc,CAAC;IAC3C,OAAO,IAAI;EACb,CAAC,EACD,CAAClB,eAAe,EAAEQ,aAAa,CACjC,CAAC;EAED,OAAO;IACL,GAAGlB,SAAS;IACZS,SAAS;IACTC,eAAe;IACfU,SAAS;IACTF;EACF,CAAC;AACH,CAAC;AAACW,OAAA,CAAA/B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTourScroll = void 0;
7
+ var _react = require("react");
8
+ var _TourGuideContext = require("./TourGuideContext.js");
9
+ /**
10
+ * Binds a scrollable to the tour. Wiring this up gives the tour three things:
11
+ *
12
+ * 1. **`followTarget`** — with `config.followTarget: true`, the spotlight and
13
+ * tooltip stay glued to the target while the user scrolls freely.
14
+ * 2. **Exact auto-scroll settling** — `onMomentumScrollEnd` tells the tour the
15
+ * programmatic scroll finished, so the highlight lands immediately instead
16
+ * of waiting for position polling to detect the stop.
17
+ * 3. **A tracked scroll offset** — `getCurrentScrollOffset` becomes redundant;
18
+ * the tour reads the offset it saw last.
19
+ *
20
+ * Already have your own onScroll? Compose: call both handlers, or spread
21
+ * `scrollProps` and call your handler from a wrapper.
22
+ */
23
+ const useTourScroll = () => {
24
+ const {
25
+ __reportScroll,
26
+ __reportScrollEnd
27
+ } = (0, _TourGuideContext.useTourGuide)();
28
+ const onScroll = (0, _react.useCallback)(e => {
29
+ __reportScroll?.(e.nativeEvent.contentOffset.y);
30
+ }, [__reportScroll]);
31
+ const onMomentumScrollEnd = (0, _react.useCallback)(() => {
32
+ __reportScrollEnd?.();
33
+ }, [__reportScrollEnd]);
34
+ const scrollProps = (0, _react.useMemo)(() => ({
35
+ onScroll,
36
+ onMomentumScrollEnd,
37
+ scrollEventThrottle: 16
38
+ }), [onScroll, onMomentumScrollEnd]);
39
+ return {
40
+ scrollProps,
41
+ onScroll,
42
+ onMomentumScrollEnd
43
+ };
44
+ };
45
+ exports.useTourScroll = useTourScroll;
46
+ //# sourceMappingURL=useTourScroll.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_TourGuideContext","useTourScroll","__reportScroll","__reportScrollEnd","useTourGuide","onScroll","useCallback","e","nativeEvent","contentOffset","y","onMomentumScrollEnd","scrollProps","useMemo","scrollEventThrottle","exports"],"sourceRoot":"../../src","sources":["useTourScroll.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,iBAAA,GAAAD,OAAA;AAsBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,aAAa,GAAGA,CAAA,KAAyB;EACpD,MAAM;IAAEC,cAAc;IAAEC;EAAkB,CAAC,GAAG,IAAAC,8BAAY,EAAC,CAAC;EAE5D,MAAMC,QAAQ,GAAG,IAAAC,kBAAW,EACzBC,CAA0C,IAAK;IAC9CL,cAAc,GAAGK,CAAC,CAACC,WAAW,CAACC,aAAa,CAACC,CAAC,CAAC;EACjD,CAAC,EACD,CAACR,cAAc,CACjB,CAAC;EAED,MAAMS,mBAAmB,GAAG,IAAAL,kBAAW,EAAC,MAAM;IAC5CH,iBAAiB,GAAG,CAAC;EACvB,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;EAEvB,MAAMS,WAAW,GAAG,IAAAC,cAAO,EACzB,OAAO;IAAER,QAAQ;IAAEM,mBAAmB;IAAEG,mBAAmB,EAAE;EAAG,CAAC,CAAC,EAClE,CAACT,QAAQ,EAAEM,mBAAmB,CAChC,CAAC;EAED,OAAO;IAAEC,WAAW;IAAEP,QAAQ;IAAEM;EAAoB,CAAC;AACvD,CAAC;AAACI,OAAA,CAAAd,aAAA,GAAAA,aAAA","ignoreList":[]}