daigram 0.0.0-stage → 0.1.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/LICENSE +661 -0
- package/LICENSE-MIT +21 -0
- package/NOTICE +11 -0
- package/README.md +788 -2
- package/assets/fonts/CascadiaCode-Regular.ttf +0 -0
- package/assets/fonts/Excalifont-Regular.ttf +0 -0
- package/assets/fonts/LICENSES.md +63 -0
- package/assets/fonts/LiberationSans-Regular.ttf +0 -0
- package/assets/fonts/Virgil-Regular.ttf +0 -0
- package/dist/ai/config.d.ts +11 -0
- package/dist/ai/config.d.ts.map +1 -0
- package/dist/ai/config.js +59 -0
- package/dist/ai/config.js.map +1 -0
- package/dist/ai/providers/anthropic.d.ts +3 -0
- package/dist/ai/providers/anthropic.d.ts.map +1 -0
- package/dist/ai/providers/anthropic.js +71 -0
- package/dist/ai/providers/anthropic.js.map +1 -0
- package/dist/ai/providers/openai-compatible.d.ts +3 -0
- package/dist/ai/providers/openai-compatible.d.ts.map +1 -0
- package/dist/ai/providers/openai-compatible.js +95 -0
- package/dist/ai/providers/openai-compatible.js.map +1 -0
- package/dist/ai/request-settings.d.ts +9 -0
- package/dist/ai/request-settings.d.ts.map +1 -0
- package/dist/ai/request-settings.js +56 -0
- package/dist/ai/request-settings.js.map +1 -0
- package/dist/ai/routes.d.ts +7 -0
- package/dist/ai/routes.d.ts.map +1 -0
- package/dist/ai/routes.js +192 -0
- package/dist/ai/routes.js.map +1 -0
- package/dist/ai/runner.d.ts +19 -0
- package/dist/ai/runner.d.ts.map +1 -0
- package/dist/ai/runner.js +77 -0
- package/dist/ai/runner.js.map +1 -0
- package/dist/ai/sse.d.ts +4 -0
- package/dist/ai/sse.d.ts.map +1 -0
- package/dist/ai/sse.js +53 -0
- package/dist/ai/sse.js.map +1 -0
- package/dist/ai/system.d.ts +2 -0
- package/dist/ai/system.d.ts.map +1 -0
- package/dist/ai/system.js +17 -0
- package/dist/ai/system.js.map +1 -0
- package/dist/ai/tools.d.ts +10 -0
- package/dist/ai/tools.d.ts.map +1 -0
- package/dist/ai/tools.js +134 -0
- package/dist/ai/tools.js.map +1 -0
- package/dist/ai/types.d.ts +72 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +2 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +52 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli/args.d.ts +15 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +78 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/commands/ai.d.ts +2 -0
- package/dist/cli/commands/ai.d.ts.map +1 -0
- package/dist/cli/commands/ai.js +45 -0
- package/dist/cli/commands/ai.js.map +1 -0
- package/dist/cli/commands/arrange.d.ts +2 -0
- package/dist/cli/commands/arrange.d.ts.map +1 -0
- package/dist/cli/commands/arrange.js +103 -0
- package/dist/cli/commands/arrange.js.map +1 -0
- package/dist/cli/commands/canvases.d.ts +2 -0
- package/dist/cli/commands/canvases.d.ts.map +1 -0
- package/dist/cli/commands/canvases.js +38 -0
- package/dist/cli/commands/canvases.js.map +1 -0
- package/dist/cli/commands/check.d.ts +2 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +15 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/comment.d.ts +2 -0
- package/dist/cli/commands/comment.d.ts.map +1 -0
- package/dist/cli/commands/comment.js +76 -0
- package/dist/cli/commands/comment.js.map +1 -0
- package/dist/cli/commands/elements.d.ts +8 -0
- package/dist/cli/commands/elements.d.ts.map +1 -0
- package/dist/cli/commands/elements.js +285 -0
- package/dist/cli/commands/elements.js.map +1 -0
- package/dist/cli/commands/frame.d.ts +2 -0
- package/dist/cli/commands/frame.d.ts.map +1 -0
- package/dist/cli/commands/frame.js +58 -0
- package/dist/cli/commands/frame.js.map +1 -0
- package/dist/cli/commands/install-skill.d.ts +2 -0
- package/dist/cli/commands/install-skill.d.ts.map +1 -0
- package/dist/cli/commands/install-skill.js +108 -0
- package/dist/cli/commands/install-skill.js.map +1 -0
- package/dist/cli/commands/layout.d.ts +2 -0
- package/dist/cli/commands/layout.d.ts.map +1 -0
- package/dist/cli/commands/layout.js +15 -0
- package/dist/cli/commands/layout.js.map +1 -0
- package/dist/cli/commands/render.d.ts +2 -0
- package/dist/cli/commands/render.d.ts.map +1 -0
- package/dist/cli/commands/render.js +64 -0
- package/dist/cli/commands/render.js.map +1 -0
- package/dist/cli/commands/scene.d.ts +8 -0
- package/dist/cli/commands/scene.d.ts.map +1 -0
- package/dist/cli/commands/scene.js +147 -0
- package/dist/cli/commands/scene.js.map +1 -0
- package/dist/cli/commands/server.d.ts +4 -0
- package/dist/cli/commands/server.d.ts.map +1 -0
- package/dist/cli/commands/server.js +66 -0
- package/dist/cli/commands/server.js.map +1 -0
- package/dist/cli/commands/snapshot.d.ts +2 -0
- package/dist/cli/commands/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/snapshot.js +41 -0
- package/dist/cli/commands/snapshot.js.map +1 -0
- package/dist/cli/image-options.d.ts +43 -0
- package/dist/cli/image-options.d.ts.map +1 -0
- package/dist/cli/image-options.js +71 -0
- package/dist/cli/image-options.js.map +1 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +115 -0
- package/dist/cli/run.js.map +1 -0
- package/dist/cli/util.d.ts +5 -0
- package/dist/cli/util.d.ts.map +1 -0
- package/dist/cli/util.js +35 -0
- package/dist/cli/util.js.map +1 -0
- package/dist/core/arrow-routing.d.ts +31 -0
- package/dist/core/arrow-routing.d.ts.map +1 -0
- package/dist/core/arrow-routing.js +244 -0
- package/dist/core/arrow-routing.js.map +1 -0
- package/dist/core/bulk-ops.d.ts +55 -0
- package/dist/core/bulk-ops.d.ts.map +1 -0
- package/dist/core/bulk-ops.js +181 -0
- package/dist/core/bulk-ops.js.map +1 -0
- package/dist/core/canvas-client.d.ts +110 -0
- package/dist/core/canvas-client.d.ts.map +1 -0
- package/dist/core/canvas-client.js +416 -0
- package/dist/core/canvas-client.js.map +1 -0
- package/dist/core/canvas-id.d.ts +4 -0
- package/dist/core/canvas-id.d.ts.map +1 -0
- package/dist/core/canvas-id.js +5 -0
- package/dist/core/canvas-id.js.map +1 -0
- package/dist/core/canvas-persistence.d.ts +30 -0
- package/dist/core/canvas-persistence.d.ts.map +1 -0
- package/dist/core/canvas-persistence.js +854 -0
- package/dist/core/canvas-persistence.js.map +1 -0
- package/dist/core/canvas-registry.d.ts +36 -0
- package/dist/core/canvas-registry.d.ts.map +1 -0
- package/dist/core/canvas-registry.js +161 -0
- package/dist/core/canvas-registry.js.map +1 -0
- package/dist/core/canvas-routes.d.ts +5 -0
- package/dist/core/canvas-routes.d.ts.map +1 -0
- package/dist/core/canvas-routes.js +29 -0
- package/dist/core/canvas-routes.js.map +1 -0
- package/dist/core/canvas-state.d.ts +14 -0
- package/dist/core/canvas-state.d.ts.map +1 -0
- package/dist/core/canvas-state.js +20 -0
- package/dist/core/canvas-state.js.map +1 -0
- package/dist/core/canvas.d.ts +13 -0
- package/dist/core/canvas.d.ts.map +1 -0
- package/dist/core/canvas.js +4 -0
- package/dist/core/canvas.js.map +1 -0
- package/dist/core/comment-ops.d.ts +3 -0
- package/dist/core/comment-ops.d.ts.map +1 -0
- package/dist/core/comment-ops.js +36 -0
- package/dist/core/comment-ops.js.map +1 -0
- package/dist/core/comments.d.ts +5 -0
- package/dist/core/comments.d.ts.map +1 -0
- package/dist/core/comments.js +137 -0
- package/dist/core/comments.js.map +1 -0
- package/dist/core/compact.d.ts +13 -0
- package/dist/core/compact.d.ts.map +1 -0
- package/dist/core/compact.js +20 -0
- package/dist/core/compact.js.map +1 -0
- package/dist/core/config.d.ts +8 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +18 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/describe.d.ts +3 -0
- package/dist/core/describe.d.ts.map +1 -0
- package/dist/core/describe.js +94 -0
- package/dist/core/describe.js.map +1 -0
- package/dist/core/design-guide.d.ts +2 -0
- package/dist/core/design-guide.d.ts.map +1 -0
- package/dist/core/design-guide.js +115 -0
- package/dist/core/design-guide.js.map +1 -0
- package/dist/core/diagram-layout.d.ts +64 -0
- package/dist/core/diagram-layout.d.ts.map +1 -0
- package/dist/core/diagram-layout.js +238 -0
- package/dist/core/diagram-layout.js.map +1 -0
- package/dist/core/diagram-ops.d.ts +165 -0
- package/dist/core/diagram-ops.d.ts.map +1 -0
- package/dist/core/diagram-ops.js +46 -0
- package/dist/core/diagram-ops.js.map +1 -0
- package/dist/core/entry.d.ts +3 -0
- package/dist/core/entry.d.ts.map +1 -0
- package/dist/core/entry.js +35 -0
- package/dist/core/entry.js.map +1 -0
- package/dist/core/expand-elements.d.ts +9 -0
- package/dist/core/expand-elements.d.ts.map +1 -0
- package/dist/core/expand-elements.js +277 -0
- package/dist/core/expand-elements.js.map +1 -0
- package/dist/core/frame-ops.d.ts +60 -0
- package/dist/core/frame-ops.d.ts.map +1 -0
- package/dist/core/frame-ops.js +90 -0
- package/dist/core/frame-ops.js.map +1 -0
- package/dist/core/frames.d.ts +31 -0
- package/dist/core/frames.d.ts.map +1 -0
- package/dist/core/frames.js +95 -0
- package/dist/core/frames.js.map +1 -0
- package/dist/core/geometry.d.ts +30 -0
- package/dist/core/geometry.d.ts.map +1 -0
- package/dist/core/geometry.js +167 -0
- package/dist/core/geometry.js.map +1 -0
- package/dist/core/layout-check.d.ts +30 -0
- package/dist/core/layout-check.d.ts.map +1 -0
- package/dist/core/layout-check.js +181 -0
- package/dist/core/layout-check.js.map +1 -0
- package/dist/core/local-origin.d.ts +4 -0
- package/dist/core/local-origin.d.ts.map +1 -0
- package/dist/core/local-origin.js +27 -0
- package/dist/core/local-origin.js.map +1 -0
- package/dist/core/mcp-dispatch.d.ts +9 -0
- package/dist/core/mcp-dispatch.d.ts.map +1 -0
- package/dist/core/mcp-dispatch.js +741 -0
- package/dist/core/mcp-dispatch.js.map +1 -0
- package/dist/core/mcp-http.d.ts +3 -0
- package/dist/core/mcp-http.d.ts.map +1 -0
- package/dist/core/mcp-http.js +38 -0
- package/dist/core/mcp-http.js.map +1 -0
- package/dist/core/mcp-server.d.ts +19 -0
- package/dist/core/mcp-server.d.ts.map +1 -0
- package/dist/core/mcp-server.js +57 -0
- package/dist/core/mcp-server.js.map +1 -0
- package/dist/core/mcp-tools.d.ts +3 -0
- package/dist/core/mcp-tools.d.ts.map +1 -0
- package/dist/core/mcp-tools.js +723 -0
- package/dist/core/mcp-tools.js.map +1 -0
- package/dist/core/normalize.d.ts +26 -0
- package/dist/core/normalize.d.ts.map +1 -0
- package/dist/core/normalize.js +134 -0
- package/dist/core/normalize.js.map +1 -0
- package/dist/core/obsidian-md.d.ts +4 -0
- package/dist/core/obsidian-md.d.ts.map +1 -0
- package/dist/core/obsidian-md.js +227 -0
- package/dist/core/obsidian-md.js.map +1 -0
- package/dist/core/pidfile.d.ts +5 -0
- package/dist/core/pidfile.d.ts.map +1 -0
- package/dist/core/pidfile.js +51 -0
- package/dist/core/pidfile.js.map +1 -0
- package/dist/core/png-scene.d.ts +4 -0
- package/dist/core/png-scene.d.ts.map +1 -0
- package/dist/core/png-scene.js +176 -0
- package/dist/core/png-scene.js.map +1 -0
- package/dist/core/render/excalidraw-node/dom.d.ts +29 -0
- package/dist/core/render/excalidraw-node/dom.d.ts.map +1 -0
- package/dist/core/render/excalidraw-node/dom.js +132 -0
- package/dist/core/render/excalidraw-node/dom.js.map +1 -0
- package/dist/core/render/excalidraw-node/index.d.ts +11 -0
- package/dist/core/render/excalidraw-node/index.d.ts.map +1 -0
- package/dist/core/render/excalidraw-node/index.js +77 -0
- package/dist/core/render/excalidraw-node/index.js.map +1 -0
- package/dist/core/render/fonts.d.ts +34 -0
- package/dist/core/render/fonts.d.ts.map +1 -0
- package/dist/core/render/fonts.js +133 -0
- package/dist/core/render/fonts.js.map +1 -0
- package/dist/core/render/index.d.ts +40 -0
- package/dist/core/render/index.d.ts.map +1 -0
- package/dist/core/render/index.js +135 -0
- package/dist/core/render/index.js.map +1 -0
- package/dist/core/render/png-worker.d.ts +2 -0
- package/dist/core/render/png-worker.d.ts.map +1 -0
- package/dist/core/render/png-worker.js +65 -0
- package/dist/core/render/png-worker.js.map +1 -0
- package/dist/core/render/png.d.ts +15 -0
- package/dist/core/render/png.d.ts.map +1 -0
- package/dist/core/render/png.js +128 -0
- package/dist/core/render/png.js.map +1 -0
- package/dist/core/render/text-metrics.d.ts +2 -0
- package/dist/core/render/text-metrics.d.ts.map +1 -0
- package/dist/core/render/text-metrics.js +136 -0
- package/dist/core/render/text-metrics.js.map +1 -0
- package/dist/core/request-canvas.d.ts +9 -0
- package/dist/core/request-canvas.d.ts.map +1 -0
- package/dist/core/request-canvas.js +2 -0
- package/dist/core/request-canvas.js.map +1 -0
- package/dist/core/request-headers.d.ts +5 -0
- package/dist/core/request-headers.d.ts.map +1 -0
- package/dist/core/request-headers.js +80 -0
- package/dist/core/request-headers.js.map +1 -0
- package/dist/core/scene-input.d.ts +2 -0
- package/dist/core/scene-input.d.ts.map +1 -0
- package/dist/core/scene-input.js +11 -0
- package/dist/core/scene-input.js.map +1 -0
- package/dist/core/scene-io.d.ts +16 -0
- package/dist/core/scene-io.d.ts.map +1 -0
- package/dist/core/scene-io.js +95 -0
- package/dist/core/scene-io.js.map +1 -0
- package/dist/core/share-url.d.ts +3 -0
- package/dist/core/share-url.d.ts.map +1 -0
- package/dist/core/share-url.js +77 -0
- package/dist/core/share-url.js.map +1 -0
- package/dist/core/spawn.d.ts +41 -0
- package/dist/core/spawn.d.ts.map +1 -0
- package/dist/core/spawn.js +153 -0
- package/dist/core/spawn.js.map +1 -0
- package/dist/core/version.d.ts +2 -0
- package/dist/core/version.d.ts.map +1 -0
- package/dist/core/version.js +14 -0
- package/dist/core/version.js.map +1 -0
- package/dist/frontend/assets/Assistant-Bold-gm-uSS1B.woff2 +0 -0
- package/dist/frontend/assets/Assistant-Medium-DrcxCXg3.woff2 +0 -0
- package/dist/frontend/assets/Assistant-Regular-DVxZuzxb.woff2 +0 -0
- package/dist/frontend/assets/Assistant-SemiBold-SCI4bEL9.woff2 +0 -0
- package/dist/frontend/assets/Tableau10-CvOaoHrI.js +1 -0
- package/dist/frontend/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
- package/dist/frontend/assets/abnfDiagram-VCTEODGH-CO_aNPe5.js +1 -0
- package/dist/frontend/assets/advancedFormat-DE2dNp0u.js +1 -0
- package/dist/frontend/assets/ar-SA-G6X2FPQ2-Bq4yiKbc.js +10 -0
- package/dist/frontend/assets/arc--vhPzIZC.js +1 -0
- package/dist/frontend/assets/architectureDiagram-5GKGNRK7-aHYJQElw.js +36 -0
- package/dist/frontend/assets/array-BKyUJesY.js +1 -0
- package/dist/frontend/assets/az-AZ-76LH7QW2-BB3yat67.js +1 -0
- package/dist/frontend/assets/band-dPffDWoQ.js +1 -0
- package/dist/frontend/assets/bg-BG-XCXSNQG7-DmC2FjQc.js +5 -0
- package/dist/frontend/assets/blockDiagram-68f4deed-Bn83vchM.js +118 -0
- package/dist/frontend/assets/blockDiagram-NRAW4CY4-CxaW-TzC.js +129 -0
- package/dist/frontend/assets/bn-BD-2XOGV67Q-DpCbZMS6.js +5 -0
- package/dist/frontend/assets/c4Diagram-15b5d702-Bq7Ko0Vs.js +10 -0
- package/dist/frontend/assets/c4Diagram-UCG6FXSJ-Dh883fAO.js +38 -0
- package/dist/frontend/assets/ca-ES-6MX7JW3Y-CBOshpbV.js +8 -0
- package/dist/frontend/assets/channel-DYvM7vRx.js +1 -0
- package/dist/frontend/assets/chunk-2Q5K7J3B-DaFhLtFc.js +1 -0
- package/dist/frontend/assets/chunk-5VM5RSS4-CyLfaWw7.js +15 -0
- package/dist/frontend/assets/chunk-F27PBJKO-BHNc-edD.js +1 -0
- package/dist/frontend/assets/chunk-G27WJ6UU-BBKiZxqf.js +231 -0
- package/dist/frontend/assets/chunk-JWPE2WC7-7twsn51D.js +1 -0
- package/dist/frontend/assets/chunk-LCL6LL3I-BTwZuXJ6.js +206 -0
- package/dist/frontend/assets/chunk-POPQ4Y6H-CaHDxqyV.js +1 -0
- package/dist/frontend/assets/chunk-SVP7TREG-B8-zByXy.js +88 -0
- package/dist/frontend/assets/chunk-XXDRQBXY-DQLro-7R.js +1 -0
- package/dist/frontend/assets/classDiagram-DTDB5LWJ-Dpwx6IJK.js +1 -0
- package/dist/frontend/assets/classDiagram-d40c83e7-BPxlcZuc.js +2 -0
- package/dist/frontend/assets/classDiagram-v2-JRS7N3AN-Dpwx6IJK.js +1 -0
- package/dist/frontend/assets/classDiagram-v2-d5a6b087-Cyz34qAK.js +2 -0
- package/dist/frontend/assets/clone-Iw0eB1Cb.js +1 -0
- package/dist/frontend/assets/cose-bilkent-JH36ORCC-C4ZX1Xvi.js +1 -0
- package/dist/frontend/assets/createText-d213de94-CDH1rzxH.js +7 -0
- package/dist/frontend/assets/cs-CZ-2BRQDIVT-CGAN69M4.js +11 -0
- package/dist/frontend/assets/cynefin-OW5HDTMX-B8XT9png.js +178 -0
- package/dist/frontend/assets/cynefinDiagram-5FMLGOSQ-COTZjqlj.js +62 -0
- package/dist/frontend/assets/cytoscape-cose-bilkent-D4yGolDn.js +1 -0
- package/dist/frontend/assets/cytoscape.esm-BjAbmLdb.js +331 -0
- package/dist/frontend/assets/da-DK-5WZEPLOC-FIDoeOAn.js +5 -0
- package/dist/frontend/assets/dagre-3AP2YEHR-v8EtxNwx.js +4 -0
- package/dist/frontend/assets/de-DE-XR44H4JA-Hquyrt1G.js +8 -0
- package/dist/frontend/assets/defaultLocale-C4B-KCzX.js +1 -0
- package/dist/frontend/assets/diagram-S7CK7UJ4-BiwOlZBI.js +30 -0
- package/dist/frontend/assets/diagram-UQ7AKVKN-DIfzNs7s.js +41 -0
- package/dist/frontend/assets/diagram-VSXAHHWV-kKkEHy5z.js +3 -0
- package/dist/frontend/assets/diagram-VX7I27RA-zTp2qGKo.js +24 -0
- package/dist/frontend/assets/diagram-Z3DM3KII-hUxSr-QT.js +24 -0
- package/dist/frontend/assets/directory-open-01563666-DWU9wJ6I.js +1 -0
- package/dist/frontend/assets/directory-open-4ed118d0-CunoC1EB.js +1 -0
- package/dist/frontend/assets/ebnfDiagram-PWID7BFC-CRwXBVzS.js +1 -0
- package/dist/frontend/assets/edges-332bd1c7-CbPhghy3.js +4 -0
- package/dist/frontend/assets/el-GR-BZB4AONW-CWRJJANX.js +10 -0
- package/dist/frontend/assets/erDiagram-880f2ed8-CY1dU-f9.js +51 -0
- package/dist/frontend/assets/erDiagram-SSCWMZ5O-BfDW8Lxf.js +99 -0
- package/dist/frontend/assets/es-ES-U4NZUMDT-BwZWIjT5.js +9 -0
- package/dist/frontend/assets/eu-ES-A7QVB2H4-B9suQ9BE.js +11 -0
- package/dist/frontend/assets/fa-IR-HGAKTJCU-tgrKvE4J.js +8 -0
- package/dist/frontend/assets/fi-FI-Z5N7JZ37-Ddoc7R-q.js +6 -0
- package/dist/frontend/assets/file-open-002ab408-DIuFHtCF.js +1 -0
- package/dist/frontend/assets/file-open-7c801643-684qeFg4.js +1 -0
- package/dist/frontend/assets/file-save-3189631c-C1wFhQhH.js +1 -0
- package/dist/frontend/assets/file-save-745eba88-Bb9F9Kg7.js +1 -0
- package/dist/frontend/assets/flowDb-7c981674-DkYacLUz.js +10 -0
- package/dist/frontend/assets/flowDiagram-A5DVABFB-CCBuG42p.js +168 -0
- package/dist/frontend/assets/flowDiagram-cbd28bf7-DhhBmCsw.js +4 -0
- package/dist/frontend/assets/flowDiagram-v2-ffc7f31a-BICbZ5-w.js +1 -0
- package/dist/frontend/assets/flowchart-elk-definition-36e2d292-BsyTsM2Q.js +139 -0
- package/dist/frontend/assets/fr-FR-RHASNOE6-Bzn_6dcd.js +9 -0
- package/dist/frontend/assets/ganttDiagram-04f9e578-CCKAlfpJ.js +257 -0
- package/dist/frontend/assets/ganttDiagram-EL5Y4UJY-B8CXkutd.js +292 -0
- package/dist/frontend/assets/gitGraphDiagram-21fc4d3e-DBAYEQql.js +70 -0
- package/dist/frontend/assets/gitGraphDiagram-WWUBYQGX-Ge5QWjv2.js +106 -0
- package/dist/frontend/assets/gl-ES-HMX3MZ6V-vcZHbFum.js +10 -0
- package/dist/frontend/assets/graph-87dI2d0Q.js +1 -0
- package/dist/frontend/assets/has-D7z5cd7K.js +1 -0
- package/dist/frontend/assets/he-IL-6SHJWFNN-CK07fY3l.js +10 -0
- package/dist/frontend/assets/hi-IN-IWLTKZ5I-CDZ0p7Jv.js +4 -0
- package/dist/frontend/assets/hu-HU-A5ZG7DT2-FH5SLnWy.js +7 -0
- package/dist/frontend/assets/id-ID-SAP4L64H-MjXIXb2f.js +10 -0
- package/dist/frontend/assets/image-blob-reduce.esm-HwCm7IZ0.js +7 -0
- package/dist/frontend/assets/index-6079d271-DiB2AL6F.js +1 -0
- package/dist/frontend/assets/index-BcAUh2Nm.css +1 -0
- package/dist/frontend/assets/index-Biw8Vgb3.js +320 -0
- package/dist/frontend/assets/index-fTyH8AV3.js +354 -0
- package/dist/frontend/assets/infoDiagram-4a4f5b27-BOdJmCUU.js +7 -0
- package/dist/frontend/assets/infoDiagram-RXCK75RN-CNm06Rxs.js +2 -0
- package/dist/frontend/assets/init-Gi6I4Gst.js +1 -0
- package/dist/frontend/assets/ishikawaDiagram-5VMMS53U-DoLWy3n2.js +70 -0
- package/dist/frontend/assets/it-IT-JPQ66NNP-D3n0iaPa.js +11 -0
- package/dist/frontend/assets/ja-JP-DBVTYXUO-ejSNO7M9.js +8 -0
- package/dist/frontend/assets/journeyDiagram-29694f62-Cm6qVjA9.js +139 -0
- package/dist/frontend/assets/journeyDiagram-EYS64GPL-ByZmvOcj.js +139 -0
- package/dist/frontend/assets/kaa-6HZHGXH3-D8l_gwno.js +1 -0
- package/dist/frontend/assets/kab-KAB-ZGHBKWFO-CCdAUgdW.js +8 -0
- package/dist/frontend/assets/kanban-definition-3QL26DDD-Y5ylzca9.js +89 -0
- package/dist/frontend/assets/katex-C5jXJg4s.js +257 -0
- package/dist/frontend/assets/kk-KZ-P5N5QNE5-DeuZqHeo.js +1 -0
- package/dist/frontend/assets/km-KH-HSX4SM5Z-CiG2k5fk.js +11 -0
- package/dist/frontend/assets/ko-KR-MTYHY66A-KQOGYf_l.js +9 -0
- package/dist/frontend/assets/ku-TR-6OUDTVRD-iPec9Wpx.js +9 -0
- package/dist/frontend/assets/layout-ChryVliD.js +1 -0
- package/dist/frontend/assets/layout-chXYHUIV.js +1 -0
- package/dist/frontend/assets/line-V0o6yOnB.js +1 -0
- package/dist/frontend/assets/linear-BvV3B0Vg.js +1 -0
- package/dist/frontend/assets/lt-LT-XHIRWOB4-CATjC2gQ.js +3 -0
- package/dist/frontend/assets/lv-LV-5QDEKY6T-BsDP-7Dd.js +7 -0
- package/dist/frontend/assets/mindmap-definition-FBJOCRG2-z4KcwRlx.js +96 -0
- package/dist/frontend/assets/mindmap-definition-ac74a2e8-C1QU2vBv.js +95 -0
- package/dist/frontend/assets/mr-IN-CRQNXWMA-DWJhwvxv.js +13 -0
- package/dist/frontend/assets/my-MM-5M5IBNSE-DckXEMN8.js +1 -0
- package/dist/frontend/assets/nb-NO-T6EIAALU-HaOR9ZeX.js +10 -0
- package/dist/frontend/assets/nl-NL-IS3SIHDZ-ef_ywpFu.js +8 -0
- package/dist/frontend/assets/nn-NO-6E72VCQL-Bg7QdVqf.js +8 -0
- package/dist/frontend/assets/oc-FR-POXYY2M6-D5HmBPnC.js +8 -0
- package/dist/frontend/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/frontend/assets/pa-IN-N4M65BXN-BHYM0tZp.js +4 -0
- package/dist/frontend/assets/path-CbwjOpE9.js +1 -0
- package/dist/frontend/assets/pegDiagram-XKGWAZYB-BL0-JiYs.js +1 -0
- package/dist/frontend/assets/pica-CHpl3DYP.js +7 -0
- package/dist/frontend/assets/pie-b97pL0mM.js +1 -0
- package/dist/frontend/assets/pieDiagram-421022e6-DiRybrxD.js +35 -0
- package/dist/frontend/assets/pieDiagram-E7YTZNPT-VybkpWmu.js +39 -0
- package/dist/frontend/assets/pl-PL-T2D74RX3-uZIVDHgu.js +9 -0
- package/dist/frontend/assets/pt-BR-5N22H2LF-dJVfhAeV.js +9 -0
- package/dist/frontend/assets/pt-PT-UZXXM6DQ-DjJzcznP.js +9 -0
- package/dist/frontend/assets/quadrantDiagram-0957ecba-BHJpECv1.js +7 -0
- package/dist/frontend/assets/quadrantDiagram-AXDQQJYC-RAG8nSkZ.js +7 -0
- package/dist/frontend/assets/railroadDiagram-O6MQD6OU-lCMtporN.js +1 -0
- package/dist/frontend/assets/requirementDiagram-23d650b8-mSFTWSrD.js +52 -0
- package/dist/frontend/assets/requirementDiagram-EFPCY7ZU-B8YnTqPO.js +84 -0
- package/dist/frontend/assets/ro-RO-JPDTUUEW-B5X8VOmp.js +11 -0
- package/dist/frontend/assets/roundRect-0PYZxl1G.js +1 -0
- package/dist/frontend/assets/ru-RU-B4JR7IUQ-Czv9kfuz.js +9 -0
- package/dist/frontend/assets/sankeyDiagram-23345273-B3g3P-D1.js +8 -0
- package/dist/frontend/assets/sankeyDiagram-P5KCCOFB-DRm9HHoQ.js +40 -0
- package/dist/frontend/assets/sankeyLinkHorizontal-CgO6js3K.js +1 -0
- package/dist/frontend/assets/sequenceDiagram-17ac3bff-DzZiSttS.js +122 -0
- package/dist/frontend/assets/sequenceDiagram-WJ2MYXX4-BrSDYDx-.js +162 -0
- package/dist/frontend/assets/si-LK-N5RQ5JYF-DFWOZdgD.js +1 -0
- package/dist/frontend/assets/sizeCapture-X5ZJPWSS-CbaN7yeQ.js +1 -0
- package/dist/frontend/assets/sk-SK-C5VTKIMK-B8VlFn2Z.js +6 -0
- package/dist/frontend/assets/sl-SI-NN7IZMDC-CJeSgLEg.js +6 -0
- package/dist/frontend/assets/stateDiagram-9c5f0230-Dzm1fyzw.js +1 -0
- package/dist/frontend/assets/stateDiagram-HBIQ2CUA-B5Nv-PBX.js +1 -0
- package/dist/frontend/assets/stateDiagram-v2-4QOOHH4V-B72hUL6s.js +1 -0
- package/dist/frontend/assets/stateDiagram-v2-51a3dcff-DvLAYBjA.js +1 -0
- package/dist/frontend/assets/styles-2ab5d517-D6473lhT.js +116 -0
- package/dist/frontend/assets/styles-5f03d8d2-CZ5U9u1n.js +160 -0
- package/dist/frontend/assets/styles-edf9a4b0-DzQC88FF.js +207 -0
- package/dist/frontend/assets/subset-shared.chunk.js +84 -0
- package/dist/frontend/assets/subset-worker.chunk.js +1 -0
- package/dist/frontend/assets/sv-SE-XGPEYMSR-BKMKxZWF.js +10 -0
- package/dist/frontend/assets/svgDrawCommon-3ba9043b-CQsuw6x4.js +1 -0
- package/dist/frontend/assets/swimlanes-XN3QIQJK-D6c81JTS.js +1 -0
- package/dist/frontend/assets/swimlanesDiagram-VK2B7HYN-SMIGSMWR.js +8 -0
- package/dist/frontend/assets/ta-IN-2NMHFXQM-BtPPl3RQ.js +9 -0
- package/dist/frontend/assets/th-TH-HPSO5L25-CSjFGi1j.js +2 -0
- package/dist/frontend/assets/timeline-definition-24CTP7MA-DTBgPsOR.js +120 -0
- package/dist/frontend/assets/timeline-definition-7e6b55e7-D44e8lHF.js +61 -0
- package/dist/frontend/assets/tr-TR-DEFEU3FU-BS1kZ0-G.js +7 -0
- package/dist/frontend/assets/uk-UA-QMV73CPH--ucRdDwc.js +6 -0
- package/dist/frontend/assets/union-DI_iry4-.js +1 -0
- package/dist/frontend/assets/vennDiagram-4TSXK5OY-DDIUJU_f.js +34 -0
- package/dist/frontend/assets/vi-VN-M7AON7JQ-BcGYkPOn.js +5 -0
- package/dist/frontend/assets/wardleyDiagram-VM6X3IG4-TfvrOirV.js +78 -0
- package/dist/frontend/assets/xychartDiagram-S5SC5T6Z-DaSdOJbv.js +7 -0
- package/dist/frontend/assets/xychartDiagram-b6496bcd-VIsyqEG1.js +7 -0
- package/dist/frontend/assets/zh-CN-LNUGB5OW-RL4CyEYU.js +10 -0
- package/dist/frontend/assets/zh-HK-E62DVLB3-DKGVR3J1.js +1 -0
- package/dist/frontend/assets/zh-TW-RAJ6MFWO-C7djgh-M.js +9 -0
- package/dist/frontend/assets/zipObject-Bl99JdSU.js +1 -0
- package/dist/frontend/index.html +569 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -0
- package/dist/index.js.map +1 -0
- package/dist/render/excalidraw-node.mjs +540 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1684 -0
- package/dist/server.js.map +1 -0
- package/dist/types.d.ts +263 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +49 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +63 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +127 -4
- package/skills/excalidraw-skill/SKILL.md +331 -0
- package/skills/excalidraw-skill/evals/evals.json +35 -0
- package/skills/excalidraw-skill/references/cheatsheet.md +217 -0
- package/src/ai/config.ts +58 -0
- package/src/ai/providers/anthropic.ts +62 -0
- package/src/ai/providers/openai-compatible.ts +84 -0
- package/src/ai/request-settings.ts +50 -0
- package/src/ai/routes.ts +157 -0
- package/src/ai/runner.ts +80 -0
- package/src/ai/sse.ts +40 -0
- package/src/ai/system.ts +16 -0
- package/src/ai/tools.ts +130 -0
- package/src/ai/types.ts +48 -0
- package/src/bin.ts +56 -0
- package/src/cli/args.ts +97 -0
- package/src/cli/commands/ai.ts +40 -0
- package/src/cli/commands/arrange.ts +112 -0
- package/src/cli/commands/canvases.ts +37 -0
- package/src/cli/commands/check.ts +15 -0
- package/src/cli/commands/comment.ts +72 -0
- package/src/cli/commands/elements.ts +299 -0
- package/src/cli/commands/frame.ts +55 -0
- package/src/cli/commands/install-skill.ts +116 -0
- package/src/cli/commands/layout.ts +14 -0
- package/src/cli/commands/render.ts +68 -0
- package/src/cli/commands/scene.ts +168 -0
- package/src/cli/commands/server.ts +71 -0
- package/src/cli/commands/snapshot.ts +45 -0
- package/src/cli/image-options.ts +77 -0
- package/src/cli/run.ts +123 -0
- package/src/cli/util.ts +39 -0
- package/src/core/arrow-routing.ts +256 -0
- package/src/core/bulk-ops.ts +183 -0
- package/src/core/canvas-client.ts +525 -0
- package/src/core/canvas-id.ts +8 -0
- package/src/core/canvas-persistence.ts +1067 -0
- package/src/core/canvas-registry.ts +180 -0
- package/src/core/canvas-routes.ts +34 -0
- package/src/core/canvas-state.ts +37 -0
- package/src/core/canvas.ts +18 -0
- package/src/core/comment-ops.ts +36 -0
- package/src/core/comments.ts +142 -0
- package/src/core/compact.ts +21 -0
- package/src/core/config.ts +24 -0
- package/src/core/describe.ts +100 -0
- package/src/core/design-guide.ts +114 -0
- package/src/core/diagram-layout.ts +278 -0
- package/src/core/diagram-ops.ts +48 -0
- package/src/core/entry.ts +37 -0
- package/src/core/expand-elements.ts +316 -0
- package/src/core/frame-ops.ts +112 -0
- package/src/core/frames.ts +113 -0
- package/src/core/geometry.ts +213 -0
- package/src/core/layout-check.ts +200 -0
- package/src/core/local-origin.ts +27 -0
- package/src/core/mcp-dispatch.ts +858 -0
- package/src/core/mcp-http.ts +38 -0
- package/src/core/mcp-server.ts +72 -0
- package/src/core/mcp-tools.ts +725 -0
- package/src/core/normalize.ts +158 -0
- package/src/core/obsidian-md.ts +231 -0
- package/src/core/pidfile.ts +52 -0
- package/src/core/png-scene.ts +177 -0
- package/src/core/render/excalidraw-node/dom.ts +159 -0
- package/src/core/render/excalidraw-node/index.ts +100 -0
- package/src/core/render/fonts.ts +173 -0
- package/src/core/render/index.ts +198 -0
- package/src/core/render/png-worker.ts +75 -0
- package/src/core/render/png.ts +148 -0
- package/src/core/render/text-metrics.ts +141 -0
- package/src/core/request-canvas.ts +10 -0
- package/src/core/request-headers.ts +79 -0
- package/src/core/scene-input.ts +11 -0
- package/src/core/scene-io.ts +125 -0
- package/src/core/share-url.ts +99 -0
- package/src/core/spawn.ts +186 -0
- package/src/core/version.ts +13 -0
- package/src/index.ts +86 -0
- package/src/server.ts +1873 -0
- package/src/types.ts +384 -0
- package/src/utils/logger.ts +77 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { ServerElement, normalizeFontFamily } from '../types.js';
|
|
2
|
+
|
|
3
|
+
// Expand the server's agent-friendly element format into real Excalidraw
|
|
4
|
+
// elements: strip server metadata, add Excalidraw defaults, generate bound
|
|
5
|
+
// text elements for `label`/`text` on shapes and arrows, and resolve arrow
|
|
6
|
+
// bindings — so exported scenes render fully in third-party consumers
|
|
7
|
+
// (excalidraw.com, the Obsidian Excalidraw plugin) without a browser tab.
|
|
8
|
+
//
|
|
9
|
+
// Extracted from share-url.ts (cleanElementsForShare), which shares this
|
|
10
|
+
// exact conversion for the encrypted excalidraw.com upload.
|
|
11
|
+
|
|
12
|
+
export interface ExpandOptions {
|
|
13
|
+
// Derive seeds, versionNonces, and `updated` timestamps from element ids
|
|
14
|
+
// and updatedAt instead of Math.random()/Date.now(), so repeated exports
|
|
15
|
+
// of an unchanged scene are byte-identical (keeps committed .excalidraw
|
|
16
|
+
// files diff-clean).
|
|
17
|
+
deterministic?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Canonical key order for exported elements: identity/geometry first, the
|
|
21
|
+
// rest alphabetical — so a no-op import→export cycle is byte-identical and
|
|
22
|
+
// committed .excalidraw files produce minimal git diffs.
|
|
23
|
+
const KEY_ORDER = ['id', 'type', 'x', 'y', 'width', 'height'];
|
|
24
|
+
export function canonicalizeKeys(v: any): any {
|
|
25
|
+
if (Array.isArray(v)) return v.map(canonicalizeKeys);
|
|
26
|
+
if (v && typeof v === 'object') {
|
|
27
|
+
const keys = Object.keys(v).sort((a, b) => {
|
|
28
|
+
const ia = KEY_ORDER.indexOf(a); const ib = KEY_ORDER.indexOf(b);
|
|
29
|
+
if (ia !== -1 || ib !== -1) return (ia === -1 ? KEY_ORDER.length : ia) - (ib === -1 ? KEY_ORDER.length : ib);
|
|
30
|
+
return a < b ? -1 : 1;
|
|
31
|
+
});
|
|
32
|
+
const out: Record<string, any> = {};
|
|
33
|
+
for (const k of keys) out[k] = canonicalizeKeys(v[k]);
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
return v;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Excalidraw orders elements by fractional-index keys that must be valid and
|
|
40
|
+
// ascending as strings: an integer part whose head letter sets its length
|
|
41
|
+
// ('a' + 1 base-62 digit, 'b' + 2, 'c' + 3, ...). A decimal counter ("a10",
|
|
42
|
+
// "a80") fails both rules, and Excalidraw rejects the scene on load.
|
|
43
|
+
const BASE62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
44
|
+
export function orderKey(n: number): string {
|
|
45
|
+
let digits = 1;
|
|
46
|
+
let capacity = 62;
|
|
47
|
+
while (n >= capacity) {
|
|
48
|
+
n -= capacity;
|
|
49
|
+
digits++;
|
|
50
|
+
capacity *= 62;
|
|
51
|
+
}
|
|
52
|
+
let key = '';
|
|
53
|
+
for (let i = 0; i < digits; i++) {
|
|
54
|
+
key = BASE62[n % 62] + key;
|
|
55
|
+
n = Math.floor(n / 62);
|
|
56
|
+
}
|
|
57
|
+
return String.fromCharCode('a'.charCodeAt(0) + digits - 1) + key;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// FNV-1a 32-bit hash — stable positive int from a string
|
|
61
|
+
export function fnv1a(str: string): number {
|
|
62
|
+
let h = 0x811c9dc5;
|
|
63
|
+
for (let i = 0; i < str.length; i++) {
|
|
64
|
+
h ^= str.charCodeAt(i);
|
|
65
|
+
h = Math.imul(h, 0x01000193);
|
|
66
|
+
}
|
|
67
|
+
return h >>> 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function expandElementsForExport(
|
|
71
|
+
sourceElements: ServerElement[],
|
|
72
|
+
options: ExpandOptions = {}
|
|
73
|
+
): Record<string, any>[] {
|
|
74
|
+
const { deterministic = false } = options;
|
|
75
|
+
const seedFor = (key: string): number =>
|
|
76
|
+
deterministic ? (fnv1a(key) % 2147483646) + 1 : Math.floor(Math.random() * 2147483647);
|
|
77
|
+
const updatedFor = (el: any): number => {
|
|
78
|
+
if (!deterministic) return Date.now();
|
|
79
|
+
// Prefer a preserved `updated` (re-imported scene) over the server's
|
|
80
|
+
// updatedAt, so no-op import→export cycles are byte-identical.
|
|
81
|
+
if (typeof el.updated === 'number') return el.updated;
|
|
82
|
+
const parsed = Date.parse(el.updatedAt ?? el.createdAt ?? '');
|
|
83
|
+
return Number.isNaN(parsed) ? 1 : parsed;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const cleanedExportElements: Record<string, any>[] = [];
|
|
87
|
+
const boundTextElements: Record<string, any>[] = [];
|
|
88
|
+
|
|
89
|
+
// Shapes created without dimensions get the same 100x100 default the live
|
|
90
|
+
// tab's skeleton converter applies, so files and headless renders agree
|
|
91
|
+
// with what the canvas shows instead of collapsing to a 0x0 element.
|
|
92
|
+
const DEFAULT_DIMENSION = 100;
|
|
93
|
+
const hasOwnGeometry = (type: string) =>
|
|
94
|
+
type === 'arrow' || type === 'line' || type === 'freedraw' || type === 'text';
|
|
95
|
+
|
|
96
|
+
function makeBaseElement(el: any, rest: any): Record<string, any> {
|
|
97
|
+
const width = rest.width ?? (hasOwnGeometry(el.type) ? undefined : DEFAULT_DIMENSION);
|
|
98
|
+
const height = rest.height ?? (hasOwnGeometry(el.type) ? undefined : DEFAULT_DIMENSION);
|
|
99
|
+
return {
|
|
100
|
+
...rest,
|
|
101
|
+
...(width !== undefined ? { width } : {}),
|
|
102
|
+
...(height !== undefined ? { height } : {}),
|
|
103
|
+
angle: rest.angle ?? 0,
|
|
104
|
+
strokeColor: rest.strokeColor ?? '#1e1e1e',
|
|
105
|
+
backgroundColor: rest.backgroundColor ?? 'transparent',
|
|
106
|
+
fillStyle: rest.fillStyle ?? 'solid',
|
|
107
|
+
strokeWidth: rest.strokeWidth ?? 2,
|
|
108
|
+
strokeStyle: rest.strokeStyle ?? 'solid',
|
|
109
|
+
roughness: rest.roughness ?? 1,
|
|
110
|
+
opacity: rest.opacity ?? 100,
|
|
111
|
+
groupIds: rest.groupIds ?? [],
|
|
112
|
+
frameId: rest.frameId ?? null,
|
|
113
|
+
roundness: rest.roundness ?? (
|
|
114
|
+
el.type === 'rectangle' || el.type === 'diamond' || el.type === 'ellipse'
|
|
115
|
+
? { type: 3 } : null
|
|
116
|
+
),
|
|
117
|
+
seed: rest.seed ?? seedFor(`${el.id}:seed`),
|
|
118
|
+
version: rest.version ?? 1,
|
|
119
|
+
versionNonce: rest.versionNonce ?? seedFor(`${el.id}:nonce`),
|
|
120
|
+
isDeleted: false,
|
|
121
|
+
boundElements: rest.boundElements ?? null,
|
|
122
|
+
updated: updatedFor(el),
|
|
123
|
+
link: rest.link ?? null,
|
|
124
|
+
locked: rest.locked ?? false
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
for (const el of sourceElements) {
|
|
129
|
+
// Strip server-only fields
|
|
130
|
+
const {
|
|
131
|
+
createdAt, updatedAt, syncedAt, source: _src,
|
|
132
|
+
syncTimestamp, label, start, end, text,
|
|
133
|
+
version: _ver,
|
|
134
|
+
...rest
|
|
135
|
+
} = el as any;
|
|
136
|
+
|
|
137
|
+
const base = makeBaseElement(el, rest);
|
|
138
|
+
|
|
139
|
+
// Standalone text elements: keep text directly
|
|
140
|
+
if (el.type === 'text') {
|
|
141
|
+
base.text = text ?? '';
|
|
142
|
+
base.originalText = text ?? '';
|
|
143
|
+
base.fontSize = rest.fontSize ?? 20;
|
|
144
|
+
// Agent-created text often has no dimensions (server stores null);
|
|
145
|
+
// third-party consumers clip width-less text, so estimate like the
|
|
146
|
+
// design guide does (~0.6×fontSize per char, 1.25 line height).
|
|
147
|
+
// Treat 0 as unmeasured, not just null/undefined: pre-2.0.0 headless
|
|
148
|
+
// creation stored width/height 0, and re-imported scenes carry it back
|
|
149
|
+
// into the store — zero-size text renders invisible in consumers that
|
|
150
|
+
// trust stored dimensions.
|
|
151
|
+
if (!base.width || !base.height) {
|
|
152
|
+
const lines = String(base.text).split('\n');
|
|
153
|
+
const longestLine = Math.max(1, ...lines.map((l: string) => l.length));
|
|
154
|
+
base.width = base.width || Math.ceil(longestLine * base.fontSize * 0.6);
|
|
155
|
+
base.height = base.height || Math.ceil(lines.length * base.fontSize * 1.25);
|
|
156
|
+
}
|
|
157
|
+
base.fontFamily = normalizeFontFamily(rest.fontFamily) ?? 1;
|
|
158
|
+
// Excalidraw's own defaults for free text, which the live canvas uses:
|
|
159
|
+
// 'center' would centre the text on its estimated box once reopened.
|
|
160
|
+
base.textAlign = rest.textAlign ?? 'left';
|
|
161
|
+
base.verticalAlign = rest.verticalAlign ?? 'top';
|
|
162
|
+
base.autoResize = rest.autoResize ?? true;
|
|
163
|
+
base.lineHeight = rest.lineHeight ?? 1.25;
|
|
164
|
+
base.containerId = rest.containerId ?? null;
|
|
165
|
+
cleanedExportElements.push(base);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Arrows: preserve browser-synced bindings; for agent-created arrows the
|
|
170
|
+
// server keeps start/end refs with null bindings (points are kept correct
|
|
171
|
+
// by rerouteBoundArrows), so synthesize live bindings from the refs —
|
|
172
|
+
// otherwise arrows don't stick to shapes when moved in Excalidraw.
|
|
173
|
+
if (el.type === 'arrow' || el.type === 'line') {
|
|
174
|
+
base.points = rest.points ?? [[0, 0], [100, 0]];
|
|
175
|
+
base.lastCommittedPoint = null;
|
|
176
|
+
if (rest.startBinding) {
|
|
177
|
+
base.startBinding = { ...rest.startBinding, fixedPoint: rest.startBinding.fixedPoint ?? null };
|
|
178
|
+
} else if (start?.id) {
|
|
179
|
+
base.startBinding = { elementId: start.id, focus: 0, gap: 4, fixedPoint: null };
|
|
180
|
+
} else {
|
|
181
|
+
base.startBinding = null;
|
|
182
|
+
}
|
|
183
|
+
if (rest.endBinding) {
|
|
184
|
+
base.endBinding = { ...rest.endBinding, fixedPoint: rest.endBinding.fixedPoint ?? null };
|
|
185
|
+
} else if (end?.id) {
|
|
186
|
+
base.endBinding = { elementId: end.id, focus: 0, gap: 4, fixedPoint: null };
|
|
187
|
+
} else {
|
|
188
|
+
base.endBinding = null;
|
|
189
|
+
}
|
|
190
|
+
base.startArrowhead = rest.startArrowhead ?? null;
|
|
191
|
+
base.endArrowhead = rest.endArrowhead ?? (el.type === 'arrow' ? 'arrow' : null);
|
|
192
|
+
base.elbowed = rest.elbowed ?? false;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Generate a bound text element for `label`/`text` on shapes and arrows —
|
|
196
|
+
// unless the element already carries a bound text reference (a scene
|
|
197
|
+
// synced from a browser tab, or a re-imported expanded export).
|
|
198
|
+
const labelText = label?.text || text;
|
|
199
|
+
const hasBoundText = Array.isArray(base.boundElements) &&
|
|
200
|
+
base.boundElements.some((b: any) => b?.type === 'text');
|
|
201
|
+
if (labelText && !hasBoundText) {
|
|
202
|
+
const textId = `${base.id}-label`;
|
|
203
|
+
// Add binding reference to parent
|
|
204
|
+
base.boundElements = [
|
|
205
|
+
...(Array.isArray(base.boundElements) ? base.boundElements : []),
|
|
206
|
+
{ type: 'text', id: textId }
|
|
207
|
+
];
|
|
208
|
+
|
|
209
|
+
// Compute text position: centered in shape, or at arrow midpoint
|
|
210
|
+
let textX: number, textY: number, textW: number, textH: number;
|
|
211
|
+
const isArrow = el.type === 'arrow' || el.type === 'line';
|
|
212
|
+
|
|
213
|
+
if (isArrow) {
|
|
214
|
+
// Position at midpoint of arrow path
|
|
215
|
+
const pts = base.points || [[0, 0], [100, 0]];
|
|
216
|
+
const lastPt = pts[pts.length - 1];
|
|
217
|
+
const midX = base.x + (lastPt[0] / 2);
|
|
218
|
+
const midY = base.y + (lastPt[1] / 2);
|
|
219
|
+
const labelW = Math.max(labelText.length * 10, 60);
|
|
220
|
+
textX = midX - labelW / 2;
|
|
221
|
+
textY = midY - 12;
|
|
222
|
+
textW = labelW;
|
|
223
|
+
textH = 24;
|
|
224
|
+
} else {
|
|
225
|
+
// Center inside shape container
|
|
226
|
+
const containerW = base.width ?? 160;
|
|
227
|
+
const containerH = base.height ?? 80;
|
|
228
|
+
textX = base.x + 10;
|
|
229
|
+
textY = base.y + containerH / 4;
|
|
230
|
+
textW = containerW - 20;
|
|
231
|
+
textH = containerH / 2;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
boundTextElements.push({
|
|
235
|
+
id: textId,
|
|
236
|
+
type: 'text',
|
|
237
|
+
x: textX,
|
|
238
|
+
y: textY,
|
|
239
|
+
width: textW,
|
|
240
|
+
height: textH,
|
|
241
|
+
angle: 0,
|
|
242
|
+
strokeColor: isArrow ? '#1e1e1e' : base.strokeColor,
|
|
243
|
+
backgroundColor: 'transparent',
|
|
244
|
+
fillStyle: 'solid',
|
|
245
|
+
strokeWidth: 1,
|
|
246
|
+
strokeStyle: 'solid',
|
|
247
|
+
roughness: 1,
|
|
248
|
+
opacity: 100,
|
|
249
|
+
groupIds: [],
|
|
250
|
+
frameId: null,
|
|
251
|
+
roundness: null,
|
|
252
|
+
seed: seedFor(`${textId}:seed`),
|
|
253
|
+
version: 1,
|
|
254
|
+
versionNonce: seedFor(`${textId}:nonce`),
|
|
255
|
+
isDeleted: false,
|
|
256
|
+
boundElements: null,
|
|
257
|
+
updated: updatedFor(el),
|
|
258
|
+
link: null,
|
|
259
|
+
locked: false,
|
|
260
|
+
text: labelText,
|
|
261
|
+
originalText: labelText,
|
|
262
|
+
fontSize: isArrow ? 14 : (rest.fontSize ?? 16),
|
|
263
|
+
fontFamily: normalizeFontFamily(rest.fontFamily) ?? 1,
|
|
264
|
+
textAlign: 'center',
|
|
265
|
+
verticalAlign: 'middle',
|
|
266
|
+
autoResize: true,
|
|
267
|
+
lineHeight: 1.25,
|
|
268
|
+
containerId: base.id
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
cleanedExportElements.push(base);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Patch shapes' boundElements to include connected arrows
|
|
276
|
+
const shapeBoundArrows = new Map<string, { type: string; id: string }[]>();
|
|
277
|
+
for (const el of cleanedExportElements) {
|
|
278
|
+
if (el.startBinding?.elementId) {
|
|
279
|
+
const arr = shapeBoundArrows.get(el.startBinding.elementId) || [];
|
|
280
|
+
arr.push({ type: 'arrow', id: el.id });
|
|
281
|
+
shapeBoundArrows.set(el.startBinding.elementId, arr);
|
|
282
|
+
}
|
|
283
|
+
if (el.endBinding?.elementId) {
|
|
284
|
+
const arr = shapeBoundArrows.get(el.endBinding.elementId) || [];
|
|
285
|
+
arr.push({ type: 'arrow', id: el.id });
|
|
286
|
+
shapeBoundArrows.set(el.endBinding.elementId, arr);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
for (const el of cleanedExportElements) {
|
|
290
|
+
const arrowBindings = shapeBoundArrows.get(el.id);
|
|
291
|
+
if (arrowBindings) {
|
|
292
|
+
// Skip refs the element already carries (re-exported expanded scenes),
|
|
293
|
+
// otherwise every export cycle appends duplicate boundElements entries.
|
|
294
|
+
const existing = new Set(
|
|
295
|
+
(Array.isArray(el.boundElements) ? el.boundElements : []).map((b: any) => b?.id)
|
|
296
|
+
);
|
|
297
|
+
const additions = arrowBindings.filter(b => !existing.has(b.id));
|
|
298
|
+
if (additions.length > 0) {
|
|
299
|
+
el.boundElements = [
|
|
300
|
+
...(Array.isArray(el.boundElements) ? el.boundElements : []),
|
|
301
|
+
...additions
|
|
302
|
+
];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// Append all bound text elements after their parents
|
|
308
|
+
cleanedExportElements.push(...boundTextElements);
|
|
309
|
+
|
|
310
|
+
// Keys follow the final array order, so the file's z-order matches what the
|
|
311
|
+
// canvas drew. Incoming keys are replaced: a mix of kept and new keys could
|
|
312
|
+
// fall out of order.
|
|
313
|
+
cleanedExportElements.forEach((el, i) => { el.index = orderKey(i); });
|
|
314
|
+
|
|
315
|
+
return deterministic ? canonicalizeKeys(cleanedExportElements) : cleanedExportElements;
|
|
316
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { ServerElement } from '../types.js';
|
|
2
|
+
import { describeScene } from './describe.js';
|
|
3
|
+
import {
|
|
4
|
+
createElementStrict, deleteElementStrict, getElements, listComments, updateElementStrict
|
|
5
|
+
} from './canvas-client.js';
|
|
6
|
+
import type { Frame } from './frames.js';
|
|
7
|
+
import {
|
|
8
|
+
findFrame, frameToFit, fromFrameSpace, inFrame, listFrames, nextFrameRect, overlappingFrames, pointInFrame, toFrameSpace
|
|
9
|
+
} from './frames.js';
|
|
10
|
+
|
|
11
|
+
export interface FrameScope { frame: Frame; frames: Frame[] }
|
|
12
|
+
|
|
13
|
+
type CanvasRect = { canvasX: number; canvasY: number; width: number; height: number };
|
|
14
|
+
export interface FrameGrowth { frame: string; from: CanvasRect; to: CanvasRect; overlaps?: string[] }
|
|
15
|
+
|
|
16
|
+
const canvasRect = (r: { x: number; y: number; width: number; height: number }): CanvasRect =>
|
|
17
|
+
({ canvasX: r.x, canvasY: r.y, width: r.width, height: r.height });
|
|
18
|
+
|
|
19
|
+
const describeFrame = (f: Frame, position: number) => ({ id: f.id, name: f.name, position, ...canvasRect(f) });
|
|
20
|
+
|
|
21
|
+
export async function frameScope(ref: string): Promise<FrameScope> {
|
|
22
|
+
const frames = listFrames(await getElements());
|
|
23
|
+
return { frame: findFrame(frames, ref), frames };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function assertOnFrame(element: ServerElement, frame: Frame): void {
|
|
27
|
+
if (element.frameId !== frame.id) {
|
|
28
|
+
throw new Error(element.id === frame.id
|
|
29
|
+
? `${element.id} is the frame "${frame.name}" itself; it is positioned in canvas coordinates, so leave out the frame option`
|
|
30
|
+
: `Element ${element.id} is not on frame "${frame.name}"`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const intoFrame = (el: any, { frame }: FrameScope): any =>
|
|
35
|
+
({ ...fromFrameSpace({ ...el, x: el.x ?? 0, y: el.y ?? 0 }, frame), frameId: frame.id });
|
|
36
|
+
|
|
37
|
+
// A frame clips what lies outside it, so the frame grows to hold what was just added or moved. from/to are canvas coordinates.
|
|
38
|
+
export async function growFrame({ frame, frames }: FrameScope, shapes: ServerElement[]): Promise<FrameGrowth | undefined> {
|
|
39
|
+
const grown = frameToFit(frame, shapes);
|
|
40
|
+
if (!grown) return undefined;
|
|
41
|
+
await updateElementStrict({ id: frame.id, ...grown });
|
|
42
|
+
const overlaps = overlappingFrames(grown, frames, frame.id);
|
|
43
|
+
return { frame: frame.name, from: canvasRect(frame), to: canvasRect(grown), ...(overlaps.length ? { overlaps } : {}) };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const overlapWarning = (frame: string, overlaps: readonly string[]): string =>
|
|
47
|
+
`warning: frame "${frame}" now overlaps ${overlaps.map(n => `"${n}"`).join(', ')}; move one of them`;
|
|
48
|
+
|
|
49
|
+
export async function listFrameSummaries() {
|
|
50
|
+
const [elements, comments] = await Promise.all([getElements(), listComments('open')]);
|
|
51
|
+
const frames = listFrames(elements);
|
|
52
|
+
const byId = new Map(elements.map(e => [e.id, e]));
|
|
53
|
+
return frames.map((p, i) => {
|
|
54
|
+
const overlaps = overlappingFrames(p, frames, p.id);
|
|
55
|
+
return {
|
|
56
|
+
...describeFrame(p, i + 1),
|
|
57
|
+
...(overlaps.length ? { overlaps } : {}),
|
|
58
|
+
elements: elements.filter(e => e.frameId === p.id).length,
|
|
59
|
+
openComments: comments.filter(c => {
|
|
60
|
+
const anchor = c.anchorElementId ? byId.get(c.anchorElementId) : undefined;
|
|
61
|
+
return pointInFrame(anchor ? { x: anchor.x + (c.dx ?? 0), y: anchor.y + (c.dy ?? 0) } : c, p);
|
|
62
|
+
}).length
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// `hint` names the option that keeps the reader in these coordinates.
|
|
68
|
+
export async function describeFrameScene(ref: string, hint: string): Promise<string> {
|
|
69
|
+
const elements = await getElements();
|
|
70
|
+
const frame = findFrame(listFrames(elements), ref);
|
|
71
|
+
return `Frame "${frame.name}", ${frame.width}x${frame.height}. Positions are relative to the frame's top-left corner, which is (0, 0); ${hint}\n\n` +
|
|
72
|
+
describeScene(elements.filter(e => inFrame(e, frame)).map(e => toFrameSpace(e, frame)));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function numberFrames(elements: readonly ServerElement[], orderedIds: readonly string[]): Promise<void> {
|
|
76
|
+
for (const [index, id] of orderedIds.entries()) {
|
|
77
|
+
const frame = elements.find(e => e.id === id);
|
|
78
|
+
if (frame && frame.customData?.frameOrder !== index) {
|
|
79
|
+
await updateElementStrict({ id, customData: { ...(frame.customData ?? {}), frameOrder: index } } as never);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// `place` puts the frame at exactly this rectangle (canvas coordinates) instead of in free space to the right.
|
|
85
|
+
export async function addFrame(name: string, size: { width?: number; height?: number }, place?: { x: number; y: number; width: number; height: number }) {
|
|
86
|
+
const elements = await getElements();
|
|
87
|
+
const frames = listFrames(elements);
|
|
88
|
+
if (frames.some(p => p.name.toLowerCase() === name.toLowerCase())) throw new Error(`A frame named "${name}" already exists`);
|
|
89
|
+
const rect = place ?? nextFrameRect(frames, elements, size);
|
|
90
|
+
await numberFrames(elements, frames.map(p => p.id));
|
|
91
|
+
const created = await createElementStrict({ type: 'frame', name, customData: { frameOrder: frames.length }, ...rect } as never);
|
|
92
|
+
return describeFrame({ id: created.id, name, ...rect }, frames.length + 1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export async function reorderFrame(ref: string, slot: number): Promise<string[]> {
|
|
96
|
+
const elements = await getElements();
|
|
97
|
+
const frames = listFrames(elements);
|
|
98
|
+
if (slot > frames.length) throw new Error(`There are ${frames.length} frames; position ${slot} does not exist`);
|
|
99
|
+
const target = findFrame(frames, ref);
|
|
100
|
+
const ids = frames.map(p => p.id).filter(id => id !== target.id);
|
|
101
|
+
ids.splice(slot - 1, 0, target.id);
|
|
102
|
+
await numberFrames(elements, ids);
|
|
103
|
+
return ids.map(id => frames.find(p => p.id === id)!.name);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export async function deleteFrame(ref: string): Promise<{ deleted: string; elements: number }> {
|
|
107
|
+
const elements = await getElements();
|
|
108
|
+
const target = findFrame(listFrames(elements), ref);
|
|
109
|
+
const doomed = elements.filter(e => inFrame(e, target));
|
|
110
|
+
for (const element of doomed) await deleteElementStrict(element.id);
|
|
111
|
+
return { deleted: target.name, elements: doomed.length - 1 };
|
|
112
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { ServerElement } from '../types.js';
|
|
2
|
+
|
|
3
|
+
// Every top-level frame is a tab. Keep the ordering rule in step with frontend/src/utils/frames.ts.
|
|
4
|
+
export interface Frame {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const orderOf = (e: ServerElement): number =>
|
|
14
|
+
typeof e.customData?.frameOrder === 'number' && Number.isFinite(e.customData.frameOrder) ? e.customData.frameOrder : Infinity;
|
|
15
|
+
|
|
16
|
+
// Tab order is stored on the frame (customData.frameOrder), not derived from where frames sit. Frames without
|
|
17
|
+
// one come after the numbered ones, in the order they were created.
|
|
18
|
+
export function listFrames(elements: readonly ServerElement[]): Frame[] {
|
|
19
|
+
const frames = elements
|
|
20
|
+
.map((e, index) => ({ e, index }))
|
|
21
|
+
.filter(({ e }) => !e.isDeleted && e.type === 'frame')
|
|
22
|
+
.sort((a, b) => {
|
|
23
|
+
const [oa, ob] = [orderOf(a.e), orderOf(b.e)];
|
|
24
|
+
return oa !== ob ? (oa < ob ? -1 : 1) : a.index - b.index;
|
|
25
|
+
})
|
|
26
|
+
.map(({ e }) => e);
|
|
27
|
+
return frames.map((f, index) => ({
|
|
28
|
+
id: f.id,
|
|
29
|
+
name: (f as { name?: string }).name?.trim() || `Frame ${index + 1}`,
|
|
30
|
+
x: f.x,
|
|
31
|
+
y: f.y,
|
|
32
|
+
width: f.width ?? 0,
|
|
33
|
+
height: f.height ?? 0
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// By id, or by name ignoring case; a name shared by two frames is refused so a command never guesses.
|
|
38
|
+
export function findFrame(frames: readonly Frame[], ref: string): Frame {
|
|
39
|
+
const byId = frames.find(p => p.id === ref);
|
|
40
|
+
if (byId) return byId;
|
|
41
|
+
const named = frames.filter(p => p.name.toLowerCase() === ref.toLowerCase());
|
|
42
|
+
if (named.length === 1) return named[0]!;
|
|
43
|
+
const known = frames.map(p => `"${p.name}"`).join(', ') || 'none';
|
|
44
|
+
throw new Error(named.length > 1 ? `Several frames are named "${ref}"; use an id` : `No frame "${ref}". Frames: ${known}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The frame grown just enough to hold the shapes, or null when they already fit. A frame clips what lies outside
|
|
48
|
+
// it. Only the right and bottom edges move: the top-left corner is the origin of frame coordinates and stays put.
|
|
49
|
+
export function frameToFit(frame: Frame, shapes: readonly ServerElement[], pad = 48): Omit<Frame, 'id' | 'name'> | null {
|
|
50
|
+
const live = shapes.filter(e => !e.isDeleted);
|
|
51
|
+
if (live.length === 0) return null;
|
|
52
|
+
const maxX = Math.max(...live.map(e => e.x + (e.width ?? 0)));
|
|
53
|
+
const maxY = Math.max(...live.map(e => e.y + (e.height ?? 0)));
|
|
54
|
+
const wider = maxX > frame.x + frame.width;
|
|
55
|
+
const taller = maxY > frame.y + frame.height;
|
|
56
|
+
if (!wider && !taller) return null;
|
|
57
|
+
return {
|
|
58
|
+
x: frame.x,
|
|
59
|
+
y: frame.y,
|
|
60
|
+
width: wider ? maxX + pad - frame.x : frame.width,
|
|
61
|
+
height: taller ? maxY + pad - frame.y : frame.height
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const toFrameSpace = <T extends { x: number; y: number }>(element: T, frame: Frame): T =>
|
|
66
|
+
({ ...element, x: element.x - frame.x, y: element.y - frame.y });
|
|
67
|
+
|
|
68
|
+
export function fromFrameSpace<T extends { x?: unknown; y?: unknown }>(fields: T, frame: Frame): T {
|
|
69
|
+
const out: Record<string, unknown> = { ...fields };
|
|
70
|
+
for (const [axis, origin] of [['x', frame.x], ['y', frame.y]] as const) {
|
|
71
|
+
const value = fields[axis];
|
|
72
|
+
if (typeof value !== 'number') continue;
|
|
73
|
+
if (value < 0) throw new Error(`${axis} is relative to the top-left corner of frame "${frame.name}", which is (0, 0); ${value} is outside it`);
|
|
74
|
+
out[axis] = origin + value;
|
|
75
|
+
}
|
|
76
|
+
return out as T;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const inFrame = (element: ServerElement, frame: Frame): boolean => element.id === frame.id || element.frameId === frame.id;
|
|
80
|
+
|
|
81
|
+
export const pointInFrame = (point: { x: number; y: number }, frame: Frame): boolean =>
|
|
82
|
+
point.x >= frame.x && point.x <= frame.x + frame.width && point.y >= frame.y && point.y <= frame.y + frame.height;
|
|
83
|
+
|
|
84
|
+
// A frame has room to grow before it meets the next one, so frames start a good way apart.
|
|
85
|
+
const FRAME_GAP = 1600;
|
|
86
|
+
const FRAME_WIDTH = 1600;
|
|
87
|
+
const FRAME_HEIGHT = 1000;
|
|
88
|
+
|
|
89
|
+
export const overlappingFrames = (rect: Omit<Frame, 'id' | 'name'>, frames: readonly Frame[], exceptId: string): string[] =>
|
|
90
|
+
frames
|
|
91
|
+
.filter(p => p.id !== exceptId && p.x < rect.x + rect.width && p.x + p.width > rect.x && p.y < rect.y + rect.height && p.y + p.height > rect.y)
|
|
92
|
+
.map(p => p.name);
|
|
93
|
+
|
|
94
|
+
// Whole numbers: stored frame coordinates stay readable.
|
|
95
|
+
export function nextFrameRect(frames: readonly Frame[], elements: readonly ServerElement[], size?: { width?: number; height?: number }): Omit<Frame, 'id' | 'name'> {
|
|
96
|
+
const live = elements.filter(e => !e.isDeleted);
|
|
97
|
+
const last = frames[frames.length - 1];
|
|
98
|
+
const width = size?.width ?? FRAME_WIDTH;
|
|
99
|
+
const height = size?.height ?? FRAME_HEIGHT;
|
|
100
|
+
let x = 0;
|
|
101
|
+
let y = 0;
|
|
102
|
+
if (last) {
|
|
103
|
+
x = Math.ceil(Math.max(...frames.map(p => p.x + p.width)) + FRAME_GAP);
|
|
104
|
+
y = Math.round(last.y);
|
|
105
|
+
} else if (live.length > 0) {
|
|
106
|
+
x = Math.ceil(Math.max(...live.map(e => e.x + (e.width ?? 0))) + FRAME_GAP);
|
|
107
|
+
y = Math.round(Math.min(...live.map(e => e.y)));
|
|
108
|
+
}
|
|
109
|
+
const blocked = (rx: number): boolean => live.some(e =>
|
|
110
|
+
e.x < rx + width && e.x + (e.width ?? 0) > rx && e.y < y + height && e.y + (e.height ?? 0) > y);
|
|
111
|
+
for (let i = 0; i < 200 && blocked(x); i++) x += width + FRAME_GAP;
|
|
112
|
+
return { x, y, width, height };
|
|
113
|
+
}
|