@protomaze/demo-engine 0.0.0-stage → 0.1.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/AGENTS.md +131 -0
- package/README.md +192 -2
- package/agent/Agent.d.ts +155 -0
- package/agent/Agent.js +1 -0
- package/agent/Guide.d.ts +2 -0
- package/agent/Guide.js +1 -0
- package/engine/DemoEngine.d.ts +338 -0
- package/engine/DemoEngine.js +1 -0
- package/engine/Guided.d.ts +12 -0
- package/engine/Guided.js +1 -0
- package/engine/Player.d.ts +154 -0
- package/engine/Player.js +1 -0
- package/engine/Plugin.d.ts +56 -0
- package/engine/Plugin.js +1 -0
- package/engine/Read.d.ts +5 -0
- package/engine/Read.js +1 -0
- package/engine/Recorder.d.ts +50 -0
- package/engine/Recorder.js +1 -0
- package/engine/Settings.d.ts +51 -0
- package/engine/Settings.js +1 -0
- package/index.d.ts +27 -0
- package/index.js +1 -0
- package/model/Demo.d.ts +201 -0
- package/model/Demo.js +1 -0
- package/model/Subtitles.d.ts +12 -0
- package/model/Subtitles.js +1 -0
- package/model/Timing.d.ts +45 -0
- package/model/Timing.js +1 -0
- package/model/Validate.d.ts +16 -0
- package/model/Validate.js +1 -0
- package/package.json +65 -4
- package/page/Input.d.ts +67 -0
- package/page/Input.js +1 -0
- package/page/Overlay.d.ts +110 -0
- package/page/Overlay.js +1 -0
- package/page/Targets.d.ts +85 -0
- package/page/Targets.js +1 -0
- package/speech/Music.d.ts +13 -0
- package/speech/Music.js +1 -0
- package/speech/Pack.d.ts +27 -0
- package/speech/Pack.js +1 -0
- package/speech/Speech.d.ts +127 -0
- package/speech/Speech.js +1 -0
- package/speech/Transcribe.d.ts +25 -0
- package/speech/Transcribe.js +1 -0
- package/speech/Workers.d.ts +22 -0
- package/speech/Workers.js +1 -0
- package/store/Share.d.ts +19 -0
- package/store/Share.js +1 -0
- package/store/Store.d.ts +55 -0
- package/store/Store.js +1 -0
- package/store/Zip.d.ts +9 -0
- package/store/Zip.js +1 -0
- package/ui/Actions.d.ts +33 -0
- package/ui/Actions.js +1 -0
- package/ui/EngineUI.d.ts +3 -0
- package/ui/EngineUI.js +1 -0
- package/ui/Hooks.d.ts +5 -0
- package/ui/Hooks.js +1 -0
- package/ui/Kit.d.ts +108 -0
- package/ui/Kit.js +1 -0
- package/ui/Library.d.ts +32 -0
- package/ui/Library.js +1 -0
- package/ui/Studio.d.ts +10 -0
- package/ui/Studio.js +1 -0
- package/ui/Styles.d.ts +2 -0
- package/ui/Styles.js +1 -0
- package/ui/Timeline.d.ts +21 -0
- package/ui/Timeline.js +1 -0
- package/video/Film.d.ts +61 -0
- package/video/Film.js +1 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
<!-- Made from src/agent/Guide.ts by dev/guide.js: edit that. -->
|
|
2
|
+
|
|
3
|
+
An app using @protomaze/demo-engine exposes these tools on `window.demoEngine` in development.
|
|
4
|
+
Drive them through a browser's JavaScript console or an agent's "run JavaScript in the page" tool.
|
|
5
|
+
|
|
6
|
+
# Making a demo with demoEngine
|
|
7
|
+
|
|
8
|
+
You see the app in a browser and run JavaScript in it. `window.demoEngine` has the tools; every
|
|
9
|
+
result is plain data. A demo is steps; each step's narration is spoken (and subtitled) a sentence at
|
|
10
|
+
a time while its actions play one after the other. Actions point at elements as a person would: by
|
|
11
|
+
what they show, not where they are.
|
|
12
|
+
|
|
13
|
+
## Workflow
|
|
14
|
+
|
|
15
|
+
1. `demoEngine.languages()` - which languages to write narration in.
|
|
16
|
+
`demoEngine.start()` - where the app is; a demo starts there. `demoEngine.demos()` - what exists.
|
|
17
|
+
2. Explore. `demoEngine.page()` lists what can be acted on, each with a ready `target`, its label,
|
|
18
|
+
state and box; `page({ query: 'save' })` or `page({ within: '[data-demo="filters"]' })` narrows it.
|
|
19
|
+
Look with screenshots too. `demoEngine.try({ do: 'click', target })` does one action now and says
|
|
20
|
+
what appeared and went: walk the app this way to learn the path the demo will take.
|
|
21
|
+
3. Plan the story before the actions: what should the viewer understand at the end? One idea per step.
|
|
22
|
+
4. Write the demo (format below). Narration first, then the actions that show it.
|
|
23
|
+
5. `demoEngine.validate(demo)` - its shape. Then `await demoEngine.check(demo)` - from the demo's
|
|
24
|
+
start, fast and silent, going past what fails, its cleanup after; fix every failure and check
|
|
25
|
+
again until `ok` twice in a row (the second run proves the cleanup).
|
|
26
|
+
6. `await demoEngine.save(demo)`, then `demoEngine.open(demo.id)` - the person sees it in the
|
|
27
|
+
studio, can play, tune, film and share it. `demoEngine.play(id)` plays it with sound once the
|
|
28
|
+
person clicks. `demoEngine.estimate(demo)` gives its length.
|
|
29
|
+
|
|
30
|
+
## Length
|
|
31
|
+
|
|
32
|
+
- Short (a teaser, one feature): 4-7 steps, 30-60 s, one or two sentences a step.
|
|
33
|
+
- Normal (a tour): 8-12 steps, 1-3 min.
|
|
34
|
+
- Detailed (a deep dive): 12-25 steps, 3-6 min; still one idea per step.
|
|
35
|
+
|
|
36
|
+
## What it is for
|
|
37
|
+
|
|
38
|
+
- Marketing video: short, benefit first, a `card` to open and close, zooms on what impresses; no
|
|
39
|
+
setup steps on screen. The person films it (film button); music can play under it.
|
|
40
|
+
- Sales pitch: one step per point the presenter makes; `pause: true` on steps where they talk
|
|
41
|
+
freely. They advance with a clicker (PageDown) and repeat with PageUp.
|
|
42
|
+
- Expo booth: 30-90 s, readable without sound (subtitles carry it), ends where it started so it can
|
|
43
|
+
loop. `demoEngine.loop([ids])` plays them unattended; a visitor's touch hands the app over.
|
|
44
|
+
- Tutorial or training: `demoEngine.guide(id)` lets the viewer do each click and entry themselves,
|
|
45
|
+
ringed with what to do. Narrate why, not only what; small steps; one new thing each.
|
|
46
|
+
|
|
47
|
+
## Narration
|
|
48
|
+
|
|
49
|
+
- For the viewer, about what matters to them: "Which pipes need work first?" before "Click Risk".
|
|
50
|
+
- Present tense, plain words, at most ~20 words a sentence; a step ~1-3 sentences.
|
|
51
|
+
- Say what to look at as it happens; name things as the app names them.
|
|
52
|
+
- Every language of `languages().write`: `say: { en: '…', de: '…' }`. Same meaning, natural in each.
|
|
53
|
+
- No "In this demo…" filler; open with the question or the benefit, close with what was shown.
|
|
54
|
+
|
|
55
|
+
## Format
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"id": "orders-tour",
|
|
60
|
+
"title": "Orders, from list to invoice",
|
|
61
|
+
"description": "One sentence: who it is for and what it shows.",
|
|
62
|
+
"start": { "…": "as demoEngine.start() gives it, or leave out" },
|
|
63
|
+
"steps": [
|
|
64
|
+
{
|
|
65
|
+
"title": "Find an order",
|
|
66
|
+
"say": { "en": "Every order lands here, newest first. Let's find one from Berlin." },
|
|
67
|
+
"actions": [
|
|
68
|
+
{ "do": "spotlight", "target": { "css": "table", "text": "orders" }, "for": 2500 },
|
|
69
|
+
{ "do": "type", "target": { "css": "input[type=\"search\"]" }, "text": "Berlin", "cue": 1 },
|
|
70
|
+
{ "do": "click", "target": { "css": "tr", "text": "berlin #" }, "wait": 1200 }
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A target: `{ css, text?, key?, index? }` - the `index`th (0-based) element matching `css` whose label
|
|
78
|
+
is `text` (or the app's locale `key`'s text: works in every language). Labels compare without case,
|
|
79
|
+
spacing, and with every number as "#": a row "Berlin 42" is "berlin #". Use the targets `page()` and
|
|
80
|
+
`describe()` give: they prefer locale keys and named regions. Avoid `index` where a scope does it:
|
|
81
|
+
`{ css: '[data-demo="filters"] button', text: 'apply' }`.
|
|
82
|
+
|
|
83
|
+
Every action has `wait` (ms before it, default 800) and `cue` (start with the step's sentence of that
|
|
84
|
+
index, 0-based: syncs a click with the words about it, in every language and voice).
|
|
85
|
+
|
|
86
|
+
Interactions:
|
|
87
|
+
- `click` { target, at?: [x, y] fractions of the box, double?, right?, shift?, ctrl?, alt?, meta? }
|
|
88
|
+
- `hover` { target, at? } - shows tooltips and hover cards (not CSS :hover looks)
|
|
89
|
+
- `type` { target, text } - replaces the field's text, a letter at a time
|
|
90
|
+
- `key` { key, target? } - 'Escape', 'Enter', 'ArrowDown', 'Control+K'; shown as keycaps
|
|
91
|
+
- `select` { target, option } - a native <select>'s option by text or value
|
|
92
|
+
- `drag` { target, at?, to: { target?, at? } } - sliders, drag and drop, panning
|
|
93
|
+
- `scroll` { target?, by?: [x, y] } - into view, or by pixels
|
|
94
|
+
- `waitFor` { target, gone?, timeout? } - until it shows (or goes): after what loads
|
|
95
|
+
|
|
96
|
+
Presentation (shown until the step ends, or `for` ms; `clear` takes all down):
|
|
97
|
+
- `spotlight` { target, text?, padding? } - dims everything else: the one thing to look at
|
|
98
|
+
- `ring` { target, text?, color?, shape?: 'box' | 'circle' } - a pulsing outline
|
|
99
|
+
- `arrow` { target, text?, from?: 'top' | 'right' | 'bottom' | 'left' } - points at it
|
|
100
|
+
- `callout` { text, target?, side?, corner? } - a note by the target, or in a corner
|
|
101
|
+
- `blur` { target } - hides names, addresses, anything private
|
|
102
|
+
- `card` { title, text? } - full screen: an opening title, a chapter, the end
|
|
103
|
+
- `zoom` { target, scale? } - magnifies the page around it (1.8 by default)
|
|
104
|
+
- `clear`
|
|
105
|
+
|
|
106
|
+
The app may add its own actions (a map's `view`, `mapClick`): `validate` lists every kind it knows
|
|
107
|
+
when one is wrong; read the app's demos (`demoEngine.get(id)`) for examples.
|
|
108
|
+
|
|
109
|
+
Step options: `title` (for the editor), `hold` (ms after), `pause: true` (waits for the presenter).
|
|
110
|
+
|
|
111
|
+
`cleanup`: actions done after the demo - when it ends or is stopped - quickly and unseen, so the app
|
|
112
|
+
is as it found it and the demo plays again: clear filters and searches, close what was opened, go
|
|
113
|
+
back to the first tab. What the app cannot undo through its UI, its start resets.
|
|
114
|
+
|
|
115
|
+
## Good demos
|
|
116
|
+
|
|
117
|
+
- Open with a `card` (title, one line of promise), close with one (what was shown, what next).
|
|
118
|
+
- Direct the eye: a spotlight or ring on what the sentence is about, an arrow for small things.
|
|
119
|
+
- Let the viewer see results: a `wait` of 1500-3000 ms after what changes a lot; `waitFor` what loads.
|
|
120
|
+
- Keep the pointer purposeful: no clicks that do not move the story.
|
|
121
|
+
- Blur personal data.
|
|
122
|
+
- Leave the app as it started: a `cleanup` list undoes what the steps changed, so demos run one
|
|
123
|
+
after another and again. Check that too: `check` runs the cleanup, then `check` again.
|
|
124
|
+
|
|
125
|
+
## Tools
|
|
126
|
+
|
|
127
|
+
help() · languages() · start() · page({ within?, query?, limit? }) · find(target) ·
|
|
128
|
+
describe(css | [x, y]) · try(action) · preview(presentationAction, ms?) · demos() · get(id) ·
|
|
129
|
+
validate(demo) · estimate(demoOrId) · check(demoOrId, { from?, to? }) · save(demo) · remove(id) ·
|
|
130
|
+
open(demoOrId) · play(demoOrId, { from? }) · guide(demoOrId, { from? }) · loop([demoOrId]) ·
|
|
131
|
+
stopLoop() · stop() · state() · link(demoOrId)
|
package/README.md
CHANGED
|
@@ -1,3 +1,193 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Protomaze Demo Engine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Demos of a web app, made and played in the app itself, in the browser: no backend.
|
|
4
|
+
|
|
5
|
+
- **Make**: by an AI through the browser (`window.demoEngine`), by recording what you do (and say),
|
|
6
|
+
or by hand in the studio, on a `@protomaze/time` timeline.
|
|
7
|
+
- **Narrate**: text to speech in the browser (Kokoro, Piper: free, no key) or ElevenLabs; speech to
|
|
8
|
+
text (Whisper in the browser, or ElevenLabs) turns what you said into narration and subtitles.
|
|
9
|
+
A **narration pack** keeps a demo's finished audio, so every viewer hears it without a key, tokens
|
|
10
|
+
or a model download.
|
|
11
|
+
- **Show**: a stand-in pointer, spotlights, rings, arrows, notes, blur, title cards, zoom, keycaps.
|
|
12
|
+
- **Play**: as a video would; **present** step by step with a clicker; **guide** a viewer who does
|
|
13
|
+
each step themselves (tutorials, trainings); **loop** unattended at an expo booth.
|
|
14
|
+
- **Film**: an MP4 or WebM of the tab with narration, music and subtitles, made in the browser, at
|
|
15
|
+
exactly 720p, 1080p, 1440p or 4K, landscape, portrait or square.
|
|
16
|
+
- **Music**: four tracks the engine composes itself (calm, lo-fi, bright, piano) - free to use
|
|
17
|
+
anywhere, nothing downloaded - or a file of one's own; quieter under the narration.
|
|
18
|
+
- **Share**: `.demo.json`, a scenario `.md`, a link with the demo in it, the video, `.vtt` / `.srt`.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm run dev # the sample app, on http://localhost:8095: "Demos" bottom left
|
|
22
|
+
npm test # the model: validation, timing, subtitles
|
|
23
|
+
npm run check # type-check everything, sample included
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## In an app
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { DemoEngine, dictionaryLabels } from '@protomaze/demo-engine';
|
|
30
|
+
|
|
31
|
+
const engine = new DemoEngine({
|
|
32
|
+
app: 'orders', // where demos, videos and settings are kept
|
|
33
|
+
demos: [{ demo: tour, scenario: tourMarkdown }], // the app's own, checked in as <id>.demo.json
|
|
34
|
+
languages: ['en', 'de'], // narration is written in these
|
|
35
|
+
language: () => i18n.language, // the page's
|
|
36
|
+
labels: dictionaryLabels(() => LOCALES[i18n.language], key => t(key)), // targets in every language
|
|
37
|
+
start: { // where a demo starts, in the app's terms
|
|
38
|
+
current: () => ({ tenant, mode }),
|
|
39
|
+
go: start => (start.tenant !== tenant ? reloadWith(start) : setMode(start.mode)), // 'reload' if it navigates
|
|
40
|
+
},
|
|
41
|
+
plugins: [mapPlugin(map)], // actions only the app knows
|
|
42
|
+
ready: () => map.whenReady(), // before a demo plays
|
|
43
|
+
filmElement: () => document.getElementById('app'), // videos crop to it, where the browser can
|
|
44
|
+
launcher: true, // a "Demos" button, for apps without a panel
|
|
45
|
+
narration: demo => `/demos/${demo.id}.narration.zip`, // packs checked in beside the demos
|
|
46
|
+
});
|
|
47
|
+
await engine.mount();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or put the library in the app's own panel: `<DemoLibrary engine={engine} />` (in its own shadow
|
|
51
|
+
root: the app's styles stay out). Everything else - the studio, the bars while playing and
|
|
52
|
+
recording, effects - the engine renders over the app, in the top layer.
|
|
53
|
+
|
|
54
|
+
From code: `engine.play(demo, { from })`, `engine.guide(demo)`, `engine.film(demo)`,
|
|
55
|
+
`engine.record()`, `engine.loop(demos, { idle, reset: 'reload' })`, `engine.check(demo)`,
|
|
56
|
+
`engine.openStudio(demo)`, `engine.link(demo)`. Sound and filming need a click in the app's window:
|
|
57
|
+
started from elsewhere (a dev panel in its own window, a link, code) the engine asks for one.
|
|
58
|
+
React: `useEngine(engine)`, `useDemos(engine)`.
|
|
59
|
+
|
|
60
|
+
## Demos
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"id": "risk-tour",
|
|
65
|
+
"title": "Risk, explained",
|
|
66
|
+
"start": { "tenant": "Gelsenkirchen" },
|
|
67
|
+
"steps": [
|
|
68
|
+
{
|
|
69
|
+
"say": { "en": "Which pipes matter most?", "de": "Welche Haltungen sind am wichtigsten?" },
|
|
70
|
+
"actions": [
|
|
71
|
+
{ "do": "spotlight", "target": { "css": "[data-demo=\"risk matrix\"]" } },
|
|
72
|
+
{ "do": "click", "target": { "css": "button", "key": "risk_reset_weights" }, "cue": 0, "wait": 1200 }
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Each step's narration is spoken a sentence at a time, each a subtitle, while its actions play one
|
|
80
|
+
after the other. A target is `{ css, text?, key?, index? }`: the elements matching `css` whose label -
|
|
81
|
+
`data-demo`, their text, `aria-label`, a field's label - is `text`, or the locale `key`'s text in the
|
|
82
|
+
page's language. Labels compare without case or spacing, every number as `#`. `wait` is ms before an
|
|
83
|
+
action (800), `cue` starts it with a sentence of the step: synced in every language and voice.
|
|
84
|
+
|
|
85
|
+
Actions: `click`, `hover`, `type`, `key`, `select`, `drag`, `scroll`, `waitFor`; and to present,
|
|
86
|
+
`spotlight`, `ring`, `arrow`, `callout`, `blur`, `card`, `zoom`, `clear` (shown till the step ends,
|
|
87
|
+
or `for` ms). [AGENTS.md](AGENTS.md) has every field; it is also what an AI reads.
|
|
88
|
+
|
|
89
|
+
A demo leaves the app as it found it, so it plays again and the next starts where it expects:
|
|
90
|
+
its `cleanup` actions run after it - when it ends or is stopped - quickly and unseen (filters
|
|
91
|
+
cleared, what it opened closed); what the app cannot undo through its UI, `start.go` resets before
|
|
92
|
+
every play and check (a sandbox tenant, demo data reloaded, the page reloaded).
|
|
93
|
+
|
|
94
|
+
`data-demo="name"` on an element names it for demos in every language and gives targets a scope.
|
|
95
|
+
`data-demo-ignore` keeps a part of the page out of recording and targets (a dev panel).
|
|
96
|
+
|
|
97
|
+
## Plugins
|
|
98
|
+
|
|
99
|
+
What only the app knows: a map's views and points, a canvas chart's bars.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const mapPlugin = (map: WebGLMap): DemoPlugin => ({
|
|
103
|
+
name: 'map',
|
|
104
|
+
actions: {
|
|
105
|
+
view: { play: action => showBounds(map, action.bounds), read: () => 'Move the map', duration: () => 1200 },
|
|
106
|
+
mapClick: {
|
|
107
|
+
async play(action, { hand }) {
|
|
108
|
+
const at = toView(map, action.at); // lon, lat → px in the map
|
|
109
|
+
const box = map.domNode.getBoundingClientRect();
|
|
110
|
+
await hand.click(map.domNode, { x: box.left + at.x, y: box.top + at.y }, { shift: action.shift });
|
|
111
|
+
},
|
|
112
|
+
read: () => 'Click on the map',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
record: ({ push }) => {
|
|
116
|
+
const moved = map.on('MapChange', () => /* once at rest */ push({ do: 'view', bounds: viewBounds(map) }));
|
|
117
|
+
return {
|
|
118
|
+
claims: element => map.domNode.contains(element), // the engine records nothing there itself
|
|
119
|
+
click: (element, x, y) => ({ do: 'mapClick', at: toWorld(map, x, y) }),
|
|
120
|
+
stop: () => moved.remove(),
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Narration packs
|
|
127
|
+
|
|
128
|
+
The studio's share menu (or the library's) makes `<id>.narration.zip`: every sentence of the demo, in
|
|
129
|
+
every language it is written in, with the voice chosen - ElevenLabs' answers as they came (kept in
|
|
130
|
+
the browser, so not paid twice), the free voices' as WAV. Check it in beside `<id>.demo.json` and
|
|
131
|
+
give its URL as `narration`. It plays before any voice: viewers need no key, pay no tokens and
|
|
132
|
+
download no model, at a booth or on a sales laptop. A sentence changed since is said by the voice
|
|
133
|
+
chosen, as ever; make the pack again to keep it too (what the pack has from the same voice is
|
|
134
|
+
reused). A pack made here is kept in this browser as well.
|
|
135
|
+
|
|
136
|
+
## Playing
|
|
137
|
+
|
|
138
|
+
| | |
|
|
139
|
+
|---|---|
|
|
140
|
+
| Space | pause, resume |
|
|
141
|
+
| → Enter PageDown | waiting: go on; else on to the next step (the rest of this one done quickly) |
|
|
142
|
+
| ← PageUp | this step again; pressed in its first seconds, the step before |
|
|
143
|
+
| 1-9 Home End | to that step, the first, the last; the bar's step list and the studio's timeline too |
|
|
144
|
+
| Esc | stop |
|
|
145
|
+
| Ctrl+Shift+L | stop a loop |
|
|
146
|
+
| Recording: Alt+N, Alt+H, Esc | next step, a hover where the pointer is, stop |
|
|
147
|
+
|
|
148
|
+
While a demo plays, the viewer's own clicks, keys and scrolling do not reach the app - they would
|
|
149
|
+
take the demo off its path - and the bar says why. Paused, the app is theirs. Guided, the ringed
|
|
150
|
+
part is. At a booth, a visitor's touch hands the app over.
|
|
151
|
+
|
|
152
|
+
Going forward, the steps between are caught up under a card naming the step; going back, the app is
|
|
153
|
+
reset - the demo's cleanup, its start - and caught up to the step, under the card. Not while filming.
|
|
154
|
+
|
|
155
|
+
A presenter's clicker sends PageDown and PageUp: "Wait for the presenter after each step" makes
|
|
156
|
+
a pitch. Guided, the viewer does each click, entry and choice; "Do it for me" lets the demo. Looped,
|
|
157
|
+
a visitor's touch hands the app over; after `idle` it plays on, from the app's start (or a reload).
|
|
158
|
+
A booth with sound: start the browser allowing it, e.g. Chrome's
|
|
159
|
+
`--autoplay-policy=no-user-gesture-required --kiosk`.
|
|
160
|
+
|
|
161
|
+
## In the browser
|
|
162
|
+
|
|
163
|
+
Free voices and Whisper download once from public CDNs (jsDelivr, Hugging Face) and are kept by the
|
|
164
|
+
browser: about 80-330 MB for Kokoro, 60 MB per Piper voice, 40-250 MB for Whisper. An ElevenLabs
|
|
165
|
+
key is kept in the browser's local storage, every sentence paid for once and kept. Demos, videos
|
|
166
|
+
and the music are kept in IndexedDB, per app. Filming uses the tab's own capture (Chrome, Edge:
|
|
167
|
+
MP4; Firefox: WebM).
|
|
168
|
+
|
|
169
|
+
## From Ing+ `src/demos`
|
|
170
|
+
|
|
171
|
+
The format is the same: `.demo.json` files play as they are, once the map's actions
|
|
172
|
+
(`view`, `mapClick`, `mapHover`) come in as a plugin. `DemoPlayer`, `DemoRecorder`, `DemoTargets`,
|
|
173
|
+
`DemoSpeech`, `DemoVideo`, `DemoStore`, `DemoLink`, `DemoSession`, `DemoOverlay` and `DemoEditor` are
|
|
174
|
+
the engine; `DemosGroup` becomes `<DemoLibrary>`; `start` and its reloads go to `start`; the locale
|
|
175
|
+
keys to `labels`; the highlight manager's readiness to `ready`.
|
|
176
|
+
|
|
177
|
+
## Publishing
|
|
178
|
+
|
|
179
|
+
Straight to npm, by [`.github/workflows/publish.yml`](.github/workflows/publish.yml) with npm's
|
|
180
|
+
**Trusted Publishing**: no npm token anywhere. A `v*.*.*` tag push runs it: it tests, compiles and
|
|
181
|
+
publishes `build/`, which is the package.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm version patch # or minor / major - bumps package.json and tags it
|
|
185
|
+
git push --follow-tags
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
One-time setup, by the npm account owner: publish the first version by hand (`npm login
|
|
189
|
+
--auth-type=web`, then `npm run deploy`; `npm-first-publish.cmd` in the protomaze folder does both),
|
|
190
|
+
then in the package's settings on npmjs.com add a Trusted Publisher: GitHub Actions, repository
|
|
191
|
+
`protomaze/demo-engine`, workflow `publish.yml`. npm checks `repository.url` in `package.json`
|
|
192
|
+
against the repository, so it stays `git+https://github.com/protomaze/demo-engine.git`. The
|
|
193
|
+
protomaze folder's `NPM_README.md` has the whole procedure, for every package.
|
package/agent/Agent.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { Demo, DemoAction, DemoTarget } from '../model/Demo';
|
|
2
|
+
import type { CheckReport, DemoEngine } from '../engine/DemoEngine';
|
|
3
|
+
import type { Listed } from '../page/Targets';
|
|
4
|
+
type DemoOrId = Demo | string;
|
|
5
|
+
/**
|
|
6
|
+
* Tools for an AI that sees the app through a browser and runs JavaScript in it: look at what can
|
|
7
|
+
* be acted on, try actions, write a demo, check it plays, save it, open it for the person. Every
|
|
8
|
+
* result is plain data. `demoEngine.help()` says how.
|
|
9
|
+
*/
|
|
10
|
+
export declare function agentTools(engine: DemoEngine): {
|
|
11
|
+
/** How to make a demo with these tools: read it first. */
|
|
12
|
+
help: () => string;
|
|
13
|
+
/** The languages narration is written in, and the one it plays in now. */
|
|
14
|
+
languages: () => {
|
|
15
|
+
write: string[];
|
|
16
|
+
plays: string;
|
|
17
|
+
};
|
|
18
|
+
/** Where the app is: a demo made now starts there. */
|
|
19
|
+
start: () => Record<string, string> | null;
|
|
20
|
+
/**
|
|
21
|
+
* What is on the page to act on, as targets ready for actions: `within` a region (css), `query`
|
|
22
|
+
* a text in their labels. Also the headings and open dialogs, to know where one is.
|
|
23
|
+
*/
|
|
24
|
+
page: ({ within, query, limit }?: {
|
|
25
|
+
within?: string;
|
|
26
|
+
query?: string;
|
|
27
|
+
limit?: number;
|
|
28
|
+
}) => {
|
|
29
|
+
url: string;
|
|
30
|
+
title: string;
|
|
31
|
+
viewport: {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
};
|
|
35
|
+
headings: string[];
|
|
36
|
+
dialogs: string[];
|
|
37
|
+
targets: Listed[];
|
|
38
|
+
};
|
|
39
|
+
/** How many elements a target names, whether the one it means shows, and where. */
|
|
40
|
+
find: (target: DemoTarget) => {
|
|
41
|
+
label?: string | undefined;
|
|
42
|
+
box?: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
} | undefined;
|
|
48
|
+
matches: number;
|
|
49
|
+
shown: boolean;
|
|
50
|
+
};
|
|
51
|
+
/** A target for the element at a point of the viewport, or the first matching `css`. */
|
|
52
|
+
describe: (where: string | [number, number]) => {
|
|
53
|
+
target: DemoTarget;
|
|
54
|
+
label: string;
|
|
55
|
+
tag: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Does one action now, quickly, as a demo would: to explore the app and to test a target.
|
|
59
|
+
* Says what came on the page with it, and what went.
|
|
60
|
+
*/
|
|
61
|
+
try: (action: DemoAction) => Promise<{
|
|
62
|
+
ok: boolean;
|
|
63
|
+
error?: string;
|
|
64
|
+
appeared: Listed[];
|
|
65
|
+
gone: string[];
|
|
66
|
+
}>;
|
|
67
|
+
/** Shows a presentation action - spotlight, ring, arrow, callout, blur, card, zoom - for `ms`, to see how it looks. */
|
|
68
|
+
preview: (action: DemoAction, ms?: number) => Promise<{
|
|
69
|
+
error?: string | undefined;
|
|
70
|
+
ok: boolean;
|
|
71
|
+
}>;
|
|
72
|
+
/** The demos there are. */
|
|
73
|
+
demos: () => Promise<{
|
|
74
|
+
id: string;
|
|
75
|
+
title: string;
|
|
76
|
+
description: string;
|
|
77
|
+
steps: number;
|
|
78
|
+
origin: "app" | "edited" | "here";
|
|
79
|
+
languages: string[];
|
|
80
|
+
duration: string;
|
|
81
|
+
video: boolean;
|
|
82
|
+
}[]>;
|
|
83
|
+
get: (id: string) => Promise<Demo>;
|
|
84
|
+
/** What is wrong with it as a demo, [] if nothing: its shape only; `check` plays it. */
|
|
85
|
+
validate: (demo: Demo) => import("..").Problem[];
|
|
86
|
+
/** How long it plays, about, and each step: for pacing. */
|
|
87
|
+
estimate: (demo: DemoOrId) => Promise<{
|
|
88
|
+
duration: string;
|
|
89
|
+
steps: {
|
|
90
|
+
step: number;
|
|
91
|
+
seconds: number;
|
|
92
|
+
}[];
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Plays it fast and silent from its start, going past what fails, its cleanup after: every
|
|
96
|
+
* target found, every action played? `from`, `to`: steps, 0-based.
|
|
97
|
+
*/
|
|
98
|
+
check: (demo: DemoOrId, options?: {
|
|
99
|
+
from?: number;
|
|
100
|
+
to?: number;
|
|
101
|
+
}) => Promise<CheckReport>;
|
|
102
|
+
/** Kept in this browser; shows in the library. Over an app's demo of the same id, until removed. */
|
|
103
|
+
save: (demo: Demo) => Promise<{
|
|
104
|
+
ok: boolean;
|
|
105
|
+
problems: import("..").Problem[];
|
|
106
|
+
id?: undefined;
|
|
107
|
+
} | {
|
|
108
|
+
ok: boolean;
|
|
109
|
+
id: string;
|
|
110
|
+
problems?: undefined;
|
|
111
|
+
}>;
|
|
112
|
+
remove: (id: string) => Promise<{
|
|
113
|
+
ok: boolean;
|
|
114
|
+
}>;
|
|
115
|
+
/** Opens it in the studio, for the person to see, tune and play. */
|
|
116
|
+
open: (demo: DemoOrId) => Promise<{
|
|
117
|
+
ok: boolean;
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* Plays it for the person, with narration. Sound needs a click in the page: without one,
|
|
121
|
+
* the page asks the person to click to start. Resolves at once.
|
|
122
|
+
*/
|
|
123
|
+
play: (demo: DemoOrId, options?: {
|
|
124
|
+
from?: number;
|
|
125
|
+
}) => Promise<{
|
|
126
|
+
note?: string | undefined;
|
|
127
|
+
ok: boolean;
|
|
128
|
+
state: "playing" | "recording" | "idle" | "ready" | "preparing";
|
|
129
|
+
}>;
|
|
130
|
+
/** Plays it guided, for a tutorial: the person does each click and entry, the page shows what. Needs their click too. */
|
|
131
|
+
guide: (demo: DemoOrId, options?: {
|
|
132
|
+
from?: number;
|
|
133
|
+
}) => Promise<{
|
|
134
|
+
ok: boolean;
|
|
135
|
+
state: "playing" | "recording" | "idle" | "ready" | "preparing";
|
|
136
|
+
}>;
|
|
137
|
+
/** Plays these on a loop, unattended: an expo booth. A visitor's touch hands the app over; idle, it plays on. */
|
|
138
|
+
loop: (demos: DemoOrId[]) => Promise<{
|
|
139
|
+
ok: boolean;
|
|
140
|
+
}>;
|
|
141
|
+
stopLoop: () => {
|
|
142
|
+
ok: boolean;
|
|
143
|
+
};
|
|
144
|
+
stop: () => {
|
|
145
|
+
ok: boolean;
|
|
146
|
+
};
|
|
147
|
+
/** What the engine is doing now. */
|
|
148
|
+
state: () => {
|
|
149
|
+
message: string | undefined;
|
|
150
|
+
};
|
|
151
|
+
/** A link that opens the app with the demo in it. */
|
|
152
|
+
link: (demo: DemoOrId) => Promise<string>;
|
|
153
|
+
};
|
|
154
|
+
export type AgentTools = ReturnType<typeof agentTools>;
|
|
155
|
+
export {};
|
package/agent/Agent.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{copyOf as e,isTarget as t}from"../model/Demo.js";import{clock as o}from"../model/Timing.js";import{validate as i}from"../model/Validate.js";import{GUIDE as a}from"./Guide.js";export function agentTools(r){const s=async e=>{if("string"!=typeof e)return e;const t=(await r.entries()).find(t=>t.demo.id===e);if(!t)throw new Error(`No demo "${e}": demoEngine.demos() lists them`);return t.demo};return{help:()=>a,languages:()=>({write:r.languages(),plays:r.language()}),start:()=>r.options.start?.current()??null,page:({within:e,query:t,limit:o}={})=>{const i=e=>e.getClientRects().length>0&&!e.closest("[data-demo-ignore]"),a=e=>Array.from(document.querySelectorAll(e)).filter(i).map(e=>e.innerText?.trim().replace(/\s+/g," ").slice(0,100)).filter(Boolean);return{url:window.location.href,title:document.title,viewport:{width:innerWidth,height:innerHeight},headings:a('h1, h2, h3, h4, h5, h6, [role="heading"]').slice(0,60),dialogs:a('dialog[open], [role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"]').slice(0,10),targets:r.targets.list({within:e,query:t,limit:o??250})}},find:e=>{if(!t(e))throw new Error("A target is { css, text?, key?, index? }");const o=r.targets.matches(e),i=o[e.index??0],a=i?.getBoundingClientRect();return{matches:o.length,shown:Boolean(i&&i.getClientRects().length>0),...i?{label:r.targets.labelOf(i),box:{x:Math.round(a.x),y:Math.round(a.y),width:Math.round(a.width),height:Math.round(a.height)}}:{}}},describe:e=>{const t="string"==typeof e?document.querySelector(e):r.targets.targetElement(document.elementsFromPoint(e[0],e[1]).find(e=>!e.closest("[data-demo-ignore]"))??null);if(!t)throw new Error(`Nothing at ${JSON.stringify(e)}`);const o=r.targets.targetElement(t)??t;return{target:r.targets.describe(o),label:r.targets.labelOf(o),tag:o.tagName.toLowerCase()}},try:async e=>{const t=r.targets.list({limit:600}),o=await r.check({id:"try",title:"Try",steps:[{say:{},actions:[{...e,wait:0}]}]},{speed:2});await new Promise(e=>setTimeout(e,400));const i=r.targets.list({limit:600}),a=e=>JSON.stringify(e.target),s=new Set(t.map(a)),n=new Set(i.map(a));return{ok:o.ok,...o.ok?{}:{error:o.failures[0]?.error??o.error??o.problems.map(e=>`${e.path} ${e.message}`).join("; ")},appeared:i.filter(e=>!s.has(a(e))).slice(0,60),gone:t.filter(e=>!n.has(a(e))).map(e=>e.label).slice(0,60)}},preview:async(e,t=3e3)=>{const o=await r.check({id:"preview",title:"Preview",steps:[{say:{},actions:[{...e,wait:0}],hold:t}]},{speed:1});return{ok:o.ok,...o.ok?{}:{error:o.failures[0]?.error??o.error}}},demos:async()=>(await r.entries()).map(({demo:e,origin:t,video:i})=>({id:e.id,title:e.title,description:e.description??"",steps:e.steps.length,origin:t,languages:r.languagesOf(e),duration:o(r.timing(e).duration),video:Boolean(i)})),get:async t=>e(await s(t)),validate:e=>i(e,r.pluginKinds()),estimate:async e=>{const t=r.timing(await s(e));return{duration:o(t.duration),steps:t.steps.map(e=>({step:e.step,seconds:Math.round((e.end-e.start)/100)/10}))}},check:async(e,t={})=>r.check(await s(e),t),save:async e=>{const t=i(e,r.pluginKinds());return t.length?{ok:!1,problems:t}:(await r.save(e),{ok:!0,id:e.id})},remove:async e=>(await r.remove(e),{ok:!0}),open:async e=>(r.openStudio(await s(e)),{ok:!0}),play:async(e,t={})=>{r.play(await s(e),t);const o=r.getState().session;return{ok:!0,state:o.mode,..."ready"===o.mode?{note:'Waiting for the person to click "Play" on the page.'}:{}}},guide:async(e,t={})=>(r.guide(await s(e),t),{ok:!0,state:r.getState().session.mode}),loop:async e=>(r.loop(await Promise.all(e.map(s))),{ok:!0}),stopLoop:()=>(r.stopLoop(),{ok:!0}),stop:()=>(r.stop(),{ok:!0}),state:()=>{const{session:e,message:t}=r.getState(),{player:o,demo:i,...a}=e;return{...a,message:t?.text}},link:async e=>r.link(await s(e))}}
|
package/agent/Guide.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** How an AI makes a demo with `window.demoEngine`: `demoEngine.help()` returns it; AGENTS.md is made from it. */
|
|
2
|
+
export declare const GUIDE = "# Making a demo with demoEngine\n\nYou see the app in a browser and run JavaScript in it. `window.demoEngine` has the tools; every\nresult is plain data. A demo is steps; each step's narration is spoken (and subtitled) a sentence at\na time while its actions play one after the other. Actions point at elements as a person would: by\nwhat they show, not where they are.\n\n## Workflow\n\n1. `demoEngine.languages()` - which languages to write narration in.\n `demoEngine.start()` - where the app is; a demo starts there. `demoEngine.demos()` - what exists.\n2. Explore. `demoEngine.page()` lists what can be acted on, each with a ready `target`, its label,\n state and box; `page({ query: 'save' })` or `page({ within: '[data-demo=\"filters\"]' })` narrows it.\n Look with screenshots too. `demoEngine.try({ do: 'click', target })` does one action now and says\n what appeared and went: walk the app this way to learn the path the demo will take.\n3. Plan the story before the actions: what should the viewer understand at the end? One idea per step.\n4. Write the demo (format below). Narration first, then the actions that show it.\n5. `demoEngine.validate(demo)` - its shape. Then `await demoEngine.check(demo)` - from the demo's\n start, fast and silent, going past what fails, its cleanup after; fix every failure and check\n again until `ok` twice in a row (the second run proves the cleanup).\n6. `await demoEngine.save(demo)`, then `demoEngine.open(demo.id)` - the person sees it in the\n studio, can play, tune, film and share it. `demoEngine.play(id)` plays it with sound once the\n person clicks. `demoEngine.estimate(demo)` gives its length.\n\n## Length\n\n- Short (a teaser, one feature): 4-7 steps, 30-60 s, one or two sentences a step.\n- Normal (a tour): 8-12 steps, 1-3 min.\n- Detailed (a deep dive): 12-25 steps, 3-6 min; still one idea per step.\n\n## What it is for\n\n- Marketing video: short, benefit first, a `card` to open and close, zooms on what impresses; no\n setup steps on screen. The person films it (film button); music can play under it.\n- Sales pitch: one step per point the presenter makes; `pause: true` on steps where they talk\n freely. They advance with a clicker (PageDown) and repeat with PageUp.\n- Expo booth: 30-90 s, readable without sound (subtitles carry it), ends where it started so it can\n loop. `demoEngine.loop([ids])` plays them unattended; a visitor's touch hands the app over.\n- Tutorial or training: `demoEngine.guide(id)` lets the viewer do each click and entry themselves,\n ringed with what to do. Narrate why, not only what; small steps; one new thing each.\n\n## Narration\n\n- For the viewer, about what matters to them: \"Which pipes need work first?\" before \"Click Risk\".\n- Present tense, plain words, at most ~20 words a sentence; a step ~1-3 sentences.\n- Say what to look at as it happens; name things as the app names them.\n- Every language of `languages().write`: `say: { en: '\u2026', de: '\u2026' }`. Same meaning, natural in each.\n- No \"In this demo\u2026\" filler; open with the question or the benefit, close with what was shown.\n\n## Format\n\n```json\n{\n \"id\": \"orders-tour\",\n \"title\": \"Orders, from list to invoice\",\n \"description\": \"One sentence: who it is for and what it shows.\",\n \"start\": { \"\u2026\": \"as demoEngine.start() gives it, or leave out\" },\n \"steps\": [\n {\n \"title\": \"Find an order\",\n \"say\": { \"en\": \"Every order lands here, newest first. Let's find one from Berlin.\" },\n \"actions\": [\n { \"do\": \"spotlight\", \"target\": { \"css\": \"table\", \"text\": \"orders\" }, \"for\": 2500 },\n { \"do\": \"type\", \"target\": { \"css\": \"input[type=\\\"search\\\"]\" }, \"text\": \"Berlin\", \"cue\": 1 },\n { \"do\": \"click\", \"target\": { \"css\": \"tr\", \"text\": \"berlin #\" }, \"wait\": 1200 }\n ]\n }\n ]\n}\n```\n\nA target: `{ css, text?, key?, index? }` - the `index`th (0-based) element matching `css` whose label\nis `text` (or the app's locale `key`'s text: works in every language). Labels compare without case,\nspacing, and with every number as \"#\": a row \"Berlin 42\" is \"berlin #\". Use the targets `page()` and\n`describe()` give: they prefer locale keys and named regions. Avoid `index` where a scope does it:\n`{ css: '[data-demo=\"filters\"] button', text: 'apply' }`.\n\nEvery action has `wait` (ms before it, default 800) and `cue` (start with the step's sentence of that\nindex, 0-based: syncs a click with the words about it, in every language and voice).\n\nInteractions:\n- `click` { target, at?: [x, y] fractions of the box, double?, right?, shift?, ctrl?, alt?, meta? }\n- `hover` { target, at? } - shows tooltips and hover cards (not CSS :hover looks)\n- `type` { target, text } - replaces the field's text, a letter at a time\n- `key` { key, target? } - 'Escape', 'Enter', 'ArrowDown', 'Control+K'; shown as keycaps\n- `select` { target, option } - a native <select>'s option by text or value\n- `drag` { target, at?, to: { target?, at? } } - sliders, drag and drop, panning\n- `scroll` { target?, by?: [x, y] } - into view, or by pixels\n- `waitFor` { target, gone?, timeout? } - until it shows (or goes): after what loads\n\nPresentation (shown until the step ends, or `for` ms; `clear` takes all down):\n- `spotlight` { target, text?, padding? } - dims everything else: the one thing to look at\n- `ring` { target, text?, color?, shape?: 'box' | 'circle' } - a pulsing outline\n- `arrow` { target, text?, from?: 'top' | 'right' | 'bottom' | 'left' } - points at it\n- `callout` { text, target?, side?, corner? } - a note by the target, or in a corner\n- `blur` { target } - hides names, addresses, anything private\n- `card` { title, text? } - full screen: an opening title, a chapter, the end\n- `zoom` { target, scale? } - magnifies the page around it (1.8 by default)\n- `clear`\n\nThe app may add its own actions (a map's `view`, `mapClick`): `validate` lists every kind it knows\nwhen one is wrong; read the app's demos (`demoEngine.get(id)`) for examples.\n\nStep options: `title` (for the editor), `hold` (ms after), `pause: true` (waits for the presenter).\n\n`cleanup`: actions done after the demo - when it ends or is stopped - quickly and unseen, so the app\nis as it found it and the demo plays again: clear filters and searches, close what was opened, go\nback to the first tab. What the app cannot undo through its UI, its start resets.\n\n## Good demos\n\n- Open with a `card` (title, one line of promise), close with one (what was shown, what next).\n- Direct the eye: a spotlight or ring on what the sentence is about, an arrow for small things.\n- Let the viewer see results: a `wait` of 1500-3000 ms after what changes a lot; `waitFor` what loads.\n- Keep the pointer purposeful: no clicks that do not move the story.\n- Blur personal data.\n- Leave the app as it started: a `cleanup` list undoes what the steps changed, so demos run one\n after another and again. Check that too: `check` runs the cleanup, then `check` again.\n\n## Tools\n\nhelp() \u00B7 languages() \u00B7 start() \u00B7 page({ within?, query?, limit? }) \u00B7 find(target) \u00B7\ndescribe(css | [x, y]) \u00B7 try(action) \u00B7 preview(presentationAction, ms?) \u00B7 demos() \u00B7 get(id) \u00B7\nvalidate(demo) \u00B7 estimate(demoOrId) \u00B7 check(demoOrId, { from?, to? }) \u00B7 save(demo) \u00B7 remove(id) \u00B7\nopen(demoOrId) \u00B7 play(demoOrId, { from? }) \u00B7 guide(demoOrId, { from? }) \u00B7 loop([demoOrId]) \u00B7\nstopLoop() \u00B7 stop() \u00B7 state() \u00B7 link(demoOrId)\n";
|
package/agent/Guide.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const GUIDE='# Making a demo with demoEngine\n\nYou see the app in a browser and run JavaScript in it. `window.demoEngine` has the tools; every\nresult is plain data. A demo is steps; each step\'s narration is spoken (and subtitled) a sentence at\na time while its actions play one after the other. Actions point at elements as a person would: by\nwhat they show, not where they are.\n\n## Workflow\n\n1. `demoEngine.languages()` - which languages to write narration in.\n `demoEngine.start()` - where the app is; a demo starts there. `demoEngine.demos()` - what exists.\n2. Explore. `demoEngine.page()` lists what can be acted on, each with a ready `target`, its label,\n state and box; `page({ query: \'save\' })` or `page({ within: \'[data-demo="filters"]\' })` narrows it.\n Look with screenshots too. `demoEngine.try({ do: \'click\', target })` does one action now and says\n what appeared and went: walk the app this way to learn the path the demo will take.\n3. Plan the story before the actions: what should the viewer understand at the end? One idea per step.\n4. Write the demo (format below). Narration first, then the actions that show it.\n5. `demoEngine.validate(demo)` - its shape. Then `await demoEngine.check(demo)` - from the demo\'s\n start, fast and silent, going past what fails, its cleanup after; fix every failure and check\n again until `ok` twice in a row (the second run proves the cleanup).\n6. `await demoEngine.save(demo)`, then `demoEngine.open(demo.id)` - the person sees it in the\n studio, can play, tune, film and share it. `demoEngine.play(id)` plays it with sound once the\n person clicks. `demoEngine.estimate(demo)` gives its length.\n\n## Length\n\n- Short (a teaser, one feature): 4-7 steps, 30-60 s, one or two sentences a step.\n- Normal (a tour): 8-12 steps, 1-3 min.\n- Detailed (a deep dive): 12-25 steps, 3-6 min; still one idea per step.\n\n## What it is for\n\n- Marketing video: short, benefit first, a `card` to open and close, zooms on what impresses; no\n setup steps on screen. The person films it (film button); music can play under it.\n- Sales pitch: one step per point the presenter makes; `pause: true` on steps where they talk\n freely. They advance with a clicker (PageDown) and repeat with PageUp.\n- Expo booth: 30-90 s, readable without sound (subtitles carry it), ends where it started so it can\n loop. `demoEngine.loop([ids])` plays them unattended; a visitor\'s touch hands the app over.\n- Tutorial or training: `demoEngine.guide(id)` lets the viewer do each click and entry themselves,\n ringed with what to do. Narrate why, not only what; small steps; one new thing each.\n\n## Narration\n\n- For the viewer, about what matters to them: "Which pipes need work first?" before "Click Risk".\n- Present tense, plain words, at most ~20 words a sentence; a step ~1-3 sentences.\n- Say what to look at as it happens; name things as the app names them.\n- Every language of `languages().write`: `say: { en: \'…\', de: \'…\' }`. Same meaning, natural in each.\n- No "In this demo…" filler; open with the question or the benefit, close with what was shown.\n\n## Format\n\n```json\n{\n "id": "orders-tour",\n "title": "Orders, from list to invoice",\n "description": "One sentence: who it is for and what it shows.",\n "start": { "…": "as demoEngine.start() gives it, or leave out" },\n "steps": [\n {\n "title": "Find an order",\n "say": { "en": "Every order lands here, newest first. Let\'s find one from Berlin." },\n "actions": [\n { "do": "spotlight", "target": { "css": "table", "text": "orders" }, "for": 2500 },\n { "do": "type", "target": { "css": "input[type=\\"search\\"]" }, "text": "Berlin", "cue": 1 },\n { "do": "click", "target": { "css": "tr", "text": "berlin #" }, "wait": 1200 }\n ]\n }\n ]\n}\n```\n\nA target: `{ css, text?, key?, index? }` - the `index`th (0-based) element matching `css` whose label\nis `text` (or the app\'s locale `key`\'s text: works in every language). Labels compare without case,\nspacing, and with every number as "#": a row "Berlin 42" is "berlin #". Use the targets `page()` and\n`describe()` give: they prefer locale keys and named regions. Avoid `index` where a scope does it:\n`{ css: \'[data-demo="filters"] button\', text: \'apply\' }`.\n\nEvery action has `wait` (ms before it, default 800) and `cue` (start with the step\'s sentence of that\nindex, 0-based: syncs a click with the words about it, in every language and voice).\n\nInteractions:\n- `click` { target, at?: [x, y] fractions of the box, double?, right?, shift?, ctrl?, alt?, meta? }\n- `hover` { target, at? } - shows tooltips and hover cards (not CSS :hover looks)\n- `type` { target, text } - replaces the field\'s text, a letter at a time\n- `key` { key, target? } - \'Escape\', \'Enter\', \'ArrowDown\', \'Control+K\'; shown as keycaps\n- `select` { target, option } - a native <select>\'s option by text or value\n- `drag` { target, at?, to: { target?, at? } } - sliders, drag and drop, panning\n- `scroll` { target?, by?: [x, y] } - into view, or by pixels\n- `waitFor` { target, gone?, timeout? } - until it shows (or goes): after what loads\n\nPresentation (shown until the step ends, or `for` ms; `clear` takes all down):\n- `spotlight` { target, text?, padding? } - dims everything else: the one thing to look at\n- `ring` { target, text?, color?, shape?: \'box\' | \'circle\' } - a pulsing outline\n- `arrow` { target, text?, from?: \'top\' | \'right\' | \'bottom\' | \'left\' } - points at it\n- `callout` { text, target?, side?, corner? } - a note by the target, or in a corner\n- `blur` { target } - hides names, addresses, anything private\n- `card` { title, text? } - full screen: an opening title, a chapter, the end\n- `zoom` { target, scale? } - magnifies the page around it (1.8 by default)\n- `clear`\n\nThe app may add its own actions (a map\'s `view`, `mapClick`): `validate` lists every kind it knows\nwhen one is wrong; read the app\'s demos (`demoEngine.get(id)`) for examples.\n\nStep options: `title` (for the editor), `hold` (ms after), `pause: true` (waits for the presenter).\n\n`cleanup`: actions done after the demo - when it ends or is stopped - quickly and unseen, so the app\nis as it found it and the demo plays again: clear filters and searches, close what was opened, go\nback to the first tab. What the app cannot undo through its UI, its start resets.\n\n## Good demos\n\n- Open with a `card` (title, one line of promise), close with one (what was shown, what next).\n- Direct the eye: a spotlight or ring on what the sentence is about, an arrow for small things.\n- Let the viewer see results: a `wait` of 1500-3000 ms after what changes a lot; `waitFor` what loads.\n- Keep the pointer purposeful: no clicks that do not move the story.\n- Blur personal data.\n- Leave the app as it started: a `cleanup` list undoes what the steps changed, so demos run one\n after another and again. Check that too: `check` runs the cleanup, then `check` again.\n\n## Tools\n\nhelp() · languages() · start() · page({ within?, query?, limit? }) · find(target) ·\ndescribe(css | [x, y]) · try(action) · preview(presentationAction, ms?) · demos() · get(id) ·\nvalidate(demo) · estimate(demoOrId) · check(demoOrId, { from?, to? }) · save(demo) · remove(id) ·\nopen(demoOrId) · play(demoOrId, { from? }) · guide(demoOrId, { from? }) · loop([demoOrId]) ·\nstopLoop() · stop() · state() · link(demoOrId)\n';
|