@datalayer/reactor-excalidraw 0.0.0 → 1.3.10

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/lib/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `@datalayer/reactor-excalidraw` — Excalidraw drawings as AI agent tools.
3
+ *
4
+ * The eleven tools an agent draws with (definitions, Zod schemas, the
5
+ * operations that validate a call), the handlers that carry it out over any
6
+ * host that keeps drawings, a pure scene model, and the reactor plugin that
7
+ * offers them as commands and an `AgentTools` bundle. No editor is assumed:
8
+ * a Lexical document, a page's canvas and a server each bring a host.
9
+ *
10
+ * @module index
11
+ */
12
+ export * from './scene';
13
+ export * from './schemas';
14
+ export * from './definitions';
15
+ export * from './operations';
16
+ export * from './host';
17
+ export * from './handlers';
18
+ export * from './tools';
19
+ export * from './plugin';
20
+ export { ExcalidrawPlugin as default } from './plugin';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright (c) 2026-Present Datalayer, Inc.
3
+ *
4
+ * BSD 3-Clause License
5
+ */
6
+ /**
7
+ * `@datalayer/reactor-excalidraw` — Excalidraw drawings as AI agent tools.
8
+ *
9
+ * The eleven tools an agent draws with (definitions, Zod schemas, the
10
+ * operations that validate a call), the handlers that carry it out over any
11
+ * host that keeps drawings, a pure scene model, and the reactor plugin that
12
+ * offers them as commands and an `AgentTools` bundle. No editor is assumed:
13
+ * a Lexical document, a page's canvas and a server each bring a host.
14
+ *
15
+ * @module index
16
+ */
17
+ export * from './scene.js';
18
+ export * from './schemas.js';
19
+ export * from './definitions.js';
20
+ export * from './operations.js';
21
+ export * from './host.js';
22
+ export * from './handlers.js';
23
+ export * from './tools.js';
24
+ export * from './plugin.js';
25
+ export { ExcalidrawPlugin as default } from './plugin.js';
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,gBAAgB,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * The agent-facing half of the Excalidraw tools.
3
+ *
4
+ * Each one validates its parameters and hands them to the executor; the work
5
+ * happens in `handlers.ts`, against the host that keeps the drawings, which
6
+ * is usually a browser page or editor. These operations run wherever the
7
+ * agent runs.
8
+ *
9
+ * So: nothing in this module may import an editor or Excalidraw, directly or
10
+ * transitively. That is what keeps the tool list loadable in Node.
11
+ *
12
+ * The eleven of them are the same three lines with different names, which is
13
+ * why they are built rather than written out. Writing them out would be
14
+ * eleven chances to get the validation call wrong, and nothing gained.
15
+ *
16
+ * @module operations
17
+ */
18
+ import { type ToolOperation } from '@datalayer/reactor/tools';
19
+ import type { ExcalidrawElementSummary } from './scene';
20
+ /** What a call that changed a drawing reports back. */
21
+ export interface ExcalidrawSceneResult {
22
+ success: boolean;
23
+ /** The drawing that was touched. */
24
+ blockId: string;
25
+ /** How many elements it holds afterwards. */
26
+ elementCount: number;
27
+ /** The ids of the elements the call created, in the order they were given. */
28
+ createdIds?: string[];
29
+ message?: string;
30
+ }
31
+ /** What inserting a drawing reports back. */
32
+ export interface ExcalidrawInsertNodeResult extends ExcalidrawSceneResult {
33
+ /** The new block's id, for the calls that follow. */
34
+ blockId: string;
35
+ }
36
+ /** One drawing in a listing. */
37
+ export interface ExcalidrawDrawingSummary {
38
+ blockId: string;
39
+ elementCount: number;
40
+ /** "3 rectangles, 2 arrows: Start, Finish" */
41
+ description: string;
42
+ width?: number;
43
+ height?: number;
44
+ }
45
+ /** What a listing reports back. */
46
+ export interface ExcalidrawListDrawingsResult {
47
+ drawings: ExcalidrawDrawingSummary[];
48
+ count: number;
49
+ }
50
+ /** What reading a drawing reports back. */
51
+ export interface ExcalidrawReadSceneResult {
52
+ blockId: string;
53
+ elementCount: number;
54
+ elements: ExcalidrawElementSummary[] | Record<string, any>[];
55
+ appState: Record<string, any>;
56
+ description: string;
57
+ }
58
+ export declare const excalidrawInsertNodeOperation: ToolOperation<unknown, ExcalidrawInsertNodeResult>;
59
+ export declare const excalidrawListDrawingsOperation: ToolOperation<unknown, ExcalidrawListDrawingsResult>;
60
+ export declare const excalidrawReadSceneOperation: ToolOperation<unknown, ExcalidrawReadSceneResult>;
61
+ export declare const excalidrawAddElementsOperation: ToolOperation<unknown, ExcalidrawSceneResult>;
62
+ export declare const excalidrawUpdateElementsOperation: ToolOperation<unknown, ExcalidrawSceneResult>;
63
+ export declare const excalidrawDeleteElementsOperation: ToolOperation<unknown, ExcalidrawSceneResult>;
64
+ export declare const excalidrawConnectElementsOperation: ToolOperation<unknown, ExcalidrawSceneResult>;
65
+ export declare const excalidrawSetAppStateOperation: ToolOperation<unknown, ExcalidrawSceneResult>;
66
+ export declare const excalidrawResizeOperation: ToolOperation<unknown, ExcalidrawSceneResult>;
67
+ export declare const excalidrawClearSceneOperation: ToolOperation<unknown, ExcalidrawSceneResult>;
68
+ export declare const excalidrawFromMermaidOperation: ToolOperation<unknown, ExcalidrawInsertNodeResult>;
69
+ /**
70
+ * Every Excalidraw operation, keyed by the name its definition points at.
71
+ */
72
+ export declare const excalidrawToolOperations: Record<string, ToolOperation<unknown, unknown>>;
73
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAiExD,uDAAuD;AACvD,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,6CAA6C;AAC7C,MAAM,WAAW,0BAA2B,SAAQ,qBAAqB;IACvE,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,gCAAgC;AAChC,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,mCAAmC;AACnC,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,wBAAwB,EAAE,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,2CAA2C;AAC3C,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,wBAAwB,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC;IAC7D,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;CACrB;AAMD,eAAO,MAAM,6BAA6B,oDAIvC,CAAC;AAEJ,eAAO,MAAM,+BAA+B,sDAIzC,CAAC;AAEJ,eAAO,MAAM,4BAA4B,mDAItC,CAAC;AAEJ,eAAO,MAAM,8BAA8B,+CAIxC,CAAC;AAEJ,eAAO,MAAM,iCAAiC,+CAI3C,CAAC;AAEJ,eAAO,MAAM,iCAAiC,+CAI3C,CAAC;AAEJ,eAAO,MAAM,kCAAkC,+CAI5C,CAAC;AAEJ,eAAO,MAAM,8BAA8B,+CAIxC,CAAC;AAEJ,eAAO,MAAM,yBAAyB,+CAInC,CAAC;AAEJ,eAAO,MAAM,6BAA6B,+CAIvC,CAAC;AAEJ,eAAO,MAAM,8BAA8B,oDAIxC,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAC3C,MAAM,EACN,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAamB,CAAC"}
@@ -0,0 +1,85 @@
1
+ /*
2
+ * Copyright (c) 2026-Present Datalayer, Inc.
3
+ *
4
+ * BSD 3-Clause License
5
+ */
6
+ /**
7
+ * The agent-facing half of the Excalidraw tools.
8
+ *
9
+ * Each one validates its parameters and hands them to the executor; the work
10
+ * happens in `handlers.ts`, against the host that keeps the drawings, which
11
+ * is usually a browser page or editor. These operations run wherever the
12
+ * agent runs.
13
+ *
14
+ * So: nothing in this module may import an editor or Excalidraw, directly or
15
+ * transitively. That is what keeps the tool list loadable in Node.
16
+ *
17
+ * The eleven of them are the same three lines with different names, which is
18
+ * why they are built rather than written out. Writing them out would be
19
+ * eleven chances to get the validation call wrong, and nothing gained.
20
+ *
21
+ * @module operations
22
+ */
23
+ import { validateWithZod, } from '@datalayer/reactor/tools';
24
+ import { excalidrawAddElementsParamsSchema, excalidrawClearSceneParamsSchema, excalidrawConnectElementsParamsSchema, excalidrawDeleteElementsParamsSchema, excalidrawFromMermaidParamsSchema, excalidrawInsertNodeParamsSchema, excalidrawListDrawingsParamsSchema, excalidrawReadSceneParamsSchema, excalidrawResizeParamsSchema, excalidrawSetAppStateParamsSchema, excalidrawUpdateElementsParamsSchema, } from './schemas.js';
25
+ /**
26
+ * Build one operation.
27
+ *
28
+ * @param name - The operation name, which is also the handler's key and the
29
+ * `operation` field of the tool definition that points here.
30
+ * @param schema - What the tool takes.
31
+ */
32
+ function excalidrawOperation(name, schema) {
33
+ return {
34
+ name,
35
+ async execute(params, context) {
36
+ const validated = validateWithZod(schema, params ?? {}, name);
37
+ if (!context.documentId) {
38
+ throw new Error(`Document ID is required for ${name}. ` +
39
+ 'Ensure the tool execution context includes a valid documentId.');
40
+ }
41
+ if (!context.executor) {
42
+ throw new Error(`Executor is required for ${name}. ` +
43
+ 'This should be provided by the platform (DefaultExecutor, BridgeExecutor, etc.)');
44
+ }
45
+ try {
46
+ return (await context.executor.execute(name, validated));
47
+ }
48
+ catch (error) {
49
+ const message = error instanceof Error ? error.message : String(error);
50
+ throw new Error(`Failed to run ${name}: ${message}`, { cause: error });
51
+ }
52
+ },
53
+ };
54
+ }
55
+ // ============================================================================
56
+ // The operations
57
+ // ============================================================================
58
+ export const excalidrawInsertNodeOperation = excalidrawOperation('excalidrawInsertNode', excalidrawInsertNodeParamsSchema);
59
+ export const excalidrawListDrawingsOperation = excalidrawOperation('excalidrawListDrawings', excalidrawListDrawingsParamsSchema);
60
+ export const excalidrawReadSceneOperation = excalidrawOperation('excalidrawReadScene', excalidrawReadSceneParamsSchema);
61
+ export const excalidrawAddElementsOperation = excalidrawOperation('excalidrawAddElements', excalidrawAddElementsParamsSchema);
62
+ export const excalidrawUpdateElementsOperation = excalidrawOperation('excalidrawUpdateElements', excalidrawUpdateElementsParamsSchema);
63
+ export const excalidrawDeleteElementsOperation = excalidrawOperation('excalidrawDeleteElements', excalidrawDeleteElementsParamsSchema);
64
+ export const excalidrawConnectElementsOperation = excalidrawOperation('excalidrawConnectElements', excalidrawConnectElementsParamsSchema);
65
+ export const excalidrawSetAppStateOperation = excalidrawOperation('excalidrawSetAppState', excalidrawSetAppStateParamsSchema);
66
+ export const excalidrawResizeOperation = excalidrawOperation('excalidrawResize', excalidrawResizeParamsSchema);
67
+ export const excalidrawClearSceneOperation = excalidrawOperation('excalidrawClearScene', excalidrawClearSceneParamsSchema);
68
+ export const excalidrawFromMermaidOperation = excalidrawOperation('excalidrawFromMermaid', excalidrawFromMermaidParamsSchema);
69
+ /**
70
+ * Every Excalidraw operation, keyed by the name its definition points at.
71
+ */
72
+ export const excalidrawToolOperations = {
73
+ excalidrawInsertNode: excalidrawInsertNodeOperation,
74
+ excalidrawListDrawings: excalidrawListDrawingsOperation,
75
+ excalidrawReadScene: excalidrawReadSceneOperation,
76
+ excalidrawAddElements: excalidrawAddElementsOperation,
77
+ excalidrawUpdateElements: excalidrawUpdateElementsOperation,
78
+ excalidrawDeleteElements: excalidrawDeleteElementsOperation,
79
+ excalidrawConnectElements: excalidrawConnectElementsOperation,
80
+ excalidrawSetAppState: excalidrawSetAppStateOperation,
81
+ excalidrawResize: excalidrawResizeOperation,
82
+ excalidrawClearScene: excalidrawClearSceneOperation,
83
+ excalidrawFromMermaid: excalidrawFromMermaidOperation,
84
+ };
85
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,eAAe,GAGhB,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EACL,iCAAiC,EACjC,gCAAgC,EAChC,qCAAqC,EACrC,oCAAoC,EACpC,iCAAiC,EACjC,gCAAgC,EAChC,kCAAkC,EAClC,+BAA+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 import type { ExcalidrawConverters, ExcalidrawDrawingHost } from './host';
2
+ export declare const EXCALIDRAW_PLUGIN_NAME = "@datalayer/reactor-excalidraw";
3
+ export type ExcalidrawPluginConfig = {
4
+ /** What keeps the drawings. Without one, every command says so. */
5
+ host: ExcalidrawDrawingHost | null;
6
+ /** Excalidraw's conversions. Without them, every command says so. */
7
+ converters: ExcalidrawConverters | null;
8
+ };
9
+ export declare const ExcalidrawPlugin: import("@datalayer/reactor").ReactorPlugin<ExcalidrawPluginConfig, unknown, unknown>;
10
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAS1E,eAAO,MAAM,sBAAsB,kCAAkC,CAAC;AAEtE,MAAM,MAAM,sBAAsB,GAAG;IACnC,mEAAmE;IACnE,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACnC,qEAAqE;IACrE,UAAU,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACzC,CAAC;AAEF,eAAO,MAAM,gBAAgB,sFAuC3B,CAAC"}
package/lib/plugin.js ADDED
@@ -0,0 +1,66 @@
1
+ /*
2
+ * Copyright (c) 2026-Present Datalayer, Inc.
3
+ *
4
+ * BSD 3-Clause License
5
+ */
6
+ /**
7
+ * The reactor plugin: the Excalidraw tools as commands, and the bundle that
8
+ * offers them to an agent.
9
+ *
10
+ * Each tool's operation is registered as a command, `excalidraw.<operation>`,
11
+ * which validates its argument and runs it against the host the plugin was
12
+ * configured with; the plugin's `AgentTools` bundle names those commands, so
13
+ * a host that mounts the plugin hands an agent the tools without declaring
14
+ * any.
15
+ *
16
+ * ```ts
17
+ * configurePlugin(ExcalidrawPlugin, {
18
+ * host: createMemoryDrawingHost(),
19
+ * converters: { convertToExcalidrawElements, parseMermaidToExcalidraw },
20
+ * });
21
+ * ```
22
+ *
23
+ * @module plugin
24
+ */
25
+ import { AgentTools, contribution, definePlugin } from '@datalayer/reactor';
26
+ import { excalidrawToolDefinitions } from './definitions.js';
27
+ import { createExcalidrawToolHandlers } from './handlers.js';
28
+ import { excalidrawToolOperations } from './operations.js';
29
+ import { createExcalidrawExecutor, EXCALIDRAW_AGENT_TOOLS, EXCALIDRAW_TOOLS_NAME, excalidrawCommandOf, } from './tools.js';
30
+ export const EXCALIDRAW_PLUGIN_NAME = '@datalayer/reactor-excalidraw';
31
+ export const ExcalidrawPlugin = definePlugin({
32
+ name: EXCALIDRAW_PLUGIN_NAME,
33
+ displayName: 'Excalidraw',
34
+ description: 'Excalidraw drawings as tools an agent draws with.',
35
+ octicon: 'paintbrush',
36
+ emoji: '\u{1F58C}\u{FE0F}',
37
+ config: { host: null, converters: null },
38
+ contributes: [contribution(AgentTools, EXCALIDRAW_AGENT_TOOLS, { id: EXCALIDRAW_TOOLS_NAME })],
39
+ register: ({ config, registerCommand }) => {
40
+ const { host, converters } = config;
41
+ const executor = host && converters
42
+ ? createExcalidrawExecutor(createExcalidrawToolHandlers(host, converters))
43
+ : null;
44
+ const undo = excalidrawToolDefinitions.map((definition) => registerCommand({
45
+ id: excalidrawCommandOf(definition.operation),
46
+ name: definition.displayName,
47
+ description: definition.description,
48
+ category: 'Excalidraw',
49
+ execute: (argument) => {
50
+ if (!executor) {
51
+ throw new Error(`${EXCALIDRAW_PLUGIN_NAME} was configured without a drawing host and converters.`);
52
+ }
53
+ return excalidrawToolOperations[definition.operation].execute(argument ?? {}, {
54
+ executor,
55
+ documentId: EXCALIDRAW_TOOLS_NAME,
56
+ });
57
+ },
58
+ }));
59
+ return () => {
60
+ for (const dispose of undo) {
61
+ dispose();
62
+ }
63
+ };
64
+ },
65
+ });
66
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;G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CAAC,WAAW;YAC5B,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,QAAQ,EAAE,YAAY;YACtB,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACpB,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACd,MAAM,IAAI,KAAK,CACb,GAAG,sBAAsB,wDAAwD,CAClF,CAAC;gBACJ,CAAC;gBACD,OAAO,wBAAwB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,EAAE;oBAC5E,QAAQ;oBACR,UAAU,EAAE,qBAAqB;iBAClC,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CACH,CAAC;QACF,OAAO,GAAG,EAAE;YACV,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;gBAC3B,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
package/lib/scene.d.ts ADDED
@@ -0,0 +1,101 @@
1
+ /**
2
+ * A drawing, read and written as data.
3
+ *
4
+ * A host keeps a whole scene as one JSON string — a Lexical `ExcalidrawNode`
5
+ * does, a page's canvas does — and the tools need to read it, change part of
6
+ * it and write it back. The parsing lives here once, rather than once per
7
+ * host with a set of assumptions each.
8
+ *
9
+ * **Two shapes, one reader.** A drawing created empty may be the string
10
+ * `'[]'`, and a drawing saved from Excalidraw holds
11
+ * `{elements, appState, files}`. Both are found in real documents, so both
12
+ * are read here and only the second is ever written.
13
+ *
14
+ * Nothing in this module imports Excalidraw or any editor: it is arithmetic
15
+ * on plain objects, which is what lets the operations that summarise a scene
16
+ * run outside a browser.
17
+ *
18
+ * @module scene
19
+ */
20
+ /** An Excalidraw element, as it sits in the scene's JSON. */
21
+ export type ExcalidrawElementData = Record<string, any>;
22
+ /**
23
+ * A whole drawing: what is in it, how the canvas is set up, and any images it
24
+ * embeds.
25
+ */
26
+ export interface ExcalidrawScene {
27
+ elements: ExcalidrawElementData[];
28
+ appState: Record<string, any>;
29
+ files: Record<string, any>;
30
+ }
31
+ /** An empty drawing. */
32
+ export declare const emptyScene: () => ExcalidrawScene;
33
+ /**
34
+ * Read a drawing's stored string.
35
+ *
36
+ * Tolerant on purpose: a drawing that cannot be parsed reads as an empty one
37
+ * rather than throwing, because the alternative is a tool call that fails on
38
+ * a document the editor itself opens quite happily.
39
+ */
40
+ export declare function parseScene(data: string | undefined | null): ExcalidrawScene;
41
+ /** Write a scene back to the string a host stores. */
42
+ export declare function serializeScene(scene: ExcalidrawScene): string;
43
+ /** The elements that are actually on the canvas. */
44
+ export declare const liveElements: (scene: ExcalidrawScene) => ExcalidrawElementData[];
45
+ /**
46
+ * One element, reduced to what somebody deciding what to do next needs.
47
+ *
48
+ * A raw Excalidraw element carries about thirty fields, most of them about
49
+ * how it is drawn rather than what it is — seeds, version nonces, fractional
50
+ * indices, roughness. Handing all of that to a model for every element buries
51
+ * the two things it actually needs, which are the id it can address the
52
+ * element by and where the element sits.
53
+ */
54
+ export interface ExcalidrawElementSummary {
55
+ id: string;
56
+ type: string;
57
+ x: number;
58
+ y: number;
59
+ width: number;
60
+ height: number;
61
+ /** The element's own text, or the text bound inside it. */
62
+ text?: string;
63
+ strokeColor?: string;
64
+ backgroundColor?: string;
65
+ /** For bound text: the element it sits inside. */
66
+ containerId?: string;
67
+ /** For arrows: what they are attached to. */
68
+ startBoundElementId?: string;
69
+ endBoundElementId?: string;
70
+ /** Groups the element belongs to, if any. */
71
+ groupIds?: string[];
72
+ }
73
+ /** Reduce one element to its summary. */
74
+ export declare function summarizeElement(element: ExcalidrawElementData): ExcalidrawElementSummary;
75
+ /**
76
+ * The text a container shows, gathered from the element bound inside it.
77
+ *
78
+ * Excalidraw does not put a label on the shape; it makes a separate text
79
+ * element whose `containerId` points back. Reading a rectangle on its own
80
+ * therefore says nothing about what the rectangle is called, which is
81
+ * usually the only thing worth knowing about it.
82
+ */
83
+ export declare function withBoundText(elements: ExcalidrawElementData[]): ExcalidrawElementSummary[];
84
+ /**
85
+ * A one-line description of a drawing, for a listing.
86
+ *
87
+ * What is in it and what it says — "3 rectangles, 2 arrows: Start, Finish" —
88
+ * which is enough to pick the right drawing out of a document holding
89
+ * several.
90
+ */
91
+ export declare function describeScene(scene: ExcalidrawScene): string;
92
+ /**
93
+ * Stamp an element as changed.
94
+ *
95
+ * Excalidraw reconciles concurrent edits by comparing `version` and, when
96
+ * those tie, `versionNonce`. An element written back with its old version is
97
+ * an element a collaborating client is entitled to discard, so every
98
+ * mutation goes through here.
99
+ */
100
+ export declare function touchElement(element: ExcalidrawElementData): ExcalidrawElementData;
101
+ //# sourceMappingURL=scene.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../src/scene.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,6DAA6D;AAC7D,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,qBAAqB,EAAE,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,wBAAwB;AACxB,eAAO,MAAM,UAAU,QAAO,eAI5B,CAAC;AAEH;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,eAAe,CA2B3E;AAED,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAM7D;AAED,oDAAoD;AACpD,eAAO,MAAM,YAAY,GAAI,OAAO,eAAe,KAAG,qBAAqB,EACpB,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,yCAAyC;AACzC,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,qBAAqB,GAC7B,wBAAwB,CA+B1B;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,qBAAqB,EAAE,GAChC,wBAAwB,EAAE,CAiB5B;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CA2B5D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CAOvB"}
package/lib/scene.js ADDED
@@ -0,0 +1,168 @@
1
+ /*
2
+ * Copyright (c) 2026-Present Datalayer, Inc.
3
+ *
4
+ * BSD 3-Clause License
5
+ */
6
+ /** An empty drawing. */
7
+ export const emptyScene = () => ({
8
+ elements: [],
9
+ appState: {},
10
+ files: {},
11
+ });
12
+ /**
13
+ * Read a drawing's stored string.
14
+ *
15
+ * Tolerant on purpose: a drawing that cannot be parsed reads as an empty one
16
+ * rather than throwing, because the alternative is a tool call that fails on
17
+ * a document the editor itself opens quite happily.
18
+ */
19
+ export function parseScene(data) {
20
+ if (!data) {
21
+ return emptyScene();
22
+ }
23
+ let parsed;
24
+ try {
25
+ parsed = JSON.parse(data);
26
+ }
27
+ catch {
28
+ return emptyScene();
29
+ }
30
+ // The legacy shape: the elements array on its own.
31
+ if (Array.isArray(parsed)) {
32
+ return {
33
+ elements: parsed,
34
+ appState: {},
35
+ files: {},
36
+ };
37
+ }
38
+ if (!parsed || typeof parsed !== 'object') {
39
+ return emptyScene();
40
+ }
41
+ const scene = parsed;
42
+ return {
43
+ elements: Array.isArray(scene.elements) ? scene.elements : [],
44
+ appState: scene.appState ?? {},
45
+ files: scene.files ?? {},
46
+ };
47
+ }
48
+ /** Write a scene back to the string a host stores. */
49
+ export function serializeScene(scene) {
50
+ return JSON.stringify({
51
+ elements: scene.elements,
52
+ appState: scene.appState,
53
+ files: scene.files,
54
+ });
55
+ }
56
+ /** The elements that are actually on the canvas. */
57
+ export const liveElements = (scene) => scene.elements.filter(element => !element?.isDeleted);
58
+ /** Reduce one element to its summary. */
59
+ export function summarizeElement(element) {
60
+ const summary = {
61
+ id: String(element?.id ?? ''),
62
+ type: String(element?.type ?? 'unknown'),
63
+ x: Number(element?.x ?? 0),
64
+ y: Number(element?.y ?? 0),
65
+ width: Number(element?.width ?? 0),
66
+ height: Number(element?.height ?? 0),
67
+ };
68
+ if (typeof element?.text === 'string' && element.text.length > 0) {
69
+ summary.text = element.text;
70
+ }
71
+ if (element?.strokeColor) {
72
+ summary.strokeColor = String(element.strokeColor);
73
+ }
74
+ if (element?.backgroundColor) {
75
+ summary.backgroundColor = String(element.backgroundColor);
76
+ }
77
+ if (element?.containerId) {
78
+ summary.containerId = String(element.containerId);
79
+ }
80
+ if (element?.startBinding?.elementId) {
81
+ summary.startBoundElementId = String(element.startBinding.elementId);
82
+ }
83
+ if (element?.endBinding?.elementId) {
84
+ summary.endBoundElementId = String(element.endBinding.elementId);
85
+ }
86
+ if (Array.isArray(element?.groupIds) && element.groupIds.length > 0) {
87
+ summary.groupIds = element.groupIds.map(String);
88
+ }
89
+ return summary;
90
+ }
91
+ /**
92
+ * The text a container shows, gathered from the element bound inside it.
93
+ *
94
+ * Excalidraw does not put a label on the shape; it makes a separate text
95
+ * element whose `containerId` points back. Reading a rectangle on its own
96
+ * therefore says nothing about what the rectangle is called, which is
97
+ * usually the only thing worth knowing about it.
98
+ */
99
+ export function withBoundText(elements) {
100
+ const textByContainer = new Map();
101
+ for (const element of elements) {
102
+ if (element?.type === 'text' && element?.containerId && element?.text) {
103
+ textByContainer.set(String(element.containerId), String(element.text));
104
+ }
105
+ }
106
+ return elements.map(element => {
107
+ const summary = summarizeElement(element);
108
+ if (summary.text === undefined) {
109
+ const bound = textByContainer.get(summary.id);
110
+ if (bound) {
111
+ summary.text = bound;
112
+ }
113
+ }
114
+ return summary;
115
+ });
116
+ }
117
+ /**
118
+ * A one-line description of a drawing, for a listing.
119
+ *
120
+ * What is in it and what it says — "3 rectangles, 2 arrows: Start, Finish" —
121
+ * which is enough to pick the right drawing out of a document holding
122
+ * several.
123
+ */
124
+ export function describeScene(scene) {
125
+ const elements = liveElements(scene);
126
+ if (elements.length === 0) {
127
+ return 'empty drawing';
128
+ }
129
+ const counts = new Map();
130
+ const labels = [];
131
+ for (const element of elements) {
132
+ const type = String(element?.type ?? 'unknown');
133
+ if (type === 'text') {
134
+ const text = String(element?.text ?? '').trim();
135
+ if (text) {
136
+ labels.push(text);
137
+ }
138
+ // Bound text is the container's label, not a shape of its own.
139
+ if (element?.containerId) {
140
+ continue;
141
+ }
142
+ }
143
+ counts.set(type, (counts.get(type) ?? 0) + 1);
144
+ }
145
+ const shapes = [...counts.entries()]
146
+ .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
147
+ .map(([type, count]) => `${count} ${type}${count > 1 ? 's' : ''}`)
148
+ .join(', ');
149
+ const said = labels.slice(0, 3).join(', ');
150
+ return said ? `${shapes}: ${said}` : shapes;
151
+ }
152
+ /**
153
+ * Stamp an element as changed.
154
+ *
155
+ * Excalidraw reconciles concurrent edits by comparing `version` and, when
156
+ * those tie, `versionNonce`. An element written back with its old version is
157
+ * an element a collaborating client is entitled to discard, so every
158
+ * mutation goes through here.
159
+ */
160
+ export function touchElement(element) {
161
+ return {
162
+ ...element,
163
+ version: Number(element?.version ?? 1) + 1,
164
+ versionNonce: Math.floor(Math.random() * 2 ** 31),
165
+ updated: Date.now(),
166
+ };
167
+ }
168
+ //# sourceMappingURL=scene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scene.js","sourceRoot":"","sources":["../src/scene.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmCH,wBAAwB;AACxB,MAAM,CAAC,MAAM,UAAU,GAAG,GAAoB,EAAE,CAAC,CAAC;IAChD,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,KAAK,EAAE,EAAE;CACV,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAA+B;IACxD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;IACD,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;IACD,mDAAmD;IACnD,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO;YACL,QAAQ,EAAE,MAAiC;YAC3C,QAAQ,EAAE,EAAE;YACZ,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC;IACD,MAAM,KAAK,GAAG,MAAkC,CAAC;IACjD,OAAO;QACL,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAA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