@rocapine/react-native-onboarding 1.66.0 → 1.67.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.
package/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export type { Condition } from "./evaluateCondition";
16
16
  export type { LeafCondition, ConditionGroup, ConditionValue, ConditionOperator, Branch, NextStep, } from "./steps/common.types";
17
17
  export { BaseStepTypeSchema, LeafConditionSchema, ConditionGroupSchema, BranchSchema, NextStepSchema, ConditionOperatorSchema, ConditionValueSchema, UNARY_CONDITION_OPERATORS, isUnaryConditionOperator, ONBOARDING_END_STEP_ID, } from "./steps/common.types";
18
18
  export * from "./products";
19
- export type { Paywall, PaywallCatalog, PaywallOptions, GetPaywallsResponseHeaders, PresentResult, } from "./paywalls/types";
19
+ export type { Paywall, PaywallCatalog, PaywallOptions, GetPaywallsResponseHeaders, PresentResult, PresentErrorReason, } from "./paywalls/types";
20
20
  export { PaywallProvider, usePaywallHost } from "./paywalls/PaywallProvider";
21
21
  export type { PaywallContextValue } from "./paywalls/PaywallProvider";
22
22
  export { usePaywall } from "./paywalls/usePaywall";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,gCAAgC,EAChC,QAAQ,EACR,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,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AAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxF,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EACV,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,MAAM,EACN,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,cAAc,YAAY,CAAC;AAE3B,YAAY,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,0BAA0B,EAC1B,aAAa,EAGb,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC7E,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wBAAwB;AACxB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,0CAAwB;AACxB,uDAAqC;AACrC,8EAA8E;AAC9E,qDAGkC;AAFhC,iHAAA,qBAAqB,OAAA;AACrB,wHAAA,4BAA4B,OAAA;AAkC9B,wDAOwC;AANtC,2GAAA,kBAAkB,OAAA;AAClB,iHAAA,wBAAwB,OAAA;AACxB,sHAAA,6BAA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iHAAA,wBAAwB,OAAA;AACxB,sHAAA,6BAA6B,OAAA;AAC7B,sHAAA,6BAA6B,OAAA;AAC7B,sHAAA,6BAA6B,OAAA;AAC7B,gHAAA,uBAAuB,OAAA;AAEzB,+EAA+E;AAC/E,2EAA2E;AAC3E,qDAI+B;AAH7B,wHAAA,yBAAyB,OAAA;AACzB,wHAAA,yBAAyB,OAAA;AACzB,uHAAA,wBAAwB,OAAA;AAG1B,sBAAsB;AACtB,0CAAwB;AAGxB,0EAAyE;AAAhE,sHAAA,iBAAiB,OAAA;AAC1B,YAAY;AACZ,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,yDAAwF;AAA/E,sHAAA,iBAAiB,OAAA;AAAE,iHAAA,YAAY,OAAA;AAAE,qHAAA,gBAAgB,OAAA;AAU1D,qDAW8B;AAV5B,kHAAA,kBAAkB,OAAA;AAClB,mHAAA,mBAAmB,OAAA;AACnB,oHAAA,oBAAoB,OAAA;AACpB,4GAAA,YAAY,OAAA;AACZ,8GAAA,cAAc,OAAA;AACd,uHAAA,uBAAuB,OAAA;AACvB,oHAAA,oBAAoB,OAAA;AACpB,yHAAA,yBAAyB,OAAA;AACzB,wHAAA,wBAAwB,OAAA;AACxB,sHAAA,sBAAsB,OAAA;AAExB,oEAAoE;AACpE,6CAA2B;AAY3B,8DAA6E;AAApE,kHAAA,eAAe,OAAA;AAAE,iHAAA,cAAc,OAAA;AAExC,oDAAmD;AAA1C,wGAAA,UAAU,OAAA"}
@@ -21,6 +21,15 @@ export type PaywallContextValue = {
21
21
  * `PaywallHost`) — never from an ordinary consumer.
22
22
  */
23
23
  complete: (result: PresentResult) => void;
24
+ /**
25
+ * Called by the paywall HOST once the paywall is actually on screen (the UI
26
+ * host wires this to its Modal's `onShow`) — never by an ordinary consumer.
27
+ *
28
+ * Without it a presentation the platform silently refused is
29
+ * indistinguishable from one the user is reading, and the refused case wedges
30
+ * the surface permanently. See `shouldBreakPresentationWedge` in `present.ts`.
31
+ */
32
+ acknowledgePresentation: () => void;
24
33
  /** Forwarded into the presented paywall's `ScreenHost.customActions`. */
25
34
  customActions: CustomActions;
26
35
  };
@@ -32,7 +41,7 @@ export declare const PaywallContext: import("react").Context<PaywallContextValue
32
41
  * internals it has no reason to touch (which paywall is active, how to
33
42
  * resolve it).
34
43
  */
