@rocapine/react-native-onboarding 1.69.0 → 1.71.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 (59) hide show
  1. package/dist/OnboardingStudioClient.d.ts +4 -4
  2. package/dist/OnboardingStudioClient.js +7 -7
  3. package/dist/OnboardingStudioClient.js.map +1 -1
  4. package/dist/paywalls/PaywallProvider.d.ts +24 -7
  5. package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
  6. package/dist/paywalls/PaywallProvider.js +80 -42
  7. package/dist/paywalls/PaywallProvider.js.map +1 -1
  8. package/dist/paywalls/present.d.ts +60 -14
  9. package/dist/paywalls/present.d.ts.map +1 -1
  10. package/dist/paywalls/present.js +67 -18
  11. package/dist/paywalls/present.js.map +1 -1
  12. package/dist/paywalls/types.d.ts +48 -23
  13. package/dist/paywalls/types.d.ts.map +1 -1
  14. package/dist/paywalls/types.js +0 -7
  15. package/dist/paywalls/types.js.map +1 -1
  16. package/dist/paywalls/usePaywall.d.ts +5 -5
  17. package/dist/paywalls/usePaywall.d.ts.map +1 -1
  18. package/dist/products/adapters/expoIap.d.ts.map +1 -1
  19. package/dist/products/adapters/expoIap.js +118 -11
  20. package/dist/products/adapters/expoIap.js.map +1 -1
  21. package/dist/products/adapters/stripeLink.d.ts +57 -0
  22. package/dist/products/adapters/stripeLink.d.ts.map +1 -0
  23. package/dist/products/adapters/stripeLink.js +158 -0
  24. package/dist/products/adapters/stripeLink.js.map +1 -0
  25. package/dist/products/index.d.ts +4 -1
  26. package/dist/products/index.d.ts.map +1 -1
  27. package/dist/products/index.js +5 -1
  28. package/dist/products/index.js.map +1 -1
  29. package/dist/products/refIdentity.d.ts +3 -0
  30. package/dist/products/refIdentity.d.ts.map +1 -0
  31. package/dist/products/refIdentity.js +37 -0
  32. package/dist/products/refIdentity.js.map +1 -0
  33. package/dist/products/types.d.ts +29 -1
  34. package/dist/products/types.d.ts.map +1 -1
  35. package/dist/products/useProducts.d.ts.map +1 -1
  36. package/dist/products/useProducts.js +7 -1
  37. package/dist/products/useProducts.js.map +1 -1
  38. package/dist/steps/common.types.d.ts +2 -0
  39. package/dist/steps/common.types.d.ts.map +1 -1
  40. package/dist/steps/common.types.js +1 -0
  41. package/dist/steps/common.types.js.map +1 -1
  42. package/package.json +1 -1
  43. package/src/OnboardingStudioClient.ts +7 -7
  44. package/src/paywalls/PaywallProvider.tsx +109 -46
  45. package/src/paywalls/__tests__/getPaywalls.test.ts +15 -12
  46. package/src/paywalls/__tests__/present.test.ts +149 -28
  47. package/src/paywalls/present.ts +74 -21
  48. package/src/paywalls/types.ts +49 -23
  49. package/src/paywalls/usePaywall.ts +5 -5
  50. package/src/products/__tests__/refIdentity.test.ts +44 -0
  51. package/src/products/adapters/__tests__/expoIap.test.ts +210 -0
  52. package/src/products/adapters/__tests__/stripeLink.test.ts +179 -0
  53. package/src/products/adapters/expoIap.ts +121 -5
  54. package/src/products/adapters/stripeLink.ts +245 -0
  55. package/src/products/index.ts +4 -0
  56. package/src/products/refIdentity.ts +33 -0
  57. package/src/products/types.ts +30 -1
  58. package/src/products/useProducts.ts +7 -4
  59. package/src/steps/common.types.ts +3 -0
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldRecordPurchaseOutcome = exports.resolvePresentedOutcome = exports.purchaseOutcomeFromResult = exports.computeIsReady = exports.computeCatalogStatus = exports.shouldBreakPresentationWedge = exports.resolvePresentDecision = exports.collectProductRefs = void 0;
3
+ exports.selectActiveProductRuntime = exports.shouldRecordPurchaseOutcome = exports.resolvePresentedOutcome = exports.purchaseOutcomeFromResult = exports.computeIsReady = exports.computeCatalogStatus = exports.shouldBreakPresentationWedge = exports.resolvePresentDecision = exports.collectProductRefs = void 0;
4
+ const refIdentity_1 = require("../products/refIdentity");
4
5
  /**
5
6
  * Union of every `paywall.products[]` across the WHOLE catalog, deduplicated
6
7
  * by content — the same identity notion `useProducts`' `refsKey` uses
7
- * (`products/useProducts.ts:41-45`: keyed on ref CONTENT, not array
8
- * identity), so this array is exactly as cheap to pass as a hand-written one:
9
- * `useProducts` resolves it once and does not refetch on every render.
8
+ * (`products/refIdentity.ts`: keyed on ref CONTENT, not array identity), so
9
+ * this array is exactly as cheap to pass as a hand-written one: `useProducts`
10
+ * resolves it once and does not refetch on every render.
10
11
  *
11
12
  * Resolving the whole catalog's union ONCE at load — rather than re-keying
12
13
  * `useProducts` per presented paywall — is the deliberate design decision:
@@ -15,14 +16,13 @@ exports.shouldRecordPurchaseOutcome = exports.resolvePresentedOutcome = exports.
15
16
  * accepted: an app resolves products for paywalls it may never show.
16
17
  */
