@rocapine/react-native-onboarding 1.73.0 → 1.74.1

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 (105) hide show
  1. package/README.md +164 -3
  2. package/dist/OnboardingStudio.d.ts +82 -0
  3. package/dist/OnboardingStudio.d.ts.map +1 -0
  4. package/dist/OnboardingStudio.js +91 -0
  5. package/dist/OnboardingStudio.js.map +1 -0
  6. package/dist/OnboardingStudioClient.d.ts +14 -5
  7. package/dist/OnboardingStudioClient.d.ts.map +1 -1
  8. package/dist/OnboardingStudioClient.js +24 -9
  9. package/dist/OnboardingStudioClient.js.map +1 -1
  10. package/dist/index.d.ts +7 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +40 -4
  13. package/dist/index.js.map +1 -1
  14. package/dist/infra/provider/OnboardingProvider.d.ts +15 -2
  15. package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
  16. package/dist/infra/provider/OnboardingProvider.js +66 -6
  17. package/dist/infra/provider/OnboardingProvider.js.map +1 -1
  18. package/dist/infra/queries/cacheKey.d.ts +41 -3
  19. package/dist/infra/queries/cacheKey.d.ts.map +1 -1
  20. package/dist/infra/queries/cacheKey.js +44 -8
  21. package/dist/infra/queries/cacheKey.js.map +1 -1
  22. package/dist/infra/queries/getOnboarding.query.d.ts.map +1 -1
  23. package/dist/infra/queries/getOnboarding.query.js +6 -1
  24. package/dist/infra/queries/getOnboarding.query.js.map +1 -1
  25. package/dist/paywalls/PaywallProvider.d.ts +52 -4
  26. package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
  27. package/dist/paywalls/PaywallProvider.js +105 -7
  28. package/dist/paywalls/PaywallProvider.js.map +1 -1
  29. package/dist/paywalls/catalogSettleWaiter.d.ts +31 -0
  30. package/dist/paywalls/catalogSettleWaiter.d.ts.map +1 -0
  31. package/dist/paywalls/catalogSettleWaiter.js +58 -0
  32. package/dist/paywalls/catalogSettleWaiter.js.map +1 -0
  33. package/dist/paywalls/getPaywalls.query.d.ts.map +1 -1
  34. package/dist/paywalls/getPaywalls.query.js +6 -1
  35. package/dist/paywalls/getPaywalls.query.js.map +1 -1
  36. package/dist/paywalls/register.d.ts +105 -0
  37. package/dist/paywalls/register.d.ts.map +1 -0
  38. package/dist/paywalls/register.js +112 -0
  39. package/dist/paywalls/register.js.map +1 -0
  40. package/dist/paywalls/usePaywall.d.ts +29 -0
  41. package/dist/paywalls/usePaywall.d.ts.map +1 -1
  42. package/dist/paywalls/usePaywall.js +2 -1
  43. package/dist/paywalls/usePaywall.js.map +1 -1
  44. package/dist/userProperties/applyPatch.d.ts +18 -0
  45. package/dist/userProperties/applyPatch.d.ts.map +1 -0
  46. package/dist/userProperties/applyPatch.js +57 -0
  47. package/dist/userProperties/applyPatch.js.map +1 -0
  48. package/dist/userProperties/effectiveParams.d.ts +29 -0
  49. package/dist/userProperties/effectiveParams.d.ts.map +1 -0
  50. package/dist/userProperties/effectiveParams.js +56 -0
  51. package/dist/userProperties/effectiveParams.js.map +1 -0
  52. package/dist/userProperties/index.d.ts +9 -0
  53. package/dist/userProperties/index.d.ts.map +1 -0
  54. package/dist/userProperties/index.js +21 -0
  55. package/dist/userProperties/index.js.map +1 -0
  56. package/dist/userProperties/reserved.d.ts +33 -0
  57. package/dist/userProperties/reserved.d.ts.map +1 -0
  58. package/dist/userProperties/reserved.js +45 -0
  59. package/dist/userProperties/reserved.js.map +1 -0
  60. package/dist/userProperties/serialize.d.ts +38 -0
  61. package/dist/userProperties/serialize.d.ts.map +1 -0
  62. package/dist/userProperties/serialize.js +67 -0
  63. package/dist/userProperties/serialize.js.map +1 -0
  64. package/dist/userProperties/store.d.ts +65 -0
  65. package/dist/userProperties/store.d.ts.map +1 -0
  66. package/dist/userProperties/store.js +155 -0
  67. package/dist/userProperties/store.js.map +1 -0
  68. package/dist/userProperties/types.d.ts +21 -0
  69. package/dist/userProperties/types.d.ts.map +1 -0
  70. package/dist/userProperties/types.js +3 -0
  71. package/dist/userProperties/types.js.map +1 -0
  72. package/dist/userProperties/useUserProperties.d.ts +20 -0
  73. package/dist/userProperties/useUserProperties.d.ts.map +1 -0
  74. package/dist/userProperties/useUserProperties.js +30 -0
  75. package/dist/userProperties/useUserProperties.js.map +1 -0
  76. package/package.json +5 -1
  77. package/src/OnboardingStudio.ts +147 -0
  78. package/src/OnboardingStudioClient.ts +27 -11
  79. package/src/__tests__/OnboardingDataGate.test.tsx +445 -0
  80. package/src/__tests__/OnboardingStudio.test.ts +208 -0
  81. package/src/__tests__/cacheKey.test.ts +71 -0
  82. package/src/__tests__/getOnboarding.query.test.ts +47 -8
  83. package/src/index.ts +43 -0
  84. package/src/infra/provider/OnboardingProvider.tsx +98 -10
  85. package/src/infra/queries/cacheKey.ts +54 -9
  86. package/src/infra/queries/getOnboarding.query.ts +9 -1
  87. package/src/paywalls/PaywallProvider.tsx +162 -6
  88. package/src/paywalls/__tests__/catalogSettleWaiter.test.ts +134 -0
  89. package/src/paywalls/__tests__/getPaywalls.test.ts +29 -11
  90. package/src/paywalls/__tests__/register.test.ts +266 -0
  91. package/src/paywalls/catalogSettleWaiter.ts +72 -0
  92. package/src/paywalls/getPaywalls.query.ts +9 -1
  93. package/src/paywalls/register.ts +169 -0
  94. package/src/paywalls/usePaywall.ts +40 -2
  95. package/src/userProperties/__tests__/effectiveParams.test.ts +51 -0
  96. package/src/userProperties/__tests__/primitives.test.ts +96 -0
  97. package/src/userProperties/__tests__/store.test.ts +181 -0
  98. package/src/userProperties/applyPatch.ts +68 -0
  99. package/src/userProperties/effectiveParams.ts +60 -0
  100. package/src/userProperties/index.ts +11 -0
  101. package/src/userProperties/reserved.ts +44 -0
  102. package/src/userProperties/serialize.ts +61 -0
  103. package/src/userProperties/store.ts +179 -0
  104. package/src/userProperties/types.ts +22 -0
  105. package/src/userProperties/useUserProperties.ts +26 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PaywallProvider = exports.usePaywallHost = exports.PaywallContext = void 0;