35
- export declare const usePaywallHost: () => Pick<PaywallContextValue, "activePaywall" | "complete" | "customActions">;
44
+ export declare const usePaywallHost: () => Pick<PaywallContextValue, "activePaywall" | "complete" | "acknowledgePresentation" | "customActions">;
36
45
  interface PaywallProviderProps {
37
46
  children: React.ReactNode;
38
47
  client: OnboardingStudioClient;
@@ -48,6 +57,16 @@ interface PaywallProviderProps {
48
57
  productProvider?: ProductProvider;
49
58
  /** Handlers for `{ type: "custom" }` ButtonActions inside a paywall's elements. */
50
59
  customActions?: CustomActions;
60
+ /**
61
+ * How long to wait for the host to confirm a paywall actually appeared
62
+ * before abandoning the presentation and resolving
63
+ * `{status:"error", reason:"host-never-presented"}`. Defaults to 5000 ms.
64
+ *
65
+ * `null` disables the recovery entirely, which reinstates the failure it
66
+ * exists to prevent: one refused presentation then disables paywalls for the
67
+ * rest of the process. Only pass `null` if the host cannot acknowledge.
68
+ */
69
+ presentAckTimeoutMs?: number | null;
51
70
  }
52
71
  /**
53
72
  * App-level ancestor. Renders ABOVE `OnboardingProvider`, not inside it —
@@ -61,6 +80,6 @@ interface PaywallProviderProps {
61
80
  * </PaywallProvider>
62
81
  * ```
63
82
  */
64
- export declare const PaywallProvider: ({ children, client, locale, customAudienceParams, productProvider, customActions, }: PaywallProviderProps) => import("react/jsx-runtime").JSX.Element;
83
+ export declare const PaywallProvider: ({ children, client, locale, customAudienceParams, productProvider, customActions, presentAckTimeoutMs, }: PaywallProviderProps) => import("react/jsx-runtime").JSX.Element;
65
84
  export {};
66
85
  //# sourceMappingURL=PaywallProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,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e,CAAC;IAClC,mFAAmF;IACnF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAoQD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,0GAQ7B,oBAAoB,4CAetB,CAAC"}
@@ -29,13 +29,23 @@ const paywallQueryClient = new react_query_1.QueryClient({
29
29
  // way `EMPTY_CUSTOM_ACTIONS` in `OnboardingProvider.tsx` documents.
30
30
  const EMPTY_CUSTOM_ACTIONS = Object.freeze({});
31
31
  const EMPTY_PAYWALL_CONTEXT = {
32
- present: async () => ({ status: "error" }),
32
+ // No provider above: there is no catalog at all, which is the same answer
33
+ // `resolvePresentDecision` gives for an unresolved one.
34
+ present: async () => ({ status: "error", reason: "unknown-placement" }),
33
35
  isReady: false,
34
36
  catalog: null,
35
37
  activePaywall: null,
36
38
  complete: () => { },
39
+ acknowledgePresentation: () => { },
37
40
  customActions: EMPTY_CUSTOM_ACTIONS,
38
41
  };
42
+ /**
43
+ * How long a presentation may go unacknowledged by the host before it is
44
+ * abandoned. Generous on purpose: a real Modal appears in well under a second,
45
+ * so this only ever elapses when the platform refused outright — and erring
46
+ * long keeps a slow-but-successful presentation from being torn down.
47
+ */
48
+ const DEFAULT_PRESENT_ACK_TIMEOUT_MS = 5000;
39
49
  exports.PaywallContext = (0, react_1.createContext)(EMPTY_PAYWALL_CONTEXT);
40
50
  /**
41
51
  * The seam a paywall HOST (Task 7's `PaywallHost`) reads from — analogous to
@@ -45,11 +55,11 @@ exports.PaywallContext = (0, react_1.createContext)(EMPTY_PAYWALL_CONTEXT);
45
55
  * resolve it).
46
56
  */
47
57
  const usePaywallHost = () => {
48
- const { activePaywall, complete, customActions } = (0, react_1.useContext)(exports.PaywallContext);
49
- return { activePaywall, complete, customActions };
58
+ const { activePaywall, complete, acknowledgePresentation, customActions } = (0, react_1.useContext)(exports.PaywallContext);
59
+ return { activePaywall, complete, acknowledgePresentation, customActions };
50
60
  };
51
61
  exports.usePaywallHost = usePaywallHost;
52
- const PaywallProviderInner = ({ children, client, locale, customAudienceParams, productProvider, customActions, }) => {
62
+ const PaywallProviderInner = ({ children, client, locale, customAudienceParams, productProvider, customActions, presentAckTimeoutMs, }) => {
53
63
  var _a;
54
64
  // `data` straight off `useQuery` is the single source of truth (Finding 1,
55
65
  // 2026-08-17 final review) — react-query's own cache already gets both a
@@ -113,6 +123,10 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
113
123
  }, [productRuntime.purchase]);
114
124
  const productRuntimeWithPurchaseTracking = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, productRuntime), { purchase })), [productRuntime, purchase]);
115
125
  const [activePlacement, setActivePlacement] = (0, react_1.useState)(null);
126
+ // Whether the host has confirmed THIS presentation is on screen. State, not
127
+ // a ref, because the timeout effect below must re-run (and cancel) the moment
128
+ // it flips.
129
+ const [hostAcknowledged, setHostAcknowledged] = (0, react_1.useState)(false);
116
130
  // Refs so `present`/`complete` stay referentially stable (empty deps) while
117
131
  // still reading current state — same pattern `useProducts.ts` uses for its
118
132
  // `purchase`/`restore` callbacks.
@@ -154,6 +168,10 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
154
168
  activePlacementRef.current = placement;
155
169
  return new Promise((resolve) => {
156
170
  pendingResolveRef.current = resolve;
171
+ // A new presentation is unacknowledged until the host says otherwise —
172
+ // reset before it starts, or the previous presentation's confirmation
173
+ // would vouch for this one and disable the recovery.
174
+ setHostAcknowledged(false);
157
175
  setActivePlacement(placement);
158
176
  });
159
177
  }, []);
@@ -177,8 +195,14 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
177
195
  // next commit.
178
196
  activePlacementRef.current = null;
179
197
  setActivePlacement(null);
198
+ setHostAcknowledged(false);
180
199
  resolve === null || resolve === void 0 ? void 0 : resolve((0, present_1.resolvePresentedOutcome)(result, lastPurchaseOutcomeRef.current));
181
200
  }, []);
201
+ // Stable (empty deps) like `present`/`complete`: the host wires this straight
202
+ // into a Modal prop, and an identity change per render would churn it.
203
+ const acknowledgePresentation = (0, react_1.useCallback)(() => {
204
+ setHostAcknowledged(true);
205
+ }, []);
182
206
  const activePaywall = activePlacement ? (_a = catalog === null || catalog === void 0 ? void 0 : catalog.paywalls[activePlacement]) !== null && _a !== void 0 ? _a : null : null;
183
207
  // Finding 6, 2026-08-17 final review, widened by N2 (round 2): a background
184
208
  // catalog revalidation (see `getPaywalls.query.ts`) can push a fresh catalog
@@ -202,10 +226,46 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
202
226
  (0, react_1.useEffect)(() => {
203
227
  if (!activePlacement || activePaywall)
204
228
  return;
205
- complete({ status: "error" });
229
+ complete({ status: "error", reason: "paywall-disappeared" });
206
230
  }, [activePlacement, activePaywall, complete]);
231
+ // The OTHER way a presentation never completes, and the one the guard above
232
+ // structurally cannot catch: `activePaywall` is perfectly non-null — the
233
+ // catalog still holds the paywall — but it never reaches the screen because
234
+ // the platform refused to present it (iOS will not present over an
235
+ // already-presenting view controller: another Modal, a
236
+ // `presentation: "modal"` route, a StoreKit alert). Nothing calls
237
+ // `complete()`, so without this the pending promise never settles,
238
+ // `activePlacement` stays set for the life of the process, and every later
239
+ // `present()` — for any placement — resolves "already-presenting" with no
240
+ // error and no log. Confirmed in production on a monetisation surface, which
241
+ // is why this recovers rather than merely reports.
242
+ //
243
+ // Cancels itself as soon as the host acknowledges, so a paywall a user is
244
+ // reading is never torn down; see `shouldBreakPresentationWedge`.
245
+ (0, react_1.useEffect)(() => {
246
+ if (presentAckTimeoutMs === null)
247
+ return;
248
+ if (!(0, present_1.shouldBreakPresentationWedge)(activePlacement, hostAcknowledged, true))
249
+ return;
250
+ const timer = setTimeout(() => {
251
+ console.warn(`[paywalls] "${activePlacement}" was never confirmed on screen within ` +
252
+ `${presentAckTimeoutMs}ms and has been abandoned, so later present() calls keep working. ` +
253
+ "The platform most likely refused to present it — on iOS, something else was already " +
254
+ "presenting (another Modal, a `presentation: \"modal\"` route, or a StoreKit alert).");
255
+ complete({ status: "error", reason: "host-never-presented" });
256
+ }, presentAckTimeoutMs);
257
+ return () => clearTimeout(timer);
258
+ }, [activePlacement, hostAcknowledged, presentAckTimeoutMs, complete]);
207
259
  const isReady = (0, react_1.useMemo)(() => (0, present_1.computeIsReady)(catalog, productRefs, productRuntime.status), [catalog, productRefs, productRuntime.status]);
