@rocapine/react-native-onboarding 1.61.0 → 1.63.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 +23 -5
- package/dist/OnboardingStudioClient.d.ts.map +1 -1
- package/dist/OnboardingStudioClient.js +82 -6
- package/dist/OnboardingStudioClient.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/infra/hooks/index.d.ts +1 -0
- package/dist/infra/hooks/index.d.ts.map +1 -1
- package/dist/infra/hooks/index.js +3 -1
- package/dist/infra/hooks/index.js.map +1 -1
- package/dist/infra/hooks/useProgressHeaderConfig.d.ts +14 -0
- package/dist/infra/hooks/useProgressHeaderConfig.d.ts.map +1 -0
- package/dist/infra/hooks/useProgressHeaderConfig.js +24 -0
- package/dist/infra/hooks/useProgressHeaderConfig.js.map +1 -0
- package/dist/infra/preload/extractAssetUrls.d.ts.map +1 -1
- package/dist/infra/preload/extractAssetUrls.js +67 -0
- package/dist/infra/preload/extractAssetUrls.js.map +1 -1
- package/dist/infra/provider/OnboardingProvider.d.ts +25 -0
- package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
- package/dist/infra/provider/OnboardingProvider.js +74 -3
- package/dist/infra/provider/OnboardingProvider.js.map +1 -1
- package/dist/infra/queries/cacheKey.d.ts +22 -4
- package/dist/infra/queries/cacheKey.d.ts.map +1 -1
- package/dist/infra/queries/cacheKey.js +26 -5
- package/dist/infra/queries/cacheKey.js.map +1 -1
- package/dist/onboarding-example.d.ts +1063 -60
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +140 -0
- package/dist/onboarding-example.js.map +1 -1
- package/dist/paywalls/PaywallProvider.d.ts +66 -0
- package/dist/paywalls/PaywallProvider.d.ts.map +1 -0
- package/dist/paywalls/PaywallProvider.js +227 -0
- package/dist/paywalls/PaywallProvider.js.map +1 -0
- package/dist/paywalls/getPaywalls.query.d.ts +37 -0
- package/dist/paywalls/getPaywalls.query.d.ts.map +1 -0
- package/dist/paywalls/getPaywalls.query.js +114 -0
- package/dist/paywalls/getPaywalls.query.js.map +1 -0
- package/dist/paywalls/present.d.ts +100 -0
- package/dist/paywalls/present.d.ts.map +1 -0
- package/dist/paywalls/present.js +113 -0
- package/dist/paywalls/present.js.map +1 -0
- package/dist/paywalls/types.d.ts +95 -0
- package/dist/paywalls/types.d.ts.map +1 -0
- package/dist/paywalls/types.js +10 -0
- package/dist/paywalls/types.js.map +1 -0
- package/dist/paywalls/usePaywall.d.ts +29 -0
- package/dist/paywalls/usePaywall.d.ts.map +1 -0
- package/dist/paywalls/usePaywall.js +17 -0
- package/dist/paywalls/usePaywall.js.map +1 -0
- package/dist/products/ProductRuntimeContext.d.ts +15 -0
- package/dist/products/ProductRuntimeContext.d.ts.map +1 -0
- package/dist/products/ProductRuntimeContext.js +19 -0
- package/dist/products/ProductRuntimeContext.js.map +1 -0
- package/dist/products/index.d.ts +1 -0
- package/dist/products/index.d.ts.map +1 -1
- package/dist/products/index.js +4 -1
- package/dist/products/index.js.map +1 -1
- package/dist/products/mergeProductRuntimes.d.ts +55 -0
- package/dist/products/mergeProductRuntimes.d.ts.map +1 -0
- package/dist/products/mergeProductRuntimes.js +79 -0
- package/dist/products/mergeProductRuntimes.js.map +1 -0
- package/dist/screens/elements/AnimatedTextElement.d.ts +7 -0
- package/dist/screens/elements/AnimatedTextElement.d.ts.map +1 -1
- package/dist/screens/elements/BaseBoxProps.d.ts +39 -0
- package/dist/screens/elements/BaseBoxProps.d.ts.map +1 -1
- package/dist/screens/elements/BaseBoxProps.js +9 -0
- package/dist/screens/elements/BaseBoxProps.js.map +1 -1
- package/dist/screens/elements/ButtonElement.d.ts +28 -0
- package/dist/screens/elements/ButtonElement.d.ts.map +1 -1
- package/dist/screens/elements/CarouselElement.d.ts +38 -0
- package/dist/screens/elements/CarouselElement.d.ts.map +1 -1
- package/dist/screens/elements/CarouselElement.js +1 -0
- package/dist/screens/elements/CarouselElement.js.map +1 -1
- package/dist/screens/elements/CheckboxGroupElement.d.ts +7 -0
- package/dist/screens/elements/CheckboxGroupElement.d.ts.map +1 -1
- package/dist/screens/elements/DatePickerElement.d.ts +7 -0
- package/dist/screens/elements/DatePickerElement.d.ts.map +1 -1
- package/dist/screens/elements/DrawingPadElement.d.ts +7 -0
- package/dist/screens/elements/DrawingPadElement.d.ts.map +1 -1
- package/dist/screens/elements/IconElement.d.ts +7 -0
- package/dist/screens/elements/IconElement.d.ts.map +1 -1
- package/dist/screens/elements/ImageElement.d.ts +26 -0
- package/dist/screens/elements/ImageElement.d.ts.map +1 -1
- package/dist/screens/elements/ImageElement.js +1 -0
- package/dist/screens/elements/ImageElement.js.map +1 -1
- package/dist/screens/elements/InputElement.d.ts +7 -0
- package/dist/screens/elements/InputElement.d.ts.map +1 -1
- package/dist/screens/elements/KeyboardAvoidingViewElement.d.ts +7 -0
- package/dist/screens/elements/KeyboardAvoidingViewElement.d.ts.map +1 -1
- package/dist/screens/elements/LottieElement.d.ts +7 -0
- package/dist/screens/elements/LottieElement.d.ts.map +1 -1
- package/dist/screens/elements/ProgressIndicatorElement.d.ts +7 -0
- package/dist/screens/elements/ProgressIndicatorElement.d.ts.map +1 -1
- package/dist/screens/elements/ProgressiveBlurImageElement.d.ts +7 -0
- package/dist/screens/elements/ProgressiveBlurImageElement.d.ts.map +1 -1
- package/dist/screens/elements/RadioGroupElement.d.ts +7 -0
- package/dist/screens/elements/RadioGroupElement.d.ts.map +1 -1
- package/dist/screens/elements/RepeatElement.d.ts +79 -0
- package/dist/screens/elements/RepeatElement.d.ts.map +1 -0
- package/dist/screens/elements/RepeatElement.js +10 -0
- package/dist/screens/elements/RepeatElement.js.map +1 -0
- package/dist/screens/elements/RichTextElement.d.ts +7 -0
- package/dist/screens/elements/RichTextElement.d.ts.map +1 -1
- package/dist/screens/elements/RiveElement.d.ts +7 -0
- package/dist/screens/elements/RiveElement.d.ts.map +1 -1
- package/dist/screens/elements/SafeAreaViewElement.d.ts +7 -0
- package/dist/screens/elements/SafeAreaViewElement.d.ts.map +1 -1
- package/dist/screens/elements/ScrollViewElement.d.ts +7 -0
- package/dist/screens/elements/ScrollViewElement.d.ts.map +1 -1
- package/dist/screens/elements/SliderElement.d.ts +7 -0
- package/dist/screens/elements/SliderElement.d.ts.map +1 -1
- package/dist/screens/elements/StackElement.d.ts +7 -0
- package/dist/screens/elements/StackElement.d.ts.map +1 -1
- package/dist/screens/elements/TextElement.d.ts +7 -0
- package/dist/screens/elements/TextElement.d.ts.map +1 -1
- package/dist/screens/elements/TypewriterTextElement.d.ts +26 -0
- package/dist/screens/elements/TypewriterTextElement.d.ts.map +1 -1
- package/dist/screens/elements/TypewriterTextElement.js +1 -0
- package/dist/screens/elements/TypewriterTextElement.js.map +1 -1
- package/dist/screens/elements/VideoElement.d.ts +7 -0
- package/dist/screens/elements/VideoElement.d.ts.map +1 -1
- package/dist/screens/elements/WheelPickerElement.d.ts +7 -0
- package/dist/screens/elements/WheelPickerElement.d.ts.map +1 -1
- package/dist/screens/elements/ZStackElement.d.ts +7 -0
- package/dist/screens/elements/ZStackElement.d.ts.map +1 -1
- package/dist/screens/types.d.ts +9 -0
- package/dist/screens/types.d.ts.map +1 -1
- package/dist/screens/types.js +9 -0
- package/dist/screens/types.js.map +1 -1
- package/dist/screens/unknownKeys.d.ts +67 -0
- package/dist/screens/unknownKeys.d.ts.map +1 -0
- package/dist/screens/unknownKeys.js +160 -0
- package/dist/screens/unknownKeys.js.map +1 -0
- package/dist/steps/common.types.d.ts +22 -1
- package/dist/steps/common.types.d.ts.map +1 -1
- package/dist/steps/common.types.js +10 -1
- package/dist/steps/common.types.js.map +1 -1
- package/dist/types.d.ts +73 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/OnboardingStudioClient.ts +110 -7
- package/src/__tests__/extractAssetUrls.test.ts +104 -0
- package/src/__tests__/mergeProductRuntimes.test.ts +172 -0
- package/src/__tests__/resolveLocalProductArgs.test.ts +41 -0
- package/src/__tests__/unknownKeys.test.ts +234 -0
- package/src/index.ts +20 -0
- package/src/infra/hooks/index.ts +1 -0
- package/src/infra/hooks/useProgressHeaderConfig.ts +21 -0
- package/src/infra/preload/extractAssetUrls.ts +72 -0
- package/src/infra/provider/OnboardingProvider.tsx +87 -3
- package/src/infra/queries/cacheKey.ts +27 -4
- package/src/onboarding-example.ts +140 -0
- package/src/paywalls/PaywallProvider.tsx +342 -0
- package/src/paywalls/__tests__/getPaywalls.test.ts +334 -0
- package/src/paywalls/__tests__/present.test.ts +190 -0
- package/src/paywalls/getPaywalls.query.ts +123 -0
- package/src/paywalls/present.ts +141 -0
- package/src/paywalls/types.ts +99 -0
- package/src/paywalls/usePaywall.ts +35 -0
- package/src/products/ProductRuntimeContext.tsx +17 -0
- package/src/products/index.ts +1 -0
- package/src/products/mergeProductRuntimes.ts +78 -0
- package/src/screens/elements/BaseBoxProps.ts +56 -0
- package/src/screens/elements/CarouselElement.ts +31 -0
- package/src/screens/elements/ImageElement.ts +16 -0
- package/src/screens/elements/RepeatElement.ts +80 -0
- package/src/screens/elements/TypewriterTextElement.ts +19 -0
- package/src/screens/types.ts +18 -0
- package/src/screens/unknownKeys.ts +211 -0
- package/src/steps/common.types.ts +34 -1
- package/src/types.ts +86 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaywallProvider.js","sourceRoot":"","sources":["../../src/paywalls/PaywallProvider.tsx"],"names":[],"mappings":";;;;AAAA,iCAAqG;AACrG,uDAAmF;AAEnF,2DAAuD;AAEvD,uCAQmB;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;Q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c,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,aAAa,GAAG,oBAAoB,GACf,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,aAAa,EAAE,aAAa,YAE3B,QAAQ,GACY,GACH,CACvB,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,eAAe,mBAqB1B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { QueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { OnboardingStudioClient } from "../OnboardingStudioClient";
|
|
3
|
+
import { PaywallCatalog } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Mirrors `getOnboarding.query.ts`'s cache-first / background-revalidate /
|
|
6
|
+
* custom-key behaviour exactly (same `staleTime: Infinity`, same
|
|
7
|
+
* production-vs-sandbox split, same "no background refetch under a custom
|
|
8
|
+
* key" rule) so a paywall does not revalidate differently from an
|
|
9
|
+
* onboarding.
|
|
10
|
+
*
|
|
11
|
+
* Deliberate difference: `getOnboardingQuery`'s `fetchAndCache` special-cases
|
|
12
|
+
* the client's offline-fallback payload (`ONBS-Onboarding-Id === "fallback"`)
|
|
13
|
+
* and skips caching it. `OnboardingStudioClient.getPaywalls` has no fallback
|
|
14
|
+
* option — it always throws on a network/response error instead of returning
|
|
15
|
+
* a stand-in payload — so there is no fallback case to special-case here:
|
|
16
|
+
* every resolved catalog is a real one and is always cached.
|
|
17
|
+
*
|
|
18
|
+
* `catalog` consumption used to be a `setCatalog` callback mirrored into a
|
|
19
|
+
* component `useState` — but `queryFn` only re-runs on a cache MISS
|
|
20
|
+
* (`staleTime: Infinity`), so that mirror went stale on a provider remount
|
|
21
|
+
* (module-scope `QueryClient`, cache outlives the provider) and on a
|
|
22
|
+
* query-key round-trip (`locale` switched away and back) — Finding 1, 2026-
|
|
23
|
+
* 08-17 final review. The fix: `PaywallProviderInner` now reads `data`
|
|
24
|
+
* straight off `useQuery` as the single source of truth — react-query's own
|
|
25
|
+
* cache already gets this right on both a remount and a key round-trip. The
|
|
26
|
+
* ONE case `data` alone can't cover is the BACKGROUND revalidation below:
|
|
27
|
+
* `fetchAndCache()` there runs detached from the pending query call (its
|
|
28
|
+
* return value is discarded, not observed by react-query), so it must push
|
|
29
|
+
* the fresh payload into the query cache directly via `queryClient.
|
|
30
|
+
* setQueryData` — there is no mirrored component state left to keep in sync.
|
|
31
|
+
*/
|
|
32
|
+
export declare const getPaywallsQuery: (client: OnboardingStudioClient, locale: string, customAudienceParams: Record<string, any>, queryClient?: QueryClient) => {
|
|
33
|
+
queryKey: (string | boolean | undefined)[];
|
|
34
|
+
queryFn: () => Promise<PaywallCatalog>;
|
|
35
|
+
staleTime: number;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=getPaywalls.query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPaywalls.query.d.ts","sourceRoot":"","sources":["../../src/paywalls/getPaywalls.query.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,sBAAsB,EAC9B,QAAQ,MAAM,EACd,sBAAsB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzC,cAAc,WAAW;;mBAcJ,OAAO,CAAC,cAAc,CAAC;;CAsE7C,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getPaywallsQuery = void 0;
|
|
7
|
+
const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
|
|
8
|
+
const cacheKey_1 = require("../infra/queries/cacheKey");
|
|
9
|
+
/**
|
|
10
|
+
* Mirrors `getOnboarding.query.ts`'s cache-first / background-revalidate /
|
|
11
|
+
* custom-key behaviour exactly (same `staleTime: Infinity`, same
|
|
12
|
+
* production-vs-sandbox split, same "no background refetch under a custom
|
|
13
|
+
* key" rule) so a paywall does not revalidate differently from an
|
|
14
|
+
* onboarding.
|
|
15
|
+
*
|
|
16
|
+
* Deliberate difference: `getOnboardingQuery`'s `fetchAndCache` special-cases
|
|
17
|
+
* the client's offline-fallback payload (`ONBS-Onboarding-Id === "fallback"`)
|
|
18
|
+
* and skips caching it. `OnboardingStudioClient.getPaywalls` has no fallback
|
|
19
|
+
* option — it always throws on a network/response error instead of returning
|
|
20
|
+
* a stand-in payload — so there is no fallback case to special-case here:
|
|
21
|
+
* every resolved catalog is a real one and is always cached.
|
|
22
|
+
*
|
|
23
|
+
* `catalog` consumption used to be a `setCatalog` callback mirrored into a
|
|
24
|
+
* component `useState` — but `queryFn` only re-runs on a cache MISS
|
|
25
|
+
* (`staleTime: Infinity`), so that mirror went stale on a provider remount
|
|
26
|
+
* (module-scope `QueryClient`, cache outlives the provider) and on a
|
|
27
|
+
* query-key round-trip (`locale` switched away and back) — Finding 1, 2026-
|
|
28
|
+
* 08-17 final review. The fix: `PaywallProviderInner` now reads `data`
|
|
29
|
+
* straight off `useQuery` as the single source of truth — react-query's own
|
|
30
|
+
* cache already gets this right on both a remount and a key round-trip. The
|
|
31
|
+
* ONE case `data` alone can't cover is the BACKGROUND revalidation below:
|
|
32
|
+
* `fetchAndCache()` there runs detached from the pending query call (its
|
|
33
|
+
* return value is discarded, not observed by react-query), so it must push
|
|
34
|
+
* the fresh payload into the query cache directly via `queryClient.
|
|
35
|
+
* setQueryData` — there is no mirrored component state left to keep in sync.
|
|
36
|
+
*/
|
|
37
|
+
const getPaywallsQuery = (client, locale, customAudienceParams, queryClient) => {
|
|
38
|
+
const queryKey = [
|
|
39
|
+
"paywallCatalog",
|
|
40
|
+
client.projectId,
|
|
41
|
+
client.options.isSandbox,
|
|
42
|
+
client.options.baseUrl,
|
|
43
|
+
client.options.cacheKey,
|
|
44
|
+
locale,
|
|
45
|
+
JSON.stringify(customAudienceParams),
|
|
46
|
+
];
|
|
47
|
+
return {
|
|
48
|
+
queryKey,
|
|
49
|
+
queryFn: async () => {
|
|
50
|
+
var _a;
|
|
51
|
+
const isProduction = !(((_a = client === null || client === void 0 ? void 0 : client.options) === null || _a === void 0 ? void 0 : _a.isSandbox) || false);
|
|
52
|
+
// A custom key opts into app-controlled caching: persist cache-first
|
|
53
|
+
// with NO background revalidation, so a pinned version survives across
|
|
54
|
+
// launches. The default key keeps stale-while-revalidate.
|
|
55
|
+
const hasCustomKey = Boolean(client.options.cacheKey);
|
|
56
|
+
const cacheKey = (0, cacheKey_1.getPaywallsCacheKey)(client.options.cacheKey);
|
|
57
|
+
// Fetches the live catalog, caches it, and pushes it into the query
|
|
58
|
+
// cache directly — see the module doc above for why that push is
|
|
59
|
+
// needed even though `queryFn`'s own return value already becomes
|
|
60
|
+
// `data` for a LIVE call: this same function also runs detached, as a
|
|
61
|
+
// background revalidation, whose return value nothing observes.
|
|
62
|
+
// Unlike `getOnboardingQuery`, there is no fallback payload to exclude
|
|
63
|
+
// from caching — a rejection here propagates as-is (error-surfacing,
|
|
64
|
+
// not a resolved fallback).
|
|
65
|
+
const fetchAndCache = async () => {
|
|
66
|
+
const { data } = await client.getPaywalls({ locale }, customAudienceParams);
|
|
67
|
+
queryClient === null || queryClient === void 0 ? void 0 : queryClient.setQueryData(queryKey, data);
|
|
68
|
+
try {
|
|
69
|
+
await async_storage_1.default.setItem(cacheKey, JSON.stringify(data));
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.warn("Failed to cache paywalls:", error);
|
|
73
|
+
}
|
|
74
|
+
return data;
|
|
75
|
+
};
|
|
76
|
+
// Sandbox / draft: always fetch fresh, no caching.
|
|
77
|
+
if (!isProduction) {
|
|
78
|
+
return fetchAndCache();
|
|
79
|
+
}
|
|
80
|
+
// Production: serve the cached catalog instantly (fast first paint,
|
|
81
|
+
// offline-resilient). With the default key this is stale-while-revalidate
|
|
82
|
+
// (also refresh in the background so studio re-deploys propagate and a
|
|
83
|
+
// stale cache heals). With a custom key it's persist-only — no background
|
|
84
|
+
// refetch — so a pinned version is never swapped out from under the host.
|
|
85
|
+
let cached = null;
|
|
86
|
+
try {
|
|
87
|
+
const cachedData = await async_storage_1.default.getItem(cacheKey);
|
|
88
|
+
if (cachedData)
|
|
89
|
+
cached = JSON.parse(cachedData);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
console.warn("Failed to load cached paywalls:", error);
|
|
93
|
+
}
|
|
94
|
+
if (cached) {
|
|
95
|
+
if (!hasCustomKey) {
|
|
96
|
+
// Background revalidation — updates the cache + query state when a
|
|
97
|
+
// fresh real payload arrives via `queryClient.setQueryData` above.
|
|
98
|
+
// Errors are swallowed: the cache already painted, so an offline
|
|
99
|
+
// revalidation must not surface as a query error.
|
|
100
|
+
void fetchAndCache().catch((error) => {
|
|
101
|
+
console.warn("Background paywalls revalidation failed:", error);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return cached;
|
|
105
|
+
}
|
|
106
|
+
// No cache yet: await the network. A rejection here surfaces as the
|
|
107
|
+
// query's error (there is no fallback to fall back to).
|
|
108
|
+
return fetchAndCache();
|
|
109
|
+
},
|
|
110
|
+
staleTime: Infinity,
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
exports.getPaywallsQuery = getPaywallsQuery;
|
|
114
|
+
//# sourceMappingURL=getPaywalls.query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPaywalls.query.js","sourceRoot":"","sources":["../../src/paywalls/getPaywalls.query.ts"],"names":[],"mappings":";;;;;;AAAA,8FAAqE;AAIrE,wDAAgE;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,MAAM,gBAAgB,GAAG,CAC9B,MAA8B,EAC9B,MAAc,EACd,oBAAyC,EACzC,WAAyB,EACzB,EAAE;IACF,MAAM,QAAQ,GAAG;QACf,gBAAgB;QAChB,MAAM,CAAC,SAAS;QAChB,MAAM,CAAC,OAAO,CAAC,SAAS;QACxB,MAAM,CAAC,OAAO,CAAC,OAAO;QACtB,MAAM,CAAC,OAAO,CAAC,QAAQ;QACvB,MAAM;QACN,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC;KACrC,CAAC;IAEF,OAAO;QACL,QAAQ;QACR,OAAO,EAAE,KAAK,IAA6B,EAAE;;YAC3C,MAAM,YAAY,GAAG,CAAC,CAAC,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,0CAAE,SAAS,KAAI,KAAK,CAAC,CAAC;YAC5D,qEAAqE;YACrE,uEAAuE;YACvE,0DAA0D;YAC1D,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACtD,MAAM,QAAQ,GAAG,IAAA,8BAAmB,EAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAE9D,oEAAoE;YACpE,iEAAiE;YACjE,kEAAkE;YAClE,sEAAsE;YACtE,gEAAgE;YAChE,uEAAuE;YACvE,qEAAqE;YACrE,4BA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AO,CAAC,IAAI,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;oBAClE,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,MAAM,CAAC;YAChB,CAAC;YAED,oEAAoE;YACpE,wDAAwD;YACxD,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC;QACD,SAAS,EAAE,QAAQ;KACpB,CAAC;AACJ,CAAC,CAAC;AAxFW,QAAA,gBAAgB,oBAwF3B"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { Paywall, PaywallCatalog, PresentResult } from "./types";
|
|
2
|
+
import type { ProductRef, ProductStatus, PurchaseResult } from "../products/types";
|
|
3
|
+
/**
|
|
4
|
+
* Union of every `paywall.products[]` across the WHOLE catalog, deduplicated
|
|
5
|
+
* by content — the same identity notion `useProducts`' `refsKey` uses
|
|
6
|
+
* (`products/useProducts.ts:41-45`: keyed on ref CONTENT, not array
|
|
7
|
+
* identity), so this array is exactly as cheap to pass as a hand-written one:
|
|
8
|
+
* `useProducts` resolves it once and does not refetch on every render.
|
|
9
|
+
*
|
|
10
|
+
* Resolving the whole catalog's union ONCE at load — rather than re-keying
|
|
11
|
+
* `useProducts` per presented paywall — is the deliberate design decision:
|
|
12
|
+
* a paywall must render the instant the user taps upgrade (spec §6.1), and a
|
|
13
|
+
* store round-trip at that moment is exactly the latency this avoids. Cost
|
|
14
|
+
* accepted: an app resolves products for paywalls it may never show.
|
|
15
|
+
*/
|
|
16
|
+
export declare const collectProductRefs: (catalog: PaywallCatalog | null) => ProductRef[];
|
|
17
|
+
/** What `present()` should do, decided as a pure function of current state. */
|
|
18
|
+
export type PresentDecision = {
|
|
19
|
+
type: "start";
|
|
20
|
+
paywall: Paywall;
|
|
21
|
+
} | {
|
|
22
|
+
type: "immediate";
|
|
23
|
+
result: PresentResult;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* `present(placement)`'s edge-case decision, extracted so both documented
|
|
27
|
+
* edge cases are covered by an importable test rather than only inspection:
|
|
28
|
+
*
|
|
29
|
+
* - **Unknown placement** (absent from the catalog, or the catalog hasn't
|
|
30
|
+
* resolved yet — both look identical here: `catalog?.paywalls[placement]`
|
|
31
|
+
* is `undefined` either way) → resolves `"error"`, never throws. A missing
|
|
32
|
+
* placement must not crash a host app mid-flow.
|
|
33
|
+
* - **`present()` called while another paywall is already showing** → also
|
|
34
|
+
* resolves `"error"` immediately, leaving the in-progress presentation
|
|
35
|
+
* untouched. This SDK shows one paywall at a time. Silently replacing the
|
|
36
|
+
* active paywall would orphan its pending `present()` promise (never
|
|
37
|
+
* resolved — that caller hangs forever); queueing the new request would
|
|
38
|
+
* need its own cancellation/timeout story that nothing here asks for.
|
|
39
|
+
* Resolving the new call immediately applies the same "resolve, don't
|
|
40
|
+
* throw" contract as the unknown-placement case, consistently.
|
|
41
|
+
*/
|
|
42
|
+
export declare const resolvePresentDecision: (catalog: PaywallCatalog | null, activePlacement: string | null, placement: string) => PresentDecision;
|
|
43
|
+
/**
|
|
44
|
+
* `isReady` = catalog resolved AND products resolved — the one flag a caller
|
|
45
|
+
* needs to know "presenting now will not show a spinner".
|
|
46
|
+
*
|
|
47
|
+
* The `productRefs.length === 0` branch handles a real edge case:
|
|
48
|
+
* `useProducts` never leaves status `"idle"` when its ref set is empty
|
|
49
|
+
* (`products/useProducts.ts:49-54` bails out before ever calling the
|
|
50
|
+
* provider) — a catalog whose paywalls declare no products at all would
|
|
51
|
+
* otherwise report `isReady: false` forever, with nothing to actually wait
|
|
52
|
+
* for.
|
|
53
|
+
*/
|
|
54
|
+
export declare const computeIsReady: (catalog: PaywallCatalog | null, productRefs: ProductRef[], productsStatus: ProductStatus) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* What a purchase attempt resolved to during the current presentation, or
|
|
57
|
+
* `null` if none did. Only the two `PurchaseResult` statuses that describe a
|
|
58
|
+
* completed store interaction are tracked — `"pending"` (e.g. Ask-to-Buy) and
|
|
59
|
+
* `"error"` are not: they don't describe what happened to the STORE PURCHASE
|
|
60
|
+
* in a way that should override how the paywall itself reports closing (an
|
|
61
|
+
* `"error"` here would collide with `PresentResult`'s existing `"error"`,
|
|
62
|
+
* which means something structurally different — an unknown placement or a
|
|
63
|
+
* mistimed `present()` call, not a failed purchase attempt).
|
|
64
|
+
*/
|
|
65
|
+
export type PurchaseOutcomeDuringPresentation = "purchased" | "cancelled" | null;
|
|
66
|
+
/** Narrows a `PurchaseResult` to the subset `PurchaseOutcomeDuringPresentation` tracks. */
|
|
67
|
+
export declare const purchaseOutcomeFromResult: (result: PurchaseResult) => PurchaseOutcomeDuringPresentation;
|
|
68
|
+
/**
|
|
69
|
+
* Reconciles what the closing action REPORTED with what actually happened at
|
|
70
|
+
* the store during this presentation. `dismiss` (spec §4.5) always reports
|
|
71
|
+
* `{status:"dismissed"}` — it is the generic "this screen is done" signal and
|
|
72
|
+
* knows nothing about purchases, which is exactly the gap spec §4.6's own
|
|
73
|
+
* canonical authoring shape falls into: `{type:"purchase", onSuccess:
|
|
74
|
+
* [{type:"dismiss"}]}` closes a successful purchase through the SAME generic
|
|
75
|
+
* signal a user backing out would produce. So a bare `"dismissed"` is treated
|
|
76
|
+
* as "the caller didn't have anything more specific to say" and gets upgraded
|
|
77
|
+
* to whatever the store actually did (if anything). Any other reported
|
|
78
|
+
* status is assumed to mean something deliberate and passes through
|
|
79
|
+
* unchanged — this only fills in the generic default, never overrides a
|
|
80
|
+
* caller that already said something more specific.
|
|
81
|
+
*/
|
|
82
|
+
export declare const resolvePresentedOutcome: (reported: PresentResult, purchaseOutcome: PurchaseOutcomeDuringPresentation) => PresentResult;
|
|
83
|
+
/**
|
|
84
|
+
* Guards the purchase-outcome WRITE against a race that resetting the ref at
|
|
85
|
+
* `present()`'s start does not, by itself, prevent: paywall A is showing,
|
|
86
|
+
* `purchase()` is in flight; the user dismisses A (nothing tracked yet, so A
|
|
87
|
+
* correctly resolves `"dismissed"`); paywall B is presented, resetting the
|
|
88
|
+
* tracked outcome; THEN A's stale promise finally settles and would write
|
|
89
|
+
* `"purchased"` into what is now B's tracker — B later reports a purchase
|
|
90
|
+
* the user never made on it. `purchase()` must capture the current
|
|
91
|
+
* generation BEFORE awaiting the store and compare it against the current
|
|
92
|
+
* generation again after — only an unchanged generation means the write is
|
|
93
|
+
* still for the presentation that started it.
|
|
94
|
+
*
|
|
95
|
+
* A monotonic counter, not the placement string: the same placement can
|
|
96
|
+
* legitimately be presented twice in a row, and a string comparison would
|
|
97
|
+
* let a stale write from the FIRST of those two land in the second.
|
|
98
|
+
*/
|
|
99
|
+
export declare const shouldRecordPurchaseOutcome: (startedInGeneration: number, currentGeneration: number) => boolean;
|
|
100
|
+
//# sourceMappingURL=present.d.ts.map
|
|
@@ -0,0 +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;AAEnF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,cAAc,GAAG,IAAI,KAAG,UAAU,EAa7E,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,sBAAsB,GACjC,SAAS,cAAc,GAAG,IAAI,EAC9B,iBAAiB,MAAM,GAAG,IAAI,EAC9B,WAAW,MAAM,KAChB,eASF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,cAAc,GACzB,SAAS,cAAc,GAAG,IAAI,EAC9B,aAAa,UAAU,EAAE,EACzB,gBAAgB,aAAa,KAC5B,OAAuF,CAAC;AAE3F;;;;;;;;;GASG;AACH,MAAM,MAAM,iCAAiC,GAAG,WAAW,GAAG,WAAW,GAAG,IAAI,CAAC;AAEjF,2FAA2F;AAC3F,eAAO,MAAM,yBAAyB,GAAI,QAAQ,cAAc,KAAG,iCACoB,CAAC;AAExF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,aAAa,EACvB,iBAAiB,iCAAiC,KACjD,aAC0F,CAAC;AAE9F;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,2BAA2B,GACtC,qBAAqB,MAAM,EAC3B,mBAAmB,MAAM,KACxB,OAAoD,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldRecordPurchaseOutcome = exports.resolvePresentedOutcome = exports.purchaseOutcomeFromResult = exports.computeIsReady = exports.resolvePresentDecision = exports.collectProductRefs = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Union of every `paywall.products[]` across the WHOLE catalog, deduplicated
|
|
6
|
+
* by content — the same identity notion `useProducts`' `refsKey` uses
|
|
7
|
+
* (`products/useProducts.ts:41-45`: keyed on ref CONTENT, not array
|
|
8
|
+
* identity), so this array is exactly as cheap to pass as a hand-written one:
|
|
9
|
+
* `useProducts` resolves it once and does not refetch on every render.
|
|
10
|
+
*
|
|
11
|
+
* Resolving the whole catalog's union ONCE at load — rather than re-keying
|
|
12
|
+
* `useProducts` per presented paywall — is the deliberate design decision:
|
|
13
|
+
* a paywall must render the instant the user taps upgrade (spec §6.1), and a
|
|
14
|
+
* store round-trip at that moment is exactly the latency this avoids. Cost
|
|
15
|
+
* accepted: an app resolves products for paywalls it may never show.
|
|
16
|
+
*/
|
|
17
|
+
const collectProductRefs = (catalog) => {
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
if (!catalog)
|
|
20
|
+
return [];
|
|
21
|
+
const seen = new Set();
|
|
22
|
+
const refs = [];
|
|
23
|
+
for (const paywall of Object.values(catalog.paywalls)) {
|
|
24
|
+
for (const ref of paywall.products) {
|
|
25
|
+
const identity = `${ref.key}|${(_a = ref.ios) !== null && _a !== void 0 ? _a : ""}|${(_b = ref.android) !== null && _b !== void 0 ? _b : ""}|${(_c = ref.compareTo) !== null && _c !== void 0 ? _c : ""}`;
|
|
26
|
+
if (seen.has(identity))
|
|
27
|
+
continue;
|
|
28
|
+
seen.add(identity);
|
|
29
|
+
refs.push(ref);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return refs;
|
|
33
|
+
};
|
|
34
|
+
exports.collectProductRefs = collectProductRefs;
|
|
35
|
+
/**
|
|
36
|
+
* `present(placement)`'s edge-case decision, extracted so both documented
|
|
37
|
+
* edge cases are covered by an importable test rather than only inspection:
|
|
38
|
+
*
|
|
39
|
+
* - **Unknown placement** (absent from the catalog, or the catalog hasn't
|
|
40
|
+
* resolved yet — both look identical here: `catalog?.paywalls[placement]`
|
|
41
|
+
* is `undefined` either way) → resolves `"error"`, never throws. A missing
|
|
42
|
+
* placement must not crash a host app mid-flow.
|
|
43
|
+
* - **`present()` called while another paywall is already showing** → also
|
|
44
|
+
* resolves `"error"` immediately, leaving the in-progress presentation
|
|
45
|
+
* untouched. This SDK shows one paywall at a time. Silently replacing the
|
|
46
|
+
* active paywall would orphan its pending `present()` promise (never
|
|
47
|
+
* resolved — that caller hangs forever); queueing the new request would
|
|
48
|
+
* need its own cancellation/timeout story that nothing here asks for.
|
|
49
|
+
* Resolving the new call immediately applies the same "resolve, don't
|
|
50
|
+
* throw" contract as the unknown-placement case, consistently.
|
|
51
|
+
*/
|
|
52
|
+
const resolvePresentDecision = (catalog, activePlacement, placement) => {
|
|
53
|
+
if (activePlacement !== null) {
|
|
54
|
+
return { type: "immediate", result: { status: "error" } };
|
|
55
|
+
}
|
|
56
|
+
const paywall = catalog === null || catalog === void 0 ? void 0 : catalog.paywalls[placement];
|
|
57
|
+
if (!paywall) {
|
|
58
|
+
return { type: "immediate", result: { status: "error" } };
|
|
59
|
+
}
|
|
60
|
+
return { type: "start", paywall };
|
|
61
|
+
};
|
|
62
|
+
exports.resolvePresentDecision = resolvePresentDecision;
|
|
63
|
+
/**
|
|
64
|
+
* `isReady` = catalog resolved AND products resolved — the one flag a caller
|
|
65
|
+
* needs to know "presenting now will not show a spinner".
|
|
66
|
+
*
|
|
67
|
+
* The `productRefs.length === 0` branch handles a real edge case:
|
|
68
|
+
* `useProducts` never leaves status `"idle"` when its ref set is empty
|
|
69
|
+
* (`products/useProducts.ts:49-54` bails out before ever calling the
|
|
70
|
+
* provider) — a catalog whose paywalls declare no products at all would
|
|
71
|
+
* otherwise report `isReady: false` forever, with nothing to actually wait
|
|
72
|
+
* for.
|
|
73
|
+
*/
|
|
74
|
+
const computeIsReady = (catalog, productRefs, productsStatus) => catalog !== null && (productRefs.length === 0 || productsStatus === "ready");
|
|
75
|
+
exports.computeIsReady = computeIsReady;
|
|
76
|
+
/** Narrows a `PurchaseResult` to the subset `PurchaseOutcomeDuringPresentation` tracks. */
|
|
77
|
+
const purchaseOutcomeFromResult = (result) => result.status === "purchased" || result.status === "cancelled" ? result.status : null;
|
|
78
|
+
exports.purchaseOutcomeFromResult = purchaseOutcomeFromResult;
|
|
79
|
+
/**
|
|
80
|
+
* Reconciles what the closing action REPORTED with what actually happened at
|
|
81
|
+
* the store during this presentation. `dismiss` (spec §4.5) always reports
|
|
82
|
+
* `{status:"dismissed"}` — it is the generic "this screen is done" signal and
|
|
83
|
+
* knows nothing about purchases, which is exactly the gap spec §4.6's own
|
|
84
|
+
* canonical authoring shape falls into: `{type:"purchase", onSuccess:
|
|
85
|
+
* [{type:"dismiss"}]}` closes a successful purchase through the SAME generic
|
|
86
|
+
* signal a user backing out would produce. So a bare `"dismissed"` is treated
|
|
87
|
+
* as "the caller didn't have anything more specific to say" and gets upgraded
|
|
88
|
+
* to whatever the store actually did (if anything). Any other reported
|
|
89
|
+
* status is assumed to mean something deliberate and passes through
|
|
90
|
+
* unchanged — this only fills in the generic default, never overrides a
|
|
91
|
+
* caller that already said something more specific.
|
|
92
|
+
*/
|
|
93
|
+
const resolvePresentedOutcome = (reported, purchaseOutcome) => reported.status === "dismissed" && purchaseOutcome ? { status: purchaseOutcome } : reported;
|
|
94
|
+
exports.resolvePresentedOutcome = resolvePresentedOutcome;
|
|
95
|
+
/**
|
|
96
|
+
* Guards the purchase-outcome WRITE against a race that resetting the ref at
|
|
97
|
+
* `present()`'s start does not, by itself, prevent: paywall A is showing,
|
|
98
|
+
* `purchase()` is in flight; the user dismisses A (nothing tracked yet, so A
|
|
99
|
+
* correctly resolves `"dismissed"`); paywall B is presented, resetting the
|
|
100
|
+
* tracked outcome; THEN A's stale promise finally settles and would write
|
|
101
|
+
* `"purchased"` into what is now B's tracker — B later reports a purchase
|
|
102
|
+
* the user never made on it. `purchase()` must capture the current
|
|
103
|
+
* generation BEFORE awaiting the store and compare it against the current
|
|
104
|
+
* generation again after — only an unchanged generation means the write is
|
|
105
|
+
* still for the presentation that started it.
|
|
106
|
+
*
|
|
107
|
+
* A monotonic counter, not the placement string: the same placement can
|
|
108
|
+
* legitimately be presented twice in a row, and a string comparison would
|
|
109
|
+
* let a stale write from the FIRST of those two land in the second.
|
|
110
|
+
*/
|
|
111
|
+
const shouldRecordPurchaseOutcome = (startedInGeneration, currentGeneration) => startedInGeneration === currentGeneration;
|
|
112
|
+
exports.shouldRecordPurchaseOutcome = shouldRecordPurchaseOutcome;
|
|
113
|
+
//# sourceMappingURL=present.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present.js","sourceRoot":"","sources":["../../src/paywalls/present.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;GAYG;AACI,MAAM,kBAAkB,GAAG,CAAC,OAA8B,EAAgB,EAAE;;IACjF,IAAI,CAAC,OAAO;QAAE,OAAO,EA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E,OAAO,EAAE,CAAC;AACpC,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC;AAEF;;;;;;;;;;GAUG;AACI,MAAM,cAAc,GAAG,CAC5B,OAA8B,EAC9B,WAAyB,EACzB,cAA6B,EACpB,EAAE,CAAC,OAAO,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,cAAc,KAAK,OAAO,CAAC,CAAC;AAJ9E,QAAA,cAAc,kBAIgE;AAc3F,2FAA2F;AACpF,MAAM,yBAAyB,GAAG,CAAC,MAAsB,EAAqC,EAAE,CACrG,MAAM,CAAC,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAD3E,QAAA,yBAAyB,6BACkD;AAExF;;;;;;;;;;;;;GAaG;AACI,MAAM,uBAAuB,GAAG,CACrC,QAAuB,EACvB,eAAkD,EACnC,EAAE,CACjB,QAAQ,CAAC,MAAM,KAAK,WAAW,IAAI,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAJjF,QAAA,uBAAuB,2BAI0D;AAE9F;;;;;;;;;;;;;;;GAeG;AACI,MAAM,2BAA2B,GAAG,CACzC,mBAA2B,EAC3B,iBAAyB,EAChB,EAAE,CAAC,mBAAmB,KAAK,iBAAiB,CAAC;AAH3C,QAAA,2BAA2B,+BAGgB"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Response types for `OnboardingStudioClient.getPaywalls()` (spec §6.1). The
|
|
3
|
+
* endpoint returns every placement for the project/audience/locale in one
|
|
4
|
+
* payload — a paywall must render the instant the user taps upgrade, and a
|
|
5
|
+
* network round-trip at that moment is a conversion bug, so there is no
|
|
6
|
+
* per-placement fetch in the common path (see `PaywallOptions.placement`).
|
|
7
|
+
*/
|
|
8
|
+
/** A single studio-authored paywall, keyed by `placement` in `PaywallCatalog.paywalls`. */
|
|
9
|
+
export type Paywall = {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
placement: string;
|
|
13
|
+
/** UIElement[] — parsed by the UI adapter (Task 7's `ScreenElementsSchema`), not here. */
|
|
14
|
+
elements: unknown[];
|
|
15
|
+
products: Array<{
|
|
16
|
+
key: string;
|
|
17
|
+
ios?: string;
|
|
18
|
+
android?: string;
|
|
19
|
+
compareTo?: string;
|
|
20
|
+
}>;
|
|
21
|
+
configuration: Record<string, unknown> | null;
|
|
22
|
+
};
|
|
23
|
+
/** Full response body of `GET get-paywalls`. */
|
|
24
|
+
export type PaywallCatalog = {
|
|
25
|
+
metadata: {
|
|
26
|
+
audienceId: number | null;
|
|
27
|
+
audienceName: string | null;
|
|
28
|
+
locale: string | null;
|
|
29
|
+
draft: boolean;
|
|
30
|
+
};
|
|
31
|
+
/** Keyed by placement, not by paywall id. */
|
|
32
|
+
paywalls: Record<string, Paywall>;
|
|
33
|
+
fonts: Record<string, unknown> | null;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Options for `OnboardingStudioClient.getPaywalls()`.
|
|
37
|
+
*
|
|
38
|
+
* `placement` narrows the response to a single paywall — the exception, not
|
|
39
|
+
* the default. Omit it to get every placement in one round-trip, which is
|
|
40
|
+
* what lets a paywall render instantly at buy-tap time (see the module doc
|
|
41
|
+
* above).
|
|
42
|
+
*/
|
|
43
|
+
export type PaywallOptions = {
|
|
44
|
+
locale?: string;
|
|
45
|
+
placement?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Response headers for `get-paywalls`. Deliberately **not** the onboarding
|
|
49
|
+
* trio (`ONBS-Onboarding-Id` / `ONBS-Audience-Id` / `ONBS-Onboarding-Name`) —
|
|
50
|
+
* the paywall endpoint has no single onboarding/audience-name concept and
|
|
51
|
+
* instead reports which paywall ids came back.
|
|
52
|
+
*/
|
|
53
|
+
export interface GetPaywallsResponseHeaders {
|
|
54
|
+
"ONBS-Audience-Id": string | null;
|
|
55
|
+
"ONBS-Paywall-Ids": string | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolved outcome of a `usePaywall().present(placement)` call (spec §7).
|
|
59
|
+
* Closed union, not the open-ended `ScreenHost.CompleteOutcome` — a
|
|
60
|
+
* presentation ends in exactly one of these four ways, and `present()`'s
|
|
61
|
+
* caller (typically an `await`) should be able to switch over it exhaustively.
|
|
62
|
+
*
|
|
63
|
+
* `"error"` covers both: (a) `placement` is absent from the catalog (or the
|
|
64
|
+
* catalog hasn't resolved yet), and (b) `present()` was called while another
|
|
65
|
+
* paywall is already being presented. Both resolve rather than throw — a
|
|
66
|
+
* missing placement or a mistimed call must not crash a host app mid-flow.
|
|
67
|
+
* See `resolvePresentDecision` in `present.ts` for the exact decision logic.
|
|
68
|
+
*
|
|
69
|
+
* `"purchased"` / `"cancelled"` are NOT produced by any ButtonAction directly
|
|
70
|
+
* — `dismiss` (the only in-content closing action) always reports
|
|
71
|
+
* `{status:"dismissed"}`, on purpose, since it doesn't know anything about
|
|
72
|
+
* purchase state. `PaywallProvider` instead tracks what the store actually
|
|
73
|
+
* did during the active presentation (`purchaseOutcomeFromResult` in
|
|
74
|
+
* `present.ts`) and `resolvePresentedOutcome` upgrades a bare `"dismissed"`
|
|
75
|
+
* to whichever of these occurred, if any — so spec §4.6's canonical authoring
|
|
76
|
+
* shape (`{type:"purchase", onSuccess:[{type:"dismiss"}]}`) resolves
|
|
77
|
+
* `"purchased"` even though `dismiss` itself never says so.
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* How a presentation ENDED — not what the user is entitled to.
|
|
81
|
+
*
|
|
82
|
+
* `"purchased"` means a purchase succeeded while this paywall was showing, and
|
|
83
|
+
* is the honest report in the common case. But it is deliberately not an
|
|
84
|
+
* entitlement signal: a purchase followed by a render crash resolves `"error"`
|
|
85
|
+
* (the boundary settles the promise so the user is not trapped), so a host that
|
|
86
|
+
* keys entitlement off `status === "purchased"` would under-grant a user who
|
|
87
|
+
* genuinely paid.
|
|
88
|
+
*
|
|
89
|
+
* Entitlement belongs to the store — read it from the `ProductProvider` /
|
|
90
|
+
* billing SDK, and use this only to decide what the UI does next.
|
|
91
|
+
*/
|
|
92
|
+
export type PresentResult = {
|
|
93
|
+
status: "purchased" | "dismissed" | "cancelled" | "error";
|
|
94
|
+
};
|
|
95
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paywalls/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,2FAA2F;AAC3F,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,0FAA0F;IAC1F,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC/C,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QACtB,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IACF,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACvC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACzC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,CAAC;CAC3D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Response types for `OnboardingStudioClient.getPaywalls()` (spec §6.1). The
|
|
4
|
+
* endpoint returns every placement for the project/audience/locale in one
|
|
5
|
+
* payload — a paywall must render the instant the user taps upgrade, and a
|
|
6
|
+
* network round-trip at that moment is a conversion bug, so there is no
|
|
7
|
+
* per-placement fetch in the common path (see `PaywallOptions.placement`).
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/paywalls/types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PaywallCatalog, PresentResult } from "./types";
|
|
2
|
+
export type UsePaywallResult = {
|
|
3
|
+
/**
|
|
4
|
+
* Present a paywall by placement. Never fetches — the catalog and its
|
|
5
|
+
* products are already resolved (or resolving) from `PaywallProvider`
|
|
6
|
+
* mount, which is the whole point: a paywall must render the instant the
|
|
7
|
+
* user taps upgrade.
|
|
8
|
+
*
|
|
9
|
+
* Resolves `{ status: "error" }` — never throws — when `placement` is
|
|
10
|
+
* absent from the catalog, or when another paywall is already being
|
|
11
|
+
* presented. See `resolvePresentDecision` in `present.ts`.
|
|
12
|
+
*/
|
|
13
|
+
present: (placement: string) => Promise<PresentResult>;
|
|
14
|
+
/**
|
|
15
|
+
* `true` once BOTH the catalog and its products have resolved — the one
|
|
16
|
+
* flag meaning "calling `present()` now will not show a spinner".
|
|
17
|
+
*/
|
|
18
|
+
isReady: boolean;
|
|
19
|
+
/** The full resolved catalog (every placement), or `null` before it loads. */
|
|
20
|
+
catalog: PaywallCatalog | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Read the paywall runtime published by an ancestor `PaywallProvider`.
|
|
24
|
+
* Outside one, returns inert defaults (`present` resolves `"error"`,
|
|
25
|
+
* `isReady: false`, `catalog: null`) rather than throwing — mirrors how
|
|
26
|
+
* `useProductRuntime()` degrades to `null` with no ancestor.
|
|
27
|
+
*/
|
|
28
|
+
export declare const usePaywall: () => UsePaywallResult;
|
|
29
|
+
//# sourceMappingURL=usePaywall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePaywall.d.ts","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACvD;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,gBAG7B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePaywall = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const PaywallProvider_1 = require("./PaywallProvider");
|
|
6
|
+
/**
|
|
7
|
+
* Read the paywall runtime published by an ancestor `PaywallProvider`.
|
|
8
|
+
* Outside one, returns inert defaults (`present` resolves `"error"`,
|
|
9
|
+
* `isReady: false`, `catalog: null`) rather than throwing — mirrors how
|
|
10
|
+
* `useProductRuntime()` degrades to `null` with no ancestor.
|
|
11
|
+
*/
|
|
12
|
+
const usePaywall = () => {
|
|
13
|
+
const { present, isReady, catalog } = (0, react_1.useContext)(PaywallProvider_1.PaywallContext);
|
|
14
|
+
return { present, isReady, catalog };
|
|
15
|
+
};
|
|
16
|
+
exports.usePaywall = usePaywall;
|
|
17
|
+
//# sourceMappingURL=usePaywall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePaywall.js","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,uDAAmD;AAwBnD;;;;;GAKG;AACI,MAAM,UAAU,GAAG,GAAqB,EAAE;IAC/C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAA,kBAAU,EAAC,gCAAc,CAAC,CAAC;IACjE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AACvC,CAAC,CAAC;AAHW,QAAA,UAAU,cAGrB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ProductRuntime } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Publishes one `ProductRuntime` above both `PaywallProvider` and
|
|
4
|
+
* `OnboardingProvider`, so a `PaywallProvider` mounted around an
|
|
5
|
+
* `OnboardingProvider` (Phase 5's `presentPaywall` arrangement) gives them one
|
|
6
|
+
* shared product catalog instead of each mounting its own `useProducts` — one
|
|
7
|
+
* store round-trip, one `purchasing` flag, for both.
|
|
8
|
+
*
|
|
9
|
+
* `null` by default: nothing above publishes a runtime, which is the normal
|
|
10
|
+
* case for an app that mounts only `OnboardingProvider`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ProductRuntimeContext: import("react").Context<ProductRuntime | null>;
|
|
13
|
+
/** The ancestor `ProductRuntime`, or `null` when no provider publishes one. */
|
|
14
|
+
export declare const useProductRuntime: () => ProductRuntime | null;
|
|
15
|
+
//# sourceMappingURL=ProductRuntimeContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductRuntimeContext.d.ts","sourceRoot":"","sources":["../../src/products/ProductRuntimeContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,gDAA6C,CAAC;AAEhF,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,QAAO,cAAc,GAAG,IAAyC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useProductRuntime = exports.ProductRuntimeContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
/**
|
|
6
|
+
* Publishes one `ProductRuntime` above both `PaywallProvider` and
|
|
7
|
+
* `OnboardingProvider`, so a `PaywallProvider` mounted around an
|
|
8
|
+
* `OnboardingProvider` (Phase 5's `presentPaywall` arrangement) gives them one
|
|
9
|
+
* shared product catalog instead of each mounting its own `useProducts` — one
|
|
10
|
+
* store round-trip, one `purchasing` flag, for both.
|
|
11
|
+
*
|
|
12
|
+
* `null` by default: nothing above publishes a runtime, which is the normal
|
|
13
|
+
* case for an app that mounts only `OnboardingProvider`.
|
|
14
|
+
*/
|
|
15
|
+
exports.ProductRuntimeContext = (0, react_1.createContext)(null);
|
|
16
|
+
/** The ancestor `ProductRuntime`, or `null` when no provider publishes one. */
|
|
17
|
+
const useProductRuntime = () => (0, react_1.useContext)(exports.ProductRuntimeContext);
|
|
18
|
+
exports.useProductRuntime = useProductRuntime;
|
|
19
|
+
//# sourceMappingURL=ProductRuntimeContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductRuntimeContext.js","sourceRoot":"","sources":["../../src/products/ProductRuntimeContext.tsx"],"names":[],"mappings":";;;AAAA,iCAAkD;AAGlD;;;;;;;;;GASG;AACU,QAAA,qBAAqB,GAAG,IAAA,qBAAa,EAAwB,IAAI,CAAC,CAAC;AAEhF,+EAA+E;AACxE,MAAM,iBAAiB,GAAG,GAA0B,EAAE,CAAC,IAAA,kBAAU,EAAC,6BAAqB,CAAC,CAAC;AAAnF,QAAA,iBAAiB,qBAAkE"}
|
package/dist/products/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { parseIsoDuration } from "./duration";
|
|
|
3
3
|
export { formatCurrency, deriveProductFields, deriveAll } from "./derive";
|
|
4
4
|
export { productVariables } from "./toVariables";
|
|
5
5
|
export { useProducts } from "./useProducts";
|
|
6
|
+
export { ProductRuntimeContext, useProductRuntime } from "./ProductRuntimeContext";
|
|
6
7
|
export { stubProductProvider } from "./adapters/stub";
|
|
7
8
|
export { revenueCatProductProvider } from "./adapters/revenueCat";
|
|
8
9
|
export { expoIapProductProvider } from "./adapters/expoIap";
|
|
@@ -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,M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