@rocapine/react-native-onboarding 1.68.2 → 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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/paywalls/PaywallProvider.d.ts +38 -7
- package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
- package/dist/paywalls/PaywallProvider.js +101 -44
- package/dist/paywalls/PaywallProvider.js.map +1 -1
- package/dist/paywalls/present.d.ts +91 -12
- package/dist/paywalls/present.d.ts.map +1 -1
- package/dist/paywalls/present.js +75 -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 +19 -4
- package/dist/paywalls/usePaywall.d.ts.map +1 -1
- package/dist/paywalls/usePaywall.js +2 -2
- package/dist/paywalls/usePaywall.js.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/index.ts +3 -0
- package/src/paywalls/PaywallProvider.tsx +145 -48
- package/src/paywalls/__tests__/getPaywalls.test.ts +15 -12
- package/src/paywalls/__tests__/present.test.ts +192 -26
- package/src/paywalls/present.ts +115 -19
- package/src/paywalls/types.ts +49 -23
- package/src/paywalls/usePaywall.ts +22 -6
- 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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ProductProvider } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Stripe Payment Link provider.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately NOT a store adapter. It makes no network call and holds no
|
|
6
|
+
* Stripe key: the price is authored in Onboarding Studio and travels inline on
|
|
7
|
+
* the `ProductRef` (`ProductRef.stripe`), so `getProducts` is a synchronous
|
|
8
|
+
* synthesis and `purchase` is a link-out.
|
|
9
|
+
*
|
|
10
|
+
* What it does NOT do, on purpose:
|
|
11
|
+
* - grant or verify anything. `purchase()` resolves `{ status: "pending" }`
|
|
12
|
+
* because the browser leaves the app — on web the JS context is destroyed.
|
|
13
|
+
* The entitlement arrives later through RevenueCat's Stripe integration,
|
|
14
|
+
* which is why `clientReferenceId` MUST return the RevenueCat App User ID:
|
|
15
|
+
* it is the key RevenueCat's webhook matches on, and the only thing tying
|
|
16
|
+
* the payment to the user. Return the wrong id and the money is taken with
|
|
17
|
+
* no entitlement granted. An ABSENT id (null/undefined/empty) is handled
|
|
18
|
+
* differently: `purchase()` refuses before opening anything, unless
|
|
19
|
+
* `allowAnonymous` opts in — see `StripeLinkProviderConfig.allowAnonymous`.
|
|
20
|
+
* - import `react-native` at module scope, so this file is safe to load on
|
|
21
|
+
* web. URL opening is injected (`openUrl`) for the same reason, and so the
|
|
22
|
+
* provider is testable under Node.
|
|
23
|
+
*/
|
|
24
|
+
export type StripeLinkProviderConfig = {
|
|
25
|
+
/**
|
|
26
|
+
* The RevenueCat App User ID, as a getter — it changes on login/logout, and
|
|
27
|
+
* a value captured at provider construction would go stale.
|
|
28
|
+
*/
|
|
29
|
+
clientReferenceId: () => string | null | undefined;
|
|
30
|
+
/** Optional email prefill for the Checkout page. */
|
|
31
|
+
prefilledEmail?: () => string | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* How to leave the app. Defaults to `react-native`'s `Linking.openURL`,
|
|
34
|
+
* required lazily so this module stays importable where react-native is not.
|
|
35
|
+
*/
|
|
36
|
+
openUrl?: (url: string) => void | Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Restoring is a store-account operation Stripe links cannot perform. Supply
|
|
39
|
+
* the host's real implementation (usually the RevenueCat adapter's
|
|
40
|
+
* `restore`) to make a Restore button work on a Stripe paywall.
|
|
41
|
+
*/
|
|
42
|
+
restore?: ProductProvider["restore"];
|
|
43
|
+
/** Passed to `Intl.NumberFormat` when formatting the authored price. */
|
|
44
|
+
locale?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Opt-in for checkout with no `clientReferenceId()`. Default `false`:
|
|
47
|
+
* `purchase()` refuses (fails closed) rather than open a Payment Link it
|
|
48
|
+
* cannot attribute to a RevenueCat user, because a payment that opens
|
|
49
|
+
* anyway is taken with NO way to grant the entitlement afterwards — see
|
|
50
|
+
* `purchase()` below. Set `true` only if you genuinely want anonymous
|
|
51
|
+
* checkout; entitlements from those purchases cannot be attributed
|
|
52
|
+
* automatically and must be reconciled out of band.
|
|
53
|
+
*/
|
|
54
|
+
allowAnonymous?: boolean;
|
|
55
|
+
};
|
|
56
|
+
export declare const stripeLinkProductProvider: (config: StripeLinkProviderConfig) => ProductProvider;
|
|
57
|
+
//# sourceMappingURL=stripeLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripeLink.d.ts","sourceRoot":"","sources":["../../../src/products/adapters/stripeLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,eAAe,EAIhB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;OAGG;IACH,iBAAiB,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,oDAAoD;IACpD,cAAc,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACjD;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACrC,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAiDF,eAAO,MAAM,yBAAyB,GAAI,QAAQ,wBAAwB,KAAG,eAqI5E,CAAC"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripeLinkProductProvider = void 0;
|
|
4
|
+
const derive_1 = require("../derive");
|
|
5
|
+
const PERIOD_FROM_UNIT = {
|
|
6
|
+
D: "week",
|
|
7
|
+
W: "week",
|
|
8
|
+
M: "month",
|
|
9
|
+
Y: "year",
|
|
10
|
+
};
|
|
11
|
+
/** Same shape the store adapters parse, for one consistent notion of period. */
|
|
12
|
+
const toPeriod = (iso) => {
|
|
13
|
+
var _a;
|
|
14
|
+
if (!iso)
|
|
15
|
+
return { period: null, count: 0 };
|
|
16
|
+
const m = /^P(\d+)([DWMY])$/.exec(iso);
|
|
17
|
+
if (!m)
|
|
18
|
+
return { period: null, count: 0 };
|
|
19
|
+
return { period: (_a = PERIOD_FROM_UNIT[m[2]]) !== null && _a !== void 0 ? _a : null, count: Number(m[1]) };
|
|
20
|
+
};
|
|
21
|
+
const lazyLinking = (url) => {
|
|
22
|
+
// Required lazily and defensively: this provider's whole point is running on
|
|
23
|
+
// web, where react-native may be absent entirely.
|
|
24
|
+
try {
|
|
25
|
+
const RN = require("react-native");
|
|
26
|
+
return RN.Linking.openURL(url);
|
|
27
|
+
}
|
|
28
|
+
catch (_a) {
|
|
29
|
+
if (typeof globalThis !== "undefined" && globalThis.location) {
|
|
30
|
+
globalThis.location.assign(url);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
throw new Error("stripeLinkProductProvider: no way to open a URL. Pass `openUrl` in the provider config.");
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const withParams = (link, params) => {
|
|
37
|
+
// Parsed rather than string-concatenated so a link that already carries
|
|
38
|
+
// query parameters (`?locale=fr`) keeps them and does not gain a second `?`.
|
|
39
|
+
const url = new URL(link);
|
|
40
|
+
for (const [name, value] of Object.entries(params)) {
|
|
41
|
+
// Omit rather than emit — Stripe would receive the literal string "null".
|
|
42
|
+
if (value === null || value === undefined || value === "")
|
|
43
|
+
continue;
|
|
44
|
+
url.searchParams.set(name, value);
|
|
45
|
+
}
|
|
46
|
+
return url.toString();
|
|
47
|
+
};
|
|
48
|
+
const stripeLinkProductProvider = (config) => {
|
|
49
|
+
const { clientReferenceId, prefilledEmail, openUrl = lazyLinking, restore, locale, allowAnonymous = false } = config;
|
|
50
|
+
// `ResolvedProduct` has no field for the payment link and widening it would
|
|
51
|
+
// put a Stripe concern on every store product, so the link is remembered
|
|
52
|
+
// here, populated by `getProducts` — the same call that produced the
|
|
53
|
+
// `ResolvedProduct` `purchase` is later handed.
|
|
54
|
+
const linkByKey = new Map();
|
|
55
|
+
return {
|
|
56
|
+
async getProducts(refs) {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
// Cleared, not merged: this call's `refs` is the full current catalog, so
|
|
59
|
+
// it defines the resolvable set on its own. A key that carried a stripe
|
|
60
|
+
// block last call but not this one (re-authored off Stripe billing) must
|
|
61
|
+
// stop resolving — an accumulating map would keep `purchase()` opening
|
|
62
|
+
// that stale link indefinitely instead of taking the "no link" error path.
|
|
63
|
+
linkByKey.clear();
|
|
64
|
+
const out = [];
|
|
65
|
+
for (const ref of refs) {
|
|
66
|
+
const s = ref.stripe;
|
|
67
|
+
// A ref with no stripe block is not an error — the catalog union spans
|
|
68
|
+
// every paywall, including `billing: "store"` ones. Dropping it is the
|
|
69
|
+
// same contract the store adapters have for a missing platform id.
|
|
70
|
+
if (!s || !s.paymentLink)
|
|
71
|
+
continue;
|
|
72
|
+
linkByKey.set(ref.key, s.paymentLink);
|
|
73
|
+
const { period, count } = toPeriod(s.periodIso);
|
|
74
|
+
const trialDays = (_a = s.trialDays) !== null && _a !== void 0 ? _a : 0;
|
|
75
|
+
out.push(Object.assign({ key: ref.key, productId: (_b = s.priceId) !== null && _b !== void 0 ? _b : s.paymentLink, store: "stripe", title: "", description: "", price: (0, derive_1.formatCurrency)(s.amount, s.currency, locale), priceAmount: s.amount, currencyCode: s.currency, period, periodCount: count, periodIso: (_c = s.periodIso) !== null && _c !== void 0 ? _c : null }, (trialDays > 0
|
|
76
|
+
? {
|
|
77
|
+
trial: {
|
|
78
|
+
period: "week",
|
|
79
|
+
periodCount: Math.max(1, Math.round(trialDays / 7)),
|
|
80
|
+
days: trialDays,
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
: {})));
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
},
|
|
87
|
+
async purchase(product) {
|
|
88
|
+
const link = linkByKey.get(product.key);
|
|
89
|
+
if (!link) {
|
|
90
|
+
return {
|
|
91
|
+
status: "error",
|
|
92
|
+
error: new Error(`stripeLinkProductProvider: no payment link for "${product.key}". ` +
|
|
93
|
+
"getProducts() never resolved this key, so the ref carries no `stripe.paymentLink`."),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// Resolved and checked BEFORE the link opens — once it opens, the
|
|
97
|
+
// browser has left the app and the payment cannot be stopped. A
|
|
98
|
+
// null/undefined/empty id is not exotic: a getter wired to
|
|
99
|
+
// RevenueCat's `appUserID` before `Purchases.configure()` resolves, or
|
|
100
|
+
// read while the user is logged out, returns null. Without this check
|
|
101
|
+
// the link would still open, `purchase()` would still resolve
|
|
102
|
+
// "pending", the user would pay, and RevenueCat would have nothing to
|
|
103
|
+
// match the payment to — nothing fails loudly at any layer. See this
|
|
104
|
+
// file's top comment: "Return the wrong id and the money is taken with
|
|
105
|
+
// no entitlement granted" — this is that, for the ABSENT case.
|
|
106
|
+
const refId = clientReferenceId();
|
|
107
|
+
const hasRefId = refId !== null && refId !== undefined && refId !== "";
|
|
108
|
+
if (!hasRefId && !allowAnonymous) {
|
|
109
|
+
return {
|
|
110
|
+
status: "error",
|
|
111
|
+
error: new Error("stripeLinkProductProvider: clientReferenceId() returned no id — refusing to open the " +
|
|
112
|
+
"Payment Link. Opening it anyway would take payment with no way to attribute the " +
|
|
113
|
+
"entitlement RevenueCat grants afterwards. Wire `clientReferenceId` to the RevenueCat App " +
|
|
114
|
+
"User ID and make sure it resolves AFTER `Purchases.configure()` completes (reading it " +
|
|
115
|
+
"before configure() finishes, or while the user is logged out, is what returns null). " +
|
|
116
|
+
"Pass `allowAnonymous: true` in the provider config if anonymous checkout — with no " +
|
|
117
|
+
"automatic entitlement attribution — is genuinely what you want."),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
// `withParams` throws synchronously on a malformed link (`new URL`) —
|
|
121
|
+
// a plausible failure mode for an author-pasted Stripe URL. That throw
|
|
122
|
+
// happens before any `await`, so left unguarded it would make
|
|
123
|
+
// `purchase()` return a REJECTED promise instead of the resolved
|
|
124
|
+
// `{ status: "error", error }` every other failure path in this file
|
|
125
|
+
// uses. Callers awaiting `purchase()` should only ever see it resolve.
|
|
126
|
+
try {
|
|
127
|
+
await openUrl(withParams(link, {
|
|
128
|
+
client_reference_id: refId,
|
|
129
|
+
prefilled_email: prefilledEmail === null || prefilledEmail === void 0 ? void 0 : prefilledEmail(),
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
// Always renamed to name the offending link — a bare `Invalid URL`
|
|
134
|
+
// (what `new URL` throws) gives an author nothing to act on.
|
|
135
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
136
|
+
return {
|
|
137
|
+
status: "error",
|
|
138
|
+
error: new Error(`stripeLinkProductProvider: failed to open payment link "${link}": ${reason}`),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
// Never "purchased": the browser has taken over and, on web, this JS
|
|
142
|
+
// context is about to be destroyed. RevenueCat reports the entitlement.
|
|
143
|
+
return { status: "pending" };
|
|
144
|
+
},
|
|
145
|
+
async restore() {
|
|
146
|
+
if (restore)
|
|
147
|
+
return restore();
|
|
148
|
+
return {
|
|
149
|
+
status: "error",
|
|
150
|
+
error: new Error("stripeLinkProductProvider: restore is not configured. A Stripe Payment Link cannot " +
|
|
151
|
+
"enumerate past purchases; pass `restore` (usually your RevenueCat adapter's) in the " +
|
|
152
|
+
"provider config so a Restore button does something."),
|
|
153
|
+
};
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
exports.stripeLinkProductProvider = stripeLinkProductProvider;
|
|
158
|
+
//# sourceMappingURL=stripeLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripeLink.js","sourceRoot":"","sources":["../../../src/products/adapters/stripeLink.ts"],"names":[],"mappings":";;;AAAA,sCAA2C;AAgE3C,MAAM,gBAAgB,GAAkC;IACtD,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,MAAM;CACV,CAAC;AAEF,gFAAgF;AAChF,MAAM,QAAQ,GAAG,CAAC,GAA8B,EAAmD,EAAE;;IACnG,IAA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AACJ,CAAC,CAAC;AArIW,QAAA,yBAAyB,6BAqIpC"}
|
package/dist/products/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export type { ProductRef, ProductPeriod, ResolvedProduct, DerivedProductFields, ProductWithDerived, PurchaseResult, RestoreResult, ProductProvider, ProductStatus, ProductRuntime, } from "./types";
|
|
1
|
+
export type { ProductRef, StripeProductRef, ProductPeriod, ResolvedProduct, DerivedProductFields, ProductWithDerived, PurchaseResult, RestoreResult, ProductProvider, ProductStatus, ProductRuntime, } from "./types";
|
|
2
2
|
export { parseIsoDuration } from "./duration";
|
|
3
3
|
export { formatCurrency, deriveProductFields, deriveAll } from "./derive";
|
|
4
4
|
export { productVariables } from "./toVariables";
|
|
5
|
+
export { productRefIdentity } from "./refIdentity";
|
|
5
6
|
export { useProducts } from "./useProducts";
|
|
6
7
|
export { ProductRuntimeContext, useProductRuntime } from "./ProductRuntimeContext";
|
|
7
8
|
export { stubProductProvider } from "./adapters/stub";
|
|
8
9
|
export { revenueCatProductProvider } from "./adapters/revenueCat";
|
|
9
10
|
export { expoIapProductProvider } from "./adapters/expoIap";
|
|
11
|
+
export { stripeLinkProductProvider } from "./adapters/stripeLink";
|
|
12
|
+
export type { StripeLinkProviderConfig } from "./adapters/stripeLink";
|
|
10
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/products/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/products/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,eAAe,EACf,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,YAAY,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/products/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.expoIapProductProvider = exports.revenueCatProductProvider = exports.stubProductProvider = exports.useProductRuntime = exports.ProductRuntimeContext = exports.useProducts = exports.productVariables = exports.deriveAll = exports.deriveProductFields = exports.formatCurrency = exports.parseIsoDuration = void 0;
|
|
3
|
+
exports.stripeLinkProductProvider = exports.expoIapProductProvider = exports.revenueCatProductProvider = exports.stubProductProvider = exports.useProductRuntime = exports.ProductRuntimeContext = exports.useProducts = exports.productRefIdentity = exports.productVariables = exports.deriveAll = exports.deriveProductFields = exports.formatCurrency = exports.parseIsoDuration = void 0;
|
|
4
4
|
var duration_1 = require("./duration");
|
|
5
5
|
Object.defineProperty(exports, "parseIsoDuration", { enumerable: true, get: function () { return duration_1.parseIsoDuration; } });
|
|
6
6
|
var derive_1 = require("./derive");
|
|
@@ -9,6 +9,8 @@ Object.defineProperty(exports, "deriveProductFields", { enumerable: true, get: f
|
|
|
9
9
|
Object.defineProperty(exports, "deriveAll", { enumerable: true, get: function () { return derive_1.deriveAll; } });
|
|
10
10
|
var toVariables_1 = require("./toVariables");
|
|
11
11
|
Object.defineProperty(exports, "productVariables", { enumerable: true, get: function () { return toVariables_1.productVariables; } });
|
|
12
|
+
var refIdentity_1 = require("./refIdentity");
|
|
13
|
+
Object.defineProperty(exports, "productRefIdentity", { enumerable: true, get: function () { return refIdentity_1.productRefIdentity; } });
|
|
12
14
|
var useProducts_1 = require("./useProducts");
|
|
13
15
|
Object.defineProperty(exports, "useProducts", { enumerable: true, get: function () { return useProducts_1.useProducts; } });
|
|
14
16
|
var ProductRuntimeContext_1 = require("./ProductRuntimeContext");
|
|
@@ -20,4 +22,6 @@ var revenueCat_1 = require("./adapters/revenueCat");
|
|
|
20
22
|
Object.defineProperty(exports, "revenueCatProductProvider", { enumerable: true, get: function () { return revenueCat_1.revenueCatProductProvider; } });
|
|
21
23
|
var expoIap_1 = require("./adapters/expoIap");
|
|
22
24
|
Object.defineProperty(exports, "expoIapProductProvider", { enumerable: true, get: function () { return expoIap_1.expoIapProductProvider; } });
|
|
25
|
+
var stripeLink_1 = require("./adapters/stripeLink");
|
|
26
|
+
Object.defineProperty(exports, "stripeLinkProductProvider", { enumerable: true, get: function () { return stripeLink_1.stripeLinkProductProvider; } });
|
|
23
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/products/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/products/index.ts"],"names":[],"mappings":";;;AAaA,uCAA8C;AAArC,4GAAA,gBAAgB,OAAA;AACzB,mCAA0E;AAAjE,wGAAA,cAAc,OAAA;AAAE,6GAAA,mBAAmB,OAAA;AAAE,mGAAA,SAAS,OAAA;AACvD,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA;AACzB,6CAAmD;AAA1C,iHAAA,kBAAkB,OAAA;AAC3B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,iEAAmF;AAA1E,8HAAA,qBAAqB,OAAA;AAAE,0HAAA,iBAAiB,OAAA;AACjD,wCAAsD;AAA7C,2GAAA,mBAAmB,OAAA;AAC5B,oDAAkE;AAAzD,uHAAA,yBAAyB,OAAA;AAClC,8CAA4D;AAAnD,iHAAA,sBAAsB,OAAA;AAC/B,oDAAkE;AAAzD,uHAAA,yBAAyB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refIdentity.d.ts","sourceRoot":"","sources":["../../src/products/refIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAoB1C,eAAO,MAAM,kBAAkB,GAAI,KAAK,UAAU,KAAG,MAYxC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.productRefIdentity = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The content identity of a `ProductRef` — the ONE place its fields are
|
|
6
|
+
* enumerated.
|
|
7
|
+
*
|
|
8
|
+
* Two callers depend on this and neither fails loudly when it is wrong:
|
|
9
|
+
* `useProducts`'s `refsKey` (a stale identity means a changed ref never
|
|
10
|
+
* refetches) and `collectProductRefs`'s dedup (a colliding identity means two
|
|
11
|
+
* distinct refs collapse into one and the second is never resolved). Both used
|
|
12
|
+
* to hand-roll the same template string, so adding a field to `ProductRef`
|
|
13
|
+
* meant remembering two places. Add new fields HERE and both callers follow.
|
|
14
|
+
*
|
|
15
|
+
* A unit separator (U+001F) rather than a printable one: a Play id is
|
|
16
|
+
* `productId:basePlanId` and a Payment Link is a URL, both of which can
|
|
17
|
+
* contain almost any printable character, so a printable separator risks
|
|
18
|
+
* `{ios:"a",android:"b"}` and `{ios:"a|b"}` hashing alike.
|
|
19
|
+
*/
|
|
20
|
+
const SEP = "\u001F";
|
|
21
|
+
const productRefIdentity = (ref) => {
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
23
|
+
return [
|
|
24
|
+
ref.key,
|
|
25
|
+
(_a = ref.ios) !== null && _a !== void 0 ? _a : "",
|
|
26
|
+
(_b = ref.android) !== null && _b !== void 0 ? _b : "",
|
|
27
|
+
(_c = ref.compareTo) !== null && _c !== void 0 ? _c : "",
|
|
28
|
+
(_e = (_d = ref.stripe) === null || _d === void 0 ? void 0 : _d.paymentLink) !== null && _e !== void 0 ? _e : "",
|
|
29
|
+
(_g = (_f = ref.stripe) === null || _f === void 0 ? void 0 : _f.priceId) !== null && _g !== void 0 ? _g : "",
|
|
30
|
+
(_j = (_h = ref.stripe) === null || _h === void 0 ? void 0 : _h.amount) !== null && _j !== void 0 ? _j : "",
|
|
31
|
+
(_l = (_k = ref.stripe) === null || _k === void 0 ? void 0 : _k.currency) !== null && _l !== void 0 ? _l : "",
|
|
32
|
+
(_o = (_m = ref.stripe) === null || _m === void 0 ? void 0 : _m.periodIso) !== null && _o !== void 0 ? _o : "",
|
|
33
|
+
(_q = (_p = ref.stripe) === null || _p === void 0 ? void 0 : _p.trialDays) !== null && _q !== void 0 ? _q : "",
|
|
34
|
+
].join(SEP);
|
|
35
|
+
};
|
|
36
|
+
exports.productRefIdentity = productRefIdentity;
|
|
37
|
+
//# sourceMappingURL=refIdentity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refIdentity.js","sourceRoot":"","sources":["../../src/products/refIdentity.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,GAAG,GAAG,QAAQ,CAAC;AAEd,MAAM,kBAAkB,GAAG,CAAC,GAAe,EAAU,EAAE;;IAC5D,OAAA;QACE,GAAG,CAAC,GAAG;QACP,MAAA,GAAG,CAAC,GAAG,mCAAI,EAAE;QACb,MAAA,GAAG,CAAC,OAAO,mCAAI,EAAE;QACjB,MAAA,GAAG,CAAC,SAAS,mCAAI,EAAE;QACnB,MAAA,MAAA,GAAG,CAAC,MAAM,0CAAE,WAAW,mCAAI,EAAE;QAC7B,MAAA,MAAA,GAAG,CAAC,MAAM,0CAAE,OAAO,mCAAI,EAAE;QACzB,MAAA,MAAA,GAAG,CAAC,MAAM,0CAAE,MAAM,mCAAI,EAAE;QACxB,MAAA,MAAA,GAAG,CAAC,MAAM,0CAAE,QAAQ,mCAAI,EAAE;QAC1B,MAAA,MAAA,GAAG,CAAC,MAAM,0CAAE,SAAS,mCAAI,EAAE;QAC3B,MAAA,MAAA,GAAG,CAAC,MAAM,0CAAE,SAAS,mCAAI,EAAE;KAC5B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;CAAA,CAAC;AAZD,QAAA,kBAAkB,sBAYjB"}
|
package/dist/products/types.d.ts
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Stripe Payment Link and the price to render beside it.
|
|
3
|
+
*
|
|
4
|
+
* Unlike `ios`/`android` — which are ids a store resolves at runtime — this
|
|
5
|
+
* block is the RESOLVED product. There is no Stripe runtime to ask: listing a
|
|
6
|
+
* price needs a secret key, and by design nobody in this system holds one
|
|
7
|
+
* (not the host, not Onboarding Studio). So the studio copies the authored
|
|
8
|
+
* price onto the ref, and `stripeLinkProductProvider` synthesises a
|
|
9
|
+
* `ResolvedProduct` from it without any network call.
|
|
10
|
+
*
|
|
11
|
+
* Consequence the author owns: this price can DRIFT from Stripe. Nothing
|
|
12
|
+
* reconciles them.
|
|
13
|
+
*/
|
|
14
|
+
export type StripeProductRef = {
|
|
15
|
+
/** `https://buy.stripe.com/...`, pre-created in Stripe. Required — nothing to open without it. */
|
|
16
|
+
paymentLink: string;
|
|
17
|
+
/** `price_...`. Informational in this version; kept for reconciliation and a future proxy mode. */
|
|
18
|
+
priceId?: string;
|
|
19
|
+
/** Major units (79, not 7900), matching `project_products.stripe_price.amount`. */
|
|
20
|
+
amount: number;
|
|
21
|
+
/** ISO-4217, e.g. "USD". */
|
|
22
|
+
currency: string;
|
|
23
|
+
/** ISO-8601, e.g. "P1Y". Drives `pricePerWeek` and friends via `deriveProductFields`. */
|
|
24
|
+
periodIso?: string | null;
|
|
25
|
+
trialDays?: number;
|
|
26
|
+
};
|
|
1
27
|
/** A product slot declared by the author: a stable key plus per-store ids. */
|
|
2
28
|
export type ProductRef = {
|
|
3
29
|
/** Author-chosen slot name used in variables, e.g. "yearly" → product.yearly.price */
|
|
@@ -6,6 +32,8 @@ export type ProductRef = {
|
|
|
6
32
|
ios?: string;
|
|
7
33
|
/** Play product identifier. `productId:basePlanId` — RevenueCat's convention. */
|
|
8
34
|
android?: string;
|
|
35
|
+
/** Stripe Payment Link + authored price. Present only on a `billing: "stripe"` paywall's refs. */
|
|
36
|
+
stripe?: StripeProductRef;
|
|
9
37
|
/** Another slot's key; savingsPct is computed against it. */
|
|
10
38
|
compareTo?: string;
|
|
11
39
|
};
|
|
@@ -15,7 +43,7 @@ export type ResolvedProduct = {
|
|
|
15
43
|
key: string;
|
|
16
44
|
/** The identifier resolved for THIS platform. */
|
|
17
45
|
productId: string;
|
|
18
|
-
store: "app_store" | "play_store";
|
|
46
|
+
store: "app_store" | "play_store" | "stripe";
|
|
19
47
|
title: string;
|
|
20
48
|
description: string;
|
|
21
49
|
/** Store-localized, pre-formatted, e.g. "$59.99". Display this. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/products/types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,MAAM,UAAU,GAAG;IACvB,sFAAsF;IACtF,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;AAEnE,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/products/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,kGAAkG;IAClG,WAAW,EAAE,MAAM,CAAC;IACpB,mGAAmG;IACnG,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;I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,CAAC,CAAC;IAC5D,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAEnE,oFAAoF;AACpF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gFAAgF;IAChF,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACnD,OAAO,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;CACvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProducts.d.ts","sourceRoot":"","sources":["../../src/products/useProducts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useProducts.d.ts","sourceRoot":"","sources":["../../src/products/useProducts.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,UAAU,EACV,cAAc,EAKf,MAAM,SAAS,CAAC;AAIjB;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,UAAU,EAAE,GAAG,SAAS,EAC9B,UAAU,eAAe,GAAG,SAAS,EACrC,SAAS,MAAM,KACd,cAgFF,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useProducts = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const derive_1 = require("./derive");
|
|
6
|
+
const refIdentity_1 = require("./refIdentity");
|
|
6
7
|
const EMPTY_PRODUCTS = {};
|
|
7
8
|
/**
|
|
8
9
|
* Resolves `refs` through `provider` once per (refs, provider) pair and exposes
|
|
@@ -25,7 +26,12 @@ const useProducts = (refs, provider, locale) => {
|
|
|
25
26
|
providerRef.current = provider;
|
|
26
27
|
// Key the effect on the refs' identity CONTENT, not the array identity — a
|
|
27
28
|
// host passing an inline array literal would otherwise refetch every render.
|
|
28
|
-
|
|
29
|
+
// `productRefIdentity` owns the field list; see its doc for why it is shared
|
|
30
|
+
// with `collectProductRefs` rather than duplicated here.
|
|
31
|
+
// "\u001E" (record separator) BETWEEN refs, distinct from the "\u001F"
|
|
32
|
+
// `productRefIdentity` puts between FIELDS — one separator for each nesting
|
|
33
|
+
// level, so no arrangement of ids can produce two identical keys.
|
|
34
|
+
const refsKey = (0, react_1.useMemo)(() => (refs !== null && refs !== void 0 ? refs : []).map(refIdentity_1.productRefIdentity).join("\u001E"), [refs]);
|
|
29
35
|
const refsRef = (0, react_1.useRef)(refs);
|
|
30
36
|
refsRef.current = refs;
|
|
31
37
|
(0, react_1.useEffect)(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProducts.js","sourceRoot":"","sources":["../../src/products/useProducts.ts"],"names":[],"mappings":";;;AAAA,iCAA0E;AAC1E,qCAAqC;
|
|
1
|
+
{"version":3,"file":"useProducts.js","sourceRoot":"","sources":["../../src/products/useProducts.ts"],"names":[],"mappings":";;;AAAA,iCAA0E;AAC1E,qCAAqC;AACrC,+CAAmD;AAWnD,MAAM,cAAc,GAAuC,EAAE,CAAC;AAE9D;;;;;;;;GAQG;AACI,MAAM,WAAW,GAAG,CACzB,IAA8B,EAC9B,QAAqC,EACrC,MAAe,EACC,EAAE;IAClB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAqC,cAAc,CAAC,CAAC;IAC7F,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAgB,MAAM,CAAC,CAAC;IAC5D,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAqB,SAAS,CAAC,CAAC;IAClE,MAAM,CAA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ACnF,CAAC;gBAAS,CAAC;YACT,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,KAAK,IAA4B,EAAE;QAC7D,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,IAAI;YAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC9E,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnF,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,IAAA,eAAO,EACZ,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,EAClE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CACzD,CAAC;AACJ,CAAC,CAAC;AApFW,QAAA,WAAW,eAoFtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocapine/react-native-onboarding",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.70.0",
|
|
4
4
|
"description": "Headless React Native SDK for Rocapine Onboarding Studio - Data fetching, state management, and hooks",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -130,11 +130,11 @@ export class OnboardingStudioClient {
|
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* Fetches the paywall catalog for this project/audience/locale from
|
|
133
|
-
* `get-paywalls`. By design **omits `
|
|
134
|
-
* deliberately returns every
|
|
133
|
+
* `get-paywalls`. By design **omits `moment` by default** — the endpoint
|
|
134
|
+
* deliberately returns every moment in one round-trip so a paywall can
|
|
135
135
|
* be presented the instant the user taps upgrade, without a network call at
|
|
136
|
-
* that moment (spec §6.1). Pass `paywallOptions.
|
|
137
|
-
* single
|
|
136
|
+
* that moment (spec §6.1). Pass `paywallOptions.moment` only when a
|
|
137
|
+
* single moment is genuinely all that's needed.
|
|
138
138
|
*
|
|
139
139
|
* Unlike `getSteps`, there is no fallback-payload option here: a
|
|
140
140
|
* non-`ok` response or a network failure always rejects rather than
|
|
@@ -174,8 +174,8 @@ export class OnboardingStudioClient {
|
|
|
174
174
|
|
|
175
175
|
// Narrows the response to a single paywall. Omitted unless explicitly
|
|
176
176
|
// requested — see the method doc above.
|
|
177
|
-
if (paywallOptions?.
|
|
178
|
-
urlParams.append("
|
|
177
|
+
if (paywallOptions?.moment) {
|
|
178
|
+
urlParams.append("moment", paywallOptions.moment);
|
|
179
179
|
}
|
|
180
180
|
|
|
181
181
|
// Deliberately NOT sending spec §6.1's `omitNulls=true`: it's a
|
|
@@ -209,7 +209,7 @@ export class OnboardingStudioClient {
|
|
|
209
209
|
return {
|
|
210
210
|
data,
|
|
211
211
|
headers: {
|
|
212
|
-
"ONBS-Audience-
|
|
212
|
+
"ONBS-Audience-Ids": response.headers.get("ONBS-Audience-Ids"),
|
|
213
213
|
"ONBS-Paywall-Ids": response.headers.get("ONBS-Paywall-Ids"),
|
|
214
214
|
},
|
|
215
215
|
};
|
package/src/index.ts
CHANGED
|
@@ -101,4 +101,7 @@ export type {
|
|
|
101
101
|
export { PaywallProvider, usePaywallHost } from "./paywalls/PaywallProvider";
|
|
102
102
|
export type { PaywallContextValue } from "./paywalls/PaywallProvider";
|
|
103
103
|
export { usePaywall } from "./paywalls/usePaywall";
|
|
104
|
+
// Exported so a host can switch exhaustively on what the catalog is doing
|
|
105
|
+
// rather than inferring it from `isReady` plus a non-null check.
|
|
106
|
+
export type { CatalogStatus } from "./paywalls/present";
|
|
104
107
|
export type { UsePaywallResult } from "./paywalls/usePaywall";
|