208
- const contextValue = (0, react_1.useMemo)(() => ({ present, isReady, catalog, activePaywall, complete, customActions }), [present, isReady, catalog, activePaywall, complete, customActions]);
260
+ const contextValue = (0, react_1.useMemo)(() => ({
261
+ present,
262
+ isReady,
263
+ catalog,
264
+ activePaywall,
265
+ complete,
266
+ acknowledgePresentation,
267
+ customActions,
268
+ }), [present, isReady, catalog, activePaywall, complete, acknowledgePresentation, customActions]);
209
269
  return ((0, jsx_runtime_1.jsx)(ProductRuntimeContext_1.ProductRuntimeContext.Provider, { value: productRuntimeWithPurchaseTracking, children: (0, jsx_runtime_1.jsx)(exports.PaywallContext.Provider, { value: contextValue, children: children }) }));
210
270
  };
211
271
  /**
@@ -220,8 +280,8 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
220
280
  * </PaywallProvider>
221
281
  * ```
222
282
  */
223
- const PaywallProvider = ({ children, client, locale = "en", customAudienceParams = {}, productProvider, customActions = EMPTY_CUSTOM_ACTIONS, }) => {
224
- return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: paywallQueryClient, children: (0, jsx_runtime_1.jsx)(PaywallProviderInner, { client: client, locale: locale, customAudienceParams: customAudienceParams, productProvider: productProvider, customActions: customActions, children: children }) }));
283
+ const PaywallProvider = ({ children, client, locale = "en", customAudienceParams = {}, productProvider, customActions = EMPTY_CUSTOM_ACTIONS, presentAckTimeoutMs = DEFAULT_PRESENT_ACK_TIMEOUT_MS, }) => {
284
+ return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: paywallQueryClient, children: (0, jsx_runtime_1.jsx)(PaywallProviderInner, { client: client, locale: locale, customAudienceParams: customAudienceParams, productProvider: productProvider, customActions: customActions, presentAckTimeoutMs: presentAckTimeoutMs, children: children }) }));
225
285
  };
226
286
  exports.PaywallProvider = PaywallProvider;
227
287
  //# sourceMappingURL=PaywallProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaywallProvider.js","sourceRoot":"","sources":["../../src/paywalls/PaywallProvider.tsx"],"names":[],"mappings":";;;;AAAA,iCAAqG;AACrG,uDAAmF;AAEnF,2DAAuD;AAEvD,uCAQmB;AACnB,yDAAsD;AAEtD,6EAA0E;AAG1E,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,0EAA0E;AAC1E,iEAAiE;AACjE,yDAAyD;AACzD,gCAAgC;AAChC,MAAM,kBAAkB,GAAG,IAAI,yBAAW,CAAC;IACzC,cAAc,EAAE;QACd,OAAO,EAAE;YACP,SAAS,EAAE,QAAQ;SACpB;KACF;CACF,CAAC,CAAC;AAEH,wEAAwE;AACxE,0EAA0E;AAC1E,6EAA6E;AAC7E,2EAA2E;AAC3E,oEAAoE;AACpE,MAAM,oBAAoB,GAAkB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAyB9D,MAAM,qBAAqB,GAAwB;IACjD,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC1C,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,aAAa,EAAE,oBAAoB;CACpC,CAAC;AAEW,QAAA,cAAc,GAAG,IAAA,qBAAa,EAAsB,qBAAqB,CAAC,CAAC;AAExF;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,GAA8E,EAAE;IAC5G,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAA,kBAAU,E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A,wBAAc,EAAC,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,EACjE,CAAC,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAC9C,CAAC;IAEF,MAAM,YAAY,GAAG,IAAA,eAAO,EAC1B,GAAG,EAAE,CAAC,CAAC;QACL,OAAO;QACP,OAAO;QACP,OAAO;QACP,aAAa;QACb,QAAQ;QACR,uBAAuB;QACvB,aAAa;KACd,CAAC,EACF,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,uBAAuB,EAAE,aAAa,CAAC,CAC7F,CAAC;IAEF,OAAO,CACL,uBAAC,6CAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,kCAAkC,YACvE,uBAAC,sBAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAAG,QAAQ,GAA2B,GACnD,CAClC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACI,MAAM,eAAe,GAAG,CAAC,EAC9B,QAAQ,EACR,MAAM,EACN,MAAM,GAAG,IAAI,EACb,oBAAoB,GAAG,EAAE,EACzB,eAAe,EACf,aAAa,GAAG,oBAAoB,EACpC,mBAAmB,GAAG,8BAA8B,GAC/B,EAAE,EAAE;IACzB,OAAO,CACL,uBAAC,iCAAmB,IAAC,MAAM,EAAE,kBAAkB,YAC7C,uBAAC,oBAAoB,IACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,oBAAoB,EAC1C,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,YAEvC,QAAQ,GACY,GACH,CACvB,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,eAAe,mBAuB1B"}
