@wireai/activation 0.1.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 (142) hide show
  1. package/AGENTS.md +73 -0
  2. package/CHANGELOG.md +572 -0
  3. package/INTEGRATION_PROMPT.md +55 -0
  4. package/LICENSE +21 -0
  5. package/README.md +923 -0
  6. package/dist/CenteredModal-C3qQBHsA.d.mts +38 -0
  7. package/dist/CenteredModal-Cdgns6--.d.ts +38 -0
  8. package/dist/coachmarks/index.d.mts +352 -0
  9. package/dist/coachmarks/index.d.ts +352 -0
  10. package/dist/coachmarks/index.js +944 -0
  11. package/dist/coachmarks/index.js.map +1 -0
  12. package/dist/coachmarks/index.mjs +918 -0
  13. package/dist/coachmarks/index.mjs.map +1 -0
  14. package/dist/decision-CFvGY6nP.d.ts +228 -0
  15. package/dist/decision-Cl8OFYzu.d.mts +228 -0
  16. package/dist/index.d.mts +1390 -0
  17. package/dist/index.d.ts +1390 -0
  18. package/dist/index.js +3260 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/index.mjs +3186 -0
  21. package/dist/index.mjs.map +1 -0
  22. package/dist/questionnaire/index.d.mts +249 -0
  23. package/dist/questionnaire/index.d.ts +249 -0
  24. package/dist/questionnaire/index.js +922 -0
  25. package/dist/questionnaire/index.js.map +1 -0
  26. package/dist/questionnaire/index.mjs +906 -0
  27. package/dist/questionnaire/index.mjs.map +1 -0
  28. package/dist/reviews/index.d.mts +213 -0
  29. package/dist/reviews/index.d.ts +213 -0
  30. package/dist/reviews/index.js +1001 -0
  31. package/dist/reviews/index.js.map +1 -0
  32. package/dist/reviews/index.mjs +971 -0
  33. package/dist/reviews/index.mjs.map +1 -0
  34. package/dist/showcase/index.d.mts +119 -0
  35. package/dist/showcase/index.d.ts +119 -0
  36. package/dist/showcase/index.js +660 -0
  37. package/dist/showcase/index.js.map +1 -0
  38. package/dist/showcase/index.mjs +651 -0
  39. package/dist/showcase/index.mjs.map +1 -0
  40. package/dist/types-BKfpdZzX.d.mts +84 -0
  41. package/dist/types-BKfpdZzX.d.ts +84 -0
  42. package/dist/types-CMuOexw0.d.mts +116 -0
  43. package/dist/types-CMuOexw0.d.ts +116 -0
  44. package/dist/types-GL_hQ0TN.d.mts +46 -0
  45. package/dist/types-GL_hQ0TN.d.ts +46 -0
  46. package/llms.txt +36 -0
  47. package/metro/index.d.ts +32 -0
  48. package/metro/index.js +83 -0
  49. package/package.json +171 -0
  50. package/src/DemoOnboarding.tsx +133 -0
  51. package/src/OnboardingFlow.tsx +504 -0
  52. package/src/WireOnboarding.tsx +248 -0
  53. package/src/analytics/analyticsEvent.ts +69 -0
  54. package/src/analytics/reportClientEvent.ts +119 -0
  55. package/src/analytics/sendPreview.ts +73 -0
  56. package/src/attribution/attribution.ts +46 -0
  57. package/src/cards/ChipSelectCard.tsx +265 -0
  58. package/src/cards/InterstitialCard.tsx +299 -0
  59. package/src/cards/NumberStepperCard.tsx +121 -0
  60. package/src/cards/SelectionCard.tsx +270 -0
  61. package/src/cards/StatusCard.tsx +170 -0
  62. package/src/cards/TextInputCard.tsx +147 -0
  63. package/src/cards/index.ts +23 -0
  64. package/src/coachmarks/CoachmarkOverlayHost.tsx +44 -0
  65. package/src/coachmarks/CoachmarkProvider.tsx +108 -0
  66. package/src/coachmarks/GestureHint.tsx +331 -0
  67. package/src/coachmarks/SpotlightOverlay.tsx +254 -0
  68. package/src/coachmarks/coachmarkAnchorRegistry.ts +70 -0
  69. package/src/coachmarks/coachmarkOverlayStore.ts +63 -0
  70. package/src/coachmarks/index.ts +62 -0
  71. package/src/coachmarks/runtime.ts +103 -0
  72. package/src/coachmarks/selectTourSteps.ts +45 -0
  73. package/src/coachmarks/types.ts +58 -0
  74. package/src/coachmarks/useCoachmarkAnchor.ts +49 -0
  75. package/src/coachmarks/useCoachmarkTour.ts +200 -0
  76. package/src/components/AnimatedSparkle.tsx +101 -0
  77. package/src/components/Button.tsx +129 -0
  78. package/src/components/CardHandoff.tsx +212 -0
  79. package/src/components/CardLayout.tsx +103 -0
  80. package/src/components/CenteredModal.tsx +184 -0
  81. package/src/components/CompletionView.tsx +186 -0
  82. package/src/components/DoneBlock.tsx +37 -0
  83. package/src/components/ErrorBlock.tsx +42 -0
  84. package/src/components/Illustration.tsx +36 -0
  85. package/src/components/LoadingBlock.tsx +182 -0
  86. package/src/components/LoadingScreen.tsx +35 -0
  87. package/src/components/OnboardingScaffold.tsx +105 -0
  88. package/src/components/StepProgress.tsx +85 -0
  89. package/src/components/loaderChrome.ts +28 -0
  90. package/src/config/onboardingFlag.ts +39 -0
  91. package/src/config/wireConfigFromEnv.ts +52 -0
  92. package/src/device/deviceContext.ts +158 -0
  93. package/src/features/WireFeaturesProvider.tsx +81 -0
  94. package/src/features/cache.ts +92 -0
  95. package/src/features/defaults.ts +67 -0
  96. package/src/features/fetchWireFeatures.ts +86 -0
  97. package/src/features/index.ts +39 -0
  98. package/src/features/types.ts +61 -0
  99. package/src/features/useWireFeatures.ts +57 -0
  100. package/src/identity/userIdentity.ts +100 -0
  101. package/src/illustrations/defaultIllustrations.tsx +99 -0
  102. package/src/index.ts +159 -0
  103. package/src/motion/centeredModalMotion.ts +45 -0
  104. package/src/motion/motionSpec.ts +133 -0
  105. package/src/motion/useReducedMotion.ts +43 -0
  106. package/src/questionnaire/QuestionnaireGate.tsx +235 -0
  107. package/src/questionnaire/decision.ts +63 -0
  108. package/src/questionnaire/index.ts +54 -0
  109. package/src/questionnaire/runtime.ts +20 -0
  110. package/src/questionnaire/transport.ts +83 -0
  111. package/src/questionnaire/types.ts +182 -0
  112. package/src/questionnaire/useQuestionnaireGate.ts +159 -0
  113. package/src/reviews/ReviewGate.tsx +316 -0
  114. package/src/reviews/ReviewModal.tsx +13 -0
  115. package/src/reviews/decision.ts +120 -0
  116. package/src/reviews/equality.ts +54 -0
  117. package/src/reviews/expo-store-review.d.ts +16 -0
  118. package/src/reviews/feedbackForm.ts +41 -0
  119. package/src/reviews/index.ts +78 -0
  120. package/src/reviews/presentation.ts +29 -0
  121. package/src/reviews/runtime.ts +45 -0
  122. package/src/reviews/storeReview.ts +62 -0
  123. package/src/reviews/transport.ts +89 -0
  124. package/src/reviews/types.ts +172 -0
  125. package/src/reviews/useReviewGate.ts +137 -0
  126. package/src/session/persistedSession.ts +143 -0
  127. package/src/session-analytics/index.ts +18 -0
  128. package/src/session-analytics/reportSessionStart.ts +144 -0
  129. package/src/session-analytics/useSessionStart.ts +114 -0
  130. package/src/showcase/FeatureShowcase.tsx +233 -0
  131. package/src/showcase/index.ts +19 -0
  132. package/src/showcase/selectShowcaseSlides.ts +45 -0
  133. package/src/showcase/showcaseColors.ts +91 -0
  134. package/src/showcase/types.ts +74 -0
  135. package/src/theme/ThemeContext.tsx +38 -0
  136. package/src/theme/defaultTheme.ts +70 -0
  137. package/src/theme/themeFromBrand.ts +93 -0
  138. package/src/theme/types.ts +88 -0
  139. package/src/theme/typography.ts +46 -0
  140. package/src/types.ts +215 -0
  141. package/src/utils/deriveAnswers.ts +43 -0
  142. package/src/utils/readProgress.ts +33 -0
