@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.types.d.ts","sourceRoot":"","sources":["../../src/steps/common.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB,kEAA0C,CAAC;AAE3E,eAAO,MAAM,iBAAiB;;;;;;mBAS5B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;iBAI5B,CAAC;AAEH,eAAO,MAAM,aAAa;;;iBAGxB,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;iBAG9B,CAAC;AAMH,eAAO,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ports.BranchSchema = exports.ConditionGroupSchema = exports.LeafConditionSchema = exports.ConditionValueSchema = exports.isUnaryConditionOperator = exports.UNARY_CONDITION_OPERATORS = exports.ConditionOperatorSchema = exports.ButtonActionSchema = exports.RestoreButtonActionSchema = exports.PurchaseButtonActionSchema = exports.SetVariableButtonActionSchema = exports.CustomButtonActionSchema = exports.HapticStyleSchema = exports.ButtonSectionSchema = exports.InfoBoxSchema = exports.SocialProofSchema = exports.MediaSourceSchema = exports.CustomPayloadSchema = void 0;
|
|
3
|
+
exports.BaseStepTypeSchema = exports.ONBOARDING_END_STEP_ID = exports.NextStepSchema = exports.BranchSchema = exports.ConditionGroupSchema = exports.LeafConditionSchema = exports.ConditionValueSchema = exports.isUnaryConditionOperator = exports.UNARY_CONDITION_OPERATORS = exports.ConditionOperatorSchema = exports.ButtonActionSchema = exports.RestoreButtonActionSchema = exports.PurchaseButtonActionSchema = exports.PresentPaywallButtonActionSchema = exports.DismissButtonActionSchema = exports.SetVariableButtonActionSchema = exports.CustomButtonActionSchema = exports.HapticStyleSchema = exports.ButtonSectionSchema = exports.InfoBoxSchema = exports.SocialProofSchema = exports.MediaSourceSchema = exports.CustomPayloadSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.CustomPayloadSchema = zod_1.z.record(zod_1.z.string(), zod_1.z.any()).nullish();
|
|
6
6
|
exports.MediaSourceSchema = zod_1.z.union([
|
|
@@ -52,6 +52,13 @@ exports.SetVariableButtonActionSchema = zod_1.z.object({
|
|
|
52
52
|
kind: zod_1.z.enum(["int", "float", "string"]).optional(),
|
|
53
53
|
arrayOp: zod_1.z.enum(["append", "remove", "toggle"]).optional(),
|
|
54
54
|
});
|
|
55
|
+
exports.DismissButtonActionSchema = zod_1.z.object({
|
|
56
|
+
type: zod_1.z.literal("dismiss"),
|
|
57
|
+
});
|
|
58
|
+
exports.PresentPaywallButtonActionSchema = zod_1.z.object({
|
|
59
|
+
type: zod_1.z.literal("presentPaywall"),
|
|
60
|
+
placement: zod_1.z.string().min(1, "placement must not be empty"),
|
|
61
|
+
});
|
|
55
62
|
exports.PurchaseButtonActionSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
56
63
|
type: zod_1.z.literal("purchase"),
|
|
57
64
|
product: zod_1.z.string().min(1, "product must not be empty"),
|
|
@@ -71,6 +78,8 @@ exports.ButtonActionSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
|
71
78
|
exports.SetVariableButtonActionSchema,
|
|
72
79
|
exports.PurchaseButtonActionSchema,
|
|
73
80
|
exports.RestoreButtonActionSchema,
|
|
81
|
+
exports.DismissButtonActionSchema,
|
|
82
|
+
exports.PresentPaywallButtonActionSchema,
|
|
74
83
|
]));
|
|
75
84
|
// ── Branching / nextStep schemas ─────────────────────────────────────────────
|
|
76
85
|
exports.ConditionOperatorSchema = zod_1.z.enum([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.types.js","sourceRoot":"","sources":["../../src/steps/common.types.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC,OAAC,CAAC,MAAM,EAAE,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;AAE9D,QAAA,iBAAiB,GAAG,OAAC,CAAC,KAAK,CAAC;IACvC,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,OAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC7F,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE;KACxB,CAAC;IACF,OAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,C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;KACD,QAAQ,EAAE;KACV,OAAO,CAAC,IAAI,CAAC,CAAC;AAGjB;;;;;;GAMG;AACU,QAAA,sBAAsB,GAAG,SAAS,CAAC;AAEhD,iFAAiF;AAEpE,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACzC,2EAA2E;IAC3E,qEAAqE;IACrE,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,8BAAsB,EAAE;QACzD,OAAO,EAAE,IAAI,8BAAsB,8EAA8E;KAClH,CAAC;IACF,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,qBAAqB,EAAE,OAAC,CAAC,OAAO,EAAE;IAClC,aAAa,EAAE,2BAAmB;IAClC,mBAAmB,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;IAC9D,aAAa,EAAE,2BAAmB,CAAC,QAAQ,EAAE;IAC7C,QAAQ,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;IAC9B,QAAQ,EAAE,sBAAc;CACzB,CAAC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -51,7 +51,80 @@ export interface OnboardingMetadata {
|
|
|
51
51
|
* (e.g. theme, fonts, entry point). Kept permissive — only the fields the SDK
|
|
52
52
|
* reads are typed; everything else the studio ships passes through untouched.
|
|
53
53
|
*/
|
|
54
|
+
/**
|
|
55
|
+
* Studio-authored styling for the onboarding progress header.
|
|
56
|
+
*
|
|
57
|
+
* Exists so "change the progress bar colour" is a Studio publish rather than an
|
|
58
|
+
* app release. Before this, `ProgressBar` exposed only `backgroundColor` /
|
|
59
|
+
* `progressColor` as props and hardcoded everything else (height 12, radius 10,
|
|
60
|
+
* the 1/5/1 three-column layout, paddings, back-chevron size), so a project
|
|
61
|
+
* needing a different bar forked its own component.
|
|
62
|
+
*
|
|
63
|
+
* Every field is optional; an omitted field falls back to the previous
|
|
64
|
+
* behaviour. Resolution order in `ProgressBar` is:
|
|
65
|
+
* explicit prop > this block > theme > hardcoded default
|
|
66
|
+
* This block deliberately outranks the theme because a theme-only knob could not
|
|
67
|
+
* reach the screen at all today: `ThemeProvider` is fed solely by the host's
|
|
68
|
+
* `customTheme`/`customLightTheme`/`customDarkTheme` props, and nothing in the SDK
|
|
69
|
+
* reads `configuration.theme` — the edge function delivers the field and no
|
|
70
|
+
* consumer exists, so the host theme is the only theme at runtime. Wiring
|
|
71
|
+
* `configuration.theme` into `ThemeProvider` (config below host props, mirroring
|
|
72
|
+
* the order here) is a known open item; until then this block is the only way
|
|
73
|
+
* Studio can restyle the header.
|
|
74
|
+
*/
|
|
75
|
+
export interface ProgressHeaderConfiguration {
|
|
76
|
+
/** Track (unfilled) colour. Defaults to `theme.colors.neutral.lower`. */
|
|
77
|
+
backgroundColor?: string;
|
|
78
|
+
/** Filled colour. Defaults to `theme.colors.primary`. */
|
|
79
|
+
progressColor?: string;
|
|
80
|
+
/** Track thickness in px. Defaults to 12. */
|
|
81
|
+
height?: number;
|
|
82
|
+
/** Track corner radius in px. Defaults to half the height (fully rounded). */
|
|
83
|
+
borderRadius?: number;
|
|
84
|
+
/** Horizontal padding around the whole header row in px. Defaults to 16. */
|
|
85
|
+
paddingHorizontal?: number;
|
|
86
|
+
/** Space below the bar in px. Defaults to 24. */
|
|
87
|
+
paddingBottom?: number;
|
|
88
|
+
/** Gap between the back button, track and right spacer in px. Defaults to 16. */
|
|
89
|
+
gap?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Width of the track relative to the side columns, as flex units. The header is
|
|
92
|
+
* a three-column row (back button / track / spacer) that defaults to 1 / 5 / 1;
|
|
93
|
+
* this sets the middle number. Larger = wider track.
|
|
94
|
+
*/
|
|
95
|
+
trackFlex?: number;
|
|
96
|
+
/** Back-chevron colour. Defaults to `theme.colors.text.primary`. */
|
|
97
|
+
backButtonColor?: string;
|
|
98
|
+
/** Back-chevron **glyph** size in px. Defaults to 24. See `backButtonContainerSize`. */
|
|
99
|
+
backButtonSize?: number;
|
|
100
|
+
/** Hide the back chevron even when the router can go back. Defaults to false. */
|
|
101
|
+
hideBackButton?: boolean;
|
|
102
|
+
/** Container fill. Unset = transparent (previous behaviour). */
|
|
103
|
+
backButtonBackgroundColor?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Container border colour. Setting this alone implies `backButtonBorderWidth: 1`
|
|
106
|
+
* — RN defaults border width to 0, so a lone colour would otherwise draw
|
|
107
|
+
* nothing. Same convenience `buildShadowStyle` applies to `shadowColor`.
|
|
108
|
+
*/
|
|
109
|
+
backButtonBorderColor?: string;
|
|
110
|
+
/** Container border width in px. Defaults to 1 when `backButtonBorderColor` is set, else 0. */
|
|
111
|
+
backButtonBorderWidth?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Container width AND height in px — the button is square. Setting it also
|
|
114
|
+
* centres the glyph inside the box and drops the default padding, so the
|
|
115
|
+
* rendered size is exactly this value (e.g. 32 for a 32x32 chip).
|
|
116
|
+
*/
|
|
117
|
+
backButtonContainerSize?: number;
|
|
118
|
+
/** Container corner radius in px. Half of `backButtonContainerSize` makes a circle. */
|
|
119
|
+
backButtonBorderRadius?: number;
|
|
120
|
+
}
|
|
54
121
|
export interface OnboardingConfiguration {
|
|
122
|
+
/**
|
|
123
|
+
* Studio-authored progress-header styling. Read directly off `configuration`
|
|
124
|
+
* (the edge function returns the whole configuration blob top-level), so it
|
|
125
|
+
* needs no backend change to start arriving.
|
|
126
|
+
*/
|
|
127
|
+
progressHeader?: ProgressHeaderConfiguration;
|
|
55
128
|
/**
|
|
56
129
|
* Id of the unique step the onboarding starts on. Read first to resolve the
|
|
57
130
|
* entry point (see `resolveStartStepNumber`). Optional; when absent or when it
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KA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AAkB,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CAAC;AAExE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,GAAG,gBAAgB,EAAE,CAAC;AAE9E,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;AAEpE,MAAM,WAAW,UAAU,CAAC,QAAQ,SAAS,YAAY,GAAG,YAAY;IACtE,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,aAAa,EAAE,uBAAuB,CAAC;IACvC,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;CACvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocapine/react-native-onboarding",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.63.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",
|
|
@@ -8,7 +8,15 @@ import {
|
|
|
8
8
|
UserDefinedParams,
|
|
9
9
|
BaseStepType,
|
|
10
10
|
} from "./types";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getOnboardingCacheKey,
|
|
13
|
+
getPaywallsCacheKey,
|
|
14
|
+
} from "./infra/queries/cacheKey";
|
|
15
|
+
import {
|
|
16
|
+
PaywallCatalog,
|
|
17
|
+
PaywallOptions,
|
|
18
|
+
GetPaywallsResponseHeaders,
|
|
19
|
+
} from "./paywalls/types";
|
|
12
20
|
|
|
13
21
|
import { Platform } from "react-native";
|
|
14
22
|
|
|
@@ -27,14 +35,18 @@ export class OnboardingStudioClient {
|
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
/**
|
|
30
|
-
* Removes this client's cached onboarding payload
|
|
31
|
-
* derived from `options.cacheKey`, or the
|
|
32
|
-
* or app launch is then a cache miss
|
|
33
|
-
* refetch as well, also
|
|
34
|
-
* `["onboardingQuestions", ...]
|
|
38
|
+
* Removes this client's cached onboarding payload AND cached paywall catalog
|
|
39
|
+
* from AsyncStorage (the keys derived from `options.cacheKey`, or the
|
|
40
|
+
* default keys). The next query mount or app launch is then a cache miss
|
|
41
|
+
* and refetches both. To force an in-session refetch as well, also
|
|
42
|
+
* invalidate the React Query keys `["onboardingQuestions", ...]` and
|
|
43
|
+
* `["paywallCatalog", ...]`.
|
|
35
44
|
*/
|
|
36
45
|
async clearCache(): Promise<void> {
|
|
37
|
-
await
|
|
46
|
+
await Promise.all([
|
|
47
|
+
AsyncStorage.removeItem(getOnboardingCacheKey(this.options.cacheKey)),
|
|
48
|
+
AsyncStorage.removeItem(getPaywallsCacheKey(this.options.cacheKey)),
|
|
49
|
+
]);
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
async getSteps<StepType extends BaseStepType = OnboardingStepType>(
|
|
@@ -115,4 +127,95 @@ export class OnboardingStudioClient {
|
|
|
115
127
|
throw error;
|
|
116
128
|
}
|
|
117
129
|
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Fetches the paywall catalog for this project/audience/locale from
|
|
133
|
+
* `get-paywalls`. By design **omits `placement` by default** — the endpoint
|
|
134
|
+
* deliberately returns every placement in one round-trip so a paywall can
|
|
135
|
+
* be presented the instant the user taps upgrade, without a network call at
|
|
136
|
+
* that moment (spec §6.1). Pass `paywallOptions.placement` only when a
|
|
137
|
+
* single placement is genuinely all that's needed.
|
|
138
|
+
*
|
|
139
|
+
* Unlike `getSteps`, there is no fallback-payload option here: a
|
|
140
|
+
* non-`ok` response or a network failure always rejects rather than
|
|
141
|
+
* resolving to a stand-in catalog.
|
|
142
|
+
*/
|
|
143
|
+
async getPaywalls(
|
|
144
|
+
paywallOptions?: PaywallOptions,
|
|
145
|
+
userDefinedParams?: UserDefinedParams
|
|
146
|
+
): Promise<{ data: PaywallCatalog; headers: GetPaywallsResponseHeaders }> {
|
|
147
|
+
console.info("OnboardingStudioClient getPaywalls");
|
|
148
|
+
const isSandbox = this.options.isSandbox;
|
|
149
|
+
|
|
150
|
+
const urlParams = new URLSearchParams();
|
|
151
|
+
// Add userDefinedParams to URL
|
|
152
|
+
if (userDefinedParams) {
|
|
153
|
+
Object.entries(userDefinedParams).forEach(([key, value]) => {
|
|
154
|
+
urlParams.append(key, value);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
urlParams.append("projectId", this.projectId);
|
|
159
|
+
urlParams.append("platform", Platform.OS);
|
|
160
|
+
|
|
161
|
+
const appVersion = this.options.appVersion; // TODO get the version from the expo app
|
|
162
|
+
if (appVersion) {
|
|
163
|
+
urlParams.append("appVersion", appVersion);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (isSandbox) {
|
|
167
|
+
urlParams.append("draft", "true");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Add paywallOptions to URL
|
|
171
|
+
if (paywallOptions?.locale) {
|
|
172
|
+
urlParams.append("locale", paywallOptions.locale);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Narrows the response to a single paywall. Omitted unless explicitly
|
|
176
|
+
// requested — see the method doc above.
|
|
177
|
+
if (paywallOptions?.placement) {
|
|
178
|
+
urlParams.append("placement", paywallOptions.placement);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Deliberately NOT sending spec §6.1's `omitNulls=true`: it's a
|
|
182
|
+
// convenience for untyped consumers that strips null-valued keys from the
|
|
183
|
+
// response, which would make the runtime shape diverge from `PaywallCatalog`
|
|
184
|
+
// and `Paywall`'s declared `| null` fields. This client parses into those
|
|
185
|
+
// typed objects, so the fields must always be present (possibly `null`),
|
|
186
|
+
// not sometimes missing.
|
|
187
|
+
const url = `${this.baseUrl}/get-paywalls?${urlParams.toString()}`;
|
|
188
|
+
console.info("OnboardingStudioClient getPaywalls url", url);
|
|
189
|
+
try {
|
|
190
|
+
const response = await Promise.race(
|
|
191
|
+
this.options.timeout
|
|
192
|
+
? [
|
|
193
|
+
fetch(url),
|
|
194
|
+
new Promise<Response>((_, reject) =>
|
|
195
|
+
setTimeout(
|
|
196
|
+
() => reject(new Error("timeout")),
|
|
197
|
+
this.options.timeout
|
|
198
|
+
)
|
|
199
|
+
),
|
|
200
|
+
]
|
|
201
|
+
: [fetch(url)]
|
|
202
|
+
);
|
|
203
|
+
if (!response.ok) {
|
|
204
|
+
throw new Error(
|
|
205
|
+
`Failed to fetch paywalls: ${response.status} ${response.statusText}`
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
const data = await response.json();
|
|
209
|
+
return {
|
|
210
|
+
data,
|
|
211
|
+
headers: {
|
|
212
|
+
"ONBS-Audience-Id": response.headers.get("ONBS-Audience-Id"),
|
|
213
|
+
"ONBS-Paywall-Ids": response.headers.get("ONBS-Paywall-Ids"),
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.error("OnboardingStudioClient getPaywalls error", error);
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
118
221
|
}
|
|
@@ -168,3 +168,107 @@ describe("extractAssetUrls — robustness", () => {
|
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
});
|
|
171
|
+
|
|
172
|
+
describe("extractAssetUrls — {{var}} templates and Repeat rows", () => {
|
|
173
|
+
it("skips an unresolved template url instead of prefetching it literally", () => {
|
|
174
|
+
// An `Image` with mode:"expression" holds a template, not an address.
|
|
175
|
+
// Prefetching it fires a guaranteed 404 for the literal string.
|
|
176
|
+
const step = {
|
|
177
|
+
type: "ComposableScreen",
|
|
178
|
+
payload: {
|
|
179
|
+
elements: [
|
|
180
|
+
{ type: "Image", props: { url: "https://cdn/zodiac/{{sign}}.png", mode: "expression" } },
|
|
181
|
+
{ type: "Image", props: { url: "https://cdn/static.png" } },
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
expect(byUrl(extractAssetUrls(onb([step])))).toEqual({
|
|
186
|
+
"https://cdn/static.png": "image",
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("resolves a Repeat template against each row so repeated media still preloads", () => {
|
|
191
|
+
const step = {
|
|
192
|
+
type: "ComposableScreen",
|
|
193
|
+
payload: {
|
|
194
|
+
elements: [
|
|
195
|
+
{
|
|
196
|
+
type: "Repeat",
|
|
197
|
+
props: {
|
|
198
|
+
keyField: "sign",
|
|
199
|
+
data: [
|
|
200
|
+
{ sign: "aries", art: "https://cdn/z/aries.png" },
|
|
201
|
+
{ sign: "leo", art: "https://cdn/z/leo.png" },
|
|
202
|
+
],
|
|
203
|
+
},
|
|
204
|
+
children: [
|
|
205
|
+
{ type: "Image", props: { url: "{{item.art}}", mode: "expression" } },
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
expect(byUrl(extractAssetUrls(onb([step])))).toEqual({
|
|
212
|
+
"https://cdn/z/aries.png": "image",
|
|
213
|
+
"https://cdn/z/leo.png": "image",
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("honours a custom `as` scope and resolves nested children", () => {
|
|
218
|
+
const step = {
|
|
219
|
+
type: "ComposableScreen",
|
|
220
|
+
payload: {
|
|
221
|
+
elements: [
|
|
222
|
+
{
|
|
223
|
+
type: "Repeat",
|
|
224
|
+
props: { as: "girl", data: [{ id: "a", photo: "https://cdn/g/a.png" }] },
|
|
225
|
+
children: [
|
|
226
|
+
{
|
|
227
|
+
type: "YStack",
|
|
228
|
+
props: {},
|
|
229
|
+
children: [{ type: "Image", props: { url: "{{girl.photo}}" } }],
|
|
230
|
+
},
|
|
231
|
+
],
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
expect(byUrl(extractAssetUrls(onb([step])))).toEqual({
|
|
237
|
+
"https://cdn/g/a.png": "image",
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it("leaves a non-row variable unresolved, so it is skipped rather than mis-fetched", () => {
|
|
242
|
+
const step = {
|
|
243
|
+
type: "ComposableScreen",
|
|
244
|
+
payload: {
|
|
245
|
+
elements: [
|
|
246
|
+
{
|
|
247
|
+
type: "Repeat",
|
|
248
|
+
props: { data: [{ art: "https://cdn/z/aries.png" }] },
|
|
249
|
+
children: [
|
|
250
|
+
{ type: "Image", props: { url: "{{item.art}}" } },
|
|
251
|
+
// references a runtime variable, not the row — still unknowable
|
|
252
|
+
{ type: "Image", props: { url: "https://cdn/{{userTheme}}/bg.png" } },
|
|
253
|
+
],
|
|
254
|
+
},
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
expect(byUrl(extractAssetUrls(onb([step])))).toEqual({
|
|
259
|
+
"https://cdn/z/aries.png": "image",
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("a Repeat with no data contributes nothing", () => {
|
|
264
|
+
const step = {
|
|
265
|
+
type: "ComposableScreen",
|
|
266
|
+
payload: {
|
|
267
|
+
elements: [
|
|
268
|
+
{ type: "Repeat", props: { data: [] }, children: [{ type: "Image", props: { url: "{{item.art}}" } }] },
|
|
269
|
+
],
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
expect(extractAssetUrls(onb([step]))).toEqual([]);
|
|
273
|
+
});
|
|
274
|
+
});
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { mergeProductRuntimes } from "../products/mergeProductRuntimes";
|
|
3
|
+
import type { ProductRuntime, ProductWithDerived } from "../products/types";
|
|
4
|
+
|
|
5
|
+
const product = (key: string): ProductWithDerived => ({
|
|
6
|
+
key,
|
|
7
|
+
productId: `com.app.${key}`,
|
|
8
|
+
store: "app_store",
|
|
9
|
+
title: key,
|
|
10
|
+
description: key,
|
|
11
|
+
price: "$1.99",
|
|
12
|
+
priceAmount: 1.99,
|
|
13
|
+
currencyCode: "USD",
|
|
14
|
+
period: null,
|
|
15
|
+
periodCount: 1,
|
|
16
|
+
periodIso: null,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const makeRuntime = (overrides: Partial<ProductRuntime> = {}): ProductRuntime => ({
|
|
20
|
+
products: {},
|
|
21
|
+
status: "idle",
|
|
22
|
+
purchasing: false,
|
|
23
|
+
purchase: async () => ({ status: "cancelled" }),
|
|
24
|
+
restore: async () => ({ status: "nothing_to_restore" }),
|
|
25
|
+
...overrides,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Finding 5, 2026-08-17 final review: `OnboardingProvider` publishes ONE of
|
|
29
|
+
// two ProductRuntimes (the shared `PaywallProvider` context one, or its own
|
|
30
|
+
// local `useProducts` call) — never both — so a host's own `productRefs`
|
|
31
|
+
// resolved locally were invisible whenever a context runtime existed. This
|
|
32
|
+
// function is the fix: it unions the two into one runtime.
|
|
33
|
+
describe("mergeProductRuntimes", () => {
|
|
34
|
+
it("returns the context runtime UNCHANGED when there are no local refs to add — the common case", () => {
|
|
35
|
+
const contextRuntime = makeRuntime({ products: { yearly: product("yearly") }, status: "ready" });
|
|
36
|
+
const localRuntime = makeRuntime();
|
|
37
|
+
|
|
38
|
+
const result = mergeProductRuntimes(contextRuntime, localRuntime, false, true);
|
|
39
|
+
|
|
40
|
+
expect(result).toBe(contextRuntime);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("unions both runtimes' products when the host declared local productRefs", () => {
|
|
44
|
+
const contextRuntime = makeRuntime({ products: { yearly: product("yearly") }, status: "ready" });
|
|
45
|
+
const localRuntime = makeRuntime({ products: { lifetime: product("lifetime") }, status: "ready" });
|
|
46
|
+
|
|
47
|
+
const result = mergeProductRuntimes(contextRuntime, localRuntime, true, true);
|
|
48
|
+
|
|
49
|
+
expect(result.products).toEqual({
|
|
50
|
+
yearly: product("yearly"),
|
|
51
|
+
lifetime: product("lifetime"),
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("is not ready until BOTH runtimes are ready", () => {
|
|
56
|
+
const contextRuntime = makeRuntime({ status: "ready" });
|
|
57
|
+
const localRuntime = makeRuntime({ status: "loading" });
|
|
58
|
+
|
|
59
|
+
expect(mergeProductRuntimes(contextRuntime, localRuntime, true, true).status).toBe("loading");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("reports 'error' if either runtime errored", () => {
|
|
63
|
+
const contextRuntime = makeRuntime({ status: "ready" });
|
|
64
|
+
const localRuntime = makeRuntime({ status: "error", error: "boom" });
|
|
65
|
+
|
|
66
|
+
const result = mergeProductRuntimes(contextRuntime, localRuntime, true, true);
|
|
67
|
+
expect(result.status).toBe("error");
|
|
68
|
+
expect(result.error).toBe("boom");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("is 'ready' once both runtimes resolved", () => {
|
|
72
|
+
const contextRuntime = makeRuntime({ status: "ready" });
|
|
73
|
+
const localRuntime = makeRuntime({ status: "ready" });
|
|
74
|
+
|
|
75
|
+
expect(mergeProductRuntimes(contextRuntime, localRuntime, true, true).status).toBe("ready");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// N3, round 2 of the final review: productRefs declared with no local
|
|
79
|
+
// productProvider is a real, unremarkable configuration (the shared context
|
|
80
|
+
// runtime is expected to cover it) — useProducts then never leaves the
|
|
81
|
+
// local runtime's status at anything but "idle" (it bails before ever
|
|
82
|
+
// calling a provider it doesn't have). A naive mergeStatus would drag the
|
|
83
|
+
// context runtime's "ready" down to "idle" forever, closing every
|
|
84
|
+
// renderWhen gate on products.loaded for the life of the component.
|
|
85
|
+
it("hasLocalProvider=false: merged status is the context runtime's alone, not dragged down by a permanently-idle local runtime", () => {
|
|
86
|
+
const contextRuntime = makeRuntime({ status: "ready", products: { yearly: product("yearly") } });
|
|
87
|
+
const localRuntime = makeRuntime({ status: "idle" });
|
|
88
|
+
|
|
89
|
+
const result = mergeProductRuntimes(contextRuntime, localRuntime, true, false);
|
|
90
|
+
|
|
91
|
+
expect(result.status).toBe("ready");
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("hasLocalProvider=false: still surfaces the context runtime's error, since that's a real failure", () => {
|
|
95
|
+
const contextRuntime = makeRuntime({ status: "error", error: "boom" });
|
|
96
|
+
const localRuntime = makeRuntime({ status: "idle" });
|
|
97
|
+
|
|
98
|
+
const result = mergeProductRuntimes(contextRuntime, localRuntime, true, false);
|
|
99
|
+
|
|
100
|
+
expect(result.status).toBe("error");
|
|
101
|
+
expect(result.error).toBe("boom");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("purchasing is true if EITHER runtime is mid-purchase", () => {
|
|
105
|
+
const contextRuntime = makeRuntime({ purchasing: false });
|
|
106
|
+
const localRuntime = makeRuntime({ purchasing: true });
|
|
107
|
+
|
|
108
|
+
expect(mergeProductRuntimes(contextRuntime, localRuntime, true, true).purchasing).toBe(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("purchase() routes a key resolved by the LOCAL runtime through the local provider", async () => {
|
|
112
|
+
let calledLocal = false;
|
|
113
|
+
const contextRuntime = makeRuntime({
|
|
114
|
+
products: { yearly: product("yearly") },
|
|
115
|
+
purchase: async () => {
|
|
116
|
+
throw new Error("must not call context purchase for a local-only key");
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
const localRuntime = makeRuntime({
|
|
120
|
+
products: { lifetime: product("lifetime") },
|
|
121
|
+
purchase: async (key) => {
|
|
122
|
+
calledLocal = true;
|
|
123
|
+
return { status: "purchased", productKey: key };
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const result = await mergeProductRuntimes(contextRuntime, localRuntime, true, true).purchase("lifetime");
|
|
128
|
+
|
|
129
|
+
expect(calledLocal).toBe(true);
|
|
130
|
+
expect(result).toEqual({ status: "purchased", productKey: "lifetime" });
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("purchase() routes anything else — including an unknown key — through the context runtime", async () => {
|
|
134
|
+
let calledContext = false;
|
|
135
|
+
const contextRuntime = makeRuntime({
|
|
136
|
+
products: { yearly: product("yearly") },
|
|
137
|
+
purchase: async (key) => {
|
|
138
|
+
calledContext = true;
|
|
139
|
+
return { status: "purchased", productKey: key };
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
const localRuntime = makeRuntime({ products: { lifetime: product("lifetime") } });
|
|
143
|
+
|
|
144
|
+
const result = await mergeProductRuntimes(contextRuntime, localRuntime, true, true).purchase("yearly");
|
|
145
|
+
|
|
146
|
+
expect(calledContext).toBe(true);
|
|
147
|
+
expect(result).toEqual({ status: "purchased", productKey: "yearly" });
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it("restore() always delegates to the context runtime — restoring is store-account-wide, not per-ref", async () => {
|
|
151
|
+
let calledContext = false;
|
|
152
|
+
let calledLocal = false;
|
|
153
|
+
const contextRuntime = makeRuntime({
|
|
154
|
+
restore: async () => {
|
|
155
|
+
calledContext = true;
|
|
156
|
+
return { status: "restored", entitlements: ["pro"] };
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
const localRuntime = makeRuntime({
|
|
160
|
+
restore: async () => {
|
|
161
|
+
calledLocal = true;
|
|
162
|
+
return { status: "restored", entitlements: ["pro"] };
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const result = await mergeProductRuntimes(contextRuntime, localRuntime, true, true).restore();
|
|
167
|
+
|
|
168
|
+
expect(calledContext).toBe(true);
|
|
169
|
+
expect(calledLocal).toBe(false);
|
|
170
|
+
expect(result).toEqual({ status: "restored", entitlements: ["pro"] });
|
|
171
|
+
});
|
|
172
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
// OnboardingProvider.tsx transitively imports `react-native` (via
|
|
4
|
+
// OnboardingStudioClient/registry.ts) and AsyncStorage — mocked the same way
|
|
5
|
+
// getOnboarding.query.test.ts does, so the module loads under Node.
|
|
6
|
+
vi.mock("@react-native-async-storage/async-storage", () => ({
|
|
7
|
+
default: { getItem: vi.fn(), setItem: vi.fn(), removeItem: vi.fn() },
|
|
8
|
+
}));
|
|
9
|
+
vi.mock("react-native", () => ({ Platform: { OS: "ios" } }));
|
|
10
|
+
|
|
11
|
+
import { resolveLocalProductArgs } from "../infra/provider/OnboardingProvider";
|
|
12
|
+
import type { ProductProvider, ProductRef } from "../products/types";
|
|
13
|
+
|
|
14
|
+
const REFS: ProductRef[] = [{ key: "yearly", ios: "com.app.yearly" }];
|
|
15
|
+
const PROVIDER: ProductProvider = {
|
|
16
|
+
getProducts: async () => [],
|
|
17
|
+
purchase: async () => ({ status: "cancelled" }),
|
|
18
|
+
restore: async () => ({ status: "nothing_to_restore" }),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Finding 5, 2026-08-17 final review: this function used to zero refs/provider
|
|
22
|
+
// out whenever a context runtime existed, on the assumption that the paywall
|
|
23
|
+
// catalog's product union is always a superset of the host's own `productRefs`
|
|
24
|
+
// — that silently broke a documented Phase 3 prop the moment a `PaywallProvider`
|
|
25
|
+
// was mounted above. It now passes the host's own args through UNCONDITIONALLY;
|
|
26
|
+
// `mergeProductRuntimes` (see its own test) does the unioning at the runtime
|
|
27
|
+
// level. This test guards the pass-through itself against a regression back to
|
|
28
|
+
// the old zeroing behavior.
|
|
29
|
+
describe("resolveLocalProductArgs", () => {
|
|
30
|
+
it("passes the host's own refs/provider through unchanged", () => {
|
|
31
|
+
const result = resolveLocalProductArgs(REFS, PROVIDER);
|
|
32
|
+
expect(result.refs).toBe(REFS);
|
|
33
|
+
expect(result.provider).toBe(PROVIDER);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("stays undefined when the host declared no productRefs/productProvider props", () => {
|
|
37
|
+
const result = resolveLocalProductArgs(undefined, undefined);
|
|
38
|
+
expect(result.refs).toBeUndefined();
|
|
39
|
+
expect(result.provider).toBeUndefined();
|
|
40
|
+
});
|
|
41
|
+
});
|