@wireai/activation 0.14.1 → 0.14.3

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.
@@ -1,18 +1,165 @@
1
1
  'use strict';
2
2
 
3
- var Onboarding = require('@blazejkustra/react-native-onboarding');
4
3
  var React = require('react');
5
4
  var reactNative = require('react-native');
6
- var Animated = require('react-native-reanimated');
7
5
  var jsxRuntime = require('react/jsx-runtime');
8
6
 
9
7
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
8
 
11
- var Onboarding__default = /*#__PURE__*/_interopDefault(Onboarding);
12
9
  var React__default = /*#__PURE__*/_interopDefault(React);
13
- var Animated__default = /*#__PURE__*/_interopDefault(Animated);
14
10
 
15
- // src/showcase/FeatureShowcase.tsx
11
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
12
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
13
+ }) : x)(function(x) {
14
+ if (typeof require !== "undefined") return require.apply(this, arguments);
15
+ throw Error('Dynamic require of "' + x + '" is not supported');
16
+ });
17
+ var lastKnown = false;
18
+ var useReducedMotion = () => {
19
+ const [reduced, setReduced] = React.useState(lastKnown);
20
+ React.useEffect(() => {
21
+ let mounted = true;
22
+ reactNative.AccessibilityInfo.isReduceMotionEnabled().then((value) => {
23
+ lastKnown = value;
24
+ if (mounted) setReduced(value);
25
+ }).catch(() => {
26
+ });
27
+ const sub = reactNative.AccessibilityInfo.addEventListener("reduceMotionChanged", (value) => {
28
+ lastKnown = value;
29
+ setReduced(value);
30
+ });
31
+ return () => {
32
+ mounted = false;
33
+ sub == null ? void 0 : sub.remove();
34
+ };
35
+ }, []);
36
+ return reduced;
37
+ };
38
+
39
+ // src/coachmarks/reanimated.ts
40
+ var runtimeRequire = (moduleName) => {
41
+ if (moduleName !== "react-native-reanimated") return void 0;
42
+ if (typeof __require !== "function") return void 0;
43
+ try {
44
+ return require("react-native-reanimated");
45
+ } catch {
46
+ return void 0;
47
+ }
48
+ };
49
+ var useStaticSharedValue = (initial) => {
50
+ const [, bump] = React.useReducer((n) => n + 1, 0);
51
+ const box = React.useRef(null);
52
+ if (box.current === null) {
53
+ let current = initial;
54
+ box.current = {
55
+ get value() {
56
+ return current;
57
+ },
58
+ set value(next) {
59
+ if (Object.is(next, current)) return;
60
+ current = next;
61
+ bump();
62
+ }
63
+ };
64
+ }
65
+ return box.current;
66
+ };
67
+ var runWorklet = (factory, fallback) => {
68
+ var _a;
69
+ try {
70
+ return (_a = factory()) != null ? _a : fallback;
71
+ } catch {
72
+ return fallback;
73
+ }
74
+ };
75
+ var StaticAnimatedView = React.forwardRef(function StaticAnimatedView2({ entering: _entering, exiting: _exiting, children, ...rest }, ref) {
76
+ return React.createElement(reactNative.View, { ...rest, ref }, children);
77
+ });
78
+ var staticCreateAnimatedComponent = (component) => function StaticAnimatedComponent({ animatedProps, ...rest }) {
79
+ return React.createElement(component, { ...rest, ...animatedProps });
80
+ };
81
+ var staticApi = {
82
+ present: false,
83
+ View: StaticAnimatedView,
84
+ createAnimatedComponent: staticCreateAnimatedComponent,
85
+ useSharedValue: useStaticSharedValue,
86
+ useAnimatedStyle: (factory) => runWorklet(factory, {}),
87
+ useAnimatedProps: (factory) => runWorklet(factory, {}),
88
+ useReducedMotion,
89
+ withTiming: (toValue) => toValue,
90
+ withRepeat: (animation) => animation,
91
+ withSequence: (...animations) => {
92
+ var _a;
93
+ return (_a = animations[animations.length - 1]) != null ? _a : 0;
94
+ },
95
+ withDelay: (_ms, animation) => animation,
96
+ fadeIn: () => void 0,
97
+ fadeOut: () => void 0
98
+ };
99
+ var isFunction = (value) => typeof value === "function";
100
+ var isComponent = (value) => typeof value === "function" || !!value && typeof value === "object" && "$$typeof" in value;
101
+ var fromModule = (mod) => {
102
+ var _a, _b;
103
+ if (!mod || typeof mod !== "object") return void 0;
104
+ const ns = mod;
105
+ const def = ns.default && typeof ns.default === "object" ? ns.default : void 0;
106
+ const pick = (name) => {
107
+ var _a2;
108
+ return (_a2 = ns[name]) != null ? _a2 : def == null ? void 0 : def[name];
109
+ };
110
+ const view = (_a = def == null ? void 0 : def.View) != null ? _a : ns.View;
111
+ const createAnimated = (_b = def == null ? void 0 : def.createAnimatedComponent) != null ? _b : ns.createAnimatedComponent;
112
+ const hooks = {
113
+ useSharedValue: pick("useSharedValue"),
114
+ useAnimatedStyle: pick("useAnimatedStyle"),
115
+ useAnimatedProps: pick("useAnimatedProps"),
116
+ useReducedMotion: pick("useReducedMotion"),
117
+ withTiming: pick("withTiming"),
118
+ withRepeat: pick("withRepeat"),
119
+ withSequence: pick("withSequence"),
120
+ withDelay: pick("withDelay")
121
+ };
122
+ const fadeIn = pick("FadeIn");
123
+ const fadeOut = pick("FadeOut");
124
+ if (!isComponent(view) || !isFunction(createAnimated)) return void 0;
125
+ if (Object.values(hooks).some((member) => !isFunction(member))) return void 0;
126
+ if (!fadeIn || !fadeOut) return void 0;
127
+ const api2 = {
128
+ present: true,
129
+ View: view,
130
+ createAnimatedComponent: createAnimated,
131
+ ...hooks,
132
+ fadeIn: (durationMs) => fadeIn.duration(durationMs),
133
+ fadeOut: (durationMs) => fadeOut.duration(durationMs)
134
+ };
135
+ return api2;
136
+ };
137
+ var cached;
138
+ var resolveReanimated = (requireModule = runtimeRequire) => {
139
+ var _a;
140
+ try {
141
+ if (cached === void 0 || requireModule !== runtimeRequire) {
142
+ const resolved = (_a = fromModule(requireModule("react-native-reanimated"))) != null ? _a : staticApi;
143
+ if (requireModule === runtimeRequire) cached = resolved;
144
+ return resolved;
145
+ }
146
+ return cached;
147
+ } catch {
148
+ return staticApi;
149
+ }
150
+ };
151
+ var api = () => resolveReanimated();
152
+ var Animated = {
153
+ get View() {
154
+ return api().View;
155
+ }};
156
+ var useSharedValue = (initial) => api().useSharedValue(initial);
157
+ var useAnimatedStyle = (factory) => api().useAnimatedStyle(factory);
158
+ var useReducedMotion2 = () => api().useReducedMotion();
159
+ var withTiming = (toValue, config) => api().withTiming(toValue, config);
160
+ var withRepeat = (animation, count, reverse) => api().withRepeat(animation, count, reverse);
161
+ var withSequence = (...animations) => api().withSequence(...animations);
162
+ var withDelay = (ms, animation) => api().withDelay(ms, animation);
16
163
  var SWIPE_MS = 700;