@@ -0,0 +1,228 @@
1
+ import { O as OnboardingTheme } from './types-BKfpdZzX.mjs';
2
+ import { C as CoachmarkStorage } from './types-GL_hQ0TN.mjs';
3
+ import { W as WireFeatures, a as WireFeaturesConfig } from './types-CMuOexw0.mjs';
4
+
5
+ /**
6
+ * The firing verdict — the SAME contract on both sides of the seam. `decideReview`
7
+ * turns local rules into one of these; a server `{fire, reason}` (from
8
+ * GET /v1/reviews/decision) is the exact same shape and OVERRIDES the local one.
9
+ */
10
+ interface ReviewDecision {
11
+ fire: boolean;
12
+ reason?: string;
13
+ }
14
+ /** Where to route a rating: 5 stars → the store, 1-4 → the feedback form. */
15
+ type RatingRoute = "store" | "feedback";
16
+ /**
17
+ * Configurable store targets for the 5-star fallback path (used when the native
18
+ * `expo-store-review` peer is absent or unavailable). At least one is recommended.
19
+ */
20
+ interface ReviewStoreConfig {
21
+ /** Apple App Store numeric app id → itms-apps review deep link. */
22
+ iosAppId?: string;
23
+ /** Android package name → market:// details link. */
24
+ androidPackage?: string;
25
+ /** An explicit fallback URL (used when the platform-specific target is absent). */
26
+ storeUrl?: string;
27
+ }
28
+ /** Local firing rules — v1 of the decision, overridden by a server decision when present. */
29
+ interface ReviewConfig {
30
+ /** Gate key. Seen/last-shown/session keys derive from it (`wire_review_<id>_*`). */
31
+ id: string;
32
+ /** Master local switch. Default true. */
33
+ enabled?: boolean;
34
+ /** Require at least this many sessions on the device before showing. Default 0. */
35
+ minSessions?: number;
36
+ /** Require at least this many tracked app events before showing. Default 0. */
37
+ minEvents?: number;
38
+ /** Suppress a re-prompt within this many days of the last shown. Default 0 (off). */
39
+ cooldownDays?: number;
40
+ /** Show at most once per app version (seen-gate keyed by `appVersion`). Default true. */
41
+ oncePerVersion?: boolean;
42
+ /** The current app version, for the once-per-version seen gate. */
43
+ appVersion?: string;
44
+ /**
45
+ * Client fallback ONLY: if no server decision arrives within this many ms of mount,
46
+ * fall back to the local rules. Null/absent → evaluate local rules immediately.
47
+ */
48
+ timeoutFallbackMs?: number | null;
49
+ }
50
+ /** The four analytics moments, mirrored on the coachmark callback convention (no PII). */
51
+ type ReviewGateEventName = "review_prompt_shown" | "review_rating_selected" | "store_review_requested" | "review_feedback_submitted";
52
+ /** One analytics moment. `stars` is present on `review_rating_selected`; never any free text. */
53
+ interface ReviewGateEvent {
54
+ name: ReviewGateEventName;
55
+ /** The gate id (`config.id`). */
56
+ id: string;
57
+ /** The chosen rating, on `review_rating_selected`. */
58
+ stars?: number;
59
+ }
60
+ /** The POST body sent to `POST /v1/reviews` (mirrors the server `CreateReviewRequest`). */
61
+ interface ReviewSubmission {
62
+ stars: number;
63
+ /** The optional "why this rating" answer (the free-text opinion box). */
64
+ feedback_text?: string;
65
+ /** The optional "what can you suggest" answer (the smaller suggestion box). */
66
+ suggestion?: string;
67
+ contact?: string;
68
+ session_id?: string;
69
+ source?: string;
70
+ meta?: Record<string, unknown>;
71
+ }
72
+ /**
73
+ * How the prompt is presented:
74
+ * • "modal" (default) — a centered popup: dimmed backdrop, card in the middle of the
75
+ * screen, spring/fade entrance. What Malik asked for after the bottom-anchored inline
76
+ * card rendered half-hidden.
77
+ * • "inline" — the bare card, positioned by wherever the host mounts it (the legacy path).
78
+ */
79
+ type ReviewPresentation = "modal" | "inline";
80
+ /** Where kit → server requests go (same tenant creds as the onboarding flow). */
81
+ interface ReviewTarget {
82
+ /** Base server URL (same as `WireOnboardingConfig.serverUrl`). */
83
+ serverUrl: string;
84
+ /** Tenant API key, sent as `Authorization: Bearer`. */
85
+ apiKey: string;
86
+ }
87
+ /** Props for the `ReviewGate` sentiment-gate component. */
88
+ interface ReviewGateProps {
89
+ /** App name, woven into the neutral prompt ("Enjoying <app>?"). */
90
+ appName?: string;
91
+ /** Store targets for the 5-star fallback path when the native peer is unavailable. */
92
+ store?: ReviewStoreConfig;
93
+ /** Where to POST a 1-4 feedback submission. Omit to skip the network (callbacks still fire). */
94
+ target?: ReviewTarget;
95
+ /** The onboarding/session id correlated with the review, when known. */
96
+ sessionId?: string;
97
+ /** Small non-PII extras stored with the review (e.g. device_key, app_version). */
98
+ meta?: Record<string, unknown>;
99
+ /** Fired at each analytics moment (host wires it to its own analytics). No PII. */
100
+ onEvent?: (event: ReviewGateEvent) => void;
101
+ /** Called once the gate is resolved (rated + routed, or dismissed). */
102
+ onResolved?: () => void;
103
+ /** Called when the gate first renders to the user (also fires `review_prompt_shown`). */
104
+ onShown?: () => void;
105
+ /** Partial theme merged over the active onboarding theme. */
106
+ theme?: Partial<OnboardingTheme>;
107
+ /** Show a Skip/Not now control. Default true (never a dead end). */
108
+ dismissible?: boolean;
109
+ /**
110
+ * How the prompt renders. Default "modal" — a centered popup over a dimmed backdrop with
111
+ * a spring/fade entrance. Pass "inline" for the legacy host-positioned bare card.
112
+ */
113
+ presentation?: ReviewPresentation;
114
+ /** The gate id, forwarded onto emitted events. */
115
+ id?: string;
116
+ }
117
+ /** Options for `useReviewGate` — the WHEN decision. */
118
+ interface UseReviewGateOptions {
119
+ config: ReviewConfig;
120
+ /** Server-provided decision (from GET /v1/reviews/decision). OVERRIDES local rules. */
121
+ decision?: ReviewDecision;
122
+ /** Current tracked app-event count (host-owned), for the `minEvents` rule. */
123
+ events?: number;
124
+ /** Sync gate storage. Defaults to the storage injected by CoachmarkProvider. */
125
+ storage?: CoachmarkStorage | null;
126
+ /** Testing override; defaults to the global `isTestingCoachmark` flag. */
127
+ isTesting?: boolean;
128
+ /**
129
+ * OPTIONAL feature-flag wiring — the review MASTER switch. When `flags.review.enabled` is false,
130
+ * the gate NEVER fires (`visible` stays false, verdict reason `feature_disabled`), whatever the
131
+ * local rules or a server decision say — it composes as an extra AND on top of the decision seam.
132
+ * Provide pre-resolved `features`, OR a `featuresConfig` to lazily fetch once, OR mount a
133
+ * `WireFeaturesProvider` above (context is read automatically). Omit all three and reviews stay
134
+ * on (fail-open), gated only by the existing rules.
135
+ */
136
+ features?: WireFeatures;
137
+ /** Lazy-fetch config for the flags, used when `features` is absent and no provider is above. */
138
+ featuresConfig?: WireFeaturesConfig;
139
+ }
140
+ /** What `useReviewGate` returns. */
141
+ interface ReviewGateController {
142
+ /** Whether the gate should be shown right now. */
143
+ visible: boolean;
144
+ /** The resolved verdict (local rules or the server override). For debugging/analytics. */
145
+ decision: ReviewDecision;
146
+ /** Persist the last-shown timestamp. Call when the gate becomes visible. */
147
+ markShown: () => void;
148
+ /** Write the once-per-version seen gate. Call when the gate is resolved. */
149
+ markResolved: () => void;
150
+ }
151
+
152
+ /**
153
+ * decision.ts — the pure decision logic for the review gate.
154
+ *
155
+ * `decideReview` is the AI seam, mirroring `selectTourSteps` exactly: ONE function that
156
+ * turns an optional injected decision into the live verdict. No injected decision → the
157
+ * local rules stand; a server decision present → it OVERRIDES them. Building the seam now
158
+ * is the whole cost of being AI-ready: today the host passes local rules only; later the
159
+ * Wire server computes `{fire, reason}` from the onboarding learnings and the host passes
160
+ * it straight in — zero app changes.
161
+ *
162
+ * // v1 (local rules only)
163
+ * const verdict = decideReview(evaluateGate(rules, signals));
164
+ *
165
+ * // AI on (server-provided decision wins)
166
+ * const verdict = decideReview(evaluateGate(rules, signals), serverDecision);
167
+ *
168
+ * `evaluateGate`, `routeRating`, and `buildReviewSubmission` are pure so the gate logic
169
+ * is verifiable in isolation (the kit has no test runner; correctness lives in these).
170
+ */
171
+
172
+ /**
173
+ * The seam. `decision` absent → the local verdict stands; present → it overrides.
174
+ * Same contract philosophy as `selectTourSteps(catalog, selection?)`.
175
+ */
176
+ declare const decideReview: (local: ReviewDecision, decision?: ReviewDecision) => ReviewDecision;
177
+ /** The signals the local rules evaluate against (read from injected sync storage + host). */
178
+ interface GateSignals {
179
+ /** Sessions observed on this device (incl. the current one). */
180
+ sessions: number;
181
+ /** Tracked app events observed (host-owned). */
182
+ events: number;
183
+ /** Epoch ms of the last time the gate was shown, or null if never. */
184
+ lastShownAt: number | null;
185
+ /** Whether the once-per-version gate is already satisfied. */
186
+ seen: boolean;
187
+ /** Current epoch ms (injected so the function stays pure). */
188
+ now: number;
189
+ }
190
+ /** The resolved local rules (defaults applied). */
191
+ interface GateRules {
192
+ enabled: boolean;
193
+ minSessions: number;
194
+ minEvents: number;
195
+ cooldownDays: number;
196
+ oncePerVersion: boolean;
197
+ }
198
+ /** Fill a partial `ReviewConfig` with the rule defaults. */
199
+ declare const resolveRules: (config: {
200
+ enabled?: boolean;
201
+ minSessions?: number;
202
+ minEvents?: number;
203
+ cooldownDays?: number;
204
+ oncePerVersion?: boolean;
205
+ }) => GateRules;
206
+ /**
207
+ * Deterministic v1 local decision. Order: disabled → once-gate → min-sessions →
208
+ * min-events → cooldown → fire. Reasons mirror the server evaluator's vocabulary.
209
+ */
210
+ declare const evaluateGate: (rules: GateRules, s: GateSignals) => ReviewDecision;
211
+ /**
212
+ * Route a rating. 5 stars → the native store review; 1-4 → the feedback form. The
213
+ * sentiment question itself is neutral — this is the ONLY place 5 is treated specially,
214
+ * never a button labeled "rate us 5 stars" (see the store-policy notes in the README).
215
+ */
216
+ declare const routeRating: (stars: number) => RatingRoute;
217
+ /** Build the `POST /v1/reviews` body. Feedback text/contact belong ONLY here, never in events. */
218
+ declare const buildReviewSubmission: (input: {
219
+ stars: number;
220
+ feedbackText?: string;
221
+ suggestion?: string;
222
+ contact?: string;
223
+ sessionId?: string;
224
+ source?: string;
225
+ meta?: Record<string, unknown>;
226
+ }) => ReviewSubmission;
227
+
228
+ export { type GateRules as G, type ReviewGateProps as R, type UseReviewGateOptions as U, type GateSignals as a, type ReviewPresentation as b, type ReviewGateController as c, type ReviewDecision as d, evaluateGate as e, type ReviewStoreConfig as f, type ReviewTarget as g, type ReviewSubmission as h, type RatingRoute as i, type ReviewConfig as j, type ReviewGateEvent as k, type ReviewGateEventName as l, buildReviewSubmission as m, decideReview as n, routeRating as o, resolveRules as r };