vizmatic 0.7.1 → 0.7.2
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/PROMPT.md +25 -1
- package/dist/{chunk-DTD35LPT.js → chunk-F6QI6QJY.js} +60 -2
- package/dist/chunk-QVYHYC7T.js +88 -0
- package/dist/cli.js +3 -3
- package/dist/index.cjs +69 -2
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +13 -2
- package/dist/scene-cli.js +1 -1
- package/dist/stage-browser/browser.d.ts +120 -2
- package/dist/stage-browser/stage.js +5 -5
- package/dist/stage-export.cjs +67 -1
- package/dist/stage-export.d.cts +5 -1
- package/dist/stage-export.d.ts +5 -1
- package/dist/stage-export.js +11 -1
- package/dist/stage.cjs +221 -22
- package/dist/stage.d.cts +122 -4
- package/dist/stage.d.ts +122 -4
- package/dist/stage.js +203 -9
- package/dist/{svg-import-Djj2q7Pc.d.cts → svg-import-5_oTbEJR.d.cts} +2 -2
- package/dist/{svg-import-Djj2q7Pc.d.ts → svg-import-5_oTbEJR.d.ts} +2 -2
- package/dist/{video-CcHW1qhV.d.cts → video-BSwNJZkn.d.cts} +25 -1
- package/dist/{video-CcHW1qhV.d.ts → video-BSwNJZkn.d.ts} +25 -1
- package/package.json +1 -1
- package/dist/chunk-3LQLKLGH.js +0 -79
package/dist/index.cjs
CHANGED
|
@@ -138,7 +138,9 @@ __export(index_exports, {
|
|
|
138
138
|
byteDifferenceState: () => byteDifferenceState,
|
|
139
139
|
cameraSvgTransform: () => cameraSvgTransform,
|
|
140
140
|
canvas: () => canvas,
|
|
141
|
+
captionsToSrt: () => captionsToSrt,
|
|
141
142
|
categoricalSampling: () => categoricalSampling,
|
|
143
|
+
chapterMetadata: () => chapterMetadata,
|
|
142
144
|
checkFrame: () => checkFrame,
|
|
143
145
|
colors: () => colors,
|
|
144
146
|
compareByteSequences: () => compareByteSequences,
|
|
@@ -18388,7 +18390,14 @@ function createTeachingTokenHistory(painter) {
|
|
|
18388
18390
|
const progress = state.moving.progress;
|
|
18389
18391
|
const settle = Math.max(0, (progress - 0.65) / 0.35);
|
|
18390
18392
|
const grow = Math.max(0, (progress - 0.8) / 0.2);
|
|
18391
|
-
const
|
|
18393
|
+
const measuredWidth = painter.measureText?.(String(state.moving.token.token), fontSize, "mono");
|
|
18394
|
+
if (measuredWidth !== void 0 && (!Number.isFinite(measuredWidth) || measuredWidth < 0)) {
|
|
18395
|
+
throw new Error("Token history measured text width must be finite and nonnegative");
|
|
18396
|
+
}
|
|
18397
|
+
const copyWidth = Math.min(from.width, Math.max(
|
|
18398
|
+
fontSize * 3,
|
|
18399
|
+
measuredWidth === void 0 ? from.width : measuredWidth + 10
|
|
18400
|
+
));
|
|
18392
18401
|
const copyHeight = Math.min(from.height, fontSize * 1.8);
|
|
18393
18402
|
const movingWidth = copyWidth + (from.width - copyWidth) * grow;
|
|
18394
18403
|
const movingHeight = copyHeight + (from.height - copyHeight) * grow;
|
|
@@ -18832,6 +18841,35 @@ var import_promises3 = require("fs/promises");
|
|
|
18832
18841
|
var import_path3 = require("path");
|
|
18833
18842
|
var import_resvg_js3 = require("@resvg/resvg-js");
|
|
18834
18843
|
var import_parse_css_color4 = __toESM(require("parse-css-color"), 1);
|
|
18844
|
+
function chapterMetadata(title, chapters, duration) {
|
|
18845
|
+
const escape = (value) => value.replace(/[\\=;#]/g, (c) => `\\${c}`).replace(/\r?\n/g, " ");
|
|
18846
|
+
const marks = chapters.filter((chapter) => Number.isFinite(chapter.time) && chapter.time < duration).map((chapter) => ({ title: chapter.title, time: Math.max(0, chapter.time) })).sort((a, b) => a.time - b.time);
|
|
18847
|
+
if (marks.length > 0) marks[0].time = 0;
|
|
18848
|
+
let out = ";FFMETADATA1\n";
|
|
18849
|
+
if (title) out += `title=${escape(title)}
|
|
18850
|
+
`;
|
|
18851
|
+
marks.forEach((mark, index) => {
|
|
18852
|
+
const end = index + 1 < marks.length ? marks[index + 1].time : duration;
|
|
18853
|
+
out += `[CHAPTER]
|
|
18854
|
+
TIMEBASE=1/1000
|
|
18855
|
+
START=${Math.round(mark.time * 1e3)}
|
|
18856
|
+
END=${Math.round(end * 1e3)}
|
|
18857
|
+
title=${escape(mark.title)}
|
|
18858
|
+
`;
|
|
18859
|
+
});
|
|
18860
|
+
return out;
|
|
18861
|
+
}
|
|
18862
|
+
function captionsToSrt(captions, duration) {
|
|
18863
|
+
const stamp = (seconds) => {
|
|
18864
|
+
const ms = Math.round(seconds * 1e3);
|
|
18865
|
+
const pad = (value, size = 2) => String(value).padStart(size, "0");
|
|
18866
|
+
return `${pad(Math.floor(ms / 36e5))}:${pad(Math.floor(ms / 6e4) % 60)}:${pad(Math.floor(ms / 1e3) % 60)},${pad(ms % 1e3, 3)}`;
|
|
18867
|
+
};
|
|
18868
|
+
return captions.filter((cue) => cue.t1 > 0 && cue.t0 < duration && cue.t1 > cue.t0 && cue.text.trim().length > 0).sort((a, b) => a.t0 - b.t0).map((cue, index) => `${index + 1}
|
|
18869
|
+
${stamp(Math.max(0, cue.t0))} --> ${stamp(Math.min(duration, cue.t1))}
|
|
18870
|
+
${cue.text.trim()}
|
|
18871
|
+
`).join("\n");
|
|
18872
|
+
}
|
|
18835
18873
|
var MAX_STDERR_CHARS = 8192;
|
|
18836
18874
|
var COLOR_FILTER = "scale=in_range=pc:out_range=tv:out_color_matrix=bt709:flags=lanczos+accurate_rnd+full_chroma_int,format=yuv420p,setparams=range=tv:color_primaries=bt709:color_trc=bt709:colorspace=bt709";
|
|
18837
18875
|
var COLOR_TAGS = ["-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709", "-color_range", "tv"];
|
|
@@ -19045,12 +19083,37 @@ async function renderRgbaVideo(renderFrame2, options) {
|
|
|
19045
19083
|
"-i",
|
|
19046
19084
|
"pipe:0"
|
|
19047
19085
|
];
|
|
19086
|
+
let inputs = 1;
|
|
19087
|
+
let audioInput = -1;
|
|
19048
19088
|
if (options.audioPath) {
|
|
19049
19089
|
if (options.audioOffset) args.push("-ss", String(options.audioOffset));
|
|
19050
19090
|
args.push("-i", (0, import_path3.resolve)(options.audioPath));
|
|
19091
|
+
audioInput = inputs++;
|
|
19092
|
+
}
|
|
19093
|
+
const sidecars = [];
|
|
19094
|
+
let metadataInput = -1, captionInput = -1;
|
|
19095
|
+
if (codec === "h264") {
|
|
19096
|
+
const chapters = options.chapters ?? [];
|
|
19097
|
+
if (options.title || chapters.length > 0) {
|
|
19098
|
+
const path = (0, import_path3.join)(outputDirectory, `.${(0, import_path3.basename)(outputPath)}.${(0, import_crypto.randomUUID)()}.tmp.ffmeta`);
|
|
19099
|
+
await (0, import_promises3.writeFile)(path, chapterMetadata(options.title, chapters, schedule.duration), { mode: 384 });
|
|
19100
|
+
sidecars.push(path);
|
|
19101
|
+
args.push("-f", "ffmetadata", "-i", path);
|
|
19102
|
+
metadataInput = inputs++;
|
|
19103
|
+
}
|
|
19104
|
+
const srt = captionsToSrt(options.captions ?? [], schedule.duration);
|
|
19105
|
+
if (srt) {
|
|
19106
|
+
const path = (0, import_path3.join)(outputDirectory, `.${(0, import_path3.basename)(outputPath)}.${(0, import_crypto.randomUUID)()}.tmp.srt`);
|
|
19107
|
+
await (0, import_promises3.writeFile)(path, srt, { mode: 384 });
|
|
19108
|
+
sidecars.push(path);
|
|
19109
|
+
args.push("-f", "srt", "-i", path);
|
|
19110
|
+
captionInput = inputs++;
|
|
19111
|
+
}
|
|
19051
19112
|
}
|
|
19052
19113
|
args.push("-map", "0:v:0");
|
|
19053
|
-
if (options.audioPath) args.push("-map",
|
|
19114
|
+
if (options.audioPath) args.push("-map", `${audioInput}:a:0`, "-af", `asetpts=PTS-STARTPTS,apad,atrim=duration=${seconds}`);
|
|
19115
|
+
if (captionInput >= 0) args.push("-map", `${captionInput}:0`, "-c:s", "mov_text", "-metadata:s:s:0", "language=eng");
|
|
19116
|
+
if (metadataInput >= 0) args.push("-map_metadata", String(metadataInput), "-map_chapters", String(metadataInput));
|
|
19054
19117
|
args.push("-frames:v", String(schedule.count), "-t", seconds, "-vf", COLOR_FILTER);
|
|
19055
19118
|
if (codec === "vp9") {
|
|
19056
19119
|
args.push("-c:v", "libvpx-vp9", "-crf", String(crf), "-b:v", "0", "-deadline", "good", "-cpu-used", "2", "-row-mt", "1", "-threads:v", String(threads));
|
|
@@ -19074,6 +19137,7 @@ async function renderRgbaVideo(renderFrame2, options) {
|
|
|
19074
19137
|
child = (0, import_child_process.spawn)(ffmpegPath, args, { stdio: ["pipe", "ignore", "pipe"] });
|
|
19075
19138
|
} catch (error) {
|
|
19076
19139
|
await (0, import_promises3.rm)(tempPath, { force: true });
|
|
19140
|
+
for (const path of sidecars) await (0, import_promises3.rm)(path, { force: true });
|
|
19077
19141
|
throw error;
|
|
19078
19142
|
}
|
|
19079
19143
|
child.stderr?.on("data", (chunk) => {
|
|
@@ -19175,6 +19239,7 @@ async function renderRgbaVideo(renderFrame2, options) {
|
|
|
19175
19239
|
throw error;
|
|
19176
19240
|
} finally {
|
|
19177
19241
|
await (0, import_promises3.rm)(tempPath, { force: true });
|
|
19242
|
+
for (const path of sidecars) await (0, import_promises3.rm)(path, { force: true });
|
|
19178
19243
|
}
|
|
19179
19244
|
}
|
|
19180
19245
|
|
|
@@ -21759,7 +21824,9 @@ async function checkFrame(input, options = {}) {
|
|
|
21759
21824
|
byteDifferenceState,
|
|
21760
21825
|
cameraSvgTransform,
|
|
21761
21826
|
canvas,
|
|
21827
|
+
captionsToSrt,
|
|
21762
21828
|
categoricalSampling,
|
|
21829
|
+
chapterMetadata,
|
|
21763
21830
|
checkFrame,
|
|
21764
21831
|
colors,
|
|
21765
21832
|
compareByteSequences,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as ThemeColors, a as ToneName, D as Density, t as typography, b as ThemeMode, C as ColorName, W as WatermarkInput, R as RenderBackground, c as DefinedAnimation } from './video-
|
|
2
|
-
export { A as AnimationCadenceAnalysis, d as AnimationDefinition, e as AnimationEasing, f as AnimationEasingName, g as AnimationFrameContext, h as AnimationHoldStep, i as AnimationInterpolator, j as AnimationKeyframeStep, k as AnimationParallelStep, l as AnimationParallelTracks, m as AnimationPropertyStep, n as AnimationTimelineStep, o as AnimationTweenStep, p as AnimationVideoOptions, q as DEFAULT_DENSITY, r as DENSITY_NAMES, s as DensityName, u as DensityRadiusScale, v as DensitySpaceScale, w as DensityStrokeScale, x as DensityTokens, y as DensityTypeScale, z as RgbaVideoFrameRenderer, B as RgbaVideoOptions, E as RgbaVideoOutput, S as SampleAnimationOptions, F as SampledAnimationFrame, G as ThemeOptions, H as ThemePreset, I as TypographyVariant, V as VideoCodec, J as VideoFrameInfo, K as Watermark, L as WatermarkElementProps, M as WatermarkImageOptions, N as WatermarkOptions, O as WatermarkPosition, P as analyzeAnimationCadence, Q as assertDensity, U as canvas, X as
|
|
1
|
+
import { T as ThemeColors, a as ToneName, D as Density, t as typography, b as ThemeMode, C as ColorName, W as WatermarkInput, R as RenderBackground, c as DefinedAnimation } from './video-BSwNJZkn.cjs';
|
|
2
|
+
export { A as AnimationCadenceAnalysis, d as AnimationDefinition, e as AnimationEasing, f as AnimationEasingName, g as AnimationFrameContext, h as AnimationHoldStep, i as AnimationInterpolator, j as AnimationKeyframeStep, k as AnimationParallelStep, l as AnimationParallelTracks, m as AnimationPropertyStep, n as AnimationTimelineStep, o as AnimationTweenStep, p as AnimationVideoOptions, q as DEFAULT_DENSITY, r as DENSITY_NAMES, s as DensityName, u as DensityRadiusScale, v as DensitySpaceScale, w as DensityStrokeScale, x as DensityTokens, y as DensityTypeScale, z as RgbaVideoFrameRenderer, B as RgbaVideoOptions, E as RgbaVideoOutput, S as SampleAnimationOptions, F as SampledAnimationFrame, G as ThemeOptions, H as ThemePreset, I as TypographyVariant, V as VideoCodec, J as VideoFrameInfo, K as Watermark, L as WatermarkElementProps, M as WatermarkImageOptions, N as WatermarkOptions, O as WatermarkPosition, P as analyzeAnimationCadence, Q as assertDensity, U as canvas, X as captionsToSrt, Y as chapterMetadata, Z as colors, _ as compositeColor, $ as defineAnimation, a0 as densityOf, a1 as densityTokens, a2 as getColor, a3 as getGradient, a4 as getReadableColor, a5 as getReadableTextColor, a6 as getReadableToneColor, a7 as getStyles, a8 as getThemeColors, a9 as getToneColor, aa as getToneFill, ab as getToneGradient, ac as gradients, ad as hasShadow, ae as heatColor, af as hold, ag as keyframe, ah as normalizeWatermark, ai as parallel, aj as parseDensity, ak as renderAnimationVideo, al as renderRgbaVideo, am as sampleAnimation, an as sampleAnimationFrame, ao as sampleAnimationFrames, ap as setDefaultDensity, aq as setDensityResolver, ar as styles, as as toneGradients, at as tween, au as typeOf, av as videoFrameSchedule, aw as withColorAlpha, ax as withDensity, ay as wrapWithBrand, az as wrapWithWatermark } from './video-BSwNJZkn.cjs';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
4
|
import { SceneFrameRequest, SceneRequest } from './scene-runtime.cjs';
|
|
5
5
|
export { EvaluatedSceneFrame, PreparedScene, SCENE_LIMITS, SCENE_RUNTIME_VERSION, evaluateSceneSource, prepareScene } from './scene-runtime.cjs';
|
|
@@ -2104,6 +2104,8 @@ interface CanvasScopeOptions {
|
|
|
2104
2104
|
/** Inject checked drawing methods to retain the host renderer's audit metadata. */
|
|
2105
2105
|
interface CanvasPainter<Shape = unknown> {
|
|
2106
2106
|
target?<Result>(id: string, draw: () => Result): Result;
|
|
2107
|
+
/** Return text width using the same font and size as text(), without painting. */
|
|
2108
|
+
measureText?(value: string, size: number, font?: string): number;
|
|
2107
2109
|
rect(x: number, y: number, width: number, height: number, fill?: string, stroke?: string, radius?: number): Shape;
|
|
2108
2110
|
text(value: string, x: number, y: number, size: number, color?: string, align?: 'left' | 'center' | 'right', font?: string): unknown;
|
|
2109
2111
|
container(bounds: CanvasBounds, draw: () => void, options?: CanvasScopeOptions): unknown;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as ThemeColors, a as ToneName, D as Density, t as typography, b as ThemeMode, C as ColorName, W as WatermarkInput, R as RenderBackground, c as DefinedAnimation } from './video-
|
|
2
|
-
export { A as AnimationCadenceAnalysis, d as AnimationDefinition, e as AnimationEasing, f as AnimationEasingName, g as AnimationFrameContext, h as AnimationHoldStep, i as AnimationInterpolator, j as AnimationKeyframeStep, k as AnimationParallelStep, l as AnimationParallelTracks, m as AnimationPropertyStep, n as AnimationTimelineStep, o as AnimationTweenStep, p as AnimationVideoOptions, q as DEFAULT_DENSITY, r as DENSITY_NAMES, s as DensityName, u as DensityRadiusScale, v as DensitySpaceScale, w as DensityStrokeScale, x as DensityTokens, y as DensityTypeScale, z as RgbaVideoFrameRenderer, B as RgbaVideoOptions, E as RgbaVideoOutput, S as SampleAnimationOptions, F as SampledAnimationFrame, G as ThemeOptions, H as ThemePreset, I as TypographyVariant, V as VideoCodec, J as VideoFrameInfo, K as Watermark, L as WatermarkElementProps, M as WatermarkImageOptions, N as WatermarkOptions, O as WatermarkPosition, P as analyzeAnimationCadence, Q as assertDensity, U as canvas, X as
|
|
1
|
+
import { T as ThemeColors, a as ToneName, D as Density, t as typography, b as ThemeMode, C as ColorName, W as WatermarkInput, R as RenderBackground, c as DefinedAnimation } from './video-BSwNJZkn.js';
|
|
2
|
+
export { A as AnimationCadenceAnalysis, d as AnimationDefinition, e as AnimationEasing, f as AnimationEasingName, g as AnimationFrameContext, h as AnimationHoldStep, i as AnimationInterpolator, j as AnimationKeyframeStep, k as AnimationParallelStep, l as AnimationParallelTracks, m as AnimationPropertyStep, n as AnimationTimelineStep, o as AnimationTweenStep, p as AnimationVideoOptions, q as DEFAULT_DENSITY, r as DENSITY_NAMES, s as DensityName, u as DensityRadiusScale, v as DensitySpaceScale, w as DensityStrokeScale, x as DensityTokens, y as DensityTypeScale, z as RgbaVideoFrameRenderer, B as RgbaVideoOptions, E as RgbaVideoOutput, S as SampleAnimationOptions, F as SampledAnimationFrame, G as ThemeOptions, H as ThemePreset, I as TypographyVariant, V as VideoCodec, J as VideoFrameInfo, K as Watermark, L as WatermarkElementProps, M as WatermarkImageOptions, N as WatermarkOptions, O as WatermarkPosition, P as analyzeAnimationCadence, Q as assertDensity, U as canvas, X as captionsToSrt, Y as chapterMetadata, Z as colors, _ as compositeColor, $ as defineAnimation, a0 as densityOf, a1 as densityTokens, a2 as getColor, a3 as getGradient, a4 as getReadableColor, a5 as getReadableTextColor, a6 as getReadableToneColor, a7 as getStyles, a8 as getThemeColors, a9 as getToneColor, aa as getToneFill, ab as getToneGradient, ac as gradients, ad as hasShadow, ae as heatColor, af as hold, ag as keyframe, ah as normalizeWatermark, ai as parallel, aj as parseDensity, ak as renderAnimationVideo, al as renderRgbaVideo, am as sampleAnimation, an as sampleAnimationFrame, ao as sampleAnimationFrames, ap as setDefaultDensity, aq as setDensityResolver, ar as styles, as as toneGradients, at as tween, au as typeOf, av as videoFrameSchedule, aw as withColorAlpha, ax as withDensity, ay as wrapWithBrand, az as wrapWithWatermark } from './video-BSwNJZkn.js';
|
|
3
3
|
import React, { ReactNode } from 'react';
|
|
4
4
|
import { SceneFrameRequest, SceneRequest } from './scene-runtime.js';
|
|
5
5
|
export { EvaluatedSceneFrame, PreparedScene, SCENE_LIMITS, SCENE_RUNTIME_VERSION, evaluateSceneSource, prepareScene } from './scene-runtime.js';
|
|
@@ -2104,6 +2104,8 @@ interface CanvasScopeOptions {
|
|
|
2104
2104
|
/** Inject checked drawing methods to retain the host renderer's audit metadata. */
|
|
2105
2105
|
interface CanvasPainter<Shape = unknown> {
|
|
2106
2106
|
target?<Result>(id: string, draw: () => Result): Result;
|
|
2107
|
+
/** Return text width using the same font and size as text(), without painting. */
|
|
2108
|
+
measureText?(value: string, size: number, font?: string): number;
|
|
2107
2109
|
rect(x: number, y: number, width: number, height: number, fill?: string, stroke?: string, radius?: number): Shape;
|
|
2108
2110
|
text(value: string, x: number, y: number, size: number, color?: string, align?: 'left' | 'center' | 'right', font?: string): unknown;
|
|
2109
2111
|
container(bounds: CanvasBounds, draw: () => void, options?: CanvasScopeOptions): unknown;
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
Watermark,
|
|
19
19
|
addSvgAccessibility,
|
|
20
20
|
analyzeAnimationCadence,
|
|
21
|
+
captionsToSrt,
|
|
22
|
+
chapterMetadata,
|
|
21
23
|
chartAccessibilityAttributes,
|
|
22
24
|
chartDescription,
|
|
23
25
|
convertIndexedToRgb,
|
|
@@ -53,7 +55,7 @@ import {
|
|
|
53
55
|
withRenderContext,
|
|
54
56
|
wrapWithBrand,
|
|
55
57
|
wrapWithWatermark
|
|
56
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-F6QI6QJY.js";
|
|
57
59
|
import {
|
|
58
60
|
DEFAULT_DENSITY,
|
|
59
61
|
DENSITY_NAMES,
|
|
@@ -14274,7 +14276,14 @@ function createTeachingTokenHistory(painter) {
|
|
|
14274
14276
|
const progress = state.moving.progress;
|
|
14275
14277
|
const settle = Math.max(0, (progress - 0.65) / 0.35);
|
|
14276
14278
|
const grow = Math.max(0, (progress - 0.8) / 0.2);
|
|
14277
|
-
const
|
|
14279
|
+
const measuredWidth = painter.measureText?.(String(state.moving.token.token), fontSize, "mono");
|
|
14280
|
+
if (measuredWidth !== void 0 && (!Number.isFinite(measuredWidth) || measuredWidth < 0)) {
|
|
14281
|
+
throw new Error("Token history measured text width must be finite and nonnegative");
|
|
14282
|
+
}
|
|
14283
|
+
const copyWidth = Math.min(from.width, Math.max(
|
|
14284
|
+
fontSize * 3,
|
|
14285
|
+
measuredWidth === void 0 ? from.width : measuredWidth + 10
|
|
14286
|
+
));
|
|
14278
14287
|
const copyHeight = Math.min(from.height, fontSize * 1.8);
|
|
14279
14288
|
const movingWidth = copyWidth + (from.width - copyWidth) * grow;
|
|
14280
14289
|
const movingHeight = copyHeight + (from.height - copyHeight) * grow;
|
|
@@ -16544,7 +16553,9 @@ export {
|
|
|
16544
16553
|
byteDifferenceState,
|
|
16545
16554
|
cameraSvgTransform,
|
|
16546
16555
|
canvas,
|
|
16556
|
+
captionsToSrt,
|
|
16547
16557
|
categoricalSampling,
|
|
16558
|
+
chapterMetadata,
|
|
16548
16559
|
checkFrame,
|
|
16549
16560
|
colors,
|
|
16550
16561
|
compareByteSequences,
|
package/dist/scene-cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{SCENE_LIMITS,renderSceneFrame,renderSceneVideo}from"./chunk-
|
|
2
|
+
import{SCENE_LIMITS,renderSceneFrame,renderSceneVideo}from"./chunk-QVYHYC7T.js";import"./chunk-PSBF4TEK.js";import{readFile,stat}from"fs/promises";import{extname}from"path";async function main(){const args=process.argv.slice(2);if(args.length===1&&["--help","-h"].includes(args[0])){process.stdout.write("Usage: vizmatic-scene --input request.json --output scene.png|scene.mp4\nAll request time values are in seconds. Source is bare TSX, never a Node module.\nOptional JSON outputScale (0.25 to 1) reduces raster resolution; previewFps (MP4 only) reduces output fps while preserving logical scene globals. Metadata reports effective output dimensions and fps.\n");return}if(args.length!==4||args[0]!=="--input"||args[2]!=="--output"){throw new Error("Usage: vizmatic-scene --input request.json --output scene.png|scene.mp4")}const input=args[1],outputPath=args[3];const extension=extname(outputPath).toLowerCase();if(extension!==".png"&&extension!==".mp4")throw new Error("Scene output must be a PNG or MP4 file.");if((await stat(input)).size>SCENE_LIMITS.sourceBytes*6+32768)throw new Error("Scene request file exceeds its size limit.");const request=JSON.parse(await readFile(input,"utf8"));if(!request||typeof request!=="object"||Array.isArray(request))throw new Error("Scene request must be a JSON object.");const allowed=new Set(["source","width","height","duration","time","fps","theme","cues","seed","outputScale",...extension===".mp4"?["previewFps"]:[]]);if(Object.keys(request).some(name=>!allowed.has(name)))throw new Error("Scene request contains an unsupported field.");const options={...request,outputPath};const metadata=extension===".png"?await renderSceneFrame(options):await renderSceneVideo(options);process.stdout.write(`${JSON.stringify(metadata)}
|
|
3
3
|
`)}main().catch(error=>{process.stderr.write(`${error instanceof Error?error.message:"Scene rendering failed."}
|
|
4
4
|
`.slice(0,4096));process.exitCode=1});
|
|
@@ -815,6 +815,18 @@ declare function rect(width: number, height: number, style?: ShapeStyle & {
|
|
|
815
815
|
}): Node;
|
|
816
816
|
declare function polygon(points: readonly Vec[], style?: ShapeStyle): Node;
|
|
817
817
|
declare function regularPolygon(sides: number, radius: number, style?: ShapeStyle): Node;
|
|
818
|
+
interface ImageOptions {
|
|
819
|
+
/** Width on the stage. With only one of width and height, the other keeps the picture's proportions. */
|
|
820
|
+
width?: number;
|
|
821
|
+
height?: number;
|
|
822
|
+
opacity?: number;
|
|
823
|
+
}
|
|
824
|
+
/**
|
|
825
|
+
* A raster picture, such as a logo or a photo, centered on its origin. `src` is a URL or a
|
|
826
|
+
* data URL. A data URL keeps a film in one file and renders the same in every tool.
|
|
827
|
+
* It fades, moves, and scales like any node. Give `width`, `height`, or both.
|
|
828
|
+
*/
|
|
829
|
+
declare function image(src: string, options?: ImageOptions): Node;
|
|
818
830
|
/** A filled point. */
|
|
819
831
|
declare function dot(radius?: number, color?: ColorInput, style?: ShapeStyle): Node;
|
|
820
832
|
interface ArrowStyle extends ShapeStyle {
|
|
@@ -2078,6 +2090,109 @@ declare class SvgNode extends Node {
|
|
|
2078
2090
|
*/
|
|
2079
2091
|
declare function fromSvg(source: string, options?: FromSvgOptions): SvgNode;
|
|
2080
2092
|
|
|
2093
|
+
/** One spoken word, timed in seconds from the start of its beat. */
|
|
2094
|
+
interface NarrationWord {
|
|
2095
|
+
text: string;
|
|
2096
|
+
start: number;
|
|
2097
|
+
end: number;
|
|
2098
|
+
}
|
|
2099
|
+
/** One take of the voice: a sentence or a short paragraph. */
|
|
2100
|
+
interface NarrationBeat {
|
|
2101
|
+
/** The text that the voice speaks. Captions use it. */
|
|
2102
|
+
say: string;
|
|
2103
|
+
/** Measured length of the recording, in seconds. */
|
|
2104
|
+
duration: number;
|
|
2105
|
+
/** Silence after the beat, in seconds, for the viewer to think. */
|
|
2106
|
+
hold?: number;
|
|
2107
|
+
/** Word times, from the speech engine or from a transcription. Cues need them. */
|
|
2108
|
+
words?: readonly NarrationWord[];
|
|
2109
|
+
}
|
|
2110
|
+
interface NarrationScene {
|
|
2111
|
+
id: string;
|
|
2112
|
+
/** Chapter title. A scene without one does not start a chapter. */
|
|
2113
|
+
title?: string;
|
|
2114
|
+
beats: readonly NarrationBeat[];
|
|
2115
|
+
}
|
|
2116
|
+
interface NarrationTiming {
|
|
2117
|
+
scenes: readonly NarrationScene[];
|
|
2118
|
+
/** Seconds before the first word. `NarrationOptions.lead` overrides it. */
|
|
2119
|
+
lead?: number;
|
|
2120
|
+
/** Seconds of silence between scenes. `NarrationOptions.gap` overrides it. */
|
|
2121
|
+
gap?: number;
|
|
2122
|
+
}
|
|
2123
|
+
interface NarrationOptions {
|
|
2124
|
+
/** Seconds before the first word, for a logo or an opening picture. Defaults to 0.6. */
|
|
2125
|
+
lead?: number;
|
|
2126
|
+
/** Seconds of silence between scenes, for the picture to change. Defaults to 0.4. */
|
|
2127
|
+
gap?: number;
|
|
2128
|
+
/** Write a caption for each spoken line. On by default. */
|
|
2129
|
+
captions?: boolean;
|
|
2130
|
+
/** Longest caption line, in characters. Defaults to 74. */
|
|
2131
|
+
captionLength?: number;
|
|
2132
|
+
/** Start a chapter at each scene that has a title. On by default. */
|
|
2133
|
+
chapters?: boolean;
|
|
2134
|
+
}
|
|
2135
|
+
/** Where one beat falls on the film's timeline, in seconds. */
|
|
2136
|
+
interface PlacedBeat {
|
|
2137
|
+
/** The first moment of the recording. */
|
|
2138
|
+
start: number;
|
|
2139
|
+
/** The last moment of the recording. */
|
|
2140
|
+
end: number;
|
|
2141
|
+
/** The end of the silence after it. */
|
|
2142
|
+
until: number;
|
|
2143
|
+
text: string;
|
|
2144
|
+
words: readonly NarrationWord[];
|
|
2145
|
+
}
|
|
2146
|
+
/** Split spoken text into caption lines: by sentence, then by length. */
|
|
2147
|
+
declare function captionLines(text: string, length?: number): string[];
|
|
2148
|
+
/** The clock of one scene. Every time is in film seconds. */
|
|
2149
|
+
declare class SceneClock {
|
|
2150
|
+
private readonly stage;
|
|
2151
|
+
readonly id: string;
|
|
2152
|
+
readonly start: number;
|
|
2153
|
+
readonly end: number;
|
|
2154
|
+
readonly beats: readonly PlacedBeat[];
|
|
2155
|
+
constructor(stage: Stage, id: string, start: number, end: number, beats: readonly PlacedBeat[]);
|
|
2156
|
+
/** When the voice says a phrase. Pass a beat index to search one beat only. Throws if the phrase is not spoken. */
|
|
2157
|
+
cue(phrase: string, beat?: number): {
|
|
2158
|
+
start: number;
|
|
2159
|
+
end: number;
|
|
2160
|
+
};
|
|
2161
|
+
/** Build when the voice starts a phrase. `offset` moves it, in seconds. */
|
|
2162
|
+
on(phrase: string, build: () => void, offset?: number, beat?: number): this;
|
|
2163
|
+
/** Build when the voice finishes a phrase. */
|
|
2164
|
+
after(phrase: string, build: () => void, offset?: number, beat?: number): this;
|
|
2165
|
+
/** Build when a beat starts. */
|
|
2166
|
+
onBeat(index: number, build: () => void, offset?: number): this;
|
|
2167
|
+
/** Build at a time counted from the start of the scene. */
|
|
2168
|
+
at(seconds: number, build: () => void): this;
|
|
2169
|
+
/** Fade nodes out just before the scene ends, so the next picture starts on a clean frame. */
|
|
2170
|
+
clear(nodes: readonly Node[], lead?: number, duration?: number): this;
|
|
2171
|
+
}
|
|
2172
|
+
/** The timeline of a whole narration. */
|
|
2173
|
+
declare class Narration {
|
|
2174
|
+
readonly scenes: readonly SceneClock[];
|
|
2175
|
+
/** The end of the last scene, in seconds. Hold the film at least this long, or the voice is cut. */
|
|
2176
|
+
readonly duration: number;
|
|
2177
|
+
readonly lead: number;
|
|
2178
|
+
readonly gap: number;
|
|
2179
|
+
constructor(stage: Stage, timing: NarrationTiming, options?: NarrationOptions);
|
|
2180
|
+
/** The clock of one scene. */
|
|
2181
|
+
scene(id: string): SceneClock;
|
|
2182
|
+
/** Where every beat's recording starts, in order, for the script that mixes the sound. */
|
|
2183
|
+
placements(): {
|
|
2184
|
+
scene: string;
|
|
2185
|
+
beat: number;
|
|
2186
|
+
start: number;
|
|
2187
|
+
end: number;
|
|
2188
|
+
}[];
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Lay a measured narration on the stage. Each scene gets a clock with phrase cues.
|
|
2192
|
+
* Captions and chapters are added to the film, so the MP4 carries them.
|
|
2193
|
+
*/
|
|
2194
|
+
declare function narration(stage: Stage, timing: NarrationTiming, options?: NarrationOptions): Narration;
|
|
2195
|
+
|
|
2081
2196
|
/**
|
|
2082
2197
|
* 3D on the stage: a camera, meshes, curves, and points, all projected to paths
|
|
2083
2198
|
* on every frame and drawn back to front. There is no GPU dependency, so the
|
|
@@ -2298,6 +2413,7 @@ declare class Vector3D extends Line3D {
|
|
|
2298
2413
|
private readonly from3;
|
|
2299
2414
|
private readonly to3;
|
|
2300
2415
|
private readonly tipSize;
|
|
2416
|
+
private readonly tipBias;
|
|
2301
2417
|
constructor(from: Reactive3, to: Reactive3, style?: Line3DStyle & {
|
|
2302
2418
|
tip?: number;
|
|
2303
2419
|
});
|
|
@@ -2314,6 +2430,8 @@ interface Points3DStyle {
|
|
|
2314
2430
|
radius?: number;
|
|
2315
2431
|
opacity?: number;
|
|
2316
2432
|
onTop?: boolean;
|
|
2433
|
+
/** Nudge toward the camera so a point resting on a surface is not cut by it. */
|
|
2434
|
+
bias?: number;
|
|
2317
2435
|
/** Soft ring around each point. */
|
|
2318
2436
|
halo?: number;
|
|
2319
2437
|
}
|
|
@@ -2479,5 +2597,5 @@ declare function defineFilmElement(load: (src: string, options?: FilmLoadOptions
|
|
|
2479
2597
|
/** Load a film module by URL and compile it once per look and background. */
|
|
2480
2598
|
declare function loadFilm(src: string, options?: FilmLoadOptions): Promise<CompiledFilm>;
|
|
2481
2599
|
|
|
2482
|
-
export { ArrayCells, Axes, Axes3D, BarChart, Callout, CodeBlock, CompiledFilm, ComplexPlane, Connector, Counter, Curve3D, EMPTY_BOUNDS, Epicycles, FilmPlayer, Graph, GraphEdge, GraphNode, GridPlane3D, Heatmap, Histogram, IDENTITY, InfoBox, LOOKS, Label3D, LabeledDot, Line3D, LineChart, MatrixNode, NeuralNet, Node, NumberLine, NumberPlane, Object3D, PieChart, Points3D, Scatter, Scene3D, Stage, StreamLines, Surface3D, Suspend, SvgNode, TexNode, TextNode, TokenRow, Trail3D, TreeGraph, Value, Vector3D, VectorField, View3D, along, angleMark, appear, apply, applyComplex, applyMatrix, arc, arcPath, areaUnder, arrayCells, arrow, attentionMatrix, axes, axes3d, barChart, blueprint, bounce, brace, braceLabel, buildOps, call, callout, chalk, checkFilm, circle, circlePath, circumscribe, codeBlock, along$1 as colorAlong, compileFilm, complex, complexPlane, compose, concat, connector, countUp, counter, css, cubicBezier, curve, curve3d, curveThrough, dashedGuides, decimal, defineFilmElement, delay, donut, dot, draw, during, dynamic, easeInCubic, easeInExpo, easeInOutCubic, easeInOutQuint, easeInQuad, easeOutCubic, easeOutExpo, easeOutQuad, easeOutQuint, ellipse, epicycles, erase, fade, fadeIn, fadeOut, film, flash, fontFor, fourier, fourierPoint, frameInkBounds, frameToSvg, fromSvg, glyphPath, graph, gridPlane3d, group, grow, heatmap, highlightSweep, histogram, indicate, infoBox, invert, isFilm, isSuspend, label3d, labeledDot, lagged, legend, line, line3d, lineChart, linePath, linear, linearGradient, lingering, loadFilm, matScale, matrix, midnight, mixColor, morph, morphCode, morphMatching, moveTo, mul, neon, neuralNet, notQuiteThere, numberLine, overshoot, paintFrame, paper, par, parametric, parametricPath, parametricSurface, parseColor, parseFont, parseSvgPath, pathBounds, pathLength, pathToD, pie, plane, point3d, pointAt, points3d, polyPath, polygon, polyline, pulse, radialGradient, ramp, recolor, rect, rectPath, regularPolygon, resolveLook, retime, reverseRing, riemann, rightAngle, ring, ringCenter, ringLength, ringThrough, ripple, rotate, runningStart, rushFrom, rushInto, samplePath, scaleBy, scatter, scene3d, secantLine, segmentCount, seq, setAssetBase, shake, shape, shift, signedArea, slowInto, smooth, smoothBy, smoothPath, smoother, sparkline, sphere, spin, spring, streamLines, subdivideEach, surface, surroundingBox, svgPath, swap, tangentAt, tangentLine, tex, text, thereAndBack, thereAndBackWithPause, to, toPaint, tokenize, tokens, traced, trail3d, transformPath, tree, trimPath, trimRing, typewriter, unionBounds, vanish, vector3d, vectorField, warp, warpPath, wiggle, wipe, write };
|
|
2483
|
-
export type { AngleOptions, Anim, AnimContext, AnimOptions, AreaOptions, ArrayCellsOptions, ArrowStyle, Aspect, AttentionMatrixOptions, Axes3DOptions, AxesOptions, BarChartOptions, BarDatum, BlendMode, Bounds, BraceLabelOptions, CalloutOptions, Canvas2D, Caption, Chapter, ChartOptions, Clip, CodeBlockOptions, CodeToken, ColorInput, CompileOverrides, ComplexPlaneOptions, ConnectorEnd, ConnectorOptions, CounterOptions, DecimalOptions, DrawOp, Ease, Edge, EpicyclesOptions, FadeOptions, FieldFn, FilmCheckOptions, FilmCheckReport, FilmDefinition, FilmDiagnostic, FilmDiagnosticCode, FilmLoadOptions, FilmOptions, FontFamily, FontWeight, FourierTerm, Frame, FromSvgOptions, Gradient, GraphEdgeSpec, GraphNodeSpec, GraphOptions, GridPlaneOptions, HeatmapOptions, HighlightOptions, HistogramOptions, ImageOp, InfoBoxOptions, InfoRow, LabeledDotOptions, LegendItem, LegendOptions, Line3DStyle, LineChartOptions, LineSeries, LoadedFont, Look, LookName, LookToken, Mat, MatrixOptions, NeuralNetOptions, NodeProps, NumberLineOptions, Paint, ParametricFn, Path, PathOp, PieDatum, PieOptions, PlaneOptions, PlayOptions, PlayerOptions, Points3DStyle, PropName, Rgba, RiemannOptions, Ring, ScatterOptions, ScatterPoint, Scene3DOptions, SecantOptions, ShapeStyle, Side, SparklineOptions, StageImage, StreamLinesOptions, SurfaceOptions, SurroundOptions, TangentOptions, Target, TexOptions, TextOptions, TokenKind, TokenSpec, TokensOptions, TracedOptions, TreeOptions, TreeSpec, TypewriterOptions, Vec, Vec3, VectorFieldOptions, WipeOptions };
|
|
2600
|
+
export { ArrayCells, Axes, Axes3D, BarChart, Callout, CodeBlock, CompiledFilm, ComplexPlane, Connector, Counter, Curve3D, EMPTY_BOUNDS, Epicycles, FilmPlayer, Graph, GraphEdge, GraphNode, GridPlane3D, Heatmap, Histogram, IDENTITY, InfoBox, LOOKS, Label3D, LabeledDot, Line3D, LineChart, MatrixNode, Narration, NeuralNet, Node, NumberLine, NumberPlane, Object3D, PieChart, Points3D, Scatter, Scene3D, SceneClock, Stage, StreamLines, Surface3D, Suspend, SvgNode, TexNode, TextNode, TokenRow, Trail3D, TreeGraph, Value, Vector3D, VectorField, View3D, along, angleMark, appear, apply, applyComplex, applyMatrix, arc, arcPath, areaUnder, arrayCells, arrow, attentionMatrix, axes, axes3d, barChart, blueprint, bounce, brace, braceLabel, buildOps, call, callout, captionLines, chalk, checkFilm, circle, circlePath, circumscribe, codeBlock, along$1 as colorAlong, compileFilm, complex, complexPlane, compose, concat, connector, countUp, counter, css, cubicBezier, curve, curve3d, curveThrough, dashedGuides, decimal, defineFilmElement, delay, donut, dot, draw, during, dynamic, easeInCubic, easeInExpo, easeInOutCubic, easeInOutQuint, easeInQuad, easeOutCubic, easeOutExpo, easeOutQuad, easeOutQuint, ellipse, epicycles, erase, fade, fadeIn, fadeOut, film, flash, fontFor, fourier, fourierPoint, frameInkBounds, frameToSvg, fromSvg, glyphPath, graph, gridPlane3d, group, grow, heatmap, highlightSweep, histogram, image, indicate, infoBox, invert, isFilm, isSuspend, label3d, labeledDot, lagged, legend, line, line3d, lineChart, linePath, linear, linearGradient, lingering, loadFilm, matScale, matrix, midnight, mixColor, morph, morphCode, morphMatching, moveTo, mul, narration, neon, neuralNet, notQuiteThere, numberLine, overshoot, paintFrame, paper, par, parametric, parametricPath, parametricSurface, parseColor, parseFont, parseSvgPath, pathBounds, pathLength, pathToD, pie, plane, point3d, pointAt, points3d, polyPath, polygon, polyline, pulse, radialGradient, ramp, recolor, rect, rectPath, regularPolygon, resolveLook, retime, reverseRing, riemann, rightAngle, ring, ringCenter, ringLength, ringThrough, ripple, rotate, runningStart, rushFrom, rushInto, samplePath, scaleBy, scatter, scene3d, secantLine, segmentCount, seq, setAssetBase, shake, shape, shift, signedArea, slowInto, smooth, smoothBy, smoothPath, smoother, sparkline, sphere, spin, spring, streamLines, subdivideEach, surface, surroundingBox, svgPath, swap, tangentAt, tangentLine, tex, text, thereAndBack, thereAndBackWithPause, to, toPaint, tokenize, tokens, traced, trail3d, transformPath, tree, trimPath, trimRing, typewriter, unionBounds, vanish, vector3d, vectorField, warp, warpPath, wiggle, wipe, write };
|
|
2601
|
+
export type { AngleOptions, Anim, AnimContext, AnimOptions, AreaOptions, ArrayCellsOptions, ArrowStyle, Aspect, AttentionMatrixOptions, Axes3DOptions, AxesOptions, BarChartOptions, BarDatum, BlendMode, Bounds, BraceLabelOptions, CalloutOptions, Canvas2D, Caption, Chapter, ChartOptions, Clip, CodeBlockOptions, CodeToken, ColorInput, CompileOverrides, ComplexPlaneOptions, ConnectorEnd, ConnectorOptions, CounterOptions, DecimalOptions, DrawOp, Ease, Edge, EpicyclesOptions, FadeOptions, FieldFn, FilmCheckOptions, FilmCheckReport, FilmDefinition, FilmDiagnostic, FilmDiagnosticCode, FilmLoadOptions, FilmOptions, FontFamily, FontWeight, FourierTerm, Frame, FromSvgOptions, Gradient, GraphEdgeSpec, GraphNodeSpec, GraphOptions, GridPlaneOptions, HeatmapOptions, HighlightOptions, HistogramOptions, ImageOp, ImageOptions, InfoBoxOptions, InfoRow, LabeledDotOptions, LegendItem, LegendOptions, Line3DStyle, LineChartOptions, LineSeries, LoadedFont, Look, LookName, LookToken, Mat, MatrixOptions, NarrationBeat, NarrationOptions, NarrationScene, NarrationTiming, NarrationWord, NeuralNetOptions, NodeProps, NumberLineOptions, Paint, ParametricFn, Path, PathOp, PieDatum, PieOptions, PlacedBeat, PlaneOptions, PlayOptions, PlayerOptions, Points3DStyle, PropName, Rgba, RiemannOptions, Ring, ScatterOptions, ScatterPoint, Scene3DOptions, SecantOptions, ShapeStyle, Side, SparklineOptions, StageImage, StreamLinesOptions, SurfaceOptions, SurroundOptions, TangentOptions, Target, TexOptions, TextOptions, TokenKind, TokenSpec, TokensOptions, TracedOptions, TreeOptions, TreeSpec, TypewriterOptions, Vec, Vec3, VectorFieldOptions, WipeOptions };
|