@rocapine/react-native-onboarding 1.73.0 → 1.74.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +136 -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 +11 -2
  15. package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
  16. package/dist/infra/provider/OnboardingProvider.js +26 -2
  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 +63 -0
  65. package/dist/userProperties/store.d.ts.map +1 -0
  66. package/dist/userProperties/store.js +153 -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 +1 -1
  77. package/src/OnboardingStudio.ts +147 -0
  78. package/src/OnboardingStudioClient.ts +27 -11
  79. package/src/__tests__/OnboardingStudio.test.ts +208 -0
  80. package/src/__tests__/cacheKey.test.ts +71 -0
  81. package/src/__tests__/getOnboarding.query.test.ts +47 -8
  82. package/src/index.ts +43 -0
  83. package/src/infra/provider/OnboardingProvider.tsx +45 -4
  84. package/src/infra/queries/cacheKey.ts +54 -9
  85. package/src/infra/queries/getOnboarding.query.ts +9 -1
  86. package/src/paywalls/PaywallProvider.tsx +162 -6
  87. package/src/paywalls/__tests__/catalogSettleWaiter.test.ts +134 -0
  88. package/src/paywalls/__tests__/getPaywalls.test.ts +29 -11
  89. package/src/paywalls/__tests__/register.test.ts +266 -0
  90. package/src/paywalls/catalogSettleWaiter.ts +72 -0
  91. package/src/paywalls/getPaywalls.query.ts +9 -1
  92. package/src/paywalls/register.ts +169 -0
  93. package/src/paywalls/usePaywall.ts +40 -2
  94. package/src/userProperties/__tests__/effectiveParams.test.ts +51 -0
  95. package/src/userProperties/__tests__/primitives.test.ts +96 -0
  96. package/src/userProperties/__tests__/store.test.ts +181 -0
  97. package/src/userProperties/applyPatch.ts +68 -0
  98. package/src/userProperties/effectiveParams.ts +60 -0
  99. package/src/userProperties/index.ts +11 -0
  100. package/src/userProperties/reserved.ts +44 -0
  101. package/src/userProperties/serialize.ts +61 -0
  102. package/src/userProperties/store.ts +177 -0
  103. package/src/userProperties/types.ts +22 -0
  104. package/src/userProperties/useUserProperties.ts +26 -0
@@ -10,6 +10,9 @@ const FontLoader_1 = require("./FontLoader");
10
10
  const extractAssetUrls_1 = require("../preload/extractAssetUrls");
11
11
  const preloadAssets_1 = require("../preload/preloadAssets");
12
12
  const unknownKeys_1 = require("../../screens/unknownKeys");
13
+ const useUserProperties_1 = require("../../userProperties/useUserProperties");
14
+ const effectiveParams_1 = require("../../userProperties/effectiveParams");
15
+ const OnboardingStudio_1 = require("../../OnboardingStudio");
13
16
  const expoRouterAdapter_1 = require("../navigation/expoRouterAdapter");
14
17
  const useProducts_1 = require("../../products/useProducts");
15
18
  const ProductRuntimeContext_1 = require("../../products/ProductRuntimeContext");
@@ -63,7 +66,17 @@ exports.resolveLocalProductArgs = resolveLocalProductArgs;
63
66
  // whole tree. Same reason EMPTY_PRODUCT_RUNTIME above is hoisted.
64
67
  const EMPTY_CUSTOM_ACTIONS = Object.freeze({});
