codeboard-studio 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/LICENSE +21 -0
- package/NOTICE +23 -0
- package/README.md +54 -0
- package/dist/src/animation/camera-plane.d.ts +8 -0
- package/dist/src/animation/camera-plane.d.ts.map +1 -0
- package/dist/src/animation/camera-plane.js +16 -0
- package/dist/src/animation/camera-plane.js.map +1 -0
- package/dist/src/animation/drawing-neighbors.d.ts +4 -0
- package/dist/src/animation/drawing-neighbors.d.ts.map +1 -0
- package/dist/src/animation/drawing-neighbors.js +38 -0
- package/dist/src/animation/drawing-neighbors.js.map +1 -0
- package/dist/src/animation/evaluate.d.ts +17 -0
- package/dist/src/animation/evaluate.d.ts.map +1 -0
- package/dist/src/animation/evaluate.js +70 -0
- package/dist/src/animation/evaluate.js.map +1 -0
- package/dist/src/animation/frame.d.ts +8 -0
- package/dist/src/animation/frame.d.ts.map +1 -0
- package/dist/src/animation/frame.js +16 -0
- package/dist/src/animation/frame.js.map +1 -0
- package/dist/src/animation/ik.d.ts +26 -0
- package/dist/src/animation/ik.d.ts.map +1 -0
- package/dist/src/animation/ik.js +47 -0
- package/dist/src/animation/ik.js.map +1 -0
- package/dist/src/animation/retime.d.ts +4 -0
- package/dist/src/animation/retime.d.ts.map +1 -0
- package/dist/src/animation/retime.js +116 -0
- package/dist/src/animation/retime.js.map +1 -0
- package/dist/src/audio/wav.d.ts +11 -0
- package/dist/src/audio/wav.d.ts.map +1 -0
- package/dist/src/audio/wav.js +58 -0
- package/dist/src/audio/wav.js.map +1 -0
- package/dist/src/authoring-runner.d.ts +2 -0
- package/dist/src/authoring-runner.d.ts.map +1 -0
- package/dist/src/authoring-runner.js +24 -0
- package/dist/src/authoring-runner.js.map +1 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +127 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/core/coordinates.d.ts +16 -0
- package/dist/src/core/coordinates.d.ts.map +1 -0
- package/dist/src/core/coordinates.js +48 -0
- package/dist/src/core/coordinates.js.map +1 -0
- package/dist/src/core/handles.d.ts +93 -0
- package/dist/src/core/handles.d.ts.map +1 -0
- package/dist/src/core/handles.js +190 -0
- package/dist/src/core/handles.js.map +1 -0
- package/dist/src/core/history.d.ts +14 -0
- package/dist/src/core/history.d.ts.map +1 -0
- package/dist/src/core/history.js +80 -0
- package/dist/src/core/history.js.map +1 -0
- package/dist/src/core/inspection.d.ts +51 -0
- package/dist/src/core/inspection.d.ts.map +1 -0
- package/dist/src/core/inspection.js +72 -0
- package/dist/src/core/inspection.js.map +1 -0
- package/dist/src/core/production.d.ts +208 -0
- package/dist/src/core/production.d.ts.map +1 -0
- package/dist/src/core/production.js +894 -0
- package/dist/src/core/production.js.map +1 -0
- package/dist/src/core/project.d.ts +146 -0
- package/dist/src/core/project.d.ts.map +1 -0
- package/dist/src/core/project.js +700 -0
- package/dist/src/core/project.js.map +1 -0
- package/dist/src/drawing/brush-authoring.d.ts +6 -0
- package/dist/src/drawing/brush-authoring.d.ts.map +1 -0
- package/dist/src/drawing/brush-authoring.js +12 -0
- package/dist/src/drawing/brush-authoring.js.map +1 -0
- package/dist/src/drawing/brushes.d.ts +157 -0
- package/dist/src/drawing/brushes.d.ts.map +1 -0
- package/dist/src/drawing/brushes.js +50 -0
- package/dist/src/drawing/brushes.js.map +1 -0
- package/dist/src/drawing/color.d.ts +5 -0
- package/dist/src/drawing/color.d.ts.map +1 -0
- package/dist/src/drawing/color.js +63 -0
- package/dist/src/drawing/color.js.map +1 -0
- package/dist/src/drawing/curves.d.ts +27 -0
- package/dist/src/drawing/curves.d.ts.map +1 -0
- package/dist/src/drawing/curves.js +170 -0
- package/dist/src/drawing/curves.js.map +1 -0
- package/dist/src/drawing/math.d.ts +10 -0
- package/dist/src/drawing/math.d.ts.map +1 -0
- package/dist/src/drawing/math.js +40 -0
- package/dist/src/drawing/math.js.map +1 -0
- package/dist/src/drawing/path-geometry.d.ts +18 -0
- package/dist/src/drawing/path-geometry.d.ts.map +1 -0
- package/dist/src/drawing/path-geometry.js +115 -0
- package/dist/src/drawing/path-geometry.js.map +1 -0
- package/dist/src/drawing/path-sampling.d.ts +10 -0
- package/dist/src/drawing/path-sampling.d.ts.map +1 -0
- package/dist/src/drawing/path-sampling.js +64 -0
- package/dist/src/drawing/path-sampling.js.map +1 -0
- package/dist/src/drawing/path.d.ts +4 -0
- package/dist/src/drawing/path.d.ts.map +1 -0
- package/dist/src/drawing/path.js +27 -0
- package/dist/src/drawing/path.js.map +1 -0
- package/dist/src/drawing/pen-input.d.ts +5 -0
- package/dist/src/drawing/pen-input.d.ts.map +1 -0
- package/dist/src/drawing/pen-input.js +30 -0
- package/dist/src/drawing/pen-input.js.map +1 -0
- package/dist/src/drawing/pixel-selection.d.ts +23 -0
- package/dist/src/drawing/pixel-selection.d.ts.map +1 -0
- package/dist/src/drawing/pixel-selection.js +142 -0
- package/dist/src/drawing/pixel-selection.js.map +1 -0
- package/dist/src/drawing/pixels.d.ts +22 -0
- package/dist/src/drawing/pixels.d.ts.map +1 -0
- package/dist/src/drawing/pixels.js +79 -0
- package/dist/src/drawing/pixels.js.map +1 -0
- package/dist/src/drawing/resource-binary.d.ts +23 -0
- package/dist/src/drawing/resource-binary.d.ts.map +1 -0
- package/dist/src/drawing/resource-binary.js +135 -0
- package/dist/src/drawing/resource-binary.js.map +1 -0
- package/dist/src/drawing/resources.d.ts +51 -0
- package/dist/src/drawing/resources.d.ts.map +1 -0
- package/dist/src/drawing/resources.js +239 -0
- package/dist/src/drawing/resources.js.map +1 -0
- package/dist/src/drawing/stroke-outline.d.ts +5 -0
- package/dist/src/drawing/stroke-outline.d.ts.map +1 -0
- package/dist/src/drawing/stroke-outline.js +53 -0
- package/dist/src/drawing/stroke-outline.js.map +1 -0
- package/dist/src/drawing/swatch.d.ts +6 -0
- package/dist/src/drawing/swatch.d.ts.map +1 -0
- package/dist/src/drawing/swatch.js +15 -0
- package/dist/src/drawing/swatch.js.map +1 -0
- package/dist/src/export/animatic-export.d.ts +11 -0
- package/dist/src/export/animatic-export.d.ts.map +1 -0
- package/dist/src/export/animatic-export.js +52 -0
- package/dist/src/export/animatic-export.js.map +1 -0
- package/dist/src/export/movie-export.d.ts +16 -0
- package/dist/src/export/movie-export.d.ts.map +1 -0
- package/dist/src/export/movie-export.js +108 -0
- package/dist/src/export/movie-export.js.map +1 -0
- package/dist/src/export/sheet-layout.d.ts +27 -0
- package/dist/src/export/sheet-layout.d.ts.map +1 -0
- package/dist/src/export/sheet-layout.js +72 -0
- package/dist/src/export/sheet-layout.js.map +1 -0
- package/dist/src/export/storyboard-export.d.ts +8 -0
- package/dist/src/export/storyboard-export.d.ts.map +1 -0
- package/dist/src/export/storyboard-export.js +76 -0
- package/dist/src/export/storyboard-export.js.map +1 -0
- package/dist/src/index.d.ts +36 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +27 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/model/query.d.ts +6 -0
- package/dist/src/model/query.d.ts.map +1 -0
- package/dist/src/model/query.js +7 -0
- package/dist/src/model/query.js.map +1 -0
- package/dist/src/model/schema.d.ts +754 -0
- package/dist/src/model/schema.d.ts.map +1 -0
- package/dist/src/model/schema.js +205 -0
- package/dist/src/model/schema.js.map +1 -0
- package/dist/src/model/types.d.ts +537 -0
- package/dist/src/model/types.d.ts.map +1 -0
- package/dist/src/model/types.js +8 -0
- package/dist/src/model/types.js.map +1 -0
- package/dist/src/model/validate.d.ts +12 -0
- package/dist/src/model/validate.d.ts.map +1 -0
- package/dist/src/model/validate.js +183 -0
- package/dist/src/model/validate.js.map +1 -0
- package/dist/src/preview/server.d.ts +6 -0
- package/dist/src/preview/server.d.ts.map +1 -0
- package/dist/src/preview/server.js +71 -0
- package/dist/src/preview/server.js.map +1 -0
- package/dist/src/render/annotations.d.ts +4 -0
- package/dist/src/render/annotations.d.ts.map +1 -0
- package/dist/src/render/annotations.js +27 -0
- package/dist/src/render/annotations.js.map +1 -0
- package/dist/src/render/brush-engine.d.ts +14 -0
- package/dist/src/render/brush-engine.d.ts.map +1 -0
- package/dist/src/render/brush-engine.js +230 -0
- package/dist/src/render/brush-engine.js.map +1 -0
- package/dist/src/render/layer-compositor.d.ts +33 -0
- package/dist/src/render/layer-compositor.d.ts.map +1 -0
- package/dist/src/render/layer-compositor.js +296 -0
- package/dist/src/render/layer-compositor.js.map +1 -0
- package/dist/src/render/panel-renderer.d.ts +33 -0
- package/dist/src/render/panel-renderer.d.ts.map +1 -0
- package/dist/src/render/panel-renderer.js +118 -0
- package/dist/src/render/panel-renderer.js.map +1 -0
- package/dist/src/render/png.d.ts +4 -0
- package/dist/src/render/png.d.ts.map +1 -0
- package/dist/src/render/png.js +10 -0
- package/dist/src/render/png.js.map +1 -0
- package/dist/src/render/review.d.ts +42 -0
- package/dist/src/render/review.d.ts.map +1 -0
- package/dist/src/render/review.js +192 -0
- package/dist/src/render/review.js.map +1 -0
- package/dist/src/render/vector-renderer.d.ts +5 -0
- package/dist/src/render/vector-renderer.d.ts.map +1 -0
- package/dist/src/render/vector-renderer.js +98 -0
- package/dist/src/render/vector-renderer.js.map +1 -0
- package/dist/src/starter.d.ts +2 -0
- package/dist/src/starter.d.ts.map +1 -0
- package/dist/src/starter.js +23 -0
- package/dist/src/starter.js.map +1 -0
- package/dist/src/storage/codec.d.ts +20 -0
- package/dist/src/storage/codec.d.ts.map +1 -0
- package/dist/src/storage/codec.js +203 -0
- package/dist/src/storage/codec.js.map +1 -0
- package/dist/src/storage/store.d.ts +89 -0
- package/dist/src/storage/store.d.ts.map +1 -0
- package/dist/src/storage/store.js +392 -0
- package/dist/src/storage/store.js.map +1 -0
- package/dist/src/updates.d.ts +10 -0
- package/dist/src/updates.d.ts.map +1 -0
- package/dist/src/updates.js +134 -0
- package/dist/src/updates.js.map +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export function encodeWav(channels, sampleRate = 48000) {
|
|
2
|
+
if (!Number.isInteger(sampleRate) || sampleRate < 8000 || sampleRate > 192000 || channels.length < 1 || channels.length > 2)
|
|
3
|
+
throw new Error("WAV requires 1-2 channels and 8-192 kHz sample rate");
|
|
4
|
+
const count = channels[0].length;
|
|
5
|
+
if (count > sampleRate * 3600 || channels.some(c => c.length !== count))
|
|
6
|
+
throw new Error("WAV channel lengths differ or exceed one hour");
|
|
7
|
+
const bytes = count * channels.length * 2, b = Buffer.alloc(44 + bytes);
|
|
8
|
+
b.write("RIFF");
|
|
9
|
+
b.writeUInt32LE(36 + bytes, 4);
|
|
10
|
+
b.write("WAVEfmt ", 8);
|
|
11
|
+
b.writeUInt32LE(16, 16);
|
|
12
|
+
b.writeUInt16LE(1, 20);
|
|
13
|
+
b.writeUInt16LE(channels.length, 22);
|
|
14
|
+
b.writeUInt32LE(sampleRate, 24);
|
|
15
|
+
b.writeUInt32LE(sampleRate * channels.length * 2, 28);
|
|
16
|
+
b.writeUInt16LE(channels.length * 2, 32);
|
|
17
|
+
b.writeUInt16LE(16, 34);
|
|
18
|
+
b.write("data", 36);
|
|
19
|
+
b.writeUInt32LE(bytes, 40);
|
|
20
|
+
for (let i = 0; i < count; i++)
|
|
21
|
+
for (let c = 0; c < channels.length; c++) {
|
|
22
|
+
const v = channels[c][i];
|
|
23
|
+
if (!Number.isFinite(v))
|
|
24
|
+
throw new Error(`Invalid audio sample ${i}`);
|
|
25
|
+
b.writeInt16LE(Math.round(Math.max(-1, Math.min(1, v)) * 32767), 44 + (i * channels.length + c) * 2);
|
|
26
|
+
}
|
|
27
|
+
return b;
|
|
28
|
+
}
|
|
29
|
+
export function createToneWav(options = {}) {
|
|
30
|
+
const frequency = options.frequency ?? 440;
|
|
31
|
+
const durationSeconds = options.durationSeconds ?? 1;
|
|
32
|
+
const sampleRate = options.sampleRate ?? 48_000;
|
|
33
|
+
const volume = Math.max(0, Math.min(1, options.volume ?? 0.25));
|
|
34
|
+
const sampleCount = Math.max(1, Math.round(durationSeconds * sampleRate));
|
|
35
|
+
const dataBytes = sampleCount * 2;
|
|
36
|
+
const output = Buffer.alloc(44 + dataBytes);
|
|
37
|
+
output.write("RIFF", 0);
|
|
38
|
+
output.writeUInt32LE(36 + dataBytes, 4);
|
|
39
|
+
output.write("WAVEfmt ", 8);
|
|
40
|
+
output.writeUInt32LE(16, 16);
|
|
41
|
+
output.writeUInt16LE(1, 20);
|
|
42
|
+
output.writeUInt16LE(1, 22);
|
|
43
|
+
output.writeUInt32LE(sampleRate, 24);
|
|
44
|
+
output.writeUInt32LE(sampleRate * 2, 28);
|
|
45
|
+
output.writeUInt16LE(2, 32);
|
|
46
|
+
output.writeUInt16LE(16, 34);
|
|
47
|
+
output.write("data", 36);
|
|
48
|
+
output.writeUInt32LE(dataBytes, 40);
|
|
49
|
+
const attack = Math.max(1, Math.round((options.attackSeconds ?? 0.015) * sampleRate));
|
|
50
|
+
const release = Math.max(1, Math.round((options.releaseSeconds ?? 0.08) * sampleRate));
|
|
51
|
+
for (let index = 0; index < sampleCount; index += 1) {
|
|
52
|
+
const envelope = Math.min(1, index / attack, (sampleCount - index - 1) / release);
|
|
53
|
+
const sample = Math.sin(index / sampleRate * Math.PI * 2 * frequency) * volume * Math.max(0, envelope);
|
|
54
|
+
output.writeInt16LE(Math.round(sample * 32767), 44 + index * 2);
|
|
55
|
+
}
|
|
56
|
+
return output;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=wav.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wav.js","sourceRoot":"","sources":["../../../src/audio/wav.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,SAAS,CAAC,QAAwB,EAAE,UAAU,GAAC,KAAK;IAClE,IAAG,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAE,UAAU,GAAC,IAAI,IAAE,UAAU,GAAC,MAAM,IAAE,QAAQ,CAAC,MAAM,GAAC,CAAC,IAAE,QAAQ,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AW,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,CAAC,WAAW,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;QAClF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,UAAU,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;QACvG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-runner.d.ts","sourceRoot":"","sources":["../../src/authoring-runner.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { registerHooks } from "node:module";
|
|
10
|
+
import { pathToFileURL } from "node:url";
|
|
11
|
+
const script = process.argv[2];
|
|
12
|
+
if (!script)
|
|
13
|
+
throw new Error("An authoring script is required");
|
|
14
|
+
process.argv.splice(1, 1);
|
|
15
|
+
registerHooks({
|
|
16
|
+
resolve(specifier, context, nextResolve) {
|
|
17
|
+
if (specifier === "codeboard-studio") {
|
|
18
|
+
return { url: new URL("./index.js", import.meta.url).href, shortCircuit: true };
|
|
19
|
+
}
|
|
20
|
+
return nextResolve(specifier, context);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
await import(__rewriteRelativeImportExtension(pathToFileURL(script).href));
|
|
24
|
+
//# sourceMappingURL=authoring-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring-runner.js","sourceRoot":"","sources":["../../src/authoring-runner.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC/B,IAAI,CAAC,MAAM;IAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;AAChE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,aAAa,CAAC;IACZ,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW;QACrC,IAAI,SAAS,KAAK,kBAAkB,EAAE,CAAC;YACrC,OAAO,EAAE,GAAG,EAAE,IAAI,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAClF,CAAC;QACD,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;CACF,CAAC,CAAC;AACH,MAAM,MAAM,kCAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
import { findPackageJSON } from "node:module";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
import { writeFile } from "node:fs/promises";
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import { starter } from "./starter.js";
|
|
10
|
+
import { confirmUpdate, installUpdate, latestRelease, newerRelease, notifyUpdate } from "./updates.js";
|
|
11
|
+
import { exportMovie } from "./export/movie-export.js";
|
|
12
|
+
import { StoryboardProject } from "./core/project.js";
|
|
13
|
+
import { exportStoryboard } from "./export/storyboard-export.js";
|
|
14
|
+
import { exportAnimaticPackage } from "./export/animatic-export.js";
|
|
15
|
+
import { startPreview } from "./preview/server.js";
|
|
16
|
+
import { ProjectStore } from "./storage/store.js";
|
|
17
|
+
const packagePath = findPackageJSON(import.meta.url);
|
|
18
|
+
if (!packagePath)
|
|
19
|
+
throw new Error("Codeboard package metadata is missing");
|
|
20
|
+
const { version } = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
21
|
+
const program = new Command()
|
|
22
|
+
.name("codeboard")
|
|
23
|
+
.enablePositionalOptions()
|
|
24
|
+
.description("Draw, animate, and render through JavaScript or TypeScript")
|
|
25
|
+
.version(version);
|
|
26
|
+
program.hook("preAction", async (_command, action) => {
|
|
27
|
+
if (action.name() !== "update")
|
|
28
|
+
await notifyUpdate(packagePath, version);
|
|
29
|
+
});
|
|
30
|
+
program.command("update")
|
|
31
|
+
.description("Check for and install the latest stable GitHub release")
|
|
32
|
+
.option("--check", "Check without installing")
|
|
33
|
+
.option("-y, --yes", "Install without an interactive confirmation")
|
|
34
|
+
.action(async (options) => {
|
|
35
|
+
try {
|
|
36
|
+
const latest = await latestRelease();
|
|
37
|
+
if (!newerRelease(latest, version)) {
|
|
38
|
+
console.log(`Codeboard ${version} is up to date (latest stable: ${latest}).`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log(`Codeboard ${latest} is available (installed: ${version}).`);
|
|
42
|
+
if (!options.check && (options.yes || await confirmUpdate()))
|
|
43
|
+
await installUpdate(packagePath, version, latest);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
program.error(error instanceof Error ? error.message : String(error));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
program.command("init")
|
|
50
|
+
.argument("[file]", "New JavaScript authoring file", "scene.mjs")
|
|
51
|
+
.action(async (file) => {
|
|
52
|
+
await writeFile(resolve(file), starter, { flag: "wx" });
|
|
53
|
+
console.log(`Created ${file}. Run: codeboard run ${JSON.stringify(file)}`);
|
|
54
|
+
});
|
|
55
|
+
program.command("run")
|
|
56
|
+
.argument("<script>", "JavaScript or TypeScript authoring file")
|
|
57
|
+
.argument("[arguments...]", "Arguments passed to your script")
|
|
58
|
+
.passThroughOptions()
|
|
59
|
+
.action(async (script, args) => {
|
|
60
|
+
const child = spawn(process.execPath, [fileURLToPath(new URL("./authoring-runner.js", import.meta.url)), resolve(script), ...args], {
|
|
61
|
+
stdio: "inherit", windowsHide: true,
|
|
62
|
+
});
|
|
63
|
+
const forward = () => child.kill("SIGINT");
|
|
64
|
+
process.on("SIGINT", forward);
|
|
65
|
+
try {
|
|
66
|
+
process.exitCode = await new Promise((accept, reject) => {
|
|
67
|
+
child.once("error", reject);
|
|
68
|
+
child.once("exit", (code) => accept(code ?? 1));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
process.off("SIGINT", forward);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
program.command("render")
|
|
76
|
+
.argument("<project>", "Path to a .cboard file")
|
|
77
|
+
.option("-o, --output <directory>", "Export directory", "storyboard-export")
|
|
78
|
+
.option("--columns <number>", "Panels per sheet row", "2")
|
|
79
|
+
.option("--rows <number>", "Panel rows per sheet page", "2")
|
|
80
|
+
.action(async (projectPath, options) => {
|
|
81
|
+
const project = await StoryboardProject.open(resolve(projectPath));
|
|
82
|
+
const result = await exportStoryboard(project, resolve(options.output), { columns: Number(options.columns), rows: Number(options.rows) });
|
|
83
|
+
console.log(`Rendered ${result.panelFiles.length} panels and ${result.pdfFile}`);
|
|
84
|
+
});
|
|
85
|
+
program.command("validate")
|
|
86
|
+
.argument("<project>", "Path to a .cboard file")
|
|
87
|
+
.action(async (projectPath) => {
|
|
88
|
+
const store = ProjectStore.open(resolve(projectPath));
|
|
89
|
+
try {
|
|
90
|
+
store.verify();
|
|
91
|
+
console.log(JSON.stringify(store.inspect(), null, 2));
|
|
92
|
+
}
|
|
93
|
+
finally {
|
|
94
|
+
store.close();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
program.command("animatic")
|
|
98
|
+
.argument("<project>", "Path to a .cboard file")
|
|
99
|
+
.option("-o, --output <directory>", "Animatic package directory", "animatic-export")
|
|
100
|
+
.action(async (projectPath, options) => {
|
|
101
|
+
const project = await StoryboardProject.open(resolve(projectPath));
|
|
102
|
+
const result = await exportAnimaticPackage(project, resolve(options.output));
|
|
103
|
+
console.log(`Rendered ${result.frameFiles.length} frames and ${result.manifestFile}`);
|
|
104
|
+
});
|
|
105
|
+
program.command("preview")
|
|
106
|
+
.argument("<project>", "Path to a .cboard file")
|
|
107
|
+
.option("-p, --port <number>", "Preview port", "4173")
|
|
108
|
+
.action(async (projectPath, options) => {
|
|
109
|
+
await startPreview(resolve(projectPath), { port: Number(options.port) });
|
|
110
|
+
});
|
|
111
|
+
program.command("movie").argument("<project>").requiredOption("-o, --output <file>").option("--ffmpeg <path>")
|
|
112
|
+
.action(async (path, options) => {
|
|
113
|
+
const project = await StoryboardProject.open(resolve(path));
|
|
114
|
+
console.log(await exportMovie(project, options.output, { onProgress: (n, total) => { if (n % 24 === 0)
|
|
115
|
+
console.log(`${n}/${total} frames`); }, ...(options.ffmpeg ? { ffmpegPath: options.ffmpeg } : {}) }));
|
|
116
|
+
});
|
|
117
|
+
program.command("inspect").argument("<project>").option("--panel <id>").option("--name <text>").option("--limit <number>", "Result count (maximum 200)", "50").option("--offset <number>", "Skip matching objects", "0").action((path, options) => {
|
|
118
|
+
const store = ProjectStore.open(resolve(path));
|
|
119
|
+
try {
|
|
120
|
+
console.log(JSON.stringify({ storage: store.inspect(), objects: store.findObjects({ limit: Number(options.limit), offset: Number(options.offset), ...options.panel ? { panelId: options.panel } : {}, ...options.name ? { name: options.name } : {} }) }, null, 2));
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
store.close();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
await program.parseAsync();
|
|
127
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B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AAW,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,kBAAkB,EAAC,4BAA4B,EAAC,IAAI,CAAC,CAAC,MAAM,CAAC,mBAAmB,EAAC,uBAAuB,EAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAW,EAAC,OAA+D,EAAC,EAAE;IACzS,MAAM,KAAK,GAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,IAAG,CAAC;QAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,OAAO,EAAC,KAAK,CAAC,OAAO,EAAE,EAAC,OAAO,EAAC,KAAK,CAAC,WAAW,CAAC,EAAC,KAAK,EAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAC,MAAM,EAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAC,GAAG,OAAO,CAAC,KAAK,CAAA,CAAC,CAAA,EAAC,OAAO,EAAC,OAAO,CAAC,KAAK,EAAC,CAAA,CAAC,CAAA,EAAE,EAAC,GAAG,OAAO,CAAC,IAAI,CAAA,CAAC,CAAA,EAAC,IAAI,EAAC,OAAO,CAAC,IAAI,EAAC,CAAA,CAAC,CAAA,EAAE,EAAC,CAAC,EAAC,EAAC,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC;IAAA,CAAC;YAAO,CAAC;QAAA,KAAK,CAAC,KAAK,EAAE,CAAC;IAAA,CAAC;AACtQ,CAAC,CAAC,CAAC;AAEH,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AffineMatrix, StoryboardDocument } from "../model/types.js";
|
|
2
|
+
export interface CoordinateOptions {
|
|
3
|
+
frame?: number;
|
|
4
|
+
camera?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface CoordinateSpace {
|
|
7
|
+
panelId: string;
|
|
8
|
+
layerId: string;
|
|
9
|
+
rootLayerId: string;
|
|
10
|
+
targetId: string;
|
|
11
|
+
frame: number;
|
|
12
|
+
localToFrame: AffineMatrix;
|
|
13
|
+
frameToLocal: AffineMatrix | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function coordinateSpace(document: StoryboardDocument, targetId: string, options?: CoordinateOptions): CoordinateSpace;
|
|
16
|
+
//# sourceMappingURL=coordinates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinates.d.ts","sourceRoot":"","sources":["../../../src/core/coordinates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAO,kBAAkB,EAAgB,MAAM,mBAAmB,CAAC;AAM5F,MAAM,WAAW,iBAAiB;IAAE,KAAK,CAAC,EAAC,MAAM,CAAC;IAAA,MAAM,CAAC,EAAC,OAAO,CAAA;CAAC;AAClE,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAC,MAAM,CAAC;IAAA,OAAO,EAAC,MAAM,CAAC;IAAA,WAAW,EAAC,MAAM,CAAC;IAAA,QAAQ,EAAC,MAAM,CAAC;IAAA,KAAK,EAAC,MAAM,CAAC;IAC9E,YAAY,EAAC,YAAY,CAAC;IAAA,YAAY,EAAC,YAAY,GAAC,IAAI,CAAC;CAC1D;AAUD,wBAAgB,eAAe,CAAC,QAAQ,EAAC,kBAAkB,EAAC,QAAQ,EAAC,MAAM,EAAC,OAAO,GAAC,iBAAoB,GAAE,eAAe,CAgBxH"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { evaluateCamera, evaluateLayer } from "../animation/evaluate.js";
|
|
2
|
+
import { assertRenderFrame } from "../animation/frame.js";
|
|
3
|
+
import { cameraPlane } from "../animation/camera-plane.js";
|
|
4
|
+
import { invertMatrix, matrixFromTransform, multiplyMatrices } from "../drawing/math.js";
|
|
5
|
+
function locate(layers, id, ancestors = []) {
|
|
6
|
+
for (const layer of layers) {
|
|
7
|
+
const path = [...ancestors, layer];
|
|
8
|
+
if (layer.id === id)
|
|
9
|
+
return { path };
|
|
10
|
+
if (layer.kind === "group") {
|
|
11
|
+
const found = locate(layer.children, id, path);
|
|
12
|
+
if (found)
|
|
13
|
+
return found;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const element = layer.elements.find(e => e.id === id);
|
|
17
|
+
if (element)
|
|
18
|
+
return { path, element };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
export function coordinateSpace(document, targetId, options = {}) {
|
|
24
|
+
for (const panel of document.panels) {
|
|
25
|
+
const found = locate(panel.layers, targetId);
|
|
26
|
+
if (!found)
|
|
27
|
+
continue;
|
|
28
|
+
const frame = options.frame ?? panel.startFrame;
|
|
29
|
+
assertRenderFrame(frame);
|
|
30
|
+
let localToFrame = [1, 0, 0, 1, 0, 0];
|
|
31
|
+
if (options.camera !== false) {
|
|
32
|
+
const shot = document.shots.find(s => s.id === panel.shotId), camera = evaluateCamera(shot?.cameraKeyframes ?? [], frame), depth = evaluateLayer(found.path[0], frame).depth;
|
|
33
|
+
localToFrame = cameraPlane(camera, depth, panel.width, panel.height).matrix;
|
|
34
|
+
}
|
|
35
|
+
for (const layer of found.path)
|
|
36
|
+
localToFrame = multiplyMatrices(localToFrame, matrixFromTransform(evaluateLayer(layer, frame).transform, layer.pivot));
|
|
37
|
+
if (found.element?.matrix)
|
|
38
|
+
localToFrame = multiplyMatrices(localToFrame, found.element.matrix);
|
|
39
|
+
let frameToLocal = null;
|
|
40
|
+
try {
|
|
41
|
+
frameToLocal = invertMatrix(localToFrame);
|
|
42
|
+
}
|
|
43
|
+
catch { /* Forward mapping remains useful when inversion is unstable. */ }
|
|
44
|
+
return { panelId: panel.id, layerId: found.path.at(-1).id, rootLayerId: found.path[0].id, targetId, frame, localToFrame, frameToLocal };
|
|
45
|
+
}
|
|
46
|
+
throw new Error(`Coordinate target is not a layer or drawing element in a panel: ${targetId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xC,IAAG,CAAC;YAAA,YAAY,GAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAAA,CAAC;QAAA,MAAK,CAAC,CAAC,gEAAgE,CAAC,CAAC;QACtH,OAAO,EAAC,OAAO,EAAC,KAAK,CAAC,EAAE,EAAC,OAAO,EAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC,EAAE,EAAC,WAAW,EAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,EAAE,EAAC,QAAQ,EAAC,KAAK,EAAC,YAAY,EAAC,YAAY,EAAC,CAAC;IACjI,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mEAAmE,QAAQ,EAAE,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { BrushPreset, DrawingElement, Id, LayerChanges, LayerOptions, MotionAnnotation, NewDrawingElement, Panel, PanelOptions, PathCommand, Point, StoryboardDocument, StrokeOptions, Transform, VectorStrokeOptions, PixelBuffer, PixelRegion, RasterSurface, Pivot, VectorFill } from "../model/types.js";
|
|
2
|
+
import { type PathBooleanOperation } from "../drawing/path-geometry.js";
|
|
3
|
+
export interface ProjectActions {
|
|
4
|
+
_addScene(sequenceId: Id, name: string, id?: Id): SceneHandle;
|
|
5
|
+
toJSON(): StoryboardDocument;
|
|
6
|
+
_addShot(sceneId: Id, name: string, id?: Id): ShotHandle;
|
|
7
|
+
_addPanel(shotId: Id, options: PanelOptions): PanelHandle;
|
|
8
|
+
_addLayer(panelId: Id, kind: "raster" | "vector" | "group", name: string, options: LayerOptions, parentGroupId?: Id): LayerHandle;
|
|
9
|
+
_addElement(panelId: Id, layerId: Id, element: NewDrawingElement): Id;
|
|
10
|
+
_readPixels(panelId: Id, layerId: Id, elementId: Id, region?: PixelRegion): PixelBuffer;
|
|
11
|
+
_addMotion(panelId: Id, annotation: Omit<MotionAnnotation, "id"> & {
|
|
12
|
+
id?: Id;
|
|
13
|
+
}): Id;
|
|
14
|
+
_updatePanel(panelId: Id, changes: Partial<Pick<Panel, "title" | "durationFrames" | "action" | "dialogue" | "camera" | "notes">>): void;
|
|
15
|
+
_updateLayer(panelId: Id, layerId: Id, changes: LayerChanges): void;
|
|
16
|
+
_updateElement(panelId: Id, layerId: Id, elementId: Id, updater: (element: DrawingElement) => DrawingElement): void;
|
|
17
|
+
_updateElements(panelId: Id, layerId: Id, elementIds: Id[], updater: (element: DrawingElement) => DrawingElement): void;
|
|
18
|
+
_remove(panelId: Id, layerId?: Id, elementIds?: Id[]): void;
|
|
19
|
+
}
|
|
20
|
+
export declare class SequenceHandle {
|
|
21
|
+
private project;
|
|
22
|
+
readonly id: Id;
|
|
23
|
+
constructor(project: ProjectActions, id: Id);
|
|
24
|
+
addScene(name: string, id?: Id): SceneHandle;
|
|
25
|
+
}
|
|
26
|
+
export declare class SceneHandle {
|
|
27
|
+
private project;
|
|
28
|
+
readonly id: Id;
|
|
29
|
+
constructor(project: ProjectActions, id: Id);
|
|
30
|
+
addShot(name: string, id?: Id): ShotHandle;
|
|
31
|
+
}
|
|
32
|
+
export declare class ShotHandle {
|
|
33
|
+
private project;
|
|
34
|
+
readonly id: Id;
|
|
35
|
+
constructor(project: ProjectActions, id: Id);
|
|
36
|
+
addPanel(options?: PanelOptions): PanelHandle;
|
|
37
|
+
}
|
|
38
|
+
export declare class PanelHandle {
|
|
39
|
+
private project;
|
|
40
|
+
readonly id: Id;
|
|
41
|
+
constructor(project: ProjectActions, id: Id);
|
|
42
|
+
addRasterLayer(name: string, options?: LayerOptions, parentGroupId?: Id): LayerHandle;
|
|
43
|
+
addVectorLayer(name: string, options?: LayerOptions, parentGroupId?: Id): LayerHandle;
|
|
44
|
+
addGroup(name: string, options?: LayerOptions, parentGroupId?: Id): LayerHandle;
|
|
45
|
+
addMotion(label: string, from: Point, to: Point, color?: string, id?: Id): Id;
|
|
46
|
+
revise(changes: Partial<Pick<Panel, "title" | "durationFrames" | "action" | "dialogue" | "camera" | "notes">>): this;
|
|
47
|
+
layer(id: Id): LayerHandle;
|
|
48
|
+
}
|
|
49
|
+
export declare class LayerHandle {
|
|
50
|
+
private project;
|
|
51
|
+
readonly panelId: Id;
|
|
52
|
+
readonly id: Id;
|
|
53
|
+
constructor(project: ProjectActions, panelId: Id, id: Id);
|
|
54
|
+
rasterSurface(image: PixelBuffer, options?: Partial<Pick<RasterSurface, "id" | "name" | "matrix" | "opacity" | "visible">>): Id;
|
|
55
|
+
readPixels(elementId: Id, region?: PixelRegion): PixelBuffer;
|
|
56
|
+
editPixels(elementId: Id, region: PixelRegion, edit: (patch: PixelBuffer) => void): this;
|
|
57
|
+
rasterStroke(points: Point[], brush: BrushPreset, options?: StrokeOptions): Id;
|
|
58
|
+
erase(points: Point[], brush: BrushPreset, options?: Omit<StrokeOptions, "erase">): Id;
|
|
59
|
+
vectorStroke(points: Point[], options?: VectorStrokeOptions): Id;
|
|
60
|
+
path(commands: PathCommand[], options?: {
|
|
61
|
+
id?: Id;
|
|
62
|
+
name?: string;
|
|
63
|
+
fill?: VectorFill;
|
|
64
|
+
stroke?: string;
|
|
65
|
+
strokeWidth?: number;
|
|
66
|
+
opacity?: number;
|
|
67
|
+
}): Id;
|
|
68
|
+
text(text: string, x: number, y: number, options?: {
|
|
69
|
+
id?: Id;
|
|
70
|
+
name?: string;
|
|
71
|
+
color?: string;
|
|
72
|
+
font?: string;
|
|
73
|
+
align?: "left" | "center" | "right";
|
|
74
|
+
opacity?: number;
|
|
75
|
+
}): Id;
|
|
76
|
+
set(changes: LayerChanges): this;
|
|
77
|
+
edit(elementId: Id, updater: (element: DrawingElement) => DrawingElement): this;
|
|
78
|
+
outlineStroke(elementId: Id): this;
|
|
79
|
+
booleanPath(elementId: Id, tool: readonly PathCommand[], operation: PathBooleanOperation): this;
|
|
80
|
+
}
|
|
81
|
+
export declare class Selection {
|
|
82
|
+
private project;
|
|
83
|
+
private panelId;
|
|
84
|
+
private layerId;
|
|
85
|
+
private elementIds;
|
|
86
|
+
constructor(project: ProjectActions, panelId: Id, layerId: Id | undefined, elementIds: Id[]);
|
|
87
|
+
transform(transform: Partial<Transform>, options?: {
|
|
88
|
+
pivot?: Pivot;
|
|
89
|
+
}): this;
|
|
90
|
+
opacity(value: number): this;
|
|
91
|
+
remove(): void;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=handles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handles.d.ts","sourceRoot":"","sources":["../../../src/core/handles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EAAE,cAAc,EAAE,EAAE,EAAS,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,EAAE,YAAY,EAC5H,WAAW,EAAE,KAAK,EAAgB,kBAAkB,EAAE,aAAa,EAAE,SAAS,EAC9E,mBAAmB,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAChF,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAc,KAAK,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AAEnF,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,UAAU,EAAC,EAAE,EAAC,IAAI,EAAC,MAAM,EAAC,EAAE,CAAC,EAAC,EAAE,GAAE,WAAW,CAAC;IACxD,MAAM,IAAI,kBAAkB,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,UAAU,CAAC;IACzD,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,WAAW,CAAC;IAC1D,SAAS,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,CAAC,EAAE,EAAE,GAAG,WAAW,CAAC;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ing/math.js";
|
|
2
|
+
import { readPixelRegion, writePixelRegion, validatePixels } from "../drawing/pixels.js";
|
|
3
|
+
import { outlinedStroke } from "../drawing/stroke-outline.js";
|
|
4
|
+
import { combinePaths } from "../drawing/path-geometry.js";
|
|
5
|
+
export class SequenceHandle {
|
|
6
|
+
project;
|
|
7
|
+
id;
|
|
8
|
+
constructor(project, id) {
|
|
9
|
+
this.project = project;
|
|
10
|
+
this.id = id;
|
|
11
|
+
}
|
|
12
|
+
addScene(name, id) { return this.project._addScene(this.id, name, id); }
|
|
13
|
+
}
|
|
14
|
+
export class SceneHandle {
|
|
15
|
+
project;
|
|
16
|
+
id;
|
|
17
|
+
constructor(project, id) {
|
|
18
|
+
this.project = project;
|
|
19
|
+
this.id = id;
|
|
20
|
+
}
|
|
21
|
+
addShot(name, id) { return this.project._addShot(this.id, name, id); }
|
|
22
|
+
}
|
|
23
|
+
export class ShotHandle {
|
|
24
|
+
project;
|
|
25
|
+
id;
|
|
26
|
+
constructor(project, id) {
|
|
27
|
+
this.project = project;
|
|
28
|
+
this.id = id;
|
|
29
|
+
}
|
|
30
|
+
addPanel(options = {}) { return this.project._addPanel(this.id, options); }
|
|
31
|
+
}
|
|
32
|
+
export class PanelHandle {
|
|
33
|
+
project;
|
|
34
|
+
id;
|
|
35
|
+
constructor(project, id) {
|
|
36
|
+
this.project = project;
|
|
37
|
+
this.id = id;
|
|
38
|
+
}
|
|
39
|
+
addRasterLayer(name, options = {}, parentGroupId) { return this.project._addLayer(this.id, "raster", name, options, parentGroupId); }
|
|
40
|
+
addVectorLayer(name, options = {}, parentGroupId) { return this.project._addLayer(this.id, "vector", name, options, parentGroupId); }
|
|
41
|
+
addGroup(name, options = {}, parentGroupId) { return this.project._addLayer(this.id, "group", name, options, parentGroupId); }
|
|
42
|
+
addMotion(label, from, to, color = "#d14a32", id) { return this.project._addMotion(this.id, { label, from, to, color, ...(id ? { id } : {}) }); }
|
|
43
|
+
revise(changes) { this.project._updatePanel(this.id, changes); return this; }
|
|
44
|
+
layer(id) { return new LayerHandle(this.project, this.id, id); }
|
|
45
|
+
}
|
|
46
|
+
export class LayerHandle {
|
|
47
|
+
project;
|
|
48
|
+
panelId;
|
|
49
|
+
id;
|
|
50
|
+
constructor(project, panelId, id) {
|
|
51
|
+
this.project = project;
|
|
52
|
+
this.panelId = panelId;
|
|
53
|
+
this.id = id;
|
|
54
|
+
}
|
|
55
|
+
rasterSurface(image, options = {}) {
|
|
56
|
+
validatePixels(image);
|
|
57
|
+
return this.project._addElement(this.panelId, this.id, { kind: "raster-surface", ...structuredClone(image), matrix: [1, 0, 0, 1, 0, 0], opacity: 1, visible: true, ...structuredClone(options) });
|
|
58
|
+
}
|
|
59
|
+
readPixels(elementId, region) {
|
|
60
|
+
return this.project._readPixels(this.panelId, this.id, elementId, region);
|
|
61
|
+
}
|
|
62
|
+
editPixels(elementId, region, edit) {
|
|
63
|
+
return this.edit(elementId, element => {
|
|
64
|
+
if (element.kind !== "raster-surface")
|
|
65
|
+
throw new Error(`Element ${elementId} is not a pixel surface`);
|
|
66
|
+
const patch = readPixelRegion(element, region), result = edit(patch);
|
|
67
|
+
if (result && typeof result.then === "function")
|
|
68
|
+
throw new Error("Pixel edit callbacks must be synchronous");
|
|
69
|
+
if (patch.width !== region.width || patch.height !== region.height)
|
|
70
|
+
throw new Error("Pixel edits cannot resize the selected region");
|
|
71
|
+
writePixelRegion(element, region.x, region.y, patch);
|
|
72
|
+
return element;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
rasterStroke(points, brush, options = {}) {
|
|
76
|
+
const stroke = {
|
|
77
|
+
kind: "raster-stroke", points: structuredClone(points), brush: structuredClone(brush), color: options.color ?? "#222222",
|
|
78
|
+
opacity: options.opacity ?? 1, erase: options.erase ?? false, seed: options.seed ?? 1, visible: true,
|
|
79
|
+
...(options.reveal ? { reveal: structuredClone(options.reveal) } : {}),
|
|
80
|
+
...(options.id ? { id: options.id } : {}), ...(options.name ? { name: options.name } : {}),
|
|
81
|
+
};
|
|
82
|
+
return this.project._addElement(this.panelId, this.id, stroke);
|
|
83
|
+
}
|
|
84
|
+
erase(points, brush, options = {}) {
|
|
85
|
+
return this.rasterStroke(points, brush, { ...options, erase: true });
|
|
86
|
+
}
|
|
87
|
+
vectorStroke(points, options = {}) {
|
|
88
|
+
const stroke = {
|
|
89
|
+
kind: "vector-stroke", points: structuredClone(points), color: options.color ?? "#181716", width: options.width ?? 6,
|
|
90
|
+
opacity: options.opacity ?? 1, taperStart: options.taperStart ?? 0, taperEnd: options.taperEnd ?? 0,
|
|
91
|
+
pressureSize: options.pressureSize ?? 0.8, closed: options.closed ?? false, visible: true,
|
|
92
|
+
...(options.id ? { id: options.id } : {}), ...(options.name ? { name: options.name } : {}),
|
|
93
|
+
...(options.fill !== undefined ? { fill: options.fill } : {}),
|
|
94
|
+
};
|
|
95
|
+
return this.project._addElement(this.panelId, this.id, stroke);
|
|
96
|
+
}
|
|
97
|
+
path(commands, options = {}) {
|
|
98
|
+
return this.project._addElement(this.panelId, this.id, {
|
|
99
|
+
kind: "vector-path", commands: structuredClone(commands), strokeWidth: options.strokeWidth ?? 0,
|
|
100
|
+
opacity: options.opacity ?? 1, visible: true, ...(options.id ? { id: options.id } : {}),
|
|
101
|
+
...(options.name ? { name: options.name } : {}), ...(options.fill !== undefined ? { fill: structuredClone(options.fill) } : {}),
|
|
102
|
+
...(options.stroke !== undefined ? { stroke: options.stroke } : {}),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
text(text, x, y, options = {}) {
|
|
106
|
+
return this.project._addElement(this.panelId, this.id, {
|
|
107
|
+
kind: "text", text, x, y, color: options.color ?? "#181716", font: options.font ?? "24px sans-serif",
|
|
108
|
+
align: options.align ?? "left", opacity: options.opacity ?? 1, visible: true,
|
|
109
|
+
...(options.id ? { id: options.id } : {}), ...(options.name ? { name: options.name } : {}),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
set(changes) {
|
|
113
|
+
this.project._updateLayer(this.panelId, this.id, changes);
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
edit(elementId, updater) {
|
|
117
|
+
this.project._updateElement(this.panelId, this.id, elementId, updater);
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
outlineStroke(elementId) {
|
|
121
|
+
return this.edit(elementId, element => {
|
|
122
|
+
if (element.kind !== "vector-stroke")
|
|
123
|
+
throw new Error(`Element ${elementId} is not a vector stroke`);
|
|
124
|
+
return outlinedStroke(element);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
booleanPath(elementId, tool, operation) {
|
|
128
|
+
return this.edit(elementId, element => {
|
|
129
|
+
if (element.kind !== "vector-path")
|
|
130
|
+
throw new Error(`Element ${elementId} is not a vector contour`);
|
|
131
|
+
return { ...element, commands: combinePaths(element.commands, tool, operation) };
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export class Selection {
|
|
136
|
+
project;
|
|
137
|
+
panelId;
|
|
138
|
+
layerId;
|
|
139
|
+
elementIds;
|
|
140
|
+
constructor(project, panelId, layerId, elementIds) {
|
|
141
|
+
this.project = project;
|
|
142
|
+
this.panelId = panelId;
|
|
143
|
+
this.layerId = layerId;
|
|
144
|
+
this.elementIds = elementIds;
|
|
145
|
+
this.elementIds = [...new Set(elementIds)];
|
|
146
|
+
}
|
|
147
|
+
transform(transform, options = {}) {
|
|
148
|
+
if (!this.layerId)
|
|
149
|
+
throw new Error("Selection.transform() requires a layerId");
|
|
150
|
+
if (this.elementIds.length === 0) {
|
|
151
|
+
if (options.pivot)
|
|
152
|
+
throw new Error("A temporary pivot requires selected elements; set the layer pivot for layer animation");
|
|
153
|
+
const panel = this.project.toJSON().panels.find((entry) => entry.id === this.panelId);
|
|
154
|
+
if (!panel)
|
|
155
|
+
throw new Error(`Panel not found: ${this.panelId}`);
|
|
156
|
+
const current = findLayer(panel.layers, this.layerId).transform;
|
|
157
|
+
this.project._updateLayer(this.panelId, this.layerId, { transform: { ...current, ...transform } });
|
|
158
|
+
return this;
|
|
159
|
+
}
|
|
160
|
+
this.project._updateElements(this.panelId, this.layerId, this.elementIds, (element) => transformElement(element, transform, options.pivot));
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
opacity(value) {
|
|
164
|
+
if (!this.layerId)
|
|
165
|
+
throw new Error("Selection.opacity() requires a layerId");
|
|
166
|
+
if (this.elementIds.length === 0)
|
|
167
|
+
this.project._updateLayer(this.panelId, this.layerId, { opacity: value });
|
|
168
|
+
else
|
|
169
|
+
this.project._updateElements(this.panelId, this.layerId, this.elementIds, (element) => ({ ...element, opacity: value }));
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
remove() { this.project._remove(this.panelId, this.layerId, this.elementIds); }
|
|
173
|
+
}
|
|
174
|
+
function findLayer(layers, id) {
|
|
175
|
+
for (const layer of layers) {
|
|
176
|
+
if (layer.id === id)
|
|
177
|
+
return layer;
|
|
178
|
+
if (layer.kind === "group") {
|
|
179
|
+
try {
|
|
180
|
+
return findLayer(layer.children, id);
|
|
181
|
+
}
|
|
182
|
+
catch { /* keep searching */ }
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
throw new Error(`Layer not found: ${id}`);
|
|
186
|
+
}
|
|
187
|
+
function transformElement(element, transform, pivot) {
|
|
188
|
+
return { ...element, matrix: multiplyMatrices(matrixFromTransform(transform, pivot), element.matrix ?? [1, 0, 0, 1, 0, 0]) };
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=handles.js.map
|