17
18
  const collectProductRefs = (catalog) => {
18
- var _a, _b, _c;
19
19
  if (!catalog)
20
20
  return [];
21
21
  const seen = new Set();
22
22
  const refs = [];
23
23
  for (const paywall of Object.values(catalog.paywalls)) {
24
24
  for (const ref of paywall.products) {
25
- const identity = `${ref.key}|${(_a = ref.ios) !== null && _a !== void 0 ? _a : ""}|${(_b = ref.android) !== null && _b !== void 0 ? _b : ""}|${(_c = ref.compareTo) !== null && _c !== void 0 ? _c : ""}`;
25
+ const identity = (0, refIdentity_1.productRefIdentity)(ref);
26
26
  if (seen.has(identity))
27
27
  continue;
28
28
  seen.add(identity);
@@ -33,13 +33,13 @@ const collectProductRefs = (catalog) => {
33
33
  };
34
34
  exports.collectProductRefs = collectProductRefs;
35
35
  /**
36
- * `present(placement)`'s edge-case decision, extracted so both documented
36
+ * `present(moment)`'s edge-case decision, extracted so both documented
37
37
  * edge cases are covered by an importable test rather than only inspection:
38
38
  *
39
- * - **Unknown placement** (absent from the catalog, or the catalog hasn't
40
- * resolved yet — both look identical here: `catalog?.paywalls[placement]`
39
+ * - **Unknown moment** (absent from the catalog, or the catalog hasn't
40
+ * resolved yet — both look identical here: `catalog?.paywalls[moment]`
41
41
  * is `undefined` either way) → resolves `"error"`, never throws. A missing
42
- * placement must not crash a host app mid-flow.
42
+ * moment must not crash a host app mid-flow.
43
43
  * - **`present()` called while another paywall is already showing** → also
44
44
  * resolves `"error"` immediately, leaving the in-progress presentation
45
45
  * untouched. This SDK shows one paywall at a time. Silently replacing the
@@ -47,19 +47,19 @@ exports.collectProductRefs = collectProductRefs;
47
47
  * resolved — that caller hangs forever); queueing the new request would
48
48
  * need its own cancellation/timeout story that nothing here asks for.
49
49
  * Resolving the new call immediately applies the same "resolve, don't
50
- * throw" contract as the unknown-placement case, consistently.
50
+ * throw" contract as the unknown-moment case, consistently.
51
51
  */
52
- const resolvePresentDecision = (catalog, activePlacement, placement) => {
53
- if (activePlacement !== null) {
54
- // `activePlacement` is echoed back deliberately — see PresentErrorReason.
52
+ const resolvePresentDecision = (catalog, activeMoment, moment) => {
53
+ if (activeMoment !== null) {
54
+ // `activeMoment` is echoed back deliberately — see PresentErrorReason.
55
55
  return {
56
56
  type: "immediate",
57
- result: { status: "error", reason: "already-presenting", activePlacement },
57
+ result: { status: "error", reason: "already-presenting", activeMoment },
58
58
  };
59
59
  }
60
- const paywall = catalog === null || catalog === void 0 ? void 0 : catalog.paywalls[placement];
60
+ const paywall = catalog === null || catalog === void 0 ? void 0 : catalog.paywalls[moment];
61
61
  if (!paywall) {
62
- return { type: "immediate", result: { status: "error", reason: "unknown-placement" } };
62
+ return { type: "immediate", result: { status: "error", reason: "unknown-moment" } };
63
63
  }
64
64
  return { type: "start", paywall };
65
65
  };
@@ -141,10 +141,59 @@ exports.resolvePresentedOutcome = resolvePresentedOutcome;
141
141
  * generation again after — only an unchanged generation means the write is
142
142
  * still for the presentation that started it.
143
143
  *
144
- * A monotonic counter, not the placement string: the same placement can
144
+ * A monotonic counter, not the moment string: the same moment can
145
145
  * legitimately be presented twice in a row, and a string comparison would
146
146
  * let a stale write from the FIRST of those two land in the second.
147
147
  */
148
148
  const shouldRecordPurchaseOutcome = (startedInGeneration, currentGeneration) => startedInGeneration === currentGeneration;
149
149
  exports.shouldRecordPurchaseOutcome = shouldRecordPurchaseOutcome;
150
+ /**
151
+ * Which of the two resolved product runtimes to publish.
152
+ *
153
+ * `PaywallProvider` resolves the catalog's product union TWICE — once through
154
+ * the host's store adapter, once through its Stripe adapter — because the
155
+ * runtime is published as one map keyed by product key, and a `store` paywall
156
+ * and a `stripe` paywall declaring the same key would otherwise fight over
157
+ * `product.<key>.price`. Only one paywall is ever presented at a time
158
+ * (`activeMoment`), so "the active one" is unambiguous.
159
+ *
160
+ * This is cheap rather than wasteful because the Stripe pass performs no
161
+ * network call (`stripeLinkProductProvider`) and each provider silently drops
162
+ * refs it cannot resolve, so neither pass does work for the other's paywalls.
163
+ *
164
+ * The statuses are deliberately NOT merged. Merging is the trap
165
+ * `mergeProductRuntimes` documents from the other direction: an `"idle"`
166
+ * runtime with nothing to wait for drags a `"ready"` one down and closes every
167
+ * `products.loaded` gate for the life of the process.
168
+ *
169
+ * `hasStripeProvider` is the guard for a misconfigured host: a `stripe`
170
+ * paywall with no `stripeProductProvider` passed leaves `useProducts` at
171
+ * `"idle"` forever (it bails before calling a provider it does not have), so
172
+ * `computeIsReady` would never turn true and paywalls would stop appearing
173
+ * with no error. Falling back to the store runtime keeps the app alive; the
174
+ * caller warns.
175
+ *
176
+ * `billing` is `undefined` whenever no paywall is active (`activePaywall` is
177
+ * null before the first `present()`, and after every `complete()`) — there is
178
+ * no `.billing` to read yet. That USED to fall through to the store runtime
179
+ * unconditionally, which meant a host that passes ONLY
180
+ * `stripeProductProvider` (no `productProvider` at all) sat on an `"idle"`
181
+ * `storeRuntime` — forever, for every screen before a paywall first presents,
182
+ * since nothing ever calls a `present()` to select the stripe runtime instead
183
+ * — so `products.loaded` read `"false"` everywhere and `isReady` never turned
184
+ * true. `hasStoreProvider` closes that gap: with no active paywall, prefer
185
+ * whichever provider was actually SUPPLIED. When both or neither exist there
186
+ * is no asymmetry to correct, so this keeps the pre-existing store-first
187
+ * default — unchanged for every host that already worked.
188
+ */
189
+ const selectActiveProductRuntime = (args) => {
190
+ if (args.billing === "stripe" && args.hasStripeProvider)
191
+ return args.stripeRuntime;
192
+ if (args.billing !== undefined)
193
+ return args.storeRuntime;
194
+ if (args.hasStripeProvider && !args.hasStoreProvider)
195
+ return args.stripeRuntime;
196
+ return args.storeRuntime;
197
+ };
198
+ exports.selectActiveProductRuntime = selectActiveProductRuntime;
150
199
  //# sourceMappingURL=present.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"present.js","sourceRoot":"","sources":["../../src/paywalls/present.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;GAYG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAA8B,EAAgB,EAAE;;IACjF,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,IAAI,GAAiB,EAAE,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;YACnC,MAAM,QAAQ,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,MAAA,GAAG,CAAC,GAAG,mCAAI,EAAE,IAAI,MAAA,GAAG,CAAC,OAAO,mCAAI,EAAE,IAAI,MAAA,GAAG,CAAC,SAAS,mCAAI,EAAE,EAAE,CAAC;YAC3F,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,SAAS;YACjC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAbW,QAAA,kBAAkB,sBAa7B;AAOF;;;;;;;;;;;;;;;;GAgBG;AACI,MAAM,sBAAsB,GAAG,CACpC,OAA8B,EAC9B,eAA8B,EAC9B,SAAiB,EACA,EAAE;IACnB,IAAI,eAAe,K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,QAAQ,IAAI,IAAI,CAAC,iBAAiB;QAAE,OAAO,IAAI,CAAC,aAAa,CAAC;IACnF,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC,YAAY,CAAC;IACzD,IAAI,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,CAAC,gBAAgB;QAAE,OAAO,IAAI,CAAC,aAAa,CAAC;IAChF,OAAO,IAAI,CAAC,YAAY,CAAC;AAC3B,CAAC,CAAC;AAXW,QAAA,0BAA0B,8BAWrC"}
@@ -1,69 +1,94 @@
1
+ import type { StripeProductRef } from "../products/types";
1
2
  /**
2
3
  * Response types for `OnboardingStudioClient.getPaywalls()` (spec §6.1). The
3
- * endpoint returns every placement for the project/audience/locale in one
4
+ * endpoint returns every moment for the project/audience/locale in one
4
5
  * payload — a paywall must render the instant the user taps upgrade, and a
5
6
  * network round-trip at that moment is a conversion bug, so there is no
6
- * per-placement fetch in the common path (see `PaywallOptions.placement`).
7
+ * per-moment fetch in the common path (see `PaywallOptions.moment`).
8
+ */
9
+ /**
10
+ * A single studio-authored paywall, keyed by `moment` in `PaywallCatalog.paywalls`.
11
+ *
12
+ * `audienceId`/`audienceName` are resolved PER MOMENT, not once for the whole
13
+ * catalog: each moment (an onboarding-end upsell, a settings-screen upgrade,
14
+ * …) runs its own independent audience waterfall, so two entries in the same
15
+ * catalog can legitimately have matched different audiences. That is why
16
+ * these fields live here and not on `PaywallCatalog.metadata`.
7
17
  */
8
- /** A single studio-authored paywall, keyed by `placement` in `PaywallCatalog.paywalls`. */
9
18
  export type Paywall = {
10
19
  id: string;
11
20
  name: string;
12
- placement: string;
21
+ moment: string;
22
+ audienceId: number | null;
23
+ audienceName: string | null;
13
24
  /** UIElement[] — parsed by the UI adapter (Task 7's `ScreenElementsSchema`), not here. */
14
25
  elements: unknown[];
26
+ /**
27
+ * Which billing path this paywall's buy actions take. `"store"` uses the
28
+ * host's store adapter (`PaywallProvider`'s `productProvider`); `"stripe"`
29
+ * uses `PaywallProvider`'s `stripeProductProvider` and opens a Payment Link.
30
+ *
31
+ * A property of the PAYWALL, not the moment or the project, so one moment
32
+ * audience can weight a `store` variant against a `stripe` variant and ramp
33
+ * the billing change as an A/B test.
34
+ */
35
+ billing: "store" | "stripe";
15
36
  products: Array<{
16
37
  key: string;
17
38
  ios?: string;
18
39
  android?: string;
19
40
  compareTo?: string;
41
+ stripe?: StripeProductRef;
20
42
  }>;
21
43
  configuration: Record<string, unknown> | null;
22
44
  };
23
45
  /** Full response body of `GET get-paywalls`. */
24
46
  export type PaywallCatalog = {
25
47
  metadata: {
26
- audienceId: number | null;
27
- audienceName: string | null;
28
48
  locale: string | null;
29
49
  draft: boolean;
30
50
  };
31
- /** Keyed by placement, not by paywall id. */
51
+ /** Keyed by moment, not by paywall id. */
32
52
  paywalls: Record<string, Paywall>;
33
53
  fonts: Record<string, unknown> | null;
34
54
  };
35
55
  /**
36
56
  * Options for `OnboardingStudioClient.getPaywalls()`.
37
57
  *
38
- * `placement` narrows the response to a single paywall — the exception, not
39
- * the default. Omit it to get every placement in one round-trip, which is
58
+ * `moment` narrows the response to a single paywall — the exception, not
59
+ * the default. Omit it to get every moment in one round-trip, which is
40
60
  * what lets a paywall render instantly at buy-tap time (see the module doc
41
61
  * above).
42
62
  */
43
63
  export type PaywallOptions = {
44
64
  locale?: string;
45
- placement?: string;
65
+ moment?: string;
46
66
  };
47
67
  /**
48
68
  * Response headers for `get-paywalls`. Deliberately **not** the onboarding
49
69
  * trio (`ONBS-Onboarding-Id` / `ONBS-Audience-Id` / `ONBS-Onboarding-Name`) —
50
70
  * the paywall endpoint has no single onboarding/audience-name concept and
51
71
  * instead reports which paywall ids came back.
72
+ *
73
+ * `ONBS-Audience-Ids` is plural (comma-separated) and parallel in order to
74
+ * `ONBS-Paywall-Ids`: each moment resolves its own audience waterfall (see
75
+ * `Paywall.audienceId`), so there is no single catalog-level audience left
76
+ * to report under a singular header.
52
77
  */
53
78
  export interface GetPaywallsResponseHeaders {
54
- "ONBS-Audience-Id": string | null;
79
+ "ONBS-Audience-Ids": string | null;
55
80
  "ONBS-Paywall-Ids": string | null;
56
81
  }
57
82
  /**
58
- * Resolved outcome of a `usePaywall().present(placement)` call (spec §7).
83
+ * Resolved outcome of a `usePaywall().present(moment)` call (spec §7).
59
84
  * Closed union, not the open-ended `ScreenHost.CompleteOutcome` — a
60
85
  * presentation ends in exactly one of these four ways, and `present()`'s
61
86
  * caller (typically an `await`) should be able to switch over it exhaustively.
62
87
  *
63
- * `"error"` covers both: (a) `placement` is absent from the catalog (or the
88
+ * `"error"` covers both: (a) `moment` is absent from the catalog (or the
64
89
  * catalog hasn't resolved yet), and (b) `present()` was called while another
65
90
  * paywall is already being presented. Both resolve rather than throw — a
66
- * missing placement or a mistimed call must not crash a host app mid-flow.
91
+ * missing moment or a mistimed call must not crash a host app mid-flow.
67
92
  * See `resolvePresentDecision` in `present.ts` for the exact decision logic.
68
93
  *
69
94
  * `"purchased"` / `"cancelled"` are NOT produced by any ButtonAction directly
@@ -94,18 +119,18 @@ export interface GetPaywallsResponseHeaders {
94
119
  * absent on every other status.
95
120
  *
96
121
  * This exists because `"error"` alone conflates conditions whose correct
97
- * recovery is OPPOSITE. `"unknown-placement"` means the catalog may simply not
122
+ * recovery is OPPOSITE. `"unknown-moment"` means the catalog may simply not
98
123
  * have arrived yet, so retrying later is right. `"already-presenting"` means a
99
124
  * presentation is in progress, so retrying is wrong and something may be
100
125
  * stuck. A caller given only the status can act correctly on neither, and two
101
126
  * separate multi-hour production investigations were spent reconstructing by
102
127
  * elimination what the SDK already knew here.
103
128
  *
104
- * - `unknown-placement` — absent from the catalog, or the catalog has not
129
+ * - `unknown-moment` — absent from the catalog, or the catalog has not
105
130
  * resolved yet. The two are indistinguishable at this layer, and both are
106
131
  * worth retrying once `usePaywall().isReady` is true.
107
- * - `already-presenting` — one paywall shows at a time. `activePlacement` on
108
- * the result names the one that IS showing: the same placement means the
132
+ * - `already-presenting` — one paywall shows at a time. `activeMoment` on
133
+ * the result names the one that IS showing: the same moment means the
109
134
  * caller double-called and wants its own in-flight guard, a different one
110
135
  * means something else holds the surface.
111
136
  * - `parse-error` — `elements` failed the UI schema, so the Modal was never
@@ -120,19 +145,19 @@ export interface GetPaywallsResponseHeaders {
120
145
  * keep the surface usable. In practice the platform refused to present
121
146
  * (iOS will not present over an already-presenting view controller — another
122
147
  * Modal, a `presentation: "modal"` route, a StoreKit alert).
123
- * - `paywall-disappeared` — the placement vanished from the catalog while it
148
+ * - `paywall-disappeared` — the moment vanished from the catalog while it
124
149
  * was on screen (a studio publish, or a query-key change mid-presentation).
125
150
  */
126
- export type PresentErrorReason = "unknown-placement" | "already-presenting" | "parse-error" | "render-error" | "host-never-presented" | "paywall-disappeared";
151
+ export type PresentErrorReason = "unknown-moment" | "already-presenting" | "parse-error" | "render-error" | "host-never-presented" | "paywall-disappeared";
127
152
  export type PresentResult = {
128
153
  status: "purchased" | "dismissed" | "cancelled" | "error";
129
154
  /** Why it failed. Set on `"error"` only — see `PresentErrorReason`. */
130
155
  reason?: PresentErrorReason;
131
156
  /**
132
- * The placement currently being presented. Set only alongside
133
- * `reason: "already-presenting"`, where knowing WHICH placement holds the
157
+ * The moment currently being presented. Set only alongside
158
+ * `reason: "already-presenting"`, where knowing WHICH moment holds the
134
159
  * surface is what distinguishes a caller double-call from an unrelated stall.
135
160
  */
136
- activePlacement?: string;
161
+ activeMoment?: string;
137
162
  };
138
163
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paywalls/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,2FAA2F;AAC3F,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,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;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,0BAA0B;IACzC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;;;;;;;GAYG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,oBAAoB,GACpB,aAAa,GACb,cAAc,GACd,sBAAsB,GACtB,qBAAqB,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;IAC1D,uEAAuE;IACvE,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
@@ -1,10 +1,3 @@
1
1
  "use strict";
2
- /**
3
- * Response types for `OnboardingStudioClient.getPaywalls()` (spec §6.1). The
4
- * endpoint returns every placement for the project/audience/locale in one
5
- * payload — a paywall must render the instant the user taps upgrade, and a
6
- * network round-trip at that moment is a conversion bug, so there is no
7
- * per-placement fetch in the common path (see `PaywallOptions.placement`).
8
- */
9
2
  Object.defineProperty(exports, "__esModule", { value: true });
10
3
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paywalls/types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paywalls/types.ts"],"names":[],"mappings":""}
@@ -3,27 +3,27 @@ import type { CatalogStatus } from "./present";
3
3
  import type { ProductStatus } from "../products/types";
4
4
  export type UsePaywallResult = {
5
5
  /**
6
- * Present a paywall by placement. Never fetches — the catalog and its
6
+ * Present a paywall by moment. Never fetches — the catalog and its
7
7
  * products are already resolved (or resolving) from `PaywallProvider`
8
8
  * mount, which is the whole point: a paywall must render the instant the
9
9
  * user taps upgrade.
10
10
  *
11
- * Resolves `{ status: "error" }` — never throws — when `placement` is
11
+ * Resolves `{ status: "error" }` — never throws — when `moment` is
12
12
  * absent from the catalog, or when another paywall is already being
13
13
  * presented. See `resolvePresentDecision` in `present.ts`.
14
14
  */
15
- present: (placement: string) => Promise<PresentResult>;
15
+ present: (moment: string) => Promise<PresentResult>;
16
16
  /**
17
17
  * `true` once BOTH the catalog and its products have resolved — the one
18
18
  * flag meaning "calling `present()` now will not show a spinner".
19
19
  */
20
20
  isReady: boolean;
21
- /** The full resolved catalog (every placement), or `null` before it loads. */
21
+ /** The full resolved catalog (every moment), or `null` before it loads. */
22
22
  catalog: PaywallCatalog | null;
23
23
  /**
24
24
  * What the catalog is doing, for hosts that need more than `isReady`'s one
25
25
  * bit. `"revalidating"` is the important one: the catalog on hand was served
26
- * from disk and a fresh fetch is in flight, so a placement missing from it may
26
+ * from disk and a fresh fetch is in flight, so a moment missing from it may
27
27
  * simply not have arrived yet. Gate "fall back to another engine" on
28
28
  * `"ready"`, not merely on a non-null catalog.
29
29
  */
@@ -1 +1 @@
1
- {"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACvD;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,gBAI7B,CAAC"}
1
+ {"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,gBAI7B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"expoIap.d.ts","sourceRoot":"","sources":["../../../src/products/adapters/expoIap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA8C,MAAM,UAAU,CAAC;AAyB5F,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,GAAI,MAAK,GAAS,KAAG,eAiEvD,CAAC"}
1
+ {"version":3,"file":"expoIap.d.ts","sourceRoot":"","sources":["../../../src/products/adapters/expoIap.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAA8C,MAAM,UAAU,CAAC;AA8D5F,sEAAsE;AACtE,eAAO,MAAM,sBAAsB,GAAI,MAAK,GAAS,KAAG,eAgJvD,CAAC"}
@@ -23,6 +23,40 @@ const toPeriod = (iso) => {
23
23
  // expo-iap surfaces a user cancellation as a code rather than a typed error.
24
24
  const isCancellation = (e) => (e === null || e === void 0 ? void 0 : e.code) === "E_USER_CANCELLED" || (e === null || e === void 0 ? void 0 : e.code) === "USER_CANCELED" || (e === null || e === void 0 ? void 0 : e.userCancelled) === true;
25
25
  const idFor = (ref) => react_native_1.Platform.OS === "ios" ? ref.ios : ref.android;
26
+ const ISO_UNIT = { day: "D", week: "W", month: "M", year: "Y" };
27
+ /**
28
+ * The store's billing period as an ISO-8601 duration.
29
+ *
30
+ * Load-bearing far beyond the `period` field: `deriveProductFields` computes
31
+ * `pricePerDay` / `pricePerWeek` / `pricePerMonth` / `pricePerYear` and
32
+ * `savingsPct` from `periodIso` alone. A null here does not degrade those — it
33
+ * removes them, so `{{product.yearly.pricePerWeek}}` renders EMPTY (an unknown
34
+ * variable interpolates to nothing, not to a literal) and a per-week-framed
35
+ * paywall silently loses its headline number.
36
+ *
37
+ * expo-iap has never exposed one ready-made, and the shape has moved:
38
+ * - ≤4.x published `subscriptionPeriodISO` / `subscriptionPeriod` on the product
39
+ * - 5.x publishes the iOS period SPLIT in two (`subscriptionPeriodUnitIOS`,
40
+ * `subscriptionPeriodNumberIOS`) and the Android one buried in the first
41
+ * pricing phase of the first subscription offer
42
+ * All three are read, newest-shape-last so an older peer keeps working.
43
+ */
44
+ const periodIsoFrom = (s) => {
45
+ var _a, _b, _c, _d, _e, _f, _g, _h;
46
+ const direct = (_a = s === null || s === void 0 ? void 0 : s.subscriptionPeriodISO) !== null && _a !== void 0 ? _a : s === null || s === void 0 ? void 0 : s.subscriptionPeriod;
47
+ if (typeof direct === "string" && direct)
48
+ return direct;
49
+ const unit = ISO_UNIT[String((_b = s === null || s === void 0 ? void 0 : s.subscriptionPeriodUnitIOS) !== null && _b !== void 0 ? _b : "").toLowerCase()];
50
+ if (unit) {
51
+ // `subscriptionPeriodNumberIOS` is typed as a STRING by expo-iap. Default to
52
+ // 1 rather than 0: StoreKit omits the count for a single-unit period, and
53
+ // "P0M" would make every derived price divide by zero.
54
+ const n = Number((_c = s === null || s === void 0 ? void 0 : s.subscriptionPeriodNumberIOS) !== null && _c !== void 0 ? _c : 1);
55
+ return `P${Number.isFinite(n) && n > 0 ? n : 1}${unit}`;
56
+ }
57
+ const androidPeriod = (_h = (_g = (_f = (_e = (_d = s === null || s === void 0 ? void 0 : s.subscriptionOffers) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.pricingPhasesAndroid) === null || _f === void 0 ? void 0 : _f.pricingPhaseList) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.billingPeriod;
58
+ return typeof androidPeriod === "string" && androidPeriod ? androidPeriod : null;
59
+ };
26
60
  /** Direct StoreKit / Play Billing provider, no vendor in the path. */
27
61
  const expoIapProductProvider = (Iap = IAP) => {
28
62
  const required = () => {
@@ -31,32 +65,67 @@ const expoIapProductProvider = (Iap = IAP) => {
31
65
  }
32
66
  return Iap;
33
67
  };
68
+ // Every expo-iap query fails until the store connection is open, and nothing
69
+ // opens it implicitly — `useIAP` does it for hook consumers, but this adapter
70
+ // is not a hook. Cached so concurrent getProducts/purchase/restore calls share
71
+ // one connect, and CLEARED on failure so a later call retries rather than
72
+ // replaying a rejected promise forever (a first call during airplane mode
73
+ // would otherwise poison the provider for the whole session).
74
+ let connecting = null;
75
+ const connect = async () => {
76
+ const M = required();
77
+ if (typeof M.initConnection !== "function")
78
+ return; // older peer: implicit connection
79
+ if (!connecting) {
80
+ connecting = Promise.resolve(M.initConnection()).catch((e) => {
81
+ connecting = null;
82
+ throw e;
83
+ });
84
+ }
85
+ await connecting;
86
+ };
87
+ // The raw store product per resolved productId, captured during getProducts.
88
+ // `purchase()` needs expo-iap's own `type` discriminator ("in-app" | "subs")
89
+ // and the full Purchase to finish, neither of which survives the trip through
90
+ // `ResolvedProduct`. Same pattern as stripeLink's `linkByKey`.
91
+ const rawById = new Map();
34
92
  return {
35
93
  async getProducts(refs) {
36
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
94
+ var _a, _b, _c, _d, _e, _f, _g, _h;
37
95
  const M = required();
38
96
  const wanted = refs.map((r) => ({ ref: r, id: idFor(r) })).filter((x) => !!x.id);
39
97
  if (wanted.length === 0)
40
98
  return [];
99
+ await connect();
41
100
  const skus = wanted.map((w) => w.id);
42
- const store = await M.getProducts(skus);
43
- const byId = new Map(store.map((s) => { var _a; return [(_a = s.id) !== null && _a !== void 0 ? _a : s.productId, s]; }));
101
+ // 5.x renamed `getProducts(skus)` to `fetchProducts({ skus, type })` — an
102
+ // object arg, not a positional array. Calling the old name on 5.x throws
103
+ // "M.getProducts is not a function", so probe rather than assume; `"all"`
104
+ // because a paywall mixes subscriptions and one-off lifetime products.
105
+ const store = typeof M.fetchProducts === "function"
106
+ ? await M.fetchProducts({ skus, type: "all" })
107
+ : await M.getProducts(skus);
108
+ const list = Array.isArray(store) ? store : [];
109
+ const byId = new Map(list.map((s) => { var _a; return [(_a = s.id) !== null && _a !== void 0 ? _a : s.productId, s]; }));
110
+ rawById.clear();
44
111
  const out = [];
45
112
  for (const { ref, id } of wanted) {
46
113
  const s = byId.get(id);
47
114
  if (!s)
48
115
  continue;
49
- const iso = (_b = (_a = s.subscriptionPeriodISO) !== null && _a !== void 0 ? _a : s.subscriptionPeriod) !== null && _b !== void 0 ? _b : null;
116
+ const productId = (_a = s.id) !== null && _a !== void 0 ? _a : s.productId;
117
+ rawById.set(productId, s);
118
+ const iso = periodIsoFrom(s);
50
119
  const { period, count } = toPeriod(iso);
51
120
  out.push({
52
121
  key: ref.key,
53
- productId: (_c = s.id) !== null && _c !== void 0 ? _c : s.productId,
122
+ productId,
54
123
  store: react_native_1.Platform.OS === "ios" ? "app_store" : "play_store",
55
- title: (_d = s.title) !== null && _d !== void 0 ? _d : "",
56
- description: (_e = s.description) !== null && _e !== void 0 ? _e : "",
57
- price: (_g = (_f = s.displayPrice) !== null && _f !== void 0 ? _f : s.localizedPrice) !== null && _g !== void 0 ? _g : "",
58
- priceAmount: Number((_h = s.price) !== null && _h !== void 0 ? _h : 0),
59
- currencyCode: (_k = (_j = s.currency) !== null && _j !== void 0 ? _j : s.currencyCode) !== null && _k !== void 0 ? _k : "",
124
+ title: (_b = s.title) !== null && _b !== void 0 ? _b : "",
125
+ description: (_c = s.description) !== null && _c !== void 0 ? _c : "",
126
+ price: (_e = (_d = s.displayPrice) !== null && _d !== void 0 ? _d : s.localizedPrice) !== null && _e !== void 0 ? _e : "",
127
+ priceAmount: Number((_f = s.price) !== null && _f !== void 0 ? _f : 0),
128
+ currencyCode: (_h = (_g = s.currency) !== null && _g !== void 0 ? _g : s.currencyCode) !== null && _h !== void 0 ? _h : "",
60
129
  period,
61
130
  periodCount: count,
62
131
  periodIso: iso,
@@ -65,9 +134,46 @@ const expoIapProductProvider = (Iap = IAP) => {
65
134
  return out;
66
135
  },
67
136
  async purchase(product) {
137
+ var _a;
68
138
  const M = required();
69
139
  try {
70
- await M.requestPurchase({ request: { sku: product.productId } });
140
+ await connect();
141
+ const raw = rawById.get(product.productId);
142
+ // A non-null period means a subscription even when the raw product is
143
+ // missing (a host that hydrated the runtime from elsewhere).
144
+ const isSubs = ((_a = raw === null || raw === void 0 ? void 0 : raw.type) !== null && _a !== void 0 ? _a : (product.period ? "subs" : "in-app")) === "subs";
145
+ const sku = product.productId;
146
+ // 5.x wants `{ request: { ios, android }, type }`. The old flat
147
+ // `{ request: { sku } }` reaches neither platform branch, so StoreKit is
148
+ // handed an undefined sku. `type` is required to tell a subscription
149
+ // from a one-off — Play rejects the wrong one outright.
150
+ const args = typeof M.fetchProducts === "function"
151
+ ? {
152
+ request: { ios: { sku }, android: { skus: [sku] } },
153
+ type: isSubs ? "subs" : "in-app",
154
+ }
155
+ : { request: { sku } };
156
+ const result = await M.requestPurchase(args);
157
+ // `requestPurchase` resolves `Purchase | Purchase[] | null`. `null` is
158
+ // the normal 5.x outcome: the transaction is delivered to
159
+ // `purchaseUpdatedListener` instead, so at this point nothing is
160
+ // confirmed. Reporting "purchased" there would grant access for a
161
+ // purchase that may still fail — hence "pending", which is exactly the
162
+ // outcome `PurchaseButtonAction.onPending` exists to handle.
163
+ const purchase = Array.isArray(result) ? result[0] : result;
164
+ if (!purchase)
165
+ return { status: "pending" };
166
+ // Unfinished transactions are re-delivered by StoreKit on every launch
167
+ // until finished. Best-effort: a failure here does not un-buy anything,
168
+ // so it must not turn a completed purchase into an error.
169
+ if (typeof M.finishTransaction === "function") {
170
+ try {
171
+ await M.finishTransaction({ purchase, isConsumable: false });
172
+ }
173
+ catch (_b) {
174
+ // ignore — reported as purchased, will be re-delivered and finished later
175
+ }
176
+ }
71
177
  return { status: "purchased", productKey: product.key };
72
178
  }
73
179
  catch (e) {
@@ -79,6 +185,7 @@ const expoIapProductProvider = (Iap = IAP) => {
79
185
  async restore() {
80
186
  const M = required();
81
187
  try {
188
+ await connect();
82
189
  const purchases = await M.getAvailablePurchases();
83
190
  const ids = (purchases !== null && purchases !== void 0 ? purchases : []).map((p) => { var _a; return (_a = p.id) !== null && _a !== void 0 ? _a : p.productId; }).filter(Boolean);
84
191
  return ids.length > 0
@@ -1 +1 @@
1
- {"version":3,"file":"expoIap.js","sourceRoot":"","sources":["../../../src/products/adapters/expoIap.ts"],"names":[],"mappings":";;;AAAA,+CAAwC;AAGxC,gFAAgF;AAChF,IAAI,GAAQ,CAAC;AACb,IAAI,CAAC;IACH,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAC5B,CAAC;AAAC,WAAM,CAAC;IACP,GAAG,GAAG,IAAI,CAAC;AACb,CAAC;AAED,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAmD,EAAE;;IACn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