3
+ exports.PaywallProvider = exports.usePaywallHost = exports.PaywallContext = exports.DEFAULT_REGISTER_TIMEOUT_MS = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const react_query_1 = require("@tanstack/react-query");
@@ -8,6 +8,11 @@ const getPaywalls_query_1 = require("./getPaywalls.query");
8
8
  const present_1 = require("./present");
9
9
  const useProducts_1 = require("../products/useProducts");
10
10
  const ProductRuntimeContext_1 = require("../products/ProductRuntimeContext");
11
+ const useUserProperties_1 = require("../userProperties/useUserProperties");
12
+ const effectiveParams_1 = require("../userProperties/effectiveParams");
13
+ const register_1 = require("./register");
14
+ const OnboardingStudio_1 = require("../OnboardingStudio");
15
+ const catalogSettleWaiter_1 = require("./catalogSettleWaiter");
11
16
  // Module-scope, private to this file — mirrors `OnboardingProvider.tsx:17-23`.
12
17
  // `OnboardingProvider`'s QueryClient is not exported, so it cannot be reused
13
18
  // here; a second, independent cache is intentional, not an oversight — the
@@ -37,6 +42,14 @@ const EMPTY_PAYWALL_CONTEXT = {
37
42
  // No provider above: there is no catalog at all, which is the same answer
38
43
  // `resolvePresentDecision` gives for an unresolved one.
39
44
  present: async () => ({ status: "error", reason: "unknown-moment" }),
45
+ // No provider above: no verdict is reachable, which is exactly the fail-open
46
+ // case — consistent with how `register` treats an unavailable catalog. A host
47
+ // that forgot the provider gets a working app whose features are ungated,
48
+ // rather than an app whose gated features are all silently dead.
49
+ register: async (_moment, feature) => {
50
+ await (feature === null || feature === void 0 ? void 0 : feature());
51
+ return { ran: true, presented: false, reason: "catalog-unavailable" };
52
+ },
40
53
  isReady: false,
41
54
  catalog: null,
42
55
  // No provider above: nothing is loading and nothing will arrive.
@@ -58,6 +71,12 @@ const EMPTY_PAYWALL_CONTEXT = {
58
71
  * long keeps a slow-but-successful presentation from being torn down.
59
72
  */
60
73
  const DEFAULT_PRESENT_ACK_TIMEOUT_MS = 5000;
74
+ /**
75
+ * How long `register()` waits for the catalog to settle before deciding without
76
+ * it. Generous enough that a cold network fetch usually lands, short enough that
77
+ * a tap does not feel stuck.
78
+ */
79
+ exports.DEFAULT_REGISTER_TIMEOUT_MS = 3000;
61
80
  exports.PaywallContext = (0, react_1.createContext)(EMPTY_PAYWALL_CONTEXT);
62
81
  /**
63
82
  * The seam a paywall HOST (Task 7's `PaywallHost`) reads from — analogous to
@@ -71,7 +90,7 @@ const usePaywallHost = () => {
71
90
  return { activePaywall, complete, acknowledgePresentation, customActions, customScreens };
72
91
  };
73
92
  exports.usePaywallHost = usePaywallHost;
74
- const PaywallProviderInner = ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, customScreens, presentAckTimeoutMs, }) => {
93
+ const PaywallProviderInner = ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, customScreens, presentAckTimeoutMs, registerTimeoutMs, }) => {
75
94
  var _a;
76
95
  // `data` straight off `useQuery` is the single source of truth (Finding 1,
77
96
  // 2026-08-17 final review) — react-query's own cache already gets both a
@@ -81,7 +100,22 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
81
100
  // for why the query still needs `paywallQueryClient` for the ONE case
82
101
  // `data` alone can't cover: a background revalidation pushing a fresh
83
102
  // payload while this query call already resolved with the cached one.
84
- const { data, error, isFetching } = (0, react_query_1.useQuery)((0, getPaywalls_query_1.getPaywallsQuery)(client, locale, customAudienceParams, paywallQueryClient));
103
+ // The user-property store is the RUNTIME half of audience targeting; the
104
+ // `customAudienceParams` prop is the static half. Merged store-wins and
105
+ // serialized once, so the query key, the disk cache key's hash and the
106
+ // querystring all see the same bytes — see `resolveEffectiveParams`.
107
+ const { properties, status: propertiesStatus } = (0, useUserProperties_1.useUserProperties)();
108
+ const params = (0, react_1.useMemo)(() => (0, effectiveParams_1.resolveEffectiveParams)(customAudienceParams, properties), [customAudienceParams, properties]);
109
+ const { data, error, isFetching } = (0, react_query_1.useQuery)(Object.assign(Object.assign({}, (0, getPaywalls_query_1.getPaywallsQuery)(client, locale, params, paywallQueryClient)), {
110
+ // Held until the store has hydrated from disk. Without this the first fetch
111
+ // of a cold launch carries an EMPTY property map, matches the catch-all
112
+ // audience, and — because the catalog is cached with `staleTime: Infinity` —
113
+ // that wrong answer is what the whole session uses.
114
+ //
115
+ // A disabled query reports `data: undefined`, `error: null`,
116
+ // `isFetching: false`, which `computeCatalogStatus` reads as "loading" — the
117
+ // honest answer while the store hydrates, and the one `register()` waits on.
118
+ enabled: propertiesStatus === "ready" }));
85
119
  const catalog = data !== null && data !== void 0 ? data : null;
86
120
  // `isFetching` (not `isLoading`) on purpose: it is also true for a BACKGROUND
87
121
  // revalidation behind an already-served cached catalog, which is precisely the
@@ -196,6 +230,17 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
196
230
  // `purchase`/`restore` callbacks.
197
231
  const catalogRef = (0, react_1.useRef)(catalog);
198
232
  catalogRef.current = catalog;
233
+ // `catalogStatus` as a ref for the same reason: `register` must read the
234
+ // CURRENT status without being re-created on every status change.
235
+ const catalogStatusRef = (0, react_1.useRef)(catalogStatus);
236
+ catalogStatusRef.current = catalogStatus;
237
+ // One waiter per provider instance, reading status through the ref above. See
238
+ // `catalogSettleWaiter.ts` for the two invariants that put it in its own
239
+ // module instead of inline here.
240
+ const settleWaiterRef = (0, react_1.useRef)(null);
241
+ if (settleWaiterRef.current === null) {
242
+ settleWaiterRef.current = (0, catalogSettleWaiter_1.createCatalogSettleWaiter)(() => catalogStatusRef.current === "loading");
243
+ }
199
244
  // `activeMomentRef` is made AUTHORITATIVE below — assigned inside
200
245
  // `present()`'s start branch and inside `complete()`, not just here. Finding
201
246
  // 4, 2026-08-17 final review: this line alone only resyncs the ref from
@@ -239,6 +284,34 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
239
284
  setActiveMoment(moment);
240
285
  });
241
286
  }, []);
287
+ // Wakes anything parked in `register` as soon as the catalog stops loading.
288
+ (0, react_1.useEffect)(() => {
289
+ var _a;
290
+ if (catalogStatus === "loading")
291
+ return;
292
+ (_a = settleWaiterRef.current) === null || _a === void 0 ? void 0 : _a.settle();
293
+ }, [catalogStatus]);
294
+ /**
295
+ * Superwall's `registerPlacement`, in this SDK's vocabulary: gate a feature on
296
+ * a moment.
297
+ *
298
+ * Gates on the MOMENT alone — there is deliberately no entitlement check.
299
+ * Exclude subscribers by authoring an audience filter against a user property
300
+ * the host sets (`plan: "pro"`), which is machinery that already exists.
301
+ *
302
+ * All of the decision logic — both fail-open paths, the wait-once rule, the
303
+ * Stripe warning — is `runRegister` in `register.ts`, where it is unit-tested.
304
+ * This callback only supplies the environment.
305
+ */
306
+ const register = (0, react_1.useCallback)((moment, feature) => (0, register_1.runRegister)({
307
+ getCatalog: () => catalogRef.current,
308
+ getCatalogStatus: () => catalogStatusRef.current,
309
+ waitForCatalogSettled: (ms) => settleWaiterRef.current.wait(ms),
310
+ // The real `present`, so the wedge recovery, the purchase-generation
311
+ // race guard and outcome reconciliation all apply unchanged.
312
+ present,
313
+ timeoutMs: registerTimeoutMs,
314
+ }, moment, feature), [present, registerTimeoutMs]);
242
315
  // Called by PaywallHost (Task 7) from the presented paywall's
243
316
  // `ScreenHost.complete`. Resolves whatever `present()` call is pending and
244
317
  // clears the active moment, hiding the Modal and allowing a new
@@ -313,6 +386,7 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
313
386
  const isReady = (0, react_1.useMemo)(() => (0, present_1.computeIsReady)(catalog, productRefs, productRuntime.status), [catalog, productRefs, productRuntime.status]);
314
387
  const contextValue = (0, react_1.useMemo)(() => ({
315
388
  present,
389
+ register,
316
390
  isReady,
317
391
  catalog,
318
392
  catalogStatus,
@@ -327,6 +401,7 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
327
401
  customScreens,
328
402
  }), [
329
403
  present,
404
+ register,
330
405
  isReady,
331
406
  catalog,
332
407
  catalogStatus,
@@ -345,14 +420,37 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
345
420
  * only flows to descendants; two true siblings could not share one runtime).
346
421
  *
347
422
  * ```tsx
348
- * <PaywallProvider client={client} productProvider={revenueCatProductProvider(Purchases)}>
423
+ * OnboardingStudio.init({ projectId: "…" }); // at module scope
424
+ *
425
+ * <PaywallProvider productProvider={revenueCatProductProvider(Purchases)}>
349
426
  * <App />
350
- * <PaywallHost /> // Task 7: renders the active paywall in a fullScreen RN Modal
427
+ * <PaywallHost /> // renders the active paywall in a fullScreen RN Modal
351
428
  * </PaywallProvider>
352
429
  * ```
430
+ *
431
+ * With no client at all — neither a prop nor an `OnboardingStudio.init()` — this
432
+ * WARNS and renders `children` untouched, so paywalls are inert and the app
433
+ * still runs. It deliberately does not throw the way `OnboardingProvider` does:
434
+ * this provider wraps the whole app (see the query-error effect inside), so
435
+ * throwing would take down every screen over a missing paywall client. Consumers
436
+ * then read the default context, where `isProviderMounted` is `false` and both
437
+ * `present` and `register` resolve their fail-open answers.
353
438
  */
354
- const PaywallProvider = ({ children, client, locale = "en", customAudienceParams = {}, productProvider, stripeProductProvider, customActions = EMPTY_CUSTOM_ACTIONS, customScreens = EMPTY_CUSTOM_SCREENS, presentAckTimeoutMs = DEFAULT_PRESENT_ACK_TIMEOUT_MS, }) => {
355
- 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, stripeProductProvider: stripeProductProvider, customActions: customActions, customScreens: customScreens, presentAckTimeoutMs: presentAckTimeoutMs, children: children }) }));
439
+ const PaywallProvider = ({ children, client: clientProp, locale = "en", customAudienceParams = {}, productProvider, stripeProductProvider, customActions = EMPTY_CUSTOM_ACTIONS, customScreens = EMPTY_CUSTOM_SCREENS, presentAckTimeoutMs = DEFAULT_PRESENT_ACK_TIMEOUT_MS, registerTimeoutMs = exports.DEFAULT_REGISTER_TIMEOUT_MS, }) => {
440
+ // Prop wins, else whatever `OnboardingStudio.init()` built. Read during render,
441
+ // so `init()` must run before the first render — at module scope.
442
+ const client = (0, OnboardingStudio_1.resolveProviderClient)(clientProp, OnboardingStudio_1.OnboardingStudio.getClient());
443
+ // Effect, not an inline call, so a re-render does not re-log. Declared above
444
+ // the early return: hooks must run unconditionally.
445
+ (0, react_1.useEffect)(() => {
446
+ if (client)
447
+ return;
448
+ console.warn(`${OnboardingStudio_1.MISSING_CLIENT_MESSAGE} Paywalls are inert until then.`);
449
+ }, [client]);
450
+ // Degrade rather than throw — see the doc above.
451
+ if (!client)
452
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
453
+ 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, stripeProductProvider: stripeProductProvider, customActions: customActions, customScreens: customScreens, presentAckTimeoutMs: presentAckTimeoutMs, registerTimeoutMs: registerTimeoutMs, children: children }) }));
356
454
  };