65
68
  const OnboardingDataGate = ({ client, locale, customAudienceParams, setOnboarding, fontsFallback, children, }) => {
66
- const { data, error } = (0, react_query_1.useQuery)((0, getOnboarding_query_1.getOnboardingQuery)(client, locale, customAudienceParams, setOnboarding));
69
+ // Same merge the paywall provider does, for the same reason: one store feeds
70
+ // both waterfalls, so an onboarding audience and a paywall audience can no
71
+ // longer disagree about the same user. See `resolveEffectiveParams`.
72
+ const { properties, status: propertiesStatus } = (0, useUserProperties_1.useUserProperties)();
73
+ const params = (0, react_1.useMemo)(() => (0, effectiveParams_1.resolveEffectiveParams)(customAudienceParams, properties), [customAudienceParams, properties]);
74
+ const { data, error } = (0, react_query_1.useQuery)(Object.assign(Object.assign({}, (0, getOnboarding_query_1.getOnboardingQuery)(client, locale, params, setOnboarding)), {
75
+ // Held until the store hydrates — otherwise the first fetch of a cold launch
76
+ // is audience-matched against an empty property map. This gate renders
77
+ // `fontsFallback`, the state this gate already shows while the payload
78
+ // loads, so nothing new appears on screen.
79
+ enabled: propertiesStatus === "ready" }));
67
80
  // Background asset preload: once the payload is available, warm every remote
68
81
  // image/video/Lottie/Rive asset so later screens render without a load flash.
69
82
  // Fire-and-forget and non-blocking — does NOT gate the FontLoaderGate render.
@@ -92,8 +105,19 @@ const OnboardingDataGate = ({ client, locale, customAudienceParams, setOnboardin
92
105
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fontsFallback !== null && fontsFallback !== void 0 ? fontsFallback : null });
93
106
  return ((0, jsx_runtime_1.jsx)(FontLoader_1.FontLoaderGate, { fonts: data.fonts, fallback: fontsFallback, children: children }));
94
107
  };
