@scenar/core 0.0.1
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/LICENSE +190 -0
- package/README.md +65 -0
- package/cursor/compute-position.d.ts +14 -0
- package/cursor/compute-position.d.ts.map +1 -0
- package/cursor/compute-position.js +17 -0
- package/cursor/compute-position.js.map +1 -0
- package/dom/scroll.d.ts +27 -0
- package/dom/scroll.d.ts.map +1 -0
- package/dom/scroll.js +63 -0
- package/dom/scroll.js.map +1 -0
- package/index.d.ts +15 -0
- package/index.d.ts.map +1 -0
- package/index.js +14 -0
- package/index.js.map +1 -0
- package/narration/types.d.ts +26 -0
- package/narration/types.d.ts.map +1 -0
- package/narration/types.js +11 -0
- package/narration/types.js.map +1 -0
- package/package.json +29 -0
- package/scenario/step-action.d.ts +105 -0
- package/scenario/step-action.d.ts.map +1 -0
- package/scenario/step-action.js +2 -0
- package/scenario/step-action.js.map +1 -0
- package/scenario/types.d.ts +35 -0
- package/scenario/types.d.ts.map +1 -0
- package/scenario/types.js +8 -0
- package/scenario/types.js.map +1 -0
- package/src/cursor/compute-position.test.ts +46 -0
- package/src/cursor/compute-position.ts +23 -0
- package/src/dom/scroll.test.ts +35 -0
- package/src/dom/scroll.ts +64 -0
- package/src/index.ts +53 -0
- package/src/narration/types.ts +27 -0
- package/src/scenario/step-action.ts +113 -0
- package/src/scenario/types.ts +36 -0
- package/src/targeting/data-attributes.test.ts +22 -0
- package/src/targeting/data-attributes.ts +30 -0
- package/src/timeline/compute-step-timeline.test.ts +60 -0
- package/src/timeline/compute-step-timeline.ts +49 -0
- package/src/timeline/derive-step.test.ts +37 -0
- package/src/timeline/derive-step.ts +15 -0
- package/src/timeline/step-duration.test.ts +38 -0
- package/src/timeline/step-duration.ts +25 -0
- package/src/timing/constants.ts +59 -0
- package/src/viewport/transform.ts +13 -0
- package/targeting/data-attributes.d.ts +21 -0
- package/targeting/data-attributes.d.ts.map +1 -0
- package/targeting/data-attributes.js +25 -0
- package/targeting/data-attributes.js.map +1 -0
- package/timeline/compute-step-timeline.d.ts +27 -0
- package/timeline/compute-step-timeline.d.ts.map +1 -0
- package/timeline/compute-step-timeline.js +26 -0
- package/timeline/compute-step-timeline.js.map +1 -0
- package/timeline/derive-step.d.ts +7 -0
- package/timeline/derive-step.d.ts.map +1 -0
- package/timeline/derive-step.js +13 -0
- package/timeline/derive-step.js.map +1 -0
- package/timeline/step-duration.d.ts +12 -0
- package/timeline/step-duration.d.ts.map +1 -0
- package/timeline/step-duration.js +18 -0
- package/timeline/step-duration.js.map +1 -0
- package/timing/constants.d.ts +55 -0
- package/timing/constants.d.ts.map +1 -0
- package/timing/constants.js +55 -0
- package/timing/constants.js.map +1 -0
- package/viewport/transform.d.ts +9 -0
- package/viewport/transform.d.ts.map +1 -0
- package/viewport/transform.js +7 -0
- package/viewport/transform.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Scenar Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @scenar/core
|
|
2
|
+
|
|
3
|
+
Pure TypeScript types, timing constants, and utility functions for the Scenar scenario playback engine. Zero framework dependencies — no React, no DOM (except scroll utilities).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @scenar/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What's inside
|
|
12
|
+
|
|
13
|
+
### Scenario types
|
|
14
|
+
|
|
15
|
+
- **`ScenarioStep<T>`** — A single step in a scenario timeline with typed data payload, delay, caption, narration text, and inline interactions.
|
|
16
|
+
- **`StepAction`** — A timed interaction within a step (click, type, hover, drag, scroll_to, set_cursor, clear_cursor, viewport_transition).
|
|
17
|
+
|
|
18
|
+
### Timeline computation
|
|
19
|
+
|
|
20
|
+
- **`computeStepTimeline(steps, manifest)`** — Pre-compute step start times and total duration from step delays and narration clip durations.
|
|
21
|
+
- **`deriveStepFromTime(currentTimeMs, stepStartTimesMs, maxIndex)`** — Find the active step for a given playback time (used by the video-export path).
|
|
22
|
+
- **`getStepDurationMs(stepIndex, manifest, steps)`** — Effective duration of a step for interaction timing.
|
|
23
|
+
|
|
24
|
+
### Timing constants
|
|
25
|
+
|
|
26
|
+
- `CLICK_DELAY_MS` (450) — Cursor settle time before click ripple.
|
|
27
|
+
- `TYPE_CHAR_DELAY_MS` (50) — Default per-character typing delay.
|
|
28
|
+
- `HOVER_HOLD_MS` (1500) — Default hover dwell time.
|
|
29
|
+
- `DRAG_SETTLE_MS` (200) — Pause at drag source before movement.
|
|
30
|
+
- `VIEWPORT_SETTLE_MS` (500) — Viewport transition spring settle time.
|
|
31
|
+
|
|
32
|
+
### DOM utilities
|
|
33
|
+
|
|
34
|
+
- `findScrollParent(el)` — Walk up the DOM to find the nearest scrollable ancestor.
|
|
35
|
+
- `scrollTargetIntoView(el)` — Smooth-scroll an element into its scroll container.
|
|
36
|
+
- `scrollTargetIntoViewInstant(el)` — Instant-scroll variant for video export.
|
|
37
|
+
|
|
38
|
+
### Cursor position
|
|
39
|
+
|
|
40
|
+
- `computeCursorPosition(container, el)` — Compute cursor position accounting for CSS zoom.
|
|
41
|
+
|
|
42
|
+
### Data-attribute contract
|
|
43
|
+
|
|
44
|
+
The engine identifies interactive elements via data attributes. These constants are the single source of truth:
|
|
45
|
+
|
|
46
|
+
- `CURSOR_TARGET_ATTRIBUTE` — `"data-cursor-target"`
|
|
47
|
+
- `SCROLL_TARGET_ATTRIBUTE` — `"data-scroll-target"`
|
|
48
|
+
- `HOVER_STATE_ATTRIBUTE` — `"data-hover"`
|
|
49
|
+
- `DRAG_STATE_ATTRIBUTE` — `"data-dragging"`
|
|
50
|
+
- `cursorTargetSelector(id)` — Build a CSS selector for a cursor target.
|
|
51
|
+
- `scrollTargetSelector(id)` — Build a CSS selector for a scroll target.
|
|
52
|
+
|
|
53
|
+
### Viewport transform
|
|
54
|
+
|
|
55
|
+
- `ViewportTransform` — `{ scale, x, y }` for zoom/pan state.
|
|
56
|
+
- `VIEWPORT_TRANSFORM_IDENTITY` — The no-op transform.
|
|
57
|
+
|
|
58
|
+
### Narration types
|
|
59
|
+
|
|
60
|
+
- `NarrationEntry` — `{ src, durationMs }` for one audio clip.
|
|
61
|
+
- `NarrationManifest` — `{ steps: (NarrationEntry | null)[] }`.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
Apache-2.0
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** A 2D point in CSS coordinate space. */
|
|
2
|
+
export interface Position {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Compute cursor position relative to the container, accounting for
|
|
8
|
+
* CSS zoom on ancestors. `getBoundingClientRect` returns viewport
|
|
9
|
+
* coordinates (post-zoom), but `position: absolute` inside a
|
|
10
|
+
* CSS-zoomed container uses pre-zoom coordinates. Dividing by the
|
|
11
|
+
* effective zoom converts viewport offsets back to CSS space.
|
|
12
|
+
*/
|
|
13
|
+
export declare function computeCursorPosition(container: HTMLElement, el: Element): Position;
|
|
14
|
+
//# sourceMappingURL=compute-position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute-position.d.ts","sourceRoot":"","sources":["../../src/cursor/compute-position.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,WAAW,QAAQ;IACvB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,WAAW,EAAE,EAAE,EAAE,OAAO,GAAG,QAAQ,CASnF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute cursor position relative to the container, accounting for
|
|
3
|
+
* CSS zoom on ancestors. `getBoundingClientRect` returns viewport
|
|
4
|
+
* coordinates (post-zoom), but `position: absolute` inside a
|
|
5
|
+
* CSS-zoomed container uses pre-zoom coordinates. Dividing by the
|
|
6
|
+
* effective zoom converts viewport offsets back to CSS space.
|
|
7
|
+
*/
|
|
8
|
+
export function computeCursorPosition(container, el) {
|
|
9
|
+
const cRect = container.getBoundingClientRect();
|
|
10
|
+
const eRect = el.getBoundingClientRect();
|
|
11
|
+
const zoom = cRect.width / container.offsetWidth || 1;
|
|
12
|
+
return {
|
|
13
|
+
x: (eRect.left - cRect.left + eRect.width / 2) / zoom,
|
|
14
|
+
y: (eRect.top - cRect.top + eRect.height / 2) / zoom,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=compute-position.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compute-position.js","sourceRoot":"","sources":["../../src/cursor/compute-position.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAAsB,EAAE,EAAW;IACvE,MAAM,KAAK,GAAG,SAAS,CAAC,qBAAqB,EAAE,CAAC;IAChD,MAAM,KAAK,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;IACzC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,WAAW,IAAI,CAAC,CAAC;IAEtD,OAAO;QACL,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI;QACrD,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI;KACrD,CAAC;AACJ,CAAC"}
|
package/dom/scroll.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared scroll helpers used by both the Cursor component and
|
|
3
|
+
* the step-interactions hook.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Walk up the DOM tree to find the nearest scrollable ancestor
|
|
7
|
+
* of the given element (one with `overflow-y: auto` or `scroll`).
|
|
8
|
+
*/
|
|
9
|
+
export declare function findScrollParent(el: Element): Element | null;
|
|
10
|
+
/**
|
|
11
|
+
* Scroll the target element into view inside its nearest scrollable
|
|
12
|
+
* ancestor using the browser's native `scrollIntoView`. This handles
|
|
13
|
+
* CSS `zoom` correctly (manual `scrollTop` arithmetic does not).
|
|
14
|
+
*
|
|
15
|
+
* After scrolling the internal container, page scroll is immediately
|
|
16
|
+
* restored so the demo block doesn't jump on the page.
|
|
17
|
+
*
|
|
18
|
+
* @returns `true` when scrolling was necessary.
|
|
19
|
+
*/
|
|
20
|
+
export declare function scrollTargetIntoView(el: Element): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Instant-scroll variant for video export where smooth scrolling
|
|
23
|
+
* doesn't work across Remotion frames. Sets `scrollTop` directly
|
|
24
|
+
* on the nearest scrollable ancestor.
|
|
25
|
+
*/
|
|
26
|
+
export declare function scrollTargetIntoViewInstant(el: Element): void;
|
|
27
|
+
//# sourceMappingURL=scroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.d.ts","sourceRoot":"","sources":["../../src/dom/scroll.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAQ5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,GAAG,OAAO,CAczD;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAa7D"}
|
package/dom/scroll.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared scroll helpers used by both the Cursor component and
|
|
3
|
+
* the step-interactions hook.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Walk up the DOM tree to find the nearest scrollable ancestor
|
|
7
|
+
* of the given element (one with `overflow-y: auto` or `scroll`).
|
|
8
|
+
*/
|
|
9
|
+
export function findScrollParent(el) {
|
|
10
|
+
let parent = el.parentElement;
|
|
11
|
+
while (parent) {
|
|
12
|
+
const { overflowY } = getComputedStyle(parent);
|
|
13
|
+
if (overflowY === "auto" || overflowY === "scroll")
|
|
14
|
+
return parent;
|
|
15
|
+
parent = parent.parentElement;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Scroll the target element into view inside its nearest scrollable
|
|
21
|
+
* ancestor using the browser's native `scrollIntoView`. This handles
|
|
22
|
+
* CSS `zoom` correctly (manual `scrollTop` arithmetic does not).
|
|
23
|
+
*
|
|
24
|
+
* After scrolling the internal container, page scroll is immediately
|
|
25
|
+
* restored so the demo block doesn't jump on the page.
|
|
26
|
+
*
|
|
27
|
+
* @returns `true` when scrolling was necessary.
|
|
28
|
+
*/
|
|
29
|
+
export function scrollTargetIntoView(el) {
|
|
30
|
+
const scrollParent = findScrollParent(el);
|
|
31
|
+
if (!scrollParent)
|
|
32
|
+
return false;
|
|
33
|
+
const pRect = scrollParent.getBoundingClientRect();
|
|
34
|
+
const eRect = el.getBoundingClientRect();
|
|
35
|
+
const isVisible = eRect.top >= pRect.top && eRect.bottom <= pRect.bottom;
|
|
36
|
+
if (isVisible)
|
|
37
|
+
return false;
|
|
38
|
+
const pageX = window.scrollX;
|
|
39
|
+
const pageY = window.scrollY;
|
|
40
|
+
el.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
41
|
+
window.scrollTo(pageX, pageY);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Instant-scroll variant for video export where smooth scrolling
|
|
46
|
+
* doesn't work across Remotion frames. Sets `scrollTop` directly
|
|
47
|
+
* on the nearest scrollable ancestor.
|
|
48
|
+
*/
|
|
49
|
+
export function scrollTargetIntoViewInstant(el) {
|
|
50
|
+
const scrollParent = findScrollParent(el);
|
|
51
|
+
if (!scrollParent)
|
|
52
|
+
return;
|
|
53
|
+
const pRect = scrollParent.getBoundingClientRect();
|
|
54
|
+
const eRect = el.getBoundingClientRect();
|
|
55
|
+
const isVisible = eRect.top >= pRect.top && eRect.bottom <= pRect.bottom;
|
|
56
|
+
if (isVisible)
|
|
57
|
+
return;
|
|
58
|
+
const pageX = window.scrollX;
|
|
59
|
+
const pageY = window.scrollY;
|
|
60
|
+
el.scrollIntoView({ block: "center", behavior: "instant" });
|
|
61
|
+
window.scrollTo(pageX, pageY);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=scroll.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scroll.js","sourceRoot":"","sources":["../../src/dom/scroll.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAW;IAC1C,IAAI,MAAM,GAAG,EAAE,CAAC,aAAa,CAAC;IAC9B,OAAO,MAAM,EAAE,CAAC;QACd,MAAM,EAAE,SAAS,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,SAAS,KAAK,MAAM,IAAI,SAAS,KAAK,QAAQ;YAAE,OAAO,MAAM,CAAC;QAClE,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;IAChC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAW;IAC9C,MAAM,YAAY,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC1C,IAAI,CAAC,YAAY;QAAE,OAAO,KAAK,CAAC;IAEhC,MAAM,KAAK,GAAG,YAAY,CAAC,qBAAqB,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IACzE,IAAI,SAAS;QAAE,OAAO,KAAK,CAAC;IAE5B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,EAAE,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,EAAW;IACrD,MAAM,YAAY,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC1C,IAAI,CAAC,YAAY;QAAE,OAAO;IAE1B,MAAM,KAAK,GAAG,YAAY,CAAC,qBAAqB,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;IACzC,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;IACzE,IAAI,SAAS;QAAE,OAAO;IAEtB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,EAAE,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5D,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAChC,CAAC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type { ScenarioStep } from "./scenario/types.js";
|
|
2
|
+
export type { ActionType, StepAction, UseStepInteractionsOptions, } from "./scenario/step-action.js";
|
|
3
|
+
export type { NarrationEntry, NarrationManifest } from "./narration/types.js";
|
|
4
|
+
export type { ViewportTransform } from "./viewport/transform.js";
|
|
5
|
+
export { VIEWPORT_TRANSFORM_IDENTITY } from "./viewport/transform.js";
|
|
6
|
+
export type { Position } from "./cursor/compute-position.js";
|
|
7
|
+
export { computeCursorPosition } from "./cursor/compute-position.js";
|
|
8
|
+
export type { StepTimeline } from "./timeline/compute-step-timeline.js";
|
|
9
|
+
export { computeStepTimeline } from "./timeline/compute-step-timeline.js";
|
|
10
|
+
export { deriveStepFromTime } from "./timeline/derive-step.js";
|
|
11
|
+
export { getStepDurationMs } from "./timeline/step-duration.js";
|
|
12
|
+
export { CLICK_DELAY_MS, TYPE_CHAR_DELAY_MS, HOVER_HOLD_MS, DRAG_SETTLE_MS, VIEWPORT_SETTLE_MS, } from "./timing/constants.js";
|
|
13
|
+
export { findScrollParent, scrollTargetIntoView, scrollTargetIntoViewInstant, } from "./dom/scroll.js";
|
|
14
|
+
export { CURSOR_TARGET_ATTRIBUTE, SCROLL_TARGET_ATTRIBUTE, HOVER_STATE_ATTRIBUTE, DRAG_STATE_ATTRIBUTE, cursorTargetSelector, scrollTargetSelector, } from "./targeting/data-attributes.js";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,YAAY,EACV,UAAU,EACV,UAAU,EACV,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9E,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAGtE,YAAY,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,YAAY,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gCAAgC,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @scenar/core — public API
|
|
2
|
+
// Pure TypeScript types, timing, and utilities for scenario playback.
|
|
3
|
+
export { VIEWPORT_TRANSFORM_IDENTITY } from "./viewport/transform.js";
|
|
4
|
+
export { computeCursorPosition } from "./cursor/compute-position.js";
|
|
5
|
+
export { computeStepTimeline } from "./timeline/compute-step-timeline.js";
|
|
6
|
+
export { deriveStepFromTime } from "./timeline/derive-step.js";
|
|
7
|
+
export { getStepDurationMs } from "./timeline/step-duration.js";
|
|
8
|
+
// Timing constants
|
|
9
|
+
export { CLICK_DELAY_MS, TYPE_CHAR_DELAY_MS, HOVER_HOLD_MS, DRAG_SETTLE_MS, VIEWPORT_SETTLE_MS, } from "./timing/constants.js";
|
|
10
|
+
// DOM scroll utilities
|
|
11
|
+
export { findScrollParent, scrollTargetIntoView, scrollTargetIntoViewInstant, } from "./dom/scroll.js";
|
|
12
|
+
// Data-attribute targeting contract
|
|
13
|
+
export { CURSOR_TARGET_ATTRIBUTE, SCROLL_TARGET_ATTRIBUTE, HOVER_STATE_ATTRIBUTE, DRAG_STATE_ATTRIBUTE, cursorTargetSelector, scrollTargetSelector, } from "./targeting/data-attributes.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,sEAAsE;AAetE,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAItE,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAIrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,uBAAuB;AACvB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AAEzB,oCAAoC;AACpC,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime narration audio data produced by a TTS build script.
|
|
3
|
+
*
|
|
4
|
+
* ScenarioPlayer consumes a {@link NarrationManifest} to play audio
|
|
5
|
+
* clips synced to step progression. Step authors write narration text
|
|
6
|
+
* on scenario steps — the build script reads that text, generates
|
|
7
|
+
* audio files, and writes a manifest that maps step indices to audio
|
|
8
|
+
* URLs and durations.
|
|
9
|
+
*/
|
|
10
|
+
/** A single audio clip for one scenario step. */
|
|
11
|
+
export interface NarrationEntry {
|
|
12
|
+
/** URL of the audio file (e.g. "/demos/approval-flow/step-0.mp3"). */
|
|
13
|
+
src: string;
|
|
14
|
+
/** Duration of the audio clip in milliseconds. */
|
|
15
|
+
durationMs: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Per-scenario manifest mapping step indices to narration audio.
|
|
19
|
+
*
|
|
20
|
+
* Array position corresponds to the step index. Steps without
|
|
21
|
+
* narration use `null`.
|
|
22
|
+
*/
|
|
23
|
+
export interface NarrationManifest {
|
|
24
|
+
steps: (NarrationEntry | null)[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/narration/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,iDAAiD;AACjD,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC;CAClC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime narration audio data produced by a TTS build script.
|
|
3
|
+
*
|
|
4
|
+
* ScenarioPlayer consumes a {@link NarrationManifest} to play audio
|
|
5
|
+
* clips synced to step progression. Step authors write narration text
|
|
6
|
+
* on scenario steps — the build script reads that text, generates
|
|
7
|
+
* audio files, and writes a manifest that maps step indices to audio
|
|
8
|
+
* URLs and durations.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/narration/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@scenar/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Pure TypeScript types, timing, and utilities for the Scenar scenario engine.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/scenar-ai/scenar.git",
|
|
11
|
+
"directory": "packages/core"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"scenar",
|
|
15
|
+
"scenario",
|
|
16
|
+
"demo",
|
|
17
|
+
"playback",
|
|
18
|
+
"timeline",
|
|
19
|
+
"engine"
|
|
20
|
+
],
|
|
21
|
+
"main": "./index.js",
|
|
22
|
+
"types": "./index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./index.d.ts",
|
|
26
|
+
"import": "./index.js"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { NarrationManifest } from "../narration/types.js";
|
|
2
|
+
import type { ViewportTransform } from "../viewport/transform.js";
|
|
3
|
+
import type { ScenarioStep } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* The set of interaction types the engine understands.
|
|
6
|
+
*
|
|
7
|
+
* Values match the proto `ActionType` enum names (`ai.scenar.scenario.v1`)
|
|
8
|
+
* so that proto ↔ engine mapping is a direct string copy.
|
|
9
|
+
*/
|
|
10
|
+
export type ActionType = "scroll_to" | "set_cursor" | "clear_cursor" | "click" | "type" | "hover" | "drag" | "viewport_transition";
|
|
11
|
+
/** A single timed interaction within a step. */
|
|
12
|
+
export interface StepAction {
|
|
13
|
+
/**
|
|
14
|
+
* When to fire, as a fraction of the step's narration duration
|
|
15
|
+
* (0.0 = step start, 1.0 = narration end). The hook reads the
|
|
16
|
+
* narration manifest to compute the real millisecond time.
|
|
17
|
+
*
|
|
18
|
+
* When no narration is available (muted / no manifest), the next
|
|
19
|
+
* step's `delayMs` is used as the fallback step duration.
|
|
20
|
+
*/
|
|
21
|
+
readonly atPercent: number;
|
|
22
|
+
/** Action type. */
|
|
23
|
+
readonly type: ActionType;
|
|
24
|
+
/**
|
|
25
|
+
* Target element identifier.
|
|
26
|
+
* - For `scroll_to`: matches `[data-scroll-target="<target>"]`
|
|
27
|
+
* - For `set_cursor` / `click` / `type` / `hover`: matches `[data-cursor-target="<target>"]`
|
|
28
|
+
* - For `drag`: matches `[data-cursor-target="<target>"]` (drag source)
|
|
29
|
+
*/
|
|
30
|
+
readonly target?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Drag destination element identifier. Only used by `drag` actions.
|
|
33
|
+
* Matches `[data-cursor-target="<dragTarget>"]`.
|
|
34
|
+
*/
|
|
35
|
+
readonly dragTarget?: string;
|
|
36
|
+
/** Text to type character-by-character. Only used by `type` actions. */
|
|
37
|
+
readonly text?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Milliseconds between characters for `type` actions.
|
|
40
|
+
* Defaults to {@link TYPE_CHAR_DELAY_MS} (50 ms).
|
|
41
|
+
*/
|
|
42
|
+
readonly typeDelay?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Milliseconds to hold the cursor over the target during a `hover`
|
|
45
|
+
* action, between enter-event dispatch and leave-event dispatch.
|
|
46
|
+
* Defaults to {@link HOVER_HOLD_MS} (1500 ms).
|
|
47
|
+
*/
|
|
48
|
+
readonly hoverDuration?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Zoom scale factor for `viewport_transition` actions.
|
|
51
|
+
* Values > 1 zoom in, < 1 zoom out. Defaults to 1.5.
|
|
52
|
+
* Ignored when {@link viewportReset} is `true`.
|
|
53
|
+
*/
|
|
54
|
+
readonly viewportZoom?: number;
|
|
55
|
+
/**
|
|
56
|
+
* When `true`, a `viewport_transition` action resets the viewport
|
|
57
|
+
* to the identity transform (scale 1, no translation). `target`
|
|
58
|
+
* and `viewportZoom` are ignored.
|
|
59
|
+
*/
|
|
60
|
+
readonly viewportReset?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** Configuration for the useStepInteractions hook. */
|
|
63
|
+
export interface UseStepInteractionsOptions<T> {
|
|
64
|
+
/** Current active step index from ScenarioPlayer. */
|
|
65
|
+
stepIndex: number;
|
|
66
|
+
/** Narration manifest for duration lookup. */
|
|
67
|
+
narrationManifest: NarrationManifest | undefined;
|
|
68
|
+
/** Container ref for DOM queries. */
|
|
69
|
+
containerRef: {
|
|
70
|
+
current: HTMLElement | null;
|
|
71
|
+
};
|
|
72
|
+
/** Callback to change the cursor target mid-step. */
|
|
73
|
+
setCursorTarget: (target: string | undefined) => void;
|
|
74
|
+
/**
|
|
75
|
+
* The full steps array. Interactions are read from each step's
|
|
76
|
+
* `interactions` field. Step `delayMs` is used as fallback duration
|
|
77
|
+
* when narration is unavailable.
|
|
78
|
+
*/
|
|
79
|
+
steps: readonly ScenarioStep<T>[];
|
|
80
|
+
/**
|
|
81
|
+
* Playback speed multiplier (default 1). Browser-path timeouts are
|
|
82
|
+
* divided by this value so interactions fire proportionally earlier
|
|
83
|
+
* at higher speeds.
|
|
84
|
+
*/
|
|
85
|
+
playbackRate?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Optional callback to control the Cursor's click ripple. The
|
|
88
|
+
* `hover` action calls `setShowRipple(false)` before moving the
|
|
89
|
+
* cursor and `setShowRipple(true)` after hover leave events fire.
|
|
90
|
+
*/
|
|
91
|
+
setShowRipple?: (show: boolean) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Optional callback to control the Cursor's drag visual. The
|
|
94
|
+
* `drag` action calls `setDragging(true)` after pressing at the
|
|
95
|
+
* source and `setDragging(false)` after releasing at the destination.
|
|
96
|
+
*/
|
|
97
|
+
setDragging?: (dragging: boolean) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Optional callback to apply a viewport transform (zoom/pan). The
|
|
100
|
+
* `viewport_transition` action computes scale and translate values
|
|
101
|
+
* needed to center the target element and calls this callback.
|
|
102
|
+
*/
|
|
103
|
+
setViewportTransform?: (transform: ViewportTransform) => void;
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=step-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-action.d.ts","sourceRoot":"","sources":["../../src/scenario/step-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,YAAY,GACZ,cAAc,GACd,OAAO,GACP,MAAM,GACN,OAAO,GACP,MAAM,GACN,qBAAqB,CAAC;AAE1B,gDAAgD;AAChD,MAAM,WAAW,UAAU;IACzB;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,sDAAsD;AACtD,MAAM,WAAW,0BAA0B,CAAC,CAAC;IAC3C,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,iBAAiB,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACjD,qCAAqC;IACrC,YAAY,EAAE;QAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;KAAE,CAAC;IAC9C,qDAAqD;IACrD,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IACtD;;;;OAIG;IACH,KAAK,EAAE,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAClC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-action.js","sourceRoot":"","sources":["../../src/scenario/step-action.ts"],"names":[],"mappings":""}
|