17
164
  var TAP_MS = 320;
18
165
  var SPREAD_MS = 620;
@@ -70,29 +217,29 @@ var GestureHintComponent = ({
70
217
  renderHand
71
218
  }) => {
72
219
  var _a;
73
- const translate = Animated.useSharedValue(0);
74
- const opacity = Animated.useSharedValue(1);
75
- const pulse = Animated.useSharedValue(1);
76
- const spread = Animated.useSharedValue(0);
77
- const reduced = Animated.useReducedMotion();
220
+ const translate = useSharedValue(0);
221
+ const opacity = useSharedValue(1);
222
+ const pulse = useSharedValue(1);
223
+ const spread = useSharedValue(0);
224
+ const reduced = useReducedMotion2();
78
225
  const isSwipe = type === "swipe_up" || type === "swipe_down" || type === "swipe_left" || type === "swipe_right";
79
226
  const isSpread = type === "pinch" || type === "zoom";
80
227
  const isTap = type === "tap" || type === "double_tap";
81
228
  React.useEffect(() => {
82
229
  if (type === "none" || reduced) return void 0;
83
230
  if (isTap) {
84
- pulse.value = Animated.withRepeat(
85
- Animated.withSequence(
86
- Animated.withTiming(0.82, { duration: TAP_MS }),
87
- Animated.withTiming(1, { duration: TAP_MS })
231
+ pulse.value = withRepeat(
232
+ withSequence(
233
+ withTiming(0.82, { duration: TAP_MS }),
234
+ withTiming(1, { duration: TAP_MS })
88
235
  ),
89
236
  -1,
90
237
  false
91
238
  );
92
- opacity.value = Animated.withRepeat(
93
- Animated.withSequence(
94
- Animated.withTiming(0.55, { duration: TAP_MS }),
95
- Animated.withTiming(1, { duration: TAP_MS })
239
+ opacity.value = withRepeat(
240
+ withSequence(
241
+ withTiming(0.55, { duration: TAP_MS }),
242
+ withTiming(1, { duration: TAP_MS })
96
243
  ),
97
244
  -1,
98
245
  false
@@ -100,48 +247,48 @@ var GestureHintComponent = ({
100
247
  return void 0;
101
248
  }
102
249
  if (isSpread) {
103
- spread.value = Animated.withRepeat(
104
- Animated.withSequence(
105
- Animated.withTiming(size * 0.26, { duration: SPREAD_MS }),
106
- Animated.withTiming(0, { duration: SPREAD_MS })
250
+ spread.value = withRepeat(
251
+ withSequence(
252
+ withTiming(size * 0.26, { duration: SPREAD_MS }),
253
+ withTiming(0, { duration: SPREAD_MS })
107
254
  ),
108
255
  -1,
109
256
  false
110
257
  );
111
258
  return void 0;
112
259
  }
113
- translate.value = Animated.withRepeat(
114
- Animated.withSequence(
115
- Animated.withTiming(0, { duration: 0 }),
116
- Animated.withTiming(-26, { duration: SWIPE_MS }),
117
- Animated.withDelay(140, Animated.withTiming(0, { duration: 0 }))
260
+ translate.value = withRepeat(
261
+ withSequence(
262
+ withTiming(0, { duration: 0 }),
263
+ withTiming(-26, { duration: SWIPE_MS }),
264
+ withDelay(140, withTiming(0, { duration: 0 }))
118
265
  ),
119
266
  -1,
120
267
  false
121
268
  );
122
- opacity.value = Animated.withRepeat(
123
- Animated.withSequence(
124
- Animated.withTiming(1, { duration: SWIPE_MS / 2 }),
125
- Animated.withTiming(0, { duration: SWIPE_MS / 2 }),
126
- Animated.withDelay(140, Animated.withTiming(1, { duration: 0 }))
269
+ opacity.value = withRepeat(
270
+ withSequence(
271
+ withTiming(1, { duration: SWIPE_MS / 2 }),
272
+ withTiming(0, { duration: SWIPE_MS / 2 }),
273
+ withDelay(140, withTiming(1, { duration: 0 }))
127
274
  ),
128
275
  -1,
129
276
  false
130
277
  );
131
278
  return void 0;
132
279
  }, [type, reduced, isTap, isSpread, translate, opacity, pulse, spread, size]);
133
- const swipeAnimatedStyle = Animated.useAnimatedStyle(() => ({
280
+ const swipeAnimatedStyle = useAnimatedStyle(() => ({
134
281
  opacity: opacity.value,
135
282
  transform: [{ translateY: translate.value }]
136
283
  }));
137
- const tapAnimatedStyle = Animated.useAnimatedStyle(() => ({
284
+ const tapAnimatedStyle = useAnimatedStyle(() => ({
138
285
  opacity: opacity.value,
139
286
  transform: [{ scale: pulse.value }]
140
287
  }));
141
- const spreadLeftStyle = Animated.useAnimatedStyle(() => ({
288
+ const spreadLeftStyle = useAnimatedStyle(() => ({
142
289
  transform: [{ translateX: -spread.value }]
143
290
  }));
144
- const spreadRightStyle = Animated.useAnimatedStyle(() => ({
291
+ const spreadRightStyle = useAnimatedStyle(() => ({
145
292
  transform: [{ translateX: spread.value }]
146
293
  }));
147
294
  if (type === "none") return null;
@@ -153,7 +300,7 @@ var GestureHintComponent = ({
153
300
  style: { transform: [{ rotate: (_a = GLYPH_ROTATION[type]) != null ? _a : "0deg" }] },
154
301
  pointerEvents: "none",
155
302
  children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles.swipeStack, children: [
156
- /* @__PURE__ */ jsxRuntime.jsx(Animated__default.default.View, { style: swipeAnimatedStyle, pointerEvents: "none", children: customGlyph != null ? customGlyph : /* @__PURE__ */ jsxRuntime.jsx(FingerPair, { size, color }) }),
303
+ /* @__PURE__ */ jsxRuntime.jsx(Animated.View, { style: swipeAnimatedStyle, pointerEvents: "none", children: customGlyph != null ? customGlyph : /* @__PURE__ */ jsxRuntime.jsx(FingerPair, { size, color }) }),
157
304
  /* @__PURE__ */ jsxRuntime.jsx(MotionTrack, { size, color })
158
305
  ] })
159
306
  }
@@ -168,16 +315,16 @@ var GestureHintComponent = ({
168
315
  backgroundColor: color
169
316
  };
170
317
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles.spreadRow, { gap: size * 0.12 }], pointerEvents: "none", children: [
171
- /* @__PURE__ */ jsxRuntime.jsx(Animated__default.default.View, { style: spreadLeftStyle, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: capsule }) }),
172
- /* @__PURE__ */ jsxRuntime.jsx(Animated__default.default.View, { style: spreadRightStyle, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: capsule }) })
318
+ /* @__PURE__ */ jsxRuntime.jsx(Animated.View, { style: spreadLeftStyle, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: capsule }) }),
319
+ /* @__PURE__ */ jsxRuntime.jsx(Animated.View, { style: spreadRightStyle, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: capsule }) })
173
320
  ] });
174
321
  }
175
322
  const ringSize = size * 0.86;
176
323
  const ringBorder = Math.max(2, size * 0.08);
177
324
  const dotSize = size * 0.32;
178
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles.tapWrap, { width: size, height: size }], pointerEvents: "none", children: customGlyph ? /* @__PURE__ */ jsxRuntime.jsx(Animated__default.default.View, { style: tapAnimatedStyle, pointerEvents: "none", children: customGlyph }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
325
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles.tapWrap, { width: size, height: size }], pointerEvents: "none", children: customGlyph ? /* @__PURE__ */ jsxRuntime.jsx(Animated.View, { style: tapAnimatedStyle, pointerEvents: "none", children: customGlyph }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
179
326
  /* @__PURE__ */ jsxRuntime.jsx(
180
- Animated__default.default.View,
327
+ Animated.View,
181
328
  {
182
329
  style: [
183
330
  styles.tapRing,
@@ -339,8 +486,8 @@ var DEFAULT_TIMEOUT_MS = 4e3;
339
486
  var failOpen = async (storage, key) => {
340
487
  var _a;
341
488
  if (!storage) return defaultWireFeatures;
342
- const cached = await readCachedFeatures(storage, key);
343
- return (_a = cached == null ? void 0 : cached.features) != null ? _a : defaultWireFeatures;
489
+ const cached3 = await readCachedFeatures(storage, key);
490
+ return (_a = cached3 == null ? void 0 : cached3.features) != null ? _a : defaultWireFeatures;
344
491
  };
345
492
  var fetchWithTimeout = async (url, apiKey, timeoutMs) => {
346
493
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
@@ -475,6 +622,47 @@ var useOnboardingTheme = () => {
475
622
  return ctx != null ? ctx : mergeTheme();
476
623
  };
477
624
 
625
+ // src/showcase/blazejOnboarding.ts
626
+ var MODULE_NAME = "@blazejkustra/react-native-onboarding";
627
+ var runtimeRequire2 = (moduleName) => {
628
+ if (moduleName !== MODULE_NAME) return void 0;
629
+ if (typeof __require !== "function") return void 0;
630
+ try {
631
+ return require("@blazejkustra/react-native-onboarding");
632
+ } catch {
633
+ return void 0;
634
+ }
635
+ };
636
+ var interop = (mod) => {
637
+ if (typeof mod === "function") return mod;
638
+ if (!mod || typeof mod !== "object") return void 0;
639
+ const ns = mod;
640
+ if (ns.default) return ns.default;
641
+ if ("$$typeof" in ns) return ns;
642
+ return void 0;
643
+ };
644
+ var asComponent = (value) => {
645
+ if (typeof value === "function") return value;
646
+ if (value && typeof value === "object" && "$$typeof" in value) {
647
+ return value;
648
+ }
649
+ return void 0;
650
+ };
651
+ var cached2;
652
+ var resolveShowcaseOnboarding = (requireModule = runtimeRequire2) => {
653
+ try {
654
+ if (cached2 === void 0 || requireModule !== runtimeRequire2) {
655
+ const component = asComponent(interop(requireModule(MODULE_NAME)));
656
+ if (requireModule === runtimeRequire2) cached2 = component != null ? component : null;
657
+ return component;
658
+ }
659
+ if (cached2 === null) return void 0;
660
+ return cached2;
661
+ } catch {
662
+ return void 0;
663
+ }
664
+ };
665
+
478
666
  // src/showcase/showcaseColors.ts
479
667
  var showcaseColorsFromTheme = (t, accent) => ({
480
668
  background: {
@@ -535,12 +723,13 @@ var _FeatureShowcase = ({
535
723
  const accent = accentColor != null ? accentColor : t.colors.primary;
536
724
  const flags = useResolvedFeatures({ flags: features, config: featuresConfig });
537
725
  const disabled = !flags.showcase.enabled;
726
+ const Onboarding = React.useMemo(() => resolveShowcaseOnboarding(), []);
538
727
  const gateKey = showcaseGateKey(config.id);
539
728
  const seen = React.useMemo(
540
729
  () => hasSeenGate(gateKey, storage, isTesting),
541
730
  [gateKey, storage, isTesting]
542
731
  );
543
- const skip = seen || disabled;
732
+ const skip = seen || disabled || !Onboarding;
544
733
  const doneRef = React.useRef(false);
545
734
  const finish = React.useCallback(() => {
546
735
  if (doneRef.current) return;
@@ -620,12 +809,12 @@ var _FeatureShowcase = ({
620
809
  }),
621
810
  [t]
622
811
  );
623
- if (skip) return null;
812
+ if (skip || !Onboarding) return null;
624
813
  const activeGesture = (_a = config.slides[activeIndex]) == null ? void 0 : _a.gesture;
625
814
  const showGesture = !!activeGesture && activeGesture !== "none" && activeGesture !== "tap" && activeGesture !== "double_tap";
626
815
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles2.fill, children: [
627
816
  /* @__PURE__ */ jsxRuntime.jsx(
628
- Onboarding__default.default,
817
+ Onboarding,
629
818
  {
630
819
  introPanel,
631
820
  steps,