@senad-d/drawme 0.1.11 → 0.2.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 +10 -1
- package/README.md +47 -46
- package/SECURITY.md +1 -1
- package/assets/references/diagram-types.md +3 -3
- package/assets/references/mermaid-authoring.md +10 -9
- package/assets/references/troubleshooting.md +5 -27
- package/assets/references/xml-authoring.md +5 -3
- package/docs/reference.md +75 -73
- package/docs/visual-review-implementation-tasks.md +4 -2
- package/example/README.md +9 -9
- package/example/drawme-architecture.drawio +5 -5
- package/example/drawme-how-it-works.drawio +7 -7
- package/example/drawme-installation-guide.drawio +6 -6
- package/package.json +5 -3
- package/src/animate.ts +124 -88
- package/src/animation.ts +105 -109
- package/src/diagram-files.ts +159 -0
- package/src/dom.ts +5 -0
- package/src/drawio.ts +324 -566
- package/src/editable-import.ts +228 -0
- package/src/explain.ts +81 -88
- package/src/export-plan.ts +175 -0
- package/src/fitcanvas.ts +29 -25
- package/src/geometry.ts +68 -29
- package/src/index.ts +201 -142
- package/src/motion.ts +251 -163
- package/src/png.ts +233 -34
- package/src/renderer.ts +361 -0
- package/src/shapesearch.ts +33 -32
- package/src/storyboard.ts +41 -26
- package/src/svg-helpers.ts +129 -0
- package/src/svgexport.ts +6 -9
- package/src/validate.ts +686 -292
- package/src/workflow.ts +41 -30
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<mxfile host="drawio" version="31.7.0">
|
|
3
3
|
<diagram id="drawme-installation-guide" name="Quick start • Light">
|
|
4
|
-
<mxGraphModel grid="1" gridSize="10" guides="1" page="1" pageScale="1" pageWidth="1635" pageHeight="
|
|
4
|
+
<mxGraphModel grid="1" gridSize="10" guides="1" page="1" pageScale="1" pageWidth="1635" pageHeight="1235" background="#FFFFFF" shadow="0">
|
|
5
5
|
<root>
|
|
6
6
|
<mxCell id="0"/>
|
|
7
7
|
<mxCell id="1" parent="0"/>
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
<mxCell id="prepare-rule-1" value="" style="fillColor=#E2E8F0;strokeColor=none;html=1;" vertex="1" parent="prepare">
|
|
48
48
|
<mxGeometry x="25" y="195" width="410" height="1" as="geometry"/>
|
|
49
49
|
</mxCell>
|
|
50
|
-
<mxCell id="desktop" value="<b>draw.io Desktop</b><br><font color="#64748B" style="font-size:17px"><font face="monospace" style="font-size:17px">brew install --cask drawio</font><br>macOS command above<br>Linux: .deb / .rpm · Windows: installer</font>" style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;spacing=0;strokeColor=none;fillColor=none;fontFamily=Helvetica;fontColor=#0F172A;fontSize=21;fontStyle=0;" vertex="1" parent="prepare">
|
|
50
|
+
<mxCell id="desktop" value="<b>draw.io Desktop</b><br><font color="#64748B" style="font-size:17px"><font face="monospace" style="font-size:17px">brew install --cask drawio</font><br>macOS command above<br>Linux: .deb / .rpm · Windows: installer<br>WSL: install native Linux draw.io</font>" style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;spacing=0;strokeColor=none;fillColor=none;fontFamily=Helvetica;fontColor=#0F172A;fontSize=21;fontStyle=0;" vertex="1" parent="prepare">
|
|
51
51
|
<mxGeometry x="25" y="220" width="410" height="150" as="geometry"/>
|
|
52
52
|
</mxCell>
|
|
53
53
|
<mxCell id="prepare-rule-2" value="" style="fillColor=#E2E8F0;strokeColor=none;html=1;" vertex="1" parent="prepare">
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
<mxCell id="start" value="<b>In your terminal</b><br><font color="#64748B" style="font-size:17px"><font face="monospace" style="font-size:18px">cd /path/to/project<br>pi</font><br>Grant project trust after review</font>" style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;spacing=0;strokeColor=none;fillColor=none;fontFamily=Helvetica;fontColor=#0F172A;fontSize=21;fontStyle=0;" vertex="1" parent="use">
|
|
75
75
|
<mxGeometry x="25" y="35" width="410" height="125" as="geometry"/>
|
|
76
76
|
</mxCell>
|
|
77
|
-
<mxCell id="verify" value="<b>Inside Pi · verify</b><br><font color="#64748B" style="font-size:16px"><font face="monospace" style="font-size:19px">/drawme-check</font><br>Reports the detected path + version</font>" style="rounded=1;absoluteArcSize=1;arcSize=12;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;spacing=20;fontFamily=Helvetica;fontSize=21;fontColor=#0F172A;fillColor=#FFFFFF;strokeColor=#E2E8F0;strokeWidth=1.5;" vertex="1" parent="use">
|
|
78
|
-
<mxGeometry x="25" y="245" width="410" height="
|
|
77
|
+
<mxCell id="verify" value="<b>Inside Pi · verify</b><br><font color="#64748B" style="font-size:16px"><font face="monospace" style="font-size:19px">/drawme-check</font><br>Reports the detected path + version<br>Mermaid and ELK layout support<br>If unavailable: explains what to do</font>" style="rounded=1;absoluteArcSize=1;arcSize=12;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;spacing=20;fontFamily=Helvetica;fontSize=21;fontColor=#0F172A;fillColor=#FFFFFF;strokeColor=#E2E8F0;strokeWidth=1.5;" vertex="1" parent="use">
|
|
78
|
+
<mxGeometry x="25" y="245" width="410" height="145" as="geometry"/>
|
|
79
79
|
</mxCell>
|
|
80
80
|
<mxCell id="describe" value="<b>Inside Pi · describe</b><br><font color="#64748B" style="font-size:17px"><font face="monospace" style="font-size:17px">/drawme a login flow with retry</font><br>Add “animated SVG” for motion</font>" style="rounded=1;absoluteArcSize=1;arcSize=12;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;spacing=20;fontFamily=Helvetica;fontSize=21;fontColor=#0F172A;fillColor=#EFF6FF;strokeColor=#2563EB;strokeWidth=1.5;" vertex="1" parent="use">
|
|
81
81
|
<mxGeometry x="25" y="460" width="410" height="145" as="geometry"/>
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
<mxCell id="footer-rule" value="" style="fillColor=#E2E8F0;strokeColor=none;html=1;" vertex="1" parent="1">
|
|
93
93
|
<mxGeometry x="40" y="1090" width="1540" height="1" as="geometry"/>
|
|
94
94
|
</mxCell>
|
|
95
|
-
<mxCell id="compatibility" value="
|
|
96
|
-
<mxGeometry x="40" y="1120" width="1540" height="
|
|
95
|
+
<mxCell id="compatibility" value="Mermaid conversion and ELK layout require draw.io 30.2.4+. Explicit page selection on export requires 32.4.1+.<br>Supported older versions still render and export without an explicit page index.<br>No CLI? Author + validate XML only — no preview or export." style="text;html=1;whiteSpace=wrap;align=left;verticalAlign=middle;spacing=0;strokeColor=none;fillColor=none;fontFamily=Helvetica;fontColor=#64748B;fontSize=17;fontStyle=0;" vertex="1" parent="1">
|
|
96
|
+
<mxGeometry x="40" y="1120" width="1540" height="75" as="geometry"/>
|
|
97
97
|
</mxCell>
|
|
98
98
|
</root>
|
|
99
99
|
</mxGraphModel>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@senad-d/drawme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Pi extension for authoring, validating, and exporting editable draw.io diagrams from natural-language descriptions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -79,9 +79,11 @@
|
|
|
79
79
|
"@vitest/coverage-v8": "^5.0.0",
|
|
80
80
|
"eslint": "^10.8.0",
|
|
81
81
|
"globals": "^17.8.0",
|
|
82
|
-
"
|
|
82
|
+
"marked": "18.0.11",
|
|
83
|
+
"typebox": "1.4.7",
|
|
83
84
|
"typescript": "~6.0.3",
|
|
84
85
|
"typescript-eslint": "^8.10.0",
|
|
85
|
-
"vitest": "^5.0.0"
|
|
86
|
+
"vitest": "^5.0.0",
|
|
87
|
+
"yaml": "2.9.0"
|
|
86
88
|
}
|
|
87
89
|
}
|
package/src/animate.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
7
|
-
import { existsSync } from "node:fs";
|
|
8
|
-
import { tmpdir } from "node:os";
|
|
9
|
-
import { basename, dirname, extname, join } from "node:path";
|
|
1
|
+
/** Validate, stage, and publish DrawMe motion under a single diagram reservation. */
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { accessSync, closeSync, constants, ftruncateSync, openSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { open, readFile, rm, writeFile } from "node:fs/promises";
|
|
5
|
+
import { basename, extname } from "node:path";
|
|
10
6
|
import { DOMParser, XMLSerializer } from "@xmldom/xmldom";
|
|
11
|
-
import type { DomEl } from "./dom";
|
|
12
7
|
import { analyzeDrawioAnimation } from "./animation";
|
|
13
|
-
import {
|
|
8
|
+
import { readDiagramXml, siblingPath, withDiagramFiles } from "./diagram-files";
|
|
9
|
+
import type { DomEl } from "./dom";
|
|
10
|
+
import { prepareExport, rejectSourceAlias, type PreparedExport } from "./drawio";
|
|
14
11
|
import {
|
|
15
12
|
type MotionSpec,
|
|
16
13
|
compileMotion,
|
|
@@ -32,9 +29,10 @@ export interface AnimateOptions {
|
|
|
32
29
|
hold?: number;
|
|
33
30
|
pageIndex?: number;
|
|
34
31
|
output?: string;
|
|
35
|
-
/** Render a storyboard PNG of the
|
|
32
|
+
/** Render a storyboard PNG of the visual batch end states (default true). */
|
|
36
33
|
storyboard?: boolean;
|
|
37
34
|
binary?: string;
|
|
35
|
+
signal?: AbortSignal;
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
export interface AnimateResult {
|
|
@@ -52,17 +50,13 @@ export interface AnimateResult {
|
|
|
52
50
|
travellingDots: number;
|
|
53
51
|
connectorFlows: number;
|
|
54
52
|
storyboard?: string;
|
|
53
|
+
storyboardSha256?: string;
|
|
55
54
|
storyboardFrames?: number;
|
|
56
55
|
storyboardFramesTotal?: number;
|
|
57
56
|
binary: string;
|
|
58
57
|
version?: string;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
function stem(path: string): string {
|
|
62
|
-
const ext = extname(path);
|
|
63
|
-
return join(dirname(path), ext ? basename(path).slice(0, -ext.length) : basename(path));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
60
|
function serialize(original: string, doc: unknown): string {
|
|
67
61
|
let serialized = new XMLSerializer().serializeToString(doc as never);
|
|
68
62
|
const declaration = /^<\?xml[^>]*\?>/.exec(original)?.[0];
|
|
@@ -73,39 +67,74 @@ function serialize(original: string, doc: unknown): string {
|
|
|
73
67
|
|
|
74
68
|
function resolveSpec(opts: AnimateOptions, model: DomEl): { spec: MotionSpec; changed: boolean } {
|
|
75
69
|
const errors: string[] = [];
|
|
76
|
-
let spec: MotionSpec | null;
|
|
77
70
|
const stored = readStoredMotion(model);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (stored === null || stored.trim() === "") {
|
|
82
|
-
throw new Error("the page has no stored motion; pass steps to define one");
|
|
83
|
-
}
|
|
84
|
-
let parsed: unknown;
|
|
71
|
+
let raw: unknown = { steps: opts.steps };
|
|
72
|
+
if (opts.steps === undefined) {
|
|
73
|
+
if (!stored?.trim()) throw new Error("the page has no stored motion; pass steps to define one");
|
|
85
74
|
try {
|
|
86
|
-
|
|
75
|
+
raw = JSON.parse(stored);
|
|
87
76
|
} catch (error) {
|
|
88
77
|
throw new Error(`stored motion contains malformed JSON: ${(error as Error).message}`, { cause: error });
|
|
89
78
|
}
|
|
90
|
-
spec = parseMotionSpec(parsed, errors);
|
|
91
|
-
if (spec && opts.loop !== undefined) spec.loop = opts.loop;
|
|
92
|
-
if (spec && opts.hold !== undefined) spec.hold = opts.hold;
|
|
93
79
|
}
|
|
80
|
+
const spec = parseMotionSpec(raw, errors, opts);
|
|
94
81
|
if (!spec || errors.length > 0) throw new Error(errors.join("; ") || "motion specification is invalid");
|
|
95
|
-
return { spec, changed: JSON.stringify(spec) !== stored };
|
|
82
|
+
if (opts.steps !== undefined) return { spec, changed: JSON.stringify(spec) !== stored };
|
|
83
|
+
if (opts.loop === undefined && opts.hold === undefined) return { spec, changed: false };
|
|
84
|
+
const previous = parseMotionSpec(raw, errors);
|
|
85
|
+
return { spec, changed: errors.length > 0 || previous?.loop !== spec.loop || previous?.hold !== spec.hold };
|
|
96
86
|
}
|
|
97
87
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
async function stageDiagram(input: string, xml: string, cleanup: string[]): Promise<string> {
|
|
89
|
+
// Stay beside the input so resolving any relative image references starts in the same directory.
|
|
90
|
+
const path = siblingPath(input, `.drawme-motion-${randomUUID()}.drawio`);
|
|
91
|
+
const handle = await open(path, "wx", 0o600);
|
|
92
|
+
cleanup.push(path);
|
|
93
|
+
try {
|
|
94
|
+
await handle.writeFile(xml, "utf8");
|
|
95
|
+
return path;
|
|
96
|
+
} finally {
|
|
97
|
+
await handle.close();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function saveMotion(input: string, xml: string): void {
|
|
102
|
+
// Do not rename a new inode over an editable source: hard-linked paths must see the edit.
|
|
103
|
+
const source = openSync(input, "r+");
|
|
104
|
+
try {
|
|
105
|
+
writeFileSync(source, xml, "utf8");
|
|
106
|
+
ftruncateSync(source, Buffer.byteLength(xml, "utf8"));
|
|
107
|
+
} finally {
|
|
108
|
+
closeSync(source);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function checkDistinctOutputs(svg: PreparedExport, board: PreparedExport, input: string): void {
|
|
113
|
+
const svgEntry = svg.publicationDestination;
|
|
114
|
+
const boardEntry = board.publicationDestination;
|
|
115
|
+
// Case sensitivity belongs to the target filesystem, not the OS. Refuse ambiguous
|
|
116
|
+
// spellings even for dangling links, without conflating distinct hard-link entries.
|
|
117
|
+
const entryKey = (entry: string) => entry.toLowerCase().toUpperCase().normalize();
|
|
118
|
+
if (entryKey(svgEntry) === entryKey(boardEntry)) {
|
|
119
|
+
throw new Error("animated SVG and storyboard resolve to the same output file or differ only by case; choose a different SVG output");
|
|
120
|
+
}
|
|
121
|
+
rejectSourceAlias(input, boardEntry);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function animateReserved(opts: AnimateOptions, output: string, storyboard: string | undefined): Promise<AnimateResult> {
|
|
125
|
+
const { input, signal, binary } = opts;
|
|
101
126
|
const pageIndex = opts.pageIndex ?? 1;
|
|
102
|
-
const xml = await
|
|
103
|
-
|
|
127
|
+
const xml = await readDiagramXml(input).catch((error: NodeJS.ErrnoException) => {
|
|
128
|
+
if (error.code === "ENOENT") throw new Error(`input file not found: ${input}`);
|
|
129
|
+
throw error;
|
|
130
|
+
});
|
|
131
|
+
const doc = new DOMParser({ onError(level) {
|
|
132
|
+
if (level !== "warning") throw new Error("invalid diagram XML");
|
|
133
|
+
} }).parseFromString(xml, "text/xml");
|
|
104
134
|
const root = doc.documentElement as unknown as DomEl | null;
|
|
105
135
|
if (!root) throw new Error("no root element (malformed XML)");
|
|
106
136
|
const { model, name } = selectPage(root, pageIndex);
|
|
107
|
-
|
|
108
|
-
// Analyze native animation on its own parse: cell collection rewrites wrapper ids in the DOM it reads.
|
|
137
|
+
// Native analysis uses its own parse, and cannot rewrite the DOM we will save.
|
|
109
138
|
const native = analyzeDrawioAnimation(xml, pageIndex);
|
|
110
139
|
if (native.errors.length > 0) throw new Error(native.errors.join("; "));
|
|
111
140
|
if (native.sequence?.enabled) {
|
|
@@ -113,65 +142,72 @@ export async function animateDiagram(opts: AnimateOptions): Promise<AnimateResul
|
|
|
113
142
|
"the page already has a native draw.io page animation; remove its animation attribute (or set enabled:false) so the motion steps are the only timeline",
|
|
114
143
|
);
|
|
115
144
|
}
|
|
116
|
-
|
|
117
145
|
const { spec, changed } = resolveSpec(opts, model);
|
|
118
146
|
const analysis = compileMotion(spec, motionCells(model), themeAccent(model));
|
|
119
147
|
if (!analysis.compiled) throw new Error(analysis.errors.join("; "));
|
|
120
148
|
const motion = analysis.compiled;
|
|
121
|
-
|
|
122
149
|
if (changed) {
|
|
150
|
+
accessSync(input, constants.W_OK);
|
|
123
151
|
storeMotion(model, JSON.stringify(spec));
|
|
124
|
-
await writeFile(opts.input, serialize(xml, doc), "utf8");
|
|
125
152
|
}
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
const
|
|
153
|
+
if (storyboard !== undefined) rejectSourceAlias(input, storyboard);
|
|
154
|
+
const updated = changed ? serialize(xml, doc) : undefined;
|
|
155
|
+
const temporary: string[] = [];
|
|
156
|
+
const prepared: PreparedExport[] = [];
|
|
129
157
|
try {
|
|
130
|
-
|
|
131
|
-
await
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
travellingDots: motion.dots.length,
|
|
149
|
-
connectorFlows: native.flowEdgeIds.length,
|
|
150
|
-
binary: exported.binary,
|
|
151
|
-
version: exported.version,
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
if (opts.storyboard ?? true) {
|
|
155
|
-
const frames = sampleFrames(motion.frames);
|
|
156
|
-
const tempDir = await mkdtemp(join(tmpdir(), "drawme-storyboard-"));
|
|
157
|
-
try {
|
|
158
|
-
const boardSource = join(tempDir, "storyboard.drawio");
|
|
159
|
-
await writeFile(boardSource, buildStoryboard(model, frames), "utf8");
|
|
160
|
-
const board = await exportDiagram({
|
|
161
|
-
input: boardSource,
|
|
162
|
-
format: "png",
|
|
163
|
-
mode: "final",
|
|
164
|
-
embed: false,
|
|
165
|
-
width: 2000,
|
|
166
|
-
output: `${stem(opts.input)}.storyboard.png`,
|
|
167
|
-
binary: opts.binary,
|
|
168
|
-
});
|
|
169
|
-
result.storyboard = board.output;
|
|
170
|
-
result.storyboardFrames = frames.length;
|
|
171
|
-
result.storyboardFramesTotal = motion.frames.length;
|
|
172
|
-
} finally {
|
|
173
|
-
await rm(tempDir, { recursive: true, force: true });
|
|
158
|
+
signal?.throwIfAborted();
|
|
159
|
+
const renderInput = updated === undefined ? input : await stageDiagram(input, updated, temporary);
|
|
160
|
+
const svg = await prepareExport(
|
|
161
|
+
{ input, format: "svg", output, pageIndex: opts.pageIndex, binary, signal }, renderInput,
|
|
162
|
+
async (stage) => writeFile(stage, injectMotion(await readFile(stage, "utf8"), motion, native.flowEdgeIds), "utf8"),
|
|
163
|
+
);
|
|
164
|
+
prepared.push(svg);
|
|
165
|
+
const frames = storyboard === undefined ? [] : sampleFrames(motion.frames);
|
|
166
|
+
let board: PreparedExport | undefined;
|
|
167
|
+
if (storyboard !== undefined) {
|
|
168
|
+
const boardSource = await stageDiagram(input, buildStoryboard(model, frames), temporary);
|
|
169
|
+
// Its source is the generated board, not the original diagram's preview owner.
|
|
170
|
+
board = await prepareExport({ input: boardSource, format: "png", mode: "final", embed: false, output: storyboard, binary, signal }, boardSource);
|
|
171
|
+
prepared.push(board);
|
|
172
|
+
checkDistinctOutputs(svg, board, input);
|
|
173
|
+
} else {
|
|
174
|
+
// Recheck the SVG publication target before touching the source file.
|
|
175
|
+
void svg.publicationDestination;
|
|
174
176
|
}
|
|
177
|
+
|
|
178
|
+
// No yield between the abort gate and publication. This is not a crash-atomic filesystem commit.
|
|
179
|
+
signal?.throwIfAborted();
|
|
180
|
+
if (updated !== undefined) saveMotion(input, updated);
|
|
181
|
+
const boardExport = board?.commit(); // Install before retiring any preview at the same path.
|
|
182
|
+
const exported = svg.commit();
|
|
183
|
+
return {
|
|
184
|
+
source: input, saved: changed, page: name, output: exported.output, steps: spec.steps.length, loop: motion.loop,
|
|
185
|
+
sequenceMs: Math.round(motion.sequenceMs), durationMs: Math.round(motion.durationMs),
|
|
186
|
+
animatedCells: motion.targetCellIds.length, drawnConnectors: motion.drawInEdgeIds.length,
|
|
187
|
+
travellingDots: motion.dots.length, connectorFlows: native.flowEdgeIds.length,
|
|
188
|
+
...(boardExport && {
|
|
189
|
+
storyboard: boardExport.output, storyboardSha256: boardExport.artifactSha256,
|
|
190
|
+
storyboardFrames: frames.length, storyboardFramesTotal: motion.frames.length,
|
|
191
|
+
}),
|
|
192
|
+
binary: exported.binary, version: exported.version,
|
|
193
|
+
};
|
|
194
|
+
} finally {
|
|
195
|
+
await Promise.all([...prepared.map((artifact) => artifact.dispose()), ...temporary.map((path) => rm(path, { force: true }))]);
|
|
175
196
|
}
|
|
176
|
-
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Validate and verify all requested artifacts before saving the selected page. */
|
|
200
|
+
export async function animateDiagram(opts: AnimateOptions): Promise<AnimateResult> {
|
|
201
|
+
const stem = basename(opts.input, extname(opts.input));
|
|
202
|
+
const defaultOutput = siblingPath(opts.input, `${stem}.animated.svg`);
|
|
203
|
+
const output = opts.output ?? defaultOutput;
|
|
204
|
+
const pageIndex = opts.pageIndex ?? 1;
|
|
205
|
+
const storyboard = (opts.storyboard ?? true)
|
|
206
|
+
? pageIndex === 1 && output === defaultOutput
|
|
207
|
+
? siblingPath(opts.input, `${stem}.storyboard.png`)
|
|
208
|
+
: `${output}.page-${pageIndex}.frames.png`
|
|
209
|
+
: undefined;
|
|
210
|
+
const paths = [opts.input, output];
|
|
211
|
+
if (storyboard !== undefined) paths.push(storyboard);
|
|
212
|
+
return withDiagramFiles(paths, opts.signal, () => animateReserved(opts, output, storyboard));
|
|
177
213
|
}
|