95
- const OnboardingProvider = ({ children, client, locale = "en", customAudienceParams = {}, customActions = EMPTY_CUSTOM_ACTIONS, fontsFallback, navigation = expoRouterAdapter_1.expoRouterAdapter, onComplete, productProvider, productRefs, }) => {
108
+ const OnboardingProvider = ({ children, client: clientProp, locale = "en", customAudienceParams = {}, customActions = EMPTY_CUSTOM_ACTIONS, fontsFallback, navigation = expoRouterAdapter_1.expoRouterAdapter, onComplete, productProvider, productRefs, }) => {
96
109
  var _a;
110
+ // An explicit prop wins; otherwise use whatever `OnboardingStudio.init()`
111
+ // built. THROWN rather than degraded, unlike `PaywallProvider`: this provider
112
+ // wraps an onboarding, so a host `ErrorBoundary` catches it and the rest of the
113
+ // app survives — and an onboarding with no client has nothing at all to render,
114
+ // where a paywall-less app is merely un-monetised.
115
+ //
116
+ // Read during render, so `init()` must run BEFORE the first render — at module
117
+ // scope, which is where the warning tells a host to put it.
118
+ const client = (0, OnboardingStudio_1.resolveProviderClient)(clientProp, OnboardingStudio_1.OnboardingStudio.getClient());
119
+ if (!client)
120
+ throw new Error(OnboardingStudio_1.MISSING_CLIENT_MESSAGE);
97
121
  const [activeStep, setActiveStep] = (0, react_1.useState)({
98
122
  number: 0,
99
123
  displayProgressHeader: false,
@@ -1 +1 @@
1
- {"version":3,"file":"OnboardingProvider.js","sourceRoot":"","sources":["../../../src/infra/provider/OnboardingProvider.tsx"],"names":[],"mappings":";;;;AAAA,iCAAyF;AACzF,uDAAmF;AACnF,yEAAsE;AACtE,wEAAoE;AAIpE,6CAA8C;AAC9C,kEAA+D;AAC/D,4DAAyD;AACzD,2DAAgG;AAEhG,uEAAoE;AACpE,4DAAyD;AAEzD,gFAAyE;AACzE,8EAA2E;AAK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B,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,GAAG,EAAE,GAAG,CAAC;IACtB,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC;IACxB,kBAAkB,EAAE,GAAG,EAAE,GAAG,CAAC;IAC7B,aAAa,EAAE,EAAE;IACjB,UAAU,EAAE,qCAAiB;IAC7B,QAAQ,EAAE,qBAAqB;CAChC,CAAC,CAAC"}
@@ -5,8 +5,40 @@
5
5
  * Lives in its own module so `getOnboarding.query.ts`, `getPaywalls.query.ts`
6
6
  * and `OnboardingStudioClient` can all use these as values without a circular
7
7
  * import (the query modules import `OnboardingStudioClient` for typing) —
8
- * this module itself has no imports.
8
+ * this module itself has no imports, and must keep none that reach
9
+ * `OnboardingStudioClient`.
10
+ *
11
+ * ## Why the key is scoped by params
12
+ *
13
+ * The react-query key has always been scoped by `customAudienceParams`; this
14
+ * disk key was a bare constant. So a cache-first read could serve a payload
15
+ * resolved under DIFFERENT params — non-null, and therefore indistinguishable
16
+ * from a correct one — with a fresh fetch in flight behind it.
17
+ *
18
+ * Observed in production: an audience gated on `hoursSinceOnboardingPaywall >= 44`
19
+ * was served the pre-threshold catalog on the launch where the user first became
20
+ * eligible, so the arm under test lost exactly the launch that mattered.
21
+ *
22
+ * That needed volatile params to trigger, which was rare while params were a
23
+ * static prop. The user-property store makes volatile params normal, so the key
24
+ * carries a hash of the resolved params (`userProperties/serialize.ts`'s
25
+ * `paramsHash`). An EMPTY hash yields the legacy key byte-for-byte, so shipping
26
+ * this does not invalidate existing installs.
27
+ *
28
+ * Every key these helpers can produce starts with one of the two prefixes below,
29
+ * which is what lets `OnboardingStudioClient.clearCache` find them all by
30
+ * scanning rather than by naming a key it can no longer predict.
9
31
  */
32
+ /**
33
+ * Every onboarding cache key starts with this — `clearCache` scans on it.
34
+ *
35
+ * Deliberately NOT a bare `rocapine-`: `USER_PROPERTIES_STORAGE_KEY` is
36
+ * `rocapine-user-properties`, and clearing a payload cache must not forget who
37
+ * the user is.
38
+ */
39
+ export declare const ONBOARDING_CACHE_KEY_PREFIX = "rocapine-onboarding";
40
+ /** Every paywall cache key starts with this — `clearCache` scans on it. */
41
+ export declare const PAYWALLS_CACHE_KEY_PREFIX = "rocapine-paywalls";
10
42
  /** Default cache key used when the host does not provide a custom one. */
11
43
  export declare const DEFAULT_ONBOARDING_CACHE_KEY = "rocapine-onboarding-studio";
12
44
  /**
@@ -17,8 +49,11 @@ export declare const DEFAULT_ONBOARDING_CACHE_KEY = "rocapine-onboarding-studio"
17
49
  * - Custom key → `"rocapine-onboarding-sdk-{customKey}"`, which the SDK
18
50
  * persists cache-first with **no** background revalidation, so the host owns
19
51
  * when to refetch (see `OnboardingStudioClient.clearCache`).
52
+ *
53
+ * `paramsHash` scopes the key to the resolved audience params — see the module
54
+ * doc. Omit it (or pass `""`) for the legacy, unscoped key.
20
55
  */
21
- export declare const getOnboardingCacheKey: (customKey?: string) => string;
56
+ export declare const getOnboardingCacheKey: (customKey?: string, paramsHash?: string) => string;
22
57
  /** Default cache key used when the host does not provide a custom one. */
23
58
  export declare const DEFAULT_PAYWALLS_CACHE_KEY = "rocapine-paywalls-studio";
24
59
  /**
@@ -33,6 +68,9 @@ export declare const DEFAULT_PAYWALLS_CACHE_KEY = "rocapine-paywalls-studio";
33
68
  * - Custom key → `"rocapine-paywalls-sdk-{customKey}"`, which the SDK persists
34
69
  * cache-first with **no** background revalidation, so the host owns when to
35
70
  * refetch (see `OnboardingStudioClient.clearCache`).
71
+ *
72
+ * `paramsHash` scopes the key to the resolved audience params — see the module
73
+ * doc. Omit it (or pass `""`) for the legacy, unscoped key.
36
74
  */
37
- export declare const getPaywallsCacheKey: (customKey?: string) => string;
75
+ export declare const getPaywallsCacheKey: (customKey?: string, paramsHash?: string) => string;
38
76
  //# sourceMappingURL=cacheKey.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cacheKey.d.ts","sourceRoot":"","sources":["../../../src/infra/queries/cacheKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0EAA0E;AAC1E,eAAO,MAAM,4BAA4B,+BAA+B,CAAC;AAEzE;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,YAAY,MAAM,KAAG,MAGzB,CAAC;AAEnC,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,6BAA6B,CAAC;AAErE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,KAAG,MAGzB,CAAC"}
1
+ {"version":3,"file":"cacheKey.d.ts","sourceRoot":"","sources":["../../../src/infra/queries/cacheKey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,wBAAwB,CAAC;AAEjE,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,sBAAsB,CAAC;AAK7D,0EAA0E;AAC1E,eAAO,MAAM,4BAA4B,+BAA+B,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,GAAI,YAAY,MAAM,EAAE,aAAa,MAAM,KAAG,MAI7E,CAAC;AAEJ,0EAA0E;AAC1E,eAAO,MAAM,0BAA0B,6BAA6B,CAAC;AAErE;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,GAAI,YAAY,MAAM,EAAE,aAAa,MAAM,KAAG,MAI3E,CAAC"}
@@ -6,10 +6,44 @@
6
6
  * Lives in its own module so `getOnboarding.query.ts`, `getPaywalls.query.ts`
7
7
  * and `OnboardingStudioClient` can all use these as values without a circular
8
8
  * import (the query modules import `OnboardingStudioClient` for typing) —
9
- * this module itself has no imports.
9
+ * this module itself has no imports, and must keep none that reach
10
+ * `OnboardingStudioClient`.
11
+ *
12
+ * ## Why the key is scoped by params
13
+ *
14
+ * The react-query key has always been scoped by `customAudienceParams`; this
15
+ * disk key was a bare constant. So a cache-first read could serve a payload
16
+ * resolved under DIFFERENT params — non-null, and therefore indistinguishable
17
+ * from a correct one — with a fresh fetch in flight behind it.
18
+ *
19
+ * Observed in production: an audience gated on `hoursSinceOnboardingPaywall >= 44`
20
+ * was served the pre-threshold catalog on the launch where the user first became
21
+ * eligible, so the arm under test lost exactly the launch that mattered.
22
+ *
23
+ * That needed volatile params to trigger, which was rare while params were a
24
+ * static prop. The user-property store makes volatile params normal, so the key
25
+ * carries a hash of the resolved params (`userProperties/serialize.ts`'s
26
+ * `paramsHash`). An EMPTY hash yields the legacy key byte-for-byte, so shipping
27
+ * this does not invalidate existing installs.
28
+ *
29
+ * Every key these helpers can produce starts with one of the two prefixes below,
30
+ * which is what lets `OnboardingStudioClient.clearCache` find them all by
31
+ * scanning rather than by naming a key it can no longer predict.
10
32
  */
11
33
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getPaywallsCacheKey = exports.DEFAULT_PAYWALLS_CACHE_KEY = exports.getOnboardingCacheKey = exports.DEFAULT_ONBOARDING_CACHE_KEY = void 0;
34
+ exports.getPaywallsCacheKey = exports.DEFAULT_PAYWALLS_CACHE_KEY = exports.getOnboardingCacheKey = exports.DEFAULT_ONBOARDING_CACHE_KEY = exports.PAYWALLS_CACHE_KEY_PREFIX = exports.ONBOARDING_CACHE_KEY_PREFIX = void 0;
35
+ /**
36
+ * Every onboarding cache key starts with this — `clearCache` scans on it.
37
+ *
38
+ * Deliberately NOT a bare `rocapine-`: `USER_PROPERTIES_STORAGE_KEY` is
39
+ * `rocapine-user-properties`, and clearing a payload cache must not forget who
40
+ * the user is.
41
+ */
42
+ exports.ONBOARDING_CACHE_KEY_PREFIX = "rocapine-onboarding";
43
+ /** Every paywall cache key starts with this — `clearCache` scans on it. */
44
+ exports.PAYWALLS_CACHE_KEY_PREFIX = "rocapine-paywalls";
45
+ /** Appends the params fingerprint, or nothing at all when there are no params. */
46
+ const withHash = (base, hash) => (hash ? `${base}-${hash}` : base);
13
47
  /** Default cache key used when the host does not provide a custom one. */
14
48
  exports.DEFAULT_ONBOARDING_CACHE_KEY = "rocapine-onboarding-studio";
15
49
  /**
@@ -20,10 +54,11 @@ exports.DEFAULT_ONBOARDING_CACHE_KEY = "rocapine-onboarding-studio";
20
54
  * - Custom key → `"rocapine-onboarding-sdk-{customKey}"`, which the SDK
21
55
  * persists cache-first with **no** background revalidation, so the host owns
22
56
  * when to refetch (see `OnboardingStudioClient.clearCache`).
57
+ *
58
+ * `paramsHash` scopes the key to the resolved audience params — see the module
59
+ * doc. Omit it (or pass `""`) for the legacy, unscoped key.
23
60
  */
24
- const getOnboardingCacheKey = (customKey) => customKey
25
- ? `rocapine-onboarding-sdk-${customKey}`
26
- : exports.DEFAULT_ONBOARDING_CACHE_KEY;
61
+ const getOnboardingCacheKey = (customKey, paramsHash) => withHash(customKey ? `rocapine-onboarding-sdk-${customKey}` : exports.DEFAULT_ONBOARDING_CACHE_KEY, paramsHash);
27
62
  exports.getOnboardingCacheKey = getOnboardingCacheKey;
28
63
  /** Default cache key used when the host does not provide a custom one. */
29
64
  exports.DEFAULT_PAYWALLS_CACHE_KEY = "rocapine-paywalls-studio";
@@ -39,9 +74,10 @@ exports.DEFAULT_PAYWALLS_CACHE_KEY = "rocapine-paywalls-studio";
39
74
  * - Custom key → `"rocapine-paywalls-sdk-{customKey}"`, which the SDK persists
40
75
  * cache-first with **no** background revalidation, so the host owns when to
41
76
  * refetch (see `OnboardingStudioClient.clearCache`).
77
+ *
78
+ * `paramsHash` scopes the key to the resolved audience params — see the module
79
+ * doc. Omit it (or pass `""`) for the legacy, unscoped key.
42
80
  */
43
- const getPaywallsCacheKey = (customKey) => customKey
44
- ? `rocapine-paywalls-sdk-${customKey}`
45
- : exports.DEFAULT_PAYWALLS_CACHE_KEY;
81
+ const getPaywallsCacheKey = (customKey, paramsHash) => withHash(customKey ? `rocapine-paywalls-sdk-${customKey}` : exports.DEFAULT_PAYWALLS_CACHE_KEY, paramsHash);
46
82
  exports.getPaywallsCacheKey = getPaywallsCacheKey;
47
83
  //# sourceMappingURL=cacheKey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cacheKey.js","sourceRoot":"","sources":["../../../src/infra/queries/cacheKey.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,0EAA0E;AAC7D,QAAA,4BAA4B,GAAG,4BAA4B,CAAC;AAEzE;;;;;;;;GAQG;AACI,MAAM,qBAAqB,GAAG,CAAC,SAAkB,EAAU,EAAE,CAClE,SAAS;IACP,CAAC,CAAC,2BAA2B,SAAS,EAAE;IACxC,CAAC,CAAC,oCAA4B,CAAC;AAHtB,QAAA,qBAAqB,yBAGC;AAEnC,0EAA0E;AAC7D,QAAA,0BAA0B,GAAG,0BAA0B,CAAC;AAErE;;;;;;;;;;;;GAYG;AACI,MAAM,mBAAmB,GAAG,CAAC,SAAkB,EAAU,EAAE,CAChE,SAAS;IACP,CAAC,CAAC,yBAAyB,SAAS,EAAE;IACtC,CAAC,CAAC,kCAA0B,CAAC;AAHpB,QAAA,mBAAmB,uBAGC"}
1
+ {"version":3,"file":"cacheKey.js","sourceRoot":"","sources":["../../../src/infra/queries/cacheKey.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAEH;;;;;;GAMG;AACU,QAAA,2BAA2B,GAAG,qBAAqB,CAAC;AAEjE,2EAA2E;AAC9D,QAAA,yBAAyB,GAAG,mBAAmB,CAAC;AAE7D,kFAAkF;AAClF,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,IAAa,EAAU,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAE5F,0EAA0E;AAC7D,QAAA,4BAA4B,GAAG,4BAA4B,CAAC;AAEzE;;;;;;;;;;;GAWG;AACI,MAAM,qBAAqB,GAAG,CAAC,SAAkB,EAAE,UAAmB,EAAU,EAAE,CACvF,QAAQ,CACN,SAAS,CAAC,CAAC,CAAC,2BAA2B,SAAS,EAAE,CAAC,CAAC,CAAC,oCAA4B,EACjF,UAAU,CACX,CAAC;AAJS,QAAA,qBAAqB,yBAI9B;AAEJ,0EAA0E;AAC7D,QAAA,0BAA0B,GAAG,0BAA0B,CAAC;AAErE;;;;;;;;;;;;;;;GAeG;AACI,MAAM,mBAAmB,GAAG,CAAC,SAAkB,EAAE,UAAmB,EAAU,EAAE,CACrF,QAAQ,CACN,SAAS,CAAC,CAAC,CAAC,yBAAyB,SAAS,EAAE,CAAC,CAAC,CAAC,kCAA0B,EAC7E,UAAU,CACX,CAAC;AAJS,QAAA,mBAAmB,uBAI5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"getOnboarding.query.d.ts","sourceRoot":"","sources":["../../../src/infra/queries/getOnboarding.query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAI3E,eAAO,MAAM,kBAAkB,GAAI,QAAQ,SAAS,YAAY,EAC9D,QAAQ,sBAAsB,EAC9B,QAAQ,MAAM,EACd,sBAAsB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzC,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,KAAK,IAAI;;mBAYrC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;;CAwEnD,CAAC"}
1
+ {"version":3,"file":"getOnboarding.query.d.ts","sourceRoot":"","sources":["../../../src/infra/queries/getOnboarding.query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAsB,MAAM,aAAa,CAAC;AAK3E,eAAO,MAAM,kBAAkB,GAAI,QAAQ,SAAS,YAAY,EAC9D,QAAQ,sBAAsB,EAC9B,QAAQ,MAAM,EACd,sBAAsB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzC,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,KAAK,IAAI;;mBAYrC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;;CA+EnD,CAAC"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getOnboardingQuery = void 0;
7
7
  const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
8
8
  const cacheKey_1 = require("./cacheKey");
9
+ const serialize_1 = require("../../userProperties/serialize");
9
10
  const getOnboardingQuery = (client, locale, customAudienceParams, setOnboarding) => {
10
11
  return {
11
12
  queryKey: [
@@ -24,7 +25,11 @@ const getOnboardingQuery = (client, locale, customAudienceParams, setOnboarding)
24
25
  // with NO background revalidation, so a pinned version survives across
25
26
  // launches. The default key keeps stale-while-revalidate.
26
27
  const hasCustomKey = Boolean(client.options.cacheKey);
27
- const cacheKey = (0, cacheKey_1.getOnboardingCacheKey)(client.options.cacheKey);
28
+ // Scoped by the resolved audience params — see `cacheKey.ts`. The provider
29
+ // hands these over already serialized to strings
30
+ // (`userProperties/effectiveParams.ts`), so the hash sees the same bytes
31
+ // that go on the querystring.
32
+ const cacheKey = (0, cacheKey_1.getOnboardingCacheKey)(client.options.cacheKey, (0, serialize_1.paramsHash)(customAudienceParams));
28
33
  // Fetches the live payload, pushes it to the provider, and caches it —
29
34
  // but NEVER caches the offline fallback. Caching the fallback (with
30
35
  // `staleTime: Infinity` + cache-first below) would pin every future
@@ -1 +1 @@
1
- {"version":3,"file":"getOnboarding.query.js","sourceRoot":"","sources":["../../../src/infra/queries/getOnboarding.query.ts"],"names":[],"mappings":";;;;;;AAAA,8FAAqE;AAIrE,yCAAmD;AAE5C,MAAM,kBAAkB,GAAG,CAChC,MAA8B,EAC9B,MAAc,EACd,oBAAyC,EACzC,aAA0D,EAC1D,EAAE;IACF,OAAO;QACL,QAAQ,EAAE;YACR,qBAAqB;YACrB,MAAM,CAAC,SAAS;YAChB,MAA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AAK,CAAC,CAAC,KAAK,EAAE,EAAE;wBACnC,OAAO,CAAC,IAAI,CAAC,4CAA4C,EAAE,KAAK,CAAC,CAAC;oBACpE,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;YAED,yEAAyE;YACzE,oEAAoE;YACpE,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC;QACD,SAAS,EAAE,QAAQ;KACpB,CAAC;AACJ,CAAC,CAAC;AA/FW,QAAA,kBAAkB,sBA+F7B"}
@@ -4,6 +4,7 @@ import { type CatalogStatus } from "./present";
4
4
  import { ProductProvider, ProductStatus } from "../products/types";
5
5
  import type { CustomActions } from "../infra/provider/OnboardingProvider";
6
6
  import type { CustomPaywallScreens } from "./customScreens";
7
+ import { type RegisterFeature, type RegisterResult } from "./register";
7
8
  /**
8
9
  * Everything a paywall consumer or a paywall HOST needs. Deliberately one
9
10
  * context carrying both, mirroring how `OnboardingProgressContext` bundles
@@ -13,6 +14,20 @@ import type { CustomPaywallScreens } from "./customScreens";
13
14
  */
14
15
  export type PaywallContextValue = {
15
16
  present: (moment: string) => Promise<PresentResult>;
17
+ /**
18
+ * Gate a feature on a moment: `register("unlock_stats", () => go())`.
19
+ *
20
+ * Runs the feature immediately when the moment has no paywall (it is not
21
+ * monetised, or not authored yet), otherwise presents the moment's paywall and
22
+ * runs the feature ONLY on a purchase. Gates on the moment alone — there is no
23
+ * entitlement check; exclude subscribers with an audience filter on a user
24
+ * property.
25
+ *
26
+ * Fails OPEN: when no catalog is reachable it runs the feature and warns, so an
27
+ * offline launch does not silently disable the app's features. The resolved
28
+ * `reason` reports which path was taken, so a host can measure that rate.
29
+ */
30
+ register: (moment: string, feature?: RegisterFeature) => Promise<RegisterResult>;
16
31
  isReady: boolean;
17
32
  catalog: PaywallCatalog | null;
18
33
  /**
@@ -75,6 +90,12 @@ export type PaywallContextValue = {
75
90
  */
76
91
  customScreens: CustomPaywallScreens;
77
92
  };
93
+ /**
94
+ * How long `register()` waits for the catalog to settle before deciding without
95
+ * it. Generous enough that a cold network fetch usually lands, short enough that
96
+ * a tap does not feel stuck.
97
+ */
98
+ export declare const DEFAULT_REGISTER_TIMEOUT_MS = 3000;
78
99
  export declare const PaywallContext: import("react").Context<PaywallContextValue>;
79
100
  /**
80
101
  * The seam a paywall HOST (Task 7's `PaywallHost`) reads from — analogous to
@@ -86,7 +107,15 @@ export declare const PaywallContext: import("react").Context<PaywallContextValue
86
107
  export declare const usePaywallHost: () => Pick<PaywallContextValue, "activePaywall" | "complete" | "acknowledgePresentation" | "customActions" | "customScreens">;
87
108
  interface PaywallProviderProps {
88
109
  children: React.ReactNode;
89
- client: OnboardingStudioClient;
110
+ /**
111
+ * The studio client. Optional: omit it and the provider uses the client
112
+ * `OnboardingStudio.init({ projectId })` built. Passing one explicitly still
113
+ * wins, so an existing host is unaffected.
114
+ *
115
+ * With neither, this provider warns and renders `children` with paywalls inert
116
+ * — it does not throw, because it wraps the whole app.
117
+ */
118
+ client?: OnboardingStudioClient;
90
119
  locale?: string;
91
120
  customAudienceParams?: Record<string, any>;
92
121
  /**
@@ -140,6 +169,15 @@ interface PaywallProviderProps {
140
169
  * rest of the process. Only pass `null` if the host cannot acknowledge.
141
170
  */
142
171
  presentAckTimeoutMs?: number | null;
172
+ /**
173
+ * How long `register()` waits for the paywall catalog to settle before deciding
174
+ * without it. Defaults to 3000 ms.
175
+ *
176
+ * On timeout `register` fails OPEN — it runs the gated feature and warns. Lower
177
+ * it if a tap feels stuck on a slow network; raise it to give the catalog more
178
+ * chance to land before a feature is given away.
179
+ */
180
+ registerTimeoutMs?: number;
143
181
  }
144
182
  /**
145
183
  * App-level ancestor. Renders ABOVE `OnboardingProvider`, not inside it —
@@ -147,12 +185,22 @@ interface PaywallProviderProps {
147
185
  * only flows to descendants; two true siblings could not share one runtime).
148
186
  *
149
187
  * ```tsx
150
- * <PaywallProvider client={client} productProvider={revenueCatProductProvider(Purchases)}>
188
+ * OnboardingStudio.init({ projectId: "…" }); // at module scope
189
+ *
190
+ * <PaywallProvider productProvider={revenueCatProductProvider(Purchases)}>
151
191
  * <App />
152
- * <PaywallHost /> // Task 7: renders the active paywall in a fullScreen RN Modal
192
+ * <PaywallHost /> // renders the active paywall in a fullScreen RN Modal
153
193
  * </PaywallProvider>
154
194
  * ```
195
+ *
196
+ * With no client at all — neither a prop nor an `OnboardingStudio.init()` — this
197
+ * WARNS and renders `children` untouched, so paywalls are inert and the app
198
+ * still runs. It deliberately does not throw the way `OnboardingProvider` does:
199
+ * this provider wraps the whole app (see the query-error effect inside), so
200
+ * throwing would take down every screen over a missing paywall client. Consumers
201
+ * then read the default context, where `isProviderMounted` is `false` and both
202
+ * `present` and `register` resolve their fail-open answers.
155
203
  */
156
- export declare const PaywallProvider: ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, customScreens, presentAckTimeoutMs, }: PaywallProviderProps) => import("react/jsx-runtime").JSX.Element;
204
+ export declare const PaywallProvider: ({ children, client: clientProp, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, customScreens, presentAckTimeoutMs, registerTimeoutMs, }: PaywallProviderProps) => import("react/jsx-runtime").JSX.Element;
157
205
  export {};
158
206
  //# sourceMappingURL=PaywallProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PaywallProvider.d.ts","sourceRoot":"","sources":["../../src/paywalls/PaywallProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAKL,KAAK,aAAa,EAOnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,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AC"}
@@ -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