@rocapine/react-native-onboarding 1.69.0 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OnboardingStudioClient.d.ts +4 -4
- package/dist/OnboardingStudioClient.js +7 -7
- package/dist/OnboardingStudioClient.js.map +1 -1
- package/dist/paywalls/PaywallProvider.d.ts +24 -7
- package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
- package/dist/paywalls/PaywallProvider.js +80 -42
- package/dist/paywalls/PaywallProvider.js.map +1 -1
- package/dist/paywalls/present.d.ts +60 -14
- package/dist/paywalls/present.d.ts.map +1 -1
- package/dist/paywalls/present.js +67 -18
- package/dist/paywalls/present.js.map +1 -1
- package/dist/paywalls/types.d.ts +48 -23
- package/dist/paywalls/types.d.ts.map +1 -1
- package/dist/paywalls/types.js +0 -7
- package/dist/paywalls/types.js.map +1 -1
- package/dist/paywalls/usePaywall.d.ts +5 -5
- package/dist/paywalls/usePaywall.d.ts.map +1 -1
- package/dist/products/adapters/stripeLink.d.ts +57 -0
- package/dist/products/adapters/stripeLink.d.ts.map +1 -0
- package/dist/products/adapters/stripeLink.js +158 -0
- package/dist/products/adapters/stripeLink.js.map +1 -0
- package/dist/products/index.d.ts +4 -1
- package/dist/products/index.d.ts.map +1 -1
- package/dist/products/index.js +5 -1
- package/dist/products/index.js.map +1 -1
- package/dist/products/refIdentity.d.ts +3 -0
- package/dist/products/refIdentity.d.ts.map +1 -0
- package/dist/products/refIdentity.js +37 -0
- package/dist/products/refIdentity.js.map +1 -0
- package/dist/products/types.d.ts +29 -1
- package/dist/products/types.d.ts.map +1 -1
- package/dist/products/useProducts.d.ts.map +1 -1
- package/dist/products/useProducts.js +7 -1
- package/dist/products/useProducts.js.map +1 -1
- package/package.json +1 -1
- package/src/OnboardingStudioClient.ts +7 -7
- package/src/paywalls/PaywallProvider.tsx +109 -46
- package/src/paywalls/__tests__/getPaywalls.test.ts +15 -12
- package/src/paywalls/__tests__/present.test.ts +149 -28
- package/src/paywalls/present.ts +74 -21
- package/src/paywalls/types.ts +49 -23
- package/src/paywalls/usePaywall.ts +5 -5
- package/src/products/__tests__/refIdentity.test.ts +44 -0
- package/src/products/adapters/__tests__/stripeLink.test.ts +179 -0
- package/src/products/adapters/stripeLink.ts +245 -0
- package/src/products/index.ts +4 -0
- package/src/products/refIdentity.ts +33 -0
- package/src/products/types.ts +30 -1
- package/src/products/useProducts.ts +7 -4
|
@@ -21,11 +21,11 @@ export declare class OnboardingStudioClient {
|
|
|
21
21
|
}>;
|
|
22
22
|
/**
|
|
23
23
|
* Fetches the paywall catalog for this project/audience/locale from
|
|
24
|
-
* `get-paywalls`. By design **omits `
|
|
25
|
-
* deliberately returns every
|
|
24
|
+
* `get-paywalls`. By design **omits `moment` by default** — the endpoint
|
|
25
|
+
* deliberately returns every moment in one round-trip so a paywall can
|
|
26
26
|
* be presented the instant the user taps upgrade, without a network call at
|
|
27
|
-
* that moment (spec §6.1). Pass `paywallOptions.
|
|
28
|
-
* single
|
|
27
|
+
* that moment (spec §6.1). Pass `paywallOptions.moment` only when a
|
|
28
|
+
* single moment is genuinely all that's needed.
|
|
29
29
|
*
|
|
30
30
|
* Unlike `getSteps`, there is no fallback-payload option here: a
|
|
31
31
|
* non-`ok` response or a network failure always rejects rather than
|
|
@@ -93,11 +93,11 @@ class OnboardingStudioClient {
|
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Fetches the paywall catalog for this project/audience/locale from
|
|
96
|
-
* `get-paywalls`. By design **omits `
|
|
97
|
-
* deliberately returns every
|
|
96
|
+
* `get-paywalls`. By design **omits `moment` by default** — the endpoint
|
|
97
|
+
* deliberately returns every moment in one round-trip so a paywall can
|
|
98
98
|
* be presented the instant the user taps upgrade, without a network call at
|
|
99
|
-
* that moment (spec §6.1). Pass `paywallOptions.
|
|
100
|
-
* single
|
|
99
|
+
* that moment (spec §6.1). Pass `paywallOptions.moment` only when a
|
|
100
|
+
* single moment is genuinely all that's needed.
|
|
101
101
|
*
|
|
102
102
|
* Unlike `getSteps`, there is no fallback-payload option here: a
|
|
103
103
|
* non-`ok` response or a network failure always rejects rather than
|
|
@@ -128,8 +128,8 @@ class OnboardingStudioClient {
|
|
|
128
128
|
}
|
|
129
129
|
// Narrows the response to a single paywall. Omitted unless explicitly
|
|
130
130
|
// requested — see the method doc above.
|
|
131
|
-
if (paywallOptions === null || paywallOptions === void 0 ? void 0 : paywallOptions.
|
|
132
|
-
urlParams.append("
|
|
131
|
+
if (paywallOptions === null || paywallOptions === void 0 ? void 0 : paywallOptions.moment) {
|
|
132
|
+
urlParams.append("moment", paywallOptions.moment);
|
|
133
133
|
}
|
|
134
134
|
// Deliberately NOT sending spec §6.1's `omitNulls=true`: it's a
|
|
135
135
|
// convenience for untyped consumers that strips null-valued keys from the
|
|
@@ -153,7 +153,7 @@ class OnboardingStudioClient {
|
|
|
153
153
|
return {
|
|
154
154
|
data,
|
|
155
155
|
headers: {
|
|
156
|
-
"ONBS-Audience-
|
|
156
|
+
"ONBS-Audience-Ids": response.headers.get("ONBS-Audience-Ids"),
|
|
157
157
|
"ONBS-Paywall-Ids": response.headers.get("ONBS-Paywall-Ids"),
|
|
158
158
|
},
|
|
159
159
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingStudioClient.js","sourceRoot":"","sources":["../src/OnboardingStudioClient.ts"],"names":[],"mappings":";;;;;;AAAA,8FAAqE;AAUrE,uDAGkC;AAOlC,+CAAwC;AAExC,MAAa,sBAAsB;IAKjC,YAAY,SAAiB,EAAE,OAAsC;QACnE,OAAO,CAAC,IAAI,CAAC,yCAAyC,EAAE,SAAS,CAAC,CAAC;QACnE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO;YACV,OAAO,CAAC,OAAO;gBACf,uDAAuD,CAAC;IAC5D,CAAC;IAED;;;;;;;OAO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,CAAC;IACH,CAAC;CACF;AAtMD,wDAsMC"}
|
|
@@ -11,13 +11,13 @@ import type { CustomActions } from "../infra/provider/OnboardingProvider";
|
|
|
11
11
|
* `infra/hooks/` slicing `OnboardingProgressContext`.
|
|
12
12
|
*/
|
|
13
13
|
export type PaywallContextValue = {
|
|
14
|
-
present: (
|
|
14
|
+
present: (moment: string) => Promise<PresentResult>;
|
|
15
15
|
isReady: boolean;
|
|
16
16
|
catalog: PaywallCatalog | null;
|
|
17
17
|
/**
|
|
18
18
|
* What the catalog is doing — the states `isReady` collapses into one
|
|
19
19
|
* boolean. See `CatalogStatus`; `"revalidating"` in particular means the
|
|
20
|
-
* catalog on hand may be superseded within moments, so a missing
|
|
20
|
+
* catalog on hand may be superseded within moments, so a missing moment
|
|
21
21
|
* does not yet mean an absent one.
|
|
22
22
|
*/
|
|
23
23
|
catalogStatus: CatalogStatus;
|
|
@@ -30,7 +30,7 @@ export type PaywallContextValue = {
|
|
|
30
30
|
/** The paywall currently being presented, or null. Read by `usePaywallHost()` — not by `usePaywall()`. */
|
|
31
31
|
activePaywall: Paywall | null;
|
|
32
32
|
/**
|
|
33
|
-
* Resolve the pending `present()` call and clear the active
|
|
33
|
+
* Resolve the pending `present()` call and clear the active moment.
|
|
34
34
|
* Call this from the presented paywall's `ScreenHost.complete` (Task 7's
|
|
35
35
|
* `PaywallHost`) — never from an ordinary consumer.
|
|
36
36
|
*/
|
|
@@ -62,13 +62,30 @@ interface PaywallProviderProps {
|
|
|
62
62
|
locale?: string;
|
|
63
63
|
customAudienceParams?: Record<string, any>;
|
|
64
64
|
/**
|
|
65
|
-
* Billing adapter
|
|
66
|
-
*
|
|
65
|
+
* Billing adapter for `billing: "store"` paywalls — also the default while
|
|
66
|
+
* no paywall is active, and the fallback for `"stripe"` when
|
|
67
|
+
* `stripeProductProvider` (see that prop) was not passed. Resolved once,
|
|
68
|
+
* over the union of every `paywall.products[]` in the catalog
|
|
69
|
+
* (deduplicated).
|
|
70
|
+
*
|
|
71
|
+
* This adapter's result is NOT unconditionally what gets published: which
|
|
72
|
+
* of `productProvider`'s and `stripeProductProvider`'s resolution reaches
|
|
73
|
+
* `ProductRuntimeContext` depends on the active paywall's `billing` (see
|
|
74
|
+
* `selectActiveProductRuntime`). Whichever one is live, it is published via
|
|
67
75
|
* `ProductRuntimeContext` — an `OnboardingProvider` mounted anywhere inside
|
|
68
|
-
* this tree picks up
|
|
76
|
+
* this tree picks up that SAME runtime instead of resolving its own, so
|
|
69
77
|
* there is one store round-trip and one `purchasing` flag for both.
|
|
70
78
|
*/
|
|
71
79
|
productProvider?: ProductProvider;
|
|
80
|
+
/**
|
|
81
|
+
* Billing adapter for `billing: "stripe"` paywalls — normally
|
|
82
|
+
* `stripeLinkProductProvider`. The catalog's product union is resolved
|
|
83
|
+
* through BOTH this and `productProvider`, and the runtime published is the
|
|
84
|
+
* one matching the presented paywall's `billing` (see
|
|
85
|
+
* `selectActiveProductRuntime`). Omit it and every paywall uses
|
|
86
|
+
* `productProvider`, exactly as before this prop existed.
|
|
87
|
+
*/
|
|
88
|
+
stripeProductProvider?: ProductProvider;
|
|
72
89
|
/** Handlers for `{ type: "custom" }` ButtonActions inside a paywall's elements. */
|
|
73
90
|
customActions?: CustomActions;
|
|
74
91
|
/**
|
|
@@ -94,6 +111,6 @@ interface PaywallProviderProps {
|
|
|
94
111
|
* </PaywallProvider>
|
|
95
112
|
* ```
|
|
96
113
|
*/
|
|
97
|
-
export declare const PaywallProvider: ({ children, client, locale, customAudienceParams, productProvider, customActions, presentAckTimeoutMs, }: PaywallProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
114
|
+
export declare const PaywallProvider: ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, presentAckTimeoutMs, }: PaywallProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
98
115
|
export {};
|
|
99
116
|
//# 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,
|
|
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;AAwB1E;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;;;OAKG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;;OAIG;IACH,cAAc,EAAE,aAAa,CAAC;IAC9B,0GAA0G;IAC1G,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C;;;;;;;OAOG;IACH,uBAAuB,EAAE,MAAM,IAAI,CAAC;IACpC,yEAAyE;IACzE,aAAa,EAAE,aAAa,CAAC;CAC9B,CAAC;AAyBF,eAAO,MAAM,cAAc,8CAA4D,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,QAAO,IAAI,CACpC,mBAAmB,EACnB,eAAe,GAAG,UAAU,GAAG,yBAAyB,GAAG,eAAe,CAK3E,CAAC;AAEF,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,eAAe,CAAC;IACxC,mFAAmF;IACnF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AA+TD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAAI,iIAS7B,oBAAoB,4CAgBtB,CAAC"}
|
|
@@ -31,7 +31,7 @@ const EMPTY_CUSTOM_ACTIONS = Object.freeze({});
|
|
|
31
31
|
const EMPTY_PAYWALL_CONTEXT = {
|
|
32
32
|
// No provider above: there is no catalog at all, which is the same answer
|
|
33
33
|
// `resolvePresentDecision` gives for an unresolved one.
|
|
34
|
-
present: async () => ({ status: "error", reason: "unknown-
|
|
34
|
+
present: async () => ({ status: "error", reason: "unknown-moment" }),
|
|
35
35
|
isReady: false,
|
|
36
36
|
catalog: null,
|
|
37
37
|
// No provider above: nothing is loading and nothing will arrive.
|
|
@@ -62,7 +62,7 @@ const usePaywallHost = () => {
|
|
|
62
62
|
return { activePaywall, complete, acknowledgePresentation, customActions };
|
|
63
63
|
};
|
|
64
64
|
exports.usePaywallHost = usePaywallHost;
|
|
65
|
-
const PaywallProviderInner = ({ children, client, locale, customAudienceParams, productProvider, customActions, presentAckTimeoutMs, }) => {
|
|
65
|
+
const PaywallProviderInner = ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, presentAckTimeoutMs, }) => {
|
|
66
66
|
var _a;
|
|
67
67
|
// `data` straight off `useQuery` is the single source of truth (Finding 1,
|
|
68
68
|
// 2026-08-17 final review) — react-query's own cache already gets both a
|
|
@@ -86,16 +86,63 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
86
86
|
// but `PaywallProvider` wraps the WHOLE app (spec §7:
|
|
87
87
|
// `<PaywallProvider><App/><PaywallHost/></PaywallProvider>`), so throwing
|
|
88
88
|
// here would crash every screen over a paywall-catalog failure alone.
|
|
89
|
-
// Instead: `catalog` simply stays null, `present()` on any
|
|
89
|
+
// Instead: `catalog` simply stays null, `present()` on any moment
|
|
90
90
|
// resolves "error" (see `resolvePresentDecision` — an unresolved catalog
|
|
91
|
-
// looks identical to an unknown
|
|
91
|
+
// looks identical to an unknown moment), and `isReady` stays false.
|
|
92
92
|
console.warn("[paywalls] Failed to load paywall catalog:", error);
|
|
93
93
|
}, [error]);
|
|
94
|
-
//
|
|
94
|
+
// Hoisted above `productRefs`/the product runtimes below: `activeMoment`
|
|
95
|
+
// (state) and `activePaywall` (derived from it) are read by the runtime
|
|
96
|
+
// selection that follows. Bare `useState(null)` with no dependencies, so
|
|
97
|
+
// hoisting past the effects and refs below it changes nothing about hook
|
|
98
|
+
// order.
|
|
99
|
+
const [activeMoment, setActiveMoment] = (0, react_1.useState)(null);
|
|
100
|
+
// Finding 6, 2026-08-17 final review, widened by N2 (round 2): a background
|
|
101
|
+
// catalog revalidation (see `getPaywalls.query.ts`) can push a fresh catalog
|
|
102
|
+
// that no longer contains the moment currently on screen (a studio
|
|
103
|
+
// publish renamed or removed it mid-session) — OR the query KEY itself can
|
|
104
|
+
// change while a paywall is showing (`locale`/`customAudienceParams`
|
|
105
|
+
// changed as a prop), which makes react-query report `data: undefined`
|
|
106
|
+
// while the new key is fetching (Finding 1's fix reads `catalog` straight
|
|
107
|
+
// from that `data`). Both collapse `activePaywall` to null the same way, so
|
|
108
|
+
// guarding on THAT — not on `catalog` being non-null — catches both: the
|
|
109
|
+
// original guard (`!catalog` check) missed the query-key case entirely,
|
|
110
|
+
// because a null `catalog` made it bail out before ever checking whether
|
|
111
|
+
// the moment was still present.
|
|
112
|
+
const activePaywall = activeMoment ? (_a = catalog === null || catalog === void 0 ? void 0 : catalog.paywalls[activeMoment]) !== null && _a !== void 0 ? _a : null : null;
|
|
113
|
+
// Union of every moment's products, deduplicated, resolved ONCE — never
|
|
95
114
|
// re-keyed per presented paywall. See `present.ts`'s `collectProductRefs`
|
|
96
115
|
// doc for why (spec §6.1's "render instantly on tap" requirement).
|
|
97
116
|
const productRefs = (0, react_1.useMemo)(() => (0, present_1.collectProductRefs)(catalog), [catalog]);
|
|
98
|
-
|
|
117
|
+
// Resolved TWICE — once per billing adapter — because the runtime is
|
|
118
|
+
// published as one map keyed by product key, and a `store` paywall and a
|
|
119
|
+
// `stripe` paywall declaring the same key would otherwise fight over
|
|
120
|
+
// `product.<key>.price`. See `selectActiveProductRuntime`'s doc for why
|
|
121
|
+
// this is cheap rather than wasteful, and why the statuses must not merge.
|
|
122
|
+
const storeRuntime = (0, useProducts_1.useProducts)(productRefs, productProvider, locale);
|
|
123
|
+
// Free in practice: `stripeLinkProductProvider.getProducts` makes no network
|
|
124
|
+
// call, and refs without a `stripe` block are dropped.
|
|
125
|
+
const stripeRuntime = (0, useProducts_1.useProducts)(productRefs, stripeProductProvider, locale);
|
|
126
|
+
const productRuntime = (0, present_1.selectActiveProductRuntime)({
|
|
127
|
+
storeRuntime,
|
|
128
|
+
stripeRuntime,
|
|
129
|
+
billing: activePaywall === null || activePaywall === void 0 ? void 0 : activePaywall.billing,
|
|
130
|
+
hasStripeProvider: stripeProductProvider !== undefined,
|
|
131
|
+
// Lets `selectActiveProductRuntime` prefer the stripe runtime while no
|
|
132
|
+
// paywall is active yet, for a host that passed ONLY
|
|
133
|
+
// `stripeProductProvider` — see that function's doc.
|
|
134
|
+
hasStoreProvider: productProvider !== undefined,
|
|
135
|
+
});
|
|
136
|
+
// A studio author can set `billing: "stripe"` on a paywall before the host
|
|
137
|
+
// ships the adapter. Loud, because the symptom otherwise is a paywall that
|
|
138
|
+
// charges through the store while the dashboard says Stripe.
|
|
139
|
+
(0, react_1.useEffect)(() => {
|
|
140
|
+
if ((activePaywall === null || activePaywall === void 0 ? void 0 : activePaywall.billing) === "stripe" && !stripeProductProvider) {
|
|
141
|
+
console.warn(`[paywalls] "${activePaywall.name}" is set to Stripe billing, but no ` +
|
|
142
|
+
"`stripeProductProvider` was passed to PaywallProvider — falling back to the store " +
|
|
143
|
+
"adapter. Pass `stripeLinkProductProvider({ clientReferenceId })` to honour it.");
|
|
144
|
+
}
|
|
145
|
+
}, [activePaywall, stripeProductProvider]);
|
|
99
146
|
// Tracks what a purchase attempt resolved to during the CURRENT
|
|
100
147
|
// presentation — read by `complete()` to upgrade a generic "dismissed"
|
|
101
148
|
// outcome (see `resolvePresentedOutcome`), reset when a new presentation
|
|
@@ -129,7 +176,8 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
129
176
|
return result;
|
|
130
177
|
}, [productRuntime.purchase]);
|
|
131
178
|
const productRuntimeWithPurchaseTracking = (0, react_1.useMemo)(() => (Object.assign(Object.assign({}, productRuntime), { purchase })), [productRuntime, purchase]);
|
|
132
|
-
|
|
179
|
+
// `activeMoment`'s `useState` was hoisted above `productRefs` — see the
|
|
180
|
+
// comment there. Only `hostAcknowledged` is declared here.
|
|
133
181
|
// Whether the host has confirmed THIS presentation is on screen. State, not
|
|
134
182
|
// a ref, because the timeout effect below must re-run (and cancel) the moment
|
|
135
183
|
// it flips.
|
|
@@ -139,7 +187,7 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
139
187
|
// `purchase`/`restore` callbacks.
|
|
140
188
|
const catalogRef = (0, react_1.useRef)(catalog);
|
|
141
189
|
catalogRef.current = catalog;
|
|
142
|
-
// `
|
|
190
|
+
// `activeMomentRef` is made AUTHORITATIVE below — assigned inside
|
|
143
191
|
// `present()`'s start branch and inside `complete()`, not just here. Finding
|
|
144
192
|
// 4, 2026-08-17 final review: this line alone only resyncs the ref from
|
|
145
193
|
// state AFTER React commits, so between a `present()` call and the next
|
|
@@ -151,16 +199,16 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
151
199
|
// orphaning this whole ref/resolver scheme exists to prevent. Assigning
|
|
152
200
|
// synchronously inside `present`/`complete` closes that window; this
|
|
153
201
|
// render-body line stays only as a resync for the (rare) case something
|
|
154
|
-
// external changes `
|
|
202
|
+
// external changes `activeMoment` state without going through either
|
|
155
203
|
// callback.
|
|
156
|
-
const
|
|
157
|
-
|
|
204
|
+
const activeMomentRef = (0, react_1.useRef)(activeMoment);
|
|
205
|
+
activeMomentRef.current = activeMoment;
|
|
158
206
|
const pendingResolveRef = (0, react_1.useRef)(null);
|
|
159
207
|
// present() must not fetch anything — the catalog and products are already
|
|
160
208
|
// resolved (or resolving) from mount. It only decides, synchronously,
|
|
161
209
|
// whether to show the Modal.
|
|
162
|
-
const present = (0, react_1.useCallback)((
|
|
163
|
-
const decision = (0, present_1.resolvePresentDecision)(catalogRef.current,
|
|
210
|
+
const present = (0, react_1.useCallback)((moment) => {
|
|
211
|
+
const decision = (0, present_1.resolvePresentDecision)(catalogRef.current, activeMomentRef.current, moment);
|
|
164
212
|
if (decision.type === "immediate") {
|
|
165
213
|
return Promise.resolve(decision.result);
|
|
166
214
|
}
|
|
@@ -172,19 +220,19 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
172
220
|
// Authoritative NOW, synchronously — see the ref's doc above. A second
|
|
173
221
|
// `present()` call before React commits reads this value, not the stale
|
|
174
222
|
// pre-commit state, and correctly takes the "already showing" branch.
|
|
175
|
-
|
|
223
|
+
activeMomentRef.current = moment;
|
|
176
224
|
return new Promise((resolve) => {
|
|
177
225
|
pendingResolveRef.current = resolve;
|
|
178
226
|
// A new presentation is unacknowledged until the host says otherwise —
|
|
179
227
|
// reset before it starts, or the previous presentation's confirmation
|
|
180
228
|
// would vouch for this one and disable the recovery.
|
|
181
229
|
setHostAcknowledged(false);
|
|
182
|
-
|
|
230
|
+
setActiveMoment(moment);
|
|
183
231
|
});
|
|
184
232
|
}, []);
|
|
185
233
|
// Called by PaywallHost (Task 7) from the presented paywall's
|
|
186
234
|
// `ScreenHost.complete`. Resolves whatever `present()` call is pending and
|
|
187
|
-
// clears the active
|
|
235
|
+
// clears the active moment, hiding the Modal and allowing a new
|
|
188
236
|
// `present()` to start. Safe to call with nothing pending (no-ops).
|
|
189
237
|
//
|
|
190
238
|
// `resolvePresentedOutcome` upgrades a bare "dismissed" to "purchased" (or
|
|
@@ -200,8 +248,8 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
200
248
|
// opening from the previous paywall's resolution is a canonical pattern,
|
|
201
249
|
// spec §4.5) must see "nothing showing" immediately, not wait for the
|
|
202
250
|
// next commit.
|
|
203
|
-
|
|
204
|
-
|
|
251
|
+
activeMomentRef.current = null;
|
|
252
|
+
setActiveMoment(null);
|
|
205
253
|
setHostAcknowledged(false);
|
|
206
254
|
resolve === null || resolve === void 0 ? void 0 : resolve((0, present_1.resolvePresentedOutcome)(result, lastPurchaseOutcomeRef.current));
|
|
207
255
|
}, []);
|
|
@@ -210,31 +258,21 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
210
258
|
const acknowledgePresentation = (0, react_1.useCallback)(() => {
|
|
211
259
|
setHostAcknowledged(true);
|
|
212
260
|
}, []);
|
|
213
|
-
|
|
214
|
-
// Finding 6, 2026-08-17 final review
|
|
215
|
-
//
|
|
216
|
-
// that no longer contains the placement currently on screen (a studio
|
|
217
|
-
// publish renamed or removed it mid-session) — OR the query KEY itself can
|
|
218
|
-
// change while a paywall is showing (`locale`/`customAudienceParams`
|
|
219
|
-
// changed as a prop), which makes react-query report `data: undefined`
|
|
220
|
-
// while the new key is fetching (Finding 1's fix reads `catalog` straight
|
|
221
|
-
// from that `data`). Both collapse `activePaywall` to null the same way, so
|
|
222
|
-
// guarding on THAT — not on `catalog` being non-null — catches both: the
|
|
223
|
-
// original guard (`!catalog` check) missed the query-key case entirely,
|
|
224
|
-
// because a null `catalog` made it bail out before ever checking whether
|
|
225
|
-
// the placement was still present.
|
|
261
|
+
// `activePaywall` was hoisted above `productRefs` — see the comment there
|
|
262
|
+
// (Finding 6, 2026-08-17 final review) for why it is derived from
|
|
263
|
+
// `activeMoment` rather than guarded on `catalog` alone.
|
|
226
264
|
//
|
|
227
265
|
// Either way, the Modal closes itself WITHOUT going through `complete()`,
|
|
228
266
|
// so the pending `present()` promise would never settle and
|
|
229
|
-
// `
|
|
267
|
+
// `activeMoment` would stay set forever, silently failing every later
|
|
230
268
|
// `present()` call with `"error"` for the rest of the app's life.
|
|
231
|
-
// `complete()` always clears `
|
|
269
|
+
// `complete()` always clears `activeMoment` together with resolving the
|
|
232
270
|
// pending promise, so it cannot race with or double-resolve this branch.
|
|
233
271
|
(0, react_1.useEffect)(() => {
|
|
234
|
-
if (!
|
|
272
|
+
if (!activeMoment || activePaywall)
|
|
235
273
|
return;
|
|
236
274
|
complete({ status: "error", reason: "paywall-disappeared" });
|
|
237
|
-
}, [
|
|
275
|
+
}, [activeMoment, activePaywall, complete]);
|
|
238
276
|
// The OTHER way a presentation never completes, and the one the guard above
|
|
239
277
|
// structurally cannot catch: `activePaywall` is perfectly non-null — the
|
|
240
278
|
// catalog still holds the paywall — but it never reaches the screen because
|
|
@@ -242,8 +280,8 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
242
280
|
// already-presenting view controller: another Modal, a
|
|
243
281
|
// `presentation: "modal"` route, a StoreKit alert). Nothing calls
|
|
244
282
|
// `complete()`, so without this the pending promise never settles,
|
|
245
|
-
// `
|
|
246
|
-
// `present()` — for any
|
|
283
|
+
// `activeMoment` stays set for the life of the process, and every later
|
|
284
|
+
// `present()` — for any moment — resolves "already-presenting" with no
|
|
247
285
|
// error and no log. Confirmed in production on a monetisation surface, which
|
|
248
286
|
// is why this recovers rather than merely reports.
|
|
249
287
|
//
|
|
@@ -252,17 +290,17 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
252
290
|
(0, react_1.useEffect)(() => {
|
|
253
291
|
if (presentAckTimeoutMs === null)
|
|
254
292
|
return;
|
|
255
|
-
if (!(0, present_1.shouldBreakPresentationWedge)(
|
|
293
|
+
if (!(0, present_1.shouldBreakPresentationWedge)(activeMoment, hostAcknowledged, true))
|
|
256
294
|
return;
|
|
257
295
|
const timer = setTimeout(() => {
|
|
258
|
-
console.warn(`[paywalls] "${
|
|
296
|
+
console.warn(`[paywalls] "${activeMoment}" was never confirmed on screen within ` +
|
|
259
297
|
`${presentAckTimeoutMs}ms and has been abandoned, so later present() calls keep working. ` +
|
|
260
298
|
"The platform most likely refused to present it — on iOS, something else was already " +
|
|
261
299
|
"presenting (another Modal, a `presentation: \"modal\"` route, or a StoreKit alert).");
|
|
262
300
|
complete({ status: "error", reason: "host-never-presented" });
|
|
263
301
|
}, presentAckTimeoutMs);
|
|
264
302
|
return () => clearTimeout(timer);
|
|
265
|
-
}, [
|
|
303
|
+
}, [activeMoment, hostAcknowledged, presentAckTimeoutMs, complete]);
|
|
266
304
|
const isReady = (0, react_1.useMemo)(() => (0, present_1.computeIsReady)(catalog, productRefs, productRuntime.status), [catalog, productRefs, productRuntime.status]);
|
|
267
305
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
268
306
|
present,
|
|
@@ -299,8 +337,8 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
299
337
|
* </PaywallProvider>
|
|
300
338
|
* ```
|
|
301
339
|
*/
|
|
302
|
-
const PaywallProvider = ({ children, client, locale = "en", customAudienceParams = {}, productProvider, customActions = EMPTY_CUSTOM_ACTIONS, presentAckTimeoutMs = DEFAULT_PRESENT_ACK_TIMEOUT_MS, }) => {
|
|
303
|
-
return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: paywallQueryClient, children: (0, jsx_runtime_1.jsx)(PaywallProviderInner, { client: client, locale: locale, customAudienceParams: customAudienceParams, productProvider: productProvider, customActions: customActions, presentAckTimeoutMs: presentAckTimeoutMs, children: children }) }));
|
|
340
|
+
const PaywallProvider = ({ children, client, locale = "en", customAudienceParams = {}, productProvider, stripeProductProvider, customActions = EMPTY_CUSTOM_ACTIONS, presentAckTimeoutMs = DEFAULT_PRESENT_ACK_TIMEOUT_MS, }) => {
|
|
341
|
+
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, presentAckTimeoutMs: presentAckTimeoutMs, children: children }) }));
|
|
304
342
|
};
|
|
305
343
|
exports.PaywallProvider = PaywallProvider;
|
|
306
344
|
//# 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,
|
|
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;AAG1E,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,0EAA0E;AAC1E,iEAAiE;AACjE,yDAAyD;AACzD,gCAAgC;AAChC,MAAM,kBAAkB,GAAG,IAAI,yBAAW,CAAC;IACzC,cAAc,EAAE;QACd,OAAO,EAAE;YACP,SAAS,EAAE,QAAQ;SACpB;KACF;CAC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E,OAAO;QACP,OAAO;QACP,OAAO;QACP,aAAa;QACb,cAAc,CAAC,MAAM;QACrB,aAAa;QACb,QAAQ;QACR,uBAAuB;QACvB,aAAa;KACd,CACF,CAAC;IAEF,OAAO,CACL,uBAAC,6CAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,kCAAkC,YACvE,uBAAC,sBAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAAG,QAAQ,GAA2B,GACnD,CAClC,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACI,MAAM,eAAe,GAAG,CAAC,EAC9B,QAAQ,EACR,MAAM,EACN,MAAM,GAAG,IAAI,EACb,oBAAoB,GAAG,EAAE,EACzB,eAAe,EACf,qBAAqB,EACrB,aAAa,GAAG,oBAAoB,EACpC,mBAAmB,GAAG,8BAA8B,GAC/B,EAAE,EAAE;IACzB,OAAO,CACL,uBAAC,iCAAmB,IAAC,MAAM,EAAE,kBAAkB,YAC7C,uBAAC,oBAAoB,IACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,oBAAoB,EAC1C,eAAe,EAAE,eAAe,EAChC,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,YAEvC,QAAQ,GACY,GACH,CACvB,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,eAAe,mBAyB1B"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Paywall, PaywallCatalog, PresentResult } from "./types";
|
|
2
|
-
import type { ProductRef, ProductStatus, PurchaseResult } from "../products/types";
|
|
2
|
+
import type { ProductRef, ProductRuntime, ProductStatus, PurchaseResult } from "../products/types";
|
|
3
3
|
/**
|
|
4
4
|
* Union of every `paywall.products[]` across the WHOLE catalog, deduplicated
|
|
5
5
|
* by content — the same identity notion `useProducts`' `refsKey` uses
|
|
6
|
-
* (`products/
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* (`products/refIdentity.ts`: keyed on ref CONTENT, not array identity), so
|
|
7
|
+
* this array is exactly as cheap to pass as a hand-written one: `useProducts`
|
|
8
|
+
* resolves it once and does not refetch on every render.
|
|
9
9
|
*
|
|
10
10
|
* Resolving the whole catalog's union ONCE at load — rather than re-keying
|
|
11
11
|
* `useProducts` per presented paywall — is the deliberate design decision:
|
|
@@ -23,13 +23,13 @@ export type PresentDecision = {
|
|
|
23
23
|
result: PresentResult;
|
|
24
24
|
};
|
|
25
25
|
/**
|
|
26
|
-
* `present(
|
|
26
|
+
* `present(moment)`'s edge-case decision, extracted so both documented
|
|
27
27
|
* edge cases are covered by an importable test rather than only inspection:
|
|
28
28
|
*
|
|
29
|
-
* - **Unknown
|
|
30
|
-
* resolved yet — both look identical here: `catalog?.paywalls[
|
|
29
|
+
* - **Unknown moment** (absent from the catalog, or the catalog hasn't
|
|
30
|
+
* resolved yet — both look identical here: `catalog?.paywalls[moment]`
|
|
31
31
|
* is `undefined` either way) → resolves `"error"`, never throws. A missing
|
|
32
|
-
*
|
|
32
|
+
* moment must not crash a host app mid-flow.
|
|
33
33
|
* - **`present()` called while another paywall is already showing** → also
|
|
34
34
|
* resolves `"error"` immediately, leaving the in-progress presentation
|
|
35
35
|
* untouched. This SDK shows one paywall at a time. Silently replacing the
|
|
@@ -37,9 +37,9 @@ export type PresentDecision = {
|
|
|
37
37
|
* resolved — that caller hangs forever); queueing the new request would
|
|
38
38
|
* need its own cancellation/timeout story that nothing here asks for.
|
|
39
39
|
* Resolving the new call immediately applies the same "resolve, don't
|
|
40
|
-
* throw" contract as the unknown-
|
|
40
|
+
* throw" contract as the unknown-moment case, consistently.
|
|
41
41
|
*/
|
|
42
|
-
export declare const resolvePresentDecision: (catalog: PaywallCatalog | null,
|
|
42
|
+
export declare const resolvePresentDecision: (catalog: PaywallCatalog | null, activeMoment: string | null, moment: string) => PresentDecision;
|
|
43
43
|
/**
|
|
44
44
|
* Whether an in-progress presentation should be abandoned because the host
|
|
45
45
|
* never confirmed it appeared.
|
|
@@ -81,7 +81,7 @@ export declare const shouldBreakPresentationWedge: (activePlacement: string | nu
|
|
|
81
81
|
* sending volatile params gets an instantly-available catalog that was resolved
|
|
82
82
|
* under DIFFERENT params, with a fresh fetch in flight behind it. That catalog
|
|
83
83
|
* is present and non-null, so it reads as ready — and a host gating on
|
|
84
|
-
* `catalog.paywalls[
|
|
84
|
+
* `catalog.paywalls[moment]` can conclude the moment does not exist and
|
|
85
85
|
* route away, milliseconds before the correct catalog arrives.
|
|
86
86
|
*
|
|
87
87
|
* Observed consequence, reported from a production pilot: for an audience gated
|
|
@@ -89,7 +89,7 @@ export declare const shouldBreakPresentationWedge: (activePlacement: string | nu
|
|
|
89
89
|
* first becomes eligible is served the PRE-threshold catalog, so the arm under
|
|
90
90
|
* test loses exactly the launch that matters. `"revalidating"` is how a host
|
|
91
91
|
* distinguishes "this catalog is final" from "this catalog may be superseded in
|
|
92
|
-
* a moment", and therefore whether a missing
|
|
92
|
+
* a moment", and therefore whether a missing moment means absent or not-yet.
|
|
93
93
|
*
|
|
94
94
|
* A present catalog outranks an error deliberately: if a background
|
|
95
95
|
* revalidation fails, react-query keeps the cached `data` AND sets `error`, and
|
|
@@ -116,7 +116,7 @@ export declare const computeIsReady: (catalog: PaywallCatalog | null, productRef
|
|
|
116
116
|
* `"error"` are not: they don't describe what happened to the STORE PURCHASE
|
|
117
117
|
* in a way that should override how the paywall itself reports closing (an
|
|
118
118
|
* `"error"` here would collide with `PresentResult`'s existing `"error"`,
|
|
119
|
-
* which means something structurally different — an unknown
|
|
119
|
+
* which means something structurally different — an unknown moment or a
|
|
120
120
|
* mistimed `present()` call, not a failed purchase attempt).
|
|
121
121
|
*/
|
|
122
122
|
export type PurchaseOutcomeDuringPresentation = "purchased" | "cancelled" | null;
|
|
@@ -149,9 +149,55 @@ export declare const resolvePresentedOutcome: (reported: PresentResult, purchase
|
|
|
149
149
|
* generation again after — only an unchanged generation means the write is
|
|
150
150
|
* still for the presentation that started it.
|
|
151
151
|
*
|
|
152
|
-
* A monotonic counter, not the
|
|
152
|
+
* A monotonic counter, not the moment string: the same moment can
|
|
153
153
|
* legitimately be presented twice in a row, and a string comparison would
|
|
154
154
|
* let a stale write from the FIRST of those two land in the second.
|
|
155
155
|
*/
|
|
156
156
|
export declare const shouldRecordPurchaseOutcome: (startedInGeneration: number, currentGeneration: number) => boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Which of the two resolved product runtimes to publish.
|
|
159
|
+
*
|
|
160
|
+
* `PaywallProvider` resolves the catalog's product union TWICE — once through
|
|
161
|
+
* the host's store adapter, once through its Stripe adapter — because the
|
|
162
|
+
* runtime is published as one map keyed by product key, and a `store` paywall
|
|
163
|
+
* and a `stripe` paywall declaring the same key would otherwise fight over
|
|
164
|
+
* `product.<key>.price`. Only one paywall is ever presented at a time
|
|
165
|
+
* (`activeMoment`), so "the active one" is unambiguous.
|
|
166
|
+
*
|
|
167
|
+
* This is cheap rather than wasteful because the Stripe pass performs no
|
|
168
|
+
* network call (`stripeLinkProductProvider`) and each provider silently drops
|
|
169
|
+
* refs it cannot resolve, so neither pass does work for the other's paywalls.
|
|
170
|
+
*
|
|
171
|
+
* The statuses are deliberately NOT merged. Merging is the trap
|
|
172
|
+
* `mergeProductRuntimes` documents from the other direction: an `"idle"`
|
|
173
|
+
* runtime with nothing to wait for drags a `"ready"` one down and closes every
|
|
174
|
+
* `products.loaded` gate for the life of the process.
|
|
175
|
+
*
|
|
176
|
+
* `hasStripeProvider` is the guard for a misconfigured host: a `stripe`
|
|
177
|
+
* paywall with no `stripeProductProvider` passed leaves `useProducts` at
|
|
178
|
+
* `"idle"` forever (it bails before calling a provider it does not have), so
|
|
179
|
+
* `computeIsReady` would never turn true and paywalls would stop appearing
|
|
180
|
+
* with no error. Falling back to the store runtime keeps the app alive; the
|
|
181
|
+
* caller warns.
|
|
182
|
+
*
|
|
183
|
+
* `billing` is `undefined` whenever no paywall is active (`activePaywall` is
|
|
184
|
+
* null before the first `present()`, and after every `complete()`) — there is
|
|
185
|
+
* no `.billing` to read yet. That USED to fall through to the store runtime
|
|
186
|
+
* unconditionally, which meant a host that passes ONLY
|
|
187
|
+
* `stripeProductProvider` (no `productProvider` at all) sat on an `"idle"`
|
|
188
|
+
* `storeRuntime` — forever, for every screen before a paywall first presents,
|
|
189
|
+
* since nothing ever calls a `present()` to select the stripe runtime instead
|
|
190
|
+
* — so `products.loaded` read `"false"` everywhere and `isReady` never turned
|
|
191
|
+
* true. `hasStoreProvider` closes that gap: with no active paywall, prefer
|
|
192
|
+
* whichever provider was actually SUPPLIED. When both or neither exist there
|
|
193
|
+
* is no asymmetry to correct, so this keeps the pre-existing store-first
|
|
194
|
+
* default — unchanged for every host that already worked.
|
|
195
|
+
*/
|
|
196
|
+
export declare const selectActiveProductRuntime: (args: {
|
|
197
|
+
storeRuntime: ProductRuntime;
|
|
198
|
+
stripeRuntime: ProductRuntime;
|
|
199
|
+
billing: "store" | "stripe" | undefined;
|
|
200
|
+
hasStripeProvider: boolean;
|
|
201
|
+
hasStoreProvider: boolean;
|
|
202
|
+
}) => ProductRuntime;
|
|
157
203
|
//# sourceMappingURL=present.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"present.d.ts","sourceRoot":"","sources":["../../src/paywalls/present.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"present.d.ts","sourceRoot":"","sources":["../../src/paywalls/present.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM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