@pixerate/editor 0.144.0 → 0.146.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.
Files changed (48) hide show
  1. package/README.md +1 -1
  2. package/dist/animation/index.cjs +2 -2
  3. package/dist/animation/index.js +1 -1
  4. package/dist/animation/player.d.cts +5 -0
  5. package/dist/animation/player.d.ts +5 -0
  6. package/dist/animation-editor/controller.d.cts +101 -1
  7. package/dist/animation-editor/controller.d.ts +101 -1
  8. package/dist/animation-editor/index.cjs +594 -147
  9. package/dist/animation-editor/index.d.cts +1 -0
  10. package/dist/animation-editor/index.d.ts +1 -0
  11. package/dist/animation-editor/index.js +525 -78
  12. package/dist/animation-editor/record.d.cts +114 -0
  13. package/dist/animation-editor/record.d.ts +114 -0
  14. package/dist/animation-editor/tools.d.cts +1 -0
  15. package/dist/animation-editor/tools.d.ts +1 -0
  16. package/dist/animation-editor/types.d.cts +6 -0
  17. package/dist/animation-editor/types.d.ts +6 -0
  18. package/dist/canvas/index.cjs +24 -24
  19. package/dist/canvas/index.js +1 -1
  20. package/dist/chunk-HRLT5BYO.js +133 -0
  21. package/dist/chunk-KC7HB5GF.cjs +133 -0
  22. package/dist/{chunk-I4T4J27S.js → chunk-QX25HWFL.js} +9 -0
  23. package/dist/{chunk-SVR5FR7B.cjs → chunk-UUTTJK77.cjs} +9 -0
  24. package/dist/diagram/editorDocument.d.cts +12 -0
  25. package/dist/diagram/editorDocument.d.ts +12 -0
  26. package/dist/diagram/index.cjs +35 -1
  27. package/dist/diagram/index.d.cts +1 -0
  28. package/dist/diagram/index.d.ts +1 -0
  29. package/dist/diagram/index.js +34 -0
  30. package/dist/persistence/documentStore.d.cts +51 -0
  31. package/dist/persistence/documentStore.d.ts +51 -0
  32. package/dist/persistence/documentTools.d.cts +35 -0
  33. package/dist/persistence/documentTools.d.ts +35 -0
  34. package/dist/persistence/editorAutosave.d.cts +33 -0
  35. package/dist/persistence/editorAutosave.d.ts +33 -0
  36. package/dist/persistence/editorDocument.d.cts +118 -0
  37. package/dist/persistence/editorDocument.d.ts +118 -0
  38. package/dist/persistence/index.cjs +294 -1
  39. package/dist/persistence/index.d.cts +4 -0
  40. package/dist/persistence/index.d.ts +4 -0
  41. package/dist/persistence/index.js +293 -0
  42. package/dist/video-editor/index.cjs +2 -2
  43. package/dist/video-editor/index.js +1 -1
  44. package/package.json +1 -1
  45. package/skills/pixerate-agent-tools/SKILL.md +21 -0
  46. package/skills/pixerate-animation-editor/SKILL.md +10 -0
  47. package/skills/pixerate-animation-editor/references/commands.md +3 -1
  48. package/skills/pixerate-diagram/SKILL.md +13 -0
