@datalayer/reactor-excalidraw 0.0.0-stage → 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/LICENSE +29 -0
- package/README.md +106 -2
- package/lib/definitions.d.ts +30 -0
- package/lib/definitions.d.ts.map +1 -0
- package/lib/definitions.js +186 -0
- package/lib/definitions.js.map +1 -0
- package/lib/handlers.d.ts +94 -0
- package/lib/handlers.d.ts.map +1 -0
- package/lib/handlers.js +456 -0
- package/lib/handlers.js.map +1 -0
- package/lib/host.d.ts +88 -0
- package/lib/host.d.ts.map +1 -0
- package/lib/host.js +73 -0
- package/lib/host.js.map +1 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +26 -0
- package/lib/index.js.map +1 -0
- package/lib/operations.d.ts +73 -0
- package/lib/operations.d.ts.map +1 -0
- package/lib/operations.js +85 -0
- package/lib/operations.js.map +1 -0
- package/lib/plugin.d.ts +10 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +66 -0
- package/lib/plugin.js.map +1 -0
- package/lib/scene.d.ts +101 -0
- package/lib/scene.d.ts.map +1 -0
- package/lib/scene.js +168 -0
- package/lib/scene.js.map +1 -0
- package/lib/schemas.d.ts +230 -0
- package/lib/schemas.d.ts.map +1 -0
- package/lib/schemas.js +209 -0
- package/lib/schemas.js.map +1 -0
- package/lib/tools.d.ts +33 -0
- package/lib/tools.d.ts.map +1 -0
- package/lib/tools.js +92 -0
- package/lib/tools.js.map +1 -0
- package/package.json +46 -4
package/lib/schemas.d.ts
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each Excalidraw tool takes.
|
|
3
|
+
*
|
|
4
|
+
* The element shape here is Excalidraw's own "skeleton" — the reduced form
|
|
5
|
+
* `convertToExcalidrawElements` accepts, where a rectangle is `{type, x, y,
|
|
6
|
+
* width, height}` rather than the thirty-field record the scene stores. That
|
|
7
|
+
* is deliberate: the skeleton is the only part of the drawing format that is
|
|
8
|
+
* meant to be written by hand, and everything it leaves out (seeds, version
|
|
9
|
+
* nonces, fractional indices, binding geometry) is exactly what a model
|
|
10
|
+
* should not be inventing.
|
|
11
|
+
*
|
|
12
|
+
* @module schemas
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
/**
|
|
16
|
+
* A shape, as written rather than as stored.
|
|
17
|
+
*
|
|
18
|
+
* Kept deliberately close to Excalidraw's skeleton type: the fields a
|
|
19
|
+
* diagram actually needs, with everything derived left to the converter.
|
|
20
|
+
*/
|
|
21
|
+
export declare const elementSkeletonSchema: z.ZodObject<{
|
|
22
|
+
type: z.ZodEnum<{
|
|
23
|
+
rectangle: "rectangle";
|
|
24
|
+
ellipse: "ellipse";
|
|
25
|
+
diamond: "diamond";
|
|
26
|
+
text: "text";
|
|
27
|
+
arrow: "arrow";
|
|
28
|
+
line: "line";
|
|
29
|
+
frame: "frame";
|
|
30
|
+
}>;
|
|
31
|
+
x: z.ZodNumber;
|
|
32
|
+
y: z.ZodNumber;
|
|
33
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
id: z.ZodOptional<z.ZodString>;
|
|
36
|
+
text: z.ZodOptional<z.ZodString>;
|
|
37
|
+
label: z.ZodOptional<z.ZodString>;
|
|
38
|
+
fontSize: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
strokeColor: z.ZodOptional<z.ZodString>;
|
|
40
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
41
|
+
fillStyle: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
hachure: "hachure";
|
|
43
|
+
"cross-hatch": "cross-hatch";
|
|
44
|
+
solid: "solid";
|
|
45
|
+
}>>;
|
|
46
|
+
strokeWidth: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
strokeStyle: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
solid: "solid";
|
|
49
|
+
dashed: "dashed";
|
|
50
|
+
dotted: "dotted";
|
|
51
|
+
}>>;
|
|
52
|
+
roughness: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
angle: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
startId: z.ZodOptional<z.ZodString>;
|
|
56
|
+
endId: z.ZodOptional<z.ZodString>;
|
|
57
|
+
points: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
|
|
58
|
+
children: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
59
|
+
name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type ElementSkeleton = z.infer<typeof elementSkeletonSchema>;
|
|
62
|
+
export declare const excalidrawInsertNodeParamsSchema: z.ZodObject<{
|
|
63
|
+
afterId: z.ZodString;
|
|
64
|
+
elements: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
65
|
+
type: z.ZodEnum<{
|
|
66
|
+
rectangle: "rectangle";
|
|
67
|
+
ellipse: "ellipse";
|
|
68
|
+
diamond: "diamond";
|
|
69
|
+
text: "text";
|
|
70
|
+
arrow: "arrow";
|
|
71
|
+
line: "line";
|
|
72
|
+
frame: "frame";
|
|
73
|
+
}>;
|
|
74
|
+
x: z.ZodNumber;
|
|
75
|
+
y: z.ZodNumber;
|
|
76
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
78
|
+
id: z.ZodOptional<z.ZodString>;
|
|
79
|
+
text: z.ZodOptional<z.ZodString>;
|
|
80
|
+
label: z.ZodOptional<z.ZodString>;
|
|
81
|
+
fontSize: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
strokeColor: z.ZodOptional<z.ZodString>;
|
|
83
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
84
|
+
fillStyle: z.ZodOptional<z.ZodEnum<{
|
|
85
|
+
hachure: "hachure";
|
|
86
|
+
"cross-hatch": "cross-hatch";
|
|
87
|
+
solid: "solid";
|
|
88
|
+
}>>;
|
|
89
|
+
strokeWidth: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
strokeStyle: z.ZodOptional<z.ZodEnum<{
|
|
91
|
+
solid: "solid";
|
|
92
|
+
dashed: "dashed";
|
|
93
|
+
dotted: "dotted";
|
|
94
|
+
}>>;
|
|
95
|
+
roughness: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
angle: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
startId: z.ZodOptional<z.ZodString>;
|
|
99
|
+
endId: z.ZodOptional<z.ZodString>;
|
|
100
|
+
points: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
|
|
101
|
+
children: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
102
|
+
name: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, z.core.$strip>>>;
|
|
104
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
105
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
export declare const excalidrawListDrawingsParamsSchema: z.ZodObject<{}, z.core.$strip>;
|
|
108
|
+
export declare const excalidrawReadSceneParamsSchema: z.ZodObject<{
|
|
109
|
+
blockId: z.ZodString;
|
|
110
|
+
detail: z.ZodOptional<z.ZodEnum<{
|
|
111
|
+
summary: "summary";
|
|
112
|
+
full: "full";
|
|
113
|
+
}>>;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
export declare const excalidrawAddElementsParamsSchema: z.ZodObject<{
|
|
116
|
+
blockId: z.ZodString;
|
|
117
|
+
elements: z.ZodArray<z.ZodObject<{
|
|
118
|
+
type: z.ZodEnum<{
|
|
119
|
+
rectangle: "rectangle";
|
|
120
|
+
ellipse: "ellipse";
|
|
121
|
+
diamond: "diamond";
|
|
122
|
+
text: "text";
|
|
123
|
+
arrow: "arrow";
|
|
124
|
+
line: "line";
|
|
125
|
+
frame: "frame";
|
|
126
|
+
}>;
|
|
127
|
+
x: z.ZodNumber;
|
|
128
|
+
y: z.ZodNumber;
|
|
129
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
id: z.ZodOptional<z.ZodString>;
|
|
132
|
+
text: z.ZodOptional<z.ZodString>;
|
|
133
|
+
label: z.ZodOptional<z.ZodString>;
|
|
134
|
+
fontSize: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
strokeColor: z.ZodOptional<z.ZodString>;
|
|
136
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
137
|
+
fillStyle: z.ZodOptional<z.ZodEnum<{
|
|
138
|
+
hachure: "hachure";
|
|
139
|
+
"cross-hatch": "cross-hatch";
|
|
140
|
+
solid: "solid";
|
|
141
|
+
}>>;
|
|
142
|
+
strokeWidth: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
strokeStyle: z.ZodOptional<z.ZodEnum<{
|
|
144
|
+
solid: "solid";
|
|
145
|
+
dashed: "dashed";
|
|
146
|
+
dotted: "dotted";
|
|
147
|
+
}>>;
|
|
148
|
+
roughness: z.ZodOptional<z.ZodNumber>;
|
|
149
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
angle: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
startId: z.ZodOptional<z.ZodString>;
|
|
152
|
+
endId: z.ZodOptional<z.ZodString>;
|
|
153
|
+
points: z.ZodOptional<z.ZodArray<z.ZodArray<z.ZodNumber>>>;
|
|
154
|
+
children: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
155
|
+
name: z.ZodOptional<z.ZodString>;
|
|
156
|
+
}, z.core.$strip>>;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
export declare const excalidrawUpdateElementsParamsSchema: z.ZodObject<{
|
|
159
|
+
blockId: z.ZodString;
|
|
160
|
+
updates: z.ZodArray<z.ZodObject<{
|
|
161
|
+
id: z.ZodString;
|
|
162
|
+
x: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
y: z.ZodOptional<z.ZodNumber>;
|
|
164
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
165
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
166
|
+
text: z.ZodOptional<z.ZodString>;
|
|
167
|
+
strokeColor: z.ZodOptional<z.ZodString>;
|
|
168
|
+
backgroundColor: z.ZodOptional<z.ZodString>;
|
|
169
|
+
fillStyle: z.ZodOptional<z.ZodEnum<{
|
|
170
|
+
hachure: "hachure";
|
|
171
|
+
"cross-hatch": "cross-hatch";
|
|
172
|
+
solid: "solid";
|
|
173
|
+
}>>;
|
|
174
|
+
strokeWidth: z.ZodOptional<z.ZodNumber>;
|
|
175
|
+
strokeStyle: z.ZodOptional<z.ZodEnum<{
|
|
176
|
+
solid: "solid";
|
|
177
|
+
dashed: "dashed";
|
|
178
|
+
dotted: "dotted";
|
|
179
|
+
}>>;
|
|
180
|
+
opacity: z.ZodOptional<z.ZodNumber>;
|
|
181
|
+
angle: z.ZodOptional<z.ZodNumber>;
|
|
182
|
+
}, z.core.$strip>>;
|
|
183
|
+
}, z.core.$strip>;
|
|
184
|
+
export declare const excalidrawDeleteElementsParamsSchema: z.ZodObject<{
|
|
185
|
+
blockId: z.ZodString;
|
|
186
|
+
elementIds: z.ZodArray<z.ZodString>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
export declare const excalidrawConnectElementsParamsSchema: z.ZodObject<{
|
|
189
|
+
blockId: z.ZodString;
|
|
190
|
+
fromId: z.ZodString;
|
|
191
|
+
toId: z.ZodString;
|
|
192
|
+
label: z.ZodOptional<z.ZodString>;
|
|
193
|
+
strokeColor: z.ZodOptional<z.ZodString>;
|
|
194
|
+
strokeStyle: z.ZodOptional<z.ZodEnum<{
|
|
195
|
+
solid: "solid";
|
|
196
|
+
dashed: "dashed";
|
|
197
|
+
dotted: "dotted";
|
|
198
|
+
}>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
export declare const excalidrawSetAppStateParamsSchema: z.ZodObject<{
|
|
201
|
+
blockId: z.ZodString;
|
|
202
|
+
viewBackgroundColor: z.ZodOptional<z.ZodString>;
|
|
203
|
+
gridSize: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
}, z.core.$strip>;
|
|
205
|
+
export declare const excalidrawResizeParamsSchema: z.ZodObject<{
|
|
206
|
+
blockId: z.ZodString;
|
|
207
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
208
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
209
|
+
}, z.core.$strip>;
|
|
210
|
+
export declare const excalidrawClearSceneParamsSchema: z.ZodObject<{
|
|
211
|
+
blockId: z.ZodString;
|
|
212
|
+
}, z.core.$strip>;
|
|
213
|
+
export declare const excalidrawFromMermaidParamsSchema: z.ZodObject<{
|
|
214
|
+
blockId: z.ZodOptional<z.ZodString>;
|
|
215
|
+
afterId: z.ZodOptional<z.ZodString>;
|
|
216
|
+
mermaid: z.ZodString;
|
|
217
|
+
fontSize: z.ZodOptional<z.ZodNumber>;
|
|
218
|
+
}, z.core.$strip>;
|
|
219
|
+
export type ExcalidrawInsertNodeParams = z.infer<typeof excalidrawInsertNodeParamsSchema>;
|
|
220
|
+
export type ExcalidrawListDrawingsParams = z.infer<typeof excalidrawListDrawingsParamsSchema>;
|
|
221
|
+
export type ExcalidrawReadSceneParams = z.infer<typeof excalidrawReadSceneParamsSchema>;
|
|
222
|
+
export type ExcalidrawAddElementsParams = z.infer<typeof excalidrawAddElementsParamsSchema>;
|
|
223
|
+
export type ExcalidrawUpdateElementsParams = z.infer<typeof excalidrawUpdateElementsParamsSchema>;
|
|
224
|
+
export type ExcalidrawDeleteElementsParams = z.infer<typeof excalidrawDeleteElementsParamsSchema>;
|
|
225
|
+
export type ExcalidrawConnectElementsParams = z.infer<typeof excalidrawConnectElementsParamsSchema>;
|
|
226
|
+
export type ExcalidrawSetAppStateParams = z.infer<typeof excalidrawSetAppStateParamsSchema>;
|
|
227
|
+
export type ExcalidrawResizeParams = z.infer<typeof excalidrawResizeParamsSchema>;
|
|
228
|
+
export type ExcalidrawClearSceneParams = z.infer<typeof excalidrawClearSceneParamsSchema>;
|
|
229
|
+
export type ExcalidrawFromMermaidParams = z.infer<typeof excalidrawFromMermaidParamsSchema>;
|
|
230
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiEhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAqBpE,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgB3C,CAAC;AAEH,eAAO,MAAM,kCAAkC,gCAAe,CAAC;AAE/D,eAAO,MAAM,+BAA+B;;;;;;iBAQ1C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAK5C,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;iBA0B/C,CAAC;AAEH,eAAO,MAAM,oCAAoC;;;iBAK/C,CAAC;AAEH,eAAO,MAAM,qCAAqC;;;;;;;;;;;iBAUhD,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;iBAS5C,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;iBAcvC,CAAC;AAEH,eAAO,MAAM,gCAAgC;;iBAE3C,CAAC;AAEH,eAAO,MAAM,iCAAiC;;;;;iBAoB5C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AACF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,kCAAkC,CAC1C,CAAC;AACF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC;AACF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAClD,OAAO,oCAAoC,CAC5C,CAAC;AACF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAClD,OAAO,oCAAoC,CAC5C,CAAC;AACF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CACnD,OAAO,qCAAqC,CAC7C,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CACpC,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC"}
|
package/lib/schemas.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026-Present Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* BSD 3-Clause License
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* What each Excalidraw tool takes.
|
|
8
|
+
*
|
|
9
|
+
* The element shape here is Excalidraw's own "skeleton" — the reduced form
|
|
10
|
+
* `convertToExcalidrawElements` accepts, where a rectangle is `{type, x, y,
|
|
11
|
+
* width, height}` rather than the thirty-field record the scene stores. That
|
|
12
|
+
* is deliberate: the skeleton is the only part of the drawing format that is
|
|
13
|
+
* meant to be written by hand, and everything it leaves out (seeds, version
|
|
14
|
+
* nonces, fractional indices, binding geometry) is exactly what a model
|
|
15
|
+
* should not be inventing.
|
|
16
|
+
*
|
|
17
|
+
* @module schemas
|
|
18
|
+
*/
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
/** Colours, arrowheads and so on are Excalidraw's own vocabulary. */
|
|
21
|
+
const colorSchema = z
|
|
22
|
+
.string()
|
|
23
|
+
.describe("CSS colour, e.g. '#1e1e1e', '#e03131', 'transparent'");
|
|
24
|
+
/**
|
|
25
|
+
* A shape, as written rather than as stored.
|
|
26
|
+
*
|
|
27
|
+
* Kept deliberately close to Excalidraw's skeleton type: the fields a
|
|
28
|
+
* diagram actually needs, with everything derived left to the converter.
|
|
29
|
+
*/
|
|
30
|
+
export const elementSkeletonSchema = z.object({
|
|
31
|
+
type: z
|
|
32
|
+
.enum(['rectangle', 'ellipse', 'diamond', 'text', 'arrow', 'line', 'frame'])
|
|
33
|
+
.describe('What to draw'),
|
|
34
|
+
x: z.number().describe('Left edge, in scene coordinates'),
|
|
35
|
+
y: z.number().describe('Top edge, in scene coordinates'),
|
|
36
|
+
width: z.number().optional().describe('Width in pixels (shapes only)'),
|
|
37
|
+
height: z.number().optional().describe('Height in pixels (shapes only)'),
|
|
38
|
+
id: z
|
|
39
|
+
.string()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('Your own id for this element, so a later arrow can point at it by name. Any string; Excalidraw keeps it.'),
|
|
42
|
+
text: z.string().optional().describe("The text itself, for type 'text'"),
|
|
43
|
+
label: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Text to put inside the shape. Excalidraw binds it to the shape, so moving the shape moves the label.'),
|
|
47
|
+
fontSize: z
|
|
48
|
+
.number()
|
|
49
|
+
.optional()
|
|
50
|
+
.describe('Font size in pixels, e.g. 16, 20, 28'),
|
|
51
|
+
strokeColor: colorSchema.optional().describe('Outline colour'),
|
|
52
|
+
backgroundColor: colorSchema.optional().describe('Fill colour'),
|
|
53
|
+
fillStyle: z
|
|
54
|
+
.enum(['hachure', 'cross-hatch', 'solid'])
|
|
55
|
+
.optional()
|
|
56
|
+
.describe('How the fill is drawn'),
|
|
57
|
+
strokeWidth: z.number().optional().describe('Outline thickness, 1 | 2 | 4'),
|
|
58
|
+
strokeStyle: z
|
|
59
|
+
.enum(['solid', 'dashed', 'dotted'])
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('Outline style'),
|
|
62
|
+
roughness: z
|
|
63
|
+
.number()
|
|
64
|
+
.optional()
|
|
65
|
+
.describe('0 for architect (clean), 1 for artist, 2 for cartoonist'),
|
|
66
|
+
opacity: z.number().optional().describe('0-100'),
|
|
67
|
+
angle: z.number().optional().describe('Rotation in radians'),
|
|
68
|
+
startId: z
|
|
69
|
+
.string()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("For 'arrow' and 'line': the id of the element the arrow starts at. The arrow stays attached when either element moves."),
|
|
72
|
+
endId: z
|
|
73
|
+
.string()
|
|
74
|
+
.optional()
|
|
75
|
+
.describe("For 'arrow' and 'line': the id of the element the arrow points at."),
|
|
76
|
+
points: z
|
|
77
|
+
.array(z.array(z.number()))
|
|
78
|
+
.optional()
|
|
79
|
+
.describe("For 'arrow' and 'line' without bindings: points relative to x,y, e.g. [[0,0],[120,0]]"),
|
|
80
|
+
children: z
|
|
81
|
+
.array(z.string())
|
|
82
|
+
.optional()
|
|
83
|
+
.describe("For 'frame': the ids of the elements it contains"),
|
|
84
|
+
name: z.string().optional().describe("For 'frame': its name"),
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Where a new drawing goes. In a document, the vocabulary `insertBlock` uses;
|
|
88
|
+
* a host with one place for drawings ignores it.
|
|
89
|
+
*/
|
|
90
|
+
const afterIdSchema = z
|
|
91
|
+
.string()
|
|
92
|
+
.describe("Where to put the drawing: 'TOP' for the beginning of the document, 'BOTTOM' for the end, or the block_id to insert after");
|
|
93
|
+
/**
|
|
94
|
+
* Which drawing a call is about. Named `blockId` because a drawing in a
|
|
95
|
+
* document is a block; a host that keeps drawings elsewhere hands out its own
|
|
96
|
+
* ids under the same name.
|
|
97
|
+
*/
|
|
98
|
+
const blockIdSchema = z
|
|
99
|
+
.string()
|
|
100
|
+
.describe('The id of the drawing, from excalidrawListDrawings');
|
|
101
|
+
export const excalidrawInsertNodeParamsSchema = z.object({
|
|
102
|
+
afterId: afterIdSchema,
|
|
103
|
+
elements: z
|
|
104
|
+
.array(elementSkeletonSchema)
|
|
105
|
+
.optional()
|
|
106
|
+
.describe('The drawing itself. Omit to insert an empty canvas for a person to draw on.'),
|
|
107
|
+
width: z
|
|
108
|
+
.number()
|
|
109
|
+
.optional()
|
|
110
|
+
.describe('Rendered width in pixels. Omit to size to the content.'),
|
|
111
|
+
height: z
|
|
112
|
+
.number()
|
|
113
|
+
.optional()
|
|
114
|
+
.describe('Rendered height in pixels. Omit to size to the content.'),
|
|
115
|
+
});
|
|
116
|
+
export const excalidrawListDrawingsParamsSchema = z.object({});
|
|
117
|
+
export const excalidrawReadSceneParamsSchema = z.object({
|
|
118
|
+
blockId: blockIdSchema,
|
|
119
|
+
detail: z
|
|
120
|
+
.enum(['summary', 'full'])
|
|
121
|
+
.optional()
|
|
122
|
+
.describe("'summary' (default) gives each element's id, type, position, size and text — enough to change it. 'full' gives the raw Excalidraw elements, which is large; ask for it only when you need a field the summary omits."),
|
|
123
|
+
});
|
|
124
|
+
export const excalidrawAddElementsParamsSchema = z.object({
|
|
125
|
+
blockId: blockIdSchema,
|
|
126
|
+
elements: z
|
|
127
|
+
.array(elementSkeletonSchema)
|
|
128
|
+
.describe('The elements to add. Existing elements are left alone.'),
|
|
129
|
+
});
|
|
130
|
+
export const excalidrawUpdateElementsParamsSchema = z.object({
|
|
131
|
+
blockId: blockIdSchema,
|
|
132
|
+
updates: z
|
|
133
|
+
.array(z.object({
|
|
134
|
+
id: z.string().describe('The element id, from excalidrawReadScene'),
|
|
135
|
+
x: z.number().optional(),
|
|
136
|
+
y: z.number().optional(),
|
|
137
|
+
width: z.number().optional(),
|
|
138
|
+
height: z.number().optional(),
|
|
139
|
+
text: z
|
|
140
|
+
.string()
|
|
141
|
+
.optional()
|
|
142
|
+
.describe("New text. On a shape this rewrites the label bound inside it; on a 'text' element it rewrites the element."),
|
|
143
|
+
strokeColor: colorSchema.optional(),
|
|
144
|
+
backgroundColor: colorSchema.optional(),
|
|
145
|
+
fillStyle: z.enum(['hachure', 'cross-hatch', 'solid']).optional(),
|
|
146
|
+
strokeWidth: z.number().optional(),
|
|
147
|
+
strokeStyle: z.enum(['solid', 'dashed', 'dotted']).optional(),
|
|
148
|
+
opacity: z.number().optional().describe('0-100'),
|
|
149
|
+
angle: z.number().optional().describe('Rotation in radians'),
|
|
150
|
+
}))
|
|
151
|
+
.describe('One entry per element to change. Fields left out are kept.'),
|
|
152
|
+
});
|
|
153
|
+
export const excalidrawDeleteElementsParamsSchema = z.object({
|
|
154
|
+
blockId: blockIdSchema,
|
|
155
|
+
elementIds: z
|
|
156
|
+
.array(z.string())
|
|
157
|
+
.describe('The ids to remove, from excalidrawReadScene'),
|
|
158
|
+
});
|
|
159
|
+
export const excalidrawConnectElementsParamsSchema = z.object({
|
|
160
|
+
blockId: blockIdSchema,
|
|
161
|
+
fromId: z.string().describe('The element the arrow starts at'),
|
|
162
|
+
toId: z.string().describe('The element the arrow points at'),
|
|
163
|
+
label: z
|
|
164
|
+
.string()
|
|
165
|
+
.optional()
|
|
166
|
+
.describe('Text to sit on the arrow, e.g. "yes", "then"'),
|
|
167
|
+
strokeColor: colorSchema.optional(),
|
|
168
|
+
strokeStyle: z.enum(['solid', 'dashed', 'dotted']).optional(),
|
|
169
|
+
});
|
|
170
|
+
export const excalidrawSetAppStateParamsSchema = z.object({
|
|
171
|
+
blockId: blockIdSchema,
|
|
172
|
+
viewBackgroundColor: colorSchema
|
|
173
|
+
.optional()
|
|
174
|
+
.describe('The canvas colour behind the drawing'),
|
|
175
|
+
gridSize: z
|
|
176
|
+
.number()
|
|
177
|
+
.optional()
|
|
178
|
+
.describe('Grid spacing in pixels. 0 turns the grid off.'),
|
|
179
|
+
});
|
|
180
|
+
export const excalidrawResizeParamsSchema = z.object({
|
|
181
|
+
blockId: blockIdSchema,
|
|
182
|
+
width: z
|
|
183
|
+
.number()
|
|
184
|
+
.optional()
|
|
185
|
+
.describe('Rendered width in pixels. Omit to go back to sizing by content.'),
|
|
186
|
+
height: z
|
|
187
|
+
.number()
|
|
188
|
+
.optional()
|
|
189
|
+
.describe('Rendered height in pixels. Omit to go back to sizing by content.'),
|
|
190
|
+
});
|
|
191
|
+
export const excalidrawClearSceneParamsSchema = z.object({
|
|
192
|
+
blockId: blockIdSchema,
|
|
193
|
+
});
|
|
194
|
+
export const excalidrawFromMermaidParamsSchema = z.object({
|
|
195
|
+
blockId: blockIdSchema
|
|
196
|
+
.optional()
|
|
197
|
+
.describe('The drawing to replace. Omit to insert a new drawing instead, positioned by afterId.'),
|
|
198
|
+
afterId: afterIdSchema
|
|
199
|
+
.optional()
|
|
200
|
+
.describe("Where a new drawing goes: 'TOP', 'BOTTOM', or a block_id. Ignored when blockId is given."),
|
|
201
|
+
mermaid: z
|
|
202
|
+
.string()
|
|
203
|
+
.describe('Mermaid source. Flowcharts, sequence diagrams and class diagrams convert to real shapes; anything else comes across as an image.'),
|
|
204
|
+
fontSize: z
|
|
205
|
+
.number()
|
|
206
|
+
.optional()
|
|
207
|
+
.describe('Font size for the generated text, in pixels'),
|
|
208
|
+
});
|
|
209
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;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IACvD,OAAO,EAAE,aAAa;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,MAAM,CAAC;IACxD,OAAO,EAAE,aAAa;SACnB,QAAQ,EAAE;SACV,QAAQ,CACP,sFAAsF,CACvF;IACH,OAAO,EAAE,aAAa;SACnB,QAAQ,EAAE;SACV,QAAQ,CACP,0FAA0F,CAC3F;IACH,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,QAAQ,CACP,kIAAkI,CACnI;IACH,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,6CAA6C,CAAC;CAC3D,CAAC,CAAC"}
|
package/lib/tools.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ToolDefinition, ToolExecutor, ToolOperation } from '@datalayer/reactor/tools';
|
|
2
|
+
import type { ExcalidrawToolHandler } from './handlers';
|
|
3
|
+
/** The plugin's short name: the tools bundle's id and the commands' namespace. */
|
|
4
|
+
export declare const EXCALIDRAW_TOOLS_NAME = "excalidraw";
|
|
5
|
+
/** What a host registers with an agent: what exists, and what runs it. */
|
|
6
|
+
export declare const excalidrawTools: {
|
|
7
|
+
name: string;
|
|
8
|
+
definitions: ToolDefinition[];
|
|
9
|
+
operations: Record<string, ToolOperation<unknown, unknown>>;
|
|
10
|
+
};
|
|
11
|
+
/** The reactor command a tool's operation runs as: `excalidraw.excalidrawReadScene`. */
|
|
12
|
+
export declare const excalidrawCommandOf: (operation: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* The executor the operations hand their validated calls to, over a set of
|
|
15
|
+
* handlers. Refuses an operation it has no handler for.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createExcalidrawExecutor(handlers: Record<string, ExcalidrawToolHandler>): ToolExecutor;
|
|
18
|
+
/**
|
|
19
|
+
* The tools as a reactor `AgentTools` bundle: each tool is the plugin's
|
|
20
|
+
* command of its operation, with the tool's name, description and
|
|
21
|
+
* parameters.
|
|
22
|
+
*/
|
|
23
|
+
export declare const EXCALIDRAW_AGENT_TOOLS: import("@datalayer/reactor").AgentToolBundle;
|
|
24
|
+
/**
|
|
25
|
+
* The operation names the three halves disagree about, if any.
|
|
26
|
+
*
|
|
27
|
+
* A definition without an operation is a tool the model can call and nothing
|
|
28
|
+
* answers; an operation without a handler is a call that reaches the executor
|
|
29
|
+
* and finds nothing to run. Neither shows up until an agent tries it, which
|
|
30
|
+
* is far too late — so this is checked in the tests, where it is cheap.
|
|
31
|
+
*/
|
|
32
|
+
export declare function excalidrawToolMismatches(handlers: Record<string, ExcalidrawToolHandler>): string[];
|
|
33
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG5F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAGxD,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,0EAA0E;AAC1E,eAAO,MAAM,eAAe,EAAE;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;CAK7D,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,GAAI,WAAW,MAAM,KAAG,MACf,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAC9C,YAAY,CAUd;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,8CAYjC,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAC9C,MAAM,EAAE,CAuBV"}
|
package/lib/tools.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026-Present Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* BSD 3-Clause License
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The Excalidraw tools, as one thing a host can hand over.
|
|
8
|
+
*
|
|
9
|
+
* Definitions, operations and handlers travel together because they are three
|
|
10
|
+
* views of the same eleven tools, and a set that has drifted — a definition
|
|
11
|
+
* pointing at an operation nobody wrote, a handler nobody advertises — is a
|
|
12
|
+
* tool that fails at call time rather than at build time. Keeping them
|
|
13
|
+
* adjacent is what {@link excalidrawToolMismatches} is able to exploit.
|
|
14
|
+
*
|
|
15
|
+
* @module tools
|
|
16
|
+
*/
|
|
17
|
+
import { defineAgentTools } from '@datalayer/reactor';
|
|
18
|
+
import { excalidrawToolDefinitions } from './definitions.js';
|
|
19
|
+
import { excalidrawToolOperations } from './operations.js';
|
|
20
|
+
/** The plugin's short name: the tools bundle's id and the commands' namespace. */
|
|
21
|
+
export const EXCALIDRAW_TOOLS_NAME = 'excalidraw';
|
|
22
|
+
/** What a host registers with an agent: what exists, and what runs it. */
|
|
23
|
+
export const excalidrawTools = {
|
|
24
|
+
name: EXCALIDRAW_TOOLS_NAME,
|
|
25
|
+
definitions: excalidrawToolDefinitions,
|
|
26
|
+
operations: excalidrawToolOperations,
|
|
27
|
+
};
|
|
28
|
+
/** The reactor command a tool's operation runs as: `excalidraw.excalidrawReadScene`. */
|
|
29
|
+
export const excalidrawCommandOf = (operation) => `${EXCALIDRAW_TOOLS_NAME}.${operation}`;
|
|
30
|
+
/**
|
|
31
|
+
* The executor the operations hand their validated calls to, over a set of
|
|
32
|
+
* handlers. Refuses an operation it has no handler for.
|
|
33
|
+
*/
|
|
34
|
+
export function createExcalidrawExecutor(handlers) {
|
|
35
|
+
return {
|
|
36
|
+
execute: async (operationName, args) => {
|
|
37
|
+
const handler = handlers[operationName];
|
|
38
|
+
if (!handler) {
|
|
39
|
+
throw new Error(`No Excalidraw handler for '${operationName}'.`);
|
|
40
|
+
}
|
|
41
|
+
return handler((args ?? {}));
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The tools as a reactor `AgentTools` bundle: each tool is the plugin's
|
|
47
|
+
* command of its operation, with the tool's name, description and
|
|
48
|
+
* parameters.
|
|
49
|
+
*/
|
|
50
|
+
export const EXCALIDRAW_AGENT_TOOLS = defineAgentTools({
|
|
51
|
+
id: EXCALIDRAW_TOOLS_NAME,
|
|
52
|
+
name: 'Excalidraw',
|
|
53
|
+
description: 'Draw diagrams in Excalidraw: insert a drawing, read it, add, change, connect and delete its shapes, and turn Mermaid source into shapes.',
|
|
54
|
+
plugin: '@datalayer/reactor-excalidraw',
|
|
55
|
+
commands: excalidrawToolDefinitions.map((definition) => ({
|
|
56
|
+
name: definition.name,
|
|
57
|
+
command: excalidrawCommandOf(definition.operation),
|
|
58
|
+
description: definition.description,
|
|
59
|
+
parameters: definition.parameters,
|
|
60
|
+
})),
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* The operation names the three halves disagree about, if any.
|
|
64
|
+
*
|
|
65
|
+
* A definition without an operation is a tool the model can call and nothing
|
|
66
|
+
* answers; an operation without a handler is a call that reaches the executor
|
|
67
|
+
* and finds nothing to run. Neither shows up until an agent tries it, which
|
|
68
|
+
* is far too late — so this is checked in the tests, where it is cheap.
|
|
69
|
+
*/
|
|
70
|
+
export function excalidrawToolMismatches(handlers) {
|
|
71
|
+
const problems = [];
|
|
72
|
+
for (const definition of excalidrawToolDefinitions) {
|
|
73
|
+
if (!excalidrawToolOperations[definition.operation]) {
|
|
74
|
+
problems.push(`${definition.name} points at operation '${definition.operation}', which does not exist`);
|
|
75
|
+
}
|
|
76
|
+
if (!definition.toolReferenceName.startsWith('excalidraw')) {
|
|
77
|
+
problems.push(`${definition.name} is not named for the plugin it belongs to`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (const name of Object.keys(excalidrawToolOperations)) {
|
|
81
|
+
if (!handlers[name]) {
|
|
82
|
+
problems.push(`operation '${name}' has no handler`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
for (const name of Object.keys(handlers)) {
|
|
86
|
+
if (!excalidrawToolOperations[name]) {
|
|
87
|
+
problems.push(`handler '${name}' has no operation`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return problems;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=tools.js.map
|
package/lib/tools.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExD,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAG,YAAY,CAAC;AAElD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,eAAe,GAIxB;IACF,IAAI,EAAE,qBAAqB;IAC3B,WAAW,EAAE,yBAAyB;IACtC,UAAU,EAAE,wBAAwB;CACrC,CAAC;AAEF,wFAAwF;AACxF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAU,EAAE,CAC/D,GAAG,qBAAqB,IAAI,SAAS,EAAE,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAA+C;IAE/C,OAAO;QACL,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE;YACrC,MAAM,OAAO,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I,IAAI,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC;QACzD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,QAAQ,CAAC,IAAI,CAAC,cAAc,IAAI,kBAAkB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,EAAE,CAAC;YACpC,QAAQ,CAAC,IAAI,CAAC,YAAY,IAAI,oBAAoB,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/reactor-excalidraw",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"version": "1.3.10",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/datalayer/reactor.git",
|
|
7
|
+
"directory": "plugins/excalidraw"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"description": "Excalidraw drawings as AI agent tools for a Datalayer Reactor platform: the tool definitions, their schemas and operations, and a pure scene model, over any host that keeps drawings.",
|
|
13
|
+
"license": "BSD-3-Clause",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "lib/index.js",
|
|
16
|
+
"types": "lib/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./lib/index.d.ts",
|
|
20
|
+
"import": "./lib/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"lib"
|
|
25
|
+
],
|
|
26
|
+
"keywords": [
|
|
27
|
+
"datalayer",
|
|
28
|
+
"reactor",
|
|
29
|
+
"plugins",
|
|
30
|
+
"excalidraw",
|
|
31
|
+
"agent",
|
|
32
|
+
"tools"
|
|
33
|
+
],
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"typescript": "5.9.3",
|
|
36
|
+
"zod": "^4.1.13"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.json && node ../../scripts/fully-specify-lib.mjs lib",
|
|
40
|
+
"check:pack": "node ../../scripts/check-npm-pack.mjs",
|
|
41
|
+
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
42
|
+
"clean": "rm -rf lib"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@datalayer/reactor": "^1.3.0",
|
|
46
|
+
"zod": ">=3.23"
|
|
47
|
+
}
|
|
48
|
+
}
|