playwright-director 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +264 -40
- package/dist/Tutorial.d.ts +2 -0
- package/dist/Tutorial.d.ts.map +1 -1
- package/dist/Tutorial.js +11 -3
- package/dist/Tutorial.js.map +1 -1
- package/dist/client.d.ts +33 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +72 -0
- package/dist/client.js.map +1 -0
- package/dist/init.js +16 -6
- package/dist/init.js.map +1 -1
- package/dist/merge.d.ts.map +1 -1
- package/dist/merge.js +2 -2
- package/dist/merge.js.map +1 -1
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +3 -0
- package/dist/reporter.js.map +1 -1
- package/dist/site/build-site.d.ts +24 -1
- package/dist/site/build-site.d.ts.map +1 -1
- package/dist/site/build-site.js +52 -10
- package/dist/site/build-site.js.map +1 -1
- package/dist/site/embed.d.ts +49 -18
- package/dist/site/embed.d.ts.map +1 -1
- package/dist/site/embed.js +53 -14
- package/dist/site/embed.js.map +1 -1
- package/dist/site/generate-manifest.d.ts +2 -0
- package/dist/site/generate-manifest.d.ts.map +1 -1
- package/dist/site/generate-manifest.js +83 -17
- package/dist/site/generate-manifest.js.map +1 -1
- package/dist/site/scaffold.d.ts +13 -0
- package/dist/site/scaffold.d.ts.map +1 -1
- package/dist/site/scaffold.js +86 -14
- package/dist/site/scaffold.js.map +1 -1
- package/dist/site/scan-tutorials.d.ts +6 -1
- package/dist/site/scan-tutorials.d.ts.map +1 -1
- package/dist/site/scan-tutorials.js +12 -8
- package/dist/site/scan-tutorials.js.map +1 -1
- package/dist/site/seo.d.ts +22 -0
- package/dist/site/seo.d.ts.map +1 -0
- package/dist/site/seo.js +91 -0
- package/dist/site/seo.js.map +1 -0
- package/dist/site/strings.d.ts +53 -0
- package/dist/site/strings.d.ts.map +1 -0
- package/dist/site/strings.js +145 -0
- package/dist/site/strings.js.map +1 -0
- package/dist/site/tokens.d.ts +28 -0
- package/dist/site/tokens.d.ts.map +1 -0
- package/dist/site/tokens.js +38 -0
- package/dist/site/tokens.js.map +1 -0
- package/dist/site/types.d.ts +84 -13
- package/dist/site/types.d.ts.map +1 -1
- package/dist/timeline.d.ts +7 -1
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js +5 -1
- package/dist/timeline.js.map +1 -1
- package/dist/tts-provider.js +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/voice-dir.d.ts +9 -0
- package/dist/voice-dir.d.ts.map +1 -0
- package/dist/voice-dir.js +21 -0
- package/dist/voice-dir.js.map +1 -0
- package/dist/voice.d.ts +3 -0
- package/dist/voice.d.ts.map +1 -1
- package/dist/voice.js +29 -16
- package/dist/voice.js.map +1 -1
- package/package.json +9 -2
- package/schemas/embed-v1.schema.json +74 -0
- package/skills/tutorialize/SKILL.md +10 -2
- package/skills/tutorialize/agent.md +7 -0
- package/skills/tutorialize/references/api.md +20 -5
- package/skills/tutorialize/references/site.md +158 -0
- package/templates/site/public/widget.js +287 -145
- package/templates/site/src/components/Emphasis.astro +8 -0
- package/templates/site/src/components/HomeLangs.astro +20 -0
- package/templates/site/src/components/LangSwitch.astro +20 -0
- package/templates/site/src/components/Lightbox.astro +50 -0
- package/templates/site/src/components/PrevNext.astro +40 -0
- package/templates/site/src/components/Seo.astro +42 -0
- package/templates/site/src/components/StepGuide.astro +115 -0
- package/templates/site/src/components/StepStrip.astro +33 -0
- package/templates/site/src/components/ThemeSwitcher.astro +22 -0
- package/templates/site/src/components/VariantFilter.astro +36 -0
- package/templates/site/src/components/VideoCard.astro +10 -107
- package/templates/site/src/components/VideoLinks.astro +19 -0
- package/templates/site/src/components/VideoModal.astro +66 -152
- package/templates/site/src/components/VideoPlayer.astro +43 -0
- package/templates/site/src/i18n.ts +19 -0
- package/templates/site/src/layouts/Shell.astro +46 -0
- package/templates/site/src/lib/filter.ts +24 -0
- package/templates/site/src/lib/site.ts +127 -0
- package/templates/site/src/pages/[lang]/index.astro +16 -0
- package/templates/site/src/pages/[slug].astro +5 -738
- package/templates/site/src/pages/index.astro +2 -2
- package/templates/site/src/styles/components.css +919 -0
- package/templates/site/src/styles/user.css +1 -0
- package/templates/themes/academy/CourseNav.astro +56 -0
- package/templates/themes/academy/Home.astro +139 -0
- package/templates/themes/academy/Layout.astro +48 -0
- package/templates/themes/academy/VideoPage.astro +75 -0
- package/templates/themes/academy/theme.css +979 -0
- package/templates/themes/classic/Home.astro +58 -0
- package/templates/themes/classic/Layout.astro +46 -0
- package/templates/themes/classic/VideoPage.astro +47 -0
- package/templates/themes/classic/theme.css +289 -0
- package/templates/site/src/components/TutorialsHome.astro +0 -141
- package/templates/site/src/layouts/Base.astro +0 -56
- package/templates/site/src/styles/tutorials.css +0 -303
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ An AI agent can also write or adapt the test for a specific communication goal
|
|
|
28
28
|
- [Reviewing & Correcting Narration](#reviewing--correcting-narration)
|
|
29
29
|
- [Claude Code Integration](#claude-code-integration)
|
|
30
30
|
- [Tutorial Gallery Site](#tutorial-gallery-site)
|
|
31
|
+
- [Themes](#themes)
|
|
31
32
|
- [In-app help widget](#in-app-help-widget)
|
|
32
33
|
- [Deploying to GitHub Pages from CI](#deploying-to-github-pages-from-ci)
|
|
33
34
|
- [How It Works](#how-it-works)
|
|
@@ -60,6 +61,9 @@ Most software teams maintain **tests** and **documentation** separately. Tests v
|
|
|
60
61
|
- **Multi-language** — Full RTL support (Arabic), per-language video filenames, i18n-ready
|
|
61
62
|
- **Playwright Reporter** — Auto-merges audio into video as each tutorial test completes
|
|
62
63
|
- **Gallery site** — `build-site` turns your recordings into a static video gallery with step-by-step guides, ready for any static host
|
|
64
|
+
- **Two site themes** — Académie (editorial: hero, search, sections, course sidebar) or Classic (card grid); design tokens, extra CSS or file overrides for your brand
|
|
65
|
+
- **SEO built in** — VideoObject JSON-LD with chapters, `sitemap.xml` with hreflang, canonical and Open Graph tags
|
|
66
|
+
- **App and docs links** — each video links to the matching screen of your app and page of your docs
|
|
63
67
|
- **In-app help widget** — the published gallery serves a `widget.js`: one `data-tutorial` attribute opens any tutorial as an overlay inside your own app
|
|
64
68
|
- **Zero runtime overhead** — All tutorial logic is no-op when `TUTORIAL_MODE` is not set
|
|
65
69
|
|
|
@@ -161,11 +165,18 @@ Videos are saved to `tutorials/videos/`, timelines to `tutorials/output/`.
|
|
|
161
165
|
Tutorial runs create files in your project. Add these to `.gitignore`:
|
|
162
166
|
|
|
163
167
|
```gitignore
|
|
164
|
-
# playwright-director generated files
|
|
168
|
+
# playwright-director generated files (the voice cache is tutorials/.cache/voice)
|
|
165
169
|
tutorials/
|
|
166
|
-
static/audio/tutorial-voice/
|
|
167
170
|
```
|
|
168
171
|
|
|
172
|
+
The narration clips are cached in `tutorials/.cache/voice/` (`TUTORIAL_VOICE_DIR`
|
|
173
|
+
changes it). They stay out of your app's `static/` or `public/` folder, so they
|
|
174
|
+
never ship in its production build: during the recording Playwright serves
|
|
175
|
+
them to the page itself. Upgrading from 0.4: clips found in the old
|
|
176
|
+
`static/audio/tutorial-voice/` are copied into the new cache the first time
|
|
177
|
+
they are needed, so nothing is re-synthesized; delete the old folder after a
|
|
178
|
+
run.
|
|
179
|
+
|
|
169
180
|
### 5. Converting an existing test
|
|
170
181
|
|
|
171
182
|
The most common use case is converting an existing Playwright test:
|
|
@@ -197,7 +208,7 @@ const tutorial = new Tutorial(page, options);
|
|
|
197
208
|
|---|---|---|---|
|
|
198
209
|
| `title` | `string` | *required* | Tutorial title shown in overlay |
|
|
199
210
|
| `translate` | `(key: string) => string` | `k => k` | Translation function — pass your i18n `t()` |
|
|
200
|
-
| `audioBaseUrl` | `string` | `'http://localhost:5173'` |
|
|
211
|
+
| `audioBaseUrl` | `string` | `'http://localhost:5173'` | Origin the narration audio plays from (Playwright serves the clips; any page origin works) |
|
|
201
212
|
| `lang` | `string` | `'en'` | Language for UI text and TTS (e.g. `'en'`, `'fr'`, `'ar'`) |
|
|
202
213
|
| `testName` | `string` | auto | Output filename slug |
|
|
203
214
|
| `testFile` | `string` | `''` | Test file path for metadata |
|
|
@@ -414,8 +425,38 @@ await tutorial.complete();
|
|
|
414
425
|
or `DENY` (Google, Bing, many SaaS apps) **cannot** be used as scenes. For
|
|
415
426
|
your own app, relax `frame-ancestors` in tutorial mode only.
|
|
416
427
|
- `stage()` navigates the parent page to `audioBaseUrl` before injecting the
|
|
417
|
-
stage, so narration audio loads same-origin
|
|
418
|
-
|
|
428
|
+
stage, so narration audio loads same-origin (Playwright answers the voice
|
|
429
|
+
URLs from the cache; the app does not need to serve them).
|
|
430
|
+
|
|
431
|
+
## Languages — one spec, one recording per language
|
|
432
|
+
|
|
433
|
+
Run the same spec once per language with `TUTORIAL_LANG`. It overrides the
|
|
434
|
+
`lang` option (narration + TTS voice: macOS Thomas / Samantha / Majed, Edge
|
|
435
|
+
Henri / Guy / Hamed, or your `TUTORIAL_TTS_CMD` with `{lang}`) and suffixes
|
|
436
|
+
every output with `.<lang>`. Drive the app UI and your texts from
|
|
437
|
+
`tutorial.lang`:
|
|
438
|
+
|
|
439
|
+
```typescript
|
|
440
|
+
const tutorial = new Tutorial(page, { title: t('look.title'), testName: 'look', lang: 'fr', translate: t });
|
|
441
|
+
await page.goto(`/properties/1/look?lang=${tutorial.lang}`); // app UI in the recorded language
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
TUTORIAL_MODE=true npx playwright test tutorial # → look.webm (default, lang option)
|
|
446
|
+
TUTORIAL_MODE=true TUTORIAL_LANG=en npx playwright test tutorial # → look.en.webm
|
|
447
|
+
TUTORIAL_MODE=true TUTORIAL_LANG=ar npx playwright test tutorial # → look.ar.webm
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
The gallery groups the recordings by slug (`look`). It gets one home page per
|
|
451
|
+
language — `/` for the site's default `lang`, `/en/`, `/ar/`… for the others,
|
|
452
|
+
linked to each other — each video page links to the same tutorial in the other
|
|
453
|
+
languages, and Arabic/Hebrew/Persian/Urdu pages render right-to-left. The site
|
|
454
|
+
chrome (buttons, labels) is translated in English, French and Arabic; see
|
|
455
|
+
`strings` in the site configuration to change a text or add a language.
|
|
456
|
+
Embed data: `embed/<slug>.<lang>.json` per language, `embed/<slug>.json` =
|
|
457
|
+
the default language (or the only one recorded), and `index.json` lists each
|
|
458
|
+
slug once with its `langs`. `load(slug, { lang })` falls back to the default
|
|
459
|
+
language when that language was not recorded.
|
|
419
460
|
|
|
420
461
|
## Variants — record the same tutorial for mobile
|
|
421
462
|
|
|
@@ -521,7 +562,7 @@ import { buildMergeCommand } from 'playwright-director';
|
|
|
521
562
|
Uses the built-in `say` command. Voices per language:
|
|
522
563
|
- French: Thomas
|
|
523
564
|
- English: Samantha
|
|
524
|
-
- Arabic:
|
|
565
|
+
- Arabic: Majed
|
|
525
566
|
|
|
526
567
|
### Edge TTS
|
|
527
568
|
|
|
@@ -548,7 +589,7 @@ npx playwright-director regen-voices # synthesize the missing
|
|
|
548
589
|
npx playwright-director regen-voices --workers=4 # parallel TTS (default 2)
|
|
549
590
|
npx playwright-director regen-voices --force # after a voice change: redo everything
|
|
550
591
|
npx playwright-director regen-voices --lang=fr # one language only
|
|
551
|
-
rm -rf
|
|
592
|
+
rm -rf tutorials/.cache/voice && npx playwright-director regen-voices # full rebuild
|
|
552
593
|
```
|
|
553
594
|
|
|
554
595
|
Narration texts are collected from the artifacts that record them verbatim:
|
|
@@ -563,6 +604,8 @@ run picks the clips up from cache.
|
|
|
563
604
|
|---|---|---|
|
|
564
605
|
| `TUTORIAL_MODE` | `false` | Enable tutorial video generation |
|
|
565
606
|
| `TUTORIAL_VARIANT` | none | Recording variant — suffixes outputs; `mobile` also compacts the overlay and pins the split |
|
|
607
|
+
| `TUTORIAL_VOICE_DIR` | `tutorials/.cache/voice` | Voice clip cache (read by recording, merge and `regen-voices`) |
|
|
608
|
+
| `TUTORIAL_LANG` | none | Recording language — overrides `lang`, suffixes outputs `.<lang>` (one run per language) |
|
|
566
609
|
| `TUTORIAL_VOICE` | `true` | Enable/disable voice narration |
|
|
567
610
|
| `TUTORIAL_VOICE_NAME` | auto | TTS voice name override |
|
|
568
611
|
| `TUTORIAL_TTS_CMD` | `say` (macOS) | Custom TTS command |
|
|
@@ -650,12 +693,20 @@ npx tutorial-transcript
|
|
|
650
693
|
# 2. Edit tutorials/transcripts/{test-name}.md — fix the narration texts
|
|
651
694
|
|
|
652
695
|
# 3. Apply: rewrites the corrected texts in your test file
|
|
653
|
-
npx tutorial-transcript apply
|
|
696
|
+
npx tutorial-transcript apply tutorials/transcripts/{test-name}.md
|
|
697
|
+
|
|
698
|
+
# 4. Re-record only that tutorial (-g matches the test title); only the
|
|
699
|
+
# changed TTS clips are regenerated (content-hash caching)
|
|
700
|
+
TUTORIAL_MODE=true npx playwright test -g "Customize the look"
|
|
654
701
|
|
|
655
|
-
#
|
|
656
|
-
|
|
702
|
+
# 5. Preview just that page (a site with only this tutorial)
|
|
703
|
+
npx playwright-director build-site -y --only={test-name}
|
|
657
704
|
```
|
|
658
705
|
|
|
706
|
+
Example — the transcript line `Cliquez sur Enregistrer.` corrected to
|
|
707
|
+
`Cliquez sur « Enregistrer » pour valider.` becomes, after `apply`, the same
|
|
708
|
+
change in the `tutorial.step(…)` string of the spec file.
|
|
709
|
+
|
|
659
710
|
`apply` pairs each transcript entry with its timeline step (by the `**key:**`
|
|
660
711
|
lines, in order — a key used twice corrects each occurrence in turn; the
|
|
661
712
|
`**[Complete]**` entry is the completion message), then locates the original
|
|
@@ -686,13 +737,14 @@ This package ships **two assets for Claude Code** that teach AI agents how to co
|
|
|
686
737
|
|
|
687
738
|
### Skill reference files
|
|
688
739
|
|
|
689
|
-
The skill bundles
|
|
740
|
+
The skill bundles three reference documents that Claude reads before tutorializing:
|
|
690
741
|
|
|
691
742
|
| File | Content |
|
|
692
743
|
|---|---|
|
|
693
744
|
| `SKILL.md` | 4-phase process: understand the viewer → design the arc → implement with `playwright-director` → verify |
|
|
694
745
|
| `references/storytelling.md` | Who is watching (role, expertise, emotional state), narration voice rules, pacing decisions, when to use context screens vs steps, multi-profile scene heuristics, directing attention (highlight vs camera zoom vs blur, secrets typed blurred) |
|
|
695
746
|
| `references/api.md` | Complete `Tutorial` class API with timing model, critical rules (e.g., navigate before any tutorial call, never override `--reporter`), camera zoom options and rules, and a pre-commit checklist |
|
|
747
|
+
| `references/site.md` | Gallery site configuration: every `tutorial-site.config.js` option, themes, sections and order, tokens → css → overrides, app/docs links, languages, CLI flags, output files |
|
|
696
748
|
|
|
697
749
|
### Setup
|
|
698
750
|
|
|
@@ -759,6 +811,8 @@ On the first run, a `tutorial-site.config.js` file is created with sensible defa
|
|
|
759
811
|
|
|
760
812
|
The command scans your `tutorials/` directory for videos, screenshots, and timeline metadata, then builds a static site ready to deploy (e.g., to Cloudflare Pages, Netlify, or any static host).
|
|
761
813
|
|
|
814
|
+
Astro, which renders the site, is playwright-director's own dependency: your project does not need it, and the build works in npm, pnpm and bun workspaces (including bun's isolated linker).
|
|
815
|
+
|
|
762
816
|
### What gets generated
|
|
763
817
|
|
|
764
818
|
```
|
|
@@ -766,9 +820,13 @@ tutorial-site-dist/ # Static site output (configurable)
|
|
|
766
820
|
├── index.html # Gallery home — videos grouped by category
|
|
767
821
|
├── {video-slug}/index.html # Dedicated page per video: player + step-by-step guide
|
|
768
822
|
├── widget.js # Embeddable in-app help widget (see below)
|
|
823
|
+
├── client.js # Headless data API (ESM) — widget.js builds on it
|
|
769
824
|
├── embed/ # Widget data
|
|
770
825
|
│ ├── {video-slug}.json # One payload per tutorial: video, description, steps
|
|
771
826
|
│ └── index.json # All available slugs (discovery/debugging)
|
|
827
|
+
├── sitemap.xml # Full baseUrl only: every page with its hreflang alternates
|
|
828
|
+
├── robots.txt # Full baseUrl at the host root only
|
|
829
|
+
├── links.json # Docs URL → tutorials that link to it (show "watch the video" in your docs)
|
|
772
830
|
└── videos/ # Copied from tutorials/videos/
|
|
773
831
|
├── *.webm # Video files
|
|
774
832
|
└── *-step-*.webp # Step screenshots (carousel on cards, guide on video pages)
|
|
@@ -782,7 +840,15 @@ narration text paired with its screenshot. Context narrations recorded
|
|
|
782
840
|
mid-flow appear as callouts between steps, and steps recorded without voice
|
|
783
841
|
still show their text.
|
|
784
842
|
|
|
785
|
-
|
|
843
|
+
Each voiced step also shows its start time (`▶ 0:13`): clicking it seeks the
|
|
844
|
+
video there, and the step that is playing is highlighted (`aria-current="step"`).
|
|
845
|
+
Seeking needs a host that answers HTTP Range requests with `206` — Cloudflare
|
|
846
|
+
Pages, Netlify and GitHub Pages do. `?t=<seconds>` in the page URL starts the
|
|
847
|
+
video there. A step
|
|
848
|
+
declared with an untranslated key (`tg.open`) is titled with the first
|
|
849
|
+
sentence of its narration instead.
|
|
850
|
+
|
|
851
|
+

|
|
786
852
|
|
|
787
853
|
Two settings control the guide (`tutorials` block of the config):
|
|
788
854
|
|
|
@@ -805,6 +871,41 @@ Two settings control the guide (`tutorials` block of the config):
|
|
|
805
871
|
|
|
806
872
|
</details>
|
|
807
873
|
|
|
874
|
+
### Themes
|
|
875
|
+
|
|
876
|
+
Two themes share the same pages and data. Pick one with `theme` in the config
|
|
877
|
+
(or `build-site --theme=classic`):
|
|
878
|
+
|
|
879
|
+
| `theme: 'academy'` (default) | `theme: 'classic'` |
|
|
880
|
+
|---|---|
|
|
881
|
+
|  |  |
|
|
882
|
+
| Hero with search and section chips, a featured "start here" video, a side table of contents, numbered cards (thumbnail = quick view, title = page), a course sidebar and a "your turn" call-to-action on video pages | Card grid grouped by section, dark mode, a thumbnail carousel per card |
|
|
883
|
+
|
|
884
|
+
Brand it with the lightest layer that does the job:
|
|
885
|
+
|
|
886
|
+
1. **`tokens`** — colors, radius, shadow and fonts become `--pd-*` CSS variables
|
|
887
|
+
(`primary onPrimary accent bg surface text muted border pro radius shadow shadowHover fontBody fontDisplay`;
|
|
888
|
+
an unknown name fails the build). `googleFonts` loads the families you name (`false` = none).
|
|
889
|
+
2. **`css`** — a stylesheet loaded after the theme.
|
|
890
|
+
3. **`overrides`** — a folder copied over the site `src/` after the theme: replace any page,
|
|
891
|
+
component or theme file (`theme/Home.astro`, `components/VideoCard.astro`, …).
|
|
892
|
+
|
|
893
|
+
To offer both looks, build twice and link the builds with `themeSwitcher`
|
|
894
|
+
(the demo gallery does this: [Académie](https://youniwemi.github.io/playwright-director/gallery/) ·
|
|
895
|
+
[Classic](https://youniwemi.github.io/playwright-director/gallery/classic/)).
|
|
896
|
+
|
|
897
|
+
**App and docs links.** Declare where a tutorial belongs in the test — `new Tutorial(page, { links: { app: '/invoices/new', docs: '/invoices/' } })` —
|
|
898
|
+
or per slug in `tutorials.links`. Paths are resolved on `appUrl` / `docsUrl` (`{lang}` is replaced by the
|
|
899
|
+
tutorial language). The video page shows "Open in the app" / "Read the documentation", and the Académie
|
|
900
|
+
call-to-action opens the app.
|
|
901
|
+
|
|
902
|
+
**SEO.** With a full `baseUrl` (`https://…`), every page gets a canonical URL, hreflang alternates and
|
|
903
|
+
Open Graph tags; video pages carry a schema.org `VideoObject` (chapters as `Clip`s, `uploadDate` from the
|
|
904
|
+
recording). The build writes `sitemap.xml`, `robots.txt` (host root only) and `links.json`. A bare-path
|
|
905
|
+
`baseUrl` skips the absolute URLs.
|
|
906
|
+
|
|
907
|
+
The full option reference is [`skills/tutorialize/references/site.md`](skills/tutorialize/references/site.md).
|
|
908
|
+
|
|
808
909
|
### In-app help widget
|
|
809
910
|
|
|
810
911
|
The published gallery doubles as a documentation backend for your app. Every
|
|
@@ -818,9 +919,10 @@ element with `data-tutorial="<video-slug>"`:
|
|
|
818
919
|
<button data-tutorial="create-account">📘 How does this work?</button>
|
|
819
920
|
```
|
|
820
921
|
|
|
821
|
-
Clicking the element opens
|
|
822
|
-
video, its intro narration
|
|
823
|
-
|
|
922
|
+
Clicking the element opens a modal dialog right inside your app — the tutorial
|
|
923
|
+
video, its intro narration and its chapters (click a chapter to jump to it in
|
|
924
|
+
the video; the playing one is highlighted), with a link to the full tutorial
|
|
925
|
+
page on the gallery:
|
|
824
926
|
|
|
825
927
|

|
|
826
928
|
|
|
@@ -833,45 +935,133 @@ Notes:
|
|
|
833
935
|
- **Slugs** are the video ids — the file names in the gallery's `videos/`
|
|
834
936
|
directory (a tutorial's `name`, plus `-<variant>` for variant recordings).
|
|
835
937
|
`GET <site>/embed/index.json` lists them all.
|
|
836
|
-
- **Programmatic API**: `window.PlaywrightDirector.open('create-account')`
|
|
837
|
-
`window.PlaywrightDirector.close()` — e.g. to launch a tutorial from an
|
|
838
|
-
checklist instead of a button.
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
938
|
+
- **Programmatic API**: `window.PlaywrightDirector.open('create-account', { lang: 'fr' })`
|
|
939
|
+
and `window.PlaywrightDirector.close()` — e.g. to launch a tutorial from an
|
|
940
|
+
onboarding checklist instead of a button. `load()` returns the data with no
|
|
941
|
+
UI (see the next section).
|
|
942
|
+
- **Language**: `open()`'s `lang`, else the trigger's `data-tutorial-lang`,
|
|
943
|
+
else your page's `<html lang>`. It picks the tutorial language (falling back
|
|
944
|
+
to the default one) and the widget texts — English, French and Arabic are
|
|
945
|
+
built in; add one from your page with
|
|
946
|
+
`PlaywrightDirector.strings.es = { close: 'Cerrar', steps: 'Pasos', … }`.
|
|
947
|
+
Arabic, Hebrew, Persian and Urdu render right-to-left.
|
|
948
|
+
- **Accessibility**: a native modal `<dialog>` — the page behind is inert, Esc
|
|
949
|
+
or a click on the backdrop closes it, focus goes to the labelled close
|
|
950
|
+
button and returns to the trigger afterwards. Chapters are a list of
|
|
951
|
+
buttons (`aria-current="step"` on the playing one; ↑/↓, Home/End move
|
|
952
|
+
between them, Enter seeks); every target is at least 44 px. The e2e suite
|
|
953
|
+
runs axe (WCAG 2.1 AA) on the open dialog in French and Arabic.
|
|
954
|
+
- **Theming**: set CSS custom properties on the widget host from your app's
|
|
955
|
+
stylesheet — your rules win over the defaults:
|
|
956
|
+
|
|
957
|
+
```css
|
|
958
|
+
.playwright-director-widget {
|
|
959
|
+
--pd-accent: #16a34a; /* default: the gallery's primaryColor */
|
|
960
|
+
--pd-surface: #ffffff; /* dialog background */
|
|
961
|
+
--pd-text: #0f172a;
|
|
962
|
+
--pd-muted: #64748b; /* secondary text */
|
|
963
|
+
--pd-border: #e2e8f0;
|
|
964
|
+
--pd-radius: 12px;
|
|
965
|
+
--pd-font: "Inter", sans-serif; /* default: your app's font */
|
|
966
|
+
--pd-focus-ring: 0 0 0 3px rgb(22 163 74 / 45%); /* a box-shadow */
|
|
967
|
+
}
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
The pre-0.5 `--playwright-director-accent` still works.
|
|
971
|
+
- **Cross-origin**: the widget loads `client.js` and `embed/<slug>.json` from
|
|
972
|
+
the gallery host, so the gallery must send `Access-Control-Allow-Origin` for
|
|
973
|
+
your app's origin. GitHub Pages sends `*` out of the box; for Cloudflare
|
|
974
|
+
Pages and Netlify, `build-site` writes a `_headers` file (see
|
|
975
|
+
[Deploying to Cloudflare Pages](#deploying-to-cloudflare-pages)).
|
|
976
|
+
|
|
977
|
+
### Headless data API — bring your own player
|
|
978
|
+
|
|
979
|
+
Apps with their own player or dialog read the same data with no UI.
|
|
980
|
+
|
|
981
|
+
**Script tag** (with `widget.js` loaded):
|
|
982
|
+
|
|
983
|
+
```js
|
|
984
|
+
const t = await window.PlaywrightDirector.load('create-account', { lang: 'fr' });
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
**Bundled ESM** (no script tag):
|
|
988
|
+
|
|
989
|
+
```js
|
|
990
|
+
import { load, loadIndex, currentStep } from 'playwright-director/client';
|
|
991
|
+
|
|
992
|
+
const t = await load('create-account', { baseUrl: 'https://tutorials.myapp.com/', lang: 'fr' });
|
|
993
|
+
video.src = t.video; // absolute URL
|
|
994
|
+
for (const s of t.steps) if (s.at !== undefined) addChapter(s.at, s.title);
|
|
995
|
+
video.ontimeupdate = () => highlight(currentStep(t.steps, video.currentTime));
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
`load()` resolves to the payload of `embed/<slug>.json` with **every URL made
|
|
999
|
+
absolute** (`video`, `poster`, `page`, `steps[].image`) plus `baseUrl`. With
|
|
1000
|
+
`lang`, it tries `embed/<slug>.<lang>.json` first and falls back to the default
|
|
1001
|
+
language. It rejects with a message that names the URL and the reason
|
|
1002
|
+
(unknown slug → HTTP 404 and the index URL; network/CORS failure → the missing
|
|
1003
|
+
`Access-Control-Allow-Origin` header).
|
|
1004
|
+
|
|
1005
|
+
The payloads are versioned: [`schemas/embed-v1.schema.json`](schemas/embed-v1.schema.json)
|
|
1006
|
+
(also importable as `playwright-director/schemas/embed-v1.schema.json`).
|
|
1007
|
+
In the raw files, all paths are **relative to the site base URL** (the
|
|
1008
|
+
directory serving `widget.js` and `embed/`).
|
|
1009
|
+
|
|
1010
|
+
| `embed/<slug>.json` field | Meaning |
|
|
1011
|
+
|---|---|
|
|
1012
|
+
| `schemaVersion` | `1` — only gains optional fields; a breaking change bumps it |
|
|
1013
|
+
| `id`, `title`, `description?`, `lang`, `variant?` | Identity and intro narration |
|
|
1014
|
+
| `duration` / `durationSeconds` | `"m:ss"` display string / number |
|
|
1015
|
+
| `video`, `poster?`, `page` | Video, poster image, full gallery page |
|
|
1016
|
+
| `steps[]` | `{ num?, at?, title?, key?, text?, image?, context? }` — `at` = start in seconds (chapters), `title` = human heading, `key` = the i18n key, `context: true` = unnumbered narration |
|
|
1017
|
+
|
|
1018
|
+
`embed/index.json` is `{ schemaVersion, tutorials: [{ id, title, duration, durationSeconds, lang, variant? }] }`.
|
|
849
1019
|
|
|
850
1020
|
### Configuration
|
|
851
1021
|
|
|
852
1022
|
```js
|
|
853
1023
|
// tutorial-site.config.js
|
|
854
1024
|
export default {
|
|
855
|
-
// Branding
|
|
1025
|
+
// Branding (see Themes above)
|
|
856
1026
|
title: "My App Tutorials", // Site title (header + page titles)
|
|
857
1027
|
logo: "./assets/logo.svg", // Path to logo image (optional)
|
|
858
|
-
|
|
859
|
-
|
|
1028
|
+
theme: "academy", // 'academy' (default) | 'classic'
|
|
1029
|
+
tokens: { primary: "#0f766e", radius: "12px", fontBody: "Inter, sans-serif" }, // --pd-* variables
|
|
1030
|
+
googleFonts: ["Inter:wght@400;600"], // Optional: fonts to load (false = none; default: the theme's)
|
|
1031
|
+
css: "./tutorials/site.css", // Optional: extra stylesheet, after the theme
|
|
1032
|
+
overrides: "./tutorials/site/", // Optional: folder copied over the site src/
|
|
1033
|
+
themeSwitcher: { Académie: "/help/", Classic: "/help/classic/" }, // Optional: links between builds
|
|
1034
|
+
// primaryColor / font: pre-0.6 spellings of tokens.primary / tokens.fontBody, still read
|
|
1035
|
+
|
|
1036
|
+
// Links (optional)
|
|
1037
|
+
appUrl: "https://app.myapp.com", // Resolves links.app; header button + call-to-action
|
|
1038
|
+
docsUrl: "https://docs.myapp.com/{lang}", // Resolves links.docs
|
|
1039
|
+
cta: true, // Académie "your turn" panel (needs an app link)
|
|
860
1040
|
|
|
861
1041
|
// Paths
|
|
862
1042
|
input: "tutorials/", // Where videos + timelines live
|
|
863
|
-
output: "tutorial-site-dist/", // Where the static site is built
|
|
1043
|
+
output: "tutorial-site-dist/", // Where the static site is built (may sit inside input)
|
|
1044
|
+
timelines: "e2e/output/", // Optional: timeline JSON dir (default <input>/output — match TUTORIAL_OUTPUT_DIR)
|
|
1045
|
+
videos: "e2e/videos/", // Optional: videos + screenshots dir (default <input>/videos)
|
|
864
1046
|
|
|
865
1047
|
// Site
|
|
866
|
-
baseUrl: "https://tutorials.myapp.com", //
|
|
867
|
-
|
|
1048
|
+
baseUrl: "https://tutorials.myapp.com", // Full URL, or just a path ("/help/") for a sub-path deployment
|
|
1049
|
+
cors: "*", // _headers Access-Control-Allow-Origin: "*", one origin, or false (no file)
|
|
1050
|
+
lang: "fr", // Default language (served at /, others at /<lang>/)
|
|
1051
|
+
strings: { // Optional: site UI texts, merged over the built-in en/fr/ar
|
|
1052
|
+
fr: { allTutorials: "Toute l’aide" },
|
|
1053
|
+
es: { allTutorials: "Todos los tutoriales", close: "Cerrar" }, // a new language starts from English
|
|
1054
|
+
},
|
|
868
1055
|
|
|
869
1056
|
// Content overrides (optional)
|
|
870
1057
|
tutorials: {
|
|
871
|
-
categories: {
|
|
872
|
-
"getting-started": { icon: "⭐", label: "Getting Started" },
|
|
1058
|
+
categories: { // Sections in display order; `items` = slugs in reading order
|
|
1059
|
+
"getting-started": { icon: "⭐", label: "Getting Started", blurb: "The first ten minutes", items: ["sign-up", "first-invoice"] },
|
|
873
1060
|
"advanced": { icon: "🚀", label: "Advanced" },
|
|
874
1061
|
},
|
|
1062
|
+
featured: "sign-up", // Académie "start here" video (default: the first one)
|
|
1063
|
+
premium: ["bank-reconciliation"], // PRO badge
|
|
1064
|
+
links: { "first-invoice": { app: "/invoices/new", docs: "/invoices/" } }, // Over the test's `links`
|
|
875
1065
|
ui: {
|
|
876
1066
|
heroTitle: "Learn My App",
|
|
877
1067
|
heroSubtitle: "Step-by-step video tutorials",
|
|
@@ -884,9 +1074,9 @@ export default {
|
|
|
884
1074
|
|
|
885
1075
|
### How videos are discovered
|
|
886
1076
|
|
|
887
|
-
The scanner looks for `.webm` files in `<input>/videos
|
|
1077
|
+
The scanner looks for `.webm` files in `<input>/videos/` (or `videos`). For each video:
|
|
888
1078
|
|
|
889
|
-
- If a matching `_timeline.json` exists in `<input>/output
|
|
1079
|
+
- If a matching `_timeline.json` exists in `<input>/output/` (or `timelines`), its metadata is used (title from narration steps, duration, category from `@feature:*` tag)
|
|
890
1080
|
- Otherwise, a human-readable title is derived from the filename and duration is left blank
|
|
891
1081
|
|
|
892
1082
|
Step screenshots (`{video}-step-{n}.{png,webp}`) are auto-detected and displayed as a carousel on each video card.
|
|
@@ -904,8 +1094,38 @@ npx serve tutorial-site-dist
|
|
|
904
1094
|
```bash
|
|
905
1095
|
playwright-director build-site # Uses ./tutorial-site.config.js
|
|
906
1096
|
playwright-director build-site --config=path/to.js # Custom config path
|
|
1097
|
+
playwright-director build-site --base=/help/ # Deploy under a sub-path (overrides baseUrl)
|
|
1098
|
+
playwright-director build-site -y # Never prompt (CI); also automatic without a TTY
|
|
1099
|
+
playwright-director build-site --only=look,billing # Only these tutorials (all languages/variants)
|
|
1100
|
+
playwright-director build-site --theme=classic # Override the config theme
|
|
1101
|
+
playwright-director build-site --output=site-classic/ # Override the output folder
|
|
1102
|
+
playwright-director build-site --dev # Serve with live reload (astro dev) instead of building
|
|
907
1103
|
```
|
|
908
1104
|
|
|
1105
|
+
`--only` builds a site with just those tutorials — handy to check one page
|
|
1106
|
+
quickly. Deploy a full build.
|
|
1107
|
+
|
|
1108
|
+
### Deploying to Cloudflare Pages
|
|
1109
|
+
|
|
1110
|
+
Publish the output directory as is. It contains a `_headers` file (also read
|
|
1111
|
+
by Netlify) so that an app on another origin can load the tutorials:
|
|
1112
|
+
|
|
1113
|
+
```
|
|
1114
|
+
/embed/* Access-Control-Allow-Origin: * Cache-Control: public, max-age=300
|
|
1115
|
+
/client.js Access-Control-Allow-Origin: * Cache-Control: public, max-age=300
|
|
1116
|
+
/widget.js Access-Control-Allow-Origin: * Cache-Control: public, max-age=300
|
|
1117
|
+
/videos/* Access-Control-Allow-Origin: * Cache-Control: public, max-age=604800
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
Set `cors` in the config to one origin (`"https://app.example.com"`) to
|
|
1121
|
+
restrict it, or `false` to write no file. With a sub-path (`--base=/help/`)
|
|
1122
|
+
the rules are prefixed with it. Videos keep their name when re-recorded, so
|
|
1123
|
+
their cache is one week, not "immutable".
|
|
1124
|
+
|
|
1125
|
+
Seeking a video (chapters, the player's timeline) needs a host that answers
|
|
1126
|
+
HTTP Range requests with `206 Partial Content`. Cloudflare Pages, Netlify and
|
|
1127
|
+
GitHub Pages do; some simple static servers (`python -m http.server`) do not.
|
|
1128
|
+
|
|
909
1129
|
### Deploying to GitHub Pages from CI
|
|
910
1130
|
|
|
911
1131
|
The gallery is a plain static site, so it deploys anywhere — this repository deploys its own on every push to `main` ([`.github/workflows/deploy-site.yml`](.github/workflows/deploy-site.yml)): a marketing landing page at the site root and the generated gallery under `/gallery/`.
|
|
@@ -929,10 +1149,14 @@ steps:
|
|
|
929
1149
|
- run: npx playwright install --with-deps chromium
|
|
930
1150
|
- run: npm run test:e2e:video # TUTORIAL_MODE=true playwright test
|
|
931
1151
|
- run: npx playwright-director build-site -y
|
|
932
|
-
- run: | #
|
|
933
|
-
|
|
1152
|
+
- run: | # same gallery, Classic theme (optional)
|
|
1153
|
+
npx playwright-director build-site -y --theme=classic \
|
|
1154
|
+
--base=/playwright-director/gallery/classic/ --output=tutorial-site-classic/
|
|
1155
|
+
- run: | # landing page + galleries
|
|
1156
|
+
mkdir -p _site/gallery/classic
|
|
934
1157
|
cp -r landing/. _site/
|
|
935
1158
|
cp -r tutorial-site-dist/. _site/gallery/
|
|
1159
|
+
cp -r tutorial-site-classic/. _site/gallery/classic/
|
|
936
1160
|
- uses: peaceiris/actions-gh-pages@v4
|
|
937
1161
|
with:
|
|
938
1162
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
package/dist/Tutorial.d.ts
CHANGED
|
@@ -64,6 +64,8 @@ export declare class Tutorial {
|
|
|
64
64
|
private get stagedScene();
|
|
65
65
|
private sameFocus;
|
|
66
66
|
static get isEnabled(): boolean;
|
|
67
|
+
/** Narration language (TUTORIAL_LANG, else the `lang` option) — drive the app UI with it, e.g. `?lang=${tutorial.lang}`. */
|
|
68
|
+
get lang(): string;
|
|
67
69
|
private translate;
|
|
68
70
|
clearFields(): void;
|
|
69
71
|
get hasSteps(): boolean;
|
package/dist/Tutorial.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../src/Tutorial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,E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,CAAC,CAAC;YAIxC,qBAAqB;IAmC7B,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC;CAsB5C"}
|
package/dist/Tutorial.js
CHANGED
|
@@ -81,8 +81,12 @@ export class Tutorial {
|
|
|
81
81
|
this.page = page;
|
|
82
82
|
// Env read here, not at module load, so tests can stub it per-instance.
|
|
83
83
|
this.variant = options.variant ?? (process.env.TUTORIAL_VARIANT || undefined);
|
|
84
|
+
// TUTORIAL_LANG records one spec per language: it wins over the option and suffixes outputs `.<lang>`.
|
|
85
|
+
const envLang = process.env.TUTORIAL_LANG || undefined;
|
|
84
86
|
const baseName = options.testName ?? `tutorial_${Date.now()}`;
|
|
85
|
-
this.testName =
|
|
87
|
+
this.testName = options.testName
|
|
88
|
+
? `${baseName}${this.variant ? `-${this.variant}` : ''}${envLang ? `.${envLang}` : ''}`
|
|
89
|
+
: baseName;
|
|
86
90
|
this.translateFn = options.translate ?? ((k) => k);
|
|
87
91
|
const audioBaseUrl = options.audioBaseUrl ?? DEFAULT_AUDIO_BASE_URL;
|
|
88
92
|
const defaultMusicUrl = TUTORIAL_MUSIC ?? '';
|
|
@@ -93,7 +97,7 @@ export class Tutorial {
|
|
|
93
97
|
testName: this.testName,
|
|
94
98
|
testTitle: options.testTitle,
|
|
95
99
|
feature: options.feature,
|
|
96
|
-
lang: options.lang ?? 'en',
|
|
100
|
+
lang: envLang ?? options.lang ?? 'en',
|
|
97
101
|
audioBaseUrl,
|
|
98
102
|
stepDelay: options.stepDelay ?? 500,
|
|
99
103
|
highlightDuration: options.highlightDuration ?? 800,
|
|
@@ -140,7 +144,7 @@ export class Tutorial {
|
|
|
140
144
|
: this.options.backgroundMusic,
|
|
141
145
|
musicVolume: this.options.musicVolume,
|
|
142
146
|
voiceVolume: this.options.voiceVolume
|
|
143
|
-
}, this.options.title, this.variant ?? '');
|
|
147
|
+
}, this.options.title, this.variant ?? '', options.links);
|
|
144
148
|
this.scenes = options.scenes ?? {};
|
|
145
149
|
this.sceneTransitionMs = options.sceneTransition?.duration ?? 600;
|
|
146
150
|
const sceneNames = Object.keys(this.scenes);
|
|
@@ -242,6 +246,10 @@ export class Tutorial {
|
|
|
242
246
|
static get isEnabled() {
|
|
243
247
|
return TUTORIAL_MODE;
|
|
244
248
|
}
|
|
249
|
+
/** Narration language (TUTORIAL_LANG, else the `lang` option) — drive the app UI with it, e.g. `?lang=${tutorial.lang}`. */
|
|
250
|
+
get lang() {
|
|
251
|
+
return this.options.lang;
|
|
252
|
+
}
|
|
245
253
|
translate(key) {
|
|
246
254
|
return this.translateFn(key);
|
|
247
255
|
}
|