@@ -40,6 +40,30 @@ export type PresentDecision = {
40
40
  * throw" contract as the unknown-placement case, consistently.
41
41
  */
42
42
  export declare const resolvePresentDecision: (catalog: PaywallCatalog | null, activePlacement: string | null, placement: string) => PresentDecision;
43
+ /**
44
+ * Whether an in-progress presentation should be abandoned because the host
45
+ * never confirmed it appeared.
46
+ *
47
+ * The failure this recovers from, observed in production: iOS refuses to
48
+ * present a view controller over one that is already presenting — another
49
+ * `Modal`, a `presentation: "modal"` route, a StoreKit alert. `present()` has
50
+ * already set `activePlacement` by then, but the host's Modal never actually
51
+ * appears, so nothing ever calls `complete()`. The pending promise never
52
+ * settles and `activePlacement` stays set for the life of the process, which
53
+ * makes EVERY later `present()` resolve `"already-presenting"` — for any
54
+ * placement, silently, on a monetisation surface.
55
+ *
56
+ * The sibling self-heal in `PaywallProvider` cannot cover it: that one requires
57
+ * `activePaywall` to be null, and here it is non-null (the catalog still holds
58
+ * the paywall perfectly well — only the platform refused to show it).
59
+ *
60
+ * Why an ACKNOWLEDGEMENT and not a bare timeout: a paywall a user is reading
61
+ * legitimately stays active for minutes, so elapsed time alone cannot
62
+ * distinguish "still on screen" from "never appeared". The host confirms
63
+ * presentation (the UI host wires this to its Modal's `onShow`), and only an
64
+ * unacknowledged presentation is ever torn down.
65
+ */
66
+ export declare const shouldBreakPresentationWedge: (activePlacement: string | null, hostAcknowledged: boolean, timedOut: boolean) => boolean;
43
67
  /**
44
68
  * `isReady` = catalog resolved AND products resolved — the one flag a caller
45
69
  * needs to know "presenting now will not show a spinner".
@@ -1 +1 @@
1
- {"version":3,"file":"present.d.ts","sourceRoot":"","sources":["../../src/paywalls/present.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,cAAc,GAAG,IAAI,KAAG,UAAU,EAa7E,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,eAAe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ACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,cAAc,GAAG,IAAI,EAC9B,iBAAiB,MAAM,GAAG,IAAI,EAC9B,WAAW,MAAM,KAChB,eAaF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,4BAA4B,GACvC,iBAAiB,MAAM,GAAG,IAAI,EAC9B,kBAAkB,OAAO,EACzB,UAAU,OAAO,KAChB,OAAoE,CAAC;AAExE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,SAAS,cAAc,GAAG,IAAI,EAC9B,aAAa,UAAU,EAAE,EACzB,gBAAgB,aAAa,KAC5B,OAAuF,CAAC;AAE3F;;;;;;;;;GASG;AACH,MAAM,MAAM,iCAAiC,GAAG,WAAW,GAAG,WAAW,GAAG,IAAI,CAAC;AAEjF,2FAA2F;AAC3F,eAAO,MAAM,yBAAyB,GAAI,QAAQ,cAAc,KAAG,iCACoB,CAAC;AAExF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,aAAa,EACvB,iBAAiB,iCAAiC,KACjD,aAC0F,CAAC;AAE9F;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,2BAA2B,GACtC,qBAAqB,MAAM,EAC3B,mBAAmB,MAAM,KACxB,OAAoD,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldRecordPurchaseOutcome = exports.resolvePresentedOutcome = exports.purchaseOutcomeFromResult = exports.computeIsReady = exports.resolvePresentDecision = exports.collectProductRefs = void 0;
3
+ exports.shouldRecordPurchaseOutcome = exports.resolvePresentedOutcome = exports.purchaseOutcomeFromResult = exports.computeIsReady = exports.shouldBreakPresentationWedge = exports.resolvePresentDecision = exports.collectProductRefs = void 0;
4
4
  /**
5
5
  * Union of every `paywall.products[]` across the WHOLE catalog, deduplicated
6
6
  * by content — the same identity notion `useProducts`' `refsKey` uses
@@ -51,15 +51,44 @@ exports.collectProductRefs = collectProductRefs;
51
51
  */
52
52
  const resolvePresentDecision = (catalog, activePlacement, placement) => {
53
53
  if (activePlacement !== null) {
54
- return { type: "immediate", result: { status: "error" } };
54
+ // `activePlacement` is echoed back deliberately — see PresentErrorReason.
55
+ return {
56
+ type: "immediate",
57
+ result: { status: "error", reason: "already-presenting", activePlacement },
58
+ };
55
59
  }
56
60
  const paywall = catalog === null || catalog === void 0 ? void 0 : catalog.paywalls[placement];
57
61
  if (!paywall) {
58
- return { type: "immediate", result: { status: "error" } };
62
+ return { type: "immediate", result: { status: "error", reason: "unknown-placement" } };
59
63
  }
60
64
  return { type: "start", paywall };
61
65
  };
62
66
  exports.resolvePresentDecision = resolvePresentDecision;
67
+ /**
68
+ * Whether an in-progress presentation should be abandoned because the host
69
+ * never confirmed it appeared.
70
+ *
71
+ * The failure this recovers from, observed in production: iOS refuses to
72
+ * present a view controller over one that is already presenting — another
73
+ * `Modal`, a `presentation: "modal"` route, a StoreKit alert. `present()` has
74
+ * already set `activePlacement` by then, but the host's Modal never actually
75
+ * appears, so nothing ever calls `complete()`. The pending promise never
76
+ * settles and `activePlacement` stays set for the life of the process, which
77
+ * makes EVERY later `present()` resolve `"already-presenting"` — for any
78
+ * placement, silently, on a monetisation surface.
79
+ *
80
+ * The sibling self-heal in `PaywallProvider` cannot cover it: that one requires
81
+ * `activePaywall` to be null, and here it is non-null (the catalog still holds
82
+ * the paywall perfectly well — only the platform refused to show it).
83
+ *
84
+ * Why an ACKNOWLEDGEMENT and not a bare timeout: a paywall a user is reading
85
+ * legitimately stays active for minutes, so elapsed time alone cannot
86
+ * distinguish "still on screen" from "never appeared". The host confirms
87
+ * presentation (the UI host wires this to its Modal's `onShow`), and only an
88
+ * unacknowledged presentation is ever torn down.
89
+ */
90
+ const shouldBreakPresentationWedge = (activePlacement, hostAcknowledged, timedOut) => activePlacement !== null && !hostAcknowledged && timedOut;
91
+ exports.shouldBreakPresentationWedge = shouldBreakPresentationWedge;
63
92
  /**
64
93
  * `isReady` = catalog resolved AND products resolved — the one flag a caller
65
94
  * needs to know "presenting now will not show a spinner".
@@ -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,EA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,uBAAuB,GAAG,CACrC,QAAuB,EACvB,eAAkD,EACnC,EAAE,CACjB,QAAQ,CAAC,MAAM,KAAK,WAAW,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAJjF,QAAA,uBAAuB,2BAI0D;AAE9F;;;;;;;;;;;;;;;GAeG;AACI,MAAM,2BAA2B,GAAG,CACzC,mBAA2B,EAC3B,iBAAyB,EAChB,EAAE,CAAC,mBAAmB,KAAK,iBAAiB,CAAC;AAH3C,QAAA,2BAA2B,+BAGgB"}
@@ -89,7 +89,50 @@ export interface GetPaywallsResponseHeaders {
89
89
  * Entitlement belongs to the store — read it from the `ProductProvider` /
90
90
  * billing SDK, and use this only to decide what the UI does next.
91
91
  */
92
+ /**
93
+ * Why a presentation resolved `"error"`. Present on every `"error"` result and
94
+ * absent on every other status.
95
+ *
96
+ * This exists because `"error"` alone conflates conditions whose correct
97
+ * recovery is OPPOSITE. `"unknown-placement"` means the catalog may simply not
98
+ * have arrived yet, so retrying later is right. `"already-presenting"` means a
99
+ * presentation is in progress, so retrying is wrong and something may be
100
+ * stuck. A caller given only the status can act correctly on neither, and two
101
+ * separate multi-hour production investigations were spent reconstructing by
102
+ * elimination what the SDK already knew here.
103
+ *
104
+ * - `unknown-placement` — absent from the catalog, or the catalog has not
105
+ * resolved yet. The two are indistinguishable at this layer, and both are
106
+ * 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
109
+ * caller double-called and wants its own in-flight guard, a different one
110
+ * means something else holds the surface.
111
+ * - `parse-error` — `elements` failed the UI schema, so the Modal was never
112
+ * opened. A CMS **data** bug (a wrong enum value, say), not a code bug; the
113
+ * host cannot fix it and the authoring tool must. The UI host logs the
114
+ * validation issues alongside this.
115
+ * - `render-error` — the element tree threw while rendering and the error
116
+ * boundary settled the promise rather than trapping the user behind an
117
+ * escape-less fullScreen Modal.
118
+ * - `host-never-presented` — the host never confirmed the paywall appeared
119
+ * within the acknowledgement window, so the presentation was abandoned to
120
+ * keep the surface usable. In practice the platform refused to present
121
+ * (iOS will not present over an already-presenting view controller — another
122
+ * Modal, a `presentation: "modal"` route, a StoreKit alert).
123
+ * - `paywall-disappeared` — the placement vanished from the catalog while it
124
+ * was on screen (a studio publish, or a query-key change mid-presentation).
125
+ */
126
+ export type PresentErrorReason = "unknown-placement" | "already-presenting" | "parse-error" | "render-error" | "host-never-presented" | "paywall-disappeared";
92
127
  export type PresentResult = {
93
128
  status: "purchased" | "dismissed" | "cancelled" | "error";
129
+ /** Why it failed. Set on `"error"` only — see `PresentErrorReason`. */
130
+ reason?: PresentErrorReason;
131
+ /**
132
+ * The placement currently being presented. Set only alongside
133
+ * `reason: "already-presenting"`, where knowing WHICH placement holds the
134
+ * surface is what distinguishes a caller double-call from an unrelated stall.
135
+ */
136
+ activePlacement?: string;
94
137
  };
95
138
  //# 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,KAAK,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,cAAc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+45,8 @@ import type { ProductRuntime } from "./types";
45
45
  * `"idle"` for the local runtime (it bails before ever calling a provider it
46
46
  * doesn't have — `useProducts.ts`), and a naive `mergeStatus` would drag the
47
47
  * context runtime's `"ready"` down to `"idle"` FOREVER, closing every
48
- * `renderWhen: {"products.loaded": {eq:"true"}}` gate for good — the same
48
+ * `renderWhen: {variable:"products.loaded",operator:"eq",value:"true"}`
49
+ * gate for good — the same
49
50
  * "idle blocks readiness when there's nothing to actually wait for" trap
50
51
  * `computeIsReady` (`present.ts`) already special-cases for an empty ref set.
51
52
  * When there is no local provider, the local runtime has nothing pending, so
@@ -1 +1 @@
1
- {"version":3,"file":"mergeProductRuntimes.d.ts","sourceRoot":"","sources":["../../src/products/mergeProductRuntimes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AAS7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,cAAc,EAC9B,cAAc,cAAc,EAC5B,cAAc,OAAO,EACrB,kBAAkB,OAAO,KACxB,cAWF,CAAC"}
1
+ {"version":3,"file":"mergeProductRuntimes.d.ts","sourceRoot":"","sources":["../../src/products/mergeProductRuntimes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AAS7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,eAAO,MAAM,oBAAoB,GAC/B,gBAAgB,cAAc,EAC9B,cAAc,cAAc,EAC5B,cAAc,OAAO,EACrB,kBAAkB,OAAO,KACxB,cAWF,CAAC"}
@@ -56,7 +56,8 @@ const mergeStatus = (a, b) => {
56
56
  * `"idle"` for the local runtime (it bails before ever calling a provider it
57
57
  * doesn't have — `useProducts.ts`), and a naive `mergeStatus` would drag the
58
58
  * context runtime's `"ready"` down to `"idle"` FOREVER, closing every
59
- * `renderWhen: {"products.loaded": {eq:"true"}}` gate for good — the same
59
+ * `renderWhen: {variable:"products.loaded",operator:"eq",value:"true"}`
60
+ * gate for good — the same
60
61
  * "idle blocks readiness when there's nothing to actually wait for" trap
61
62
  * `computeIsReady` (`present.ts`) already special-cases for an empty ref set.
62
63
  * When there is no local provider, the local runtime has nothing pending, so
@@ -1 +1 @@
1
- {"version":3,"file":"mergeProductRuntimes.js","sourceRoot":"","sources":["../../src/products/mergeProductRuntimes.ts"],"names":[],"mappings":";;;AAEA,MAAM,WAAW,GAAG,CAAC,CAAgB,EAAE,CAAgB,EAAiB,EAAE;IACxE,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACnD,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACnD,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACI,MAAM,oBAAoB,GAAG,CAClC,cAA8B,EAC9B,YAA4B,EAC5B,YAAqB,EACrB,gBAAyB,EACT,EAAE;;IAClB,IAAI,CAAC,YAAY;QAAE,OAAO,cAAc,CAAC;IACzC,OAAO;QACL,QAAQ,kCAAO,cAAc,CAAC,QAAQ,GAAK,YAAY,CAAC,QAAQ,CAAE;QAClE,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM;QAC1G,KAAK,EAAE,MAAA,cAAc,CAAC,KAAK,mCAAI,YAAY,CAAC,KAAK;QACjD,UAAU,EAAE,cAAc,CAAC,UAAU,IAAI,Y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Y,CAAC,KAAK;QACjD,UAAU,EAAE,cAAc,CAAC,UAAU,IAAI,YAAY,CAAC,UAAU;QAChE,QAAQ,EAAE,CAAC,GAAW,EAAE,EAAE,CACxB,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC;QAC1F,OAAO,EAAE,cAAc,CAAC,OAAO;KAChC,CAAC;AACJ,CAAC,CAAC;AAhBW,QAAA,oBAAoB,wBAgB/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocapine/react-native-onboarding",
3
- "version": "1.66.0",
3
+ "version": "1.67.0",
4
4
  "description": "Headless React Native SDK for Rocapine Onboarding Studio - Data fetching, state management, and hooks",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -94,6 +94,9 @@ export type {
94
94
  PaywallOptions,
95
95
  GetPaywallsResponseHeaders,
96
96
  PresentResult,
97
+ // Exported so a host can switch exhaustively on WHY a presentation failed
98
+ // rather than pattern-matching the message.
99
+ PresentErrorReason,
97
100
  } from "./paywalls/types";
98
101
  export { PaywallProvider, usePaywallHost } from "./paywalls/PaywallProvider";
99
102
  export type { PaywallContextValue } from "./paywalls/PaywallProvider";
@@ -8,6 +8,7 @@ import {
8
8
  computeIsReady,
9
9
  purchaseOutcomeFromResult,
10
10
  resolvePresentDecision,
11
+ shouldBreakPresentationWedge,
11
12
  resolvePresentedOutcome,
12
13
  shouldRecordPurchaseOutcome,
13
14
  type PurchaseOutcomeDuringPresentation,
@@ -58,19 +59,39 @@ export type PaywallContextValue = {
58
59
  * `PaywallHost`) — never from an ordinary consumer.
59
60
  */
60
61
  complete: (result: PresentResult) => void;
62
+ /**
63
+ * Called by the paywall HOST once the paywall is actually on screen (the UI
64
+ * host wires this to its Modal's `onShow`) — never by an ordinary consumer.
65
+ *
66
+ * Without it a presentation the platform silently refused is
67
+ * indistinguishable from one the user is reading, and the refused case wedges
68
+ * the surface permanently. See `shouldBreakPresentationWedge` in `present.ts`.
69
+ */
70
+ acknowledgePresentation: () => void;
61
71
  /** Forwarded into the presented paywall's `ScreenHost.customActions`. */
62
72
  customActions: CustomActions;
63
73
  };
64
74
 
65
75
  const EMPTY_PAYWALL_CONTEXT: PaywallContextValue = {
66
- present: async () => ({ status: "error" }),
76
+ // No provider above: there is no catalog at all, which is the same answer
77
+ // `resolvePresentDecision` gives for an unresolved one.
78
+ present: async () => ({ status: "error", reason: "unknown-placement" }),
67
79
  isReady: false,
68
80
  catalog: null,
69
81
  activePaywall: null,
70
82
  complete: () => {},
83
+ acknowledgePresentation: () => {},
71
84
  customActions: EMPTY_CUSTOM_ACTIONS,
72
85
  };
73
86
 
87
+ /**
88
+ * How long a presentation may go unacknowledged by the host before it is
89
+ * abandoned. Generous on purpose: a real Modal appears in well under a second,
90
+ * so this only ever elapses when the platform refused outright — and erring
91
+ * long keeps a slow-but-successful presentation from being torn down.
92
+ */
93
+ const DEFAULT_PRESENT_ACK_TIMEOUT_MS = 5000;
94
+
74
95
  export const PaywallContext = createContext<PaywallContextValue>(EMPTY_PAYWALL_CONTEXT);
75
96
 
76
97
  /**
@@ -80,9 +101,13 @@ export const PaywallContext = createContext<PaywallContextValue>(EMPTY_PAYWALL_C
80
101
  * internals it has no reason to touch (which paywall is active, how to
81
102
  * resolve it).
82
103
  */
83
- export const usePaywallHost = (): Pick<PaywallContextValue, "activePaywall" | "complete" | "customActions"> => {
84
- const { activePaywall, complete, customActions } = useContext(PaywallContext);
85
- return { activePaywall, complete, customActions };
104
+ export const usePaywallHost = (): Pick<
105
+ PaywallContextValue,
106
+ "activePaywall" | "complete" | "acknowledgePresentation" | "customActions"
107
+ > => {
108
+ const { activePaywall, complete, acknowledgePresentation, customActions } =
109
+ useContext(PaywallContext);
110
+ return { activePaywall, complete, acknowledgePresentation, customActions };
86
111
  };
87
112
 
88
113
  interface PaywallProviderProps {
@@ -100,6 +125,16 @@ interface PaywallProviderProps {
100
125
  productProvider?: ProductProvider;
101
126
  /** Handlers for `{ type: "custom" }` ButtonActions inside a paywall's elements. */
102
127
  customActions?: CustomActions;
128
+ /**
129
+ * How long to wait for the host to confirm a paywall actually appeared
130
+ * before abandoning the presentation and resolving
131
+ * `{status:"error", reason:"host-never-presented"}`. Defaults to 5000 ms.
132
+ *
133
+ * `null` disables the recovery entirely, which reinstates the failure it
134
+ * exists to prevent: one refused presentation then disables paywalls for the
135
+ * rest of the process. Only pass `null` if the host cannot acknowledge.
136
+ */
137
+ presentAckTimeoutMs?: number | null;
103
138
  }
104
139
 
105
140
  interface PaywallProviderInnerProps {
@@ -109,6 +144,7 @@ interface PaywallProviderInnerProps {
109
144
  customAudienceParams: Record<string, any>;
110
145
  productProvider?: ProductProvider;
111
146
  customActions: CustomActions;
147
+ presentAckTimeoutMs: number | null;
112
148
  }
113
149
 
114
150
  const PaywallProviderInner = ({
@@ -118,6 +154,7 @@ const PaywallProviderInner = ({
118
154
  customAudienceParams,
119
155
  productProvider,
120
156
  customActions,
157
+ presentAckTimeoutMs,
121
158
  }: PaywallProviderInnerProps) => {
122
159
  // `data` straight off `useQuery` is the single source of truth (Finding 1,
123
160
  // 2026-08-17 final review) — react-query's own cache already gets both a
@@ -194,6 +231,10 @@ const PaywallProviderInner = ({
194
231
  );
195
232
 
196
233
  const [activePlacement, setActivePlacement] = useState<string | null>(null);
234
+ // Whether the host has confirmed THIS presentation is on screen. State, not
235
+ // a ref, because the timeout effect below must re-run (and cancel) the moment
236
+ // it flips.
237
+ const [hostAcknowledged, setHostAcknowledged] = useState(false);
197
238
  // Refs so `present`/`complete` stay referentially stable (empty deps) while
198
239
  // still reading current state — same pattern `useProducts.ts` uses for its
199
240
  // `purchase`/`restore` callbacks.
@@ -236,6 +277,10 @@ const PaywallProviderInner = ({
236
277
  activePlacementRef.current = placement;
237
278
  return new Promise<PresentResult>((resolve) => {
238
279
  pendingResolveRef.current = resolve;
280
+ // A new presentation is unacknowledged until the host says otherwise —
281
+ // reset before it starts, or the previous presentation's confirmation
282
+ // would vouch for this one and disable the recovery.
283
+ setHostAcknowledged(false);
239
284
  setActivePlacement(placement);
240
285
  });
241
286
  }, []);
@@ -260,9 +305,16 @@ const PaywallProviderInner = ({
260
305
  // next commit.
261
306
  activePlacementRef.current = null;
262
307
  setActivePlacement(null);
308
+ setHostAcknowledged(false);
263
309
  resolve?.(resolvePresentedOutcome(result, lastPurchaseOutcomeRef.current));
264
310
  }, []);
265
311
 
312
+ // Stable (empty deps) like `present`/`complete`: the host wires this straight
313
+ // into a Modal prop, and an identity change per render would churn it.
314
+ const acknowledgePresentation = useCallback(() => {
315
+ setHostAcknowledged(true);
316
+ }, []);
317
+
266
318
  const activePaywall = activePlacement ? catalog?.paywalls[activePlacement] ?? null : null;
267
319
 
268
320
  // Finding 6, 2026-08-17 final review, widened by N2 (round 2): a background
@@ -286,17 +338,54 @@ const PaywallProviderInner = ({
286
338
  // pending promise, so it cannot race with or double-resolve this branch.
287
339
  useEffect(() => {
288
340
  if (!activePlacement || activePaywall) return;
289
- complete({ status: "error" });
341
+ complete({ status: "error", reason: "paywall-disappeared" });
290
342
  }, [activePlacement, activePaywall, complete]);
291
343
 
344
+ // The OTHER way a presentation never completes, and the one the guard above
345
+ // structurally cannot catch: `activePaywall` is perfectly non-null — the
346
+ // catalog still holds the paywall — but it never reaches the screen because
347
+ // the platform refused to present it (iOS will not present over an
348
+ // already-presenting view controller: another Modal, a
349
+ // `presentation: "modal"` route, a StoreKit alert). Nothing calls
350
+ // `complete()`, so without this the pending promise never settles,
351
+ // `activePlacement` stays set for the life of the process, and every later
352
+ // `present()` — for any placement — resolves "already-presenting" with no
353
+ // error and no log. Confirmed in production on a monetisation surface, which
354
+ // is why this recovers rather than merely reports.
355
+ //
356
+ // Cancels itself as soon as the host acknowledges, so a paywall a user is
357
+ // reading is never torn down; see `shouldBreakPresentationWedge`.
358
+ useEffect(() => {
359
+ if (presentAckTimeoutMs === null) return;
360
+ if (!shouldBreakPresentationWedge(activePlacement, hostAcknowledged, true)) return;
361
+ const timer = setTimeout(() => {
362
+ console.warn(
363
+ `[paywalls] "${activePlacement}" was never confirmed on screen within ` +
364
+ `${presentAckTimeoutMs}ms and has been abandoned, so later present() calls keep working. ` +
365
+ "The platform most likely refused to present it — on iOS, something else was already " +
366
+ "presenting (another Modal, a `presentation: \"modal\"` route, or a StoreKit alert).",
367
+ );
368
+ complete({ status: "error", reason: "host-never-presented" });
369
+ }, presentAckTimeoutMs);
370
+ return () => clearTimeout(timer);
371
+ }, [activePlacement, hostAcknowledged, presentAckTimeoutMs, complete]);
372
+
292
373
  const isReady = useMemo(
293
374
  () => computeIsReady(catalog, productRefs, productRuntime.status),
294
375
  [catalog, productRefs, productRuntime.status]
295
376
  );
296
377
 
297
378
  const contextValue = useMemo<PaywallContextValue>(
298
- () => ({ present, isReady, catalog, activePaywall, complete, customActions }),
299
- [present, isReady, catalog, activePaywall, complete, customActions]
379
+ () => ({
380
+ present,
381
+ isReady,
382
+ catalog,
383
+ activePaywall,
384
+ complete,
385
+ acknowledgePresentation,
386
+ customActions,
387
+ }),
388
+ [present, isReady, catalog, activePaywall, complete, acknowledgePresentation, customActions]
300
389
  );
301
390
 
302
391
  return (
@@ -325,6 +414,7 @@ export const PaywallProvider = ({
325
414
  customAudienceParams = {},
326
415
  productProvider,
327
416
  customActions = EMPTY_CUSTOM_ACTIONS,
417
+ presentAckTimeoutMs = DEFAULT_PRESENT_ACK_TIMEOUT_MS,
328
418
  }: PaywallProviderProps) => {
329
419
  return (
330
420
  <QueryClientProvider client={paywallQueryClient}>
@@ -334,6 +424,7 @@ export const PaywallProvider = ({
334
424
  customAudienceParams={customAudienceParams}
335
425
  productProvider={productProvider}
336
426
  customActions={customActions}
427
+ presentAckTimeoutMs={presentAckTimeoutMs}
337
428
  >
338
429
  {children}
339
430
  </PaywallProviderInner>
@@ -5,6 +5,7 @@ import {
5
5
  purchaseOutcomeFromResult,
6
6
  resolvePresentDecision,
7
7
  resolvePresentedOutcome,
8
+ shouldBreakPresentationWedge,
8
9
  shouldRecordPurchaseOutcome,
9
10
  } from "../present";
10
11
  import type { Paywall, PaywallCatalog } from "../types";
@@ -81,26 +82,94 @@ describe("resolvePresentDecision", () => {
81
82
  expect(decision).toEqual({ type: "start", paywall });
82
83
  });
83
84
 
84
- it("resolves 'error' immediately when the placement is absent from the catalog", () => {
85
+ // Every error below carries a `reason`. The bare `{status:"error"}` these
86
+ // used to assert is what made two conditions with OPPOSITE correct responses
87
+ // — "retry later, the catalog may still arrive" vs "do not retry, something
88
+ // is stuck" — indistinguishable to the caller.
89
+ it("resolves 'unknown-placement' when the placement is absent from the catalog", () => {
85
90
  const decision = resolvePresentDecision(catalog, null, "does_not_exist");
86
- expect(decision).toEqual({ type: "immediate", result: { status: "error" } });
91
+ expect(decision).toEqual({
92
+ type: "immediate",
93
+ result: { status: "error", reason: "unknown-placement" },
94
+ });
87
95
  });
88
96
 
89
- it("resolves 'error' immediately when the catalog has not resolved yet (null)", () => {
97
+ it("resolves 'unknown-placement' when the catalog has not resolved yet (null)", () => {
90
98
  const decision = resolvePresentDecision(null, null, "hard_paywall");
91
- expect(decision).toEqual({ type: "immediate", result: { status: "error" } });
99
+ expect(decision).toEqual({
100
+ type: "immediate",
101
+ result: { status: "error", reason: "unknown-placement" },
102
+ });
92
103
  });
93
104
 
94
- it("resolves 'error' immediately when another paywall is already showing, even for a valid placement", () => {
105
+ it("resolves 'already-presenting' AND names the placement that is showing", () => {
106
+ // The placement is the difference between "I double-called for the same
107
+ // one" (caller adds a guard) and "something else is stuck" (caller cannot
108
+ // fix it) — different diagnoses, so the bare status could serve neither.
95
109
  const decision = resolvePresentDecision(catalog, "already_showing", "hard_paywall");
96
- expect(decision).toEqual({ type: "immediate", result: { status: "error" } });
110
+ expect(decision).toEqual({
111
+ type: "immediate",
112
+ result: {
113
+ status: "error",
114
+ reason: "already-presenting",
115
+ activePlacement: "already_showing",
116
+ },
117
+ });
118
+ });
119
+
120
+ it("reports 'already-presenting' when the caller re-presents the SAME placement", () => {
121
+ const decision = resolvePresentDecision(catalog, "hard_paywall", "hard_paywall");
122
+ expect(decision).toEqual({
123
+ type: "immediate",
124
+ result: {
125
+ status: "error",
126
+ reason: "already-presenting",
127
+ activePlacement: "hard_paywall",
128
+ },
129
+ });
97
130
  });
98
131
 
99
132
  it("the concurrent-present check takes priority over the unknown-placement check", () => {
100
133
  // Both conditions are true at once: prove the function still resolves
101
- // rather than e.g. throwing on the first branch it happens to hit.
134
+ // rather than e.g. throwing on the first branch it happens to hit, and
135
+ // that the reason reflects the branch actually taken.
102
136
  const decision = resolvePresentDecision(catalog, "already_showing", "does_not_exist");
103
- expect(decision).toEqual({ type: "immediate", result: { status: "error" } });
137
+ expect(decision).toEqual({
138
+ type: "immediate",
139
+ result: {
140
+ status: "error",
141
+ reason: "already-presenting",
142
+ activePlacement: "already_showing",
143
+ },
144
+ });
145
+ });
146
+ });
147
+
148
+ describe("shouldBreakPresentationWedge", () => {
149
+ // The confirmed production failure this exists for: iOS refuses to present a
150
+ // view controller over one that is already presenting (another Modal, a
151
+ // `presentation: "modal"` route, a StoreKit alert). `present()` has already
152
+ // set `activePlacement`, the host's Modal never actually appears, so nothing
153
+ // ever calls `complete()` — and because `activePaywall` is non-null the
154
+ // OTHER self-heal (which requires it to be null) cannot fire. Every later
155
+ // `present()` then returns "error" for the life of the process, with no
156
+ // error and no log, on a monetisation surface.
157
+ it("breaks the wedge once a presentation has timed out unacknowledged", () => {
158
+ expect(shouldBreakPresentationWedge("hard_paywall", false, true)).toBe(true);
159
+ });
160
+
161
+ it("does NOT fire while nothing is being presented", () => {
162
+ expect(shouldBreakPresentationWedge(null, false, true)).toBe(false);
163
+ });
164
+
165
+ it("does NOT fire once the host has acknowledged — a real paywall may stay up for minutes", () => {
166
+ // The whole point of requiring an acknowledgement rather than a bare
167
+ // timeout: a user reading a paywall must never have it torn down.
168
+ expect(shouldBreakPresentationWedge("hard_paywall", true, true)).toBe(false);
169
+ });
170
+
171
+ it("does NOT fire before the timeout elapses, even unacknowledged", () => {
172
+ expect(shouldBreakPresentationWedge("hard_paywall", false, false)).toBe(false);
104
173
  });
105
174
  });
106
175
 
@@ -57,15 +57,48 @@ export const resolvePresentDecision = (
57
57
  placement: string
58
58
  ): PresentDecision => {
59
59
  if (activePlacement !== null) {
60
- return { type: "immediate", result: { status: "error" } };
60
+ // `activePlacement` is echoed back deliberately — see PresentErrorReason.
61
+ return {
62
+ type: "immediate",
63
+ result: { status: "error", reason: "already-presenting", activePlacement },
64
+ };
61
65
  }
62
66
  const paywall = catalog?.paywalls[placement];
63
67
  if (!paywall) {
64
- return { type: "immediate", result: { status: "error" } };
68
+ return { type: "immediate", result: { status: "error", reason: "unknown-placement" } };
65
69
  }
66
70
  return { type: "start", paywall };
67
71
  };
68
72
 
73
+ /**
74
+ * Whether an in-progress presentation should be abandoned because the host
75
+ * never confirmed it appeared.
76
+ *
77
+ * The failure this recovers from, observed in production: iOS refuses to
78
+ * present a view controller over one that is already presenting — another
79
+ * `Modal`, a `presentation: "modal"` route, a StoreKit alert. `present()` has
80
+ * already set `activePlacement` by then, but the host's Modal never actually
81
+ * appears, so nothing ever calls `complete()`. The pending promise never
82
+ * settles and `activePlacement` stays set for the life of the process, which
83
+ * makes EVERY later `present()` resolve `"already-presenting"` — for any
84
+ * placement, silently, on a monetisation surface.
85
+ *
86
+ * The sibling self-heal in `PaywallProvider` cannot cover it: that one requires
87
+ * `activePaywall` to be null, and here it is non-null (the catalog still holds
88
+ * the paywall perfectly well — only the platform refused to show it).
89
+ *
90
+ * Why an ACKNOWLEDGEMENT and not a bare timeout: a paywall a user is reading
91
+ * legitimately stays active for minutes, so elapsed time alone cannot
92
+ * distinguish "still on screen" from "never appeared". The host confirms
93
+ * presentation (the UI host wires this to its Modal's `onShow`), and only an
94
+ * unacknowledged presentation is ever torn down.
95
+ */
96
+ export const shouldBreakPresentationWedge = (
97
+ activePlacement: string | null,
98
+ hostAcknowledged: boolean,
99
+ timedOut: boolean
100
+ ): boolean => activePlacement !== null && !hostAcknowledged && timedOut;
101
+
69
102
  /**
70
103
  * `isReady` = catalog resolved AND products resolved — the one flag a caller
71
104
  * needs to know "presenting now will not show a spinner".
@@ -94,6 +94,56 @@ export interface GetPaywallsResponseHeaders {
94
94
  * Entitlement belongs to the store — read it from the `ProductProvider` /
95
95
  * billing SDK, and use this only to decide what the UI does next.
96
96
  */
97
+ /**
98
+ * Why a presentation resolved `"error"`. Present on every `"error"` result and
99
+ * absent on every other status.
100
+ *
101
+ * This exists because `"error"` alone conflates conditions whose correct
102
+ * recovery is OPPOSITE. `"unknown-placement"` means the catalog may simply not
103
+ * have arrived yet, so retrying later is right. `"already-presenting"` means a
104
+ * presentation is in progress, so retrying is wrong and something may be
105
+ * stuck. A caller given only the status can act correctly on neither, and two
106
+ * separate multi-hour production investigations were spent reconstructing by
107
+ * elimination what the SDK already knew here.
108
+ *
109
+ * - `unknown-placement` — absent from the catalog, or the catalog has not
110
+ * resolved yet. The two are indistinguishable at this layer, and both are
111
+ * worth retrying once `usePaywall().isReady` is true.
112
+ * - `already-presenting` — one paywall shows at a time. `activePlacement` on
113
+ * the result names the one that IS showing: the same placement means the
114
+ * caller double-called and wants its own in-flight guard, a different one
115
+ * means something else holds the surface.
116
+ * - `parse-error` — `elements` failed the UI schema, so the Modal was never
117
+ * opened. A CMS **data** bug (a wrong enum value, say), not a code bug; the
118
+ * host cannot fix it and the authoring tool must. The UI host logs the
119
+ * validation issues alongside this.
120
+ * - `render-error` — the element tree threw while rendering and the error
121
+ * boundary settled the promise rather than trapping the user behind an
122
+ * escape-less fullScreen Modal.
123
+ * - `host-never-presented` — the host never confirmed the paywall appeared
124
+ * within the acknowledgement window, so the presentation was abandoned to
125
+ * keep the surface usable. In practice the platform refused to present
126
+ * (iOS will not present over an already-presenting view controller — another
127
+ * Modal, a `presentation: "modal"` route, a StoreKit alert).
128
+ * - `paywall-disappeared` — the placement vanished from the catalog while it
129
+ * was on screen (a studio publish, or a query-key change mid-presentation).
130
+ */
131
+ export type PresentErrorReason =
132
+ | "unknown-placement"
133
+ | "already-presenting"
134
+ | "parse-error"
135
+ | "render-error"
136
+ | "host-never-presented"
137
+ | "paywall-disappeared";
138
+
97
139
  export type PresentResult = {
98
140
  status: "purchased" | "dismissed" | "cancelled" | "error";
141
+ /** Why it failed. Set on `"error"` only — see `PresentErrorReason`. */
142
+ reason?: PresentErrorReason;
143
+ /**
144
+ * The placement currently being presented. Set only alongside
145
+ * `reason: "already-presenting"`, where knowing WHICH placement holds the
146
+ * surface is what distinguishes a caller double-call from an unrelated stall.
147
+ */
148
+ activePlacement?: string;
99
149
  };
@@ -53,7 +53,8 @@ const mergeStatus = (a: ProductStatus, b: ProductStatus): ProductStatus => {
53
53
  * `"idle"` for the local runtime (it bails before ever calling a provider it
54
54
  * doesn't have — `useProducts.ts`), and a naive `mergeStatus` would drag the
55
55
  * context runtime's `"ready"` down to `"idle"` FOREVER, closing every
56
- * `renderWhen: {"products.loaded": {eq:"true"}}` gate for good — the same
56
+ * `renderWhen: {variable:"products.loaded",operator:"eq",value:"true"}`
57
+ * gate for good — the same
57
58
  * "idle blocks readiness when there's nothing to actually wait for" trap
58
59
  * `computeIsReady` (`present.ts`) already special-cases for an empty ref set.
59
60
  * When there is no local provider, the local runtime has nothing pending, so