@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,10 +1,159 @@
1
- import Onboarding from '@blazejkustra/react-native-onboarding';
2
- import React, { createContext, useEffect, useMemo, useRef, useCallback, useState, useContext } from 'react';
3
- import { StyleSheet, View } from 'react-native';
4
- import Animated, { useSharedValue, useReducedMotion, withRepeat, withSequence, withTiming, withDelay, useAnimatedStyle } from 'react-native-reanimated';
1
+ import React, { forwardRef, createElement, createContext, useEffect, useMemo, useRef, useCallback, useState, useContext, useReducer } from 'react';
2
+ import { View, StyleSheet, AccessibilityInfo } from 'react-native';
5
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
4
 
7
- // src/showcase/FeatureShowcase.tsx
5
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
6
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
7
+ }) : x)(function(x) {
8
+ if (typeof require !== "undefined") return require.apply(this, arguments);
9
+ throw Error('Dynamic require of "' + x + '" is not supported');
10
+ });
11
+ var lastKnown = false;
12
+ var useReducedMotion = () => {
13
+ const [reduced, setReduced] = useState(lastKnown);
14
+ useEffect(() => {
15
+ let mounted = true;
16
+ AccessibilityInfo.isReduceMotionEnabled().then((value) => {
17
+ lastKnown = value;
18
+ if (mounted) setReduced(value);
19
+ }).catch(() => {
20
+ });
21
+ const sub = AccessibilityInfo.addEventListener("reduceMotionChanged", (value) => {
22
+ lastKnown = value;
23
+ setReduced(value);
24
+ });
25
+ return () => {
26
+ mounted = false;
27
+ sub == null ? void 0 : sub.remove();
28
+ };
29
+ }, []);
30
+ return reduced;
31
+ };
32
+
33
+ // src/coachmarks/reanimated.ts
34
+ var runtimeRequire = (moduleName) => {
35
+ if (moduleName !== "react-native-reanimated") return void 0;
36
+ if (typeof __require !== "function") return void 0;
37
+ try {
38
+ return __require("react-native-reanimated");
39
+ } catch {
40
+ return void 0;
41
+ }
42
+ };
43
+ var useStaticSharedValue = (initial) => {
44
+ const [, bump] = useReducer((n) => n + 1, 0);
45
+ const box = useRef(null);
46
+ if (box.current === null) {
47
+ let current = initial;
48
+ box.current = {
49
+ get value() {
50
+ return current;
51
+ },
52
+ set value(next) {
53
+ if (Object.is(next, current)) return;
54
+ current = next;
55
+ bump();
56
+ }
57
+ };
58
+ }
59
+ return box.current;
60
+ };
61
+ var runWorklet = (factory, fallback) => {
62
+ var _a;
63
+ try {
64
+ return (_a = factory()) != null ? _a : fallback;
65
+ } catch {
66
+ return fallback;
67
+ }
68
+ };
69
+ var StaticAnimatedView = forwardRef(function StaticAnimatedView2({ entering: _entering, exiting: _exiting, children, ...rest }, ref) {
70
+ return createElement(View, { ...rest, ref }, children);
71
+ });
72
+ var staticCreateAnimatedComponent = (component) => function StaticAnimatedComponent({ animatedProps, ...rest }) {
73
+ return createElement(component, { ...rest, ...animatedProps });
74
+ };
75
+ var staticApi = {
76
+ present: false,
77
+ View: StaticAnimatedView,
78
+ createAnimatedComponent: staticCreateAnimatedComponent,
79
+ useSharedValue: useStaticSharedValue,
80
+ useAnimatedStyle: (factory) => runWorklet(factory, {}),
81
+ useAnimatedProps: (factory) => runWorklet(factory, {}),
82
+ useReducedMotion,
83
+ withTiming: (toValue) => toValue,
84
+ withRepeat: (animation) => animation,
85
+ withSequence: (...animations) => {
86
+ var _a;
87
+ return (_a = animations[animations.length - 1]) != null ? _a : 0;
88
+ },
89
+ withDelay: (_ms, animation) => animation,
90
+ fadeIn: () => void 0,
91
+ fadeOut: () => void 0
92
+ };
93
+ var isFunction = (value) => typeof value === "function";
94
+ var isComponent = (value) => typeof value === "function" || !!value && typeof value === "object" && "$$typeof" in value;
95
+ var fromModule = (mod) => {
96
+ var _a, _b;
97
+ if (!mod || typeof mod !== "object") return void 0;
98
+ const ns = mod;
99
+ const def = ns.default && typeof ns.default === "object" ? ns.default : void 0;
100
+ const pick = (name) => {
101
+ var _a2;
102
+ return (_a2 = ns[name]) != null ? _a2 : def == null ? void 0 : def[name];
103
+ };
104
+ const view = (_a = def == null ? void 0 : def.View) != null ? _a : ns.View;
105
+ const createAnimated = (_b = def == null ? void 0 : def.createAnimatedComponent) != null ? _b : ns.createAnimatedComponent;
106
+ const hooks = {
107
+ useSharedValue: pick("useSharedValue"),
108
+ useAnimatedStyle: pick("useAnimatedStyle"),
109
+ useAnimatedProps: pick("useAnimatedProps"),
110
+ useReducedMotion: pick("useReducedMotion"),
111
+ withTiming: pick("withTiming"),
112
+ withRepeat: pick("withRepeat"),
113
+ withSequence: pick("withSequence"),
114
+ withDelay: pick("withDelay")
115
+ };
116
+ const fadeIn = pick("FadeIn");
117
+ const fadeOut = pick("FadeOut");
118
+ if (!isComponent(view) || !isFunction(createAnimated)) return void 0;
119
+ if (Object.values(hooks).some((member) => !isFunction(member))) return void 0;
120
+ if (!fadeIn || !fadeOut) return void 0;
121
+ const api2 = {
122
+ present: true,
123
+ View: view,
124
+ createAnimatedComponent: createAnimated,
125
+ ...hooks,
126
+ fadeIn: (durationMs) => fadeIn.duration(durationMs),
127
+ fadeOut: (durationMs) => fadeOut.duration(durationMs)
128
+ };
129
+ return api2;
130
+ };
131
+ var cached;
132
+ var resolveReanimated = (requireModule = runtimeRequire) => {
133
+ var _a;
134
+ try {
135
+ if (cached === void 0 || requireModule !== runtimeRequire) {
136
+ const resolved = (_a = fromModule(requireModule("react-native-reanimated"))) != null ? _a : staticApi;
137
+ if (requireModule === runtimeRequire) cached = resolved;
138
+ return resolved;
139
+ }
140
+ return cached;
141
+ } catch {
142
+ return staticApi;
143
+ }
144
+ };
145
+ var api = () => resolveReanimated();
146
+ var Animated = {
147
+ get View() {
148
+ return api().View;
149
+ }};
150
+ var useSharedValue = (initial) => api().useSharedValue(initial);
151
+ var useAnimatedStyle = (factory) => api().useAnimatedStyle(factory);
152
+ var useReducedMotion2 = () => api().useReducedMotion();
153
+ var withTiming = (toValue, config) => api().withTiming(toValue, config);
154
+ var withRepeat = (animation, count, reverse) => api().withRepeat(animation, count, reverse);
155
+ var withSequence = (...animations) => api().withSequence(...animations);
156
+ var withDelay = (ms, animation) => api().withDelay(ms, animation);
8
157
  var SWIPE_MS = 700;
