@rocapine/react-native-onboarding 1.62.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.
Files changed (113) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +7 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/infra/hooks/index.d.ts +1 -0
  6. package/dist/infra/hooks/index.d.ts.map +1 -1
  7. package/dist/infra/hooks/index.js +3 -1
  8. package/dist/infra/hooks/index.js.map +1 -1
  9. package/dist/infra/hooks/useProgressHeaderConfig.d.ts +14 -0
  10. package/dist/infra/hooks/useProgressHeaderConfig.d.ts.map +1 -0
  11. package/dist/infra/hooks/useProgressHeaderConfig.js +24 -0
  12. package/dist/infra/hooks/useProgressHeaderConfig.js.map +1 -0
  13. package/dist/infra/preload/extractAssetUrls.d.ts.map +1 -1
  14. package/dist/infra/preload/extractAssetUrls.js +67 -0
  15. package/dist/infra/preload/extractAssetUrls.js.map +1 -1
  16. package/dist/infra/provider/OnboardingProvider.d.ts.map +1 -1
  17. package/dist/infra/provider/OnboardingProvider.js +11 -0
  18. package/dist/infra/provider/OnboardingProvider.js.map +1 -1
  19. package/dist/onboarding-example.d.ts +1063 -60
  20. package/dist/onboarding-example.d.ts.map +1 -1
  21. package/dist/onboarding-example.js +140 -0
  22. package/dist/onboarding-example.js.map +1 -1
  23. package/dist/screens/elements/AnimatedTextElement.d.ts +7 -0
  24. package/dist/screens/elements/AnimatedTextElement.d.ts.map +1 -1
  25. package/dist/screens/elements/BaseBoxProps.d.ts +39 -0
  26. package/dist/screens/elements/BaseBoxProps.d.ts.map +1 -1
  27. package/dist/screens/elements/BaseBoxProps.js +9 -0
  28. package/dist/screens/elements/BaseBoxProps.js.map +1 -1
  29. package/dist/screens/elements/ButtonElement.d.ts +28 -0
  30. package/dist/screens/elements/ButtonElement.d.ts.map +1 -1
  31. package/dist/screens/elements/CarouselElement.d.ts +38 -0
  32. package/dist/screens/elements/CarouselElement.d.ts.map +1 -1
  33. package/dist/screens/elements/CarouselElement.js +1 -0
  34. package/dist/screens/elements/CarouselElement.js.map +1 -1
  35. package/dist/screens/elements/CheckboxGroupElement.d.ts +7 -0
  36. package/dist/screens/elements/CheckboxGroupElement.d.ts.map +1 -1
  37. package/dist/screens/elements/DatePickerElement.d.ts +7 -0
  38. package/dist/screens/elements/DatePickerElement.d.ts.map +1 -1
  39. package/dist/screens/elements/DrawingPadElement.d.ts +7 -0
  40. package/dist/screens/elements/DrawingPadElement.d.ts.map +1 -1
  41. package/dist/screens/elements/IconElement.d.ts +7 -0
  42. package/dist/screens/elements/IconElement.d.ts.map +1 -1
  43. package/dist/screens/elements/ImageElement.d.ts +26 -0
  44. package/dist/screens/elements/ImageElement.d.ts.map +1 -1
  45. package/dist/screens/elements/ImageElement.js +1 -0
  46. package/dist/screens/elements/ImageElement.js.map +1 -1
  47. package/dist/screens/elements/InputElement.d.ts +7 -0
  48. package/dist/screens/elements/InputElement.d.ts.map +1 -1
  49. package/dist/screens/elements/KeyboardAvoidingViewElement.d.ts +7 -0
  50. package/dist/screens/elements/KeyboardAvoidingViewElement.d.ts.map +1 -1
  51. package/dist/screens/elements/LottieElement.d.ts +7 -0
  52. package/dist/screens/elements/LottieElement.d.ts.map +1 -1
  53. package/dist/screens/elements/ProgressIndicatorElement.d.ts +7 -0
  54. package/dist/screens/elements/ProgressIndicatorElement.d.ts.map +1 -1
  55. package/dist/screens/elements/ProgressiveBlurImageElement.d.ts +7 -0
  56. package/dist/screens/elements/ProgressiveBlurImageElement.d.ts.map +1 -1
  57. package/dist/screens/elements/RadioGroupElement.d.ts +7 -0
  58. package/dist/screens/elements/RadioGroupElement.d.ts.map +1 -1
  59. package/dist/screens/elements/RepeatElement.d.ts +79 -0
  60. package/dist/screens/elements/RepeatElement.d.ts.map +1 -0
  61. package/dist/screens/elements/RepeatElement.js +10 -0
  62. package/dist/screens/elements/RepeatElement.js.map +1 -0
  63. package/dist/screens/elements/RichTextElement.d.ts +7 -0
  64. package/dist/screens/elements/RichTextElement.d.ts.map +1 -1
  65. package/dist/screens/elements/RiveElement.d.ts +7 -0
  66. package/dist/screens/elements/RiveElement.d.ts.map +1 -1
  67. package/dist/screens/elements/SafeAreaViewElement.d.ts +7 -0
  68. package/dist/screens/elements/SafeAreaViewElement.d.ts.map +1 -1
  69. package/dist/screens/elements/ScrollViewElement.d.ts +7 -0
  70. package/dist/screens/elements/ScrollViewElement.d.ts.map +1 -1
  71. package/dist/screens/elements/SliderElement.d.ts +7 -0
  72. package/dist/screens/elements/SliderElement.d.ts.map +1 -1
  73. package/dist/screens/elements/StackElement.d.ts +7 -0
  74. package/dist/screens/elements/StackElement.d.ts.map +1 -1
  75. package/dist/screens/elements/TextElement.d.ts +7 -0
  76. package/dist/screens/elements/TextElement.d.ts.map +1 -1
  77. package/dist/screens/elements/TypewriterTextElement.d.ts +26 -0
  78. package/dist/screens/elements/TypewriterTextElement.d.ts.map +1 -1
  79. package/dist/screens/elements/TypewriterTextElement.js +1 -0
  80. package/dist/screens/elements/TypewriterTextElement.js.map +1 -1
  81. package/dist/screens/elements/VideoElement.d.ts +7 -0
  82. package/dist/screens/elements/VideoElement.d.ts.map +1 -1
  83. package/dist/screens/elements/WheelPickerElement.d.ts +7 -0
  84. package/dist/screens/elements/WheelPickerElement.d.ts.map +1 -1
  85. package/dist/screens/elements/ZStackElement.d.ts +7 -0
  86. package/dist/screens/elements/ZStackElement.d.ts.map +1 -1
  87. package/dist/screens/types.d.ts +9 -0
  88. package/dist/screens/types.d.ts.map +1 -1
  89. package/dist/screens/types.js +9 -0
  90. package/dist/screens/types.js.map +1 -1
  91. package/dist/screens/unknownKeys.d.ts +67 -0
  92. package/dist/screens/unknownKeys.d.ts.map +1 -0
  93. package/dist/screens/unknownKeys.js +160 -0
  94. package/dist/screens/unknownKeys.js.map +1 -0
  95. package/dist/types.d.ts +73 -0
  96. package/dist/types.d.ts.map +1 -1
  97. package/package.json +1 -1
  98. package/src/__tests__/extractAssetUrls.test.ts +104 -0
  99. package/src/__tests__/unknownKeys.test.ts +234 -0
  100. package/src/index.ts +8 -0
  101. package/src/infra/hooks/index.ts +1 -0
  102. package/src/infra/hooks/useProgressHeaderConfig.ts +21 -0
  103. package/src/infra/preload/extractAssetUrls.ts +72 -0
  104. package/src/infra/provider/OnboardingProvider.tsx +14 -0
  105. package/src/onboarding-example.ts +140 -0
  106. package/src/screens/elements/BaseBoxProps.ts +56 -0
  107. package/src/screens/elements/CarouselElement.ts +31 -0
  108. package/src/screens/elements/ImageElement.ts +16 -0
  109. package/src/screens/elements/RepeatElement.ts +80 -0
  110. package/src/screens/elements/TypewriterTextElement.ts +19 -0
  111. package/src/screens/types.ts +18 -0
  112. package/src/screens/unknownKeys.ts +211 -0
  113. package/src/types.ts +86 -0
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatUnknownElementKeys = exports.collectUnknownKeysInSteps = exports.collectUnknownElementKeys = void 0;
4
+ const types_1 = require("./types");
5
+ const zdef = (schema) => { var _a, _b; return (_b = (_a = schema === null || schema === void 0 ? void 0 : schema._zod) === null || _a === void 0 ? void 0 : _a.def) !== null && _b !== void 0 ? _b : schema === null || schema === void 0 ? void 0 : schema._def; };
6
+ // Every string literal a `type` field can hold. Most variants use
7
+ // `z.literal("X")`, but the stack variant is `z.union([literal, literal])`.
8
+ const literalsOf = (schema) => {
9
+ var _a, _b;
10
+ const def = zdef(schema);
11
+ if (!def)
12
+ return [];
13
+ if (def.type === "literal") {
14
+ const values = (_a = def.values) !== null && _a !== void 0 ? _a : (def.value !== undefined ? [def.value] : []);
15
+ return values.filter((v) => typeof v === "string");
16
+ }
17
+ if (def.type === "union")
18
+ return ((_b = def.options) !== null && _b !== void 0 ? _b : []).flatMap(literalsOf);
19
+ return [];
20
+ };
21
+ let registry = null;
22
+ // Built once, lazily. Any shape change in zod's internals degrades to "no
23
+ // registry", which makes the whole feature a no-op rather than a crash — this is
24
+ // a diagnostic, it must never be able to break rendering.
25
+ const getRegistry = () => {
26
+ var _a, _b, _c, _d, _e;
27
+ if (registry)
28
+ return registry;
29
+ const built = new Map();
30
+ try {
31
+ const lazyDef = zdef(types_1.UIElementSchema);
32
+ const union = typeof (lazyDef === null || lazyDef === void 0 ? void 0 : lazyDef.getter) === "function" ? lazyDef.getter() : types_1.UIElementSchema;
33
+ const options = (_b = (_a = zdef(union)) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : [];
34
+ for (const option of options) {
35
+ const shape = (_c = zdef(option)) === null || _c === void 0 ? void 0 : _c.shape;
36
+ if (!shape)
37
+ continue;
38
+ const propsShape = (_e = (_d = zdef(shape.props)) === null || _d === void 0 ? void 0 : _d.shape) !== null && _e !== void 0 ? _e : {};
39
+ const keySets = {
40
+ topLevel: new Set(Object.keys(shape)),
41
+ props: new Set(Object.keys(propsShape)),
42
+ };
43
+ for (const typeName of literalsOf(shape.type))
44
+ built.set(typeName, keySets);
45
+ }
46
+ }
47
+ catch (_f) {
48
+ // fall through to whatever was built before the failure
49
+ }
50
+ registry = built;
51
+ return registry;
52
+ };
53
+ const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
54
+ // Structural comparison good enough to tell "same value duplicated" from "two
55
+ // values that disagree". Falls back to "assume they differ" if the value can't be
56
+ // serialized (circular / exotic), since a false alarm is cheaper here than
57
+ // staying silent about a real conflict.
58
+ const valuesDiffer = (a, b) => {
59
+ if (a === b)
60
+ return false;
61
+ try {
62
+ return JSON.stringify(a) !== JSON.stringify(b);
63
+ }
64
+ catch (_a) {
65
+ return true;
66
+ }
67
+ };
68
+ /**
69
+ * Walk an element tree and report unrecognized top-level keys.
70
+ *
71
+ * Elements whose `type` isn't in the schema are skipped rather than reported —
72
+ * an unknown element type is a parse error the union already surfaces properly,
73
+ * and guessing its key set would produce noise.
74
+ */
75
+ const collectUnknownElementKeys = (elements, basePath = "elements") => {
76
+ const known = getRegistry();
77
+ if (known.size === 0 || !Array.isArray(elements))
78
+ return [];
79
+ const found = [];
80
+ const visit = (node, path) => {
81
+ if (!isRecord(node))
82
+ return;
83
+ const elementType = typeof node.type === "string" ? node.type : undefined;
84
+ const keySets = elementType ? known.get(elementType) : undefined;
85
+ if (keySets) {
86
+ const props = isRecord(node.props) ? node.props : undefined;
87
+ for (const key of Object.keys(node)) {
88
+ if (keySets.topLevel.has(key))
89
+ continue;
90
+ const isValidProp = keySets.props.has(key);
91
+ const alreadyInProps = isValidProp && props !== undefined && key in props;
92
+ found.push({
93
+ path,
94
+ elementId: typeof node.id === "string" ? node.id : "(no id)",
95
+ elementType: elementType,
96
+ key,
97
+ kind: !isValidProp ? "unknown" : alreadyInProps ? "shadowed" : "misplaced",
98
+ suggestion: isValidProp ? `props.${key}` : undefined,
99
+ conflicts: alreadyInProps ? valuesDiffer(node[key], props[key]) : undefined,
100
+ });
101
+ }
102
+ }
103
+ // Recurse regardless of whether this node was recognized, so a stray key
104
+ // nested under an unknown-typed parent is still found.
105
+ if (Array.isArray(node.children)) {
106
+ node.children.forEach((child, i) => visit(child, `${path}.children[${i}]`));
107
+ }
108
+ };
109
+ elements.forEach((element, i) => visit(element, `${basePath}[${i}]`));
110
+ return found;
111
+ };
112
+ exports.collectUnknownElementKeys = collectUnknownElementKeys;
113
+ /**
114
+ * Same check across a whole steps array, for callers holding a fetched
115
+ * onboarding rather than one screen's elements. Only steps carrying
116
+ * `payload.elements` are inspected; other step types have no element tree.
117
+ */
118
+ const collectUnknownKeysInSteps = (steps) => {
119
+ if (!Array.isArray(steps))
120
+ return [];
121
+ return steps.flatMap((step, i) => {
122
+ if (!isRecord(step))
123
+ return [];
124
+ const payload = step.payload;
125
+ if (!isRecord(payload) || !Array.isArray(payload.elements))
126
+ return [];
127
+ const stepId = typeof step.id === "string" ? step.id : String(i);
128
+ return (0, exports.collectUnknownElementKeys)(payload.elements, `step[${stepId}].elements`);
129
+ });
130
+ };
131
+ exports.collectUnknownKeysInSteps = collectUnknownKeysInSteps;
132
+ /** Human-readable report; returns "" when there is nothing to say. */
133
+ const formatUnknownElementKeys = (found) => {
134
+ if (found.length === 0)
135
+ return "";
136
+ const lines = found.map((f) => {
137
+ const where = `${f.path} (${f.elementType} "${f.elementId}")`;
138
+ if (f.kind === "shadowed") {
139
+ // Do NOT say "did you mean props.X?" here — props.X is already there. The
140
+ // useful warning is which copy wins, because the trap is editing the dead
141
+ // one and concluding the renderer is broken.
142
+ return f.conflicts
143
+ ? ` • ${where}: "${f.key}" is ignored — ${f.suggestion} is ALSO set, to a ` +
144
+ `different value, and that is the one taking effect. Editing this ` +
145
+ `top-level copy will do nothing; delete it.`
146
+ : ` • ${where}: "${f.key}" is ignored — ${f.suggestion} is already set to the ` +
147
+ `same value and is the one taking effect. Delete this top-level copy.`;
148
+ }
149
+ if (f.kind === "misplaced") {
150
+ return ` • ${where}: "${f.key}" is not a top-level key — did you mean ${f.suggestion}?`;
151
+ }
152
+ return ` • ${where}: unrecognized top-level key "${f.key}"`;
153
+ });
154
+ return (`[onboarding] ${found.length} unrecognized top-level ` +
155
+ `${found.length === 1 ? "key" : "keys"} on elements. These are silently ` +
156
+ `dropped when the payload is parsed, so they have no effect:\n` +
157
+ lines.join("\n"));
158
+ };
159
+ exports.formatUnknownElementKeys = formatUnknownElementKeys;
160
+ //# sourceMappingURL=unknownKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unknownKeys.js","sourceRoot":"","sources":["../../src/screens/unknownKeys.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAuD1C,MAAM,IAAI,GAAG,CAAC,MAAW,EAAO,EAAE,eAAC,OAAA,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,GAAG,mCAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAA,EAAA,CAAC;AAErE,kEAAkE;AAClE,4EAA4E;AAC5E,MAAM,UAAU,GAAG,CAAC,MA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QAC7E,CAAC;QACD,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAC3B,OAAO,OAAO,KAAK,MAAM,CAAC,CAAC,GAAG,2CAA2C,CAAC,CAAC,UAAU,GAAG,CAAC;QAC3F,CAAC;QACD,OAAO,OAAO,KAAK,iCAAiC,CAAC,CAAC,GAAG,GAAG,CAAC;IAC/D,CAAC,CAAC,CAAC;IACH,OAAO,CACL,gBAAgB,KAAK,CAAC,MAAM,0BAA0B;QACtD,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,mCAAmC;QACzE,+DAA+D;QAC/D,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CACjB,CAAC;AACJ,CAAC,CAAC;AA1BW,QAAA,wBAAwB,4BA0BnC"}
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
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,6BAA6B,CACvC,QAAQ,SAAS,YAAY,GAAG,YAAY,IAC1C;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,C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
+ "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",
@@ -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,234 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import {
3
+ collectUnknownElementKeys,
4
+ collectUnknownKeysInSteps,
5
+ formatUnknownElementKeys,
6
+ } from "../screens/unknownKeys";
7
+ import { ComposableScreenStepTypeSchema } from "../steps/ComposableScreen/types";
8
+
9
+ describe("collectUnknownElementKeys", () => {
10
+ it("finds a BaseBoxProp written one level too high and says where it belongs", () => {
11
+ // The real-world case: `animation` next to `type`/`props` instead of inside
12
+ // `props`. Parses fine, renders fine, animation never happens.
13
+ const found = collectUnknownElementKeys([
14
+ {
15
+ id: "hero",
16
+ type: "Image",
17
+ props: { url: "https://x/y.png" },
18
+ animation: { entering: { preset: "FadeInDown", duration: 300 } },
19
+ },
20
+ ]);
21
+
22
+ expect(found).toHaveLength(1);
23
+ expect(found[0]).toMatchObject({
24
+ path: "elements[0]",
25
+ elementId: "hero",
26
+ elementType: "Image",
27
+ key: "animation",
28
+ kind: "misplaced",
29
+ suggestion: "props.animation",
30
+ });
31
+ });
32
+
33
+ it("distinguishes a STALE DUPLICATE from a misplaced prop", () => {
34
+ // The real corpus case: `props.animation` is already present and working
35
+ // (200ms), and a stale top-level copy (300ms) sits alongside it doing
36
+ // nothing. "did you mean props.animation?" would be actively misleading —
37
+ // they didn't forget it, they have two and are probably editing the dead one.
38
+ const found = collectUnknownElementKeys([
39
+ {
40
+ id: "loader-img-1",
41
+ type: "Image",
42
+ props: {
43
+ url: "https://x/y.png",
44
+ animation: { entering: { preset: "FadeIn", duration: 200, easing: "ease-in" } },
45
+ },
46
+ animation: { entering: { preset: "FadeIn", duration: 300, easing: "ease-in-out" } },
47
+ },
48
+ ]);
49
+
50
+ expect(found).toHaveLength(1);
51
+ expect(found[0]).toMatchObject({
52
+ key: "animation",
53
+ kind: "shadowed",
54
+ suggestion: "props.animation",
55
+ conflicts: true,
56
+ });
57
+ });
58
+
59
+ it("does not cry wolf when the duplicate is identical", () => {
60
+ const anim = { entering: { preset: "FadeIn", duration: 200 } };
61
+ const found = collectUnknownElementKeys([
62
+ { id: "i", type: "Image", props: { url: "u", animation: anim }, animation: { ...anim } },
63
+ ]);
64
+ expect(found[0]).toMatchObject({ kind: "shadowed", conflicts: false });
65
+ });
66
+
67
+ it("treats a key absent from props as misplaced even when props exists", () => {
68
+ const found = collectUnknownElementKeys([
69
+ { id: "i", type: "Image", props: { url: "u" }, onPress: [] },
70
+ ]);
71
+ expect(found[0]).toMatchObject({ kind: "misplaced", suggestion: "props.onPress" });
72
+ });
73
+
74
+ it("confirms the misplaced key really is dropped by the schema (why this exists)", () => {
75
+ const step = {
76
+ id: "s",
77
+ name: "n",
78
+ type: "ComposableScreen",
79
+ displayProgressHeader: true,
80
+ payload: {
81
+ elements: [
82
+ {
83
+ id: "hero",
84
+ type: "Image",
85
+ props: { url: "https://x/y.png" },
86
+ animation: { entering: { preset: "FadeInDown", duration: 300 } },
87
+ },
88
+ ],
89
+ },
90
+ };
91
+
92
+ const parsed = ComposableScreenStepTypeSchema.safeParse(step);
93
+ // Parsing SUCCEEDS — that is the whole problem.
94
+ expect(parsed.success).toBe(true);
95
+ expect((parsed as any).data.payload.elements[0].animation).toBeUndefined();
96
+ // ...and the diagnostic is what surfaces it.
97
+ expect(collectUnknownElementKeys(step.payload.elements)).toHaveLength(1);
98
+ });
99
+
100
+ it("reports a genuinely unknown key with no suggestion", () => {
101
+ const found = collectUnknownElementKeys([
102
+ { id: "t", type: "Text", props: { content: "hi" }, wobble: 3 },
103
+ ]);
104
+ expect(found).toHaveLength(1);
105
+ expect(found[0].key).toBe("wobble");
106
+ expect(found[0].kind).toBe("unknown");
107
+ expect(found[0].suggestion).toBeUndefined();
108
+ });
109
+
110
+ it("is silent on correct elements, including every valid top-level key", () => {
111
+ const found = collectUnknownElementKeys([
112
+ {
113
+ id: "stack",
114
+ name: "a name",
115
+ type: "YStack",
116
+ renderWhen: { variable: "v", operator: "eq", value: 1 },
117
+ props: { gap: 8 },
118
+ children: [{ id: "t", type: "Text", props: { content: "hi" } }],
119
+ },
120
+ ]);
121
+ expect(found).toEqual([]);
122
+ });
123
+
124
+ it("descends into children and reports the nested path", () => {
125
+ const found = collectUnknownElementKeys([
126
+ {
127
+ id: "outer",
128
+ type: "YStack",
129
+ props: {},
130
+ children: [
131
+ { id: "ok", type: "Text", props: { content: "fine" } },
132
+ { id: "bad", type: "Text", props: { content: "x" }, onPress: [] },
133
+ ],
134
+ },
135
+ ]);
136
+ expect(found).toHaveLength(1);
137
+ expect(found[0].path).toBe("elements[0].children[1]");
138
+ expect(found[0].suggestion).toBe("props.onPress");
139
+ });
140
+
141
+ it("skips unknown element types but still checks their children", () => {
142
+ // An unknown `type` is a parse error the union already reports well; guessing
143
+ // its key set would be noise. Its children are still ordinary elements.
144
+ const found = collectUnknownElementKeys([
145
+ {
146
+ id: "mystery",
147
+ type: "NotAnElement",
148
+ props: {},
149
+ bogus: 1,
150
+ children: [{ id: "t", type: "Text", props: { content: "x" }, animation: {} }],
151
+ },
152
+ ]);
153
+ expect(found).toHaveLength(1);
154
+ expect(found[0].elementId).toBe("t");
155
+ });
156
+
157
+ it("never throws on malformed input", () => {
158
+ expect(collectUnknownElementKeys(undefined)).toEqual([]);
159
+ expect(collectUnknownElementKeys("nope")).toEqual([]);
160
+ expect(collectUnknownElementKeys([null, 42, undefined])).toEqual([]);
161
+ expect(collectUnknownElementKeys([{ type: "Text" }])).toEqual([]);
162
+ });
163
+
164
+ it("derives allowed keys from the schema, so container children are recognised", () => {
165
+ // `children` is valid on YStack but not on Image — derived per variant, not
166
+ // from one hardcoded list.
167
+ expect(collectUnknownElementKeys([{ id: "y", type: "YStack", props: {}, children: [] }])).toEqual([]);
168
+ const onImage = collectUnknownElementKeys([
169
+ { id: "i", type: "Image", props: { url: "u" }, children: [] },
170
+ ]);
171
+ expect(onImage).toHaveLength(1);
172
+ expect(onImage[0].key).toBe("children");
173
+ });
174
+ });
175
+
176
+ describe("collectUnknownKeysInSteps", () => {
177
+ it("scans every ComposableScreen step and labels findings by step id", () => {
178
+ const found = collectUnknownKeysInSteps([
179
+ { id: "intro", type: "MediaContent", payload: { title: "no elements here" } },
180
+ {
181
+ id: "reveal",
182
+ type: "ComposableScreen",
183
+ payload: {
184
+ elements: [
185
+ { id: "a", type: "Image", props: { url: "u" }, animation: {} },
186
+ { id: "b", type: "Image", props: { url: "u" }, animation: {} },
187
+ ],
188
+ },
189
+ },
190
+ ]);
191
+ expect(found).toHaveLength(2);
192
+ expect(found[0].path).toBe("step[reveal].elements[0]");
193
+ expect(found.every((f) => f.suggestion === "props.animation")).toBe(true);
194
+ });
195
+
196
+ it("returns nothing for step lists with no element trees", () => {
197
+ expect(collectUnknownKeysInSteps([{ id: "x", type: "Ratings", payload: {} }])).toEqual([]);
198
+ expect(collectUnknownKeysInSteps(undefined)).toEqual([]);
199
+ });
200
+ });
201
+
202
+ describe("formatUnknownElementKeys", () => {
203
+ it("returns an empty string when there is nothing to report", () => {
204
+ expect(formatUnknownElementKeys([])).toBe("");
205
+ });
206
+
207
+ it("says which copy wins for a stale duplicate, and never says 'did you mean'", () => {
208
+ const msg = formatUnknownElementKeys(
209
+ collectUnknownElementKeys([
210
+ {
211
+ id: "loader-img-1",
212
+ type: "Image",
213
+ props: { url: "u", animation: { entering: { duration: 200 } } },
214
+ animation: { entering: { duration: 300 } },
215
+ },
216
+ ])
217
+ );
218
+ expect(msg).toContain("is ignored");
219
+ expect(msg).toContain("different value");
220
+ expect(msg).toContain("taking effect");
221
+ expect(msg).not.toContain("did you mean");
222
+ });
223
+
224
+ it("names the fix for a misplaced prop", () => {
225
+ const msg = formatUnknownElementKeys(
226
+ collectUnknownElementKeys([
227
+ { id: "hero", type: "Image", props: { url: "u" }, animation: {} },
228
+ ])
229
+ );
230
+ expect(msg).toContain('did you mean props.animation?');
231
+ expect(msg).toContain("hero");
232
+ expect(msg).toContain("silently dropped");
233
+ });
234
+ });
package/src/index.ts CHANGED
@@ -47,6 +47,14 @@ export {
47
47
  generateWheelPickerRangeItems,
48
48
  resolveWheelPickerItems,
49
49
  } from "./steps/ComposableScreen/types";
50
+ // Payload diagnostics — non-fatal detection of keys placed at an element's top
51
+ // level that the schema silently drops (e.g. `animation` outside `props`).
52
+ export {
53
+ collectUnknownElementKeys,
54
+ collectUnknownKeysInSteps,
55
+ formatUnknownElementKeys,
56
+ } from "./screens/unknownKeys";
57
+ export type { UnknownElementKey } from "./screens/unknownKeys";
50
58
  // Hooks and providers
51
59
  export * from "./infra";
52
60
  // Navigation adapter (dependency-injected navigation)
@@ -3,3 +3,4 @@ export { useOnboardingStart } from "./useOnboardingStart";
3
3
  export { useOnboarding } from "./useOnboarding";
4
4
  export { useOnboardingHeaderHeight } from "./useOnboardingHeaderHeight";
5
5
  export { useOnboardingNavigation } from "./useOnboardingNavigation";
6
+ export { useProgressHeaderConfig } from "./useProgressHeaderConfig";
@@ -0,0 +1,21 @@
1
+ import { useContext } from "react";
2
+ import { OnboardingProgressContext } from "../provider/OnboardingProvider";
3
+ import type { ProgressHeaderConfiguration } from "../../types";
4
+
5
+ const EMPTY: ProgressHeaderConfiguration = {};
6
+
7
+ /**
8
+ * Studio-authored progress-header styling (`configuration.progressHeader`).
9
+ *
10
+ * Returns an empty object when the onboarding hasn't loaded yet or the studio
11
+ * hasn't authored the block, so callers can read fields unconditionally and fall
12
+ * back per-field rather than branching on the whole object.
13
+ *
14
+ * The progress header is host-rendered (the app mounts `<ProgressBar>` in its
15
+ * layout), so the bar reads this itself instead of the provider passing props
16
+ * down — that keeps the studio knob working without every host changing code.
17
+ */
18
+ export const useProgressHeaderConfig = (): ProgressHeaderConfiguration => {
19
+ const { onboarding } = useContext(OnboardingProgressContext);
20
+ return onboarding?.configuration?.progressHeader ?? EMPTY;
21
+ };