@rocapine/react-native-onboarding 1.71.0 → 1.73.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/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/paywalls/PaywallProvider.d.ts +44 -2
- package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
- package/dist/paywalls/PaywallProvider.js +19 -5
- package/dist/paywalls/PaywallProvider.js.map +1 -1
- package/dist/paywalls/customScreens.d.ts +83 -0
- package/dist/paywalls/customScreens.d.ts.map +1 -0
- package/dist/paywalls/customScreens.js +3 -0
- package/dist/paywalls/customScreens.js.map +1 -0
- package/dist/paywalls/types.d.ts +64 -1
- package/dist/paywalls/types.d.ts.map +1 -1
- package/dist/paywalls/usePaywall.d.ts +14 -0
- package/dist/paywalls/usePaywall.d.ts.map +1 -1
- package/dist/paywalls/usePaywall.js +10 -2
- package/dist/paywalls/usePaywall.js.map +1 -1
- package/dist/steps/Paywall/types.d.ts +63 -0
- package/dist/steps/Paywall/types.d.ts.map +1 -0
- package/dist/steps/Paywall/types.js +29 -0
- package/dist/steps/Paywall/types.js.map +1 -0
- package/dist/steps/types.d.ts +2 -1
- package/dist/steps/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +11 -0
- package/src/paywalls/PaywallProvider.tsx +64 -3
- package/src/paywalls/customScreens.ts +82 -0
- package/src/paywalls/types.ts +63 -1
- package/src/paywalls/usePaywall.ts +24 -2
- package/src/steps/Paywall/types.ts +29 -0
- package/src/steps/types.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from "./onboarding-example";
|
|
|
4
4
|
export { getOnboardingCacheKey, DEFAULT_ONBOARDING_CACHE_KEY, } from "./infra/queries/cacheKey";
|
|
5
5
|
export type { ButtonAction, CustomButtonAction, SetVariableButtonAction, ComposableVariableEntry, ComposableVariableKind, WheelPickerElementProps, WheelPickerItem, WheelPickerRange, RichTextElementProps, ProgressiveBlurImageElementProps, BlurMask, LinearBlurMask, RadialBlurMask, BlurMaskStop, BlurAppear, ProgressIndicatorElementProps, ProgressEasing, AnimationEasing, SpringConfig, EnteringPreset, ExitingPreset, LayoutPreset, EffectPreset, EnteringAnimation, ExitingAnimation, LayoutAnimation, ElementEffect, ElementAnimation, ElementTransform, } from "./steps/ComposableScreen/types";
|
|
6
6
|
export { ButtonActionSchema, CustomButtonActionSchema, SetVariableButtonActionSchema, WheelPickerElementPropsSchema, generateWheelPickerRangeItems, resolveWheelPickerItems, } from "./steps/ComposableScreen/types";
|
|
7
|
+
export type { PaywallStepType } from "./steps/Paywall/types";
|
|
8
|
+
export { PaywallStepTypeSchema, PaywallStepPayloadSchema } from "./steps/Paywall/types";
|
|
7
9
|
export { collectUnknownElementKeys, collectUnknownKeysInSteps, formatUnknownElementKeys, } from "./screens/unknownKeys";
|
|
8
10
|
export type { UnknownElementKey } from "./screens/unknownKeys";
|
|
9
11
|
export * from "./infra";
|
|
@@ -16,8 +18,9 @@ export type { Condition } from "./evaluateCondition";
|
|
|
16
18
|
export type { LeafCondition, ConditionGroup, ConditionValue, ConditionOperator, Branch, NextStep, } from "./steps/common.types";
|
|
17
19
|
export { BaseStepTypeSchema, LeafConditionSchema, ConditionGroupSchema, BranchSchema, NextStepSchema, ConditionOperatorSchema, ConditionValueSchema, UNARY_CONDITION_OPERATORS, isUnaryConditionOperator, ONBOARDING_END_STEP_ID, } from "./steps/common.types";
|
|
18
20
|
export * from "./products";
|
|
19
|
-
export type { Paywall, PaywallCatalog, PaywallOptions, GetPaywallsResponseHeaders, PresentResult, PresentErrorReason, } from "./paywalls/types";
|
|
21
|
+
export type { Paywall, PaywallCustomPayload, PaywallCatalog, PaywallOptions, GetPaywallsResponseHeaders, PresentResult, PresentErrorReason, } from "./paywalls/types";
|
|
20
22
|
export { PaywallProvider, usePaywallHost } from "./paywalls/PaywallProvider";
|
|
23
|
+
export type { CustomPaywallScreenProps, CustomPaywallScreens } from "./paywalls/customScreens";
|
|
21
24
|
export type { PaywallContextValue } from "./paywalls/PaywallProvider";
|
|
22
25
|
export { usePaywall } from "./paywalls/usePaywall";
|
|
23
26
|
export type { CatalogStatus } from "./paywalls/present";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,gCAAgC,EAChC,QAAQ,EACR,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,cAAc,SAAS,CAAC;AAExB,YAAY,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxF,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EACV,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,MAAM,EACN,QAAQ,GACT,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,cAAc,YAAY,CAAC;AAE3B,YAAY,EACV,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,gCAAgC,EAChC,QAAQ,EACR,cAAc,EACd,cAAc,EACd,YAAY,EACZ,UAAU,EACV,6BAA6B,EAC7B,cAAc,EACd,eAAe,EACf,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GAC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E,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAI7E,YAAY,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC/F,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.usePaywall = exports.usePaywallHost = exports.PaywallProvider = exports.ONBOARDING_END_STEP_ID = exports.isUnaryConditionOperator = exports.UNARY_CONDITION_OPERATORS = exports.ConditionValueSchema = exports.ConditionOperatorSchema = exports.NextStepSchema = exports.BranchSchema = exports.ConditionGroupSchema = exports.LeafConditionSchema = exports.BaseStepTypeSchema = exports.isConditionGroup = exports.evaluateLeaf = exports.evaluateCondition = exports.resolveStartStepNumber = exports.resolveNextStepNumber = exports.expoRouterAdapter = exports.formatUnknownElementKeys = exports.collectUnknownKeysInSteps = exports.collectUnknownElementKeys = exports.resolveWheelPickerItems = exports.generateWheelPickerRangeItems = exports.WheelPickerElementPropsSchema = exports.SetVariableButtonActionSchema = exports.CustomButtonActionSchema = exports.ButtonActionSchema = exports.DEFAULT_ONBOARDING_CACHE_KEY = exports.getOnboardingCacheKey = exports.OnboardingStudioClient = void 0;
|
|
17
|
+
exports.usePaywall = exports.usePaywallHost = exports.PaywallProvider = exports.ONBOARDING_END_STEP_ID = exports.isUnaryConditionOperator = exports.UNARY_CONDITION_OPERATORS = exports.ConditionValueSchema = exports.ConditionOperatorSchema = exports.NextStepSchema = exports.BranchSchema = exports.ConditionGroupSchema = exports.LeafConditionSchema = exports.BaseStepTypeSchema = exports.isConditionGroup = exports.evaluateLeaf = exports.evaluateCondition = exports.resolveStartStepNumber = exports.resolveNextStepNumber = exports.expoRouterAdapter = exports.formatUnknownElementKeys = exports.collectUnknownKeysInSteps = exports.collectUnknownElementKeys = exports.PaywallStepPayloadSchema = exports.PaywallStepTypeSchema = exports.resolveWheelPickerItems = exports.generateWheelPickerRangeItems = exports.WheelPickerElementPropsSchema = exports.SetVariableButtonActionSchema = exports.CustomButtonActionSchema = exports.ButtonActionSchema = exports.DEFAULT_ONBOARDING_CACHE_KEY = exports.getOnboardingCacheKey = exports.OnboardingStudioClient = void 0;
|
|
18
18
|
// Core client and types
|
|
19
19
|
var OnboardingStudioClient_1 = require("./OnboardingStudioClient");
|
|
20
20
|
Object.defineProperty(exports, "OnboardingStudioClient", { enumerable: true, get: function () { return OnboardingStudioClient_1.OnboardingStudioClient; } });
|
|
@@ -31,6 +31,9 @@ Object.defineProperty(exports, "SetVariableButtonActionSchema", { enumerable: tr
|
|
|
31
31
|
Object.defineProperty(exports, "WheelPickerElementPropsSchema", { enumerable: true, get: function () { return types_1.WheelPickerElementPropsSchema; } });
|
|
32
32
|
Object.defineProperty(exports, "generateWheelPickerRangeItems", { enumerable: true, get: function () { return types_1.generateWheelPickerRangeItems; } });
|
|
33
33
|
Object.defineProperty(exports, "resolveWheelPickerItems", { enumerable: true, get: function () { return types_1.resolveWheelPickerItems; } });
|
|
34
|
+
var types_2 = require("./steps/Paywall/types");
|
|
35
|
+
Object.defineProperty(exports, "PaywallStepTypeSchema", { enumerable: true, get: function () { return types_2.PaywallStepTypeSchema; } });
|
|
36
|
+
Object.defineProperty(exports, "PaywallStepPayloadSchema", { enumerable: true, get: function () { return types_2.PaywallStepPayloadSchema; } });
|
|
34
37
|
// Payload diagnostics — non-fatal detection of keys placed at an element's top
|
|
35
38
|
// level that the schema silently drops (e.g. `animation` outside `props`).
|
|
36
39
|
var unknownKeys_1 = require("./screens/unknownKeys");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wBAAwB;AACxB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,0CAAwB;AACxB,uDAAqC;AACrC,8EAA8E;AAC9E,qDAGkC;AAFhC,iHAAA,qBAAqB,OAAA;AACrB,wHAAA,4BAA4B,OAAA;AAkC9B,wDAOwC;AANtC,2GAAA,kBAAkB,OAAA;AAClB,iHAAA,wBAAwB,OAAA;AACxB,sHAAA,6BAA6B,OAAA;AAC7B,sHAAA,6BAA6B,OAAA;AAC7B,sHAAA,6BAA6B,OAAA;AAC7B,gHAAA,uBAAuB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wBAAwB;AACxB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,0CAAwB;AACxB,uDAAqC;AACrC,8EAA8E;AAC9E,qDAGkC;AAFhC,iHAAA,qBAAqB,OAAA;AACrB,wHAAA,4BAA4B,OAAA;AAkC9B,wDAOwC;AANtC,2GAAA,kBAAkB,OAAA;AAClB,iHAAA,wBAAwB,OAAA;AACxB,sHAAA,6BAA6B,OAAA;AAC7B,sHAAA,6BAA6B,OAAA;AAC7B,sHAAA,6BAA6B,OAAA;AAC7B,gHAAA,uBAAuB,OAAA;AAKzB,+CAAwF;AAA/E,8GAAA,qBAAqB,OAAA;AAAE,iHAAA,wBAAwB,OAAA;AACxD,+EAA+E;AAC/E,2EAA2E;AAC3E,qDAI+B;AAH7B,wHAAA,yBAAyB,OAAA;AACzB,wHAAA,yBAAyB,OAAA;AACzB,uHAAA,wBAAwB,OAAA;AAG1B,sBAAsB;AACtB,0CAAwB;AAGxB,0EAAyE;AAAhE,sHAAA,iBAAiB,OAAA;AAC1B,YAAY;AACZ,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,yDAAwF;AAA/E,sHAAA,iBAAiB,OAAA;AAAE,iHAAA,YAAY,OAAA;AAAE,qHAAA,gBAAgB,OAAA;AAU1D,qDAW8B;AAV5B,kHAAA,kBAAkB,OAAA;AAClB,mHAAA,mBAAmB,OAAA;AACnB,oHAAA,oBAAoB,OAAA;AACpB,4GAAA,YAAY,OAAA;AACZ,8GAAA,cAAc,OAAA;AACd,uHAAA,uBAAuB,OAAA;AACvB,oHAAA,oBAAoB,OAAA;AACpB,yHAAA,yBAAyB,OAAA;AACzB,wHAAA,wBAAwB,OAAA;AACxB,sHAAA,sBAAsB,OAAA;AAExB,oEAAoE;AACpE,6CAA2B;AAe3B,8DAA6E;AAApE,kHAAA,eAAe,OAAA;AAAE,iHAAA,cAAc,OAAA;AAMxC,oDAAmD;AAA1C,wGAAA,UAAU,OAAA"}
|
|
@@ -3,6 +3,7 @@ import { Paywall, PaywallCatalog, PresentResult } from "./types";
|
|
|
3
3
|
import { type CatalogStatus } from "./present";
|
|
4
4
|
import { ProductProvider, ProductStatus } from "../products/types";
|
|
5
5
|
import type { CustomActions } from "../infra/provider/OnboardingProvider";
|
|
6
|
+
import type { CustomPaywallScreens } from "./customScreens";
|
|
6
7
|
/**
|
|
7
8
|
* Everything a paywall consumer or a paywall HOST needs. Deliberately one
|
|
8
9
|
* context carrying both, mirroring how `OnboardingProgressContext` bundles
|
|
@@ -21,6 +22,22 @@ export type PaywallContextValue = {
|
|
|
21
22
|
* does not yet mean an absent one.
|
|
22
23
|
*/
|
|
23
24
|
catalogStatus: CatalogStatus;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a real `PaywallProvider` is above this consumer.
|
|
27
|
+
*
|
|
28
|
+
* Exists because `EMPTY_PAYWALL_CONTEXT` reports `catalogStatus: "loading"` —
|
|
29
|
+
* honest for `present()`'s contract (nothing is loading and nothing will
|
|
30
|
+
* arrive, so `"error"` is the answer) but INDISTINGUISHABLE from a genuine
|
|
31
|
+
* first load. A consumer that renders a spinner while loading would spin
|
|
32
|
+
* forever under no provider, and the inline `Paywall` onboarding step
|
|
33
|
+
* (`UI/Pages/Paywall/Renderer.tsx` in the UI package) is exactly that
|
|
34
|
+
* consumer.
|
|
35
|
+
*
|
|
36
|
+
* Deliberately NOT a new `CatalogStatus` member: widening that union breaks
|
|
37
|
+
* every host switching exhaustively over it, and "no provider" is not a
|
|
38
|
+
* catalog state.
|
|
39
|
+
*/
|
|
40
|
+
isProviderMounted: boolean;
|
|
24
41
|
/**
|
|
25
42
|
* What the store products are doing. The other half of `isReady`: a host that
|
|
26
43
|
* sees `catalogStatus: "ready"` but `isReady: false` can tell it is waiting on
|
|
@@ -46,6 +63,17 @@ export type PaywallContextValue = {
|
|
|
46
63
|
acknowledgePresentation: () => void;
|
|
47
64
|
/** Forwarded into the presented paywall's `ScreenHost.customActions`. */
|
|
48
65
|
customActions: CustomActions;
|
|
66
|
+
/**
|
|
67
|
+
* Host-registered screens for `renderMode: "custom"` paywalls, keyed by
|
|
68
|
+
* `customScreenId`.
|
|
69
|
+
*
|
|
70
|
+
* Published HERE — rather than only on `PaywallHost`, where it started in
|
|
71
|
+
* 1.72.0 — because there are now two renderers: that Modal, and the inline
|
|
72
|
+
* `Paywall` onboarding step, which never goes through `PaywallHost` at all.
|
|
73
|
+
* One registration has to serve both, and this is the provider every host
|
|
74
|
+
* already mounts. `PaywallHost`'s own prop still wins for that host.
|
|
75
|
+
*/
|
|
76
|
+
customScreens: CustomPaywallScreens;
|
|
49
77
|
};
|
|
50
78
|
export declare const PaywallContext: import("react").Context<PaywallContextValue>;
|
|
51
79
|
/**
|
|
@@ -55,7 +83,7 @@ export declare const PaywallContext: import("react").Context<PaywallContextValue
|
|
|
55
83
|
* internals it has no reason to touch (which paywall is active, how to
|
|
56
84
|
* resolve it).
|
|
57
85
|
*/
|
|
58
|
-
export declare const usePaywallHost: () => Pick<PaywallContextValue, "activePaywall" | "complete" | "acknowledgePresentation" | "customActions">;
|
|
86
|
+
export declare const usePaywallHost: () => Pick<PaywallContextValue, "activePaywall" | "complete" | "acknowledgePresentation" | "customActions" | "customScreens">;
|
|
59
87
|
interface PaywallProviderProps {
|
|
60
88
|
children: React.ReactNode;
|
|
61
89
|
client: OnboardingStudioClient;
|
|
@@ -88,6 +116,20 @@ interface PaywallProviderProps {
|
|
|
88
116
|
stripeProductProvider?: ProductProvider;
|
|
89
117
|
/** Handlers for `{ type: "custom" }` ButtonActions inside a paywall's elements. */
|
|
90
118
|
customActions?: CustomActions;
|
|
119
|
+
/**
|
|
120
|
+
* Screens for `renderMode: "custom"` paywalls, keyed by the
|
|
121
|
+
* `customScreenId` authored in the studio.
|
|
122
|
+
*
|
|
123
|
+
* THE canonical place to register them: both renderers read from here —
|
|
124
|
+
* `PaywallHost`'s Modal and the inline `Paywall` onboarding step, which never
|
|
125
|
+
* goes through `PaywallHost`. `PaywallHost` still accepts its own
|
|
126
|
+
* `customScreens` prop (1.72.0's API), and that prop overrides this for that
|
|
127
|
+
* host; prefer this one.
|
|
128
|
+
*
|
|
129
|
+
* MUST be referentially stable (module scope, or `useMemo`) — it lands in the
|
|
130
|
+
* context value and in consumers' dependency arrays.
|
|
131
|
+
*/
|
|
132
|
+
customScreens?: CustomPaywallScreens;
|
|
91
133
|
/**
|
|
92
134
|
* How long to wait for the host to confirm a paywall actually appeared
|
|
93
135
|
* before abandoning the presentation and resolving
|
|
@@ -111,6 +153,6 @@ interface PaywallProviderProps {
|
|
|
111
153
|
* </PaywallProvider>
|
|
112
154
|
* ```
|
|
113
155
|
*/
|
|
114
|
-
export declare const PaywallProvider: ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, presentAckTimeoutMs, }: PaywallProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
156
|
+
export declare const PaywallProvider: ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, customScreens, presentAckTimeoutMs, }: PaywallProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
115
157
|
export {};
|
|
116
158
|
//# sourceMappingURL=PaywallProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaywallProvider.d.ts","sourceRoot":"","sources":["../../src/paywalls/PaywallProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAKL,KAAK,aAAa,EAOnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"PaywallProvider.d.ts","sourceRoot":"","sources":["../../src/paywalls/PaywallProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAKL,KAAK,aAAa,EAOnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AA8B5D;;;;;;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,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B,oBAAoB,4CAiBtB,CAAC"}
|
|
@@ -28,6 +28,11 @@ const paywallQueryClient = new react_query_1.QueryClient({
|
|
|
28
28
|
// `ScreenHost`), so an unstable identity would defeat memoization the same
|
|
29
29
|
// way `EMPTY_CUSTOM_ACTIONS` in `OnboardingProvider.tsx` documents.
|
|
30
30
|
const EMPTY_CUSTOM_ACTIONS = Object.freeze({});
|
|
31
|
+
// Frozen at module scope for the same reason as EMPTY_CUSTOM_ACTIONS above: it
|
|
32
|
+
// sits in the published context value, and an unstable identity would defeat
|
|
33
|
+
// memoization in every consumer that lists it as a dependency (the inline
|
|
34
|
+
// `Paywall` step's decision memo does).
|
|
35
|
+
const EMPTY_CUSTOM_SCREENS = Object.freeze({});
|
|
31
36
|
const EMPTY_PAYWALL_CONTEXT = {
|
|
32
37
|
// No provider above: there is no catalog at all, which is the same answer
|
|
33
38
|
// `resolvePresentDecision` gives for an unresolved one.
|
|
@@ -36,11 +41,15 @@ const EMPTY_PAYWALL_CONTEXT = {
|
|
|
36
41
|
catalog: null,
|
|
37
42
|
// No provider above: nothing is loading and nothing will arrive.
|
|
38
43
|
catalogStatus: "loading",
|
|
44
|
+
// The one value that distinguishes this object from a real provider's — see
|
|
45
|
+
// the field's doc above for why `catalogStatus` cannot do that job.
|
|
46
|
+
isProviderMounted: false,
|
|
39
47
|
productsStatus: "idle",
|
|
40
48
|
activePaywall: null,
|
|
41
49
|
complete: () => { },
|
|
42
50
|
acknowledgePresentation: () => { },
|
|
43
51
|
customActions: EMPTY_CUSTOM_ACTIONS,
|
|
52
|
+
customScreens: EMPTY_CUSTOM_SCREENS,
|
|
44
53
|
};
|
|
45
54
|
/**
|
|
46
55
|
* How long a presentation may go unacknowledged by the host before it is
|
|
@@ -58,11 +67,11 @@ exports.PaywallContext = (0, react_1.createContext)(EMPTY_PAYWALL_CONTEXT);
|
|
|
58
67
|
* resolve it).
|
|
59
68
|
*/
|
|
60
69
|
const usePaywallHost = () => {
|
|
61
|
-
const { activePaywall, complete, acknowledgePresentation, customActions } = (0, react_1.useContext)(exports.PaywallContext);
|
|
62
|
-
return { activePaywall, complete, acknowledgePresentation, customActions };
|
|
70
|
+
const { activePaywall, complete, acknowledgePresentation, customActions, customScreens } = (0, react_1.useContext)(exports.PaywallContext);
|
|
71
|
+
return { activePaywall, complete, acknowledgePresentation, customActions, customScreens };
|
|
63
72
|
};
|
|
64
73
|
exports.usePaywallHost = usePaywallHost;
|
|
65
|
-
const PaywallProviderInner = ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, presentAckTimeoutMs, }) => {
|
|
74
|
+
const PaywallProviderInner = ({ children, client, locale, customAudienceParams, productProvider, stripeProductProvider, customActions, customScreens, presentAckTimeoutMs, }) => {
|
|
66
75
|
var _a;
|
|
67
76
|
// `data` straight off `useQuery` is the single source of truth (Finding 1,
|
|
68
77
|
// 2026-08-17 final review) — react-query's own cache already gets both a
|
|
@@ -307,11 +316,15 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
307
316
|
isReady,
|
|
308
317
|
catalog,
|
|
309
318
|
catalogStatus,
|
|
319
|
+
// A literal `true` — no dependency-array entry needed, unlike every
|
|
320
|
+
// other member of this object.
|
|
321
|
+
isProviderMounted: true,
|
|
310
322
|
productsStatus: productRuntime.status,
|
|
311
323
|
activePaywall,
|
|
312
324
|
complete,
|
|
313
325
|
acknowledgePresentation,
|
|
314
326
|
customActions,
|
|
327
|
+
customScreens,
|
|
315
328
|
}), [
|
|
316
329
|
present,
|
|
317
330
|
isReady,
|
|
@@ -322,6 +335,7 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
322
335
|
complete,
|
|
323
336
|
acknowledgePresentation,
|
|
324
337
|
customActions,
|
|
338
|
+
customScreens,
|
|
325
339
|
]);
|
|
326
340
|
return ((0, jsx_runtime_1.jsx)(ProductRuntimeContext_1.ProductRuntimeContext.Provider, { value: productRuntimeWithPurchaseTracking, children: (0, jsx_runtime_1.jsx)(exports.PaywallContext.Provider, { value: contextValue, children: children }) }));
|
|
327
341
|
};
|
|
@@ -337,8 +351,8 @@ const PaywallProviderInner = ({ children, client, locale, customAudienceParams,
|
|
|
337
351
|
* </PaywallProvider>
|
|
338
352
|
* ```
|
|
339
353
|
*/
|
|
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 }) }));
|
|
354
|
+
const PaywallProvider = ({ children, client, locale = "en", customAudienceParams = {}, productProvider, stripeProductProvider, customActions = EMPTY_CUSTOM_ACTIONS, customScreens = EMPTY_CUSTOM_SCREENS, presentAckTimeoutMs = DEFAULT_PRESENT_ACK_TIMEOUT_MS, }) => {
|
|
355
|
+
return ((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: paywallQueryClient, children: (0, jsx_runtime_1.jsx)(PaywallProviderInner, { client: client, locale: locale, customAudienceParams: customAudienceParams, productProvider: productProvider, stripeProductProvider: stripeProductProvider, customActions: customActions, customScreens: customScreens, presentAckTimeoutMs: presentAckTimeoutMs, children: children }) }));
|
|
342
356
|
};
|
|
343
357
|
exports.PaywallProvider = PaywallProvider;
|
|
344
358
|
//# 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,uCAYmB;AACnB,yDAAsD;AAEtD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G,oBAAoB,EACpC,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,aAAa,EAAE,aAAa,EAC5B,mBAAmB,EAAE,mBAAmB,YAEvC,QAAQ,GACY,GACH,CACvB,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,eAAe,mBA2B1B"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { PaywallCustomPayload } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* What a host-registered custom paywall screen receives.
|
|
5
|
+
*
|
|
6
|
+
* The contract is deliberately small. A custom paywall exists because the host
|
|
7
|
+
* already has a screen it wants to render — a StoreKit-driven layout, a Skia
|
|
8
|
+
* animation, anything the element vocabulary cannot express — so the studio's
|
|
9
|
+
* whole contribution is "which screen, and which products". Everything else
|
|
10
|
+
* the screen needs, it already has.
|
|
11
|
+
*
|
|
12
|
+
* In particular there is NO product runtime here, and that is a decision
|
|
13
|
+
* rather than an omission: `collectProductRefs` does not walk `customPayload`,
|
|
14
|
+
* so the SDK resolves no store products for a custom paywall and the screen
|
|
15
|
+
* gets ids, not prices. A native paywall queries the store itself for display
|
|
16
|
+
* prices — which is exactly what it does not need the studio for.
|
|
17
|
+
*
|
|
18
|
+
* DECLARED IN THE HEADLESS PACKAGE, even though only the UI package renders
|
|
19
|
+
* these screens, because there are now TWO renderers: `PaywallHost`'s Modal
|
|
20
|
+
* and the inline `Paywall` onboarding step. The registry they share is
|
|
21
|
+
* published on `PaywallProvider`, which lives here, so the type has to as
|
|
22
|
+
* well. `@rocapine/react-native-onboarding-ui` re-exports both names so
|
|
23
|
+
* existing imports keep resolving.
|
|
24
|
+
*/
|
|
25
|
+
export type CustomPaywallScreenProps = {
|
|
26
|
+
/**
|
|
27
|
+
* Slot key to per-platform store product id, e.g.
|
|
28
|
+
* `{ monthly: { ios: "com.app.m", android: "app_m" } }`.
|
|
29
|
+
*
|
|
30
|
+
* Never `undefined`: an absent `customPayload` on the wire (an older
|
|
31
|
+
* `get-paywalls`) arrives here as `{}`, so the one prop this screen exists
|
|
32
|
+
* to read always has a shape.
|
|
33
|
+
*/
|
|
34
|
+
payload: PaywallCustomPayload;
|
|
35
|
+
/**
|
|
36
|
+
* Ends the presentation and resolves whatever is waiting on it.
|
|
37
|
+
*
|
|
38
|
+
* MUST be called, on every exit path — including the screen's own close
|
|
39
|
+
* button.
|
|
40
|
+
*
|
|
41
|
+
* From `PaywallHost`: until it is called, `PaywallProvider` considers this
|
|
42
|
+
* paywall active and every later `present()` resolves `"already-presenting"`.
|
|
43
|
+
* From an inline `Paywall` onboarding STEP: the step is hard-gated, so only
|
|
44
|
+
* `{ status: "purchased" }` (or no argument at all, which a bare `continue`
|
|
45
|
+
* action produces) advances the onboarding — a `"dismissed"` outcome is
|
|
46
|
+
* deliberately ignored there, and the user stays on the paywall.
|
|
47
|
+
*
|
|
48
|
+
* Note `"pending"` does NOT advance a gated step: a Stripe Payment Link
|
|
49
|
+
* resolves pending, which means UNCONFIRMED. `PresentResult` describes how a
|
|
50
|
+
* paywall CLOSED, never what the user is entitled to — read entitlement from
|
|
51
|
+
* the billing SDK.
|
|
52
|
+
*/
|
|
53
|
+
complete: (outcome?: {
|
|
54
|
+
status: "purchased" | "dismissed" | "cancelled";
|
|
55
|
+
}) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Which paywall is being shown. `moment` is what resolved it; `id` and
|
|
58
|
+
* `name` are the studio's, for analytics. Enough to report a conversion
|
|
59
|
+
* without also handing over the `elements` tree a custom paywall has no use
|
|
60
|
+
* for.
|
|
61
|
+
*/
|
|
62
|
+
paywall: {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
moment: string;
|
|
66
|
+
customScreenId: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The registry, keyed by the `customScreenId` authored in the studio.
|
|
71
|
+
*
|
|
72
|
+
* Register it on `PaywallProvider` — that is the canonical place, and the only
|
|
73
|
+
* one an inline `Paywall` onboarding step can read. `PaywallHost` also accepts
|
|
74
|
+
* it as a prop, which overrides the provider's for that host only; that prop
|
|
75
|
+
* predates the inline step and is kept so 1.72.0 integrations keep compiling.
|
|
76
|
+
*
|
|
77
|
+
* A paywall naming a key absent from the map never renders: `PaywallHost`
|
|
78
|
+
* resolves `{ status: "error", reason: "unknown-custom-screen" }` and never
|
|
79
|
+
* opens its Modal, and an inline step logs and skips rather than trapping the
|
|
80
|
+
* user in the funnel.
|
|
81
|
+
*/
|
|
82
|
+
export type CustomPaywallScreens = Record<string, ComponentType<CustomPaywallScreenProps>>;
|
|
83
|
+
//# sourceMappingURL=customScreens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customScreens.d.ts","sourceRoot":"","sources":["../../src/paywalls/customScreens.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;;;OAOG;IACH,OAAO,EAAE,oBAAoB,CAAC;IAC9B;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,MAAM,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,CAAA;KAAE,KAAK,IAAI,CAAC;IAClF;;;;;OAKG;IACH,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customScreens.js","sourceRoot":"","sources":["../../src/paywalls/customScreens.ts"],"names":[],"mappings":""}
|
package/dist/paywalls/types.d.ts
CHANGED
|
@@ -41,7 +41,62 @@ export type Paywall = {
|
|
|
41
41
|
stripe?: StripeProductRef;
|
|
42
42
|
}>;
|
|
43
43
|
configuration: Record<string, unknown> | null;
|
|
44
|
+
/**
|
|
45
|
+
* Who draws this paywall. `"elements"` (the default) renders the authored
|
|
46
|
+
* `elements` tree; `"custom"` hands it to a screen the HOST registered under
|
|
47
|
+
* `customScreenId` (see `PaywallHost`'s `customScreens` prop in the UI
|
|
48
|
+
* package), and `elements` is then ignored entirely.
|
|
49
|
+
*
|
|
50
|
+
* A property of the PAYWALL, not the moment — the same reasoning as
|
|
51
|
+
* `billing` above: one moment audience can weight an element-tree variant
|
|
52
|
+
* against a native-screen variant and ramp the change as an A/B test.
|
|
53
|
+
*
|
|
54
|
+
* OPTIONAL, and absent means `"elements"`. Not because the studio omits it
|
|
55
|
+
* (it always sends a value) but because a device on a NEW SDK can be talking
|
|
56
|
+
* to an OLDER `get-paywalls` that predates the field. Treating absent as
|
|
57
|
+
* `"custom"`, or as an error, would break every existing paywall on that
|
|
58
|
+
* pairing; treating it as `"elements"` is exactly the old behaviour.
|
|
59
|
+
*/
|
|
60
|
+
renderMode?: "elements" | "custom";
|
|
61
|
+
/**
|
|
62
|
+
* Which host-registered screen renders this paywall. Meaningful only when
|
|
63
|
+
* `renderMode` is `"custom"`.
|
|
64
|
+
*
|
|
65
|
+
* Nullable as well as optional: the studio accepts a custom paywall with no
|
|
66
|
+
* screen id (it warns rather than refusing), so an empty value is a state
|
|
67
|
+
* that genuinely arrives. `PaywallHost` reports it as
|
|
68
|
+
* `{ status: "error", reason: "unknown-custom-screen" }` rather than opening
|
|
69
|
+
* an empty full-screen Modal.
|
|
70
|
+
*/
|
|
71
|
+
customScreenId?: string | null;
|
|
72
|
+
/**
|
|
73
|
+
* The product map handed to that screen: slot key to per-platform store
|
|
74
|
+
* product id. This is the one thing a native paywall cannot get from
|
|
75
|
+
* anywhere else — the moment waterfall picked THIS variant, and which
|
|
76
|
+
* products it offers is an authoring decision, not something compiled into
|
|
77
|
+
* the app.
|
|
78
|
+
*
|
|
79
|
+
* Deliberately NOT the same thing as `products` above. Those slots exist to
|
|
80
|
+
* feed `{{product.<key>.price}}` interpolation into an element tree, and a
|
|
81
|
+
* custom screen has no interpolation — so a custom paywall carries product
|
|
82
|
+
* IDS and no prices, and the SDK resolves no store products for it at all
|
|
83
|
+
* (`collectProductRefs` does not walk this map). A native paywall asks the
|
|
84
|
+
* store for its own display prices, which is exactly what it does not need
|
|
85
|
+
* the studio for.
|
|
86
|
+
*/
|
|
87
|
+
customPayload?: PaywallCustomPayload;
|
|
44
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* `Paywall.customPayload` — slot key to per-platform product id.
|
|
91
|
+
*
|
|
92
|
+
* Both platform fields are optional: a paywall shipped on one platform only is
|
|
93
|
+
* legitimate, and so is a key whose ids have not been filled in yet (the
|
|
94
|
+
* studio warns about that rather than refusing to save it).
|
|
95
|
+
*/
|
|
96
|
+
export type PaywallCustomPayload = Record<string, {
|
|
97
|
+
ios?: string;
|
|
98
|
+
android?: string;
|
|
99
|
+
}>;
|
|
45
100
|
/** Full response body of `GET get-paywalls`. */
|
|
46
101
|
export type PaywallCatalog = {
|
|
47
102
|
metadata: {
|
|
@@ -147,8 +202,16 @@ export interface GetPaywallsResponseHeaders {
|
|
|
147
202
|
* Modal, a `presentation: "modal"` route, a StoreKit alert).
|
|
148
203
|
* - `paywall-disappeared` — the moment vanished from the catalog while it
|
|
149
204
|
* was on screen (a studio publish, or a query-key change mid-presentation).
|
|
205
|
+
* - `unknown-custom-screen` — the paywall is `renderMode: "custom"` and names
|
|
206
|
+
* a `customScreenId` this host did not register (or names none at all), so
|
|
207
|
+
* there was nothing to render and the Modal was never opened. Deliberately
|
|
208
|
+
* NOT folded into `parse-error`: that one is a CMS **data** bug the author
|
|
209
|
+
* must fix, this is a HOST **wiring** bug the app must fix — opposite
|
|
210
|
+
* remedies, and conflating them is the exact mistake this union's split
|
|
211
|
+
* already exists to avoid. `PaywallHost` logs both the missing id and the
|
|
212
|
+
* ids that ARE registered, which is usually the whole diagnosis.
|
|
150
213
|
*/
|
|
151
|
-
export type PresentErrorReason = "unknown-moment" | "already-presenting" | "parse-error" | "render-error" | "host-never-presented" | "paywall-disappeared";
|
|
214
|
+
export type PresentErrorReason = "unknown-moment" | "already-presenting" | "parse-error" | "render-error" | "host-never-presented" | "paywall-disappeared" | "unknown-custom-screen";
|
|
152
215
|
export type PresentResult = {
|
|
153
216
|
status: "purchased" | "dismissed" | "cancelled" | "error";
|
|
154
217
|
/** Why it failed. Set on `"error"` only — see `PresentErrorReason`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/paywalls/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D;;;;;;GAMG;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,0FAA0F;IAC1F,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB;;;;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AC1D,uEAAuE;IACvE,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PaywallCatalog, PresentResult } from "./types";
|
|
2
2
|
import type { CatalogStatus } from "./present";
|
|
3
3
|
import type { ProductStatus } from "../products/types";
|
|
4
|
+
import type { CustomPaywallScreens } from "./customScreens";
|
|
4
5
|
export type UsePaywallResult = {
|
|
5
6
|
/**
|
|
6
7
|
* Present a paywall by moment. Never fetches — the catalog and its
|
|
@@ -33,6 +34,19 @@ export type UsePaywallResult = {
|
|
|
33
34
|
* host tell "still waiting on the store" from "still waiting on us".
|
|
34
35
|
*/
|
|
35
36
|
productsStatus: ProductStatus;
|
|
37
|
+
/**
|
|
38
|
+
* Whether a real `PaywallProvider` is above this consumer — see the field's
|
|
39
|
+
* doc on `PaywallContextValue`. Needed by any consumer that renders a
|
|
40
|
+
* spinner while the catalog loads, because with no provider
|
|
41
|
+
* `catalogStatus` reports `"loading"` and nothing ever arrives.
|
|
42
|
+
*/
|
|
43
|
+
isProviderMounted: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Host-registered screens for `renderMode: "custom"` paywalls, keyed by
|
|
46
|
+
* `customScreenId`. Exposed here because the inline `Paywall` onboarding
|
|
47
|
+
* step renders them itself, never going through `PaywallHost`.
|
|
48
|
+
*/
|
|
49
|
+
customScreens: CustomPaywallScreens;
|
|
36
50
|
};
|
|
37
51
|
/**
|
|
38
52
|
* Read the paywall runtime published by an ancestor `PaywallProvider`.
|
|
@@ -1 +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;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
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;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;;;;;;OASG;IACH,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B;;;;;;OAMG;IACH,aAAa,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,cAAc,EAAE,aAAa,CAAC;IAC9B;;;;;OAKG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,aAAa,EAAE,oBAAoB,CAAC;CACrC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAO,gBAY7B,CAAC"}
|
|
@@ -10,8 +10,16 @@ const PaywallProvider_1 = require("./PaywallProvider");
|
|
|
10
10
|
* `useProductRuntime()` degrades to `null` with no ancestor.
|
|
11
11
|
*/
|
|
12
12
|
const usePaywall = () => {
|
|
13
|
-
const { present, isReady, catalog, catalogStatus, productsStatus } = (0, react_1.useContext)(PaywallProvider_1.PaywallContext);
|
|
14
|
-
return {
|
|
13
|
+
const { present, isReady, catalog, catalogStatus, productsStatus, isProviderMounted, customScreens } = (0, react_1.useContext)(PaywallProvider_1.PaywallContext);
|
|
14
|
+
return {
|
|
15
|
+
present,
|
|
16
|
+
isReady,
|
|
17
|
+
catalog,
|
|
18
|
+
catalogStatus,
|
|
19
|
+
productsStatus,
|
|
20
|
+
isProviderMounted,
|
|
21
|
+
customScreens,
|
|
22
|
+
};
|
|
15
23
|
};
|
|
16
24
|
exports.usePaywall = usePaywall;
|
|
17
25
|
//# sourceMappingURL=usePaywall.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaywall.js","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,uDAAmD;
|
|
1
|
+
{"version":3,"file":"usePaywall.js","sourceRoot":"","sources":["../../src/paywalls/usePaywall.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,uDAAmD;AAqDnD;;;;;GAKG;AACI,MAAM,UAAU,GAAG,GAAqB,EAAE;IAC/C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB,EAAE,aAAa,EAAE,GAClG,IAAA,kBAAU,EAAC,gCAAc,CAAC,CAAC;IAC7B,OAAO;QACL,OAAO;QACP,OAAO;QACP,OAAO;QACP,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,aAAa;KACd,CAAC;AACJ,CAAC,CAAC;AAZW,QAAA,UAAU,cAYrB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* A step that IS a paywall.
|
|
4
|
+
*
|
|
5
|
+
* `moment` is a `moments.key` — the same address a host passes to `present()`.
|
|
6
|
+
* It resolves through the catalog `get-paywalls` already returns keyed by
|
|
7
|
+
* moment, which means the audience waterfall has ALREADY picked the variant:
|
|
8
|
+
* targeting and weighted A/B come for free, and this payload needs exactly one
|
|
9
|
+
* field. No wire change was required anywhere for this step type.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately not a paywall id: that would bypass the waterfall, so
|
|
12
|
+
* A/B-testing a paywall inside an onboarding would mean duplicating the whole
|
|
13
|
+
* onboarding.
|
|
14
|
+
*
|
|
15
|
+
* Rendered inline by the UI package's `Pages/Paywall/Renderer.tsx`, and
|
|
16
|
+
* HARD-GATED — only a purchase advances past it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const PaywallStepPayloadSchema: z.ZodObject<{
|
|
19
|
+
moment: z.ZodString;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
export declare const PaywallStepTypeSchema: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
displayProgressHeader: z.ZodBoolean;
|
|
25
|
+
customPayload: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
|
|
26
|
+
continueButtonLabel: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
27
|
+
buttonSection: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
label: z.ZodOptional<z.ZodString>;
|
|
29
|
+
icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
figmaUrl: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
nextStep: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
33
|
+
defaultTargetStepId: z.ZodString;
|
|
34
|
+
branches: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
35
|
+
condition: z.ZodDefault<z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
|
|
36
|
+
variable: z.ZodString;
|
|
37
|
+
operator: z.ZodEnum<{
|
|
38
|
+
in: "in";
|
|
39
|
+
eq: "eq";
|
|
40
|
+
neq: "neq";
|
|
41
|
+
gt: "gt";
|
|
42
|
+
lt: "lt";
|
|
43
|
+
gte: "gte";
|
|
44
|
+
lte: "lte";
|
|
45
|
+
contains: "contains";
|
|
46
|
+
not_in: "not_in";
|
|
47
|
+
is_empty: "is_empty";
|
|
48
|
+
is_not_empty: "is_not_empty";
|
|
49
|
+
is_null: "is_null";
|
|
50
|
+
is_not_null: "is_not_null";
|
|
51
|
+
}>;
|
|
52
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>>;
|
|
53
|
+
}, z.core.$strip>, z.ZodType<import("../common.types").ConditionGroup, unknown, z.core.$ZodTypeInternals<import("../common.types").ConditionGroup, unknown>>]>>>;
|
|
54
|
+
targetStepId: z.ZodString;
|
|
55
|
+
}, z.core.$strip>>>;
|
|
56
|
+
}, z.core.$strip>>>;
|
|
57
|
+
type: z.ZodLiteral<"Paywall">;
|
|
58
|
+
payload: z.ZodObject<{
|
|
59
|
+
moment: z.ZodString;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type PaywallStepType = z.infer<typeof PaywallStepTypeSchema>;
|
|
63
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/steps/Paywall/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,wBAAwB;;iBAEnC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaywallStepTypeSchema = exports.PaywallStepPayloadSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_types_1 = require("../common.types");
|
|
6
|
+
/**
|
|
7
|
+
* A step that IS a paywall.
|
|
8
|
+
*
|
|
9
|
+
* `moment` is a `moments.key` — the same address a host passes to `present()`.
|
|
10
|
+
* It resolves through the catalog `get-paywalls` already returns keyed by
|
|
11
|
+
* moment, which means the audience waterfall has ALREADY picked the variant:
|
|
12
|
+
* targeting and weighted A/B come for free, and this payload needs exactly one
|
|
13
|
+
* field. No wire change was required anywhere for this step type.
|
|
14
|
+
*
|
|
15
|
+
* Deliberately not a paywall id: that would bypass the waterfall, so
|
|
16
|
+
* A/B-testing a paywall inside an onboarding would mean duplicating the whole
|
|
17
|
+
* onboarding.
|
|
18
|
+
*
|
|
19
|
+
* Rendered inline by the UI package's `Pages/Paywall/Renderer.tsx`, and
|
|
20
|
+
* HARD-GATED — only a purchase advances past it.
|
|
21
|
+
*/
|
|
22
|
+
exports.PaywallStepPayloadSchema = zod_1.z.object({
|
|
23
|
+
moment: zod_1.z.string().min(1),
|
|
24
|
+
});
|
|
25
|
+
exports.PaywallStepTypeSchema = common_types_1.BaseStepTypeSchema.extend({
|
|
26
|
+
type: zod_1.z.literal("Paywall"),
|
|
27
|
+
payload: exports.PaywallStepPayloadSchema,
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/steps/Paywall/types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,kDAAqD;AAErD;;;;;;;;;;;;;;;GAeG;AACU,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC1B,CAAC,CAAC;AAEU,QAAA,qBAAqB,GAAG,iCAAkB,CAAC,MAAM,CAAC;IAC7D,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,gCAAwB;CAClC,CAAC,CAAC"}
|
package/dist/steps/types.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import { CommitmentStepType } from "./Commitment/types";
|
|
|
3
3
|
import { LoaderStepType } from "./Loader/types";
|
|
4
4
|
import { MediaContentStepType } from "./MediaContent/types";
|
|
5
5
|
import { ComposableScreenStepType } from "./ComposableScreen/types";
|
|
6
|
+
import { PaywallStepType } from "./Paywall/types";
|
|
6
7
|
import { PickerStepType } from "./Picker/types";
|
|
7
8
|
import { QuestionStepType } from "./Question/types";
|
|
8
9
|
import { RatingsStepType } from "./Ratings/types";
|
|
9
|
-
export type OnboardingStepType = CarouselStepType | CommitmentStepType | LoaderStepType | MediaContentStepType | ComposableScreenStepType | PickerStepType | QuestionStepType | RatingsStepType;
|
|
10
|
+
export type OnboardingStepType = CarouselStepType | CommitmentStepType | LoaderStepType | MediaContentStepType | ComposableScreenStepType | PaywallStepType | PickerStepType | QuestionStepType | RatingsStepType;
|
|
10
11
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/steps/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,cAAc,GACd,gBAAgB,GAChB,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/steps/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,oBAAoB,GACpB,wBAAwB,GACxB,eAAe,GACf,cAAc,GACd,gBAAgB,GAChB,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocapine/react-native-onboarding",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.73.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",
|
package/src/index.ts
CHANGED
|
@@ -47,6 +47,10 @@ export {
|
|
|
47
47
|
generateWheelPickerRangeItems,
|
|
48
48
|
resolveWheelPickerItems,
|
|
49
49
|
} from "./steps/ComposableScreen/types";
|
|
50
|
+
// A step that IS a paywall: `payload.moment` names a moment, and the audience
|
|
51
|
+
// waterfall behind it picks which paywall renders.
|
|
52
|
+
export type { PaywallStepType } from "./steps/Paywall/types";
|
|
53
|
+
export { PaywallStepTypeSchema, PaywallStepPayloadSchema } from "./steps/Paywall/types";
|
|
50
54
|
// Payload diagnostics — non-fatal detection of keys placed at an element's top
|
|
51
55
|
// level that the schema silently drops (e.g. `animation` outside `props`).
|
|
52
56
|
export {
|
|
@@ -90,6 +94,9 @@ export * from "./products";
|
|
|
90
94
|
// Paywalls (paywall phase 5) — catalog types, provider, and the `usePaywall` hook
|
|
91
95
|
export type {
|
|
92
96
|
Paywall,
|
|
97
|
+
// Exported so a host's custom paywall screen can type the product map it
|
|
98
|
+
// receives without restating the shape.
|
|
99
|
+
PaywallCustomPayload,
|
|
93
100
|
PaywallCatalog,
|
|
94
101
|
PaywallOptions,
|
|
95
102
|
GetPaywallsResponseHeaders,
|
|
@@ -99,6 +106,10 @@ export type {
|
|
|
99
106
|
PresentErrorReason,
|
|
100
107
|
} from "./paywalls/types";
|
|
101
108
|
export { PaywallProvider, usePaywallHost } from "./paywalls/PaywallProvider";
|
|
109
|
+
// The custom-screen registry lives on PaywallProvider now (two renderers read
|
|
110
|
+
// it: PaywallHost's Modal and the inline Paywall onboarding step), so its types
|
|
111
|
+
// live in the headless package. onboarding-ui re-exports both names.
|
|
112
|
+
export type { CustomPaywallScreenProps, CustomPaywallScreens } from "./paywalls/customScreens";
|
|
102
113
|
export type { PaywallContextValue } from "./paywalls/PaywallProvider";
|
|
103
114
|
export { usePaywall } from "./paywalls/usePaywall";
|
|
104
115
|
// Exported so a host can switch exhaustively on what the catalog is doing
|
|
@@ -20,6 +20,7 @@ import { useProducts } from "../products/useProducts";
|
|
|
20
20
|
import { ProductProvider, ProductStatus } from "../products/types";
|
|
21
21
|
import { ProductRuntimeContext } from "../products/ProductRuntimeContext";
|
|
22
22
|
import type { CustomActions } from "../infra/provider/OnboardingProvider";
|
|
23
|
+
import type { CustomPaywallScreens } from "./customScreens";
|
|
23
24
|
|
|
24
25
|
// Module-scope, private to this file — mirrors `OnboardingProvider.tsx:17-23`.
|
|
25
26
|
// `OnboardingProvider`'s QueryClient is not exported, so it cannot be reused
|
|
@@ -43,6 +44,12 @@ const paywallQueryClient = new QueryClient({
|
|
|
43
44
|
// way `EMPTY_CUSTOM_ACTIONS` in `OnboardingProvider.tsx` documents.
|
|
44
45
|
const EMPTY_CUSTOM_ACTIONS: CustomActions = Object.freeze({});
|
|
45
46
|
|
|
47
|
+
// Frozen at module scope for the same reason as EMPTY_CUSTOM_ACTIONS above: it
|
|
48
|
+
// sits in the published context value, and an unstable identity would defeat
|
|
49
|
+
// memoization in every consumer that lists it as a dependency (the inline
|
|
50
|
+
// `Paywall` step's decision memo does).
|
|
51
|
+
const EMPTY_CUSTOM_SCREENS: CustomPaywallScreens = Object.freeze({});
|
|
52
|
+
|
|
46
53
|
/**
|
|
47
54
|
* Everything a paywall consumer or a paywall HOST needs. Deliberately one
|
|
48
55
|
* context carrying both, mirroring how `OnboardingProgressContext` bundles
|
|
@@ -61,6 +68,22 @@ export type PaywallContextValue = {
|
|
|
61
68
|
* does not yet mean an absent one.
|
|
62
69
|
*/
|
|
63
70
|
catalogStatus: CatalogStatus;
|
|
71
|
+
/**
|
|
72
|
+
* Whether a real `PaywallProvider` is above this consumer.
|
|
73
|
+
*
|
|
74
|
+
* Exists because `EMPTY_PAYWALL_CONTEXT` reports `catalogStatus: "loading"` —
|
|
75
|
+
* honest for `present()`'s contract (nothing is loading and nothing will
|
|
76
|
+
* arrive, so `"error"` is the answer) but INDISTINGUISHABLE from a genuine
|
|
77
|
+
* first load. A consumer that renders a spinner while loading would spin
|
|
78
|
+
* forever under no provider, and the inline `Paywall` onboarding step
|
|
79
|
+
* (`UI/Pages/Paywall/Renderer.tsx` in the UI package) is exactly that
|
|
80
|
+
* consumer.
|
|
81
|
+
*
|
|
82
|
+
* Deliberately NOT a new `CatalogStatus` member: widening that union breaks
|
|
83
|
+
* every host switching exhaustively over it, and "no provider" is not a
|
|
84
|
+
* catalog state.
|
|
85
|
+
*/
|
|
86
|
+
isProviderMounted: boolean;
|
|
64
87
|
/**
|
|
65
88
|
* What the store products are doing. The other half of `isReady`: a host that
|
|
66
89
|
* sees `catalogStatus: "ready"` but `isReady: false` can tell it is waiting on
|
|
@@ -86,6 +109,17 @@ export type PaywallContextValue = {
|
|
|
86
109
|
acknowledgePresentation: () => void;
|
|
87
110
|
/** Forwarded into the presented paywall's `ScreenHost.customActions`. */
|
|
88
111
|
customActions: CustomActions;
|
|
112
|
+
/**
|
|
113
|
+
* Host-registered screens for `renderMode: "custom"` paywalls, keyed by
|
|
114
|
+
* `customScreenId`.
|
|
115
|
+
*
|
|
116
|
+
* Published HERE — rather than only on `PaywallHost`, where it started in
|
|
117
|
+
* 1.72.0 — because there are now two renderers: that Modal, and the inline
|
|
118
|
+
* `Paywall` onboarding step, which never goes through `PaywallHost` at all.
|
|
119
|
+
* One registration has to serve both, and this is the provider every host
|
|
120
|
+
* already mounts. `PaywallHost`'s own prop still wins for that host.
|
|
121
|
+
*/
|
|
122
|
+
customScreens: CustomPaywallScreens;
|
|
89
123
|
};
|
|
90
124
|
|
|
91
125
|
const EMPTY_PAYWALL_CONTEXT: PaywallContextValue = {
|
|
@@ -96,11 +130,15 @@ const EMPTY_PAYWALL_CONTEXT: PaywallContextValue = {
|
|
|
96
130
|
catalog: null,
|
|
97
131
|
// No provider above: nothing is loading and nothing will arrive.
|
|
98
132
|
catalogStatus: "loading",
|
|
133
|
+
// The one value that distinguishes this object from a real provider's — see
|
|
134
|
+
// the field's doc above for why `catalogStatus` cannot do that job.
|
|
135
|
+
isProviderMounted: false,
|
|
99
136
|
productsStatus: "idle",
|
|
100
137
|
activePaywall: null,
|
|
101
138
|
complete: () => {},
|
|
102
139
|
acknowledgePresentation: () => {},
|
|
103
140
|
customActions: EMPTY_CUSTOM_ACTIONS,
|
|
141
|
+
customScreens: EMPTY_CUSTOM_SCREENS,
|
|
104
142
|
};
|
|
105
143
|
|
|
106
144
|
/**
|
|
@@ -122,11 +160,11 @@ export const PaywallContext = createContext<PaywallContextValue>(EMPTY_PAYWALL_C
|
|
|
122
160
|
*/
|
|
123
161
|
export const usePaywallHost = (): Pick<
|
|
124
162
|
PaywallContextValue,
|
|
125
|
-
"activePaywall" | "complete" | "acknowledgePresentation" | "customActions"
|
|
163
|
+
"activePaywall" | "complete" | "acknowledgePresentation" | "customActions" | "customScreens"
|
|
126
164
|
> => {
|
|
127
|
-
const { activePaywall, complete, acknowledgePresentation, customActions } =
|
|
165
|
+
const { activePaywall, complete, acknowledgePresentation, customActions, customScreens } =
|
|
128
166
|
useContext(PaywallContext);
|
|
129
|
-
return { activePaywall, complete, acknowledgePresentation, customActions };
|
|
167
|
+
return { activePaywall, complete, acknowledgePresentation, customActions, customScreens };
|
|
130
168
|
};
|
|
131
169
|
|
|
132
170
|
interface PaywallProviderProps {
|
|
@@ -161,6 +199,20 @@ interface PaywallProviderProps {
|
|
|
161
199
|
stripeProductProvider?: ProductProvider;
|
|
162
200
|
/** Handlers for `{ type: "custom" }` ButtonActions inside a paywall's elements. */
|
|
163
201
|
customActions?: CustomActions;
|
|
202
|
+
/**
|
|
203
|
+
* Screens for `renderMode: "custom"` paywalls, keyed by the
|
|
204
|
+
* `customScreenId` authored in the studio.
|
|
205
|
+
*
|
|
206
|
+
* THE canonical place to register them: both renderers read from here —
|
|
207
|
+
* `PaywallHost`'s Modal and the inline `Paywall` onboarding step, which never
|
|
208
|
+
* goes through `PaywallHost`. `PaywallHost` still accepts its own
|
|
209
|
+
* `customScreens` prop (1.72.0's API), and that prop overrides this for that
|
|
210
|
+
* host; prefer this one.
|
|
211
|
+
*
|
|
212
|
+
* MUST be referentially stable (module scope, or `useMemo`) — it lands in the
|
|
213
|
+
* context value and in consumers' dependency arrays.
|
|
214
|
+
*/
|
|
215
|
+
customScreens?: CustomPaywallScreens;
|
|
164
216
|
/**
|
|
165
217
|
* How long to wait for the host to confirm a paywall actually appeared
|
|
166
218
|
* before abandoning the presentation and resolving
|
|
@@ -181,6 +233,7 @@ interface PaywallProviderInnerProps {
|
|
|
181
233
|
productProvider?: ProductProvider;
|
|
182
234
|
stripeProductProvider?: ProductProvider;
|
|
183
235
|
customActions: CustomActions;
|
|
236
|
+
customScreens: CustomPaywallScreens;
|
|
184
237
|
presentAckTimeoutMs: number | null;
|
|
185
238
|
}
|
|
186
239
|
|
|
@@ -192,6 +245,7 @@ const PaywallProviderInner = ({
|
|
|
192
245
|
productProvider,
|
|
193
246
|
stripeProductProvider,
|
|
194
247
|
customActions,
|
|
248
|
+
customScreens,
|
|
195
249
|
presentAckTimeoutMs,
|
|
196
250
|
}: PaywallProviderInnerProps) => {
|
|
197
251
|
// `data` straight off `useQuery` is the single source of truth (Finding 1,
|
|
@@ -464,11 +518,15 @@ const PaywallProviderInner = ({
|
|
|
464
518
|
isReady,
|
|
465
519
|
catalog,
|
|
466
520
|
catalogStatus,
|
|
521
|
+
// A literal `true` — no dependency-array entry needed, unlike every
|
|
522
|
+
// other member of this object.
|
|
523
|
+
isProviderMounted: true,
|
|
467
524
|
productsStatus: productRuntime.status,
|
|
468
525
|
activePaywall,
|
|
469
526
|
complete,
|
|
470
527
|
acknowledgePresentation,
|
|
471
528
|
customActions,
|
|
529
|
+
customScreens,
|
|
472
530
|
}),
|
|
473
531
|
[
|
|
474
532
|
present,
|
|
@@ -480,6 +538,7 @@ const PaywallProviderInner = ({
|
|
|
480
538
|
complete,
|
|
481
539
|
acknowledgePresentation,
|
|
482
540
|
customActions,
|
|
541
|
+
customScreens,
|
|
483
542
|
]
|
|
484
543
|
);
|
|
485
544
|
|
|
@@ -510,6 +569,7 @@ export const PaywallProvider = ({
|
|
|
510
569
|
productProvider,
|
|
511
570
|
stripeProductProvider,
|
|
512
571
|
customActions = EMPTY_CUSTOM_ACTIONS,
|
|
572
|
+
customScreens = EMPTY_CUSTOM_SCREENS,
|
|
513
573
|
presentAckTimeoutMs = DEFAULT_PRESENT_ACK_TIMEOUT_MS,
|
|
514
574
|
}: PaywallProviderProps) => {
|
|
515
575
|
return (
|
|
@@ -521,6 +581,7 @@ export const PaywallProvider = ({
|
|
|
521
581
|
productProvider={productProvider}
|
|
522
582
|
stripeProductProvider={stripeProductProvider}
|
|
523
583
|
customActions={customActions}
|
|
584
|
+
customScreens={customScreens}
|
|
524
585
|
presentAckTimeoutMs={presentAckTimeoutMs}
|
|
525
586
|
>
|
|
526
587
|
{children}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { PaywallCustomPayload } from "./types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a host-registered custom paywall screen receives.
|
|
6
|
+
*
|
|
7
|
+
* The contract is deliberately small. A custom paywall exists because the host
|
|
8
|
+
* already has a screen it wants to render — a StoreKit-driven layout, a Skia
|
|
9
|
+
* animation, anything the element vocabulary cannot express — so the studio's
|
|
10
|
+
* whole contribution is "which screen, and which products". Everything else
|
|
11
|
+
* the screen needs, it already has.
|
|
12
|
+
*
|
|
13
|
+
* In particular there is NO product runtime here, and that is a decision
|
|
14
|
+
* rather than an omission: `collectProductRefs` does not walk `customPayload`,
|
|
15
|
+
* so the SDK resolves no store products for a custom paywall and the screen
|
|
16
|
+
* gets ids, not prices. A native paywall queries the store itself for display
|
|
17
|
+
* prices — which is exactly what it does not need the studio for.
|
|
18
|
+
*
|
|
19
|
+
* DECLARED IN THE HEADLESS PACKAGE, even though only the UI package renders
|
|
20
|
+
* these screens, because there are now TWO renderers: `PaywallHost`'s Modal
|
|
21
|
+
* and the inline `Paywall` onboarding step. The registry they share is
|
|
22
|
+
* published on `PaywallProvider`, which lives here, so the type has to as
|
|
23
|
+
* well. `@rocapine/react-native-onboarding-ui` re-exports both names so
|
|
24
|
+
* existing imports keep resolving.
|
|
25
|
+
*/
|
|
26
|
+
export type CustomPaywallScreenProps = {
|
|
27
|
+
/**
|
|
28
|
+
* Slot key to per-platform store product id, e.g.
|
|
29
|
+
* `{ monthly: { ios: "com.app.m", android: "app_m" } }`.
|
|
30
|
+
*
|
|
31
|
+
* Never `undefined`: an absent `customPayload` on the wire (an older
|
|
32
|
+
* `get-paywalls`) arrives here as `{}`, so the one prop this screen exists
|
|
33
|
+
* to read always has a shape.
|
|
34
|
+
*/
|
|
35
|
+
payload: PaywallCustomPayload;
|
|
36
|
+
/**
|
|
37
|
+
* Ends the presentation and resolves whatever is waiting on it.
|
|
38
|
+
*
|
|
39
|
+
* MUST be called, on every exit path — including the screen's own close
|
|
40
|
+
* button.
|
|
41
|
+
*
|
|
42
|
+
* From `PaywallHost`: until it is called, `PaywallProvider` considers this
|
|
43
|
+
* paywall active and every later `present()` resolves `"already-presenting"`.
|
|
44
|
+
* From an inline `Paywall` onboarding STEP: the step is hard-gated, so only
|
|
45
|
+
* `{ status: "purchased" }` (or no argument at all, which a bare `continue`
|
|
46
|
+
* action produces) advances the onboarding — a `"dismissed"` outcome is
|
|
47
|
+
* deliberately ignored there, and the user stays on the paywall.
|
|
48
|
+
*
|
|
49
|
+
* Note `"pending"` does NOT advance a gated step: a Stripe Payment Link
|
|
50
|
+
* resolves pending, which means UNCONFIRMED. `PresentResult` describes how a
|
|
51
|
+
* paywall CLOSED, never what the user is entitled to — read entitlement from
|
|
52
|
+
* the billing SDK.
|
|
53
|
+
*/
|
|
54
|
+
complete: (outcome?: { status: "purchased" | "dismissed" | "cancelled" }) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Which paywall is being shown. `moment` is what resolved it; `id` and
|
|
57
|
+
* `name` are the studio's, for analytics. Enough to report a conversion
|
|
58
|
+
* without also handing over the `elements` tree a custom paywall has no use
|
|
59
|
+
* for.
|
|
60
|
+
*/
|
|
61
|
+
paywall: {
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
moment: string;
|
|
65
|
+
customScreenId: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The registry, keyed by the `customScreenId` authored in the studio.
|
|
71
|
+
*
|
|
72
|
+
* Register it on `PaywallProvider` — that is the canonical place, and the only
|
|
73
|
+
* one an inline `Paywall` onboarding step can read. `PaywallHost` also accepts
|
|
74
|
+
* it as a prop, which overrides the provider's for that host only; that prop
|
|
75
|
+
* predates the inline step and is kept so 1.72.0 integrations keep compiling.
|
|
76
|
+
*
|
|
77
|
+
* A paywall naming a key absent from the map never renders: `PaywallHost`
|
|
78
|
+
* resolves `{ status: "error", reason: "unknown-custom-screen" }` and never
|
|
79
|
+
* opens its Modal, and an inline step logs and skips rather than trapping the
|
|
80
|
+
* user in the funnel.
|
|
81
|
+
*/
|
|
82
|
+
export type CustomPaywallScreens = Record<string, ComponentType<CustomPaywallScreenProps>>;
|
package/src/paywalls/types.ts
CHANGED
|
@@ -43,8 +43,61 @@ export type Paywall = {
|
|
|
43
43
|
stripe?: StripeProductRef;
|
|
44
44
|
}>;
|
|
45
45
|
configuration: Record<string, unknown> | null;
|
|
46
|
+
/**
|
|
47
|
+
* Who draws this paywall. `"elements"` (the default) renders the authored
|
|
48
|
+
* `elements` tree; `"custom"` hands it to a screen the HOST registered under
|
|
49
|
+
* `customScreenId` (see `PaywallHost`'s `customScreens` prop in the UI
|
|
50
|
+
* package), and `elements` is then ignored entirely.
|
|
51
|
+
*
|
|
52
|
+
* A property of the PAYWALL, not the moment — the same reasoning as
|
|
53
|
+
* `billing` above: one moment audience can weight an element-tree variant
|
|
54
|
+
* against a native-screen variant and ramp the change as an A/B test.
|
|
55
|
+
*
|
|
56
|
+
* OPTIONAL, and absent means `"elements"`. Not because the studio omits it
|
|
57
|
+
* (it always sends a value) but because a device on a NEW SDK can be talking
|
|
58
|
+
* to an OLDER `get-paywalls` that predates the field. Treating absent as
|
|
59
|
+
* `"custom"`, or as an error, would break every existing paywall on that
|
|
60
|
+
* pairing; treating it as `"elements"` is exactly the old behaviour.
|
|
61
|
+
*/
|
|
62
|
+
renderMode?: "elements" | "custom";
|
|
63
|
+
/**
|
|
64
|
+
* Which host-registered screen renders this paywall. Meaningful only when
|
|
65
|
+
* `renderMode` is `"custom"`.
|
|
66
|
+
*
|
|
67
|
+
* Nullable as well as optional: the studio accepts a custom paywall with no
|
|
68
|
+
* screen id (it warns rather than refusing), so an empty value is a state
|
|
69
|
+
* that genuinely arrives. `PaywallHost` reports it as
|
|
70
|
+
* `{ status: "error", reason: "unknown-custom-screen" }` rather than opening
|
|
71
|
+
* an empty full-screen Modal.
|
|
72
|
+
*/
|
|
73
|
+
customScreenId?: string | null;
|
|
74
|
+
/**
|
|
75
|
+
* The product map handed to that screen: slot key to per-platform store
|
|
76
|
+
* product id. This is the one thing a native paywall cannot get from
|
|
77
|
+
* anywhere else — the moment waterfall picked THIS variant, and which
|
|
78
|
+
* products it offers is an authoring decision, not something compiled into
|
|
79
|
+
* the app.
|
|
80
|
+
*
|
|
81
|
+
* Deliberately NOT the same thing as `products` above. Those slots exist to
|
|
82
|
+
* feed `{{product.<key>.price}}` interpolation into an element tree, and a
|
|
83
|
+
* custom screen has no interpolation — so a custom paywall carries product
|
|
84
|
+
* IDS and no prices, and the SDK resolves no store products for it at all
|
|
85
|
+
* (`collectProductRefs` does not walk this map). A native paywall asks the
|
|
86
|
+
* store for its own display prices, which is exactly what it does not need
|
|
87
|
+
* the studio for.
|
|
88
|
+
*/
|
|
89
|
+
customPayload?: PaywallCustomPayload;
|
|
46
90
|
};
|
|
47
91
|
|
|
92
|
+
/**
|
|
93
|
+
* `Paywall.customPayload` — slot key to per-platform product id.
|
|
94
|
+
*
|
|
95
|
+
* Both platform fields are optional: a paywall shipped on one platform only is
|
|
96
|
+
* legitimate, and so is a key whose ids have not been filled in yet (the
|
|
97
|
+
* studio warns about that rather than refusing to save it).
|
|
98
|
+
*/
|
|
99
|
+
export type PaywallCustomPayload = Record<string, { ios?: string; android?: string }>;
|
|
100
|
+
|
|
48
101
|
/** Full response body of `GET get-paywalls`. */
|
|
49
102
|
export type PaywallCatalog = {
|
|
50
103
|
metadata: {
|
|
@@ -153,6 +206,14 @@ export interface GetPaywallsResponseHeaders {
|
|
|
153
206
|
* Modal, a `presentation: "modal"` route, a StoreKit alert).
|
|
154
207
|
* - `paywall-disappeared` — the moment vanished from the catalog while it
|
|
155
208
|
* was on screen (a studio publish, or a query-key change mid-presentation).
|
|
209
|
+
* - `unknown-custom-screen` — the paywall is `renderMode: "custom"` and names
|
|
210
|
+
* a `customScreenId` this host did not register (or names none at all), so
|
|
211
|
+
* there was nothing to render and the Modal was never opened. Deliberately
|
|
212
|
+
* NOT folded into `parse-error`: that one is a CMS **data** bug the author
|
|
213
|
+
* must fix, this is a HOST **wiring** bug the app must fix — opposite
|
|
214
|
+
* remedies, and conflating them is the exact mistake this union's split
|
|
215
|
+
* already exists to avoid. `PaywallHost` logs both the missing id and the
|
|
216
|
+
* ids that ARE registered, which is usually the whole diagnosis.
|
|
156
217
|
*/
|
|
157
218
|
export type PresentErrorReason =
|
|
158
219
|
| "unknown-moment"
|
|
@@ -160,7 +221,8 @@ export type PresentErrorReason =
|
|
|
160
221
|
| "parse-error"
|
|
161
222
|
| "render-error"
|
|
162
223
|
| "host-never-presented"
|
|
163
|
-
| "paywall-disappeared"
|
|
224
|
+
| "paywall-disappeared"
|
|
225
|
+
| "unknown-custom-screen";
|
|
164
226
|
|
|
165
227
|
export type PresentResult = {
|
|
166
228
|
status: "purchased" | "dismissed" | "cancelled" | "error";
|
|
@@ -3,6 +3,7 @@ import { PaywallContext } from "./PaywallProvider";
|
|
|
3
3
|
import { PaywallCatalog, PresentResult } from "./types";
|
|
4
4
|
import type { CatalogStatus } from "./present";
|
|
5
5
|
import type { ProductStatus } from "../products/types";
|
|
6
|
+
import type { CustomPaywallScreens } from "./customScreens";
|
|
6
7
|
|
|
7
8
|
export type UsePaywallResult = {
|
|
8
9
|
/**
|
|
@@ -36,6 +37,19 @@ export type UsePaywallResult = {
|
|
|
36
37
|
* host tell "still waiting on the store" from "still waiting on us".
|
|
37
38
|
*/
|
|
38
39
|
productsStatus: ProductStatus;
|
|
40
|
+
/**
|
|
41
|
+
* Whether a real `PaywallProvider` is above this consumer — see the field's
|
|
42
|
+
* doc on `PaywallContextValue`. Needed by any consumer that renders a
|
|
43
|
+
* spinner while the catalog loads, because with no provider
|
|
44
|
+
* `catalogStatus` reports `"loading"` and nothing ever arrives.
|
|
45
|
+
*/
|
|
46
|
+
isProviderMounted: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Host-registered screens for `renderMode: "custom"` paywalls, keyed by
|
|
49
|
+
* `customScreenId`. Exposed here because the inline `Paywall` onboarding
|
|
50
|
+
* step renders them itself, never going through `PaywallHost`.
|
|
51
|
+
*/
|
|
52
|
+
customScreens: CustomPaywallScreens;
|
|
39
53
|
};
|
|
40
54
|
|
|
41
55
|
/**
|
|
@@ -45,7 +59,15 @@ export type UsePaywallResult = {
|
|
|
45
59
|
* `useProductRuntime()` degrades to `null` with no ancestor.
|
|
46
60
|
*/
|
|
47
61
|
export const usePaywall = (): UsePaywallResult => {
|
|
48
|
-
const { present, isReady, catalog, catalogStatus, productsStatus } =
|
|
62
|
+
const { present, isReady, catalog, catalogStatus, productsStatus, isProviderMounted, customScreens } =
|
|
49
63
|
useContext(PaywallContext);
|
|
50
|
-
return {
|
|
64
|
+
return {
|
|
65
|
+
present,
|
|
66
|
+
isReady,
|
|
67
|
+
catalog,
|
|
68
|
+
catalogStatus,
|
|
69
|
+
productsStatus,
|
|
70
|
+
isProviderMounted,
|
|
71
|
+
customScreens,
|
|
72
|
+
};
|
|
51
73
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BaseStepTypeSchema } from "../common.types";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A step that IS a paywall.
|
|
6
|
+
*
|
|
7
|
+
* `moment` is a `moments.key` — the same address a host passes to `present()`.
|
|
8
|
+
* It resolves through the catalog `get-paywalls` already returns keyed by
|
|
9
|
+
* moment, which means the audience waterfall has ALREADY picked the variant:
|
|
10
|
+
* targeting and weighted A/B come for free, and this payload needs exactly one
|
|
11
|
+
* field. No wire change was required anywhere for this step type.
|
|
12
|
+
*
|
|
13
|
+
* Deliberately not a paywall id: that would bypass the waterfall, so
|
|
14
|
+
* A/B-testing a paywall inside an onboarding would mean duplicating the whole
|
|
15
|
+
* onboarding.
|
|
16
|
+
*
|
|
17
|
+
* Rendered inline by the UI package's `Pages/Paywall/Renderer.tsx`, and
|
|
18
|
+
* HARD-GATED — only a purchase advances past it.
|
|
19
|
+
*/
|
|
20
|
+
export const PaywallStepPayloadSchema = z.object({
|
|
21
|
+
moment: z.string().min(1),
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
export const PaywallStepTypeSchema = BaseStepTypeSchema.extend({
|
|
25
|
+
type: z.literal("Paywall"),
|
|
26
|
+
payload: PaywallStepPayloadSchema,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type PaywallStepType = z.infer<typeof PaywallStepTypeSchema>;
|
package/src/steps/types.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { CommitmentStepType } from "./Commitment/types";
|
|
|
3
3
|
import { LoaderStepType } from "./Loader/types";
|
|
4
4
|
import { MediaContentStepType } from "./MediaContent/types";
|
|
5
5
|
import { ComposableScreenStepType } from "./ComposableScreen/types";
|
|
6
|
+
import { PaywallStepType } from "./Paywall/types";
|
|
6
7
|
import { PickerStepType } from "./Picker/types";
|
|
7
8
|
import { QuestionStepType } from "./Question/types";
|
|
8
9
|
import { RatingsStepType } from "./Ratings/types";
|
|
@@ -13,6 +14,7 @@ export type OnboardingStepType =
|
|
|
13
14
|
| LoaderStepType
|
|
14
15
|
| MediaContentStepType
|
|
15
16
|
| ComposableScreenStepType
|
|
17
|
+
| PaywallStepType
|
|
16
18
|
| PickerStepType
|
|
17
19
|
| QuestionStepType
|
|
18
20
|
| RatingsStepType;
|