357
455
  exports.PaywallProvider = PaywallProvider;
358
456
  //# 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,uCAYmB;AACnB,yDAAsD;AAEtD,6EAA0E;AAI1E,+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,MAA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IAAI,CAAC,MAAM;QAAE,OAAO,2DAAG,QAAQ,GAAI,CAAC;IAEpC,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,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,iBAAiB,EAAE,iBAAiB,YAEnC,QAAQ,GACY,GACH,CACvB,CAAC;AACJ,CAAC,CAAC;AA3CW,QAAA,eAAe,mBA2C1B"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Parks `register()` callers while the paywall catalog is still loading, and
3
+ * wakes them when it settles or when their own timeout elapses.
4
+ *
5
+ * Extracted from `PaywallProvider` — rather than written inline over a couple of
6
+ * refs — because it has two invariants that are easy to get wrong and impossible
7
+ * to assert from inside a component without a DOM (this repo's tests run in
8
+ * vitest's default `node` environment):
9
+ *
10
+ * 1. **A waiter resolves exactly once.** A timeout can fire after a real settle
11
+ * already woke the waiter. Resolving a Promise twice is harmless in itself,
12
+ * but the bookkeeping around it is not — a stale entry left in the set would
13
+ * be woken by the NEXT settle, running a continuation that belongs to nobody.
14
+ * 2. **Draining must not skip a re-parked waiter.** A woken caller's continuation
15
+ * may call `register()` again and park immediately; mutating the set while
16
+ * iterating it would either miss that new waiter or loop over it. So the set
17
+ * is swapped out before it is drained.
18
+ *
19
+ * The timer is injected so both invariants are testable without real time.
20
+ */
21
+ /** Cancels the scheduled callback. */
22
+ export type ScheduleCancel = () => void;
23
+ export type Schedule = (fn: () => void, ms: number) => ScheduleCancel;
24
+ export type CatalogSettleWaiter = {
25
+ /** Resolves when the catalog stops loading, or after `timeoutMs`. */
26
+ wait: (timeoutMs: number) => Promise<void>;
27
+ /** Wakes every parked waiter. Called when the catalog status leaves "loading". */
28
+ settle: () => void;
29
+ };
30
+ export declare const createCatalogSettleWaiter: (isLoading: () => boolean, schedule?: Schedule) => CatalogSettleWaiter;
31
+ //# sourceMappingURL=catalogSettleWaiter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogSettleWaiter.d.ts","sourceRoot":"","sources":["../../src/paywalls/catalogSettleWaiter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,sCAAsC;AACtC,MAAM,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC;AACxC,MAAM,MAAM,QAAQ,GAAG,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,EAAE,EAAE,MAAM,KAAK,cAAc,CAAC;AAEtE,MAAM,MAAM,mBAAmB,GAAG;IAChC,qEAAqE;IACrE,IAAI,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,kFAAkF;IAClF,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAOF,eAAO,MAAM,yBAAyB,GACpC,WAAW,MAAM,OAAO,EACxB,WAAU,QAA0B,KACnC,mBA+BF,CAAC"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /**
3
+ * Parks `register()` callers while the paywall catalog is still loading, and
4
+ * wakes them when it settles or when their own timeout elapses.
5
+ *
6
+ * Extracted from `PaywallProvider` — rather than written inline over a couple of
7
+ * refs — because it has two invariants that are easy to get wrong and impossible
8
+ * to assert from inside a component without a DOM (this repo's tests run in
9
+ * vitest's default `node` environment):
10
+ *
11
+ * 1. **A waiter resolves exactly once.** A timeout can fire after a real settle
12
+ * already woke the waiter. Resolving a Promise twice is harmless in itself,
13
+ * but the bookkeeping around it is not — a stale entry left in the set would
14
+ * be woken by the NEXT settle, running a continuation that belongs to nobody.
15
+ * 2. **Draining must not skip a re-parked waiter.** A woken caller's continuation
16
+ * may call `register()` again and park immediately; mutating the set while
17
+ * iterating it would either miss that new waiter or loop over it. So the set
18
+ * is swapped out before it is drained.
19
+ *
20
+ * The timer is injected so both invariants are testable without real time.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.createCatalogSettleWaiter = void 0;
24
+ const defaultSchedule = (fn, ms) => {
25
+ const timer = setTimeout(fn, ms);
26
+ return () => clearTimeout(timer);
27
+ };
28
+ const createCatalogSettleWaiter = (isLoading, schedule = defaultSchedule) => {
29
+ let waiters = new Set();
30
+ return {
31
+ wait: (timeoutMs) => new Promise((resolve) => {
32
+ // Nothing to wait for — do not allocate a timer or an entry.
33
+ if (!isLoading())
34
+ return resolve();
35
+ let settled = false;
36
+ let cancelTimer = () => { };
37
+ const finish = () => {
38
+ if (settled)
39
+ return; // invariant 1
40
+ settled = true;
41
+ waiters.delete(finish);
42
+ cancelTimer();
43
+ resolve();
44
+ };
45
+ waiters.add(finish);
46
+ cancelTimer = schedule(finish, timeoutMs);
47
+ }),
48
+ settle: () => {
49
+ // Swapped before draining — invariant 2.
50
+ const parked = waiters;
51
+ waiters = new Set();
52
+ for (const wake of parked)
53
+ wake();
54
+ },
55
+ };
56
+ };
57
+ exports.createCatalogSettleWaiter = createCatalogSettleWaiter;
58
+ //# sourceMappingURL=catalogSettleWaiter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalogSettleWaiter.js","sourceRoot":"","sources":["../../src/paywalls/catalogSettleWaiter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;AAaH,MAAM,eAAe,GAAa,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;IAC3C,MAAM,KAAK,GAAG,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACjC,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC,CAAC;AAEK,MAAM,yBAAyB,GAAG,CACvC,SAAwB,EACxB,WAAqB,eAAe,EACf,EAAE;IACvB,IAAI,OAAO,GAAG,IAAI,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AgB,GAC3B,QAAQ,sBAAsB,EAC9B,QAAQ,MAAM,EACd,sBAAsB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzC,cAAc,WAAW;;mBAcJ,OAAO,CAAC,cAAc,CAAC;;CAsE7C,CAAC"}
1
+ {"version":3,"file":"getPaywalls.query.d.ts","sourceRoot":"","sources":["../../src/paywalls/getPaywalls.query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAIzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,sBAAsB,EAC9B,QAAQ,MAAM,EACd,sBAAsB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzC,cAAc,WAAW;;mBAcJ,OAAO,CAAC,cAAc,CAAC;;CA6E7C,CAAC"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getPaywallsQuery = void 0;
7
7
  const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
8
8
  const cacheKey_1 = require("../infra/queries/cacheKey");
9
+ const serialize_1 = require("../userProperties/serialize");
9
10
  /**
10
11
  * Mirrors `getOnboarding.query.ts`'s cache-first / background-revalidate /
11
12
  * custom-key behaviour exactly (same `staleTime: Infinity`, same
@@ -53,7 +54,11 @@ const getPaywallsQuery = (client, locale, customAudienceParams, queryClient) =>
53
54
  // with NO background revalidation, so a pinned version survives across
54
55
  // launches. The default key keeps stale-while-revalidate.
55
56
  const hasCustomKey = Boolean(client.options.cacheKey);
56
- const cacheKey = (0, cacheKey_1.getPaywallsCacheKey)(client.options.cacheKey);
57
+ // Scoped by the resolved audience params — see `cacheKey.ts`. This is what
58
+ // makes `catalogStatus: "revalidating"` mean "a genuine freshness refresh"
59
+ // rather than "this catalog may have been resolved under other params",
60
+ // which `register()`'s decision relies on.
61
+ const cacheKey = (0, cacheKey_1.getPaywallsCacheKey)(client.options.cacheKey, (0, serialize_1.paramsHash)(customAudienceParams));
57
62
  // Fetches the live catalog, caches it, and pushes it into the query
58
63
  // cache directly — see the module doc above for why that push is
59
64
  // needed even though `queryFn`'s own return value already becomes
@@ -1 +1 @@
1
- {"version":3,"file":"getPaywalls.query.js","sourceRoot":"","sources":["../../src/paywalls/getPaywalls.query.ts"],"names":[],"mappings":";;;;;;AAAA,8FAAqE;AAIrE,wDAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,MAAM,gBAAgB,GAAG,CAC9B,MAA8B,EAC9B,MAAc,EACd,oBAAyC,EACzC,WAAyB,EACzB,EAAE;IACF,MAAM,QAAQ,GAAG;QACf,gBAAgB;QAChB,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,OAAO,CAAC,SAAS;QACxB,MAAM,CAAC,OAAO,CAAC,OAAO;QACtB,MAAM,CAAC,OAAO,CAAC,QAAQ;QACvB,MAAM;QACN,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;KACrC,CAAC;IAEF,OAAO;QACL,QAAQ;QACR,OAAO,EAAE,KAAK,IAA6B,EAAE;;YAC3C,MAAM,YAAY,GAAG,CAAC,CAAC,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,0CAAE,SAAS,KAAI,KAAK,CAAC,CAAC;YAC5D,qEAAqE;YACrE,uEAAuE;YACvE,0DAA0D;YAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACtD,MAAM,QAAQ,GAAG,IAAA,8BAAmB,EAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAE9D,oEAAoE;YACpE,iEAAiE;YACjE,kEAAkE;YAClE,sEAAsE;YACtE,gEAAgE;YAChE,uEAAuE;YAC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YAED,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,YAAY,EAAE,CAAC;oBAClB,mEAAmE;oBACnE,mEAAmE;oBACnE,iEAAiE;oBACjE,kDAAkD;oBAClD,KAAK,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;wBACnC,OAAO,CAAC,IAAI,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;oBAClE,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;YAED,oEAAoE;YACpE,wDAAwD;YACxD,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC;QACD,SAAS,EAAE,QAAQ;KACpB,CAAC;AACJ,CAAC,CAAC;AA/FW,QAAA,gBAAgB,oBA+F3B"}
@@ -0,0 +1,105 @@
1
+ import type { Paywall, PaywallCatalog, PresentResult } from "./types";
2
+ import type { CatalogStatus } from "./present";
3
+ /** The feature `register` gates. May be async; `register` awaits it. */
4
+ export type RegisterFeature = () => void | Promise<void>;
5
+ /**
6
+ * What `register(moment, feature)` should do, as a pure function of current
7
+ * state — extracted for the same reason `resolvePresentDecision` and
8
+ * `shouldAdvanceOnComplete` are: every branch on a monetisation path gets an
9
+ * importable test rather than inspection.
10
+ */
11
+ export type RegisterDecision = {
12
+ type: "run";
13
+ reason: "no-paywall" | "catalog-unavailable";
14
+ } | {
15
+ type: "present";
16
+ paywall: Paywall;
17
+ } | {
18
+ type: "wait";
19
+ };
20
+ /**
21
+ * `wait` is a DECISION rather than something the caller infers from
22
+ * `catalogStatus` itself, so "when may register block?" has exactly one answer in
23
+ * one tested place. The caller awaits the catalog settling and calls this again;
24
+ * the second call cannot return `wait`, because the wait resolves only on
25
+ * `"ready"`/`"error"` and a timeout is treated as `catalog-unavailable` without
26
+ * asking again.
27
+ *
28
+ * `"revalidating"` counts as usable. That is safe only because the AsyncStorage
29
+ * cache key is scoped by audience params: before that, a revalidating catalog
30
+ * might have been resolved under DIFFERENT params, so a missing moment could
31
+ * mean "not yet" rather than "absent". Now a served catalog always matches the
32
+ * current params.
33
+ */
34
+ export declare const resolveRegisterDecision: (catalog: PaywallCatalog | null, catalogStatus: CatalogStatus, moment: string) => RegisterDecision;
35
+ /**
36
+ * Whether a completed presentation unlocks the feature. Only a purchase does.
37
+ *
38
+ * This one-liner is correct only because `resolvePresentedOutcome` already
39
+ * upgraded the generic `{status:"dismissed"}` that the canonical authoring shape
40
+ * — `{type:"purchase", onSuccess:[{type:"dismiss"}]}` — produces into
41
+ * `"purchased"` when the store actually charged. Without that upgrade this would
42
+ * refuse the feature to every user who bought.
43
+ *
44
+ * **A Stripe paywall never unlocks on the purchase alone.** `PresentResult` has
45
+ * no `"pending"` status — that belongs to `PurchaseResult` — so a Payment Link
46
+ * checkout surfaces here as whatever its action list reported, in practice
47
+ * `"dismissed"` via its `onPending` branch. The entitlement arrives out-of-band
48
+ * through RevenueCat, so grant access from that webhook rather than from
49
+ * `register`. `runRegister` warns when it is about to present one.
50
+ */
51
+ export declare const shouldRunFeature: (outcome: PresentResult) => boolean;
52
+ /**
53
+ * What `register` resolves to.
54
+ *
55
+ * Returned rather than fire-and-forget so a host can measure how often it ran
56
+ * ungated: `reason: "catalog-unavailable"` is the rate at which failing open is
57
+ * giving features away, and a host that cannot see that number cannot decide
58
+ * whether the default is right for it.
59
+ */
60
+ export type RegisterResult = {
61
+ ran: true;
62
+ presented: false;
63
+ reason: "no-paywall" | "catalog-unavailable";
64
+ } | {
65
+ ran: true;
66
+ presented: true;
67
+ reason: "purchased";
68
+ outcome: PresentResult;
69
+ } | {
70
+ ran: false;
71
+ presented: true;
72
+ reason: "not-purchased";
73
+ outcome: PresentResult;
74
+ };
75
+ /**
76
+ * Everything `register` reads from its environment, injected.
77
+ *
78
+ * The catalog and its status are read through GETTERS rather than passed by value
79
+ * because `register` may await a wait in the middle: reading them once up front
80
+ * would decide against a catalog that has since arrived, which is the entire
81
+ * point of waiting.
82
+ */
83
+ export type RegisterDeps = {
84
+ getCatalog: () => PaywallCatalog | null;
85
+ getCatalogStatus: () => CatalogStatus;
86
+ /** Resolves when the catalog stops loading, or after `timeoutMs`. */
87
+ waitForCatalogSettled: (timeoutMs: number) => Promise<void>;
88
+ present: (moment: string) => Promise<PresentResult>;
89
+ timeoutMs: number;
90
+ };
91
+ /**
92
+ * `register(moment, feature)`'s whole orchestration.
93
+ *
94
+ * Lives here rather than inside `PaywallProvider` so every branch — both
95
+ * fail-open paths, the wait-once rule, the Stripe warning, and the
96
+ * withhold-on-dismiss case — is covered by a plain async test. This repo has no
97
+ * vitest config, so tests run without a DOM; a provider-rendering test would mean
98
+ * adding jsdom to assert control flow that has nothing to do with rendering.
99
+ *
100
+ * It delegates presentation to the injected `present`, which in the provider is
101
+ * the real one — so the wedge recovery, the purchase-generation race guard and
102
+ * outcome reconciliation all apply unchanged.
103
+ */
104
+ export declare const runRegister: (deps: RegisterDeps, moment: string, feature?: RegisterFeature) => Promise<RegisterResult>;
105
+ //# sourceMappingURL=register.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/paywalls/register.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,YAAY,GAAG,qBAAqB,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,cAAc,GAAG,IAAI,EAC9B,eAAe,aAAa,EAC5B,QAAQ,MAAM,KACb,gBAaF,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,aAAa,KAAG,OAC1B,CAAC;AAEjC;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,GAAG,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,YAAY,GAAG,qBAAqB,CAAA;CAAE,GAC7E;IAAE,GAAG,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,GAC3E;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAAC;AAErF;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,cAAc,GAAG,IAAI,CAAC;IACxC,gBAAgB,EAAE,MAAM,aAAa,CAAC;IACtC,qEAAqE;IACrE,qBAAqB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,YAAY,EAClB,QAAQ,MAAM,EACd,UAAU,eAAe,KACxB,OAAO,CAAC,cAAc,CAoDxB,CAAC"}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runRegister = exports.shouldRunFeature = exports.resolveRegisterDecision = void 0;
4
+ /**
5
+ * `wait` is a DECISION rather than something the caller infers from
6
+ * `catalogStatus` itself, so "when may register block?" has exactly one answer in
7
+ * one tested place. The caller awaits the catalog settling and calls this again;
8
+ * the second call cannot return `wait`, because the wait resolves only on
9
+ * `"ready"`/`"error"` and a timeout is treated as `catalog-unavailable` without
10
+ * asking again.
11
+ *
12
+ * `"revalidating"` counts as usable. That is safe only because the AsyncStorage
13
+ * cache key is scoped by audience params: before that, a revalidating catalog
14
+ * might have been resolved under DIFFERENT params, so a missing moment could
15
+ * mean "not yet" rather than "absent". Now a served catalog always matches the
16
+ * current params.
17
+ */
18
+ const resolveRegisterDecision = (catalog, catalogStatus, moment) => {
19
+ if (!catalog) {
20
+ // Nothing to decide against yet. "loading" is worth waiting for; anything
21
+ // else with no catalog is terminal.
22
+ return catalogStatus === "loading"
23
+ ? { type: "wait" }
24
+ : { type: "run", reason: "catalog-unavailable" };
25
+ }
26
+ const paywall = catalog.paywalls[moment];
27
+ // A moment absent from a RESOLVED catalog is not a failure: it means the moment
28
+ // is not monetised, or is not authored yet. The feature is free.
29
+ if (!paywall)
30
+ return { type: "run", reason: "no-paywall" };
31
+ return { type: "present", paywall };
32
+ };
33
+ exports.resolveRegisterDecision = resolveRegisterDecision;
34
+ /**
35
+ * Whether a completed presentation unlocks the feature. Only a purchase does.
36
+ *
37
+ * This one-liner is correct only because `resolvePresentedOutcome` already
38
+ * upgraded the generic `{status:"dismissed"}` that the canonical authoring shape
39
+ * — `{type:"purchase", onSuccess:[{type:"dismiss"}]}` — produces into
40
+ * `"purchased"` when the store actually charged. Without that upgrade this would
41
+ * refuse the feature to every user who bought.
42
+ *
43
+ * **A Stripe paywall never unlocks on the purchase alone.** `PresentResult` has
44
+ * no `"pending"` status — that belongs to `PurchaseResult` — so a Payment Link
45
+ * checkout surfaces here as whatever its action list reported, in practice
46
+ * `"dismissed"` via its `onPending` branch. The entitlement arrives out-of-band
47
+ * through RevenueCat, so grant access from that webhook rather than from
48
+ * `register`. `runRegister` warns when it is about to present one.
49
+ */
50
+ const shouldRunFeature = (outcome) => outcome.status === "purchased";
51
+ exports.shouldRunFeature = shouldRunFeature;
52
+ /**
53
+ * `register(moment, feature)`'s whole orchestration.
54
+ *
55
+ * Lives here rather than inside `PaywallProvider` so every branch — both
56
+ * fail-open paths, the wait-once rule, the Stripe warning, and the
57
+ * withhold-on-dismiss case — is covered by a plain async test. This repo has no
58
+ * vitest config, so tests run without a DOM; a provider-rendering test would mean
59
+ * adding jsdom to assert control flow that has nothing to do with rendering.
60
+ *
61
+ * It delegates presentation to the injected `present`, which in the provider is
62
+ * the real one — so the wedge recovery, the purchase-generation race guard and
63
+ * outcome reconciliation all apply unchanged.
64
+ */
65
+ const runRegister = async (deps, moment, feature) => {
66
+ let decision = (0, exports.resolveRegisterDecision)(deps.getCatalog(), deps.getCatalogStatus(), moment);
67
+ if (decision.type === "wait") {
68
+ // Called on a user tap, so it cannot simply fail because the catalog has not
69
+ // landed. In practice a returning user's catalog is already on disk and this
70
+ // resolves immediately.
71
+ await deps.waitForCatalogSettled(deps.timeoutMs);
72
+ decision = (0, exports.resolveRegisterDecision)(deps.getCatalog(), deps.getCatalogStatus(), moment);
73
+ // The wait timed out with the catalog still loading. Decide — never wait a
74
+ // second time, or a permanently-loading catalog would park the caller
75
+ // forever in `timeoutMs` increments.
76
+ if (decision.type === "wait")
77
+ decision = { type: "run", reason: "catalog-unavailable" };
78
+ }
79
+ if (decision.type === "run") {
80
+ if (decision.reason === "catalog-unavailable") {
81
+ // Failing OPEN. The alternative locks every gated feature behind a network
82
+ // call: an offline launch would make the app's features silently dead with
83
+ // no paywall to explain why, which is indistinguishable from a broken app.
84
+ // The cost is real — some sessions get a paid feature free — so it is
85
+ // logged, and the returned `reason` lets a host measure the rate.
86
+ console.warn(`[paywalls] register("${moment}") could not reach a verdict (no paywall catalog) ` +
87
+ "and ran the feature ungated. The catalog failed to load, or is still loading " +
88
+ "after the register timeout.");
89
+ }
90
+ await (feature === null || feature === void 0 ? void 0 : feature());
91
+ return { ran: true, presented: false, reason: decision.reason };
92
+ }
93
+ if (decision.paywall.billing === "stripe") {
94
+ // See `shouldRunFeature`: a Payment Link checkout never produces a
95
+ // "purchased" PresentResult, so the gated feature cannot unlock from it.
96
+ console.warn(`[paywalls] register("${moment}") will present a Stripe-billed paywall. A Payment ` +
97
+ 'Link checkout never resolves as "purchased" — the entitlement arrives out-of-band ' +
98
+ "through RevenueCat — so the gated feature will NOT run on a successful checkout. " +
99
+ "Grant access from your RevenueCat entitlement webhook instead.");
100
+ }
101
+ const outcome = await deps.present(moment);
102
+ if ((0, exports.shouldRunFeature)(outcome)) {
103
+ await (feature === null || feature === void 0 ? void 0 : feature());
104
+ return { ran: true, presented: true, reason: "purchased", outcome };
105
+ }
106
+ // Covers dismissed, cancelled and every `present()` error — including
107
+ // "already-presenting", which needs no branch of its own: the feature does not
108
+ // run and the in-flight paywall is untouched.
109
+ return { ran: false, presented: true, reason: "not-purchased", outcome };
110
+ };
111
+ exports.runRegister = runRegister;
112
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/paywalls/register.ts"],"names":[],"mappings":";;;AAiBA;;;;;;;;;;;;;GAaG;AACI,MAAM,uBAAuB,GAAG,CACrC,OAA8B,EAC9B,aAA4B,EAC5B,MAAc,EACI,EAAE;IACpB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,0EAA0E;QAC1E,oCAAoC;QACpC,OAAO,aAAa,KAAK,SAAS;YAChC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE;YAClB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IACrD,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzC,gFAAgF;IAChF,iEAAiE;IACjE,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,IAAI,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