@xom11/whiteboard 0.10.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/{ExcalidrawWithMenus-EAVPOPJZ.mjs → ExcalidrawWithMenus-KBLDWPM2.mjs} +2 -3
- package/dist/ExcalidrawWithMenus-KBLDWPM2.mjs.map +1 -0
- package/dist/catalog.json +57 -0
- package/dist/{chunk-PWIMZIB6.mjs → chunk-2SKXRBGS.mjs} +7 -8
- package/dist/chunk-2SKXRBGS.mjs.map +1 -0
- package/dist/chunk-33PEN2WC.mjs +57 -0
- package/dist/chunk-33PEN2WC.mjs.map +1 -0
- package/dist/chunk-3KBL77M6.mjs +127 -0
- package/dist/chunk-3KBL77M6.mjs.map +1 -0
- package/dist/chunk-5UTGXHLJ.mjs +57 -0
- package/dist/chunk-5UTGXHLJ.mjs.map +1 -0
- package/dist/chunk-6XUPIGVD.mjs +467 -0
- package/dist/chunk-6XUPIGVD.mjs.map +1 -0
- package/dist/chunk-7WG2KDRF.mjs +28 -0
- package/dist/chunk-7WG2KDRF.mjs.map +1 -0
- package/dist/chunk-FZY33J6Z.mjs +95 -0
- package/dist/chunk-FZY33J6Z.mjs.map +1 -0
- package/dist/chunk-HNQLZIEP.mjs +78 -0
- package/dist/chunk-HNQLZIEP.mjs.map +1 -0
- package/dist/chunk-NVJ7K3DK.mjs +29 -0
- package/dist/chunk-NVJ7K3DK.mjs.map +1 -0
- package/dist/chunk-O4WIZFRQ.mjs +11 -0
- package/dist/chunk-O4WIZFRQ.mjs.map +1 -0
- package/dist/{chunk-YVJP7NRG.mjs → chunk-O6QTYAKE.mjs} +7 -9
- package/dist/chunk-O6QTYAKE.mjs.map +1 -0
- package/dist/chunk-R5FL6S7L.mjs +22 -0
- package/dist/chunk-R5FL6S7L.mjs.map +1 -0
- package/dist/chunk-RBUILBX3.mjs +388 -0
- package/dist/chunk-RBUILBX3.mjs.map +1 -0
- package/dist/chunk-RD34F5PM.mjs +57 -0
- package/dist/chunk-RD34F5PM.mjs.map +1 -0
- package/dist/{chunk-7P7SQFOW.mjs → chunk-RXOFO64U.mjs} +3 -3
- package/dist/chunk-RXOFO64U.mjs.map +1 -0
- package/dist/chunk-TOOHCAWP.mjs +1167 -0
- package/dist/chunk-TOOHCAWP.mjs.map +1 -0
- package/dist/{chunk-C6SCVOMC.mjs → chunk-TQYQVXNW.mjs} +5 -41
- package/dist/chunk-TQYQVXNW.mjs.map +1 -0
- package/dist/chunk-VBJLUHCY.mjs +23 -0
- package/dist/chunk-VBJLUHCY.mjs.map +1 -0
- package/dist/chunk-VRWZILTG.mjs +205 -0
- package/dist/chunk-VRWZILTG.mjs.map +1 -0
- package/dist/chunk-XVSO7FBM.mjs +61 -0
- package/dist/chunk-XVSO7FBM.mjs.map +1 -0
- package/dist/geometry-2d.d.mts +3 -6
- package/dist/geometry-2d.d.ts +3 -6
- package/dist/geometry-2d.js +5069 -2651
- package/dist/geometry-2d.js.map +1 -1
- package/dist/geometry-2d.mjs +8 -4
- package/dist/geometry-3d.d.mts +4 -7
- package/dist/geometry-3d.d.ts +4 -7
- package/dist/geometry-3d.js +3053 -2150
- package/dist/geometry-3d.js.map +1 -1
- package/dist/geometry-3d.mjs +7 -4
- package/dist/graph-2d.d.mts +4 -7
- package/dist/graph-2d.d.ts +4 -7
- package/dist/graph-2d.js +3363 -1670
- package/dist/graph-2d.js.map +1 -1
- package/dist/graph-2d.mjs +10 -3
- package/dist/host-3N4E4KJH.mjs +1142 -0
- package/dist/host-3N4E4KJH.mjs.map +1 -0
- package/dist/{host-Z3TEJKZA.mjs → host-6SNSZ332.mjs} +4 -4
- package/dist/{host-Z3TEJKZA.mjs.map → host-6SNSZ332.mjs.map} +1 -1
- package/dist/host-EVJT3LIF.mjs +3198 -0
- package/dist/host-EVJT3LIF.mjs.map +1 -0
- package/dist/host-HN4X3TBC.mjs +2374 -0
- package/dist/host-HN4X3TBC.mjs.map +1 -0
- package/dist/index.css +4 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +675 -19
- package/dist/index.d.ts +675 -19
- package/dist/index.js +11764 -9417
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1492 -335
- package/dist/index.mjs.map +1 -1
- package/dist/latex.d.mts +3 -4
- package/dist/latex.d.ts +3 -4
- package/dist/latex.js +33 -18
- package/dist/latex.js.map +1 -1
- package/dist/latex.mjs +2 -3
- package/dist/render-OCVGDKK6.mjs +8 -0
- package/dist/render-OCVGDKK6.mjs.map +1 -0
- package/dist/serialize-GKN6OVPM.mjs +6 -0
- package/dist/serialize-GKN6OVPM.mjs.map +1 -0
- package/dist/{types-CinstD7T.d.mts → types-rA4slL08.d.mts} +69 -4
- package/dist/{types-CinstD7T.d.ts → types-rA4slL08.d.ts} +69 -4
- package/package.json +24 -5
- package/dist/ExcalidrawWithMenus-EAVPOPJZ.mjs.map +0 -1
- package/dist/chunk-74VEEZBV.mjs +0 -619
- package/dist/chunk-74VEEZBV.mjs.map +0 -1
- package/dist/chunk-7P7SQFOW.mjs.map +0 -1
- package/dist/chunk-BJTO5JO5.mjs +0 -11
- package/dist/chunk-BJTO5JO5.mjs.map +0 -1
- package/dist/chunk-C6SCVOMC.mjs.map +0 -1
- package/dist/chunk-D257NCQW.mjs +0 -58
- package/dist/chunk-D257NCQW.mjs.map +0 -1
- package/dist/chunk-G7FR3AIV.mjs +0 -193
- package/dist/chunk-G7FR3AIV.mjs.map +0 -1
- package/dist/chunk-HTBLO5JO.mjs +0 -41
- package/dist/chunk-HTBLO5JO.mjs.map +0 -1
- package/dist/chunk-PWIMZIB6.mjs.map +0 -1
- package/dist/chunk-SBDMF4NQ.mjs +0 -212
- package/dist/chunk-SBDMF4NQ.mjs.map +0 -1
- package/dist/chunk-WQOABS6N.mjs +0 -197
- package/dist/chunk-WQOABS6N.mjs.map +0 -1
- package/dist/chunk-YVJP7NRG.mjs.map +0 -1
- package/dist/host-N6ACNJKI.mjs +0 -3226
- package/dist/host-N6ACNJKI.mjs.map +0 -1
- package/dist/host-NKGV6RF2.mjs +0 -1134
- package/dist/host-NKGV6RF2.mjs.map +0 -1
- package/dist/host-XVK7UCRE.mjs +0 -2908
- package/dist/host-XVK7UCRE.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -3,17 +3,18 @@ import { NonDeletedExcalidrawElement } from '@excalidraw/excalidraw/element/type
|
|
|
3
3
|
export { ExcalidrawElement, NonDeletedExcalidrawElement } from '@excalidraw/excalidraw/element/types';
|
|
4
4
|
import { AppState, BinaryFiles } from '@excalidraw/excalidraw/types';
|
|
5
5
|
export { AppState, BinaryFiles } from '@excalidraw/excalidraw/types';
|
|
6
|
-
import { S as StampType } from './types-
|
|
7
|
-
export { B as BaseStampCustomData } from './types-
|
|
6
|
+
import { S as StampType, G as GenerateGeometryFigure, a as State } from './types-rA4slL08.mjs';
|
|
7
|
+
export { A as AiFigureUiResult, B as BaseStampCustomData } from './types-rA4slL08.mjs';
|
|
8
8
|
import { GeometryCustomData } from './geometry-2d.mjs';
|
|
9
|
-
export { geometryStamp
|
|
9
|
+
export { geometryStamp } from './geometry-2d.mjs';
|
|
10
10
|
import { LatexCustomData } from './latex.mjs';
|
|
11
|
-
export {
|
|
11
|
+
export { latexStamp } from './latex.mjs';
|
|
12
12
|
import { Geometry3DCustomData } from './geometry-3d.mjs';
|
|
13
|
-
export { geometry3dStamp
|
|
13
|
+
export { geometry3dStamp } from './geometry-3d.mjs';
|
|
14
14
|
import { Graph2DCustomData } from './graph-2d.mjs';
|
|
15
|
-
export { graph2dStamp
|
|
15
|
+
export { graph2dStamp } from './graph-2d.mjs';
|
|
16
16
|
import { PDFDocumentProxy } from 'pdfjs-dist';
|
|
17
|
+
import { z } from 'zod';
|
|
17
18
|
import 'react';
|
|
18
19
|
|
|
19
20
|
interface SyncableAppState {
|
|
@@ -29,22 +30,44 @@ interface ExcalidrawSceneSnapshot {
|
|
|
29
30
|
appState: SyncableAppState;
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Mô tả 1 stamp trong catalog. Bundle size đo bằng KB (kilobytes) gzip — tính
|
|
35
|
+
* trên file entry `dist/{id}.mjs`. Đây là bound trên: code thực sự nạp khi
|
|
36
|
+
* user dùng stamp có thể nhỏ hơn nếu shared chunks đã load cho stamp khác.
|
|
37
|
+
*/
|
|
38
|
+
interface StampCatalogEntry {
|
|
39
|
+
/** Khớp với `StampType.kind`. Vd 'geometry', 'latex', 'geometry3d', 'graph2d'. */
|
|
40
|
+
id: string;
|
|
41
|
+
/** Tên hiển thị cho admin UI (tiếng Việt). */
|
|
42
|
+
title: string;
|
|
43
|
+
/** Phiên bản schema customData. Bump khi BREAKING change format. */
|
|
44
|
+
version: number;
|
|
45
|
+
/** true nếu stamp chưa production-ready (EXPERIMENTAL_STAMPS). */
|
|
46
|
+
experimental: boolean;
|
|
47
|
+
/** Dependency runtime mà consumer phải cài qua peerDependency. */
|
|
48
|
+
runtimeDeps: ReadonlyArray<string>;
|
|
49
|
+
/** Size dist/{id}.{mjs,css} sau gzip (KB). Populated postbuild. */
|
|
50
|
+
bundleSize: {
|
|
51
|
+
js: number;
|
|
52
|
+
css: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Catalog tĩnh của 4 stamps hiện tại. `bundleSize` ở đây là PLACEHOLDER —
|
|
57
|
+
* `scripts/build-catalog.mjs` sẽ override giá trị này trong `dist/`. Tại
|
|
58
|
+
* source (chạy jest / dev), bundleSize sẽ là 0 — đừng dùng cho quyết định
|
|
59
|
+
* production, chỉ dùng entries trong build artifact.
|
|
60
|
+
*/
|
|
61
|
+
declare const STAMP_CATALOG: ReadonlyArray<StampCatalogEntry>;
|
|
62
|
+
/** Lấy entry theo stamp.kind. Trả null nếu không có. */
|
|
63
|
+
declare function findCatalogEntry(id: string): StampCatalogEntry | null;
|
|
64
|
+
|
|
32
65
|
/** Stamp ổn định, sẵn sàng production. */
|
|
33
66
|
declare const STABLE_STAMPS: ReadonlyArray<StampType>;
|
|
34
67
|
/** Stamp experimental — chưa ổn định cho production. Consumer phải opt-in. */
|
|
35
68
|
declare const EXPERIMENTAL_STAMPS: ReadonlyArray<StampType>;
|
|
36
|
-
/** Tất cả stamp (stable + experimental).
|
|
69
|
+
/** Tất cả stamp (stable + experimental). */
|
|
37
70
|
declare const ALL_STAMPS: ReadonlyArray<StampType>;
|
|
38
|
-
/**
|
|
39
|
-
* Set stamp mặc định cho Whiteboard = ALL_STAMPS (bật tất cả tool).
|
|
40
|
-
* Consumer muốn ẩn experimental: `<Whiteboard stamps={STABLE_STAMPS} />`.
|
|
41
|
-
*
|
|
42
|
-
* Để thêm 1 stamp mới (vd chart):
|
|
43
|
-
* 1. Tạo `src/stamps/chart/index.tsx` export `chartStamp: StampType`.
|
|
44
|
-
* 2. Import + add vào STABLE_STAMPS (production-ready) hoặc
|
|
45
|
-
* EXPERIMENTAL_STAMPS (chưa ổn định) ở file này.
|
|
46
|
-
* 3. Re-export `chartStamp` từ `src/stamps/index.ts` + `src/index.ts`.
|
|
47
|
-
*/
|
|
48
71
|
declare const DEFAULT_STAMPS: ReadonlyArray<StampType>;
|
|
49
72
|
/** Tìm stamp tương ứng với customData của element. null nếu không match. */
|
|
50
73
|
declare function findStampForCustomData(data: unknown, stamps?: ReadonlyArray<StampType>): StampType | null;
|
|
@@ -79,8 +102,29 @@ interface WhiteboardProps {
|
|
|
79
102
|
* `STABLE_STAMPS` để chỉ bật stamp ổn định.
|
|
80
103
|
*/
|
|
81
104
|
stamps?: ReadonlyArray<StampType>;
|
|
105
|
+
/**
|
|
106
|
+
* Snapshot từ server. Precedence: `initialScene` > localStorage > blank.
|
|
107
|
+
* - `undefined` (default) → đọc từ localStorage qua `storageKey`
|
|
108
|
+
* - `null` → explicit blank, bỏ qua localStorage
|
|
109
|
+
* - object → dùng làm initialData của Excalidraw, bỏ qua localStorage
|
|
110
|
+
*
|
|
111
|
+
* Dùng để load board từ server. Thường đi cùng `storageKey={null}` để
|
|
112
|
+
* tránh localStorage stale override server data.
|
|
113
|
+
*/
|
|
114
|
+
initialScene?: ExcalidrawSceneSnapshot | null;
|
|
115
|
+
/**
|
|
116
|
+
* Binary files (raster, base64) từ server. Add vào Excalidraw đúng 1 lần
|
|
117
|
+
* khi api ready. Dùng kèm `initialScene` cho flow load-from-server.
|
|
118
|
+
* Nếu cần inject files động về sau, dùng `onApi` rồi gọi `api.addFiles`.
|
|
119
|
+
*/
|
|
120
|
+
initialFiles?: BinaryFiles;
|
|
121
|
+
/**
|
|
122
|
+
* Opt-in bridge for the geometry editor AI prompt. This callback should call
|
|
123
|
+
* `generateFigure()` on a server boundary so API credentials never reach the browser.
|
|
124
|
+
*/
|
|
125
|
+
generateGeometryFigure?: GenerateGeometryFigure;
|
|
82
126
|
}
|
|
83
|
-
declare function Whiteboard({ storageKey, readOnly, onSceneChange, onFilesChange, onApi, langCode, stamps, }: WhiteboardProps): react_jsx_runtime.JSX.Element;
|
|
127
|
+
declare function Whiteboard({ storageKey, readOnly, onSceneChange, onFilesChange, onApi, langCode, stamps, initialScene, initialFiles, generateGeometryFigure, }: WhiteboardProps): react_jsx_runtime.JSX.Element;
|
|
84
128
|
|
|
85
129
|
declare function pickSyncableAppState(s: AppState): SyncableAppState;
|
|
86
130
|
|
|
@@ -233,4 +277,616 @@ declare function insertPdfPages(api: ExApi, source: File | Blob | ArrayBuffer, o
|
|
|
233
277
|
*/
|
|
234
278
|
declare function parsePageRange(input: string, totalPages: number): number[];
|
|
235
279
|
|
|
236
|
-
|
|
280
|
+
declare const DslInput: z.ZodObject<{
|
|
281
|
+
version: z.ZodLiteral<1>;
|
|
282
|
+
points: z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
283
|
+
name: z.ZodString;
|
|
284
|
+
kind: z.ZodLiteral<"free">;
|
|
285
|
+
x: z.ZodNumber;
|
|
286
|
+
y: z.ZodNumber;
|
|
287
|
+
}, "strip", z.ZodTypeAny, {
|
|
288
|
+
kind: "free";
|
|
289
|
+
y: number;
|
|
290
|
+
x: number;
|
|
291
|
+
name: string;
|
|
292
|
+
}, {
|
|
293
|
+
kind: "free";
|
|
294
|
+
y: number;
|
|
295
|
+
x: number;
|
|
296
|
+
name: string;
|
|
297
|
+
}>, z.ZodObject<{
|
|
298
|
+
name: z.ZodString;
|
|
299
|
+
kind: z.ZodLiteral<"midpoint">;
|
|
300
|
+
p1: z.ZodString;
|
|
301
|
+
p2: z.ZodString;
|
|
302
|
+
}, "strip", z.ZodTypeAny, {
|
|
303
|
+
kind: "midpoint";
|
|
304
|
+
name: string;
|
|
305
|
+
p1: string;
|
|
306
|
+
p2: string;
|
|
307
|
+
}, {
|
|
308
|
+
kind: "midpoint";
|
|
309
|
+
name: string;
|
|
310
|
+
p1: string;
|
|
311
|
+
p2: string;
|
|
312
|
+
}>, z.ZodObject<{
|
|
313
|
+
name: z.ZodString;
|
|
314
|
+
kind: z.ZodLiteral<"onSegment">;
|
|
315
|
+
segmentId: z.ZodString;
|
|
316
|
+
t: z.ZodNumber;
|
|
317
|
+
}, "strip", z.ZodTypeAny, {
|
|
318
|
+
kind: "onSegment";
|
|
319
|
+
name: string;
|
|
320
|
+
t: number;
|
|
321
|
+
segmentId: string;
|
|
322
|
+
}, {
|
|
323
|
+
kind: "onSegment";
|
|
324
|
+
name: string;
|
|
325
|
+
t: number;
|
|
326
|
+
segmentId: string;
|
|
327
|
+
}>, z.ZodObject<{
|
|
328
|
+
name: z.ZodString;
|
|
329
|
+
kind: z.ZodLiteral<"onLine">;
|
|
330
|
+
lineId: z.ZodString;
|
|
331
|
+
t: z.ZodNumber;
|
|
332
|
+
}, "strip", z.ZodTypeAny, {
|
|
333
|
+
kind: "onLine";
|
|
334
|
+
name: string;
|
|
335
|
+
t: number;
|
|
336
|
+
lineId: string;
|
|
337
|
+
}, {
|
|
338
|
+
kind: "onLine";
|
|
339
|
+
name: string;
|
|
340
|
+
t: number;
|
|
341
|
+
lineId: string;
|
|
342
|
+
}>, z.ZodObject<{
|
|
343
|
+
name: z.ZodString;
|
|
344
|
+
kind: z.ZodLiteral<"onCircle">;
|
|
345
|
+
circleId: z.ZodString;
|
|
346
|
+
theta: z.ZodNumber;
|
|
347
|
+
}, "strip", z.ZodTypeAny, {
|
|
348
|
+
kind: "onCircle";
|
|
349
|
+
name: string;
|
|
350
|
+
theta: number;
|
|
351
|
+
circleId: string;
|
|
352
|
+
}, {
|
|
353
|
+
kind: "onCircle";
|
|
354
|
+
name: string;
|
|
355
|
+
theta: number;
|
|
356
|
+
circleId: string;
|
|
357
|
+
}>, z.ZodObject<{
|
|
358
|
+
name: z.ZodString;
|
|
359
|
+
kind: z.ZodLiteral<"perpFoot">;
|
|
360
|
+
from: z.ZodString;
|
|
361
|
+
onLine: z.ZodString;
|
|
362
|
+
}, "strip", z.ZodTypeAny, {
|
|
363
|
+
kind: "perpFoot";
|
|
364
|
+
onLine: string;
|
|
365
|
+
from: string;
|
|
366
|
+
name: string;
|
|
367
|
+
}, {
|
|
368
|
+
kind: "perpFoot";
|
|
369
|
+
onLine: string;
|
|
370
|
+
from: string;
|
|
371
|
+
name: string;
|
|
372
|
+
}>, z.ZodObject<{
|
|
373
|
+
name: z.ZodString;
|
|
374
|
+
kind: z.ZodLiteral<"circumcenter">;
|
|
375
|
+
vertices: z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString], null>;
|
|
376
|
+
}, "strip", z.ZodTypeAny, {
|
|
377
|
+
kind: "circumcenter";
|
|
378
|
+
name: string;
|
|
379
|
+
vertices: [string, string, string];
|
|
380
|
+
}, {
|
|
381
|
+
kind: "circumcenter";
|
|
382
|
+
name: string;
|
|
383
|
+
vertices: [string, string, string];
|
|
384
|
+
}>, z.ZodObject<{
|
|
385
|
+
name: z.ZodString;
|
|
386
|
+
kind: z.ZodLiteral<"incenter">;
|
|
387
|
+
vertices: z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString], null>;
|
|
388
|
+
}, "strip", z.ZodTypeAny, {
|
|
389
|
+
kind: "incenter";
|
|
390
|
+
name: string;
|
|
391
|
+
vertices: [string, string, string];
|
|
392
|
+
}, {
|
|
393
|
+
kind: "incenter";
|
|
394
|
+
name: string;
|
|
395
|
+
vertices: [string, string, string];
|
|
396
|
+
}>, z.ZodObject<{
|
|
397
|
+
name: z.ZodString;
|
|
398
|
+
kind: z.ZodLiteral<"centroid">;
|
|
399
|
+
vertices: z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString], null>;
|
|
400
|
+
}, "strip", z.ZodTypeAny, {
|
|
401
|
+
kind: "centroid";
|
|
402
|
+
name: string;
|
|
403
|
+
vertices: [string, string, string];
|
|
404
|
+
}, {
|
|
405
|
+
kind: "centroid";
|
|
406
|
+
name: string;
|
|
407
|
+
vertices: [string, string, string];
|
|
408
|
+
}>, z.ZodObject<{
|
|
409
|
+
name: z.ZodString;
|
|
410
|
+
kind: z.ZodLiteral<"orthocenter">;
|
|
411
|
+
vertices: z.ZodTuple<[z.ZodString, z.ZodString, z.ZodString], null>;
|
|
412
|
+
}, "strip", z.ZodTypeAny, {
|
|
413
|
+
kind: "orthocenter";
|
|
414
|
+
name: string;
|
|
415
|
+
vertices: [string, string, string];
|
|
416
|
+
}, {
|
|
417
|
+
kind: "orthocenter";
|
|
418
|
+
name: string;
|
|
419
|
+
vertices: [string, string, string];
|
|
420
|
+
}>, z.ZodObject<{
|
|
421
|
+
name: z.ZodString;
|
|
422
|
+
kind: z.ZodLiteral<"intersection">;
|
|
423
|
+
ref1: z.ZodString;
|
|
424
|
+
ref2: z.ZodString;
|
|
425
|
+
branch: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>]>>;
|
|
426
|
+
}, "strip", z.ZodTypeAny, {
|
|
427
|
+
kind: "intersection";
|
|
428
|
+
name: string;
|
|
429
|
+
ref1: string;
|
|
430
|
+
ref2: string;
|
|
431
|
+
branch?: 0 | 1 | undefined;
|
|
432
|
+
}, {
|
|
433
|
+
kind: "intersection";
|
|
434
|
+
name: string;
|
|
435
|
+
ref1: string;
|
|
436
|
+
ref2: string;
|
|
437
|
+
branch?: 0 | 1 | undefined;
|
|
438
|
+
}>]>, "many">;
|
|
439
|
+
shapes: z.ZodDefault<z.ZodArray<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
440
|
+
name: z.ZodString;
|
|
441
|
+
kind: z.ZodLiteral<"segment">;
|
|
442
|
+
p1: z.ZodString;
|
|
443
|
+
p2: z.ZodString;
|
|
444
|
+
}, "strip", z.ZodTypeAny, {
|
|
445
|
+
kind: "segment";
|
|
446
|
+
name: string;
|
|
447
|
+
p1: string;
|
|
448
|
+
p2: string;
|
|
449
|
+
}, {
|
|
450
|
+
kind: "segment";
|
|
451
|
+
name: string;
|
|
452
|
+
p1: string;
|
|
453
|
+
p2: string;
|
|
454
|
+
}>, z.ZodObject<{
|
|
455
|
+
name: z.ZodString;
|
|
456
|
+
kind: z.ZodLiteral<"line">;
|
|
457
|
+
p1: z.ZodString;
|
|
458
|
+
p2: z.ZodString;
|
|
459
|
+
}, "strip", z.ZodTypeAny, {
|
|
460
|
+
kind: "line";
|
|
461
|
+
name: string;
|
|
462
|
+
p1: string;
|
|
463
|
+
p2: string;
|
|
464
|
+
}, {
|
|
465
|
+
kind: "line";
|
|
466
|
+
name: string;
|
|
467
|
+
p1: string;
|
|
468
|
+
p2: string;
|
|
469
|
+
}>, z.ZodObject<{
|
|
470
|
+
name: z.ZodString;
|
|
471
|
+
kind: z.ZodLiteral<"ray">;
|
|
472
|
+
origin: z.ZodString;
|
|
473
|
+
through: z.ZodString;
|
|
474
|
+
}, "strip", z.ZodTypeAny, {
|
|
475
|
+
kind: "ray";
|
|
476
|
+
name: string;
|
|
477
|
+
origin: string;
|
|
478
|
+
through: string;
|
|
479
|
+
}, {
|
|
480
|
+
kind: "ray";
|
|
481
|
+
name: string;
|
|
482
|
+
origin: string;
|
|
483
|
+
through: string;
|
|
484
|
+
}>, z.ZodObject<{
|
|
485
|
+
name: z.ZodString;
|
|
486
|
+
kind: z.ZodLiteral<"polygon">;
|
|
487
|
+
vertices: z.ZodArray<z.ZodString, "many">;
|
|
488
|
+
}, "strip", z.ZodTypeAny, {
|
|
489
|
+
kind: "polygon";
|
|
490
|
+
name: string;
|
|
491
|
+
vertices: string[];
|
|
492
|
+
}, {
|
|
493
|
+
kind: "polygon";
|
|
494
|
+
name: string;
|
|
495
|
+
vertices: string[];
|
|
496
|
+
}>, z.ZodObject<{
|
|
497
|
+
name: z.ZodString;
|
|
498
|
+
kind: z.ZodLiteral<"perpendicular">;
|
|
499
|
+
throughPoint: z.ZodString;
|
|
500
|
+
toLine: z.ZodString;
|
|
501
|
+
}, "strip", z.ZodTypeAny, {
|
|
502
|
+
kind: "perpendicular";
|
|
503
|
+
name: string;
|
|
504
|
+
throughPoint: string;
|
|
505
|
+
toLine: string;
|
|
506
|
+
}, {
|
|
507
|
+
kind: "perpendicular";
|
|
508
|
+
name: string;
|
|
509
|
+
throughPoint: string;
|
|
510
|
+
toLine: string;
|
|
511
|
+
}>, z.ZodObject<{
|
|
512
|
+
name: z.ZodString;
|
|
513
|
+
kind: z.ZodLiteral<"parallel">;
|
|
514
|
+
throughPoint: z.ZodString;
|
|
515
|
+
toLine: z.ZodString;
|
|
516
|
+
}, "strip", z.ZodTypeAny, {
|
|
517
|
+
kind: "parallel";
|
|
518
|
+
name: string;
|
|
519
|
+
throughPoint: string;
|
|
520
|
+
toLine: string;
|
|
521
|
+
}, {
|
|
522
|
+
kind: "parallel";
|
|
523
|
+
name: string;
|
|
524
|
+
throughPoint: string;
|
|
525
|
+
toLine: string;
|
|
526
|
+
}>, z.ZodObject<{
|
|
527
|
+
name: z.ZodString;
|
|
528
|
+
kind: z.ZodLiteral<"perpBisector">;
|
|
529
|
+
p1: z.ZodString;
|
|
530
|
+
p2: z.ZodString;
|
|
531
|
+
}, "strip", z.ZodTypeAny, {
|
|
532
|
+
kind: "perpBisector";
|
|
533
|
+
name: string;
|
|
534
|
+
p1: string;
|
|
535
|
+
p2: string;
|
|
536
|
+
}, {
|
|
537
|
+
kind: "perpBisector";
|
|
538
|
+
name: string;
|
|
539
|
+
p1: string;
|
|
540
|
+
p2: string;
|
|
541
|
+
}>, z.ZodObject<{
|
|
542
|
+
name: z.ZodString;
|
|
543
|
+
kind: z.ZodLiteral<"angleBisector">;
|
|
544
|
+
p1: z.ZodString;
|
|
545
|
+
vertex: z.ZodString;
|
|
546
|
+
p2: z.ZodString;
|
|
547
|
+
}, "strip", z.ZodTypeAny, {
|
|
548
|
+
kind: "angleBisector";
|
|
549
|
+
name: string;
|
|
550
|
+
p1: string;
|
|
551
|
+
p2: string;
|
|
552
|
+
vertex: string;
|
|
553
|
+
}, {
|
|
554
|
+
kind: "angleBisector";
|
|
555
|
+
name: string;
|
|
556
|
+
p1: string;
|
|
557
|
+
p2: string;
|
|
558
|
+
vertex: string;
|
|
559
|
+
}>, z.ZodObject<{
|
|
560
|
+
name: z.ZodString;
|
|
561
|
+
kind: z.ZodLiteral<"tangent">;
|
|
562
|
+
throughPoint: z.ZodString;
|
|
563
|
+
toCircle: z.ZodString;
|
|
564
|
+
branch: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<"on">]>>;
|
|
565
|
+
}, "strip", z.ZodTypeAny, {
|
|
566
|
+
kind: "tangent";
|
|
567
|
+
name: string;
|
|
568
|
+
throughPoint: string;
|
|
569
|
+
toCircle: string;
|
|
570
|
+
branch?: 0 | 1 | "on" | undefined;
|
|
571
|
+
}, {
|
|
572
|
+
kind: "tangent";
|
|
573
|
+
name: string;
|
|
574
|
+
throughPoint: string;
|
|
575
|
+
toCircle: string;
|
|
576
|
+
branch?: 0 | 1 | "on" | undefined;
|
|
577
|
+
}>, z.ZodObject<{
|
|
578
|
+
name: z.ZodString;
|
|
579
|
+
kind: z.ZodLiteral<"circleCP">;
|
|
580
|
+
center: z.ZodString;
|
|
581
|
+
surfacePoint: z.ZodString;
|
|
582
|
+
}, "strip", z.ZodTypeAny, {
|
|
583
|
+
kind: "circleCP";
|
|
584
|
+
name: string;
|
|
585
|
+
center: string;
|
|
586
|
+
surfacePoint: string;
|
|
587
|
+
}, {
|
|
588
|
+
kind: "circleCP";
|
|
589
|
+
name: string;
|
|
590
|
+
center: string;
|
|
591
|
+
surfacePoint: string;
|
|
592
|
+
}>, z.ZodObject<{
|
|
593
|
+
name: z.ZodString;
|
|
594
|
+
kind: z.ZodLiteral<"circle3">;
|
|
595
|
+
p1: z.ZodString;
|
|
596
|
+
p2: z.ZodString;
|
|
597
|
+
p3: z.ZodString;
|
|
598
|
+
}, "strip", z.ZodTypeAny, {
|
|
599
|
+
kind: "circle3";
|
|
600
|
+
name: string;
|
|
601
|
+
p1: string;
|
|
602
|
+
p2: string;
|
|
603
|
+
p3: string;
|
|
604
|
+
}, {
|
|
605
|
+
kind: "circle3";
|
|
606
|
+
name: string;
|
|
607
|
+
p1: string;
|
|
608
|
+
p2: string;
|
|
609
|
+
p3: string;
|
|
610
|
+
}>]>, "many">>;
|
|
611
|
+
}, "strip", z.ZodTypeAny, {
|
|
612
|
+
version: 1;
|
|
613
|
+
points: ({
|
|
614
|
+
kind: "free";
|
|
615
|
+
y: number;
|
|
616
|
+
x: number;
|
|
617
|
+
name: string;
|
|
618
|
+
} | {
|
|
619
|
+
kind: "midpoint";
|
|
620
|
+
name: string;
|
|
621
|
+
p1: string;
|
|
622
|
+
p2: string;
|
|
623
|
+
} | {
|
|
624
|
+
kind: "onSegment";
|
|
625
|
+
name: string;
|
|
626
|
+
t: number;
|
|
627
|
+
segmentId: string;
|
|
628
|
+
} | {
|
|
629
|
+
kind: "onLine";
|
|
630
|
+
name: string;
|
|
631
|
+
t: number;
|
|
632
|
+
lineId: string;
|
|
633
|
+
} | {
|
|
634
|
+
kind: "onCircle";
|
|
635
|
+
name: string;
|
|
636
|
+
theta: number;
|
|
637
|
+
circleId: string;
|
|
638
|
+
} | {
|
|
639
|
+
kind: "perpFoot";
|
|
640
|
+
onLine: string;
|
|
641
|
+
from: string;
|
|
642
|
+
name: string;
|
|
643
|
+
} | {
|
|
644
|
+
kind: "circumcenter";
|
|
645
|
+
name: string;
|
|
646
|
+
vertices: [string, string, string];
|
|
647
|
+
} | {
|
|
648
|
+
kind: "incenter";
|
|
649
|
+
name: string;
|
|
650
|
+
vertices: [string, string, string];
|
|
651
|
+
} | {
|
|
652
|
+
kind: "centroid";
|
|
653
|
+
name: string;
|
|
654
|
+
vertices: [string, string, string];
|
|
655
|
+
} | {
|
|
656
|
+
kind: "orthocenter";
|
|
657
|
+
name: string;
|
|
658
|
+
vertices: [string, string, string];
|
|
659
|
+
} | {
|
|
660
|
+
kind: "intersection";
|
|
661
|
+
name: string;
|
|
662
|
+
ref1: string;
|
|
663
|
+
ref2: string;
|
|
664
|
+
branch?: 0 | 1 | undefined;
|
|
665
|
+
})[];
|
|
666
|
+
shapes: ({
|
|
667
|
+
kind: "segment";
|
|
668
|
+
name: string;
|
|
669
|
+
p1: string;
|
|
670
|
+
p2: string;
|
|
671
|
+
} | {
|
|
672
|
+
kind: "line";
|
|
673
|
+
name: string;
|
|
674
|
+
p1: string;
|
|
675
|
+
p2: string;
|
|
676
|
+
} | {
|
|
677
|
+
kind: "ray";
|
|
678
|
+
name: string;
|
|
679
|
+
origin: string;
|
|
680
|
+
through: string;
|
|
681
|
+
} | {
|
|
682
|
+
kind: "polygon";
|
|
683
|
+
name: string;
|
|
684
|
+
vertices: string[];
|
|
685
|
+
} | {
|
|
686
|
+
kind: "perpendicular";
|
|
687
|
+
name: string;
|
|
688
|
+
throughPoint: string;
|
|
689
|
+
toLine: string;
|
|
690
|
+
} | {
|
|
691
|
+
kind: "parallel";
|
|
692
|
+
name: string;
|
|
693
|
+
throughPoint: string;
|
|
694
|
+
toLine: string;
|
|
695
|
+
} | {
|
|
696
|
+
kind: "perpBisector";
|
|
697
|
+
name: string;
|
|
698
|
+
p1: string;
|
|
699
|
+
p2: string;
|
|
700
|
+
} | {
|
|
701
|
+
kind: "angleBisector";
|
|
702
|
+
name: string;
|
|
703
|
+
p1: string;
|
|
704
|
+
p2: string;
|
|
705
|
+
vertex: string;
|
|
706
|
+
} | {
|
|
707
|
+
kind: "tangent";
|
|
708
|
+
name: string;
|
|
709
|
+
throughPoint: string;
|
|
710
|
+
toCircle: string;
|
|
711
|
+
branch?: 0 | 1 | "on" | undefined;
|
|
712
|
+
} | {
|
|
713
|
+
kind: "circleCP";
|
|
714
|
+
name: string;
|
|
715
|
+
center: string;
|
|
716
|
+
surfacePoint: string;
|
|
717
|
+
} | {
|
|
718
|
+
kind: "circle3";
|
|
719
|
+
name: string;
|
|
720
|
+
p1: string;
|
|
721
|
+
p2: string;
|
|
722
|
+
p3: string;
|
|
723
|
+
})[];
|
|
724
|
+
}, {
|
|
725
|
+
version: 1;
|
|
726
|
+
points: ({
|
|
727
|
+
kind: "free";
|
|
728
|
+
y: number;
|
|
729
|
+
x: number;
|
|
730
|
+
name: string;
|
|
731
|
+
} | {
|
|
732
|
+
kind: "midpoint";
|
|
733
|
+
name: string;
|
|
734
|
+
p1: string;
|
|
735
|
+
p2: string;
|
|
736
|
+
} | {
|
|
737
|
+
kind: "onSegment";
|
|
738
|
+
name: string;
|
|
739
|
+
t: number;
|
|
740
|
+
segmentId: string;
|
|
741
|
+
} | {
|
|
742
|
+
kind: "onLine";
|
|
743
|
+
name: string;
|
|
744
|
+
t: number;
|
|
745
|
+
lineId: string;
|
|
746
|
+
} | {
|
|
747
|
+
kind: "onCircle";
|
|
748
|
+
name: string;
|
|
749
|
+
theta: number;
|
|
750
|
+
circleId: string;
|
|
751
|
+
} | {
|
|
752
|
+
kind: "perpFoot";
|
|
753
|
+
onLine: string;
|
|
754
|
+
from: string;
|
|
755
|
+
name: string;
|
|
756
|
+
} | {
|
|
757
|
+
kind: "circumcenter";
|
|
758
|
+
name: string;
|
|
759
|
+
vertices: [string, string, string];
|
|
760
|
+
} | {
|
|
761
|
+
kind: "incenter";
|
|
762
|
+
name: string;
|
|
763
|
+
vertices: [string, string, string];
|
|
764
|
+
} | {
|
|
765
|
+
kind: "centroid";
|
|
766
|
+
name: string;
|
|
767
|
+
vertices: [string, string, string];
|
|
768
|
+
} | {
|
|
769
|
+
kind: "orthocenter";
|
|
770
|
+
name: string;
|
|
771
|
+
vertices: [string, string, string];
|
|
772
|
+
} | {
|
|
773
|
+
kind: "intersection";
|
|
774
|
+
name: string;
|
|
775
|
+
ref1: string;
|
|
776
|
+
ref2: string;
|
|
777
|
+
branch?: 0 | 1 | undefined;
|
|
778
|
+
})[];
|
|
779
|
+
shapes?: ({
|
|
780
|
+
kind: "segment";
|
|
781
|
+
name: string;
|
|
782
|
+
p1: string;
|
|
783
|
+
p2: string;
|
|
784
|
+
} | {
|
|
785
|
+
kind: "line";
|
|
786
|
+
name: string;
|
|
787
|
+
p1: string;
|
|
788
|
+
p2: string;
|
|
789
|
+
} | {
|
|
790
|
+
kind: "ray";
|
|
791
|
+
name: string;
|
|
792
|
+
origin: string;
|
|
793
|
+
through: string;
|
|
794
|
+
} | {
|
|
795
|
+
kind: "polygon";
|
|
796
|
+
name: string;
|
|
797
|
+
vertices: string[];
|
|
798
|
+
} | {
|
|
799
|
+
kind: "perpendicular";
|
|
800
|
+
name: string;
|
|
801
|
+
throughPoint: string;
|
|
802
|
+
toLine: string;
|
|
803
|
+
} | {
|
|
804
|
+
kind: "parallel";
|
|
805
|
+
name: string;
|
|
806
|
+
throughPoint: string;
|
|
807
|
+
toLine: string;
|
|
808
|
+
} | {
|
|
809
|
+
kind: "perpBisector";
|
|
810
|
+
name: string;
|
|
811
|
+
p1: string;
|
|
812
|
+
p2: string;
|
|
813
|
+
} | {
|
|
814
|
+
kind: "angleBisector";
|
|
815
|
+
name: string;
|
|
816
|
+
p1: string;
|
|
817
|
+
p2: string;
|
|
818
|
+
vertex: string;
|
|
819
|
+
} | {
|
|
820
|
+
kind: "tangent";
|
|
821
|
+
name: string;
|
|
822
|
+
throughPoint: string;
|
|
823
|
+
toCircle: string;
|
|
824
|
+
branch?: 0 | 1 | "on" | undefined;
|
|
825
|
+
} | {
|
|
826
|
+
kind: "circleCP";
|
|
827
|
+
name: string;
|
|
828
|
+
center: string;
|
|
829
|
+
surfacePoint: string;
|
|
830
|
+
} | {
|
|
831
|
+
kind: "circle3";
|
|
832
|
+
name: string;
|
|
833
|
+
p1: string;
|
|
834
|
+
p2: string;
|
|
835
|
+
p3: string;
|
|
836
|
+
})[] | undefined;
|
|
837
|
+
}>;
|
|
838
|
+
type DslInputT = z.infer<typeof DslInput>;
|
|
839
|
+
|
|
840
|
+
type TranspileErrorCode = 'SCHEMA' | 'DUPLICATE_NAME' | 'UNKNOWN_REF' | 'KIND_MISMATCH' | 'CYCLE';
|
|
841
|
+
interface TranspileError {
|
|
842
|
+
code: TranspileErrorCode;
|
|
843
|
+
message: string;
|
|
844
|
+
path?: string[];
|
|
845
|
+
hint?: string;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
interface GenerateOptions {
|
|
849
|
+
apiKey: string;
|
|
850
|
+
model?: string;
|
|
851
|
+
maxTokens?: number;
|
|
852
|
+
enableCaching?: boolean;
|
|
853
|
+
signal?: AbortSignal;
|
|
854
|
+
}
|
|
855
|
+
interface TokenUsage {
|
|
856
|
+
inputTokens: number;
|
|
857
|
+
outputTokens: number;
|
|
858
|
+
cacheReadTokens: number;
|
|
859
|
+
cacheCreationTokens: number;
|
|
860
|
+
}
|
|
861
|
+
type GenerateResult = {
|
|
862
|
+
ok: true;
|
|
863
|
+
state: State;
|
|
864
|
+
dsl: DslInputT;
|
|
865
|
+
usage: TokenUsage;
|
|
866
|
+
} | {
|
|
867
|
+
ok: false;
|
|
868
|
+
reason: 'refused';
|
|
869
|
+
message: string;
|
|
870
|
+
usage?: TokenUsage;
|
|
871
|
+
} | {
|
|
872
|
+
ok: false;
|
|
873
|
+
reason: 'parse_error';
|
|
874
|
+
message: string;
|
|
875
|
+
raw?: unknown;
|
|
876
|
+
usage?: TokenUsage;
|
|
877
|
+
} | {
|
|
878
|
+
ok: false;
|
|
879
|
+
reason: 'transpile_error';
|
|
880
|
+
message: string;
|
|
881
|
+
errors: TranspileError[];
|
|
882
|
+
dsl: unknown;
|
|
883
|
+
usage?: TokenUsage;
|
|
884
|
+
} | {
|
|
885
|
+
ok: false;
|
|
886
|
+
reason: 'api_error';
|
|
887
|
+
message: string;
|
|
888
|
+
status?: number;
|
|
889
|
+
};
|
|
890
|
+
declare function generateFigure(problem: string, opts: GenerateOptions): Promise<GenerateResult>;
|
|
891
|
+
|
|
892
|
+
export { ALL_STAMPS, DEFAULT_STAMPS, EXPERIMENTAL_STAMPS, type ExcalidrawSceneSnapshot, GenerateGeometryFigure, type GenerateOptions, type GenerateResult, Geometry3DCustomData, GeometryCustomData, Graph2DCustomData, type InsertPdfPagesOptions, type InsertPdfPagesResult, type InsertRasterizedPagesOptions, type InsertRasterizedPagesResult, LatexCustomData, type RasterizeOptions, type RasterizedPage, STABLE_STAMPS, STAMP_CATALOG, type StampCatalogEntry, type StampCustomData, StampType, type SyncableAppState, type TokenUsage, Whiteboard, type WhiteboardProps, closePdfDocument, configurePdfWorker, findCatalogEntry, findStampForCustomData, generateFigure, insertPdfPages, insertRasterizedPagesIntoScene, isStampElement, loadPdfDocument, parsePageRange, pickSyncableAppState, rasterizePdf, restoreMissingStampFiles };
|