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,256 @@
|
|
|
1
|
+
import type { ServerElement } from '../types.js';
|
|
2
|
+
|
|
3
|
+
export interface Rect { x: number; y: number; width: number; height: number }
|
|
4
|
+
export type Point = [number, number];
|
|
5
|
+
|
|
6
|
+
export interface RouteOptions {
|
|
7
|
+
/** Space kept clear around every shape the path passes (default 16). */
|
|
8
|
+
margin?: number;
|
|
9
|
+
/** Space between a shape's edge and the arrow's end (default 8). */
|
|
10
|
+
gap?: number;
|
|
11
|
+
/** What a bend costs, in the units of length (default 30): fewer bends are preferred over a slightly shorter path. */
|
|
12
|
+
bendCost?: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type Side = 0 | 1 | 2 | 3; // top, right, bottom, left
|
|
16
|
+
const DIRECTION: readonly Point[] = [[0, -1], [1, 0], [0, 1], [-1, 0]];
|
|
17
|
+
const REACH = 150;
|
|
18
|
+
const MAX_NODES = 40_000;
|
|
19
|
+
|
|
20
|
+
const overlap = (a0: number, a1: number, b0: number, b1: number): [number, number] | null => {
|
|
21
|
+
const lo = Math.max(a0, b0);
|
|
22
|
+
const hi = Math.min(a1, b1);
|
|
23
|
+
return lo <= hi ? [lo, hi] : null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Where an arrow meets a side. When the two shapes face each other with their ranges overlapping, both ends use the
|
|
27
|
+
// middle of the shared range, so the arrow can run straight.
|
|
28
|
+
function port(rect: Rect, side: Side, other: Rect): Point {
|
|
29
|
+
const cx = rect.x + rect.width / 2;
|
|
30
|
+
const cy = rect.y + rect.height / 2;
|
|
31
|
+
const shared = side % 2 === 1
|
|
32
|
+
? overlap(rect.y, rect.y + rect.height, other.y, other.y + other.height)
|
|
33
|
+
: overlap(rect.x, rect.x + rect.width, other.x, other.x + other.width);
|
|
34
|
+
const along = shared ? (shared[0] + shared[1]) / 2 : undefined;
|
|
35
|
+
if (side === 0) return [along ?? cx, rect.y];
|
|
36
|
+
if (side === 2) return [along ?? cx, rect.y + rect.height];
|
|
37
|
+
return side === 1 ? [rect.x + rect.width, along ?? cy] : [rect.x, along ?? cy];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const contains = (outer: Rect, inner: Rect): boolean =>
|
|
41
|
+
outer.x <= inner.x && outer.y <= inner.y && outer.x + outer.width >= inner.x + inner.width && outer.y + outer.height >= inner.y + inner.height;
|
|
42
|
+
|
|
43
|
+
const touches = (a: Rect, b: Rect, reach: number): boolean =>
|
|
44
|
+
a.x - reach < b.x + b.width && a.x + a.width + reach > b.x && a.y - reach < b.y + b.height && a.y + a.height + reach > b.y;
|
|
45
|
+
|
|
46
|
+
// A binary min-heap of [priority, state].
|
|
47
|
+
class Heap {
|
|
48
|
+
private items: Array<[number, number]> = [];
|
|
49
|
+
get size(): number { return this.items.length; }
|
|
50
|
+
push(priority: number, state: number): void {
|
|
51
|
+
const items = this.items;
|
|
52
|
+
items.push([priority, state]);
|
|
53
|
+
let i = items.length - 1;
|
|
54
|
+
while (i > 0) {
|
|
55
|
+
const parent = (i - 1) >> 1;
|
|
56
|
+
if (items[parent]![0] <= items[i]![0]) break;
|
|
57
|
+
[items[parent], items[i]] = [items[i]!, items[parent]!];
|
|
58
|
+
i = parent;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
pop(): [number, number] {
|
|
62
|
+
const items = this.items;
|
|
63
|
+
const top = items[0]!;
|
|
64
|
+
const last = items.pop()!;
|
|
65
|
+
if (items.length > 0) {
|
|
66
|
+
items[0] = last;
|
|
67
|
+
let i = 0;
|
|
68
|
+
for (;;) {
|
|
69
|
+
const [l, r] = [2 * i + 1, 2 * i + 2];
|
|
70
|
+
let smallest = i;
|
|
71
|
+
if (l < items.length && items[l]![0] < items[smallest]![0]) smallest = l;
|
|
72
|
+
if (r < items.length && items[r]![0] < items[smallest]![0]) smallest = r;
|
|
73
|
+
if (smallest === i) break;
|
|
74
|
+
[items[smallest], items[i]] = [items[i]!, items[smallest]!];
|
|
75
|
+
i = smallest;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return top;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// The cheapest right-angled path between two points that stays out of the blocked rectangles (they may be touched).
|
|
83
|
+
function shortestPath(from: Point, to: Point, blocked: readonly Rect[], bendCost: number): { path: Point[]; cost: number } | null {
|
|
84
|
+
const xs = [...new Set([from[0], to[0], ...blocked.flatMap(r => [r.x, r.x + r.width])])].sort((a, b) => a - b);
|
|
85
|
+
const ys = [...new Set([from[1], to[1], ...blocked.flatMap(r => [r.y, r.y + r.height])])].sort((a, b) => a - b);
|
|
86
|
+
if (xs.length * ys.length > MAX_NODES) return null;
|
|
87
|
+
const nx = xs.length;
|
|
88
|
+
const ny = ys.length;
|
|
89
|
+
const inside = (x: number, y: number): boolean => blocked.some(r => x > r.x && x < r.x + r.width && y > r.y && y < r.y + r.height);
|
|
90
|
+
const free = new Uint8Array(nx * ny);
|
|
91
|
+
for (let i = 0; i < nx; i++) for (let j = 0; j < ny; j++) free[i * ny + j] = inside(xs[i]!, ys[j]!) ? 0 : 1;
|
|
92
|
+
|
|
93
|
+
const start = xs.indexOf(from[0]) * ny + ys.indexOf(from[1]);
|
|
94
|
+
const goal = xs.indexOf(to[0]) * ny + ys.indexOf(to[1]);
|
|
95
|
+
if (!free[start] || !free[goal]) return null;
|
|
96
|
+
|
|
97
|
+
// State: node * 5 + the direction it was reached by (4 = none yet).
|
|
98
|
+
const best = new Float64Array(nx * ny * 5).fill(Infinity);
|
|
99
|
+
const before = new Int32Array(nx * ny * 5).fill(-1);
|
|
100
|
+
const heap = new Heap();
|
|
101
|
+
const heuristic = (node: number): number => Math.abs(xs[(node / ny) | 0]! - to[0]) + Math.abs(ys[node % ny]! - to[1]);
|
|
102
|
+
const first = start * 5 + 4;
|
|
103
|
+
best[first] = 0;
|
|
104
|
+
heap.push(heuristic(start), first);
|
|
105
|
+
|
|
106
|
+
while (heap.size > 0) {
|
|
107
|
+
const [, state] = heap.pop();
|
|
108
|
+
const node = (state / 5) | 0;
|
|
109
|
+
const dir = state % 5;
|
|
110
|
+
const cost = best[state]!;
|
|
111
|
+
if (node === goal) {
|
|
112
|
+
const path: Point[] = [];
|
|
113
|
+
for (let st = state; st !== -1; st = before[st]!) {
|
|
114
|
+
const n = (st / 5) | 0;
|
|
115
|
+
path.push([xs[(n / ny) | 0]!, ys[n % ny]!]);
|
|
116
|
+
}
|
|
117
|
+
return { path: path.reverse(), cost };
|
|
118
|
+
}
|
|
119
|
+
const [i, j] = [(node / ny) | 0, node % ny];
|
|
120
|
+
for (let d = 0; d < 4; d++) {
|
|
121
|
+
const [ni, nj] = [i + DIRECTION[d]![0], j + DIRECTION[d]![1]];
|
|
122
|
+
if (ni < 0 || nj < 0 || ni >= nx || nj >= ny || !free[ni * ny + nj]) continue;
|
|
123
|
+
const [x0, y0, x1, y1] = [xs[i]!, ys[j]!, xs[ni]!, ys[nj]!];
|
|
124
|
+
if (inside((x0 + x1) / 2, (y0 + y1) / 2)) continue;
|
|
125
|
+
const next = (ni * ny + nj) * 5 + d;
|
|
126
|
+
const total = cost + Math.abs(x1 - x0) + Math.abs(y1 - y0) + (dir !== 4 && dir !== d ? bendCost : 0);
|
|
127
|
+
if (total < best[next]!) {
|
|
128
|
+
best[next] = total;
|
|
129
|
+
before[next] = state;
|
|
130
|
+
heap.push(total + heuristic(ni * ny + nj), next);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const simplify = (points: Point[]): Point[] => {
|
|
138
|
+
const out: Point[] = [];
|
|
139
|
+
for (const p of points) {
|
|
140
|
+
const last = out[out.length - 1];
|
|
141
|
+
if (last && last[0] === p[0] && last[1] === p[1]) continue;
|
|
142
|
+
const before = out[out.length - 2];
|
|
143
|
+
if (before && last && ((before[0] === last[0] && last[0] === p[0]) || (before[1] === last[1] && last[1] === p[1]))) out[out.length - 1] = p;
|
|
144
|
+
else out.push(p);
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// Whether a path passes through the inside of a rectangle (touching its edge is allowed).
|
|
150
|
+
const crossesInterior = (path: readonly Point[], r: Rect): boolean => path.slice(1).some((p, i) => {
|
|
151
|
+
const a = path[i]!;
|
|
152
|
+
return Math.max(a[0], p[0]) > r.x && Math.min(a[0], p[0]) < r.x + r.width && Math.max(a[1], p[1]) > r.y && Math.min(a[1], p[1]) < r.y + r.height;
|
|
153
|
+
});
|
|
154
|
+
const clear = (path: readonly Point[], rects: readonly Rect[]): boolean => !rects.some(r => crossesInterior(path, r));
|
|
155
|
+
|
|
156
|
+
const bends = (points: readonly Point[]): number => Math.max(0, points.length - 2);
|
|
157
|
+
const length = (points: readonly Point[]): number => points.slice(1).reduce((sum, p, i) => sum + Math.abs(p[0] - points[i]![0]) + Math.abs(p[1] - points[i]![1]), 0);
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* A right-angled path from one shape to another that keeps clear of the other shapes. The ends sit `gap` outside the
|
|
161
|
+
* shapes' sides, which are chosen to give the cheapest path. Returns null when there is none (the shapes are walled in
|
|
162
|
+
* or the canvas is too large to search); the caller then keeps a straight arrow.
|
|
163
|
+
*
|
|
164
|
+
* `obstacles` are the shapes in the way. One that contains either end is a backdrop, not an obstacle, and is ignored.
|
|
165
|
+
*/
|
|
166
|
+
export function routeOrthogonal(from: Rect, to: Rect, obstacles: readonly Rect[], options: RouteOptions = {}): Point[] | null {
|
|
167
|
+
const { margin = 16, gap = 8, bendCost = 30 } = options;
|
|
168
|
+
const solid = obstacles.filter(o => !contains(o, from) && !contains(o, to));
|
|
169
|
+
// The last stretch before a shape is straight and long enough to carry an arrowhead; between shapes close together
|
|
170
|
+
// it is as short as the margin allows.
|
|
171
|
+
return bestRoute(from, to, solid, 30, { margin, gap, bendCost }) ?? bestRoute(from, to, solid, margin, { margin, gap, bendCost });
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Leaving a shape on the side that faces the other, and arriving on the side that faces back, reads as a flow; any other
|
|
175
|
+
// pair costs this much extra, so it is chosen only when it is clearly shorter.
|
|
176
|
+
const SIDE_PENALTY = 40;
|
|
177
|
+
function facingSides(from: Rect, to: Rect): [Side, Side] {
|
|
178
|
+
const [dx, dy] = [to.x + to.width / 2 - (from.x + from.width / 2), to.y + to.height / 2 - (from.y + from.height / 2)];
|
|
179
|
+
const out: Side = Math.abs(dy) >= Math.abs(dx) ? (dy >= 0 ? 2 : 0) : (dx >= 0 ? 1 : 3);
|
|
180
|
+
return [out, ((out + 2) % 4) as Side];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function bestRoute(from: Rect, to: Rect, solid: readonly Rect[], stub: number, { margin, gap, bendCost }: Required<RouteOptions>): Point[] | null {
|
|
184
|
+
const everything = [from, to, ...solid];
|
|
185
|
+
const [facingOut, facingIn] = facingSides(from, to);
|
|
186
|
+
const grown = (r: Rect): Rect => ({ x: r.x - margin, y: r.y - margin, width: r.width + 2 * margin, height: r.height + 2 * margin });
|
|
187
|
+
|
|
188
|
+
// Every side pair, cheapest possible first: a pair can cost no less than the distance between its two ends, so the
|
|
189
|
+
// search stops as soon as that exceeds the best path found (usually after the first one or two).
|
|
190
|
+
const pairs = ([0, 1, 2, 3] as Side[]).flatMap(a => ([0, 1, 2, 3] as Side[]).map(b => {
|
|
191
|
+
const [pa, pb] = [port(from, a, to), port(to, b, from)];
|
|
192
|
+
const p0: Point = [pa[0] + DIRECTION[a]![0] * gap, pa[1] + DIRECTION[a]![1] * gap];
|
|
193
|
+
const p3: Point = [pb[0] + DIRECTION[b]![0] * gap, pb[1] + DIRECTION[b]![1] * gap];
|
|
194
|
+
const s0: Point = [p0[0] + DIRECTION[a]![0] * stub, p0[1] + DIRECTION[a]![1] * stub];
|
|
195
|
+
const s1: Point = [p3[0] + DIRECTION[b]![0] * stub, p3[1] + DIRECTION[b]![1] * stub];
|
|
196
|
+
return { p0, p3, s0, s1, penalty: (a === facingOut ? 0 : SIDE_PENALTY) + (b === facingIn ? 0 : SIDE_PENALTY), lower: Math.abs(p3[0] - p0[0]) + Math.abs(p3[1] - p0[1]) };
|
|
197
|
+
})).sort((x, y) => x.lower - y.lower);
|
|
198
|
+
|
|
199
|
+
const best: { path: Point[] | null; cost: number } = { path: null, cost: Infinity };
|
|
200
|
+
// A candidate is kept when it keeps clear of every shape, and of the two it joins, and is cheaper than the best so far.
|
|
201
|
+
const consider = (path: Point[], penalty: number): boolean => {
|
|
202
|
+
if (!clear(path, solid) || crossesInterior(path, from) || crossesInterior(path, to)) return false;
|
|
203
|
+
const cost = length(path) + bendCost * bends(path) + penalty;
|
|
204
|
+
if (cost < best.cost) Object.assign(best, { path, cost });
|
|
205
|
+
return true;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
for (const { p0, p3, s0, s1, lower, penalty } of pairs) {
|
|
209
|
+
if (lower >= best.cost) break;
|
|
210
|
+
// Often the two ends line up, and no search is needed.
|
|
211
|
+
if ((s0[0] === s1[0] || s0[1] === s1[1]) && consider(simplify([p0, s0, s1, p3]), penalty)) continue;
|
|
212
|
+
const region = { x: Math.min(s0[0], s1[0]), y: Math.min(s0[1], s1[1]), width: Math.abs(s1[0] - s0[0]), height: Math.abs(s1[1] - s0[1]) };
|
|
213
|
+
// A path found among the nearby shapes may still run past one left out, so it is checked against all of them.
|
|
214
|
+
for (const among of [everything.filter(o => touches(region, o, REACH)), everything]) {
|
|
215
|
+
const found = shortestPath(s0, s1, among.map(grown), bendCost);
|
|
216
|
+
if (found && consider(simplify([p0, ...found.path, p3]), penalty)) break;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return best.path;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const NOT_OBSTACLES = new Set(['arrow', 'line', 'freedraw', 'frame', 'magicframe']);
|
|
223
|
+
const SHAPE_TYPES = new Set(['rectangle', 'diamond', 'ellipse']);
|
|
224
|
+
|
|
225
|
+
const rectOf = (e: ServerElement): Rect => ({ x: e.x, y: e.y, width: e.width ?? 0, height: e.height ?? 0 });
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Puts a right-angled, obstacle-avoiding path on an arrow between two shapes: its position, points and size. Everything
|
|
229
|
+
* else on the canvas that is a shape, free text or an image is in the way, except the arrow's own ends and text labels
|
|
230
|
+
* (which sit inside their shapes). Returns false, leaving the arrow alone, when there is no route.
|
|
231
|
+
*/
|
|
232
|
+
export function routeArrowAround(arrow: ServerElement, start: ServerElement, end: ServerElement, elements: Iterable<ServerElement>): boolean {
|
|
233
|
+
if (start.id === end.id) return false;
|
|
234
|
+
const all = [...elements];
|
|
235
|
+
const [startBox, endBox] = [rectOf(start), rectOf(end)];
|
|
236
|
+
// A zone behind the ends (it contains one of them) is a backdrop; the text written inside it, such as its title, is
|
|
237
|
+
// annotation, not something to route round.
|
|
238
|
+
const zones = all.filter(e => SHAPE_TYPES.has(e.type) && e.id !== start.id && e.id !== end.id && (contains(rectOf(e), startBox) || contains(rectOf(e), endBox))).map(rectOf);
|
|
239
|
+
const obstacles: Rect[] = [];
|
|
240
|
+
for (const e of all) {
|
|
241
|
+
if (e.isDeleted || NOT_OBSTACLES.has(e.type) || e.id === start.id || e.id === end.id || e.id === arrow.id) continue;
|
|
242
|
+
if (e.type === 'text' && (e.containerId || zones.some(z => contains(z, rectOf(e))))) continue;
|
|
243
|
+
const box = rectOf(e);
|
|
244
|
+
// Whatever lies inside an end shape (a card's header and text, a label) is part of it: the path stops at its outline.
|
|
245
|
+
if (contains(rectOf(start), box) || contains(rectOf(end), box)) continue;
|
|
246
|
+
obstacles.push(box);
|
|
247
|
+
}
|
|
248
|
+
const path = routeOrthogonal(rectOf(start), rectOf(end), obstacles);
|
|
249
|
+
if (!path) return false;
|
|
250
|
+
const [x, y] = path[0]!;
|
|
251
|
+
const points = path.map(([px, py]): Point => [px - x, py - y]);
|
|
252
|
+
const xs = points.map(p => p[0]);
|
|
253
|
+
const ys = points.map(p => p[1]);
|
|
254
|
+
Object.assign(arrow, { x, y, points, width: Math.max(...xs) - Math.min(...xs), height: Math.max(...ys) - Math.min(...ys) });
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { ServerElement } from '../types.js';
|
|
2
|
+
import { generateId } from '../types.js';
|
|
3
|
+
import {
|
|
4
|
+
batchCreateElementsStrict, deleteElementStrict, getElements, orderElementsStrict, updateElementStrict
|
|
5
|
+
} from './canvas-client.js';
|
|
6
|
+
import { compactElement } from './compact.js';
|
|
7
|
+
import { addFrame, frameScope, growFrame } from './frame-ops.js';
|
|
8
|
+
import type { FrameGrowth } from './frame-ops.js';
|
|
9
|
+
import { listFrames, overlappingFrames } from './frames.js';
|
|
10
|
+
import { fittedSize } from './layout-check.js';
|
|
11
|
+
|
|
12
|
+
/** What the canvas holds after a write, read back from the server: a write that reports success but changed nothing shows here. */
|
|
13
|
+
export async function sceneSummary(): Promise<{ elements: number }> {
|
|
14
|
+
return { elements: (await getElements()).filter(e => !e.isDeleted).length };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const FRAME_TYPES = new Set(['frame', 'magicframe']);
|
|
18
|
+
|
|
19
|
+
// What a caller means by a set of ids: those, the text labels bound to them, and, unless `groups` is off, the rest of
|
|
20
|
+
// any group they belong to.
|
|
21
|
+
export function withCompanions(all: readonly ServerElement[], ids: readonly string[], groups = true): ServerElement[] {
|
|
22
|
+
const byId = new Map(all.map(e => [e.id, e]));
|
|
23
|
+
const missing = ids.filter(id => !byId.has(id));
|
|
24
|
+
if (missing.length) throw new Error(`Not found: ${missing.join(', ')}`);
|
|
25
|
+
const picked = new Set(ids);
|
|
26
|
+
if (groups) {
|
|
27
|
+
const wanted = new Set(ids.flatMap(id => byId.get(id)!.groupIds ?? []));
|
|
28
|
+
for (const e of all) if (e.groupIds?.some(g => wanted.has(g))) picked.add(e.id);
|
|
29
|
+
}
|
|
30
|
+
for (const e of all) if (e.type === 'text' && e.containerId && picked.has(e.containerId)) picked.add(e.id);
|
|
31
|
+
return all.filter(e => picked.has(e.id));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const noFrames = (targets: readonly ServerElement[], what: string): void => {
|
|
35
|
+
if (targets.some(e => FRAME_TYPES.has(e.type))) throw new Error(`A frame cannot be ${what}`);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const outsideOf = (frame: { x: number; y: number; width: number; height: number }, shapes: readonly ServerElement[]): number =>
|
|
39
|
+
shapes.filter(e => e.x < frame.x || e.y < frame.y || e.x + (e.width ?? 0) > frame.x + frame.width || e.y + (e.height ?? 0) > frame.y + frame.height).length;
|
|
40
|
+
|
|
41
|
+
export interface Adopted { moved: number; ids: string[]; frameGrew?: FrameGrowth; outside?: number; reassigned?: number }
|
|
42
|
+
|
|
43
|
+
// Puts elements on a frame without moving them. A frame grows right and down to hold them; what lies left of or above it
|
|
44
|
+
// stays outside and is clipped, which `outside` counts.
|
|
45
|
+
export async function moveElementsToFrame(ids: readonly string[], frameRef: string): Promise<Adopted> {
|
|
46
|
+
const scope = await frameScope(frameRef);
|
|
47
|
+
const targets = withCompanions(await getElements(), ids);
|
|
48
|
+
noFrames(targets, 'put in a frame');
|
|
49
|
+
const updated: ServerElement[] = [];
|
|
50
|
+
const done: string[] = [];
|
|
51
|
+
for (const e of targets) await step(async () => updated.push(await updateElementStrict({ id: e.id, frameId: scope.frame.id } as never)), done, e.id);
|
|
52
|
+
const frameGrew = await growFrame(scope, updated);
|
|
53
|
+
const reassigned = targets.filter(e => e.frameId && e.frameId !== scope.frame.id).length;
|
|
54
|
+
const outside = outsideOf(frameGrew ? { x: frameGrew.to.canvasX, y: frameGrew.to.canvasY, width: frameGrew.to.width, height: frameGrew.to.height } : scope.frame, updated);
|
|
55
|
+
return { moved: updated.length, ids: updated.map(e => e.id), ...(frameGrew ? { frameGrew } : {}), ...(outside ? { outside } : {}), ...(reassigned ? { reassigned } : {}) };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// A frame fitted around these elements, which then sit on it.
|
|
59
|
+
export async function addFrameAround(name: string, ids: readonly string[], padding = 40) {
|
|
60
|
+
const all = await getElements();
|
|
61
|
+
const targets = withCompanions(all, ids);
|
|
62
|
+
noFrames(targets, 'wrapped in a frame');
|
|
63
|
+
const minX = Math.min(...targets.map(e => e.x));
|
|
64
|
+
const minY = Math.min(...targets.map(e => e.y));
|
|
65
|
+
const maxX = Math.max(...targets.map(e => e.x + (e.width ?? 0)));
|
|
66
|
+
const maxY = Math.max(...targets.map(e => e.y + (e.height ?? 0)));
|
|
67
|
+
const place = { x: minX - padding, y: minY - padding, width: maxX - minX + 2 * padding, height: maxY - minY + 2 * padding };
|
|
68
|
+
const overlaps = overlappingFrames(place, listFrames(all), '');
|
|
69
|
+
const frame = await addFrame(name, {}, place);
|
|
70
|
+
const done: string[] = [];
|
|
71
|
+
// The frame exists by now, so a failure here leaves it behind with only some elements on it.
|
|
72
|
+
for (const e of targets) await step(() => updateElementStrict({ id: e.id, frameId: frame.id } as never), done, e.id);
|
|
73
|
+
const reassigned = targets.filter(e => e.frameId).length;
|
|
74
|
+
return { frame, adopted: targets.length, ...(reassigned ? { reassigned } : {}), ...(overlaps.length ? { overlaps } : {}) };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Deletes elements and the text labels bound to them.
|
|
78
|
+
export async function deleteElements(ids: readonly string[]): Promise<string[]> {
|
|
79
|
+
const targets = withCompanions(await getElements(), ids, false);
|
|
80
|
+
noFrames(targets, 'deleted here (use frame delete)');
|
|
81
|
+
const done: string[] = [];
|
|
82
|
+
for (const e of targets) await step(() => deleteElementStrict(e.id), done, e.id);
|
|
83
|
+
return done;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Writes are one element at a time, so a failure part way says what was already done instead of leaving that unsaid.
|
|
87
|
+
async function step(write: () => Promise<unknown>, done: string[], id: string): Promise<void> {
|
|
88
|
+
try {
|
|
89
|
+
await write();
|
|
90
|
+
} catch (error) {
|
|
91
|
+
throw new Error(`${(error as Error).message} (stopped at ${id}; already done: ${done.length ? done.join(', ') : 'none'})`);
|
|
92
|
+
}
|
|
93
|
+
done.push(id);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Moves elements with their labels and groups (all of an outer group, as selecting one does). An arrow joined to a
|
|
97
|
+
// shape follows it (the server reroutes it); only a free arrow is moved by hand.
|
|
98
|
+
export async function moveElements(ids: readonly string[], dx: number, dy: number): Promise<string[]> {
|
|
99
|
+
const targets = withCompanions(await getElements(), ids);
|
|
100
|
+
const moved: string[] = [];
|
|
101
|
+
for (const e of targets) {
|
|
102
|
+
const joined = e as ServerElement & { startBinding?: unknown; endBinding?: unknown; start?: unknown; end?: unknown };
|
|
103
|
+
if ((e.type === 'arrow' || e.type === 'line') && (joined.startBinding || joined.endBinding || joined.start || joined.end)) continue;
|
|
104
|
+
await step(() => updateElementStrict({ id: e.id, x: e.x + dx, y: e.y + dy }), moved, e.id);
|
|
105
|
+
}
|
|
106
|
+
return moved;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export async function reorderElements(ids: readonly string[], to: 'back' | 'front'): Promise<number> {
|
|
110
|
+
return orderElementsStrict([...ids], to);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const LABELLED = new Set(['rectangle', 'diamond', 'ellipse']);
|
|
114
|
+
|
|
115
|
+
// Grows shapes so their labels fit; never shrinks, and leaves a shape alone when its label already fits or it is not a box.
|
|
116
|
+
// A shape on a frame that grows past it takes the frame along.
|
|
117
|
+
export async function fitToText(ids: readonly string[]): Promise<{ fitted: Array<{ id: string; from: { width: number; height: number }; to: { width: number; height: number } }>; frameGrew?: FrameGrowth[] }> {
|
|
118
|
+
const all = await getElements();
|
|
119
|
+
const bound = new Map(all.filter(e => e.type === 'text' && e.containerId).map(e => [e.containerId!, e]));
|
|
120
|
+
const fitted = [];
|
|
121
|
+
const grown = new Map<string, ServerElement[]>();
|
|
122
|
+
for (const id of ids) {
|
|
123
|
+
const shape = all.find(e => e.id === id);
|
|
124
|
+
if (!shape) throw new Error(`Element ${id} not found`);
|
|
125
|
+
const size = LABELLED.has(shape.type) ? fittedSize(shape, bound.get(id)) : null;
|
|
126
|
+
if (!size) continue;
|
|
127
|
+
const updated = await updateElementStrict({ id, ...size });
|
|
128
|
+
fitted.push({ id, from: { width: shape.width ?? 0, height: shape.height ?? 0 }, to: size });
|
|
129
|
+
if (shape.frameId) grown.set(shape.frameId, [...(grown.get(shape.frameId) ?? []), updated]);
|
|
130
|
+
}
|
|
131
|
+
const frameGrew: FrameGrowth[] = [];
|
|
132
|
+
for (const [frame, shapes] of grown) {
|
|
133
|
+
const growth = await growFrame(await frameScope(frame), shapes);
|
|
134
|
+
if (growth) frameGrew.push(growth);
|
|
135
|
+
}
|
|
136
|
+
return { fitted, ...(frameGrew.length ? { frameGrew } : {}) };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// A true copy: the labels and groups come along, and what pointed between the originals points between the copies.
|
|
140
|
+
// A reference to something that was not copied is dropped rather than left pointing at the original.
|
|
141
|
+
export async function cloneElements(
|
|
142
|
+
ids: readonly string[],
|
|
143
|
+
options: { offsetX?: number; offsetY?: number; frame?: string } = {}
|
|
144
|
+
): Promise<{ copies: ServerElement[]; frameGrew?: FrameGrowth }> {
|
|
145
|
+
const { offsetX = 20, offsetY = 20 } = options;
|
|
146
|
+
const scope = options.frame === undefined ? undefined : await frameScope(options.frame);
|
|
147
|
+
const originals = withCompanions(await getElements(), ids);
|
|
148
|
+
noFrames(originals, 'copied');
|
|
149
|
+
const newIds = new Map(originals.map(e => [e.id, generateId()]));
|
|
150
|
+
const newGroups = new Map<string, string>();
|
|
151
|
+
const group = (g: string): string => newGroups.get(g) ?? (newGroups.set(g, generateId()), newGroups.get(g)!);
|
|
152
|
+
const remap = (id: string | null | undefined): string | null => (id && newIds.has(id) ? newIds.get(id)! : null);
|
|
153
|
+
|
|
154
|
+
const copies = originals.map((original): ServerElement => {
|
|
155
|
+
const copy = structuredClone(compactElement(original)) as Record<string, any>;
|
|
156
|
+
const source = original as Record<string, any>;
|
|
157
|
+
copy.id = newIds.get(original.id);
|
|
158
|
+
copy.x = original.x + offsetX;
|
|
159
|
+
copy.y = original.y + offsetY;
|
|
160
|
+
if (original.groupIds) copy.groupIds = original.groupIds.map(group);
|
|
161
|
+
if (original.containerId !== undefined) copy.containerId = remap(original.containerId);
|
|
162
|
+
if (original.boundElements) copy.boundElements = original.boundElements.filter(b => newIds.has(b.id)).map(b => ({ ...b, id: newIds.get(b.id)! }));
|
|
163
|
+
for (const key of ['startBinding', 'endBinding'] as const) {
|
|
164
|
+
const binding = source[key];
|
|
165
|
+
if (binding) copy[key] = newIds.has(binding.elementId) ? { ...binding, elementId: newIds.get(binding.elementId) } : null;
|
|
166
|
+
}
|
|
167
|
+
// The server binds an arrow by `start` and `end` as well, and would reattach a copy to the originals through them.
|
|
168
|
+
for (const key of ['start', 'end'] as const) {
|
|
169
|
+
const link = source[key];
|
|
170
|
+
if (!link?.id) continue;
|
|
171
|
+
if (newIds.has(link.id)) copy[key] = { ...link, id: newIds.get(link.id) };
|
|
172
|
+
else delete copy[key];
|
|
173
|
+
}
|
|
174
|
+
// Two elements must not share a stacking index; the server and the page assign one.
|
|
175
|
+
delete copy.index;
|
|
176
|
+
if (scope) copy.frameId = scope.frame.id;
|
|
177
|
+
return copy as ServerElement;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const created = await batchCreateElementsStrict(copies);
|
|
181
|
+
const frameGrew = scope ? await growFrame(scope, created) : undefined;
|
|
182
|
+
return { copies: created, ...(frameGrew ? { frameGrew } : {}) };
|
|
183
|
+
}
|