@rocapine/react-native-onboarding 1.72.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.
- package/README.md +136 -3
- package/dist/OnboardingStudio.d.ts +82 -0
- package/dist/OnboardingStudio.d.ts.map +1 -0
- package/dist/OnboardingStudio.js +91 -0
- package/dist/OnboardingStudio.js.map +1 -0
- package/dist/OnboardingStudioClient.d.ts +14 -5
- package/dist/OnboardingStudioClient.d.ts.map +1 -1
- package/dist/OnboardingStudioClient.js +24 -9
- package/dist/OnboardingStudioClient.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -4
- package/dist/index.js.map +1 -1
- package/dist/infra/provider/OnboardingProvider.d.ts +11 -2
- package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
- package/dist/infra/provider/OnboardingProvider.js +26 -2
- package/dist/infra/provider/OnboardingProvider.js.map +1 -1
- package/dist/infra/queries/cacheKey.d.ts +41 -3
- package/dist/infra/queries/cacheKey.d.ts.map +1 -1
- package/dist/infra/queries/cacheKey.js +44 -8
- package/dist/infra/queries/cacheKey.js.map +1 -1
- package/dist/infra/queries/getOnboarding.query.d.ts.map +1 -1
- package/dist/infra/queries/getOnboarding.query.js +6 -1
- package/dist/infra/queries/getOnboarding.query.js.map +1 -1
- package/dist/paywalls/PaywallProvider.d.ts +95 -5
- package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
- package/dist/paywalls/PaywallProvider.js +121 -9
- package/dist/paywalls/PaywallProvider.js.map +1 -1
- package/dist/paywalls/catalogSettleWaiter.d.ts +31 -0
- package/dist/paywalls/catalogSettleWaiter.d.ts.map +1 -0
- package/dist/paywalls/catalogSettleWaiter.js +58 -0
- package/dist/paywalls/catalogSettleWaiter.js.map +1 -0
- package/dist/paywalls/customScreens.d.ts +83 -0
- package/dist/paywalls/customScreens.d.ts.map +1 -0
- package/dist/paywalls/customScreens.js +3 -0
- package/dist/paywalls/customScreens.js.map +1 -0
- package/dist/paywalls/getPaywalls.query.d.ts.map +1 -1
- package/dist/paywalls/getPaywalls.query.js +6 -1
- package/dist/paywalls/getPaywalls.query.js.map +1 -1
- package/dist/paywalls/register.d.ts +105 -0
- package/dist/paywalls/register.d.ts.map +1 -0
- package/dist/paywalls/register.js +112 -0
- package/dist/paywalls/register.js.map +1 -0
- package/dist/paywalls/usePaywall.d.ts +43 -0
- package/dist/paywalls/usePaywall.d.ts.map +1 -1
- package/dist/paywalls/usePaywall.js +11 -2
- package/dist/paywalls/usePaywall.js.map +1 -1
- package/dist/steps/Paywall/types.d.ts +63 -0
- package/dist/steps/Paywall/types.d.ts.map +1 -0
- package/dist/steps/Paywall/types.js +29 -0
- package/dist/steps/Paywall/types.js.map +1 -0
- package/dist/steps/types.d.ts +2 -1
- package/dist/steps/types.d.ts.map +1 -1
- package/dist/userProperties/applyPatch.d.ts +18 -0
- package/dist/userProperties/applyPatch.d.ts.map +1 -0
- package/dist/userProperties/applyPatch.js +57 -0
- package/dist/userProperties/applyPatch.js.map +1 -0
- package/dist/userProperties/effectiveParams.d.ts +29 -0
- package/dist/userProperties/effectiveParams.d.ts.map +1 -0
- package/dist/userProperties/effectiveParams.js +56 -0
- package/dist/userProperties/effectiveParams.js.map +1 -0
- package/dist/userProperties/index.d.ts +9 -0
- package/dist/userProperties/index.d.ts.map +1 -0
- package/dist/userProperties/index.js +21 -0
- package/dist/userProperties/index.js.map +1 -0
- package/dist/userProperties/reserved.d.ts +33 -0
- package/dist/userProperties/reserved.d.ts.map +1 -0
- package/dist/userProperties/reserved.js +45 -0
- package/dist/userProperties/reserved.js.map +1 -0
- package/dist/userProperties/serialize.d.ts +38 -0
- package/dist/userProperties/serialize.d.ts.map +1 -0
- package/dist/userProperties/serialize.js +67 -0
- package/dist/userProperties/serialize.js.map +1 -0
- package/dist/userProperties/store.d.ts +63 -0
- package/dist/userProperties/store.d.ts.map +1 -0
- package/dist/userProperties/store.js +153 -0
- package/dist/userProperties/store.js.map +1 -0
- package/dist/userProperties/types.d.ts +21 -0
- package/dist/userProperties/types.d.ts.map +1 -0
- package/dist/userProperties/types.js +3 -0
- package/dist/userProperties/types.js.map +1 -0
- package/dist/userProperties/useUserProperties.d.ts +20 -0
- package/dist/userProperties/useUserProperties.d.ts.map +1 -0
- package/dist/userProperties/useUserProperties.js +30 -0
- package/dist/userProperties/useUserProperties.js.map +1 -0
- package/package.json +1 -1
- package/src/OnboardingStudio.ts +147 -0
- package/src/OnboardingStudioClient.ts +27 -11
- package/src/__tests__/OnboardingStudio.test.ts +208 -0
- package/src/__tests__/cacheKey.test.ts +71 -0
- package/src/__tests__/getOnboarding.query.test.ts +47 -8
- package/src/index.ts +51 -0
- package/src/infra/provider/OnboardingProvider.tsx +45 -4
- package/src/infra/queries/cacheKey.ts +54 -9
- package/src/infra/queries/getOnboarding.query.ts +9 -1
- package/src/paywalls/PaywallProvider.tsx +226 -9
- package/src/paywalls/__tests__/catalogSettleWaiter.test.ts +134 -0
- package/src/paywalls/__tests__/getPaywalls.test.ts +29 -11
- package/src/paywalls/__tests__/register.test.ts +266 -0
- package/src/paywalls/catalogSettleWaiter.ts +72 -0
- package/src/paywalls/customScreens.ts +82 -0
- package/src/paywalls/getPaywalls.query.ts +9 -1
- package/src/paywalls/register.ts +169 -0
- package/src/paywalls/usePaywall.ts +63 -3
- package/src/steps/Paywall/types.ts +29 -0
- package/src/steps/types.ts +2 -0
- package/src/userProperties/__tests__/effectiveParams.test.ts +51 -0
- package/src/userProperties/__tests__/primitives.test.ts +96 -0
- package/src/userProperties/__tests__/store.test.ts +181 -0
- package/src/userProperties/applyPatch.ts +68 -0
- package/src/userProperties/effectiveParams.ts +60 -0
- package/src/userProperties/index.ts +11 -0
- package/src/userProperties/reserved.ts +44 -0
- package/src/userProperties/serialize.ts +61 -0
- package/src/userProperties/store.ts +177 -0
- package/src/userProperties/types.ts +22 -0
- 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
|
-
|
|
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;AAK3E,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC;IAClC,cAAc,EAAE;QACd,OAAO,EAAE;YACP,SAAS,EAAE,QAAQ;SACpB;KACF;CACF,CAAC,CAAA;AAEF,0EAA0E;AAC1E,wEAAwE;AACxE,sEAAsE;AACtE,MAAM,qBAAqB,GAAmB;IAC5C,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC;IACnF,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC;CACnF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,uBAAuB,GAAG,CACrC,WAAqC,EACrC,eAA4C,EAC+B,EAAE,CAAC,CAAC;IAC/E,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,eAAe;CAC1B,CAAC,CAAC;AANU,QAAA,uBAAuB,2BAMjC;AAEH,iFAAiF;AACjF,kFAAkF;AAClF,mFAAmF;AACnF,kEAAkE;AAClE,MAAM,oBAAoB,GAAkB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;
|
|
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,8EAA2E;AAC3E,0EAA8E;AAC9E,6DAIgC;AAChC,uEAAoE;AACpE,4DAAyD;AAEzD,gFAAyE;AACzE,8EAA2E;AAK3E,MAAM,WAAW,GAAG,IAAI,yBAAW,CAAC;IAClC,cAAc,EAAE;QACd,OAAO,EAAE;YACP,SAAS,EAAE,QAAQ;SACpB;KACF;CACF,CAAC,CAAA;AAEF,0EAA0E;AAC1E,wEAAwE;AACxE,sEAAsE;AACtE,MAAM,qBAAqB,GAAmB;IAC5C,QAAQ,EAAE,EAAE;IACZ,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC;IACnF,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC;CACnF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,uBAAuB,GAAG,CACrC,WAAqC,EACrC,eAA4C,EAC+B,EAAE,CAAC,CAAC;IAC/E,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,eAAe;CAC1B,CAAC,CAAC;AANU,QAAA,uBAAuB,2BAMjC;AAEH,iFAAiF;AACjF,kFAAkF;AAClF,mFAAmF;AACnF,kEAAkE;AAClE,MAAM,oBAAoB,GAAkB,MAA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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
|
|
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
|
|
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;
|
|
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
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"getOnboarding.query.js","sourceRoot":"","sources":["../../../src/infra/queries/getOnboarding.query.ts"],"names":[],"mappings":";;;;;;AAAA,8FAAqE;AAIrE,yCAAmD;AACnD,8DAA4D;AAErD,MAAM,kBAAkB,GAAG,CAChC,MAA8B,EAC9B,MAAc,EACd,oBAAyC,EACzC,aAA0D,EAC1D,EAAE;IACF,OAAO;QACL,QAAQ,EAAE;YACR,qBAAq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zB,CAAC;QACD,SAAS,EAAE,QAAQ;KACpB,CAAC;AACJ,CAAC,CAAC;AA/FW,QAAA,kBAAkB,sBA+F7B"}
|
|
@@ -3,6 +3,8 @@ import { Paywall, PaywallCatalog, PresentResult } from "./types";
|
|
|
3
3
|
import { type CatalogStatus } from "./present";
|
|
4
4
|
import { ProductProvider, ProductStatus } from "../products/types";
|
|
5
5
|
import type { CustomActions } from "../infra/provider/OnboardingProvider";
|
|
6
|
+
import type { CustomPaywallScreens } from "./customScreens";
|
|
7
|
+
import { type RegisterFeature, type RegisterResult } from "./register";
|
|
6
8
|
/**
|
|
7
9
|
* Everything a paywall consumer or a paywall HOST needs. Deliberately one
|
|
8
10
|
* context carrying both, mirroring how `OnboardingProgressContext` bundles
|
|
@@ -12,6 +14,20 @@ import type { CustomActions } from "../infra/provider/OnboardingProvider";
|
|
|
12
14
|
*/
|
|
13
15
|
export type PaywallContextValue = {
|
|
14
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>;
|
|
15
31
|
isReady: boolean;
|
|
16
32
|
catalog: PaywallCatalog | null;
|
|
17
33
|
/**
|
|
@@ -21,6 +37,22 @@ export type PaywallContextValue = {
|
|
|
21
37
|
* does not yet mean an absent one.
|
|
22
38
|
*/
|
|
23
39
|
catalogStatus: CatalogStatus;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a real `PaywallProvider` is above this consumer.
|
|
42
|
+
*
|
|
43
|
+
* Exists because `EMPTY_PAYWALL_CONTEXT` reports `catalogStatus: "loading"` —
|
|
44
|
+
* honest for `present()`'s contract (nothing is loading and nothing will
|
|
45
|
+
* arrive, so `"error"` is the answer) but INDISTINGUISHABLE from a genuine
|
|
46
|
+
* first load. A consumer that renders a spinner while loading would spin
|
|
47
|
+
* forever under no provider, and the inline `Paywall` onboarding step
|
|
48
|
+
* (`UI/Pages/Paywall/Renderer.tsx` in the UI package) is exactly that
|
|
49
|
+
* consumer.
|
|
50
|
+
*
|
|
51
|
+
* Deliberately NOT a new `CatalogStatus` member: widening that union breaks
|
|
52
|
+
* every host switching exhaustively over it, and "no provider" is not a
|
|
53
|
+
* catalog state.
|
|
54
|
+
*/
|
|
55
|
+
isProviderMounted: boolean;
|
|
24
56
|
/**
|
|
25
57
|
* What the store products are doing. The other half of `isReady`: a host that
|
|
26
58
|
* sees `catalogStatus: "ready"` but `isReady: false` can tell it is waiting on
|
|
@@ -46,7 +78,24 @@ export type PaywallContextValue = {
|
|
|
46
78
|
acknowledgePresentation: () => void;
|
|
47
79
|
/** Forwarded into the presented paywall's `ScreenHost.customActions`. */
|
|
48
80
|
customActions: CustomActions;
|
|
81
|
+
/**
|
|
82
|
+
* Host-registered screens for `renderMode: "custom"` paywalls, keyed by
|
|
83
|
+
* `customScreenId`.
|
|
84
|
+
*
|
|
85
|
+
* Published HERE — rather than only on `PaywallHost`, where it started in
|
|
86
|
+
* 1.72.0 — because there are now two renderers: that Modal, and the inline
|
|
87
|
+
* `Paywall` onboarding step, which never goes through `PaywallHost` at all.
|
|
88
|
+
* One registration has to serve both, and this is the provider every host
|
|
89
|
+
* already mounts. `PaywallHost`'s own prop still wins for that host.
|
|
90
|
+
*/
|
|
91
|
+
customScreens: CustomPaywallScreens;
|
|
49
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;
|
|
50
99
|
export declare const PaywallContext: import("react").Context<PaywallContextValue>;
|
|
51
100
|
/**
|
|
52
101
|
* The seam a paywall HOST (Task 7's `PaywallHost`) reads from — analogous to
|
|
@@ -55,10 +104,18 @@ export declare const PaywallContext: import("react").Context<PaywallContextValue
|
|
|
55
104
|
* internals it has no reason to touch (which paywall is active, how to
|
|
56
105
|
* resolve it).
|
|
57
106
|
*/
|
|
58
|
-
export declare const usePaywallHost: () => Pick<PaywallContextValue, "activePaywall" | "complete" | "acknowledgePresentation" | "customActions">;
|
|
107
|
+
export declare const usePaywallHost: () => Pick<PaywallContextValue, "activePaywall" | "complete" | "acknowledgePresentation" | "customActions" | "customScreens">;
|
|
59
108
|
interface PaywallProviderProps {
|
|
60
109
|
children: React.ReactNode;
|
|
61
|
-
|
|
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;
|
|
62
119
|
locale?: string;
|
|
63
120
|
customAudienceParams?: Record<string, any>;
|
|
64
121
|
/**
|
|
@@ -88,6 +145,20 @@ interface PaywallProviderProps {
|
|
|
88
145
|
stripeProductProvider?: ProductProvider;
|
|
89
146
|
/** Handlers for `{ type: "custom" }` ButtonActions inside a paywall's elements. */
|
|
90
147
|
customActions?: CustomActions;
|
|
148
|
+
/**
|
|
149
|
+
* Screens for `renderMode: "custom"` paywalls, keyed by the
|
|
150
|
+
* `customScreenId` authored in the studio.
|
|
151
|
+
*
|
|
152
|
+
* THE canonical place to register them: both renderers read from here —
|
|
153
|
+
* `PaywallHost`'s Modal and the inline `Paywall` onboarding step, which never
|
|
154
|
+
* goes through `PaywallHost`. `PaywallHost` still accepts its own
|
|
155
|
+
* `customScreens` prop (1.72.0's API), and that prop overrides this for that
|
|
156
|
+
* host; prefer this one.
|
|
157
|
+
*
|
|
158
|
+
* MUST be referentially stable (module scope, or `useMemo`) — it lands in the
|
|
159
|
+
* context value and in consumers' dependency arrays.
|
|
160
|
+
*/
|
|
161
|
+
customScreens?: CustomPaywallScreens;
|
|
91
162
|
/**
|
|
92
163
|
* How long to wait for the host to confirm a paywall actually appeared
|
|
93
164
|
* before abandoning the presentation and resolving
|
|
@@ -98,6 +169,15 @@ interface PaywallProviderProps {
|
|
|
98
169
|
* rest of the process. Only pass `null` if the host cannot acknowledge.
|
|
99
170
|
*/
|
|
100
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;
|
|
101
181
|
}
|
|
102
182
|
/**
|
|
103
183
|
* App-level ancestor. Renders ABOVE `OnboardingProvider`, not inside it —
|
|
@@ -105,12 +185,22 @@ interface PaywallProviderProps {
|
|
|
105
185
|
* only flows to descendants; two true siblings could not share one runtime).
|
|
106
186
|
*
|
|
107
187
|
* ```tsx
|
|
108
|
-
*
|
|
188
|
+
* OnboardingStudio.init({ projectId: "…" }); // at module scope
|
|
189
|
+
*
|
|
190
|
+
* <PaywallProvider productProvider={revenueCatProductProvider(Purchases)}>
|
|
109
191
|
* <App />
|
|
110
|
-
* <PaywallHost /> //
|
|
192
|
+
* <PaywallHost /> // renders the active paywall in a fullScreen RN Modal
|
|
111
193
|
* </PaywallProvider>
|
|
112
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.
|
|
113
203
|
*/
|
|
114
|
-
export declare const PaywallProvider: ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, 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;
|
|
115
205
|
export {};
|
|
116
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;
|
|
1
|
+
{"version":3,"file":"Pa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