@slidevideo/cli 0.1.2 → 0.2.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/CHANGELOG.md +41 -0
- package/IMPRESSUM.md +18 -4
- package/LICENSE-TERMS.md +46 -13
- package/README.md +5 -5
- package/addons/slidevideo/geometry.ts +63 -30
- package/addons/slidevideo/global-top.vue +41 -9
- package/addons/slidevideo/playback-entries.ts +17 -6
- package/addons/slidevideo/preview.ts +27 -15
- package/dist/adapters/browser-runtime.d.ts +3 -0
- package/dist/adapters/elevenlabs.d.ts +1 -0
- package/dist/adapters/elevenlabs.js +8 -4
- package/dist/adapters/powerpoint.d.ts +7 -4
- package/dist/adapters/powerpoint.js +123 -34
- package/dist/adapters/slidev-inspection.d.ts +5 -2
- package/dist/adapters/slidev-inspection.js +5 -6
- package/dist/adapters/slidev-server.js +136 -15
- package/dist/adapters/slidev.d.ts +12 -4
- package/dist/adapters/slidev.js +356 -70
- package/dist/annotation-paint.d.ts +65 -11
- package/dist/annotation-paint.js +290 -10
- package/dist/annotations.d.ts +13 -8
- package/dist/annotations.js +620 -89
- package/dist/assembly.d.ts +48 -40
- package/dist/assembly.js +72 -28
- package/dist/calibration.js +5 -4
- package/dist/cli.js +180 -39
- package/dist/compositor.d.ts +38 -6
- package/dist/compositor.js +299 -46
- package/dist/contracts.d.ts +96 -35
- package/dist/contracts.js +2 -1
- package/dist/executables.d.ts +2 -0
- package/dist/executables.js +27 -8
- package/dist/media.d.ts +12 -1
- package/dist/media.js +53 -4
- package/dist/pipeline.d.ts +36 -10
- package/dist/pipeline.js +163 -46
- package/dist/preview/contracts.d.ts +3 -3
- package/dist/preview/player.js +20 -15
- package/dist/preview/server.d.ts +2 -1
- package/dist/preview/server.js +8 -7
- package/dist/run.d.ts +1 -1
- package/dist/run.js +8 -3
- package/dist/setup-install.d.ts +1 -0
- package/dist/setup-install.js +8 -1
- package/dist/setup.d.ts +29 -8
- package/dist/setup.js +183 -76
- package/dist/skill-install.d.ts +35 -0
- package/dist/skill-install.js +132 -0
- package/dist/speech.js +10 -6
- package/dist/storyboard.js +12 -6
- package/dist/timing.js +2 -2
- package/package.json +4 -3
- package/schemas/annotation-geometry.v1.json +260 -28
- package/schemas/run-manifest.v1.json +31 -0
- package/schemas/schedule.v1.json +655 -1
- package/schemas/storyboard.v1.json +558 -33
- package/skills/slidevideo/SKILL.md +11 -9
- package/skills/slidevideo/references/decks.md +228 -0
- package/skills/slidevideo/references/production.md +17 -12
- package/skills/slidevideo/references/storyboard.md +71 -38
- package/tools/powerpoint/powerpoint.ps1 +52 -41
- package/tools/powerpoint/preview.ps1 +5 -5
- package/schemas/schedule.v2.json +0 -496
- package/schemas/storyboard.v2.json +0 -802
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.2.1
|
|
6
|
+
|
|
7
|
+
- Add storyboard-controlled underline annotations with solid or dashed strokes and optional left-to-right wipes.
|
|
8
|
+
- Inspect Slidev and PowerPoint decks directly with `slidevideo inspect --deck <file>` before creating a storyboard.
|
|
9
|
+
- Register the bundled coding-agent skill with `slidevideo skill --install`, inspect deck-compatibility rules with `slidevideo skill decks`, and report skill status in `slidevideo setup`.
|
|
10
|
+
- Configure video dimensions and frame rate on the CLI with `--width`, `--height`, and `--fps` instead of a storyboard `output` block.
|
|
11
|
+
|
|
12
|
+
## 0.2.0
|
|
13
|
+
|
|
14
|
+
- Speed up video assembly with sparse marker highlights or overlays by restricting Canvas compositing to active frame intervals and dirty regions while compositing static top layers in FFmpeg.
|
|
15
|
+
|
|
16
|
+
- Stream Slidev recordings directly into the run directory instead of buffering full WebM captures in browser memory and `/tmp`, and remove the 30-second capture finalization cap.
|
|
17
|
+
|
|
18
|
+
- Support Slidev setup, preview, and video production on macOS, including Homebrew FFmpeg installation and macOS browser discovery.
|
|
19
|
+
|
|
20
|
+
- Stream file hashing and compute output digests before publication so captures and videos larger than 2 GiB do not crash or lock retries.
|
|
21
|
+
|
|
22
|
+
- Scale default stage timeouts to the resolved video duration, remove 120-second FFmpeg caps inside active stages, and replace `--timeout-ms` with `--timeout-minutes`.
|
|
23
|
+
|
|
24
|
+
- Preserve existing files when speech generation targets a nonempty directory without a run manifest.
|
|
25
|
+
|
|
26
|
+
- Storyboards now require `version: 1` and an `annotations` list; use `annotations: []` when no highlights are needed.
|
|
27
|
+
|
|
28
|
+
- Fix Slidev theme loading for presentations outside the installation folder.
|
|
29
|
+
|
|
30
|
+
- Recover from occupied output files without recording again.
|
|
31
|
+
|
|
32
|
+
- Fix validation of recording schedules and cached speech.
|
|
33
|
+
|
|
34
|
+
- Recognize Markdown decks with uppercase file extensions.
|
|
35
|
+
|
|
36
|
+
- Fix version and failure details in run reports.
|
|
37
|
+
|
|
38
|
+
- Configure Edge TTS and ElevenLabs in one setup session, with the option to configure either provider later.
|
|
39
|
+
|
|
40
|
+
- Save an ElevenLabs API key once for use across projects.
|
|
41
|
+
|
|
42
|
+
- Choose narration voices in the storyboard without voice prompts during installation.
|
|
43
|
+
|
|
44
|
+
- Fix setup readiness and license reporting for deferred providers and already active licenses.
|
|
45
|
+
|
|
5
46
|
## 0.1.2
|
|
6
47
|
|
|
7
48
|
- Remind users to retain their custom npm installation prefix when they run an update command.
|
package/IMPRESSUM.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Imprint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Information pursuant to Section 5 of the German Digital Services Act (DDG).
|
|
4
|
+
|
|
5
|
+
## Service provider
|
|
4
6
|
|
|
5
7
|
Christian Pietsch
|
|
6
8
|
|
|
@@ -8,6 +10,18 @@ Kirchenstr. 22A
|
|
|
8
10
|
|
|
9
11
|
22869 Schenefeld, Germany
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
## Contact
|
|
14
|
+
|
|
15
|
+
Email: [hello@slidevideo.io](mailto:hello@slidevideo.io)
|
|
16
|
+
|
|
17
|
+
Telephone: [+49 40 40196280](tel:+494040196280)
|
|
18
|
+
|
|
19
|
+
## Editorial responsibility
|
|
20
|
+
|
|
21
|
+
Person responsible for content pursuant to Section 18(2) of the German Interstate Media Treaty (MStV):
|
|
22
|
+
|
|
23
|
+
Christian Pietsch, Kirchenstr. 22A, 22869 Schenefeld, Germany
|
|
24
|
+
|
|
25
|
+
## Consumer dispute resolution
|
|
12
26
|
|
|
13
|
-
|
|
27
|
+
Notice pursuant to Section 36 of the German Consumer Dispute Resolution Act (VSBG): We are neither willing nor obliged to participate in dispute resolution proceedings before a consumer arbitration board.
|
package/LICENSE-TERMS.md
CHANGED
|
@@ -1,36 +1,59 @@
|
|
|
1
1
|
# SlideVideo license terms
|
|
2
2
|
|
|
3
|
-
Effective
|
|
3
|
+
Effective 22 November 2026.
|
|
4
4
|
|
|
5
5
|
## Who provides SlideVideo
|
|
6
6
|
|
|
7
7
|
Christian Pietsch, Kirchenstr. 22A, 22869 Schenefeld, Germany, provides SlideVideo. Contact us at [hello@slidevideo.io](mailto:hello@slidevideo.io) or [+49 40 40196280](tel:+494040196280).
|
|
8
8
|
|
|
9
|
-
We grant you permission to install and use the SlideVideo CLI under these terms. SlideVideo and its contributors retain
|
|
9
|
+
We grant you a non-exclusive, non-transferable permission to install and use the SlideVideo CLI under these terms. SlideVideo and its contributors retain all rights in the software. Third-party components are subject to their own licenses, and external speech providers are subject to their own service terms and fees.
|
|
10
|
+
|
|
11
|
+
You may not modify, patch, redistribute or wrap the SlideVideo software to remove, hide or bypass the export watermark or license checks, except to the extent mandatory statutory law (such as Sections 69d and 69e of the German Copyright Act) permits acts necessary for interoperability or error correction.
|
|
10
12
|
|
|
11
13
|
## Free use
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Individuals and organizations of any size may use SlideVideo at no charge to create, publish and share watermarked videos for personal, educational, internal company or own-brand purposes, and to share unpaid watermarked drafts for review, subject to the rights they hold in the content. Keep the `slidevideo.io` watermark clearly visible and unmodified when you use, edit or share those videos.
|
|
16
|
+
|
|
17
|
+
Free use does not permit selling, licensing or delivering finished videos to clients or third parties for compensation, or offering SlideVideo exports inside a hosted service, API or SaaS product for external users, even with the watermark visible. You need an active paid license covering your use to produce a version that omits, crops, covers, hides or removes the watermark, or to deliver paid client videos or hosted third-party exports.
|
|
14
18
|
|
|
15
19
|
## Watermark-Free License
|
|
16
20
|
|
|
17
|
-
Each person who independently creates or adapts a SlideVideo storyboard for watermark-free delivery is a producer and needs a license covering their work. This applies when a colleague runs the export on their behalf.
|
|
21
|
+
Each person who independently creates or adapts a SlideVideo storyboard for watermark-free delivery is a producer and needs a license covering their work. This requirement also applies when a colleague or coding agent runs the export on their behalf.
|
|
22
|
+
|
|
23
|
+
An active Watermark-Free License covers one named producer acting either as an individual, for a non-profit or public educational institution, or within a small organization of up to 10 people across affiliated entities (counting employees, founders and regular contractors).
|
|
24
|
+
|
|
25
|
+
The license covers watermark-free videos created solely for that producer's own projects or their qualifying small organization's own products, courses, channels, documentation, marketing and internal communication. Producers may monetize their own channels, courses and products (including ad revenue, course sales and sponsor mentions within their own content). That producer may install SlideVideo on their own devices and direct an interactive coding agent to perform individual exports. Colleagues inside the qualifying organization may supply slides or review drafts under the free terms.
|
|
26
|
+
|
|
27
|
+
The Watermark-Free License does not cover any of the following uses, each of which requires a Corporate & Agency License:
|
|
28
|
+
|
|
29
|
+
- Creating, adapting or exporting commissioned videos for clients, customers' brands or third-party channels for compensation, including agency, studio, consultancy, freelance or white-label deliverables
|
|
30
|
+
- Reselling, sublicensing or distributing produced videos as client deliverables
|
|
31
|
+
- Use by or on behalf of an organization with more than 10 people
|
|
32
|
+
- Offering or embedding SlideVideo exports in a hosted service, API or SaaS product for third parties
|
|
33
|
+
- Scheduled, event-triggered, shared-queue or automated batch workflows that create multiple finished videos
|
|
34
|
+
|
|
35
|
+
## Corporate & Agency License
|
|
18
36
|
|
|
19
|
-
|
|
37
|
+
A separate Corporate & Agency License is required in any of these cases:
|
|
20
38
|
|
|
21
|
-
|
|
39
|
+
- **Corporate teams.** Watermark-free exports for organizations with more than 10 people using SlideVideo for internal communication, training, documentation or marketing.
|
|
40
|
+
- **Agencies, freelancers and resellers.** Producing, customizing or delivering paid videos for clients, customers' brands or other third parties (beyond unpaid watermarked review drafts).
|
|
41
|
+
- **Platforms and hosted services.** Products, APIs or SaaS services that run SlideVideo to generate videos for external users or tenants, with or without a watermark.
|
|
42
|
+
- **Automated and batch workflows.** Watermark-free scheduled jobs, event-triggered pipelines, CI workflows or shared export queues that produce multiple finished videos, regardless of organization size.
|
|
22
43
|
|
|
23
|
-
|
|
44
|
+
Contact [hello@slidevideo.io](mailto:hello@slidevideo.io) to arrange a Corporate & Agency License. The written agreement specifies the covered organization, producer seats or export scope, permitted client or automation rights, pricing and invoicing terms.
|
|
24
45
|
|
|
25
46
|
## Individual billing, activation and cancellation
|
|
26
47
|
|
|
27
|
-
The individual subscription costs €4.99 per month, including applicable taxes. It continues indefinitely and we charge you monthly until the subscription ends. Before you order, checkout shows the total monthly price, billing interval and cancellation terms. We email your contract confirmation and license key.
|
|
48
|
+
The individual Watermark-Free License subscription costs €4.99 per month per producer, including applicable taxes. It continues indefinitely and we charge you monthly until the subscription ends. Before you order, checkout shows the total monthly price, billing interval and cancellation terms. We email your contract confirmation and license key.
|
|
28
49
|
|
|
29
|
-
Enter your key using `slidevideo setup --license` and keep it private. The CLI checks the key locally.
|
|
50
|
+
Enter your key using `slidevideo setup --license` and keep it private. The CLI checks the key locally. Your right to produce new watermark-free exports depends on timely payment for the current billing period and compliance with these terms. If your organization grows past 10 people or you begin producing client videos, contact us to transition to a Corporate & Agency License before producing new watermark-free exports.
|
|
51
|
+
|
|
52
|
+
We may suspend or terminate a license for cause and add its key to the CLI revocation list if the key is shared across multiple producers, published or leaked, used outside the permitted license tier, or left unpaid after a failed renewal notice or payment reversal.
|
|
30
53
|
|
|
31
54
|
You may cancel at any time by email or post using the contact details above. When we offer subscriptions for purchase online, use the cancellation link on the [SlideVideo website](https://slidevideo.io). We email your declaration, receipt time and intended end date. Ordinary cancellation takes effect at the end of the current billing period, or on a later date you request. If you request the earliest available date, the notice period is at most one month. You may end the contract sooner when the law gives you that right.
|
|
32
55
|
|
|
33
|
-
When your paid license ends, remove the activation using `slidevideo setup --license` and use the free tier for new exports. After ordinary cancellation, you may continue to use
|
|
56
|
+
When your paid license ends, remove the activation using `slidevideo setup --license` and use the free tier for new exports. After ordinary cancellation at the end of a paid billing period, you may continue to use and publish videos you lawfully produced within the scope of your license while it was active. If a contract is rescinded through withdrawal or payment chargeback, your right to use, publish or distribute watermark-free videos produced under that key ends and you must remove the activation.
|
|
34
57
|
|
|
35
58
|
## Right of withdrawal for consumers
|
|
36
59
|
|
|
@@ -38,7 +61,7 @@ If you buy the subscription as a consumer online, you may withdraw within 14 day
|
|
|
38
61
|
|
|
39
62
|
Send a clear statement that you wish to withdraw by email or post using the contact details above. You may use the form below. We email your declaration and receipt time. Send your declaration before the withdrawal period ends to meet the deadline.
|
|
40
63
|
|
|
41
|
-
We refund payments for the withdrawn subscription without undue delay and within 14 days of receiving your withdrawal. We use your original payment method unless you expressly agree to another one. We charge no fees for the refund.
|
|
64
|
+
We refund payments for the withdrawn subscription without undue delay and within 14 days of receiving your withdrawal. We use your original payment method unless you expressly agree to another one. We charge no fees for the refund. Upon withdrawal, we revoke the issued license key and you must stop using the key and any watermark-free videos exported under the withdrawn contract.
|
|
42
65
|
|
|
43
66
|
### Optional withdrawal form
|
|
44
67
|
|
|
@@ -51,8 +74,18 @@ I wish to withdraw from my SlideVideo Watermark-Free License subscription.
|
|
|
51
74
|
- Date of this notice
|
|
52
75
|
- Your signature, for paper submissions only
|
|
53
76
|
|
|
54
|
-
## Your content and
|
|
77
|
+
## Your content, warranty and liability
|
|
55
78
|
|
|
56
|
-
You keep the rights you hold in your slides, scripts, media and finished videos. Make sure you have permission to use the content you include and comply with the terms of any third-party media, fonts or speech services you choose.
|
|
79
|
+
You keep the rights you hold in your slides, scripts, media and finished videos. Make sure you have permission to use the content you include and comply with the terms of any third-party media, fonts or speech services you choose. You are responsible for reviewing finished videos before publishing or relying on them.
|
|
57
80
|
|
|
58
81
|
Consumers have statutory rights if we fail to supply the digital product or it is defective. You may ask us to fix a defect, and you may be entitled to a price reduction, termination or compensation when the legal conditions for those remedies apply. We provide and notify you of required updates, including security updates, for the period required by law. Your mandatory consumer protections apply throughout these terms.
|
|
82
|
+
|
|
83
|
+
We are liable without limitation for intent and gross negligence, for injury to life, body or health, for fraudulently concealed defects, under an expressly assumed guarantee and under the German Product Liability Act (Produkthaftungsgesetz).
|
|
84
|
+
|
|
85
|
+
In cases of slight negligence, we are liable only for breaches of an essential contractual obligation (a duty whose fulfillment enables proper performance of the contract and on whose observance you may regularly rely), and that liability is limited to the foreseeable damage typical for this type of contract. Any further liability for slight negligence is excluded. For free use, strict liability without fault for initial defects is also excluded to the extent permitted by law. These limitations apply equally in favor of our legal representatives, employees and agents.
|
|
86
|
+
|
|
87
|
+
## Governing law and jurisdiction
|
|
88
|
+
|
|
89
|
+
German law applies to these terms, excluding the UN Convention on Contracts for the International Sale of Goods (CISG). If you are a consumer habitually resident in another country, mandatory consumer protection provisions of your country of residence continue to apply.
|
|
90
|
+
|
|
91
|
+
If you act as a merchant (Kaufmann), a legal entity under public law, a special fund under public law, or a business customer without a general place of jurisdiction in Germany, the exclusive place of jurisdiction for all disputes arising from or in connection with these terms is Pinneberg, Germany. We also remain entitled to bring proceedings at your general place of jurisdiction.
|
package/README.md
CHANGED
|
@@ -5,23 +5,23 @@ SlideVideo turns a slide deck into a narrated video. It reads a `slidevideo.yaml
|
|
|
5
5
|
Install Node.js 22.22.0 or later, then run:
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm install --global @slidevideo/cli
|
|
8
|
+
npm install --global @slidevideo/cli@latest
|
|
9
9
|
slidevideo setup
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Setup checks
|
|
12
|
+
Setup prepares shared tools, checks both speech providers, and detects Slidev and native PowerPoint support. You can leave either provider for later. ElevenLabs setup accepts hidden API key input and saves one key in your per-user config for all projects. Your storyboard selects the deck format, speech provider, and voice. In your project folder, put `slidevideo.yaml` next to your presentation. Run:
|
|
13
13
|
|
|
14
14
|
```sh
|
|
15
15
|
slidevideo validate --storyboard slidevideo.yaml
|
|
16
16
|
slidevideo build --storyboard slidevideo.yaml --run runs/hello-001
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
A completed build writes `runs/hello-001/final.mp4
|
|
19
|
+
A completed build writes `runs/hello-001/final.mp4` at `1920x1080` and `30 fps` by default. Pass `--width` and `--height` together and optional `--fps` to select another resolution or frame rate. Use `slidevideo setup --license` to activate a key. The installed version checks its bundled revocation list offline. New exports using a revoked key include the watermark.
|
|
20
20
|
|
|
21
|
-
To draft or edit a storyboard,
|
|
21
|
+
To draft or edit a storyboard with a coding agent, run `slidevideo skill --install` to link the bundled skill into `~/.agents/skills/slidevideo` and `~/.claude/skills/slidevideo` when Claude Code is detected, or ask the agent to run `slidevideo skill`. For non-interactive setup, run `slidevideo setup --install --json` and see `slidevideo setup --help` and `slidevideo skill --help` for provider and project flags. Use `slidevideo inspect --deck <file> --json` to list slide names, click counts, media IDs, and highlight targets before creating `slidevideo.yaml`. The CLI includes the skill and its storyboard, deck-compatibility, and recording references.
|
|
22
22
|
|
|
23
23
|
Interactive calls check npm in the background at most once every 24 hours and show cached update notices on later calls. Stable installations use `latest`; existing alpha installations use `alpha`. Notices include an exact-version upgrade command. If you installed with `--prefix`, add the same `--prefix` option to that command so npm updates the copy on your `PATH`. Set `SLIDEVIDEO_NO_UPDATE_CHECK=1` to disable checks and notices. CI, noninteractive calls, `--json` and `--quiet` skip both.
|
|
24
24
|
|
|
25
25
|
See the [user manual](https://slidevideo.io/guide.html) for host prerequisites and a first build, and the [changelog](CHANGELOG.md) for release notes. Run `slidevideo --help` for the installed command reference.
|
|
26
26
|
|
|
27
|
-
Run `slidevideo license` for the bundled license terms or `slidevideo impressum` for the provider's contact details. Both commands work offline. You can also read the [license terms](https://slidevideo.io/license.html) and [
|
|
27
|
+
Run `slidevideo license` for the bundled license terms or `slidevideo impressum` for the provider's contact details. Both commands work offline. You can also read the [license terms](https://slidevideo.io/license.html) and [Imprint](https://slidevideo.io/impressum.html) on the website.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AnnotationGeometry,
|
|
1
|
+
import type { AnnotationGeometry, GeometryRequest, Rectangle } from '../../dist/contracts.js'
|
|
2
2
|
|
|
3
3
|
type PlaybackPosition = { slide: string; visit: string; click: number; index: number }
|
|
4
|
-
type Measurement = {
|
|
4
|
+
type Measurement = { fragments: Rectangle[]; content: Rectangle; slide: Rectangle; viewport: { width: number; height: number }; elements: Element[] }
|
|
5
5
|
const rectangle = (rect: DOMRect): Rectangle => ({ x: rect.x, y: rect.y, width: rect.width, height: rect.height })
|
|
6
6
|
function axisAligned(element: Element) {
|
|
7
7
|
const style = getComputedStyle(element)
|
|
@@ -46,8 +46,8 @@ function visibleBounds(element: Element, content: HTMLElement): Rectangle {
|
|
|
46
46
|
}
|
|
47
47
|
return bounds
|
|
48
48
|
}
|
|
49
|
-
function measure(
|
|
50
|
-
if (position.slide !==
|
|
49
|
+
function measure(request: GeometryRequest, position: PlaybackPosition): Measurement {
|
|
50
|
+
if (position.slide !== request.slide || position.visit !== request.visit || position.click !== request.click) throw new Error('Slide visit or reveal state changed')
|
|
51
51
|
const { content, slide } = audience(position.index)
|
|
52
52
|
for (let ancestor: Element | null = content; ancestor; ancestor = ancestor.parentElement) axisAligned(ancestor)
|
|
53
53
|
for (let ancestor: Element | null = slide; ancestor && ancestor !== content; ancestor = ancestor.parentElement) {
|
|
@@ -56,53 +56,86 @@ function measure(annotation: ResolvedAnnotation, position: PlaybackPosition): Me
|
|
|
56
56
|
}
|
|
57
57
|
const contentRect = rectangle(content.getBoundingClientRect())
|
|
58
58
|
if (!(contentRect.width > 0 && contentRect.height > 0) || !within(contentRect, { x: 0, y: 0, width: innerWidth, height: innerHeight })) throw new Error('Slide-content rectangle is empty or clipped by the capture viewport')
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
let fragments: Rectangle[]
|
|
60
|
+
let elements: Element[] = []
|
|
61
|
+
switch (request.target.type) {
|
|
62
|
+
case 'slide':
|
|
63
|
+
fragments = []
|
|
64
|
+
break
|
|
65
|
+
case 'region': {
|
|
66
|
+
const target = request.target
|
|
67
|
+
fragments = [{ x: target.x, y: target.y, width: target.width, height: target.height }]
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
case 'element': {
|
|
71
|
+
const candidates = slide.querySelectorAll(request.target.selector)
|
|
72
|
+
if (candidates.length !== 1) throw new Error(`Selector ${JSON.stringify(request.target.selector)} matched ${candidates.length} elements in the active audience slide`)
|
|
73
|
+
const element = candidates[0]
|
|
74
|
+
const rect = visibleBounds(element, content)
|
|
75
|
+
fragments = [{ x: (rect.x - contentRect.x) / contentRect.width, y: (rect.y - contentRect.y) / contentRect.height, width: rect.width / contentRect.width, height: rect.height / contentRect.height }]
|
|
76
|
+
elements = [element]
|
|
77
|
+
break
|
|
78
|
+
}
|
|
79
|
+
case 'shape':
|
|
80
|
+
throw new Error('PowerPoint shape targets are unsupported by Slidev')
|
|
81
|
+
}
|
|
82
|
+
return { fragments, content: contentRect, slide: rectangle(slide.getBoundingClientRect()), viewport: { width: innerWidth, height: innerHeight }, elements }
|
|
71
83
|
}
|
|
72
84
|
const difference = (a: Rectangle, b: Rectangle) => Math.max(...(['x', 'y', 'width', 'height'] as const).map(key => Math.abs(a[key] - b[key])))
|
|
73
|
-
|
|
74
|
-
|
|
85
|
+
const requestId = (request: GeometryRequest) => `${request.scene}\0${request.slide}\0${request.visit}\0${request.click}\0${request.key}\0${request.start_ms}\0${request.end_ms}`
|
|
86
|
+
const requestLabel = (request: GeometryRequest) => request.annotations.length === 1
|
|
87
|
+
? `Annotation ${request.annotations[0]}`
|
|
88
|
+
: `Annotations ${request.annotations.join(', ')}`
|
|
89
|
+
export function geometryCollector(requests: GeometryRequest[], output: AnnotationGeometry[], position: () => PlaybackPosition, elapsed: () => number, fail: (message: string) => void) {
|
|
90
|
+
const active = new Map<string, { request: GeometryRequest; first: Measurement; record: AnnotationGeometry }>()
|
|
75
91
|
let frame = 0
|
|
76
92
|
let running = true
|
|
77
|
-
function sample(
|
|
93
|
+
function sample(request: GeometryRequest) {
|
|
78
94
|
try {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
95
|
+
const id = requestId(request)
|
|
96
|
+
const measurement = measure(request, position())
|
|
97
|
+
const existing = active.get(id)
|
|
81
98
|
if (!existing) {
|
|
82
|
-
const
|
|
83
|
-
|
|
99
|
+
const now = elapsed()
|
|
100
|
+
const { annotations: _annotations, ...targetWindow } = request
|
|
101
|
+
const record: AnnotationGeometry = { ...targetWindow, observed_start_ms: now, observed_end_ms: now, viewport: measurement.viewport, content: measurement.content, fragments: measurement.fragments, samples: 1 }
|
|
102
|
+
output.push(record); active.set(id, { request, first: measurement, record })
|
|
84
103
|
} else {
|
|
85
104
|
const first = existing.first
|
|
86
|
-
const
|
|
87
|
-
|
|
105
|
+
const elementsChanged = measurement.elements.length !== first.elements.length || measurement.elements.some((element, index) => element !== first.elements[index])
|
|
106
|
+
const fragmentsMoved = measurement.fragments.length !== first.fragments.length || measurement.fragments.some((bounds, index) => {
|
|
107
|
+
const reference = first.fragments[index]
|
|
108
|
+
const delta = [
|
|
109
|
+
(bounds.x - reference.x) * first.content.width,
|
|
110
|
+
(bounds.y - reference.y) * first.content.height,
|
|
111
|
+
(bounds.width - reference.width) * first.content.width,
|
|
112
|
+
(bounds.height - reference.height) * first.content.height,
|
|
113
|
+
]
|
|
114
|
+
return Math.max(...delta.map(Math.abs)) > 0.5
|
|
115
|
+
})
|
|
116
|
+
if (elementsChanged || measurement.viewport.width !== first.viewport.width || measurement.viewport.height !== first.viewport.height || difference(measurement.content, first.content) > 0.5 || difference(measurement.slide, first.slide) > 0.5 || fragmentsMoved) {
|
|
117
|
+
throw new Error('Target or slide layout moved during the annotation interval')
|
|
118
|
+
}
|
|
88
119
|
existing.record.samples++; existing.record.observed_end_ms = elapsed()
|
|
89
120
|
}
|
|
90
|
-
} catch (error) {
|
|
121
|
+
} catch (error) {
|
|
122
|
+
throw new Error(`${requestLabel(request)} (${request.key}, ${request.slide}, visit ${request.visit}, click ${request.click}): ${error instanceof Error ? error.message : String(error)}`)
|
|
123
|
+
}
|
|
91
124
|
}
|
|
92
125
|
function tick() {
|
|
93
126
|
if (!running) return
|
|
94
|
-
try { for (const {
|
|
127
|
+
try { for (const { request } of active.values()) sample(request) }
|
|
95
128
|
catch (error) { fail(String(error)); stop(); return }
|
|
96
129
|
frame = requestAnimationFrame(tick)
|
|
97
130
|
}
|
|
98
131
|
function stop() { running = false; cancelAnimationFrame(frame); active.clear() }
|
|
99
132
|
frame = requestAnimationFrame(tick)
|
|
100
133
|
return {
|
|
101
|
-
start(
|
|
102
|
-
end(
|
|
134
|
+
start(request: GeometryRequest) { sample(request) },
|
|
135
|
+
end(request: GeometryRequest) { sample(request); active.delete(requestId(request)) },
|
|
103
136
|
stop,
|
|
104
137
|
complete() {
|
|
105
|
-
if (output.length !==
|
|
138
|
+
if (output.length !== requests.length || active.size) throw new Error('Annotation geometry collection did not complete')
|
|
106
139
|
},
|
|
107
140
|
}
|
|
108
141
|
}
|
|
@@ -2,15 +2,40 @@
|
|
|
2
2
|
import { ref, nextTick, onMounted, onUnmounted } from 'vue'
|
|
3
3
|
import { useNav } from '@slidev/client'
|
|
4
4
|
import type { Schedule, ObservedEvent, ScheduledAction, AnnotationGeometry, PresentationInspection } from '../../dist/contracts.js'
|
|
5
|
+
import { geometryRequests, groupEffectsByBlend, paintPrimitives, type PaintableEffect } from '../../dist/annotation-paint.js'
|
|
5
6
|
import { geometryCollector, inspectAudienceTargets } from './geometry'
|
|
6
|
-
import type { createPreview
|
|
7
|
+
import type { createPreview } from './preview'
|
|
7
8
|
import { playbackEntries } from './playback-entries'
|
|
8
9
|
const nav = useNav()
|
|
9
10
|
const marker = ref('')
|
|
10
11
|
const enabled = new URLSearchParams(location.search).has('slidevideo')
|
|
11
12
|
const previewEnabled = enabled && new URLSearchParams(location.search).has('slidevideo-preview')
|
|
12
|
-
const
|
|
13
|
+
const previewCanvases: HTMLCanvasElement[] = []
|
|
13
14
|
let preview: ReturnType<typeof createPreview> | undefined
|
|
15
|
+
function renderPreview(effects: PaintableEffect[], timeMs: number) {
|
|
16
|
+
const groups = groupEffectsByBlend(effects, timeMs)
|
|
17
|
+
while (previewCanvases.length > groups.length) previewCanvases.pop()!.remove()
|
|
18
|
+
const width = innerWidth
|
|
19
|
+
const height = innerHeight
|
|
20
|
+
for (const [index, group] of groups.entries()) {
|
|
21
|
+
let canvas = previewCanvases[index]
|
|
22
|
+
if (!canvas) {
|
|
23
|
+
canvas = document.createElement('canvas')
|
|
24
|
+
canvas.dataset.slidevideoCanvas = String(index)
|
|
25
|
+
Object.assign(canvas.style, { position: 'fixed', inset: '0', width: '100%', height: '100%', zIndex: '999998', pointerEvents: 'none' })
|
|
26
|
+
document.body.append(canvas)
|
|
27
|
+
previewCanvases.push(canvas)
|
|
28
|
+
}
|
|
29
|
+
const blendCss = group.blend === 'darken' ? 'darken' : 'normal'
|
|
30
|
+
if (canvas.style.mixBlendMode !== blendCss) canvas.style.mixBlendMode = blendCss
|
|
31
|
+
if (canvas.width !== width) canvas.width = width
|
|
32
|
+
if (canvas.height !== height) canvas.height = height
|
|
33
|
+
const context = canvas.getContext('2d')
|
|
34
|
+
if (!context) throw new Error('2D canvas context is unavailable for preview')
|
|
35
|
+
context.clearRect(0, 0, width, height)
|
|
36
|
+
paintPrimitives(context, group.primitives, { backdrop: false })
|
|
37
|
+
}
|
|
38
|
+
}
|
|
14
39
|
function silence(event: Event) {
|
|
15
40
|
if (event.target instanceof HTMLMediaElement && !event.target.muted) event.target.muted = true
|
|
16
41
|
}
|
|
@@ -50,11 +75,16 @@ const media = (id: string) => {
|
|
|
50
75
|
if (!(element instanceof HTMLMediaElement)) throw new Error(`Missing media ${id}`)
|
|
51
76
|
return element
|
|
52
77
|
}
|
|
78
|
+
function slideReady(index: number) {
|
|
79
|
+
const page = document.querySelector(`#slide-content #slideshow > .slidev-page[data-slidev-no="${index}"]`)
|
|
80
|
+
return Boolean(page?.firstElementChild && !page.querySelector('.slidev-slide-loading'))
|
|
81
|
+
}
|
|
53
82
|
async function navigate(index: number, click = 0) {
|
|
83
|
+
await nav.slides.value[index - 1]?.load()
|
|
54
84
|
await nav.go(index, click, true); await painted()
|
|
55
85
|
const deadline = performance.now() + 10000
|
|
56
86
|
let waited = false
|
|
57
|
-
while (!
|
|
87
|
+
while (!slideReady(index)) {
|
|
58
88
|
if (performance.now() >= deadline) throw new Error(`Slide ${index} did not finish loading`)
|
|
59
89
|
waited = true; await wait(10)
|
|
60
90
|
}
|
|
@@ -140,13 +170,15 @@ async function play(verifyTiming = false) {
|
|
|
140
170
|
const start = performance.now()
|
|
141
171
|
for (const event of state.markers) { event.observed_ms -= start - origin; event.rendered_by_ms -= start - origin }
|
|
142
172
|
origin = start
|
|
143
|
-
|
|
173
|
+
const requests = geometryRequests(schedule)
|
|
174
|
+
if (requests.length) geometry = geometryCollector(requests, state.annotation_geometry, () => ({ slide: String(nav.currentSlideRoute.value.meta.slide.frontmatter.name ?? `slide-${nav.currentSlideNo.value}`), visit, click: nav.clicks.value, index: nav.currentSlideNo.value }), () => performance.now() - origin, message => { state.failure = message })
|
|
144
175
|
for (const entry of playbackEntries(schedule)) {
|
|
145
176
|
while (performance.now() - origin < entry.at) await wait(entry.at - (performance.now() - origin))
|
|
146
177
|
if (current !== generation) throw new Error('Playback reset')
|
|
147
178
|
if (state.failure) throw new Error(state.failure)
|
|
148
|
-
if (entry.type === 'start') { geometry!.start(entry.
|
|
149
|
-
if (entry.type === 'end') { geometry!.end(entry.
|
|
179
|
+
if (entry.type === 'geometry-start') { geometry!.start(entry.request); continue }
|
|
180
|
+
if (entry.type === 'geometry-end') { geometry!.end(entry.request); continue }
|
|
181
|
+
if (entry.type === 'annotation-start' || entry.type === 'annotation-end') continue
|
|
150
182
|
const item = entry.item
|
|
151
183
|
await apply(item)
|
|
152
184
|
const observed_ms = performance.now() - origin
|
|
@@ -186,13 +218,14 @@ async function inspectTargets(): Promise<PresentationInspection['annotation_targ
|
|
|
186
218
|
if (click) await navigate(slide.no, click)
|
|
187
219
|
for (const target of inspectAudienceTargets(slide.no)) if (!targets.has(target.identity)) targets.set(target.identity, `click ${click}; ${target.description}`)
|
|
188
220
|
}
|
|
189
|
-
result.push({ slide: String(slide.meta.slide.frontmatter.name ?? `slide-${slide.no}`), targets: [...targets].map(([identity, description]) => ({ identity, description })) })
|
|
221
|
+
result.push({ slide: String(slide.meta.slide.frontmatter.name ?? `slide-${slide.no}`), clicks: nav.clicksTotal.value, targets: [...targets].map(([identity, description]) => ({ identity, description })) })
|
|
190
222
|
}
|
|
191
223
|
await navigate(1)
|
|
192
224
|
return result
|
|
193
225
|
}
|
|
194
226
|
onUnmounted(() => {
|
|
195
227
|
generation++; clearWaits(); geometry?.stop(); preview?.dispose()
|
|
228
|
+
previewCanvases.splice(0).forEach(canvas => canvas.remove())
|
|
196
229
|
for (const element of monitors.keys()) stopMedia(element, false)
|
|
197
230
|
document.removeEventListener('play', silence, true); document.removeEventListener('volumechange', silence, true)
|
|
198
231
|
for (const type of ['keydown', 'pointerdown', 'click', 'dblclick', 'wheel']) document.removeEventListener(type, preventNavigation, true)
|
|
@@ -207,7 +240,7 @@ onMounted(async () => {
|
|
|
207
240
|
if (!response.ok) throw new Error('Preview configuration is unavailable')
|
|
208
241
|
const config = await response.json()
|
|
209
242
|
const { createPreview } = await import('./preview')
|
|
210
|
-
preview = createPreview(config.schedule, config.mediaHashes, config.parentOrigin, prepare, apply, () => ({ slide: String(nav.currentSlideRoute.value.meta.slide.frontmatter.name ?? `slide-${nav.currentSlideNo.value}`), visit, click: nav.clicks.value, index: nav.currentSlideNo.value }),
|
|
243
|
+
preview = createPreview(config.schedule, config.mediaHashes, config.parentOrigin, prepare, apply, () => ({ slide: String(nav.currentSlideRoute.value.meta.slide.frontmatter.name ?? `slide-${nav.currentSlideNo.value}`), visit, click: nav.clicks.value, index: nav.currentSlideNo.value }), renderPreview)
|
|
211
244
|
window.__slidevideo.preview = preview
|
|
212
245
|
await preview.initialize()
|
|
213
246
|
} catch (error) {
|
|
@@ -222,7 +255,6 @@ onMounted(async () => {
|
|
|
222
255
|
<template>
|
|
223
256
|
<Teleport to="body">
|
|
224
257
|
<div v-if="enabled && marker" :style="{ position: 'fixed', inset: '0', zIndex: 999999, background: marker, pointerEvents: 'none' }" />
|
|
225
|
-
<div v-for="layer in previewLayers" :key="layer.id" :data-slidevideo-annotation="layer.id" :style="{ position: 'fixed', left: `${layer.rectangle.x}px`, top: `${layer.rectangle.y}px`, width: `${layer.rectangle.width}px`, height: `${layer.rectangle.height}px`, background: layer.color, opacity: layer.opacity, mixBlendMode: layer.blend === 'darken' ? 'darken' : 'normal', zIndex: 999998, pointerEvents: 'none' }" />
|
|
226
258
|
</Teleport>
|
|
227
259
|
</template>
|
|
228
260
|
|
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import type { ResolvedAnnotation, Schedule, ScheduledAction } from '../../dist/contracts.js'
|
|
1
|
+
import type { GeometryRequest, ResolvedAnnotation, Schedule, ScheduledAction } from '../../dist/contracts.js'
|
|
2
|
+
import { geometryRequests } from '../../dist/annotation-paint.js'
|
|
2
3
|
|
|
3
|
-
type PlaybackEntry = { at: number; order: number } & (
|
|
4
|
-
{ type: 'action'; item: ScheduledAction }
|
|
5
|
-
{ type: 'start' | 'end';
|
|
4
|
+
export type PlaybackEntry = { at: number; order: number } & (
|
|
5
|
+
| { type: 'action'; item: ScheduledAction }
|
|
6
|
+
| { type: 'geometry-start' | 'geometry-end'; request: GeometryRequest }
|
|
7
|
+
| { type: 'annotation-start' | 'annotation-end'; annotation: ResolvedAnnotation }
|
|
6
8
|
)
|
|
7
9
|
|
|
8
10
|
export function playbackEntries(schedule: Schedule): PlaybackEntry[] {
|
|
9
11
|
const entries: PlaybackEntry[] = schedule.actions.map(item => ({ at: item.start_ms, order: 1, type: 'action', item }))
|
|
10
|
-
for (const
|
|
11
|
-
entries.push(
|
|
12
|
+
for (const request of geometryRequests(schedule)) {
|
|
13
|
+
entries.push(
|
|
14
|
+
{ at: request.start_ms, order: 2, type: 'geometry-start', request },
|
|
15
|
+
{ at: request.end_ms, order: -1, type: 'geometry-end', request },
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
for (const annotation of schedule.annotations) {
|
|
19
|
+
entries.push(
|
|
20
|
+
{ at: annotation.start_ms, order: 3, type: 'annotation-start', annotation },
|
|
21
|
+
{ at: annotation.end_ms, order: -2, type: 'annotation-end', annotation },
|
|
22
|
+
)
|
|
12
23
|
}
|
|
13
24
|
return entries.sort((a, b) => a.at - b.at || a.order - b.order)
|
|
14
25
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { AnnotationGeometry, ResolvedAnnotation, Schedule, ScheduledAction } from '../../dist/contracts.js'
|
|
2
|
-
import { annotationPaint, type
|
|
2
|
+
import { annotationPaint, findTargetGeometry, geometryRequests, underlineFragmentsVisible, type PaintableEffect } from '../../dist/annotation-paint.js'
|
|
3
3
|
import { playbackEntries } from './playback-entries'
|
|
4
4
|
import { geometryCollector } from './geometry'
|
|
5
5
|
|
|
6
6
|
type PreviewStatus = 'loading' | 'ready' | 'playing' | 'paused' | 'ended' | 'error'
|
|
7
|
-
export type PreviewLayer = AnnotationPaint & { id: string }
|
|
8
7
|
type Position = { slide: string; visit: string; click: number; index: number }
|
|
9
8
|
export function createPreview(
|
|
10
9
|
schedule: Schedule,
|
|
@@ -13,7 +12,7 @@ export function createPreview(
|
|
|
13
12
|
prepare: (schedule: Schedule, hashes: Record<string, string>) => Promise<void>,
|
|
14
13
|
apply: (item: ScheduledAction) => Promise<void>,
|
|
15
14
|
position: () => Position,
|
|
16
|
-
|
|
15
|
+
render: (effects: PaintableEffect[], timeMs: number) => void,
|
|
17
16
|
) {
|
|
18
17
|
let status: PreviewStatus = 'loading'
|
|
19
18
|
let message = ''
|
|
@@ -51,23 +50,31 @@ export function createPreview(
|
|
|
51
50
|
generation++; interruptWait(); cancelAnimationFrame(frame)
|
|
52
51
|
collector?.stop(); collector = undefined
|
|
53
52
|
for (const element of media) element.pause()
|
|
54
|
-
media.clear(); active.clear();
|
|
53
|
+
media.clear(); active.clear(); render([], elapsed())
|
|
55
54
|
}
|
|
56
55
|
function fail(error: unknown) {
|
|
57
56
|
offset = elapsed(); status = 'error'; message = error instanceof Error ? error.message : String(error)
|
|
58
57
|
freeze(); stop(); notify()
|
|
59
58
|
}
|
|
60
59
|
function paint() {
|
|
61
|
-
const output:
|
|
62
|
-
for (const annotation of schedule.annotations
|
|
60
|
+
const output: PaintableEffect[] = []
|
|
61
|
+
for (const annotation of schedule.annotations) {
|
|
63
62
|
if (!active.has(annotation.id)) continue
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
switch (annotation.effect) {
|
|
64
|
+
case 'highlight':
|
|
65
|
+
case 'underline': {
|
|
66
|
+
const record = findTargetGeometry(geometry, annotation, annotation.target)
|
|
67
|
+
if (!record) throw new Error(`Annotation ${annotation.id}: preview geometry is unavailable`)
|
|
68
|
+
const painted = annotationPaint(annotation, record)
|
|
69
|
+
if (painted.effect === 'underline' && !underlineFragmentsVisible(painted)) {
|
|
70
|
+
throw new Error(`Annotation ${annotation.id}: underline is clipped outside the slide-content rectangle`)
|
|
71
|
+
}
|
|
72
|
+
output.push(painted)
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
69
76
|
}
|
|
70
|
-
|
|
77
|
+
render(output, elapsed())
|
|
71
78
|
}
|
|
72
79
|
async function waitUntil(at: number, current: number) {
|
|
73
80
|
while (current === generation) {
|
|
@@ -80,16 +87,21 @@ export function createPreview(
|
|
|
80
87
|
function tick() {
|
|
81
88
|
if (status !== 'playing' && status !== 'paused') return
|
|
82
89
|
if (status === 'paused') freeze()
|
|
90
|
+
else if (active.size) {
|
|
91
|
+
try { paint() } catch (error) { fail(error); return }
|
|
92
|
+
}
|
|
83
93
|
if (performance.now() - lastNotification > 200) { notify(); lastNotification = performance.now() }
|
|
84
94
|
frame = requestAnimationFrame(tick)
|
|
85
95
|
}
|
|
86
96
|
async function run(current: number) {
|
|
87
97
|
try {
|
|
88
|
-
collector = geometryCollector(schedule
|
|
98
|
+
collector = geometryCollector(geometryRequests(schedule), geometry, position, elapsed, fail)
|
|
89
99
|
for (const entry of entries) {
|
|
90
100
|
if (!await waitUntil(entry.at, current)) return
|
|
91
|
-
if (entry.type === 'start')
|
|
92
|
-
else if (entry.type === 'end')
|
|
101
|
+
if (entry.type === 'geometry-start') collector!.start(entry.request)
|
|
102
|
+
else if (entry.type === 'geometry-end') collector!.end(entry.request)
|
|
103
|
+
else if (entry.type === 'annotation-start') { active.set(entry.annotation.id, entry.annotation); paint() }
|
|
104
|
+
else if (entry.type === 'annotation-end') { active.delete(entry.annotation.id); paint() }
|
|
93
105
|
else if (entry.type === 'media-end') {
|
|
94
106
|
const element = document.getElementById(entry.id)
|
|
95
107
|
if (element instanceof HTMLMediaElement) { element.pause(); media.delete(element) }
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Narration, SpeechAsset, TtsAdapter, Voice } from '../contracts.js';
|
|
2
|
+
export declare function elevenLabsApiKey(environment?: NodeJS.ProcessEnv): string | undefined;
|
|
2
3
|
export declare class ElevenLabsAdapter implements TtsAdapter {
|
|
3
4
|
id: string;
|
|
4
5
|
version: string;
|