@rocapine/react-native-onboarding 1.75.0 → 1.76.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 +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/onboarding-example.d.ts +140 -0
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +41 -1
- package/dist/onboarding-example.js.map +1 -1
- package/dist/paywalls/PaywallProvider.d.ts +71 -5
- package/dist/paywalls/PaywallProvider.d.ts.map +1 -1
- package/dist/paywalls/PaywallProvider.js +237 -57
- package/dist/paywalls/PaywallProvider.js.map +1 -1
- package/dist/paywalls/customScreens.d.ts +31 -0
- package/dist/paywalls/customScreens.d.ts.map +1 -1
- package/dist/paywalls/observer.d.ts +129 -0
- package/dist/paywalls/observer.d.ts.map +1 -0
- package/dist/paywalls/observer.js +211 -0
- package/dist/paywalls/observer.js.map +1 -0
- package/dist/paywalls/present.d.ts +19 -15
- package/dist/paywalls/present.d.ts.map +1 -1
- package/dist/paywalls/present.js +21 -17
- package/dist/paywalls/present.js.map +1 -1
- package/dist/paywalls/types.d.ts +3 -1
- package/dist/paywalls/types.d.ts.map +1 -1
- package/dist/products/adapters/expoIap.d.ts +38 -1
- package/dist/products/adapters/expoIap.d.ts.map +1 -1
- package/dist/products/adapters/expoIap.js +509 -75
- package/dist/products/adapters/expoIap.js.map +1 -1
- package/dist/products/index.d.ts +1 -0
- package/dist/products/index.d.ts.map +1 -1
- package/dist/products/index.js.map +1 -1
- package/dist/products/types.d.ts +13 -0
- package/dist/products/types.d.ts.map +1 -1
- package/dist/screens/completingActions.d.ts +55 -3
- package/dist/screens/completingActions.d.ts.map +1 -1
- package/dist/screens/completingActions.js +209 -15
- package/dist/screens/completingActions.js.map +1 -1
- package/dist/screens/elementTypeRegistry.d.ts +14 -0
- package/dist/screens/elementTypeRegistry.d.ts.map +1 -1
- package/dist/screens/elementTypeRegistry.js +38 -1
- package/dist/screens/elementTypeRegistry.js.map +1 -1
- package/dist/screens/elements/ButtonElement.d.ts +3 -2
- package/dist/screens/elements/ButtonElement.d.ts.map +1 -1
- package/dist/screens/elements/ButtonElement.js +5 -1
- package/dist/screens/elements/ButtonElement.js.map +1 -1
- package/dist/screens/types.d.ts +2 -2
- package/dist/screens/types.d.ts.map +1 -1
- package/dist/screens/types.js +5 -1
- package/dist/screens/types.js.map +1 -1
- package/dist/screens/unknownKeys.d.ts +25 -4
- package/dist/screens/unknownKeys.d.ts.map +1 -1
- package/dist/screens/unknownKeys.js +81 -2
- package/dist/screens/unknownKeys.js.map +1 -1
- package/dist/steps/common.types.d.ts +178 -6
- package/dist/steps/common.types.d.ts.map +1 -1
- package/dist/steps/common.types.js +64 -3
- package/dist/steps/common.types.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/authoringDocEscapes.test.ts +59 -0
- package/src/__tests__/completingActions.test.ts +371 -1
- package/src/__tests__/customActionHooks.test.ts +224 -0
- package/src/__tests__/onboardingExampleElements.test.ts +47 -0
- package/src/__tests__/requestPermissionAction.test.ts +138 -0
- package/src/__tests__/retryIdempotencyDocs.test.ts +57 -0
- package/src/__tests__/unknownKeys.test.ts +110 -0
- package/src/index.ts +33 -1
- package/src/onboarding-example.ts +41 -1
- package/src/paywalls/PaywallProvider.tsx +370 -66
- package/src/paywalls/__tests__/PaywallProvider.observer.test.tsx +866 -0
- package/src/paywalls/__tests__/observer.test.ts +401 -0
- package/src/paywalls/__tests__/present.test.ts +0 -18
- package/src/paywalls/customScreens.ts +34 -1
- package/src/paywalls/observer.ts +308 -0
- package/src/paywalls/present.ts +24 -18
- package/src/paywalls/types.ts +3 -1
- package/src/products/adapters/__tests__/expoIap.contract.test.ts +648 -0
- package/src/products/adapters/__tests__/expoIap.test.ts +25 -11
- package/src/products/adapters/__tests__/expoIap5Fake.ts +288 -0
- package/src/products/adapters/expoIap.ts +609 -78
- package/src/products/index.ts +1 -0
- package/src/products/types.ts +13 -0
- package/src/screens/completingActions.ts +223 -15
- package/src/screens/elementTypeRegistry.ts +34 -0
- package/src/screens/elements/ButtonElement.ts +9 -1
- package/src/screens/types.ts +2 -2
- package/src/screens/unknownKeys.ts +113 -7
- package/src/steps/common.types.ts +213 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
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.RequestPermissionButtonActionSchema = exports.RestoreButtonActionSchema = exports.PurchaseButtonActionSchema = exports.PermissionKindSchema = exports.PERMISSION_KINDS = exports.PresentPaywallButtonActionSchema = exports.DismissButtonActionSchema = exports.SetVariableButtonActionSchema = exports.CustomButtonActionSchema = exports.CustomActionRetrySchema = 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([
|
|
@@ -38,11 +38,27 @@ exports.HapticStyleSchema = zod_1.z.enum([
|
|
|
38
38
|
"soft",
|
|
39
39
|
"rigid",
|
|
40
40
|
]);
|
|
41
|
-
exports.
|
|
41
|
+
exports.CustomActionRetrySchema = zod_1.z.object({
|
|
42
|
+
maxAttempts: zod_1.z
|
|
43
|
+
.number()
|
|
44
|
+
.int("maxAttempts must be a whole number of attempts")
|
|
45
|
+
.min(1, "maxAttempts must be at least 1")
|
|
46
|
+
.max(10, "maxAttempts must be at most 10"),
|
|
47
|
+
delayMs: zod_1.z.number().min(0).max(10000).optional(),
|
|
48
|
+
timeoutMs: zod_1.z
|
|
49
|
+
.number()
|
|
50
|
+
.min(1000, "timeoutMs must be at least 1000 (no real handler answers faster)")
|
|
51
|
+
.max(300000, "timeoutMs must be at most 300000 (five minutes)")
|
|
52
|
+
.optional(),
|
|
53
|
+
});
|
|
54
|
+
exports.CustomButtonActionSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
42
55
|
type: zod_1.z.literal("custom"),
|
|
43
56
|
function: zod_1.z.string().min(1, "function must not be empty"),
|
|
44
57
|
variables: zod_1.z.array(zod_1.z.string()).optional(),
|
|
45
|
-
|
|
58
|
+
onResolve: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
59
|
+
onError: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
60
|
+
retry: exports.CustomActionRetrySchema.optional(),
|
|
61
|
+
}));
|
|
46
62
|
exports.SetVariableButtonActionSchema = zod_1.z.object({
|
|
47
63
|
type: zod_1.z.literal("setVariable"),
|
|
48
64
|
name: zod_1.z.string().min(1, "name must not be empty"),
|
|
@@ -59,6 +75,43 @@ exports.PresentPaywallButtonActionSchema = zod_1.z.object({
|
|
|
59
75
|
type: zod_1.z.literal("presentPaywall"),
|
|
60
76
|
placement: zod_1.z.string().min(1, "placement must not be empty"),
|
|
61
77
|
});
|
|
78
|
+
/**
|
|
79
|
+
* The permissions a `requestPermission` action can ask for.
|
|
80
|
+
*
|
|
81
|
+
* Deliberately narrow, and closed. Every member here is reachable through an
|
|
82
|
+
* **optionally installed** Expo module that the UI package dynamic-`require`s
|
|
83
|
+
* at press time (the `expo-haptics` precedent), so an app that does not need a
|
|
84
|
+
* permission does not carry its native code:
|
|
85
|
+
*
|
|
86
|
+
* | kind | module(s) tried, in order |
|
|
87
|
+
* |---|---|
|
|
88
|
+
* | `notifications` | `expo-notifications` |
|
|
89
|
+
* | `appTrackingTransparency` | `expo-tracking-transparency` (iOS 14+; other platforms report `granted`) |
|
|
90
|
+
* | `locationWhenInUse` | `expo-location` (foreground only — background location needs its own review justification) |
|
|
91
|
+
* | `camera` | `expo-camera` |
|
|
92
|
+
* | `microphone` | `expo-audio`, then `expo-camera` |
|
|
93
|
+
* | `photoLibrary` | `expo-image-picker`, then `expo-media-library` |
|
|
94
|
+
*
|
|
95
|
+
* NOT members, on purpose: **HealthKit** and **Screen Time / Family Controls**.
|
|
96
|
+
* Both need app-owned entitlements and a config plugin neither package ships,
|
|
97
|
+
* so neither can be honestly requested from inside the SDK. They arrive through
|
|
98
|
+
* the host `requestPermission` resolver on the `ScreenHost` (the same seam as
|
|
99
|
+
* `products` / `presentPaywall`) once a `kind` for them is added — a
|
|
100
|
+
* deliberately separate decision, not a silent no-op today.
|
|
101
|
+
*
|
|
102
|
+
* READING a permission's current status is not here either: this is a press
|
|
103
|
+
* action, and "skip the screen when already granted" is a variable-bag
|
|
104
|
+
* capability with nowhere to live in this shape. Tracked separately.
|
|
105
|
+
*/
|
|
106
|
+
exports.PERMISSION_KINDS = [
|
|
107
|
+
"notifications",
|
|
108
|
+
"appTrackingTransparency",
|
|
109
|
+
"locationWhenInUse",
|
|
110
|
+
"camera",
|
|
111
|
+
"microphone",
|
|
112
|
+
"photoLibrary",
|
|
113
|
+
];
|
|
114
|
+
exports.PermissionKindSchema = zod_1.z.enum(exports.PERMISSION_KINDS);
|
|
62
115
|
exports.PurchaseButtonActionSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
63
116
|
type: zod_1.z.literal("purchase"),
|
|
64
117
|
product: zod_1.z.string().min(1, "product must not be empty"),
|
|
@@ -73,6 +126,13 @@ exports.RestoreButtonActionSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
|
73
126
|
onNothingToRestore: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
74
127
|
onError: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
75
128
|
}));
|
|
129
|
+
exports.RequestPermissionButtonActionSchema = zod_1.z.lazy(() => zod_1.z.object({
|
|
130
|
+
type: zod_1.z.literal("requestPermission"),
|
|
131
|
+
kind: exports.PermissionKindSchema,
|
|
132
|
+
onGranted: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
133
|
+
onDenied: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
134
|
+
onUnavailable: zod_1.z.array(exports.ButtonActionSchema).optional(),
|
|
135
|
+
}));
|
|
76
136
|
exports.ButtonActionSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
77
137
|
zod_1.z.literal("continue"),
|
|
78
138
|
exports.CustomButtonActionSchema,
|
|
@@ -81,6 +141,7 @@ exports.ButtonActionSchema = zod_1.z.lazy(() => zod_1.z.union([
|
|
|
81
141
|
exports.RestoreButtonActionSchema,
|
|
82
142
|
exports.DismissButtonActionSchema,
|
|
83
143
|
exports.PresentPaywallButtonActionSchema,
|
|
144
|
+
exports.RequestPermissionButtonActionSchema,
|
|
84
145
|
]));
|
|
85
146
|
// ── Branching / nextStep schemas ─────────────────────────────────────────────
|
|
86
147
|
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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AC,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocapine/react-native-onboarding",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.76.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",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { actionsCanComplete, hasCompletingAction } from "../screens/completingActions";
|
|
5
|
+
|
|
6
|
+
// The authoring surfaces are prose, so nothing type-checks the payloads they
|
|
7
|
+
// teach against the runtime that reads them — and a `custom` CTA is exactly
|
|
8
|
+
// where that costs something. Reads the docs off disk, the same technique as
|
|
9
|
+
// `unknownElementTypes.test.ts` and `actionSchemaMirror.test.ts` (review round
|
|
10
|
+
// 2 of !263, finding 4).
|
|
11
|
+
|
|
12
|
+
const ROOT = join(__dirname, "../../../..");
|
|
13
|
+
const read = (rel: string): string => readFileSync(join(ROOT, rel), "utf8");
|
|
14
|
+
|
|
15
|
+
/** The fenced code block that contains `marker`, parsed as JSON. */
|
|
16
|
+
const jsonBlockAround = (src: string, rel: string, marker: string): unknown => {
|
|
17
|
+
const at = src.indexOf(marker);
|
|
18
|
+
expect(at, `${rel} no longer mentions ${marker}`).toBeGreaterThan(-1);
|
|
19
|
+
const fence = src.lastIndexOf("```", at);
|
|
20
|
+
const body = src.indexOf("\n", fence) + 1;
|
|
21
|
+
return JSON.parse(src.slice(body, src.indexOf("```", body)));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** The inline `` `actions: [...]` `` span that contains `marker`, parsed as JSON. */
|
|
25
|
+
const inlineActionsAround = (src: string, rel: string, marker: string): unknown => {
|
|
26
|
+
const at = src.indexOf(marker);
|
|
27
|
+
expect(at, `${rel} no longer mentions ${marker}`).toBeGreaterThan(-1);
|
|
28
|
+
const span = src.slice(src.lastIndexOf("`", at) + 1, src.indexOf("`", at));
|
|
29
|
+
return JSON.parse(span.replace(/^actions:\s*/, ""));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A `custom` action is a way off the screen only when BOTH of its paths reach
|
|
34
|
+
* one — `onResolve ∪ rest` and `onError ∪ rest` (`completingActions.ts`). A doc
|
|
35
|
+
* that teaches a shape failing that test is teaching a screen nobody can leave,
|
|
36
|
+
* and — once anything else on it is stripped by the #209 boundary — one the
|
|
37
|
+
* renderer bolts a second Continue button onto.
|
|
38
|
+
*/
|
|
39
|
+
describe("authoring docs — the `custom` CTAs they teach can be left", () => {
|
|
40
|
+
it("credits the Tier 2 canonical button, which trails its custom with a continue", () => {
|
|
41
|
+
const rel = "claude-plugin/skills/customize-onboarding-components/SKILL.md";
|
|
42
|
+
const element = jsonBlockAround(read(rel), rel, "trackOnboardingComplete");
|
|
43
|
+
// `[{custom}, "continue"]`: the trailing escape runs whether the handler
|
|
44
|
+
// resolved or failed, so it satisfies both terms of the conjunction. This
|
|
45
|
+
// half of the finding never reproduced — it was written against the earlier
|
|
46
|
+
// `(onResolve ∪ rest) ∧ onError` reading, before `rest` flowed through both
|
|
47
|
+
// terms — and is pinned here rather than "fixed".
|
|
48
|
+
expect(hasCompletingAction([element])).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("credits the `delayedContinue` loader fallback", () => {
|
|
52
|
+
const rel = "claude-plugin/skills/create-step-json/references/composable-archetypes.md";
|
|
53
|
+
const actions = inlineActionsAround(read(rel), rel, "delayedContinue");
|
|
54
|
+
// This one was a bare `[{custom}]` — nothing after the action and neither
|
|
55
|
+
// hook declared, so the press escapes on NO path: the host's timer resolves,
|
|
56
|
+
// the handler's return value is discarded, and the screen never advances.
|
|
57
|
+
expect(actionsCanComplete(actions)).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
actionsCanComplete,
|
|
4
|
+
completingActionKind,
|
|
5
|
+
hasCompletingAction,
|
|
6
|
+
} from "../screens/completingActions";
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* "Can the user still get off this screen?" (#209, review finding 1).
|
|
@@ -137,3 +141,369 @@ describe("hasCompletingAction", () => {
|
|
|
137
141
|
expect(hasCompletingAction([button("cta", [{ type: "continue" }])])).toBe(false);
|
|
138
142
|
});
|
|
139
143
|
});
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* `requestPermission` (#196) is the one action whose branch lists must NOT be
|
|
147
|
+
* read with the generic "any nested list completes it" rule, and review round 1
|
|
148
|
+
* caught the first version doing exactly that.
|
|
149
|
+
*
|
|
150
|
+
* The question this predicate answers is "can the user still get off this
|
|
151
|
+
* screen?", and for a permission ask the honest answer is "only on the outcomes
|
|
152
|
+
* the author covered". The runtime has three: a grant runs `onGranted`, a
|
|
153
|
+
* refusal runs `onDenied`, and "this build cannot ask" runs
|
|
154
|
+
* `onUnavailable ?? onDenied`. A CTA holding its only `"continue"` in
|
|
155
|
+
* `onGranted` traps every user who refuses — and traps EVERY user on a build
|
|
156
|
+
* that never installed the optional Expo module, which is a packaging fact the
|
|
157
|
+
* person pressing the button cannot do anything about.
|
|
158
|
+
*
|
|
159
|
+
* So the rule is AND across the outcomes, not OR: the action counts as a way
|
|
160
|
+
* forward only when a grant AND a non-grant both reach `"continue"` /
|
|
161
|
+
* `{dismiss}`. That is the file's stated bias ("errs toward no") applied to the
|
|
162
|
+
* one action whose result the user does not fully control. `purchase` and
|
|
163
|
+
* `restore` keep the OR reading deliberately — a cancelled purchase leaves the
|
|
164
|
+
* user free to press again, whereas a standing OS denial cannot be retried.
|
|
165
|
+
*/
|
|
166
|
+
describe("hasCompletingAction — requestPermission outcome hooks", () => {
|
|
167
|
+
const ask = (hooks: Record<string, unknown[]>) => [
|
|
168
|
+
button("cta", [{ type: "requestPermission", kind: "notifications", ...hooks }]),
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
it("counts an ask that advances on a grant AND on a refusal", () => {
|
|
172
|
+
expect(hasCompletingAction(ask({ onGranted: ["continue"], onDenied: ["continue"] }))).toBe(true);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it("counts a grant path that continues and a refusal path that dismisses", () => {
|
|
176
|
+
expect(
|
|
177
|
+
hasCompletingAction(ask({ onGranted: ["continue"], onDenied: [{ type: "dismiss" }] }))
|
|
178
|
+
).toBe(true);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// The trap. `onGranted` alone reads as NO way forward, so the #209 strip
|
|
182
|
+
// supplies its own escape CTA.
|
|
183
|
+
it("reports no way forward when only the grant path advances", () => {
|
|
184
|
+
expect(hasCompletingAction(ask({ onGranted: ["continue"] }))).toBe(false);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
it("reports no way forward when only the refusal path advances", () => {
|
|
188
|
+
expect(hasCompletingAction(ask({ onDenied: ["continue"] }))).toBe(false);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
// `onUnavailable` covers the module-absent outcome only; a denial still needs
|
|
192
|
+
// `onDenied`, so this shape strands the user who taps "Don't Allow".
|
|
193
|
+
it("reports no way forward when onDenied is missing but onUnavailable advances", () => {
|
|
194
|
+
expect(
|
|
195
|
+
hasCompletingAction(ask({ onGranted: ["continue"], onUnavailable: ["continue"] }))
|
|
196
|
+
).toBe(false);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// All three declared: every runtime path advances.
|
|
200
|
+
it("counts an ask that covers all three outcomes", () => {
|
|
201
|
+
expect(
|
|
202
|
+
hasCompletingAction(
|
|
203
|
+
ask({ onGranted: ["continue"], onDenied: ["continue"], onUnavailable: ["continue"] })
|
|
204
|
+
)
|
|
205
|
+
).toBe(true);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// `onUnavailable` present but dead, while `onDenied` advances: the
|
|
209
|
+
// module-absent build runs onUnavailable and stays put, so this is a trap the
|
|
210
|
+
// OR reading would have missed too.
|
|
211
|
+
it("reports no way forward when a declared onUnavailable does not advance", () => {
|
|
212
|
+
expect(
|
|
213
|
+
hasCompletingAction(
|
|
214
|
+
ask({
|
|
215
|
+
onGranted: ["continue"],
|
|
216
|
+
onDenied: ["continue"],
|
|
217
|
+
onUnavailable: [{ type: "setVariable", name: "push", value: "n/a" }],
|
|
218
|
+
})
|
|
219
|
+
)
|
|
220
|
+
).toBe(false);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
// A typo'd hook name is stripped by the (deliberately non-strict) schema, so
|
|
224
|
+
// the payload validates clean and the denial path is dead. The AND rule is
|
|
225
|
+
// what turns that into a visible escape CTA rather than a silent trap.
|
|
226
|
+
it("reports no way forward when the refusal hook is misspelled", () => {
|
|
227
|
+
expect(
|
|
228
|
+
hasCompletingAction(ask({ onGranted: ["continue"], onDeneid: ["continue"] }))
|
|
229
|
+
).toBe(false);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
it("reports no way forward for a permission ask with no terminal hook", () => {
|
|
233
|
+
expect(
|
|
234
|
+
hasCompletingAction(ask({ onGranted: [{ type: "setVariable", name: "push", value: "on" }] }))
|
|
235
|
+
).toBe(false);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// A separate CTA elsewhere on the screen is still a way forward — the rule
|
|
239
|
+
// narrows what the ASK itself counts for, nothing else.
|
|
240
|
+
it("still finds a sibling skip button", () => {
|
|
241
|
+
expect(
|
|
242
|
+
hasCompletingAction([
|
|
243
|
+
button("cta", [{ type: "requestPermission", kind: "notifications", onGranted: ["continue"] }]),
|
|
244
|
+
button("skip", ["continue"]),
|
|
245
|
+
])
|
|
246
|
+
).toBe(true);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
// Nesting: an ask inside another action's branch list is walked the same way.
|
|
250
|
+
it("counts a fully covered ask nested inside purchase.onSuccess", () => {
|
|
251
|
+
expect(
|
|
252
|
+
hasCompletingAction([
|
|
253
|
+
button("cta", [
|
|
254
|
+
{
|
|
255
|
+
type: "purchase",
|
|
256
|
+
product: "yearly",
|
|
257
|
+
onSuccess: [
|
|
258
|
+
{
|
|
259
|
+
type: "requestPermission",
|
|
260
|
+
kind: "notifications",
|
|
261
|
+
onGranted: ["continue"],
|
|
262
|
+
onDenied: ["continue"],
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
]),
|
|
267
|
+
])
|
|
268
|
+
).toBe(true);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* `actionsCanComplete` — the same walk, exposed for ONE action list rather than
|
|
274
|
+
* a whole element tree, so the runtime can consult the SDK's own definition of
|
|
275
|
+
* "this was a way off the screen" instead of re-deriving it (review round 1,
|
|
276
|
+
* finding 1).
|
|
277
|
+
*
|
|
278
|
+
* `runActions` needs it at press time for exactly one decision: a
|
|
279
|
+
* `requestPermission` whose build cannot ask at all, with no `onUnavailable`
|
|
280
|
+
* declared. Whether that press was the screen's only way forward is the
|
|
281
|
+
* difference between "log and move on" and "the user is stuck", and it is the
|
|
282
|
+
* same question this module already answers statically.
|
|
283
|
+
*
|
|
284
|
+
* OR across the list, unlike `permissionAskCompletes`' AND across one ask's
|
|
285
|
+
* outcomes: the caller asks "did the author intend this press to move the user
|
|
286
|
+
* on", not "does every outcome move them on".
|
|
287
|
+
*/
|
|
288
|
+
describe("actionsCanComplete", () => {
|
|
289
|
+
it("is true for a list holding continue or dismiss", () => {
|
|
290
|
+
expect(actionsCanComplete(["continue"])).toBe(true);
|
|
291
|
+
expect(actionsCanComplete([{ type: "dismiss" }])).toBe(true);
|
|
292
|
+
expect(actionsCanComplete([{ type: "setVariable", name: "a", value: "b" }, "continue"])).toBe(
|
|
293
|
+
true
|
|
294
|
+
);
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("is false for a list that leaves the user on the screen", () => {
|
|
298
|
+
expect(actionsCanComplete([{ type: "setVariable", name: "a", value: "b" }])).toBe(false);
|
|
299
|
+
expect(actionsCanComplete([{ type: "custom", function: "doThing" }])).toBe(false);
|
|
300
|
+
expect(actionsCanComplete([{ type: "presentPaywall", placement: "hard" }])).toBe(false);
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
it("walks nested branch lists", () => {
|
|
304
|
+
expect(
|
|
305
|
+
actionsCanComplete([{ type: "purchase", product: "yearly", onSuccess: ["continue"] }])
|
|
306
|
+
).toBe(true);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// Total on junk: it runs on a payload the runtime has already parsed, but the
|
|
310
|
+
// predicate is the one thing that must not throw while deciding whether a
|
|
311
|
+
// user is trapped.
|
|
312
|
+
it("is false for anything that is not an action list", () => {
|
|
313
|
+
expect(actionsCanComplete(undefined)).toBe(false);
|
|
314
|
+
expect(actionsCanComplete(null)).toBe(false);
|
|
315
|
+
expect(actionsCanComplete("continue")).toBe(false);
|
|
316
|
+
expect(actionsCanComplete([null, 3, { type: "continue" }])).toBe(false);
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Review round 2, finding 1. `actionsCanComplete`'s yes/no was not enough: the
|
|
322
|
+
* runtime substitutes the author's escape for an ask it could not perform, and
|
|
323
|
+
* the two completing actions report DIFFERENT outcomes to the host.
|
|
324
|
+
* `complete()` (bare) is what `Pages/Paywall/Renderer`'s hard gate reads as
|
|
325
|
+
* "advance", so standing in for an authored `{dismiss}` with a bare advance
|
|
326
|
+
* handed out paid content. `"dismiss"` therefore wins whenever both are
|
|
327
|
+
* reachable — nobody was asked anything, so the SDK claims the LESS permissive
|
|
328
|
+
* of the two answers the author authored.
|
|
329
|
+
*/
|
|
330
|
+
describe("completingActionKind", () => {
|
|
331
|
+
it("names the completing action a list reaches", () => {
|
|
332
|
+
expect(completingActionKind(["continue"])).toBe("continue");
|
|
333
|
+
expect(completingActionKind([{ type: "dismiss" }])).toBe("dismiss");
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
it("prefers dismiss when both are reachable, in either order", () => {
|
|
337
|
+
expect(completingActionKind(["continue", { type: "dismiss" }])).toBe("dismiss");
|
|
338
|
+
expect(completingActionKind([{ type: "dismiss" }, "continue"])).toBe("dismiss");
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it("walks nested branch lists like the predicate does", () => {
|
|
342
|
+
expect(
|
|
343
|
+
completingActionKind([
|
|
344
|
+
{ type: "purchase", product: "yearly", onSuccess: [{ type: "dismiss" }] },
|
|
345
|
+
])
|
|
346
|
+
).toBe("dismiss");
|
|
347
|
+
expect(
|
|
348
|
+
completingActionKind([{ type: "restore", onSuccess: ["continue"] }])
|
|
349
|
+
).toBe("continue");
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// A nested ask keeps the AND-across-outcomes rule: it contributes an escape
|
|
353
|
+
// only when it is one on EVERY path.
|
|
354
|
+
it("respects the requestPermission AND rule when nested", () => {
|
|
355
|
+
expect(
|
|
356
|
+
completingActionKind([
|
|
357
|
+
{ type: "requestPermission", kind: "notifications", onGranted: ["continue"] },
|
|
358
|
+
])
|
|
359
|
+
).toBeUndefined();
|
|
360
|
+
expect(
|
|
361
|
+
completingActionKind([
|
|
362
|
+
{
|
|
363
|
+
type: "requestPermission",
|
|
364
|
+
kind: "notifications",
|
|
365
|
+
onGranted: ["continue"],
|
|
366
|
+
onDenied: [{ type: "dismiss" }],
|
|
367
|
+
},
|
|
368
|
+
])
|
|
369
|
+
).toBe("dismiss");
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it("is undefined for a list that leaves the user on the screen, and for junk", () => {
|
|
373
|
+
expect(completingActionKind([{ type: "setVariable", name: "a", value: "b" }])).toBeUndefined();
|
|
374
|
+
expect(completingActionKind([])).toBeUndefined();
|
|
375
|
+
expect(completingActionKind(undefined)).toBeUndefined();
|
|
376
|
+
expect(completingActionKind(null)).toBeUndefined();
|
|
377
|
+
expect(completingActionKind("continue")).toBeUndefined();
|
|
378
|
+
expect(completingActionKind([null, 3, { type: "continue" }])).toBeUndefined();
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
// The two must never disagree about WHETHER there is an escape — one walk
|
|
382
|
+
// answers both, and this is the assertion that keeps it that way.
|
|
383
|
+
it("agrees with actionsCanComplete on every shape", () => {
|
|
384
|
+
for (const actions of [
|
|
385
|
+
["continue"],
|
|
386
|
+
[{ type: "dismiss" }],
|
|
387
|
+
[{ type: "setVariable", name: "a", value: "b" }],
|
|
388
|
+
[{ type: "purchase", product: "yearly", onSuccess: ["continue"] }],
|
|
389
|
+
[{ type: "requestPermission", kind: "camera", onGranted: ["continue"] }],
|
|
390
|
+
undefined,
|
|
391
|
+
null,
|
|
392
|
+
[],
|
|
393
|
+
]) {
|
|
394
|
+
expect(completingActionKind(actions) !== undefined).toBe(actionsCanComplete(actions));
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* `custom` is read with AND across its outcomes, like `requestPermission` and
|
|
401
|
+
* unlike everything else (#191, review round 1, finding 6).
|
|
402
|
+
*
|
|
403
|
+
* The async gate this SDK documents puts the screen's only `"continue"` inside
|
|
404
|
+
* `onResolve`. That is the exact shape `permissionAskCompletes` was carved out
|
|
405
|
+
* to refuse: `onResolve` runs on the resolve path and NOWHERE else, so a
|
|
406
|
+
* `"continue"` reachable only there is not a way off the screen for a user
|
|
407
|
+
* whose backend is down — nor for one running a host with `customActions: {}`,
|
|
408
|
+
* which is `ScreenHost`'s own default. The generic OR read it as one, which is
|
|
409
|
+
* what let the walk report "this screen has a CTA" for a screen nobody could
|
|
410
|
+
* leave.
|
|
411
|
+
*
|
|
412
|
+
* The AND is over the action's TWO paths — the handler resolved, and the
|
|
413
|
+
* handler failed (a throw with the budget spent, an attempt past
|
|
414
|
+
* `retry.timeoutMs`, or a name the host never registered: one rule since the
|
|
415
|
+
* semantics decision of 2026-09-11, #191 / #266). Both leave the enclosing list
|
|
416
|
+
* running, so whatever follows the action counts for both terms, and
|
|
417
|
+
* `[{custom}, "continue"]` IS a way off the screen — on every path, not on two
|
|
418
|
+
* of three as it was while a throw aborted. Round 2 of this PR required
|
|
419
|
+
* `onError` on its own and therefore read that shape — the only `custom` shape
|
|
420
|
+
* Studio can author today — as a trap; see
|
|
421
|
+
* `onboarding-ui/src/UI/Runtime/__tests__/mergeBaseEscapeParity.test.ts`, and
|
|
422
|
+
* `customActionEscapeCoherence.test.ts` beside it for the check that this walk
|
|
423
|
+
* and `runActions` agree.
|
|
424
|
+
*/
|
|
425
|
+
describe("completingActions — custom is AND across its outcome hooks", () => {
|
|
426
|
+
const gate = (extra: Record<string, unknown>) => [
|
|
427
|
+
{ type: "custom", function: "generatePlan", ...extra },
|
|
428
|
+
];
|
|
429
|
+
|
|
430
|
+
it("does not count a continue reachable only when the handler resolves", () => {
|
|
431
|
+
expect(actionsCanComplete(gate({ onResolve: ["continue"] }))).toBe(false);
|
|
432
|
+
expect(
|
|
433
|
+
actionsCanComplete(
|
|
434
|
+
gate({
|
|
435
|
+
onResolve: ["continue"],
|
|
436
|
+
onError: [{ type: "setVariable", name: "planError", value: "true" }],
|
|
437
|
+
})
|
|
438
|
+
)
|
|
439
|
+
).toBe(false);
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
it("counts it when BOTH outcomes reach a way off the screen", () => {
|
|
443
|
+
expect(
|
|
444
|
+
actionsCanComplete(gate({ onResolve: ["continue"], onError: ["continue"] }))
|
|
445
|
+
).toBe(true);
|
|
446
|
+
expect(
|
|
447
|
+
completingActionKind(gate({ onResolve: ["continue"], onError: [{ type: "dismiss" }] }))
|
|
448
|
+
).toBe("dismiss");
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
it("does not count a bare custom action, nor one whose `variables` are named like actions", () => {
|
|
452
|
+
expect(actionsCanComplete(gate({}))).toBe(false);
|
|
453
|
+
// `variables: ["continue"]` used to satisfy the generic OR walk.
|
|
454
|
+
expect(actionsCanComplete(gate({ variables: ["continue"] }))).toBe(false);
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it("counts a sibling AFTER the custom action (retro round 2, finding 2)", () => {
|
|
458
|
+
// `[{custom}, "continue"]` is the shape an author writes when Studio cannot
|
|
459
|
+
// spell `onResolve` — which is every `custom` payload in the field until
|
|
460
|
+
// `rocapine/onboarding-studio#288` lands. The trailing `"continue"` runs on
|
|
461
|
+
// BOTH of the action's paths — the handler resolved, or it failed — so it
|
|
462
|
+
// is a way off the screen, and reading it as a trap bolted a duplicate CTA
|
|
463
|
+
// onto stripped screens that already had one.
|
|
464
|
+
expect(actionsCanComplete([...gate({}), "continue"])).toBe(true);
|
|
465
|
+
expect(
|
|
466
|
+
actionsCanComplete([
|
|
467
|
+
...gate({ onError: [{ type: "setVariable", name: "planError", value: "true" }] }),
|
|
468
|
+
"continue",
|
|
469
|
+
])
|
|
470
|
+
).toBe(true);
|
|
471
|
+
// An `onError` that escapes is a way off the screen on its own terms, so it
|
|
472
|
+
// does not need the sibling — but the sibling does not disqualify it either.
|
|
473
|
+
expect(actionsCanComplete([...gate({ onError: ["continue"] }), "continue"])).toBe(true);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
it("still refuses a custom whose ONLY escape is on the resolve path", () => {
|
|
477
|
+
// The sibling rule above must not launder round 1's finding 6 back in, and
|
|
478
|
+
// neither does removing the abort: with nothing trailing the action, a host
|
|
479
|
+
// running `customActions: {}` — the `ScreenHost` default — reaches neither
|
|
480
|
+
// `onResolve` nor anything after it. (#266 costed this decision as
|
|
481
|
+
// "reverts to the generic OR walk". OR would credit this `onResolve` and
|
|
482
|
+
// re-open finding 6; what the decision removes is a third term the code
|
|
483
|
+
// never had.)
|
|
484
|
+
expect(actionsCanComplete(gate({ onResolve: ["continue"] }))).toBe(false);
|
|
485
|
+
expect(actionsCanComplete([...gate({ onResolve: ["continue"] })])).toBe(false);
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
it("counts a sibling BEFORE it, which runs whatever the handler does", () => {
|
|
489
|
+
// `runActions` returns at the first completing action, so the custom never
|
|
490
|
+
// runs and the escape is unconditional — which is why everything before the
|
|
491
|
+
// barrier keeps the plain OR reading.
|
|
492
|
+
expect(actionsCanComplete(["continue", ...gate({})])).toBe(true);
|
|
493
|
+
expect(completingActionKind([{ type: "dismiss" }, ...gate({})])).toBe("dismiss");
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
it("reads the classic shape the same way inside an element tree", () => {
|
|
497
|
+
expect(hasCompletingAction([button("cta", [...gate({}), "continue"])])).toBe(true);
|
|
498
|
+
// And still strands when the only escape is behind the handler.
|
|
499
|
+
expect(hasCompletingAction([button("cta", gate({ onResolve: ["continue"] }))])).toBe(false);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
it("reads a whole element tree the same way", () => {
|
|
503
|
+
const screen = [button("cta", gate({ onResolve: ["continue"] }))];
|
|
504
|
+
expect(hasCompletingAction(screen)).toBe(false);
|
|
505
|
+
expect(
|
|
506
|
+
hasCompletingAction([button("cta", gate({ onResolve: ["continue"], onError: ["continue"] }))])
|
|
507
|
+
).toBe(true);
|
|
508
|
+
});
|
|
509
|
+
});
|