@@ -0,0 +1,133 @@
1
+ import {
2
+ createLoadReport,
3
+ migrateDocument
4
+ } from "./chunk-WHKNYFM2.js";
5
+ import {
6
+ stripPrototypeKeys
7
+ } from "./chunk-HF5QZS7Z.js";
8
+
9
+ // src/persistence/editorDocument.ts
10
+ var EditorDocumentLoadError = class extends Error {
11
+ /** The `LoadReport` when the input was a file that could not be migrated. */
12
+ report;
13
+ constructor(message, report) {
14
+ super(message);
15
+ this.name = "EditorDocumentLoadError";
16
+ this.report = report;
17
+ }
18
+ };
19
+ var EDITOR_DOCUMENT_FORMAT = "pixerate.editor-document";
20
+ var KIND = /^[a-z][a-z0-9_]*$/;
21
+ function isEditorDocumentFile(value) {
22
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
23
+ const v = value;
24
+ return v.format === EDITOR_DOCUMENT_FORMAT && typeof v.kind === "string" && typeof v.formatVersion === "number" && "document" in v;
25
+ }
26
+ function toEditorDocumentFile(doc, name) {
27
+ return {
28
+ format: EDITOR_DOCUMENT_FORMAT,
29
+ kind: doc.kind,
30
+ formatVersion: doc.formatVersion,
31
+ ...name ? { name } : {},
32
+ document: doc.getDocument()
33
+ };
34
+ }
35
+ function serializeEditorDocument(doc, options = {}) {
36
+ return JSON.stringify(toEditorDocumentFile(doc, options.name), null, options.space);
37
+ }
38
+ function parseEditorDocument(text, options = {}) {
39
+ let value;
40
+ try {
41
+ value = stripPrototypeKeys(JSON.parse(text));
42
+ } catch (error) {
43
+ throw new EditorDocumentLoadError(`The file is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
44
+ }
45
+ if (!isEditorDocumentFile(value)) {
46
+ throw new EditorDocumentLoadError(`The file is not a saved editor document (expected "format": "${EDITOR_DOCUMENT_FORMAT}").`);
47
+ }
48
+ if (options.kind && value.kind !== options.kind) {
49
+ throw new EditorDocumentLoadError(`The file is a ${value.kind} document, not a ${options.kind} document.`);
50
+ }
51
+ return value;
52
+ }
53
+ function defineEditorDocument(spec) {
54
+ if (!KIND.test(spec.kind)) throw new Error(`Editor document kind "${spec.kind}" must match ${KIND}.`);
55
+ const formatVersion = spec.formatVersion ?? 1;
56
+ const listeners = /* @__PURE__ */ new Set();
57
+ let revision = 0;
58
+ let unsubscribe = null;
59
+ let connected = false;
60
+ const connect = () => {
61
+ if (unsubscribe) return;
62
+ if (connected) revision++;
63
+ connected = true;
64
+ unsubscribe = spec.subscribe(() => {
65
+ revision++;
66
+ listeners.forEach((listener) => {
67
+ try {
68
+ listener();
69
+ } catch (error) {
70
+ console.error(`[${spec.kind} document] Error in change listener:`, error);
71
+ }
72
+ });
73
+ });
74
+ };
75
+ connect();
76
+ const unwrap = (input) => {
77
+ if (!isEditorDocumentFile(input)) return { document: input, report: createLoadReport({ version: formatVersion }) };
78
+ if (input.kind !== spec.kind) throw new EditorDocumentLoadError(`This is a ${input.kind} document; it cannot be opened in the ${spec.kind} editor.`);
79
+ const steps = Object.fromEntries(
80
+ Object.entries(spec.migrations ?? {}).map(([v, step]) => [v, (w) => ({ ...w, document: step(w.document) })])
81
+ );
82
+ const { doc, report } = migrateDocument(
83
+ { formatVersion: input.formatVersion, document: input.document },
84
+ { currentVersion: formatVersion, versionKey: "formatVersion", steps }
85
+ );
86
+ if (report.readOnly) throw new EditorDocumentLoadError(`Cannot open the ${spec.kind} document: ${report.readOnly.message}.`, report);
87
+ return { document: doc.document, report };
88
+ };
89
+ return {
90
+ kind: spec.kind,
91
+ formatVersion,
92
+ recordsLoads: spec.recordsLoads !== false,
93
+ getDocument: () => spec.get(),
94
+ loadDocument(input, options = {}) {
95
+ const { document, report } = unwrap(input);
96
+ if (document === void 0 || document === null) throw new EditorDocumentLoadError(`No ${spec.kind} document was given.`);
97
+ try {
98
+ spec.load(document, { history: options.history ?? "reset" });
99
+ } catch (error) {
100
+ if (error instanceof EditorDocumentLoadError) throw error;
101
+ throw new EditorDocumentLoadError(error instanceof Error ? error.message : String(error));
102
+ }
103
+ return report;
104
+ },
105
+ revision: () => {
106
+ connect();
107
+ return revision;
108
+ },
109
+ subscribe(listener) {
110
+ connect();
111
+ listeners.add(listener);
112
+ return () => {
113
+ listeners.delete(listener);
114
+ };
115
+ },
116
+ history: spec.history,
117
+ readOnly: () => spec.readOnly?.() ?? false,
118
+ destroy() {
119
+ unsubscribe?.();
120
+ unsubscribe = null;
121
+ }
122
+ };
123
+ }
124
+
125
+ export {
126
+ EditorDocumentLoadError,
127
+ EDITOR_DOCUMENT_FORMAT,
128
+ isEditorDocumentFile,
129
+ toEditorDocumentFile,
130
+ serializeEditorDocument,
131
+ parseEditorDocument,
132
+ defineEditorDocument
133
+ };
@@ -0,0 +1,133 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+ var _chunkL5OWG2NAcjs = require('./chunk-L5OWG2NA.cjs');
5
+
6
+
7
+ var _chunk2BSBFBOAcjs = require('./chunk-2BSBFBOA.cjs');
8
+
9
+ // src/persistence/editorDocument.ts
10
+ var EditorDocumentLoadError = class extends Error {
11
+ /** The `LoadReport` when the input was a file that could not be migrated. */
12
+
13
+ constructor(message, report) {
14
+ super(message);
15
+ this.name = "EditorDocumentLoadError";
16
+ this.report = report;
17
+ }
18
+ };
19
+ var EDITOR_DOCUMENT_FORMAT = "pixerate.editor-document";
20
+ var KIND = /^[a-z][a-z0-9_]*$/;
21
+ function isEditorDocumentFile(value) {
22
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
23
+ const v = value;
24
+ return v.format === EDITOR_DOCUMENT_FORMAT && typeof v.kind === "string" && typeof v.formatVersion === "number" && "document" in v;
25
+ }
26
+ function toEditorDocumentFile(doc, name) {
27
+ return {
28
+ format: EDITOR_DOCUMENT_FORMAT,
29
+ kind: doc.kind,
30
+ formatVersion: doc.formatVersion,
31
+ ...name ? { name } : {},
32
+ document: doc.getDocument()
33
+ };
34
+ }
35
+ function serializeEditorDocument(doc, options = {}) {
36
+ return JSON.stringify(toEditorDocumentFile(doc, options.name), null, options.space);
37
+ }
38
+ function parseEditorDocument(text, options = {}) {
39
+ let value;
40
+ try {
41
+ value = _chunk2BSBFBOAcjs.stripPrototypeKeys.call(void 0, JSON.parse(text));
42
+ } catch (error) {
43
+ throw new EditorDocumentLoadError(`The file is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
44
+ }
45
+ if (!isEditorDocumentFile(value)) {
46
+ throw new EditorDocumentLoadError(`The file is not a saved editor document (expected "format": "${EDITOR_DOCUMENT_FORMAT}").`);
47
+ }
48
+ if (options.kind && value.kind !== options.kind) {
49
+ throw new EditorDocumentLoadError(`The file is a ${value.kind} document, not a ${options.kind} document.`);
50
+ }
51
+ return value;
52
+ }
53
+ function defineEditorDocument(spec) {
54
+ if (!KIND.test(spec.kind)) throw new Error(`Editor document kind "${spec.kind}" must match ${KIND}.`);
55
+ const formatVersion = _nullishCoalesce(spec.formatVersion, () => ( 1));
56
+ const listeners = /* @__PURE__ */ new Set();
57
+ let revision = 0;
58
+ let unsubscribe = null;
59
+ let connected = false;
60
+ const connect = () => {
61
+ if (unsubscribe) return;
62
+ if (connected) revision++;
63
+ connected = true;
64
+ unsubscribe = spec.subscribe(() => {
65
+ revision++;
66
+ listeners.forEach((listener) => {
67
+ try {
68
+ listener();
69
+ } catch (error) {
70
+ console.error(`[${spec.kind} document] Error in change listener:`, error);
71
+ }
72
+ });
73
+ });
74
+ };
75
+ connect();
76
+ const unwrap = (input) => {
77
+ if (!isEditorDocumentFile(input)) return { document: input, report: _chunkL5OWG2NAcjs.createLoadReport.call(void 0, { version: formatVersion }) };
78
+ if (input.kind !== spec.kind) throw new EditorDocumentLoadError(`This is a ${input.kind} document; it cannot be opened in the ${spec.kind} editor.`);
79
+ const steps = Object.fromEntries(
80
+ Object.entries(_nullishCoalesce(spec.migrations, () => ( {}))).map(([v, step]) => [v, (w) => ({ ...w, document: step(w.document) })])
81
+ );
82
+ const { doc, report } = _chunkL5OWG2NAcjs.migrateDocument.call(void 0,
83
+ { formatVersion: input.formatVersion, document: input.document },
84
+ { currentVersion: formatVersion, versionKey: "formatVersion", steps }
85
+ );
86
+ if (report.readOnly) throw new EditorDocumentLoadError(`Cannot open the ${spec.kind} document: ${report.readOnly.message}.`, report);
87
+ return { document: doc.document, report };
88
+ };
89
+ return {
90
+ kind: spec.kind,
91
+ formatVersion,
92
+ recordsLoads: spec.recordsLoads !== false,
93
+ getDocument: () => spec.get(),
94
+ loadDocument(input, options = {}) {
95
+ const { document, report } = unwrap(input);
96
+ if (document === void 0 || document === null) throw new EditorDocumentLoadError(`No ${spec.kind} document was given.`);
97
+ try {
98
+ spec.load(document, { history: _nullishCoalesce(options.history, () => ( "reset")) });
99
+ } catch (error) {
100
+ if (error instanceof EditorDocumentLoadError) throw error;
101
+ throw new EditorDocumentLoadError(error instanceof Error ? error.message : String(error));
102
+ }
103
+ return report;
104
+ },
105
+ revision: () => {
106
+ connect();
107
+ return revision;
108
+ },
109
+ subscribe(listener) {
110
+ connect();
111
+ listeners.add(listener);
112
+ return () => {
113
+ listeners.delete(listener);
114
+ };
115
+ },
116
+ history: spec.history,
117
+ readOnly: () => _nullishCoalesce(_optionalChain([spec, 'access', _ => _.readOnly, 'optionalCall', _2 => _2()]), () => ( false)),
118
+ destroy() {
119
+ _optionalChain([unsubscribe, 'optionalCall', _3 => _3()]);
120
+ unsubscribe = null;
121
+ }
122
+ };
123
+ }
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+ exports.EditorDocumentLoadError = EditorDocumentLoadError; exports.EDITOR_DOCUMENT_FORMAT = EDITOR_DOCUMENT_FORMAT; exports.isEditorDocumentFile = isEditorDocumentFile; exports.toEditorDocumentFile = toEditorDocumentFile; exports.serializeEditorDocument = serializeEditorDocument; exports.parseEditorDocument = parseEditorDocument; exports.defineEditorDocument = defineEditorDocument;
@@ -201,6 +201,15 @@ var AnimationPlayer = class {
201
201
  get currentTime() {
202
202
  return this.time;
203
203
  }
204
+ /**
205
+ * The playhead at this moment of the clock, between frames too (`currentTime` is the last
206
+ * frame's): what input arriving between frames, like a recorded pointer move, happened at.
207
+ */
208
+ get liveTime() {
209
+ if (!this.playing) return this.time;
210
+ const d = this.duration;
211
+ return this.loop === "none" || d <= 0 ? this.clamp(this.rawNow()) : wrapAnimationTime(this.rawNow(), d, this.loop);
212
+ }
204
213
  get isPlaying() {
205
214
  return this.playing;
206
215
  }
@@ -201,6 +201,15 @@ var AnimationPlayer = (_class2 = class {
201
201
  get currentTime() {
202
202
  return this.time;
203
203
  }
204
+ /**
205
+ * The playhead at this moment of the clock, between frames too (`currentTime` is the last
206
+ * frame's): what input arriving between frames, like a recorded pointer move, happened at.
207
+ */
208
+ get liveTime() {
209
+ if (!this.playing) return this.time;
210
+ const d = this.duration;
211
+ return this.loop === "none" || d <= 0 ? this.clamp(this.rawNow()) : wrapAnimationTime(this.rawNow(), d, this.loop);
212
+ }
204
213
  get isPlaying() {
205
214
  return this.playing;
206
215
  }
@@ -0,0 +1,12 @@
1
+ import { type EditorDocument } from '../persistence/editorDocument.cjs';
2
+ import type { DiagramController } from './controller.cjs';
3
+ /** A diagram as it is saved: its Mermaid source (layout rides in the `%% @pixerate` comment). */
4
+ export interface DiagramEditorDocument {
5
+ source: string;
6
+ }
7
+ /**
8
+ * The save / load / undo contract for a `DiagramController` (kind `diagram`), for
9
+ * `createEditorAutosave`, `createDocumentToolProvider` and the React / Svelte wrappers.
10
+ * Recorded loads are one undo step; read-only controllers refuse them.
11
+ */
12
+ export declare function createDiagramEditorDocument(controller: DiagramController): EditorDocument<DiagramEditorDocument>;
@@ -0,0 +1,12 @@
1
+ import { type EditorDocument } from '../persistence/editorDocument.js';
2
+ import type { DiagramController } from './controller.js';
3
+ /** A diagram as it is saved: its Mermaid source (layout rides in the `%% @pixerate` comment). */
4
+ export interface DiagramEditorDocument {
5
+ source: string;
6
+ }
7
+ /**
8
+ * The save / load / undo contract for a `DiagramController` (kind `diagram`), for
9
+ * `createEditorAutosave`, `createDocumentToolProvider` and the React / Svelte wrappers.
10
+ * Recorded loads are one undo step; read-only controllers refuse them.
11
+ */
12
+ export declare function createDiagramEditorDocument(controller: DiagramController): EditorDocument<DiagramEditorDocument>;
@@ -1,5 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
+ var _chunkKC7HB5GFcjs = require('../chunk-KC7HB5GF.cjs');
4
+
5
+
3
6
 
4
7
 
5
8
 
@@ -116,6 +119,8 @@
116
119
 
117
120
 
118
121
  var _chunkZVNAMTFOcjs = require('../chunk-ZVNAMTFO.cjs');
122
+ require('../chunk-L5OWG2NA.cjs');
123
+ require('../chunk-2BSBFBOA.cjs');
119
124
 
120
125
 
121
126
 
@@ -131,6 +136,34 @@ var _chunkFJ2MSI43cjs = require('../chunk-FJ2MSI43.cjs');
131
136
  // src/diagram/types.ts
132
137
  var DIRECTIONS = ["TB", "TD", "BT", "LR", "RL"];
133
138
 
139
+ // src/diagram/editorDocument.ts
140
+ function createDiagramEditorDocument(controller) {
141
+ return _chunkKC7HB5GFcjs.defineEditorDocument.call(void 0, {
142
+ kind: "diagram",
143
+ get: () => ({ source: controller.getSource() }),
144
+ load: (document, { history }) => {
145
+ const source = document.source;
146
+ if (typeof source !== "string") throw new Error("A diagram document is { source: string } (Mermaid text).");
147
+ const result = controller.load(source, { clearHistory: history === "reset" });
148
+ if (!result.ok) throw new Error(result.message);
149
+ },
150
+ subscribe: (listener) => {
151
+ let source = controller.getSource();
152
+ return controller.subscribe((state) => {
153
+ if (state.source === source) return;
154
+ source = state.source;
155
+ listener();
156
+ });
157
+ },
158
+ history: {
159
+ undo: () => controller.undo(),
160
+ redo: () => controller.redo(),
161
+ getState: () => controller.history.getState()
162
+ },
163
+ readOnly: () => controller.getState().readOnly ? "The diagram is read-only." : false
164
+ });
165
+ }
166
+
134
167
  // src/diagram/source/find.ts
135
168
  var MERMAID_INFO = /^(mermaid|mmd)\b/i;
136
169
  function findMermaidSources(text) {
@@ -2576,4 +2609,5 @@ function planDiagramEdits(source, place, ops, speed = 1) {
2576
2609
 
2577
2610
 
2578
2611
 
2579
- exports.ARCH_METRICS = _chunkZVNAMTFOcjs.ARCH_METRICS; exports.C4_METRICS = _chunkZVNAMTFOcjs.C4_METRICS; exports.CLASS_RELATIONS = _chunkZVNAMTFOcjs.CLASS_RELATIONS; exports.DIRECTIONS = DIRECTIONS; exports.DiagramController = DiagramController; exports.DiagramDirector = DiagramDirector; exports.EDITABLE_DIAGRAM_FAMILIES = EDITABLE_DIAGRAM_FAMILIES; exports.ER_CARDINALITIES = _chunkZVNAMTFOcjs.ER_CARDINALITIES; exports.ER_PATTERNS = _chunkZVNAMTFOcjs.ER_PATTERNS; exports.FAMILY_BLANKS = FAMILY_BLANKS; exports.FAMILY_DESCRIPTIONS = FAMILY_DESCRIPTIONS; exports.FAMILY_TEMPLATES = FAMILY_TEMPLATES; exports.FAMILY_TITLES = FAMILY_TITLES; exports.FLOWCHART_SHAPES = _chunkZVNAMTFOcjs.FLOWCHART_SHAPES; exports.GANTT_CONFIG_KEYS = _chunkZVNAMTFOcjs.GANTT_CONFIG_KEYS; exports.GANTT_METRICS = _chunkZVNAMTFOcjs.GANTT_METRICS; exports.GANTT_TAGS = _chunkZVNAMTFOcjs.GANTT_TAGS; exports.META_COMMENT_PREFIX = _chunkZVNAMTFOcjs.META_COMMENT_PREFIX; exports.META_FRONTMATTER_KEY = _chunkZVNAMTFOcjs.META_FRONTMATTER_KEY; exports.POINT_BOX = _chunkZVNAMTFOcjs.POINT_BOX; exports.PRESENCE_COLORS = _chunkUJGAA6AKcjs.PRESENCE_COLORS; exports.PerformanceQueue = _chunkUJGAA6AKcjs.PerformanceQueue; exports.PresenceStore = _chunkUJGAA6AKcjs.PresenceStore; exports.QUADRANT_METRICS = _chunkZVNAMTFOcjs.QUADRANT_METRICS; exports.RADAR_CHART_BOX = _chunkZVNAMTFOcjs.RADAR_CHART_BOX; exports.SEQUENCE_METRICS = _chunkZVNAMTFOcjs.SEQUENCE_METRICS; exports.STATE_SHAPES = _chunkZVNAMTFOcjs.STATE_SHAPES; exports.XY_CHART_BOX = _chunkZVNAMTFOcjs.XY_CHART_BOX; exports.afterIds = _chunkZVNAMTFOcjs.afterIds; exports.applyEdit = _chunkZVNAMTFOcjs.applyEdit; exports.applyEdits = _chunkZVNAMTFOcjs.applyEdits; exports.applyStatementEdit = _chunkZVNAMTFOcjs.applyStatementEdit; exports.architectureAdapter = _chunkZVNAMTFOcjs.architectureAdapter; exports.architectureArrow = _chunkZVNAMTFOcjs.architectureArrow; exports.architectureEdgeRoute = _chunkZVNAMTFOcjs.architectureEdgeRoute; exports.architectureGrammar = _chunkZVNAMTFOcjs.architectureGrammar; exports.architectureLayout = _chunkZVNAMTFOcjs.architectureLayout; exports.architectureUI = architectureUI; exports.c4Adapter = _chunkZVNAMTFOcjs.c4Adapter; exports.c4ArrowHead = _chunkZVNAMTFOcjs.c4ArrowHead; exports.c4BoundaryText = _chunkZVNAMTFOcjs.c4BoundaryText; exports.c4ElementGeometry = _chunkZVNAMTFOcjs.c4ElementGeometry; exports.c4ElementType = _chunkZVNAMTFOcjs.c4ElementType; exports.c4Grammar = _chunkZVNAMTFOcjs.c4Grammar; exports.c4Layout = _chunkZVNAMTFOcjs.c4Layout; exports.c4RelGeometry = _chunkZVNAMTFOcjs.c4RelGeometry; exports.c4Stereotype = _chunkZVNAMTFOcjs.c4Stereotype; exports.c4UI = c4UI; exports.canonicalShape = _chunkZVNAMTFOcjs.canonicalShape; exports.changedItems = changedItems; exports.checkFieldData = checkFieldData; exports.classGrammar = _chunkZVNAMTFOcjs.classGrammar; exports.classUI = classUI; exports.createDiagramToolProvider = createDiagramToolProvider; exports.createInstantPresenceClock = _chunkUJGAA6AKcjs.createInstantPresenceClock; exports.createLineAdapter = _chunkZVNAMTFOcjs.createLineAdapter; exports.createPassthroughAdapter = _chunkZVNAMTFOcjs.createPassthroughAdapter; exports.createStatementAdapter = _chunkZVNAMTFOcjs.createStatementAdapter; exports.describeDiagram = describeDiagram; exports.describeFields = describeFields; exports.detectFamily = _chunkZVNAMTFOcjs.detectFamily; exports.detectFamilyFromHeader = _chunkZVNAMTFOcjs.detectFamilyFromHeader; exports.diagramShapes = diagramShapes; exports.diagramSupportsDirection = diagramSupportsDirection; exports.diagramSupportsGroups = diagramSupportsGroups; exports.draftFrames = draftFrames; exports.dropMetaKeys = _chunkZVNAMTFOcjs.dropMetaKeys; exports.emptyMeta = _chunkZVNAMTFOcjs.emptyMeta; exports.erGrammar = _chunkZVNAMTFOcjs.erGrammar; exports.erUI = erUI; exports.familyUI = familyUI; exports.filterInPlace = _chunkZVNAMTFOcjs.filterInPlace; exports.findMermaidSources = findMermaidSources; exports.flowchartAdapter = _chunkZVNAMTFOcjs.flowchartAdapter; exports.flowchartUI = flowchartUI; exports.formatAxis = _chunkZVNAMTFOcjs.formatAxis; exports.formatChain = _chunkZVNAMTFOcjs.formatChain; exports.formatGanttDate = _chunkZVNAMTFOcjs.formatGanttDate; exports.formatLink = _chunkZVNAMTFOcjs.formatLink; exports.formatNode = _chunkZVNAMTFOcjs.formatNode; exports.ganttAdapter = _chunkZVNAMTFOcjs.ganttAdapter; exports.ganttGeometry = _chunkZVNAMTFOcjs.ganttGeometry; exports.ganttGrammar = _chunkZVNAMTFOcjs.ganttGrammar; exports.ganttUI = ganttUI; exports.getDiagramAdapter = _chunkZVNAMTFOcjs.getDiagramAdapter; exports.getFamilyLayout = _chunkZVNAMTFOcjs.getFamilyLayout; exports.gitGraphAdapter = _chunkZVNAMTFOcjs.gitGraphAdapter; exports.gitGraphGrammar = _chunkZVNAMTFOcjs.gitGraphGrammar; exports.gitGraphUI = gitGraphUI; exports.indentOf = _chunkZVNAMTFOcjs.indentOf; exports.isMetaEmpty = _chunkZVNAMTFOcjs.isMetaEmpty; exports.journeyAdapter = _chunkZVNAMTFOcjs.journeyAdapter; exports.journeyGrammar = _chunkZVNAMTFOcjs.journeyGrammar; exports.journeyLayout = _chunkZVNAMTFOcjs.journeyLayout; exports.journeyUI = journeyUI; exports.mergeMeta = _chunkZVNAMTFOcjs.mergeMeta; exports.mindmapAdapter = _chunkZVNAMTFOcjs.mindmapAdapter; exports.mindmapGrammar = _chunkZVNAMTFOcjs.mindmapGrammar; exports.mindmapUI = mindmapUI; exports.parseAttributes = _chunkZVNAMTFOcjs.parseAttributes; exports.parseChain = _chunkZVNAMTFOcjs.parseChain; exports.parseFlowchartSource = _chunkZVNAMTFOcjs.parseFlowchartSource; exports.parseGanttDate = _chunkZVNAMTFOcjs.parseGanttDate; exports.parseLink = _chunkZVNAMTFOcjs.parseLink; exports.parseMembers = _chunkZVNAMTFOcjs.parseMembers; exports.parseMermaid = _chunkZVNAMTFOcjs.parseMermaid; exports.parseSankey = parseSankey; exports.parseStatement = _chunkZVNAMTFOcjs.parseStatement; exports.parseStatementDocument = _chunkZVNAMTFOcjs.parseStatementDocument; exports.parseTreemap = parseTreemap; exports.pickFieldData = pickFieldData; exports.pieAdapter = _chunkZVNAMTFOcjs.pieAdapter; exports.pieGrammar = _chunkZVNAMTFOcjs.pieGrammar; exports.pieUI = pieUI; exports.planDiagramEdit = planDiagramEdit; exports.planDiagramEdits = planDiagramEdits; exports.pointCentre = _chunkZVNAMTFOcjs.pointCentre; exports.pointPosition = _chunkZVNAMTFOcjs.pointPosition; exports.positionToData = _chunkZVNAMTFOcjs.positionToData; exports.quadrantAdapter = _chunkZVNAMTFOcjs.quadrantAdapter; exports.quadrantGeometry = _chunkZVNAMTFOcjs.quadrantGeometry; exports.quadrantGrammar = _chunkZVNAMTFOcjs.quadrantGrammar; exports.quadrantSpace = _chunkZVNAMTFOcjs.quadrantSpace; exports.quadrantUI = quadrantUI; exports.quote = _chunkZVNAMTFOcjs.quote; exports.quoteLabelIfNeeded = _chunkZVNAMTFOcjs.quoteLabelIfNeeded; exports.radarAdapter = _chunkZVNAMTFOcjs.radarAdapter; exports.radarGrammar = _chunkZVNAMTFOcjs.radarGrammar; exports.radarUI = radarUI; exports.realPresenceClock = _chunkUJGAA6AKcjs.realPresenceClock; exports.registerDiagramAdapter = _chunkZVNAMTFOcjs.registerDiagramAdapter; exports.registerFamilyLayout = _chunkZVNAMTFOcjs.registerFamilyLayout; exports.relationFor = _chunkZVNAMTFOcjs.relationFor; exports.renameMetaKey = _chunkZVNAMTFOcjs.renameMetaKey; exports.resolveShape = _chunkZVNAMTFOcjs.resolveShape; exports.sequenceAdapter = _chunkZVNAMTFOcjs.sequenceAdapter; exports.sequenceGeometry = _chunkZVNAMTFOcjs.sequenceGeometry; exports.sequenceGrammar = _chunkZVNAMTFOcjs.sequenceGrammar; exports.sequenceUI = sequenceUI; exports.serializeMermaid = _chunkZVNAMTFOcjs.serializeMermaid; exports.serializeMeta = _chunkZVNAMTFOcjs.serializeMeta; exports.serializeStatementDocument = _chunkZVNAMTFOcjs.serializeStatementDocument; exports.serviceLabelLines = _chunkZVNAMTFOcjs.serviceLabelLines; exports.sharedFrameLayout = _chunkZVNAMTFOcjs.sharedFrameLayout; exports.slugId = _chunkZVNAMTFOcjs.slugId; exports.spaceInput = _chunkZVNAMTFOcjs.spaceInput; exports.splitOutsideQuotes = _chunkZVNAMTFOcjs.splitOutsideQuotes; exports.splitSource = _chunkZVNAMTFOcjs.splitSource; exports.splitStatements = _chunkZVNAMTFOcjs.splitStatements; exports.stateGrammar = _chunkZVNAMTFOcjs.stateGrammar; exports.stateUI = stateUI; exports.supportTierOf = _chunkZVNAMTFOcjs.supportTierOf; exports.timelineAdapter = _chunkZVNAMTFOcjs.timelineAdapter; exports.timelineGrammar = _chunkZVNAMTFOcjs.timelineGrammar; exports.timelineLayout = _chunkZVNAMTFOcjs.timelineLayout; exports.timelineUI = timelineUI; exports.treemapValue = treemapValue; exports.uniqueId = _chunkZVNAMTFOcjs.uniqueId; exports.unquote = _chunkZVNAMTFOcjs.unquote; exports.validateDiagramEdit = validateDiagramEdit; exports.xyChartAdapter = _chunkZVNAMTFOcjs.xyChartAdapter; exports.xyChartGrammar = _chunkZVNAMTFOcjs.xyChartGrammar; exports.xyChartUI = xyChartUI;
2612
+
2613
+ exports.ARCH_METRICS = _chunkZVNAMTFOcjs.ARCH_METRICS; exports.C4_METRICS = _chunkZVNAMTFOcjs.C4_METRICS; exports.CLASS_RELATIONS = _chunkZVNAMTFOcjs.CLASS_RELATIONS; exports.DIRECTIONS = DIRECTIONS; exports.DiagramController = DiagramController; exports.DiagramDirector = DiagramDirector; exports.EDITABLE_DIAGRAM_FAMILIES = EDITABLE_DIAGRAM_FAMILIES; exports.ER_CARDINALITIES = _chunkZVNAMTFOcjs.ER_CARDINALITIES; exports.ER_PATTERNS = _chunkZVNAMTFOcjs.ER_PATTERNS; exports.FAMILY_BLANKS = FAMILY_BLANKS; exports.FAMILY_DESCRIPTIONS = FAMILY_DESCRIPTIONS; exports.FAMILY_TEMPLATES = FAMILY_TEMPLATES; exports.FAMILY_TITLES = FAMILY_TITLES; exports.FLOWCHART_SHAPES = _chunkZVNAMTFOcjs.FLOWCHART_SHAPES; exports.GANTT_CONFIG_KEYS = _chunkZVNAMTFOcjs.GANTT_CONFIG_KEYS; exports.GANTT_METRICS = _chunkZVNAMTFOcjs.GANTT_METRICS; exports.GANTT_TAGS = _chunkZVNAMTFOcjs.GANTT_TAGS; exports.META_COMMENT_PREFIX = _chunkZVNAMTFOcjs.META_COMMENT_PREFIX; exports.META_FRONTMATTER_KEY = _chunkZVNAMTFOcjs.META_FRONTMATTER_KEY; exports.POINT_BOX = _chunkZVNAMTFOcjs.POINT_BOX; exports.PRESENCE_COLORS = _chunkUJGAA6AKcjs.PRESENCE_COLORS; exports.PerformanceQueue = _chunkUJGAA6AKcjs.PerformanceQueue; exports.PresenceStore = _chunkUJGAA6AKcjs.PresenceStore; exports.QUADRANT_METRICS = _chunkZVNAMTFOcjs.QUADRANT_METRICS; exports.RADAR_CHART_BOX = _chunkZVNAMTFOcjs.RADAR_CHART_BOX; exports.SEQUENCE_METRICS = _chunkZVNAMTFOcjs.SEQUENCE_METRICS; exports.STATE_SHAPES = _chunkZVNAMTFOcjs.STATE_SHAPES; exports.XY_CHART_BOX = _chunkZVNAMTFOcjs.XY_CHART_BOX; exports.afterIds = _chunkZVNAMTFOcjs.afterIds; exports.applyEdit = _chunkZVNAMTFOcjs.applyEdit; exports.applyEdits = _chunkZVNAMTFOcjs.applyEdits; exports.applyStatementEdit = _chunkZVNAMTFOcjs.applyStatementEdit; exports.architectureAdapter = _chunkZVNAMTFOcjs.architectureAdapter; exports.architectureArrow = _chunkZVNAMTFOcjs.architectureArrow; exports.architectureEdgeRoute = _chunkZVNAMTFOcjs.architectureEdgeRoute; exports.architectureGrammar = _chunkZVNAMTFOcjs.architectureGrammar; exports.architectureLayout = _chunkZVNAMTFOcjs.architectureLayout; exports.architectureUI = architectureUI; exports.c4Adapter = _chunkZVNAMTFOcjs.c4Adapter; exports.c4ArrowHead = _chunkZVNAMTFOcjs.c4ArrowHead; exports.c4BoundaryText = _chunkZVNAMTFOcjs.c4BoundaryText; exports.c4ElementGeometry = _chunkZVNAMTFOcjs.c4ElementGeometry; exports.c4ElementType = _chunkZVNAMTFOcjs.c4ElementType; exports.c4Grammar = _chunkZVNAMTFOcjs.c4Grammar; exports.c4Layout = _chunkZVNAMTFOcjs.c4Layout; exports.c4RelGeometry = _chunkZVNAMTFOcjs.c4RelGeometry; exports.c4Stereotype = _chunkZVNAMTFOcjs.c4Stereotype; exports.c4UI = c4UI; exports.canonicalShape = _chunkZVNAMTFOcjs.canonicalShape; exports.changedItems = changedItems; exports.checkFieldData = checkFieldData; exports.classGrammar = _chunkZVNAMTFOcjs.classGrammar; exports.classUI = classUI; exports.createDiagramEditorDocument = createDiagramEditorDocument; exports.createDiagramToolProvider = createDiagramToolProvider; exports.createInstantPresenceClock = _chunkUJGAA6AKcjs.createInstantPresenceClock; exports.createLineAdapter = _chunkZVNAMTFOcjs.createLineAdapter; exports.createPassthroughAdapter = _chunkZVNAMTFOcjs.createPassthroughAdapter; exports.createStatementAdapter = _chunkZVNAMTFOcjs.createStatementAdapter; exports.describeDiagram = describeDiagram; exports.describeFields = describeFields; exports.detectFamily = _chunkZVNAMTFOcjs.detectFamily; exports.detectFamilyFromHeader = _chunkZVNAMTFOcjs.detectFamilyFromHeader; exports.diagramShapes = diagramShapes; exports.diagramSupportsDirection = diagramSupportsDirection; exports.diagramSupportsGroups = diagramSupportsGroups; exports.draftFrames = draftFrames; exports.dropMetaKeys = _chunkZVNAMTFOcjs.dropMetaKeys; exports.emptyMeta = _chunkZVNAMTFOcjs.emptyMeta; exports.erGrammar = _chunkZVNAMTFOcjs.erGrammar; exports.erUI = erUI; exports.familyUI = familyUI; exports.filterInPlace = _chunkZVNAMTFOcjs.filterInPlace; exports.findMermaidSources = findMermaidSources; exports.flowchartAdapter = _chunkZVNAMTFOcjs.flowchartAdapter; exports.flowchartUI = flowchartUI; exports.formatAxis = _chunkZVNAMTFOcjs.formatAxis; exports.formatChain = _chunkZVNAMTFOcjs.formatChain; exports.formatGanttDate = _chunkZVNAMTFOcjs.formatGanttDate; exports.formatLink = _chunkZVNAMTFOcjs.formatLink; exports.formatNode = _chunkZVNAMTFOcjs.formatNode; exports.ganttAdapter = _chunkZVNAMTFOcjs.ganttAdapter; exports.ganttGeometry = _chunkZVNAMTFOcjs.ganttGeometry; exports.ganttGrammar = _chunkZVNAMTFOcjs.ganttGrammar; exports.ganttUI = ganttUI; exports.getDiagramAdapter = _chunkZVNAMTFOcjs.getDiagramAdapter; exports.getFamilyLayout = _chunkZVNAMTFOcjs.getFamilyLayout; exports.gitGraphAdapter = _chunkZVNAMTFOcjs.gitGraphAdapter; exports.gitGraphGrammar = _chunkZVNAMTFOcjs.gitGraphGrammar; exports.gitGraphUI = gitGraphUI; exports.indentOf = _chunkZVNAMTFOcjs.indentOf; exports.isMetaEmpty = _chunkZVNAMTFOcjs.isMetaEmpty; exports.journeyAdapter = _chunkZVNAMTFOcjs.journeyAdapter; exports.journeyGrammar = _chunkZVNAMTFOcjs.journeyGrammar; exports.journeyLayout = _chunkZVNAMTFOcjs.journeyLayout; exports.journeyUI = journeyUI; exports.mergeMeta = _chunkZVNAMTFOcjs.mergeMeta; exports.mindmapAdapter = _chunkZVNAMTFOcjs.mindmapAdapter; exports.mindmapGrammar = _chunkZVNAMTFOcjs.mindmapGrammar; exports.mindmapUI = mindmapUI; exports.parseAttributes = _chunkZVNAMTFOcjs.parseAttributes; exports.parseChain = _chunkZVNAMTFOcjs.parseChain; exports.parseFlowchartSource = _chunkZVNAMTFOcjs.parseFlowchartSource; exports.parseGanttDate = _chunkZVNAMTFOcjs.parseGanttDate; exports.parseLink = _chunkZVNAMTFOcjs.parseLink; exports.parseMembers = _chunkZVNAMTFOcjs.parseMembers; exports.parseMermaid = _chunkZVNAMTFOcjs.parseMermaid; exports.parseSankey = parseSankey; exports.parseStatement = _chunkZVNAMTFOcjs.parseStatement; exports.parseStatementDocument = _chunkZVNAMTFOcjs.parseStatementDocument; exports.parseTreemap = parseTreemap; exports.pickFieldData = pickFieldData; exports.pieAdapter = _chunkZVNAMTFOcjs.pieAdapter; exports.pieGrammar = _chunkZVNAMTFOcjs.pieGrammar; exports.pieUI = pieUI; exports.planDiagramEdit = planDiagramEdit; exports.planDiagramEdits = planDiagramEdits; exports.pointCentre = _chunkZVNAMTFOcjs.pointCentre; exports.pointPosition = _chunkZVNAMTFOcjs.pointPosition; exports.positionToData = _chunkZVNAMTFOcjs.positionToData; exports.quadrantAdapter = _chunkZVNAMTFOcjs.quadrantAdapter; exports.quadrantGeometry = _chunkZVNAMTFOcjs.quadrantGeometry; exports.quadrantGrammar = _chunkZVNAMTFOcjs.quadrantGrammar; exports.quadrantSpace = _chunkZVNAMTFOcjs.quadrantSpace; exports.quadrantUI = quadrantUI; exports.quote = _chunkZVNAMTFOcjs.quote; exports.quoteLabelIfNeeded = _chunkZVNAMTFOcjs.quoteLabelIfNeeded; exports.radarAdapter = _chunkZVNAMTFOcjs.radarAdapter; exports.radarGrammar = _chunkZVNAMTFOcjs.radarGrammar; exports.radarUI = radarUI; exports.realPresenceClock = _chunkUJGAA6AKcjs.realPresenceClock; exports.registerDiagramAdapter = _chunkZVNAMTFOcjs.registerDiagramAdapter; exports.registerFamilyLayout = _chunkZVNAMTFOcjs.registerFamilyLayout; exports.relationFor = _chunkZVNAMTFOcjs.relationFor; exports.renameMetaKey = _chunkZVNAMTFOcjs.renameMetaKey; exports.resolveShape = _chunkZVNAMTFOcjs.resolveShape; exports.sequenceAdapter = _chunkZVNAMTFOcjs.sequenceAdapter; exports.sequenceGeometry = _chunkZVNAMTFOcjs.sequenceGeometry; exports.sequenceGrammar = _chunkZVNAMTFOcjs.sequenceGrammar; exports.sequenceUI = sequenceUI; exports.serializeMermaid = _chunkZVNAMTFOcjs.serializeMermaid; exports.serializeMeta = _chunkZVNAMTFOcjs.serializeMeta; exports.serializeStatementDocument = _chunkZVNAMTFOcjs.serializeStatementDocument; exports.serviceLabelLines = _chunkZVNAMTFOcjs.serviceLabelLines; exports.sharedFrameLayout = _chunkZVNAMTFOcjs.sharedFrameLayout; exports.slugId = _chunkZVNAMTFOcjs.slugId; exports.spaceInput = _chunkZVNAMTFOcjs.spaceInput; exports.splitOutsideQuotes = _chunkZVNAMTFOcjs.splitOutsideQuotes; exports.splitSource = _chunkZVNAMTFOcjs.splitSource; exports.splitStatements = _chunkZVNAMTFOcjs.splitStatements; exports.stateGrammar = _chunkZVNAMTFOcjs.stateGrammar; exports.stateUI = stateUI; exports.supportTierOf = _chunkZVNAMTFOcjs.supportTierOf; exports.timelineAdapter = _chunkZVNAMTFOcjs.timelineAdapter; exports.timelineGrammar = _chunkZVNAMTFOcjs.timelineGrammar; exports.timelineLayout = _chunkZVNAMTFOcjs.timelineLayout; exports.timelineUI = timelineUI; exports.treemapValue = treemapValue; exports.uniqueId = _chunkZVNAMTFOcjs.uniqueId; exports.unquote = _chunkZVNAMTFOcjs.unquote; exports.validateDiagramEdit = validateDiagramEdit; exports.xyChartAdapter = _chunkZVNAMTFOcjs.xyChartAdapter; exports.xyChartGrammar = _chunkZVNAMTFOcjs.xyChartGrammar; exports.xyChartUI = xyChartUI;
@@ -11,6 +11,7 @@
11
11
  * Ported from Ursula.
12
12
  */
13
13
  export * from './types.cjs';
14
+ export { createDiagramEditorDocument, type DiagramEditorDocument } from './editorDocument.cjs';
14
15
  export { parseMermaid, serializeMermaid, applyEdit, applyEdits, detectFamily, type ParseOptions } from './document.cjs';
15
16
  export { registerDiagramAdapter, getDiagramAdapter, supportTierOf } from './registry.cjs';
16
17
  export { splitSource, detectFamilyFromHeader, splitStatements, type SplitSource } from './source/lines.cjs';
@@ -11,6 +11,7 @@
11
11
  * Ported from Ursula.
12
12
  */
13
13
  export * from './types.js';
14
+ export { createDiagramEditorDocument, type DiagramEditorDocument } from './editorDocument.js';
14
15
  export { parseMermaid, serializeMermaid, applyEdit, applyEdits, detectFamily, type ParseOptions } from './document.js';
15
16
  export { registerDiagramAdapter, getDiagramAdapter, supportTierOf } from './registry.js';
16
17
  export { splitSource, detectFamilyFromHeader, splitStatements, type SplitSource } from './source/lines.js';
@@ -1,3 +1,6 @@
1
+ import {
2
+ defineEditorDocument
3
+ } from "../chunk-HRLT5BYO.js";
1
4
  import {
2
5
  ARCH_METRICS,
3
6
  C4_METRICS,
@@ -116,6 +119,8 @@ import {
116
119
  xyChartAdapter,
117
120
  xyChartGrammar
118
121
  } from "../chunk-GZ2FM3ZB.js";
122
+ import "../chunk-WHKNYFM2.js";
123
+ import "../chunk-HF5QZS7Z.js";
119
124
  import {
120
125
  PRESENCE_COLORS,
121
126
  PerformanceQueue,
@@ -131,6 +136,34 @@ import {
131
136
  // src/diagram/types.ts
132
137
  var DIRECTIONS = ["TB", "TD", "BT", "LR", "RL"];
133
138
 
139
+ // src/diagram/editorDocument.ts
140
+ function createDiagramEditorDocument(controller) {
141
+ return defineEditorDocument({
142
+ kind: "diagram",
143
+ get: () => ({ source: controller.getSource() }),
144
+ load: (document, { history }) => {
145
+ const source = document.source;
146
+ if (typeof source !== "string") throw new Error("A diagram document is { source: string } (Mermaid text).");
147
+ const result = controller.load(source, { clearHistory: history === "reset" });
148
+ if (!result.ok) throw new Error(result.message);
149
+ },
150
+ subscribe: (listener) => {
151
+ let source = controller.getSource();
152
+ return controller.subscribe((state) => {
153
+ if (state.source === source) return;
154
+ source = state.source;
155
+ listener();
156
+ });
157
+ },
158
+ history: {
159
+ undo: () => controller.undo(),
160
+ redo: () => controller.redo(),
161
+ getState: () => controller.history.getState()
162
+ },
163
+ readOnly: () => controller.getState().readOnly ? "The diagram is read-only." : false
164
+ });
165
+ }
166
+
134
167
  // src/diagram/source/find.ts
135
168
  var MERMAID_INFO = /^(mermaid|mmd)\b/i;
136
169
  function findMermaidSources(text) {
@@ -2466,6 +2499,7 @@ export {
2466
2499
  checkFieldData,
2467
2500
  classGrammar,
2468
2501
  classUI,
2502
+ createDiagramEditorDocument,
2469
2503
  createDiagramToolProvider,
2470
2504
  createInstantPresenceClock,
2471
2505
  createLineAdapter,
@@ -0,0 +1,51 @@
1
+ import { type EditorDocument, type EditorDocumentFile } from "./editorDocument.cjs";
2
+ import type { LoadReport } from "./migrate.cjs";
3
+ import type { StorageAdapter } from "./storage.cjs";
4
+ /** One saved document as the index lists it (no document read needed). */
5
+ export interface SavedEditorDocument {
6
+ /** Storage key of the document, e.g. `"diagram/release-flow"`; pass it to `open`. */
7
+ key: string;
8
+ kind: string;
9
+ name: string;
10
+ formatVersion: number;
11
+ /** ISO time of the last save. */
12
+ savedAt: string;
13
+ }
14
+ export interface EditorDocumentStoreOptions {
15
+ storage: StorageAdapter;
16
+ /** Prefix of every key this store writes (default `pixerate.documents`). */
17
+ namespace?: string;
18
+ /** Wall clock for `savedAt` (default `Date.now`). */
19
+ now?: () => number;
20
+ }
21
+ export interface EditorDocumentStore {
22
+ /**
23
+ * Saves the current document under `name` (one document per kind and name:
24
+ * saving the same name again replaces it).
25
+ */
26
+ save(doc: EditorDocument, name: string): Promise<SavedEditorDocument>;
27
+ /** Saved documents, newest first; only one kind's with `kind`. */
28
+ list(kind?: string): Promise<SavedEditorDocument[]>;
29
+ /** The saved file, or `null` when nothing is stored under `key`. */
30
+ read(key: string): Promise<EditorDocumentFile | null>;
31
+ /**
32
+ * Loads a saved document into `doc` (see `EditorDocument.loadDocument`) and
33
+ * returns its entry with the load report. Throws when `key` is unknown.
34
+ */
35
+ open(doc: EditorDocument, key: string, options?: {
36
+ history?: "reset" | "record";
37
+ }): Promise<SavedEditorDocument & {
38
+ report: LoadReport;
39
+ }>;
40
+ /** Deletes a saved document; `false` when there was none. */
41
+ remove(key: string): Promise<boolean>;
42
+ }
43
+ /** `"Release flow v2"` → `"release-flow-v2"` (the key part of a saved name). */
44
+ export declare function slugifyDocumentName(name: string): string;
45
+ /**
46
+ * Named documents on a key/value `StorageAdapter`, for every editor kind:
47
+ * each file under its own key plus one index entry for listing. Operations
48
+ * run one at a time, so concurrent saves do not lose index entries. The index
49
+ * is cached after the first read: use one store per storage namespace.
50
+ */
51
+ export declare function createEditorDocumentStore(options: EditorDocumentStoreOptions): EditorDocumentStore;
@@ -0,0 +1,51 @@
1
+ import { type EditorDocument, type EditorDocumentFile } from "./editorDocument.js";
2
+ import type { LoadReport } from "./migrate.js";
3
+ import type { StorageAdapter } from "./storage.js";
4
+ /** One saved document as the index lists it (no document read needed). */
5
+ export interface SavedEditorDocument {
6
+ /** Storage key of the document, e.g. `"diagram/release-flow"`; pass it to `open`. */
7
+ key: string;
8
+ kind: string;
9
+ name: string;
10
+ formatVersion: number;
11
+ /** ISO time of the last save. */
12
+ savedAt: string;
13
+ }
14
+ export interface EditorDocumentStoreOptions {
15
+ storage: StorageAdapter;
16
+ /** Prefix of every key this store writes (default `pixerate.documents`). */
17
+ namespace?: string;
18
+ /** Wall clock for `savedAt` (default `Date.now`). */
19
+ now?: () => number;
20
+ }
21
+ export interface EditorDocumentStore {
22
+ /**
23
+ * Saves the current document under `name` (one document per kind and name:
24
+ * saving the same name again replaces it).
25
+ */
26
+ save(doc: EditorDocument, name: string): Promise<SavedEditorDocument>;
27
+ /** Saved documents, newest first; only one kind's with `kind`. */
28
+ list(kind?: string): Promise<SavedEditorDocument[]>;
29
+ /** The saved file, or `null` when nothing is stored under `key`. */
30
+ read(key: string): Promise<EditorDocumentFile | null>;
31
+ /**
32
+ * Loads a saved document into `doc` (see `EditorDocument.loadDocument`) and
33
+ * returns its entry with the load report. Throws when `key` is unknown.
34
+ */
35
+ open(doc: EditorDocument, key: string, options?: {
36
+ history?: "reset" | "record";
37
+ }): Promise<SavedEditorDocument & {
38
+ report: LoadReport;
39
+ }>;
40
+ /** Deletes a saved document; `false` when there was none. */
41
+ remove(key: string): Promise<boolean>;
42
+ }
43
+ /** `"Release flow v2"` → `"release-flow-v2"` (the key part of a saved name). */
44
+ export declare function slugifyDocumentName(name: string): string;
45
+ /**
46
+ * Named documents on a key/value `StorageAdapter`, for every editor kind:
47
+ * each file under its own key plus one index entry for listing. Operations
48
+ * run one at a time, so concurrent saves do not lose index entries. The index
49
+ * is cached after the first read: use one store per storage namespace.
50
+ */
51
+ export declare function createEditorDocumentStore(options: EditorDocumentStoreOptions): EditorDocumentStore;
@@ -0,0 +1,35 @@
1
+ import type { AgentToolProvider } from "../tools/registry.cjs";
2
+ import type { EditorDocumentStore } from "./documentStore.cjs";
3
+ import type { EditorDocument } from "./editorDocument.cjs";
4
+ export interface DocumentToolProviderOptions {
5
+ /** Provider id (default `<kind>-document`). */
6
+ id?: string;
7
+ /** Tool-name prefix (`<namespace>__<name>`); defaults to the id, `''` for bare names. */
8
+ namespace?: string;
9
+ /** Toolset title (default "<Noun> document"). */
10
+ title?: string;
11
+ /** The skill that documents the editor's tools, e.g. `pixerate-diagram`. */
12
+ skill?: string;
13
+ /** What the document is called in descriptions (default the kind with spaces, e.g. "video project"). */
14
+ noun?: string;
15
+ /**
16
+ * Add `undo_<kind>` / `redo_<kind>` (default `true`). Pass `false` for editors
17
+ * whose own provider already has them.
18
+ */
19
+ history?: boolean;
20
+ /** Saved documents: adds `save_<kind>_document`, `list_saved_<kind>_documents` and `open_saved_<kind>_document`. */
21
+ store?: EditorDocumentStore;
22
+ /** Name `save_<kind>_document` uses when none is given (default "Untitled <noun>"). */
23
+ name?: () => string | undefined;
24
+ /** `get_<kind>_document` refuses documents whose JSON is longer than this (default 200000 characters). */
25
+ maxChars?: number;
26
+ }
27
+ /**
28
+ * The same document tools for every editor, named after `doc.kind`:
29
+ * `get_<kind>_document`, `load_<kind>_document`, `undo_<kind>`, `redo_<kind>`
30
+ * and, with a `store`, `save_<kind>_document`, `list_saved_<kind>_documents`
31
+ * and `open_saved_<kind>_document`. Loads are checked before anything changes
32
+ * and are one undo step where the editor supports it. A read-only document
33
+ * keeps its read tools; its write tools refuse with the reason.
34
+ */
35
+ export declare function createDocumentToolProvider(doc: EditorDocument, options?: DocumentToolProviderOptions): AgentToolProvider;