9
158
  var TAP_MS = 320;
10
159
  var SPREAD_MS = 620;
@@ -66,7 +215,7 @@ var GestureHintComponent = ({
66
215
  const opacity = useSharedValue(1);
67
216
  const pulse = useSharedValue(1);
68
217
  const spread = useSharedValue(0);
69
- const reduced = useReducedMotion();
218
+ const reduced = useReducedMotion2();
70
219
  const isSwipe = type === "swipe_up" || type === "swipe_down" || type === "swipe_left" || type === "swipe_right";
71
220
  const isSpread = type === "pinch" || type === "zoom";
72
221
  const isTap = type === "tap" || type === "double_tap";
@@ -331,8 +480,8 @@ var DEFAULT_TIMEOUT_MS = 4e3;
331
480
  var failOpen = async (storage, key) => {
332
481
  var _a;
333
482
  if (!storage) return defaultWireFeatures;
334
- const cached = await readCachedFeatures(storage, key);
335
- return (_a = cached == null ? void 0 : cached.features) != null ? _a : defaultWireFeatures;
483
+ const cached3 = await readCachedFeatures(storage, key);
484
+ return (_a = cached3 == null ? void 0 : cached3.features) != null ? _a : defaultWireFeatures;
336
485
  };
337
486
  var fetchWithTimeout = async (url, apiKey, timeoutMs) => {
338
487
  const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
@@ -467,6 +616,47 @@ var useOnboardingTheme = () => {
467
616
  return ctx != null ? ctx : mergeTheme();
468
617
  };
469
618
 
619
+ // src/showcase/blazejOnboarding.ts
620
+ var MODULE_NAME = "@blazejkustra/react-native-onboarding";
621
+ var runtimeRequire2 = (moduleName) => {
622
+ if (moduleName !== MODULE_NAME) return void 0;
623
+ if (typeof __require !== "function") return void 0;
624
+ try {
625
+ return __require("@blazejkustra/react-native-onboarding");
626
+ } catch {
627
+ return void 0;
628
+ }
629
+ };
630
+ var interop = (mod) => {
631
+ if (typeof mod === "function") return mod;
632
+ if (!mod || typeof mod !== "object") return void 0;
633
+ const ns = mod;
634
+ if (ns.default) return ns.default;
635
+ if ("$$typeof" in ns) return ns;
636
+ return void 0;
637
+ };
638
+ var asComponent = (value) => {
639
+ if (typeof value === "function") return value;
640
+ if (value && typeof value === "object" && "$$typeof" in value) {
641
+ return value;
642
+ }
643
+ return void 0;
644
+ };
645
+ var cached2;
646
+ var resolveShowcaseOnboarding = (requireModule = runtimeRequire2) => {
647
+ try {
648
+ if (cached2 === void 0 || requireModule !== runtimeRequire2) {
649
+ const component = asComponent(interop(requireModule(MODULE_NAME)));
650
+ if (requireModule === runtimeRequire2) cached2 = component != null ? component : null;
651
+ return component;
652
+ }
653
+ if (cached2 === null) return void 0;
654
+ return cached2;
655
+ } catch {
656
+ return void 0;
657
+ }
658
+ };
659
+
470
660
  // src/showcase/showcaseColors.ts
471
661
  var showcaseColorsFromTheme = (t, accent) => ({
472
662
  background: {
@@ -527,12 +717,13 @@ var _FeatureShowcase = ({
527
717
  const accent = accentColor != null ? accentColor : t.colors.primary;
528
718
  const flags = useResolvedFeatures({ flags: features, config: featuresConfig });
529
719
  const disabled = !flags.showcase.enabled;
720
+ const Onboarding = useMemo(() => resolveShowcaseOnboarding(), []);
530
721
  const gateKey = showcaseGateKey(config.id);
531
722
  const seen = useMemo(
532
723
  () => hasSeenGate(gateKey, storage, isTesting),
533
724
  [gateKey, storage, isTesting]
534
725
  );
535
- const skip = seen || disabled;
726
+ const skip = seen || disabled || !Onboarding;
536
727
  const doneRef = useRef(false);
537
728
  const finish = useCallback(() => {
538
729
  if (doneRef.current) return;
@@ -612,7 +803,7 @@ var _FeatureShowcase = ({
612
803
  }),
613
804
  [t]
614
805
  );
615
- if (skip) return null;
806
+ if (skip || !Onboarding) return null;
616
807
  const activeGesture = (_a = config.slides[activeIndex]) == null ? void 0 : _a.gesture;
617
808
  const showGesture = !!activeGesture && activeGesture !== "none" && activeGesture !== "tap" && activeGesture !== "double_tap";
618
809
  return /* @__PURE__ */ jsxs(View, { style: styles2.fill, children: [