@rocapine/react-native-onboarding 1.74.1 → 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/evaluateCondition.d.ts.map +1 -1
- package/dist/evaluateCondition.js +103 -4
- package/dist/evaluateCondition.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/dist/onboarding-example.d.ts +375 -99
- package/dist/onboarding-example.d.ts.map +1 -1
- package/dist/onboarding-example.js +118 -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 +95 -0
- package/dist/screens/completingActions.d.ts.map +1 -0
- package/dist/screens/completingActions.js +302 -0
- package/dist/screens/completingActions.js.map +1 -0
- package/dist/screens/elementTypeRegistry.d.ts +45 -0
- package/dist/screens/elementTypeRegistry.d.ts.map +1 -0
- package/dist/screens/elementTypeRegistry.js +119 -0
- package/dist/screens/elementTypeRegistry.js.map +1 -0
- 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/resolveRenderableStep.d.ts +42 -0
- package/dist/screens/resolveRenderableStep.d.ts.map +1 -0
- package/dist/screens/resolveRenderableStep.js +28 -0
- package/dist/screens/resolveRenderableStep.js.map +1 -0
- 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/unknownElementTypes.d.ts +94 -0
- package/dist/screens/unknownElementTypes.d.ts.map +1 -0
- package/dist/screens/unknownElementTypes.js +141 -0
- package/dist/screens/unknownElementTypes.js.map +1 -0
- package/dist/screens/unknownKeys.d.ts +30 -6
- package/dist/screens/unknownKeys.d.ts.map +1 -1
- package/dist/screens/unknownKeys.js +88 -54
- package/dist/screens/unknownKeys.js.map +1 -1
- package/dist/steps/common.types.d.ts +262 -9
- 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 +509 -0
- package/src/__tests__/customActionHooks.test.ts +224 -0
- package/src/__tests__/elementTypeRegistry.test.ts +48 -0
- package/src/__tests__/evaluateCondition.test.ts +228 -3
- package/src/__tests__/onboardingExampleElements.test.ts +74 -0
- package/src/__tests__/requestPermissionAction.test.ts +138 -0
- package/src/__tests__/resolveRenderableStep.test.ts +117 -0
- package/src/__tests__/retryIdempotencyDocs.test.ts +57 -0
- package/src/__tests__/unknownElementTypes.test.ts +240 -0
- package/src/__tests__/unknownKeys.test.ts +110 -0
- package/src/evaluateCondition.ts +107 -4
- package/src/index.ts +55 -0
- package/src/onboarding-example.ts +119 -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 +316 -0
- package/src/screens/elementTypeRegistry.ts +122 -0
- package/src/screens/elements/ButtonElement.ts +9 -1
- package/src/screens/resolveRenderableStep.ts +59 -0
- package/src/screens/types.ts +2 -2
- package/src/screens/unknownElementTypes.ts +204 -0
- package/src/screens/unknownKeys.ts +119 -56
- package/src/steps/common.types.ts +297 -9
package/src/evaluateCondition.ts
CHANGED
|
@@ -42,9 +42,112 @@ function isEmpty(v: unknown): boolean {
|
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// A condition's right-hand side may reference other variables with `{{name}}`,
|
|
46
|
+
// which is what lets a condition compare two variables instead of a variable
|
|
47
|
+
// against an authored literal. `RepeatElement` documents exactly this shape to
|
|
48
|
+
// make `Repeat` subsume a `Match` — `{ variable: "item.sign", operator: "eq",
|
|
49
|
+
// value: "{{zodiacSign}}" }` — and without interpolation here that comparison
|
|
50
|
+
// tests against the 14-character literal and never matches.
|
|
51
|
+
//
|
|
52
|
+
// References resolve to the variable's raw value stringified, matching
|
|
53
|
+
// `Image mode:"expression"` (machine identifiers, not display labels); the map
|
|
54
|
+
// reaching this function is already flat primitives. An unknown reference
|
|
55
|
+
// resolves to the empty string rather than throwing, so a gate on a variable
|
|
56
|
+
// that has not been written yet simply does not match.
|
|
57
|
+
const REF = /\{\{([^}]+?)\}\}/g;
|
|
58
|
+
|
|
59
|
+
function interpolateRefs(value: unknown, variables: Record<string, unknown>): unknown {
|
|
60
|
+
if (Array.isArray(value)) return value.map((v) => interpolateRefs(v, variables));
|
|
61
|
+
if (typeof value !== "string" || !value.includes("{{")) return value;
|
|
62
|
+
return value.replace(REF, (_, key: string) => {
|
|
63
|
+
const resolved = variables[key.trim()];
|
|
64
|
+
return resolved === undefined || resolved === null ? "" : String(resolved);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// "No member" vs "a member that is empty". An unresolved `{{ref}}` interpolates
|
|
69
|
+
// to the empty string (`interpolateRefs`), and it reaches the comparison in both
|
|
70
|
+
// right-hand-side shapes identically — bare, or as the single member of the array
|
|
71
|
+
// Studio's condition editor emits. Keeping it as a member would make an
|
|
72
|
+
// empty-string variable a member of a list nobody has written (`in` matches,
|
|
73
|
+
// `not_in` does not — the opposite of the same gate written bare), and an
|
|
74
|
+
// empty-string variable is reachable: `InputElement` stores "" on clear and
|
|
75
|
+
// `Input.defaultValue: ""` is overlaid into the variable map. Nothing authorable
|
|
76
|
+
// is lost — Studio's value field drops empty members (`filter(Boolean)`), and
|
|
77
|
+
// `is_empty` is the operator for "the variable is blank".
|
|
78
|
+
function isAbsentMember(member: unknown): boolean {
|
|
79
|
+
return isNullish(member) || member === "";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// The membership operators (`in` / `not_in`, and `contains` against an array
|
|
83
|
+
// variable) need a real list and used to answer a CONSTANT without one —
|
|
84
|
+
// `in` false for every row, `not_in` true for every row, no warning (#225).
|
|
85
|
+
//
|
|
86
|
+
// Two right-hand-side shapes reach them without being `Array.isArray`, and both
|
|
87
|
+
// are the natural way to author a membership test now that a `{{ref}}` on the
|
|
88
|
+
// right-hand side resolves (#217):
|
|
89
|
+
//
|
|
90
|
+
// value: "{{selected}}" a reference to a multi-select variable, whose flat
|
|
91
|
+
// value is a JSON-encoded string ('["a","b"]' — see
|
|
92
|
+
// `decodeArrayValue`), so the ref interpolates to a
|
|
93
|
+
// string and `Array.isArray` is false.
|
|
94
|
+
// value: ["{{selected}}"] what Studio's condition editor emits: it splits the
|
|
95
|
+
// value field on commas, so the reference lands as
|
|
96
|
+
// the single member of a one-member array. That one
|
|
97
|
+
// IS an array, and used to reach the comparison as a
|
|
98
|
+
// list holding one JSON string — equally constant.
|
|
99
|
+
//
|
|
100
|
+
// So a member list is built by decoding the value itself AND each of its
|
|
101
|
+
// members, flattening one level. Only one level: nothing authorable nests
|
|
102
|
+
// deeper, and a deep flatten would silently merge a shape nobody wrote.
|
|
103
|
+
//
|
|
104
|
+
// `value: []` keeps its documented constants (`in` false / `not_in` true) — an
|
|
105
|
+
// empty Studio value field yields it, and an empty list legitimately has no
|
|
106
|
+
// members. So does a reference that resolves to nothing: an unresolved `{{ref}}`
|
|
107
|
+
// interpolates to the empty string (see `interpolateRefs`), and "not written
|
|
108
|
+
// yet" means "no members", not "a member that is the empty string".
|
|
109
|
+
//
|
|
110
|
+
// Anything else scalar (`in` against `"male"`) is an authoring mistake with no
|
|
111
|
+
// correct answer. It reads as a ONE-member list — the only reading that is not a
|
|
112
|
+
// silent constant, and what `in: "male"` plainly means — and warns, because the
|
|
113
|
+
// evaluator returns `boolean` and `renderWhen` has no third state, so a warning
|
|
114
|
+
// is the loudest a runtime can be. No Studio-authored payload can produce this
|
|
115
|
+
// shape (its editor always emits an array), so nothing that evaluates correctly
|
|
116
|
+
// today changes.
|
|
117
|
+
function toMemberList(value: unknown, operator: string): unknown[] {
|
|
118
|
+
const decoded = decodeArrayValue(value);
|
|
119
|
+
if (Array.isArray(decoded)) {
|
|
120
|
+
return decoded
|
|
121
|
+
.flatMap((member) => {
|
|
122
|
+
const inner = decodeArrayValue(member);
|
|
123
|
+
return Array.isArray(inner) ? inner : [inner];
|
|
124
|
+
})
|
|
125
|
+
.filter((member) => !isAbsentMember(member));
|
|
126
|
+
}
|
|
127
|
+
if (isAbsentMember(decoded)) return [];
|
|
128
|
+
console.warn(
|
|
129
|
+
`[onboarding] condition operator "${operator}" needs a list on its right-hand side, ` +
|
|
130
|
+
`got ${typeof decoded} ${JSON.stringify(decoded)}. Treating it as a single-member list. ` +
|
|
131
|
+
`Author an array (or a {{ref}} to a multi-select variable) instead.`
|
|
132
|
+
);
|
|
133
|
+
return [decoded];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Members compare stringified. A decoded JSON array keeps its members typed, and
|
|
137
|
+
// `Repeat` keeps a numeric row field numeric on purpose (`repeatScope.buildRowFlat`,
|
|
138
|
+
// so `gt` compares numerically), so `1` and `"1"` have to be the same member —
|
|
139
|
+
// otherwise `not_in(1, [1, 2])` is true. Shared with the `contains` array branch,
|
|
140
|
+
// which coerced neither side, so the two operators would otherwise disagree about
|
|
141
|
+
// the same data.
|
|
142
|
+
function includesMember(members: unknown[], target: unknown): boolean {
|
|
143
|
+
const needle = String(target);
|
|
144
|
+
return members.some((member) => String(member) === needle);
|
|
145
|
+
}
|
|
146
|
+
|
|
45
147
|
export function evaluateLeaf(condition: LeafCondition, variables: Record<string, unknown>): boolean {
|
|
46
148
|
const raw = decodeArrayValue(variables[condition.variable]);
|
|
47
|
-
const { operator
|
|
149
|
+
const { operator } = condition;
|
|
150
|
+
const value = interpolateRefs(condition.value, variables) as typeof condition.value;
|
|
48
151
|
|
|
49
152
|
switch (operator) {
|
|
50
153
|
case "eq":
|
|
@@ -61,12 +164,12 @@ export function evaluateLeaf(condition: LeafCondition, variables: Record<string,
|
|
|
61
164
|
return coerceToNumber(raw) <= coerceToNumber(value);
|
|
62
165
|
case "contains":
|
|
63
166
|
return Array.isArray(raw)
|
|
64
|
-
? raw
|
|
167
|
+
? includesMember(raw, value)
|
|
65
168
|
: String(raw).includes(String(value));
|
|
66
169
|
case "in":
|
|
67
|
-
return
|
|
170
|
+
return includesMember(toMemberList(value, operator), raw);
|
|
68
171
|
case "not_in":
|
|
69
|
-
return
|
|
172
|
+
return !includesMember(toMemberList(value, operator), raw);
|
|
70
173
|
case "is_empty":
|
|
71
174
|
return isEmpty(raw);
|
|
72
175
|
case "is_not_empty":
|
package/src/index.ts
CHANGED
|
@@ -11,7 +11,10 @@ export {
|
|
|
11
11
|
export type {
|
|
12
12
|
ButtonAction,
|
|
13
13
|
CustomButtonAction,
|
|
14
|
+
CustomActionRetry,
|
|
14
15
|
SetVariableButtonAction,
|
|
16
|
+
RequestPermissionButtonAction,
|
|
17
|
+
PermissionKind,
|
|
15
18
|
ComposableVariableEntry,
|
|
16
19
|
ComposableVariableKind,
|
|
17
20
|
WheelPickerElementProps,
|
|
@@ -42,7 +45,11 @@ export type {
|
|
|
42
45
|
export {
|
|
43
46
|
ButtonActionSchema,
|
|
44
47
|
CustomButtonActionSchema,
|
|
48
|
+
CustomActionRetrySchema,
|
|
45
49
|
SetVariableButtonActionSchema,
|
|
50
|
+
RequestPermissionButtonActionSchema,
|
|
51
|
+
PermissionKindSchema,
|
|
52
|
+
PERMISSION_KINDS,
|
|
46
53
|
WheelPickerElementPropsSchema,
|
|
47
54
|
generateWheelPickerRangeItems,
|
|
48
55
|
resolveWheelPickerItems,
|
|
@@ -102,6 +109,42 @@ export {
|
|
|
102
109
|
formatUnknownElementKeys,
|
|
103
110
|
} from "./screens/unknownKeys";
|
|
104
111
|
export type { UnknownElementKey } from "./screens/unknownKeys";
|
|
112
|
+
// Forward compatibility for element TYPES (#209): an element type published
|
|
113
|
+
// after this app shipped is OMITTED rather than failing the whole screen.
|
|
114
|
+
// `KNOWN_ELEMENT_TYPES` is the capability list of what this build can render.
|
|
115
|
+
export {
|
|
116
|
+
KNOWN_ELEMENT_TYPES,
|
|
117
|
+
dropUnknownElementTypes,
|
|
118
|
+
dropUnknownElementTypesInStep,
|
|
119
|
+
collectUnknownElementTypes,
|
|
120
|
+
collectUnknownElementTypesInSteps,
|
|
121
|
+
formatUnknownElementTypes,
|
|
122
|
+
} from "./screens/unknownElementTypes";
|
|
123
|
+
export type { UnknownElementType } from "./screens/unknownElementTypes";
|
|
124
|
+
// The whole render-boundary decision in one pure call: what to parse, what to
|
|
125
|
+
// log, and whether the renderer must supply its own way off the screen — a
|
|
126
|
+
// ComposableScreen authors its CTA INSIDE the element tree, so a strip can take
|
|
127
|
+
// it and leave a screen nobody can leave. `deriveElementTypeNames` is how a
|
|
128
|
+
// rendering package keys the strip on ITS OWN element union instead of this
|
|
129
|
+
// one's: what draws has to decide what is kept, and the two packages' installed
|
|
130
|
+
// versions can differ.
|
|
131
|
+
export { resolveRenderableStep } from "./screens/resolveRenderableStep";
|
|
132
|
+
export type { RenderableStep } from "./screens/resolveRenderableStep";
|
|
133
|
+
// `hasCompletingAction` answers it for a whole element tree (what the strip
|
|
134
|
+
// needs); `actionsCanComplete` answers it for one action list, which is what the
|
|
135
|
+
// UI runtime consults at press time before deciding whether a permission ask it
|
|
136
|
+
// could not perform has left the user with no way off the screen.
|
|
137
|
+
// `completingActionKind` answers WHICH of the two completing actions that list
|
|
138
|
+
// reaches — the runtime has to stand in for the author's escape with the same
|
|
139
|
+
// outcome the author authored, since `complete()` and `complete({status:
|
|
140
|
+
// "dismissed"})` are not interchangeable at a paywall's hard gate.
|
|
141
|
+
export {
|
|
142
|
+
hasCompletingAction,
|
|
143
|
+
actionsCanComplete,
|
|
144
|
+
completingActionKind,
|
|
145
|
+
} from "./screens/completingActions";
|
|
146
|
+
export type { EscapeAction } from "./screens/completingActions";
|
|
147
|
+
export { deriveElementTypeNames } from "./screens/elementTypeRegistry";
|
|
105
148
|
// Hooks and providers
|
|
106
149
|
export * from "./infra";
|
|
107
150
|
// Navigation adapter (dependency-injected navigation)
|
|
@@ -154,6 +197,18 @@ export { PaywallProvider, usePaywallHost } from "./paywalls/PaywallProvider";
|
|
|
154
197
|
// live in the headless package. onboarding-ui re-exports both names.
|
|
155
198
|
export type { CustomPaywallScreenProps, CustomPaywallScreens } from "./paywalls/customScreens";
|
|
156
199
|
export type { PaywallContextValue } from "./paywalls/PaywallProvider";
|
|
200
|
+
// `PaywallProvider`'s `observer` prop: the host's own analytics hook into every
|
|
201
|
+
// presentation. Names match rocalytics-sdk's `PaywallObserver` verbatim.
|
|
202
|
+
export type {
|
|
203
|
+
PaywallObserver,
|
|
204
|
+
PaywallPresentationInfo,
|
|
205
|
+
PaywallPresentationHandle,
|
|
206
|
+
PaywallPresentationEnd,
|
|
207
|
+
PaywallTransactionInfo,
|
|
208
|
+
PaywallSurface,
|
|
209
|
+
PaywallPresentation,
|
|
210
|
+
PaywallPresentationSource,
|
|
211
|
+
} from "./paywalls/observer";
|
|
157
212
|
export { usePaywall } from "./paywalls/usePaywall";
|
|
158
213
|
// Exported so a host can switch exhaustively on what the catalog is doing
|
|
159
214
|
// rather than inferring it from `isReady` plus a non-null check.
|
|
@@ -782,6 +782,84 @@ export const onboardingExample = {
|
|
|
782
782
|
marginVertical: 4,
|
|
783
783
|
},
|
|
784
784
|
},
|
|
785
|
+
// Expression stdlib demo. Every function runs at PRESS time (the
|
|
786
|
+
// engine's only call site is a `setVariable` action), so a
|
|
787
|
+
// computed date or an assembled sentence is written into a
|
|
788
|
+
// variable here and then plainly interpolated by the Texts below.
|
|
789
|
+
{
|
|
790
|
+
id: "stdlib-compute",
|
|
791
|
+
type: "Button",
|
|
792
|
+
props: {
|
|
793
|
+
label: "Compute my plan",
|
|
794
|
+
variant: "outlined",
|
|
795
|
+
marginVertical: 8,
|
|
796
|
+
actions: [
|
|
797
|
+
{
|
|
798
|
+
type: "setVariable",
|
|
799
|
+
name: "goalDate",
|
|
800
|
+
// `"now"` is the same sentinel DatePicker accepts, and the
|
|
801
|
+
// format spec is the DatePicker `format` prop vocabulary.
|
|
802
|
+
value: 'format(addDays("now", 90), "medium")',
|
|
803
|
+
valueMode: "expression",
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
type: "setVariable",
|
|
807
|
+
name: "goalSentence",
|
|
808
|
+
// Grammatical listing over the CheckboxGroup member labels.
|
|
809
|
+
value: "list({{goals}})",
|
|
810
|
+
valueMode: "expression",
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
type: "setVariable",
|
|
814
|
+
name: "goalCount",
|
|
815
|
+
value: 'count({{goals}}) + " " + plural(count({{goals}}), "goal", "goals")',
|
|
816
|
+
valueMode: "expression",
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
type: "setVariable",
|
|
820
|
+
name: "weeklyPace",
|
|
821
|
+
// Rounds to nearest — not trunc — and holds the result
|
|
822
|
+
// inside an inclusive range. Over the slider's
|
|
823
|
+
// 0..1 / step-0.1 grid the reachable outputs are
|
|
824
|
+
// 1,1,1,1,2,2,2,3,3,3,3 — a 4/3/4 split, the most even
|
|
825
|
+
// available for eleven positions across three values, so
|
|
826
|
+
// no stretch of the slider is inert.
|
|
827
|
+
//
|
|
828
|
+
// The multiplier is chosen so the RAW value overshoots
|
|
829
|
+
// the bounds a little and not a lot: raw runs
|
|
830
|
+
// 0,0,1,1,2,2,2,3,3,4,4, so `clamp` is OBSERVABLE at both
|
|
831
|
+
// ends (0 -> 1 twice, 4 -> 3 twice). That is the whole
|
|
832
|
+
// constraint — an expression whose raw range already sits
|
|
833
|
+
// inside 1..3, like `round(1 + {{intensity}} * 2)`, makes
|
|
834
|
+
// clamp change no value at all and demonstrates an inert
|
|
835
|
+
// function; one that overshoots hard, like `* 5`, returns
|
|
836
|
+
// 3 at six of the eleven positions and leaves the upper
|
|
837
|
+
// half of the slider dead.
|
|
838
|
+
//
|
|
839
|
+
// What this shape does not cover: no reachable position
|
|
840
|
+
// lands on an exact .5 tie, so round-half-up is pinned in
|
|
841
|
+
// `expression.test.ts` rather than here. A trunc
|
|
842
|
+
// regression is still caught at 0.4 (1.6 -> 2, not 1) and
|
|
843
|
+
// 0.7 (2.8 -> 3, not 2).
|
|
844
|
+
value: "clamp(round({{intensity}} * 4), 1, 3)",
|
|
845
|
+
valueMode: "expression",
|
|
846
|
+
},
|
|
847
|
+
],
|
|
848
|
+
},
|
|
849
|
+
},
|
|
850
|
+
{
|
|
851
|
+
id: "stdlib-display",
|
|
852
|
+
type: "Text",
|
|
853
|
+
props: {
|
|
854
|
+
content:
|
|
855
|
+
"{{goalCount}}: {{goalSentence}} — by {{goalDate}}, {{weeklyPace}}x / week",
|
|
856
|
+
mode: "expression",
|
|
857
|
+
fontSize: 14,
|
|
858
|
+
textAlign: "center",
|
|
859
|
+
opacity: 0.6,
|
|
860
|
+
marginVertical: 4,
|
|
861
|
+
},
|
|
862
|
+
},
|
|
785
863
|
{
|
|
786
864
|
id: "hero-date-picker",
|
|
787
865
|
type: "DatePicker",
|
|
@@ -1133,6 +1211,19 @@ export const onboardingExample = {
|
|
|
1133
1211
|
},
|
|
1134
1212
|
],
|
|
1135
1213
|
},
|
|
1214
|
+
// #191 — the runtime publishes `actions.pending.<elementId>` while
|
|
1215
|
+
// that element's action list is awaiting, so a pending state needs
|
|
1216
|
+
// no host code and no new element type.
|
|
1217
|
+
{
|
|
1218
|
+
id: "hero-button-pending",
|
|
1219
|
+
type: "Text",
|
|
1220
|
+
renderWhen: {
|
|
1221
|
+
variable: "actions.pending.hero-button",
|
|
1222
|
+
operator: "eq",
|
|
1223
|
+
value: "true",
|
|
1224
|
+
},
|
|
1225
|
+
props: { content: "One moment…", fontSize: 14, color: "#6B7280" },
|
|
1226
|
+
},
|
|
1136
1227
|
{
|
|
1137
1228
|
id: "hero-button",
|
|
1138
1229
|
type: "Button",
|
|
@@ -1141,8 +1232,35 @@ export const onboardingExample = {
|
|
|
1141
1232
|
variant: "filled",
|
|
1142
1233
|
marginVertical: 8,
|
|
1143
1234
|
haptic: "medium",
|
|
1235
|
+
// Deliberately NOT the `onResolve: ["continue"]` async-gate
|
|
1236
|
+
// shape (review round 1, findings 1 and 7). This payload is
|
|
1237
|
+
// the exported `fallbackOnboarding`, rendered by apps that
|
|
1238
|
+
// pass no `customActions` at all — `trackCta` is registered
|
|
1239
|
+
// nowhere in the SDK — and a gate puts the screen's only way
|
|
1240
|
+
// forward behind a handler that host may not have. The
|
|
1241
|
+
// trailing `"continue"` runs on the resolve path, and
|
|
1242
|
+
// `onError` covers the other two. The async gate is where
|
|
1243
|
+
// its handler is guaranteed: `example/app/example/
|
|
1244
|
+
// composable-screen.tsx` (`async-gate`), which is not that
|
|
1245
|
+
// screen's only CTA either.
|
|
1144
1246
|
actions: [
|
|
1145
|
-
{
|
|
1247
|
+
{
|
|
1248
|
+
type: "custom",
|
|
1249
|
+
function: "trackCta",
|
|
1250
|
+
variables: ["name", "plan", "goals"],
|
|
1251
|
+
// One attempt, bounded (#264). `trackCta` is analytics —
|
|
1252
|
+
// if the host's handler never settles, the press never
|
|
1253
|
+
// finishes, the trailing `"continue"` never runs, and the
|
|
1254
|
+
// single-flight claim drops every further tap: a dead CTA
|
|
1255
|
+
// on the screen apps get when they pass no payload at
|
|
1256
|
+
// all. 8s is generous for a fire-and-forget beacon.
|
|
1257
|
+
retry: { maxAttempts: 1, timeoutMs: 8000 },
|
|
1258
|
+
// Kept although the trailing `"continue"` now runs on
|
|
1259
|
+
// every outcome (semantics decision 1 on #191): it makes
|
|
1260
|
+
// the intent explicit at the point a reader asks "what
|
|
1261
|
+
// happens offline?", and it is where failure UI would go.
|
|
1262
|
+
onError: ["continue"],
|
|
1263
|
+
},
|
|
1146
1264
|
"continue",
|
|
1147
1265
|
],
|
|
1148
1266
|
},
|