@slidevideo/cli 0.3.1 → 0.9.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/CHANGELOG.md +13 -0
- package/README.md +1 -1
- package/addons/slidevideo/global-top.vue +8 -2
- package/addons/slidevideo/preview.ts +11 -1
- package/dist/adapters/edge.d.ts +1 -0
- package/dist/adapters/edge.js +4 -3
- package/dist/adapters/elevenlabs.d.ts +1 -0
- package/dist/adapters/elevenlabs.js +4 -3
- package/dist/adapters/powerpoint.js +7 -3
- package/dist/adapters/slidev-inspection.js +4 -2
- package/dist/annotation-paint.d.ts +35 -2
- package/dist/annotation-paint.js +234 -0
- package/dist/annotations.d.ts +8 -2
- package/dist/annotations.js +236 -24
- package/dist/assembly.js +143 -37
- package/dist/cli.js +20 -3
- package/dist/compositor.d.ts +17 -2
- package/dist/compositor.js +57 -23
- package/dist/contracts.d.ts +63 -2
- package/dist/media.js +24 -1
- package/dist/pipeline.js +3 -2
- package/dist/preview/contracts.d.ts +1 -0
- package/dist/preview/player.js +13 -2
- package/dist/preview/server.d.ts +1 -1
- package/dist/preview/server.js +3 -3
- package/dist/speech.d.ts +3 -2
- package/dist/speech.js +147 -44
- package/dist/storyboard.js +17 -1
- package/dist/timing.d.ts +3 -2
- package/dist/timing.js +72 -4
- package/dist/update-check-worker.js +43 -11
- package/dist/update-check.js +14 -10
- package/package.json +1 -1
- package/schemas/schedule.v1.json +599 -0
- package/schemas/storyboard.v1.json +1134 -0
- package/skills/slidevideo/SKILL.md +3 -3
- package/skills/slidevideo/references/storyboard.md +57 -1
package/dist/timing.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Schedule, SpeechManifest, Storyboard, TtsAdapter } from './contracts.js';
|
|
2
|
-
import { type VerifiedSpeechAudio } from './speech.js';
|
|
3
|
-
export declare function resolveTiming(story: Storyboard, speech: SpeechManifest): Promise<Schedule>;
|
|
2
|
+
import { type VerifiedSpeech, type VerifiedSpeechAudio } from './speech.js';
|
|
3
|
+
export declare function resolveTiming(story: Storyboard, speech: SpeechManifest, verified?: VerifiedSpeech): Promise<Schedule>;
|
|
4
4
|
export declare function resolvePreviewTiming(story: Storyboard, adapters: ReadonlyMap<string, TtsAdapter>, cache?: string): Promise<{
|
|
5
5
|
schedule: Schedule;
|
|
6
6
|
approximate: string[];
|
|
7
|
+
approximateCues: string[];
|
|
7
8
|
audio: Map<string, VerifiedSpeechAudio>;
|
|
8
9
|
}>;
|
package/dist/timing.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { requireCondition } from './errors.js';
|
|
2
2
|
import { probe } from './media.js';
|
|
3
3
|
import { checkSpeech, retainedSpeechTiming } from './speech.js';
|
|
4
|
-
export async function resolveTiming(story, speech) {
|
|
4
|
+
export async function resolveTiming(story, speech, verified) {
|
|
5
5
|
for (const asset of speech.assets)
|
|
6
|
-
await checkSpeech(asset);
|
|
6
|
+
await checkSpeech(asset, verified);
|
|
7
7
|
return resolveSchedule(story, speech.assets);
|
|
8
8
|
}
|
|
9
|
+
function approximateAlignment(text, durationMs) {
|
|
10
|
+
if (text.length === 0)
|
|
11
|
+
return null;
|
|
12
|
+
const units = Array.from({ length: text.length }, (_, index) => ({
|
|
13
|
+
text: text[index],
|
|
14
|
+
start: index,
|
|
15
|
+
end: index + 1,
|
|
16
|
+
start_ms: (index / text.length) * durationMs,
|
|
17
|
+
end_ms: ((index + 1) / text.length) * durationMs,
|
|
18
|
+
}));
|
|
19
|
+
return { form: 'original', granularity: 'character', text, units };
|
|
20
|
+
}
|
|
9
21
|
export async function resolvePreviewTiming(story, adapters, cache) {
|
|
10
22
|
const assets = [];
|
|
11
23
|
const approximate = [];
|
|
@@ -25,10 +37,40 @@ export async function resolvePreviewTiming(story, adapters, cache) {
|
|
|
25
37
|
else {
|
|
26
38
|
approximate.push(segment.id);
|
|
27
39
|
const words = segment.text.trim().split(/\s+/).filter(Boolean).length;
|
|
28
|
-
|
|
40
|
+
const durationMs = Math.max(1000, words * 60000 / 150);
|
|
41
|
+
assets.push({
|
|
42
|
+
id: segment.id,
|
|
43
|
+
duration_ms: durationMs,
|
|
44
|
+
transcript: { original: segment.text, normalized: segment.text },
|
|
45
|
+
alignment: approximateAlignment(segment.text, durationMs),
|
|
46
|
+
});
|
|
29
47
|
}
|
|
30
48
|
}
|
|
31
|
-
|
|
49
|
+
const schedule = await resolveSchedule(story, assets);
|
|
50
|
+
const approximateSet = new Set(approximate);
|
|
51
|
+
const seenCues = new Set();
|
|
52
|
+
const approximateCues = [];
|
|
53
|
+
const recordCue = (id) => {
|
|
54
|
+
if (!seenCues.has(id)) {
|
|
55
|
+
seenCues.add(id);
|
|
56
|
+
approximateCues.push(id);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
for (const item of schedule.actions) {
|
|
60
|
+
if (item.cue_span && approximateSet.has(item.cue_span.segment))
|
|
61
|
+
recordCue(item.id);
|
|
62
|
+
}
|
|
63
|
+
for (const annotation of schedule.annotations) {
|
|
64
|
+
if (annotation.cue_span && approximateSet.has(annotation.cue_span.segment))
|
|
65
|
+
recordCue(annotation.source_id ?? annotation.id);
|
|
66
|
+
}
|
|
67
|
+
for (const overlay of story.overlays ?? []) {
|
|
68
|
+
if (overlay.visible?.some(interval => (typeof interval.start !== 'number' && approximateSet.has(interval.start.segment))
|
|
69
|
+
|| (typeof interval.end !== 'number' && approximateSet.has(interval.end.segment)))) {
|
|
70
|
+
recordCue(overlay.id);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { schedule, approximate, approximateCues, audio };
|
|
32
74
|
}
|
|
33
75
|
async function resolveSchedule(story, speech) {
|
|
34
76
|
const media = await Promise.all(story.media.map(async (item) => ({ ...item, ...await probe(item.src) })));
|
|
@@ -208,6 +250,22 @@ async function resolveSchedule(story, speech) {
|
|
|
208
250
|
...windowFields,
|
|
209
251
|
};
|
|
210
252
|
}
|
|
253
|
+
if (annotation.effect === 'arrow') {
|
|
254
|
+
if (annotation.motion) {
|
|
255
|
+
const inMs = annotation.motion.in_ms ?? 0;
|
|
256
|
+
const outMs = annotation.motion.out_ms ?? 0;
|
|
257
|
+
requireCondition(inMs + outMs <= end - time, 'ANNOTATION_MOTION', `Annotation ${resolvedId}: ${annotation.motion.type} motion exceeds resolved duration (${Math.round(end - time)} ms)`, 2, context);
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
id: resolvedId,
|
|
261
|
+
scene: annotation.scene,
|
|
262
|
+
effect: 'arrow',
|
|
263
|
+
target: target,
|
|
264
|
+
...(annotation.appearance ? { appearance: annotation.appearance } : {}),
|
|
265
|
+
...(annotation.motion ? { motion: annotation.motion } : {}),
|
|
266
|
+
...windowFields,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
211
269
|
const singleTarget = target;
|
|
212
270
|
if (annotation.effect === 'underline') {
|
|
213
271
|
if (annotation.motion) {
|
|
@@ -276,6 +334,16 @@ async function resolveSchedule(story, speech) {
|
|
|
276
334
|
: pt),
|
|
277
335
|
};
|
|
278
336
|
}
|
|
337
|
+
if (t.type === 'connector') {
|
|
338
|
+
const normalizeEndpoint = (ep) => 'target' in ep && ep.target.type === 'text'
|
|
339
|
+
? { ...ep, target: { ...ep.target, text: normalizeSpaces(ep.target.text) } }
|
|
340
|
+
: ep;
|
|
341
|
+
return {
|
|
342
|
+
...t,
|
|
343
|
+
from: normalizeEndpoint(t.from),
|
|
344
|
+
to: normalizeEndpoint(t.to),
|
|
345
|
+
};
|
|
346
|
+
}
|
|
279
347
|
return t.type === 'text' ? { ...t, text: normalizeSpaces(t.text) } : t;
|
|
280
348
|
};
|
|
281
349
|
const normalizedTarget = normalizeTarget(annotation.target);
|
|
@@ -1,23 +1,55 @@
|
|
|
1
|
-
import { renameSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { mkdirSync, renameSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { gt, valid } from 'semver';
|
|
3
4
|
import { userDataDirectory } from './installation.js';
|
|
4
5
|
import { updateVersion } from './update-check.js';
|
|
5
6
|
const channel = process.argv[2];
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const rawInstalled = process.argv[3];
|
|
8
|
+
const installed = typeof rawInstalled === 'string' && valid(rawInstalled) ? rawInstalled : '0.0.0';
|
|
9
|
+
const userAgent = `slidevideo-cli/${installed} (${process.platform}; ${process.arch})`;
|
|
10
|
+
async function fetchReleaseVersion(targetChannel) {
|
|
11
|
+
let siteVersion;
|
|
8
12
|
try {
|
|
9
|
-
const
|
|
13
|
+
const url = targetChannel === 'alpha'
|
|
14
|
+
? 'https://slidevideo.io/release.json?channel=alpha'
|
|
15
|
+
: 'https://slidevideo.io/release.json';
|
|
16
|
+
const response = await fetch(url, {
|
|
17
|
+
headers: { 'user-agent': userAgent, accept: 'application/json' },
|
|
10
18
|
signal: AbortSignal.timeout(3000),
|
|
11
19
|
});
|
|
12
20
|
if (response.ok) {
|
|
13
21
|
const result = await response.json();
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
siteVersion = updateVersion(result?.version, targetChannel);
|
|
23
|
+
if (siteVersion && gt(siteVersion, installed))
|
|
24
|
+
return siteVersion;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch { }
|
|
28
|
+
try {
|
|
29
|
+
const fallback = await fetch(`https://registry.npmjs.org/@slidevideo%2fcli/${targetChannel}`, {
|
|
30
|
+
headers: { 'user-agent': userAgent, accept: 'application/json' },
|
|
31
|
+
signal: AbortSignal.timeout(3000),
|
|
32
|
+
});
|
|
33
|
+
if (fallback.ok) {
|
|
34
|
+
const result = await fallback.json();
|
|
35
|
+
const npmVersion = updateVersion(result?.version, targetChannel);
|
|
36
|
+
if (npmVersion)
|
|
37
|
+
return siteVersion && gt(siteVersion, npmVersion) ? siteVersion : npmVersion;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch { }
|
|
41
|
+
return siteVersion;
|
|
42
|
+
}
|
|
43
|
+
if (channel === 'latest' || channel === 'alpha') {
|
|
44
|
+
const deadline = setTimeout(() => process.exit(0), 6500);
|
|
45
|
+
try {
|
|
46
|
+
const version = await fetchReleaseVersion(channel);
|
|
47
|
+
if (version) {
|
|
48
|
+
const directory = join(userDataDirectory(), 'updates');
|
|
49
|
+
mkdirSync(directory, { recursive: true });
|
|
50
|
+
const pending = join(directory, `${channel}.${process.pid}.tmp`);
|
|
51
|
+
writeFileSync(pending, JSON.stringify(version), { mode: 0o600 });
|
|
52
|
+
renameSync(pending, join(directory, `${channel}.json`));
|
|
21
53
|
}
|
|
22
54
|
}
|
|
23
55
|
catch { }
|
package/dist/update-check.js
CHANGED
|
@@ -21,11 +21,13 @@ export function updateVersion(value, channel) {
|
|
|
21
21
|
return version && updateChannel(version) === channel ? version : undefined;
|
|
22
22
|
}
|
|
23
23
|
export function notifyUpdate(json, quiet) {
|
|
24
|
-
if (
|
|
24
|
+
if (process.env.SLIDEVIDEO_NO_UPDATE_CHECK === '1'
|
|
25
|
+
|| process.env.DO_NOT_TRACK === '1'
|
|
25
26
|
|| (process.env.CI && process.env.CI !== 'false')
|
|
26
27
|
|| process.env.GITHUB_ACTIONS || process.env.TF_BUILD || process.env.BUILD_NUMBER
|
|
27
|
-
||
|
|
28
|
+
|| process.env.NODE_TEST_CONTEXT)
|
|
28
29
|
return;
|
|
30
|
+
const interactive = !json && !quiet && Boolean(process.stdin.isTTY && process.stdout.isTTY && process.stderr.isTTY);
|
|
29
31
|
try {
|
|
30
32
|
const { version: installed } = JSON.parse(readFileSync(packagePath('package.json'), 'utf8'));
|
|
31
33
|
if (typeof installed !== 'string')
|
|
@@ -34,13 +36,15 @@ export function notifyUpdate(json, quiet) {
|
|
|
34
36
|
if (!channel)
|
|
35
37
|
return;
|
|
36
38
|
const directory = join(userDataDirectory(), 'updates');
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
if (interactive) {
|
|
40
|
+
let available;
|
|
41
|
+
try {
|
|
42
|
+
available = updateVersion(JSON.parse(readFileSync(join(directory, `${channel}.json`), 'utf8')), channel);
|
|
43
|
+
}
|
|
44
|
+
catch { }
|
|
45
|
+
if (available && gt(available, installed)) {
|
|
46
|
+
process.stderr.write(`[slidevideo] Update available: ${installed} → ${available}\nRun npm install -g @slidevideo/cli@${available}\nFor a custom install prefix, add the original --prefix option to this command.\n`);
|
|
47
|
+
}
|
|
44
48
|
}
|
|
45
49
|
mkdirSync(directory, { recursive: true });
|
|
46
50
|
const attempt = join(directory, 'attempt.json');
|
|
@@ -69,7 +73,7 @@ export function notifyUpdate(json, quiet) {
|
|
|
69
73
|
release();
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
|
-
const child = spawn(process.execPath, [fileURLToPath(new URL('./update-check-worker.js', import.meta.url)), channel], {
|
|
76
|
+
const child = spawn(process.execPath, [fileURLToPath(new URL('./update-check-worker.js', import.meta.url)), channel, installed], {
|
|
73
77
|
detached: true, stdio: 'ignore', windowsHide: true,
|
|
74
78
|
});
|
|
75
79
|
child.on('error', () => { });
|