sldeditor 0.0.1
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 +25 -0
- package/README.md +117 -0
- package/THIRD_PARTY_NOTICES.md +31 -0
- package/dist/OneLineEditor.d.ts +24 -0
- package/dist/OneLineEditor.d.ts.map +1 -0
- package/dist/canvas/AnnotationLayer.d.ts +18 -0
- package/dist/canvas/AnnotationLayer.d.ts.map +1 -0
- package/dist/canvas/BusHandles.d.ts +10 -0
- package/dist/canvas/BusHandles.d.ts.map +1 -0
- package/dist/canvas/BusLayer.d.ts +8 -0
- package/dist/canvas/BusLayer.d.ts.map +1 -0
- package/dist/canvas/BusbarPreview.d.ts +7 -0
- package/dist/canvas/BusbarPreview.d.ts.map +1 -0
- package/dist/canvas/CanvasSvg.d.ts +11 -0
- package/dist/canvas/CanvasSvg.d.ts.map +1 -0
- package/dist/canvas/ElementHoverLabel.d.ts +9 -0
- package/dist/canvas/ElementHoverLabel.d.ts.map +1 -0
- package/dist/canvas/ElementLayer.d.ts +17 -0
- package/dist/canvas/ElementLayer.d.ts.map +1 -0
- package/dist/canvas/FreeAnnotationLayer.d.ts +18 -0
- package/dist/canvas/FreeAnnotationLayer.d.ts.map +1 -0
- package/dist/canvas/MarqueeOverlay.d.ts +6 -0
- package/dist/canvas/MarqueeOverlay.d.ts.map +1 -0
- package/dist/canvas/PlaceGhost.d.ts +16 -0
- package/dist/canvas/PlaceGhost.d.ts.map +1 -0
- package/dist/canvas/SelectionOverlay.d.ts +7 -0
- package/dist/canvas/SelectionOverlay.d.ts.map +1 -0
- package/dist/canvas/TerminalLayer.d.ts +13 -0
- package/dist/canvas/TerminalLayer.d.ts.map +1 -0
- package/dist/canvas/WireLayer.d.ts +11 -0
- package/dist/canvas/WireLayer.d.ts.map +1 -0
- package/dist/canvas/WirePreview.d.ts +8 -0
- package/dist/canvas/WirePreview.d.ts.map +1 -0
- package/dist/canvas/drop-on-bus.d.ts +45 -0
- package/dist/canvas/drop-on-bus.d.ts.map +1 -0
- package/dist/canvas/fit-to-content.d.ts +22 -0
- package/dist/canvas/fit-to-content.d.ts.map +1 -0
- package/dist/canvas/grid.d.ts +14 -0
- package/dist/canvas/grid.d.ts.map +1 -0
- package/dist/canvas/hit-test.d.ts +14 -0
- package/dist/canvas/hit-test.d.ts.map +1 -0
- package/dist/canvas/hover-bus.d.ts +7 -0
- package/dist/canvas/hover-bus.d.ts.map +1 -0
- package/dist/canvas/index.d.ts +11 -0
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/canvas/marquee-bus.d.ts +17 -0
- package/dist/canvas/marquee-bus.d.ts.map +1 -0
- package/dist/canvas/resolve-wire-target.d.ts +4 -0
- package/dist/canvas/resolve-wire-target.d.ts.map +1 -0
- package/dist/canvas/synthetic-pointer-cancel.d.ts +12 -0
- package/dist/canvas/synthetic-pointer-cancel.d.ts.map +1 -0
- package/dist/canvas/tools/BusbarTool.d.ts +3 -0
- package/dist/canvas/tools/BusbarTool.d.ts.map +1 -0
- package/dist/canvas/tools/PanTool.d.ts +3 -0
- package/dist/canvas/tools/PanTool.d.ts.map +1 -0
- package/dist/canvas/tools/PlaceTool.d.ts +3 -0
- package/dist/canvas/tools/PlaceTool.d.ts.map +1 -0
- package/dist/canvas/tools/SelectTool.d.ts +3 -0
- package/dist/canvas/tools/SelectTool.d.ts.map +1 -0
- package/dist/canvas/tools/TextTool.d.ts +3 -0
- package/dist/canvas/tools/TextTool.d.ts.map +1 -0
- package/dist/canvas/tools/WireTool.d.ts +3 -0
- package/dist/canvas/tools/WireTool.d.ts.map +1 -0
- package/dist/canvas/tools/index.d.ts +4 -0
- package/dist/canvas/tools/index.d.ts.map +1 -0
- package/dist/canvas/tools/types.d.ts +25 -0
- package/dist/canvas/tools/types.d.ts.map +1 -0
- package/dist/canvas/touch.d.ts +20 -0
- package/dist/canvas/touch.d.ts.map +1 -0
- package/dist/canvas/transform-attr.d.ts +3 -0
- package/dist/canvas/transform-attr.d.ts.map +1 -0
- package/dist/canvas/useHoverHighlight.d.ts +3 -0
- package/dist/canvas/useHoverHighlight.d.ts.map +1 -0
- package/dist/canvas/useKeyboardShortcuts.d.ts +15 -0
- package/dist/canvas/useKeyboardShortcuts.d.ts.map +1 -0
- package/dist/canvas/useTools.d.ts +4 -0
- package/dist/canvas/useTools.d.ts.map +1 -0
- package/dist/canvas/useViewport.d.ts +18 -0
- package/dist/canvas/useViewport.d.ts.map +1 -0
- package/dist/canvas/viewport-bus.d.ts +4 -0
- package/dist/canvas/viewport-bus.d.ts.map +1 -0
- package/dist/canvas/wire-target-bus.d.ts +14 -0
- package/dist/canvas/wire-target-bus.d.ts.map +1 -0
- package/dist/canvas/zoom-bus.d.ts +11 -0
- package/dist/canvas/zoom-bus.d.ts.map +1 -0
- package/dist/compiler/auto-layout.d.ts +18 -0
- package/dist/compiler/auto-layout.d.ts.map +1 -0
- package/dist/compiler/auto-route.d.ts +10 -0
- package/dist/compiler/auto-route.d.ts.map +1 -0
- package/dist/compiler/compile.d.ts +4 -0
- package/dist/compiler/compile.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +6 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/internal-model.d.ts +73 -0
- package/dist/compiler/internal-model.d.ts.map +1 -0
- package/dist/compiler/library-index.d.ts +4 -0
- package/dist/compiler/library-index.d.ts.map +1 -0
- package/dist/compiler/transforms.d.ts +7 -0
- package/dist/compiler/transforms.d.ts.map +1 -0
- package/dist/compiler/union-find.d.ts +14 -0
- package/dist/compiler/union-find.d.ts.map +1 -0
- package/dist/components/ContextMenu.d.ts +26 -0
- package/dist/components/ContextMenu.d.ts.map +1 -0
- package/dist/components/ContextualToolbar.d.ts +12 -0
- package/dist/components/ContextualToolbar.d.ts.map +1 -0
- package/dist/components/EditorShell.d.ts +2 -0
- package/dist/components/EditorShell.d.ts.map +1 -0
- package/dist/components/ExportMenu.d.ts +8 -0
- package/dist/components/ExportMenu.d.ts.map +1 -0
- package/dist/components/FileMenu.d.ts +11 -0
- package/dist/components/FileMenu.d.ts.map +1 -0
- package/dist/components/FloatingToolbar.d.ts +2 -0
- package/dist/components/FloatingToolbar.d.ts.map +1 -0
- package/dist/components/LeftPanel.d.ts +2 -0
- package/dist/components/LeftPanel.d.ts.map +1 -0
- package/dist/components/LibraryPopover.d.ts +8 -0
- package/dist/components/LibraryPopover.d.ts.map +1 -0
- package/dist/components/OnboardingCard.d.ts +13 -0
- package/dist/components/OnboardingCard.d.ts.map +1 -0
- package/dist/components/PropertyPanel.d.ts +8 -0
- package/dist/components/PropertyPanel.d.ts.map +1 -0
- package/dist/components/RightPanel.d.ts +2 -0
- package/dist/components/RightPanel.d.ts.map +1 -0
- package/dist/components/ViewToolbar.d.ts +19 -0
- package/dist/components/ViewToolbar.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/tooltip.d.ts +18 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/upward-popover.d.ts +8 -0
- package/dist/components/ui/upward-popover.d.ts.map +1 -0
- package/dist/element-library/index.d.ts +14 -0
- package/dist/element-library/index.d.ts.map +1 -0
- package/dist/hooks/editor-tier.d.ts +32 -0
- package/dist/hooks/editor-tier.d.ts.map +1 -0
- package/dist/hooks/use-editor-tier.d.ts +6 -0
- package/dist/hooks/use-editor-tier.d.ts.map +1 -0
- package/dist/hooks/use-onboarding.d.ts +15 -0
- package/dist/hooks/use-onboarding.d.ts.map +1 -0
- package/dist/hooks/use-panels.d.ts +16 -0
- package/dist/hooks/use-panels.d.ts.map +1 -0
- package/dist/hooks/use-theme.d.ts +24 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +14 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/library.d.ts +14 -0
- package/dist/i18n/library.d.ts.map +1 -0
- package/dist/i18n/messages.d.ts +348 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/export-dxf.d.ts +16 -0
- package/dist/lib/export-dxf.d.ts.map +1 -0
- package/dist/lib/export-image.d.ts +13 -0
- package/dist/lib/export-image.d.ts.map +1 -0
- package/dist/lib/file-io.d.ts +26 -0
- package/dist/lib/file-io.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/model/index.d.ts +3 -0
- package/dist/model/index.d.ts.map +1 -0
- package/dist/model/library.d.ts +115 -0
- package/dist/model/library.d.ts.map +1 -0
- package/dist/model/types.d.ts +78 -0
- package/dist/model/types.d.ts.map +1 -0
- package/dist/sldeditor.cjs +193 -0
- package/dist/sldeditor.cjs.map +1 -0
- package/dist/sldeditor.js +11601 -0
- package/dist/sldeditor.js.map +1 -0
- package/dist/store/id-allocator.d.ts +11 -0
- package/dist/store/id-allocator.d.ts.map +1 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/store.d.ts +104 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +107 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NovaShang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Note: This software embeds electrical symbols originally from the QElectroTech
|
|
24
|
+
project (https://qelectrotech.org), distributed under the Creative Commons
|
|
25
|
+
Attribution 3.0 License. See THIRD_PARTY_NOTICES.md for attribution details.
|
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# sldeditor
|
|
2
|
+
|
|
3
|
+
In-browser editor component for **electrical single-line diagrams (SLD / 一次系统图)**. Pure-frontend, no backend, no cloud. Designed to be dropped into a React app or used standalone.
|
|
4
|
+
|
|
5
|
+
> The local source directory is named `oneline-editor` (legacy); the npm package is `sldeditor`.
|
|
6
|
+
|
|
7
|
+
## What's in the box
|
|
8
|
+
|
|
9
|
+
- **47 built-in symbols** — breaker, disconnector, transformer (2W/3W), busbar, CT/PT, generator, motor, PV, inverter, EV charger, battery, meter, arrester, fuse, recloser, VFD, and more. Symbol set lives in `src/element-library/*.json` and is hot-loaded into a typed registry.
|
|
10
|
+
- **Terminal-level wiring** — connect to pins, not bounding boxes. Auto-snap + orthogonal routing.
|
|
11
|
+
- **Busbar as a first-class element** — stretchable, multi-tap, handles arbitrary device attachments.
|
|
12
|
+
- **Explicit topology model** — connectivity nodes computed from terminal coincidence, separate from rendering geometry. Exposed via the `compile()` function so you can run your own analyses on top.
|
|
13
|
+
- **Undo/redo, multi-select, copy/paste, alignment, snap, grid, zoom/pan**.
|
|
14
|
+
- **Local-first persistence** — JSON file open/save, plus SVG / PNG / DXF export. State is also cached in `localStorage` so refresh doesn't lose work.
|
|
15
|
+
- **i18n** — Chinese + English UI, locale store exposed so embedders can sync with their own translation layer.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install sldeditor
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { OneLineEditor } from 'sldeditor';
|
|
25
|
+
import 'sldeditor/style.css';
|
|
26
|
+
|
|
27
|
+
export default function App() {
|
|
28
|
+
return (
|
|
29
|
+
<div style={{ height: '100vh' }}>
|
|
30
|
+
<OneLineEditor />
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Peer deps: `react >= 18`, `react-dom >= 18` (React 19 tested).
|
|
37
|
+
|
|
38
|
+
`OneLineEditor` mounts a full editor (canvas + toolbars + panels). Pass `diagram` to seed an initial `DiagramFile`; otherwise it loads from `localStorage` or starts empty.
|
|
39
|
+
|
|
40
|
+
### Style isolation
|
|
41
|
+
|
|
42
|
+
Every selector in `sldeditor/style.css` is scoped under `.ole-root` — including all Tailwind utilities and CSS variables. The editor always renders that wrapper, so the stylesheet is safe to drop into a host app that has its own Tailwind, design system, or hand-written CSS without collisions.
|
|
43
|
+
|
|
44
|
+
### Migrating from a git submodule
|
|
45
|
+
|
|
46
|
+
If your repo currently pulls this project as a submodule:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git submodule deinit -- oneline-editor
|
|
50
|
+
git rm oneline-editor
|
|
51
|
+
rm -rf .git/modules/oneline-editor
|
|
52
|
+
npm install sldeditor
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then rewrite imports:
|
|
56
|
+
|
|
57
|
+
```diff
|
|
58
|
+
- import { OneLineEditor } from '../oneline-editor/src';
|
|
59
|
+
+ import { OneLineEditor } from 'sldeditor';
|
|
60
|
+
+ import 'sldeditor/style.css';
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The `style.css` import is **required** in npm mode (in the submodule layout your bundler probably picked up the source Tailwind file via content scan; in npm mode you get the prebuilt bundle).
|
|
64
|
+
|
|
65
|
+
## Public API
|
|
66
|
+
|
|
67
|
+
The editor reads/writes from a built-in zustand store. For embedding apps that want programmatic control (importers, AI tool-calling, custom renderers), `src/index.ts` exports:
|
|
68
|
+
|
|
69
|
+
- `useEditorStore` — full store: diagram, selection, viewport, undo stack
|
|
70
|
+
- `compile(diagram)` — produces an `InternalModel` with resolved geometry + connectivity nodes; use it to build viewers or run topology analysis without re-implementing the model
|
|
71
|
+
- `LIBRARY`, `getLibraryEntry` — the symbol registry
|
|
72
|
+
- `newBusId`, `newElementId`, `wireIdFromEnds` — id allocators for programmatic edits (deterministic content-hash wire ids so the same endpoint pair always maps to the same id)
|
|
73
|
+
- `FileMenu`, `ExportMenu` — optional toolbar widgets if you want the bundled file/export UX
|
|
74
|
+
- `buildExportSvg`, `downloadSvg`, `downloadPng`, `buildExportDxf`, `downloadDxf` — export primitives if you're building your own export UI
|
|
75
|
+
- `fitToContent`, `fitToContentSoon` — reset the viewport after programmatic edits
|
|
76
|
+
- `useLocale` — sync editor UI language with your app's i18n
|
|
77
|
+
|
|
78
|
+
## What it's not
|
|
79
|
+
|
|
80
|
+
- Not a format converter — does **not** read/write CIM, IEC 61850 SCL, PSD-BPA, PSS/E, or PowerFactory formats. JSON only.
|
|
81
|
+
- Not a simulator — no power flow, short-circuit, or stability calculations.
|
|
82
|
+
- Not a SCADA viewer — no real-time binding.
|
|
83
|
+
- Not a secondary / control-loop diagram tool.
|
|
84
|
+
|
|
85
|
+
## Docs
|
|
86
|
+
|
|
87
|
+
- [Getting started](./docs/getting-started.md) — install, sizing, seeding, theme/locale, exports
|
|
88
|
+
- [API reference](./docs/api.md) — every public export, grouped by purpose
|
|
89
|
+
- [Data model](./docs/data-model.md) — `DiagramFile` schema
|
|
90
|
+
- [Embedding + viewer API design](./docs/binding-and-viewer-api.md) — runtime data-binding plans
|
|
91
|
+
- [Runtime PRD](./docs/runtime-prd.md) — read-only viewer roadmap
|
|
92
|
+
- [Blog / changelog notes](./docs/blog/)
|
|
93
|
+
|
|
94
|
+
## Develop
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
npm install
|
|
98
|
+
npm run dev # standalone demo at localhost:5173
|
|
99
|
+
npm run build:lib # produces dist/sldeditor.js + dist/style.css
|
|
100
|
+
npm run typecheck
|
|
101
|
+
npm test
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Releasing
|
|
105
|
+
|
|
106
|
+
Versions ship via [Changesets](https://github.com/changesets/changesets). After making a publishable change:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npx changeset # write a patch/minor/major note
|
|
110
|
+
git commit -am "feat: ..."
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
When the PR lands on `master`, the **Release** GitHub Action opens a "Version Packages" PR; merging that PR publishes to npm and creates a GitHub release. Repo needs an `NPM_TOKEN` secret with automation-token scope.
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT. Third-party attributions in [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md).
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Third-Party Notices
|
|
2
|
+
|
|
3
|
+
OneLineEditor 包含、使用或基于以下第三方资源。本文件汇总它们的来源、许可与使用约束。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## QElectroTech Elements Collection
|
|
8
|
+
|
|
9
|
+
- **来源**:QElectroTech 项目, https://qelectrotech.org
|
|
10
|
+
- **使用位置**:`third_party/qelectrotech/10_electric/`
|
|
11
|
+
- **使用方式**:作为电气元件符号的素材来源。后续会通过脚本将 `.elmt` 文件转换为 SVG + 端口元数据,集成到本项目的元件库中。
|
|
12
|
+
- **License**:Creative Commons Attribution 3.0 (CC-BY 3.0)
|
|
13
|
+
- 全文:https://creativecommons.org/licenses/by/3.0/
|
|
14
|
+
- 上游声明:见 `third_party/qelectrotech/ELEMENTS.LICENSE`
|
|
15
|
+
|
|
16
|
+
### 署名(Attribution)
|
|
17
|
+
|
|
18
|
+
> Electrical symbols originally from the QElectroTech project (https://qelectrotech.org), distributed under the Creative Commons Attribution 3.0 License.
|
|
19
|
+
>
|
|
20
|
+
> 本产品中的电气元件符号源自 QElectroTech 项目(https://qelectrotech.org),依 CC-BY 3.0 许可使用。如有改动(例如适配 Web 渲染、调整端子坐标),均为 OneLineEditor 项目所做的修改。
|
|
21
|
+
|
|
22
|
+
### 使用约束
|
|
23
|
+
|
|
24
|
+
1. **必须保留署名**:在产品的"关于"信息、文档或源代码注释中保留上述 attribution。
|
|
25
|
+
2. **必须声明修改**:经过转换/修改的元件 SVG 应在元数据中保留 "modified from QElectroTech original" 字样。
|
|
26
|
+
3. **不可暗示作者背书**:不得以任何方式暗示 QElectroTech 项目或其作者认可、推荐 OneLineEditor。
|
|
27
|
+
4. **禁止用作机器学习训练数据**:上游 ELEMENTS.LICENSE 显式禁止将 elements 文件用于训练 ML 模型。本项目不得、亦不得允许第三方将 `third_party/qelectrotech/` 下的 `.elmt` 文件或其衍生产物用于此目的。
|
|
28
|
+
|
|
29
|
+
### 注意
|
|
30
|
+
|
|
31
|
+
- **QElectroTech 应用程序本体**采用 GPLv2 license。本项目**不**包含或链接其应用代码,仅使用其 elements collection(CC-BY 3.0)。GPLv2 不波及本项目。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DiagramFile } from './model';
|
|
2
|
+
import { Locale } from './i18n';
|
|
3
|
+
import { Theme } from './hooks/use-theme';
|
|
4
|
+
export interface OneLineEditorProps {
|
|
5
|
+
className?: string;
|
|
6
|
+
/** Initial DiagramFile to render. Re-renders when this reference changes. */
|
|
7
|
+
diagram?: DiagramFile;
|
|
8
|
+
/**
|
|
9
|
+
* Force the editor's UI language. When omitted, falls back to the user's
|
|
10
|
+
* previous choice (localStorage) or the browser's locale. When set, the
|
|
11
|
+
* embedder owns the language and any change to this prop is mirrored into
|
|
12
|
+
* the locale store.
|
|
13
|
+
*/
|
|
14
|
+
locale?: Locale;
|
|
15
|
+
/**
|
|
16
|
+
* Force the editor's color mode. When omitted, uses the user's previous
|
|
17
|
+
* choice or OS `prefers-color-scheme`. Applied via the `dark` class on
|
|
18
|
+
* `<html>` (the standard Tailwind pattern), so embedding hosts that share
|
|
19
|
+
* the same documentElement will see the same class.
|
|
20
|
+
*/
|
|
21
|
+
theme?: Theme;
|
|
22
|
+
}
|
|
23
|
+
export declare function OneLineEditor({ className, diagram, locale, theme }: OneLineEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=OneLineEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OneLineEditor.d.ts","sourceRoot":"","sources":["../src/OneLineEditor.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAa,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,wBAAgB,aAAa,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,kBAAkB,2CAoCtF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders structural labels (element ID + showOnCanvas params) next to each
|
|
3
|
+
* element. Labels are derived purely from `Element` data and the library
|
|
4
|
+
* schema — they do not live in the diagram's serialized form.
|
|
5
|
+
*
|
|
6
|
+
* The label block is positioned at the world projection of the element's
|
|
7
|
+
* `LibraryEntry.label` anchor (or a viewBox-derived fallback). Element
|
|
8
|
+
* rotation moves the anchor accordingly, but the text itself is rendered
|
|
9
|
+
* upright (no rotate on the text group) so labels stay readable.
|
|
10
|
+
*
|
|
11
|
+
* Visibility is governed by `DiagramFile.meta.labelMode`:
|
|
12
|
+
* - 'off' → no labels.
|
|
13
|
+
* - 'id' → element name/ID only.
|
|
14
|
+
* - 'all' → ID plus each library param marked `showOnCanvas: true`.
|
|
15
|
+
* Default when unset: 'all'.
|
|
16
|
+
*/
|
|
17
|
+
export declare function AnnotationLayer(): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=AnnotationLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationLayer.d.ts","sourceRoot":"","sources":["../../src/canvas/AnnotationLayer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH,wBAAgB,eAAe,4CAoD9B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stretch handles for the selected bus. Two `<circle>` grips at the bus's
|
|
3
|
+
* endpoints. Dragging a grip updates the bus's `span`, and — for the
|
|
4
|
+
* trailing grip — shifts `at` so the opposite end stays fixed visually.
|
|
5
|
+
*
|
|
6
|
+
* Handles capture pointer events themselves; SelectTool sees the drag start
|
|
7
|
+
* on a non-element target and won't try to also move the bus body.
|
|
8
|
+
*/
|
|
9
|
+
export declare function BusHandles(): import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
//# sourceMappingURL=BusHandles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BusHandles.d.ts","sourceRoot":"","sources":["../../src/canvas/BusHandles.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAUH,wBAAgB,UAAU,mDAkCzB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders one `<g>` per bus. Each bus is a horizontal or vertical line
|
|
3
|
+
* segment whose length is `geometry.span` and direction is given by
|
|
4
|
+
* `geometry.axis` (x → horizontal, y → vertical). Tagged with `data-bus-id`
|
|
5
|
+
* so hit-test can identify clicks on the bus body.
|
|
6
|
+
*/
|
|
7
|
+
export declare function BusLayer(): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=BusLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BusLayer.d.ts","sourceRoot":"","sources":["../../src/canvas/BusLayer.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,wBAAgB,QAAQ,4CA0EvB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live preview for the busbar tool. Snaps the cursor to the dominant axis
|
|
3
|
+
* (horizontal or vertical) so users see exactly the line that will be
|
|
4
|
+
* created on pointerup.
|
|
5
|
+
*/
|
|
6
|
+
export declare function BusbarPreview(): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
//# sourceMappingURL=BusbarPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BusbarPreview.d.ts","sourceRoot":"","sources":["../../src/canvas/BusbarPreview.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,wBAAgB,aAAa,mDAmC5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Top-level canvas SVG. Owns the pan/zoom viewport `<g>`, the static grid
|
|
3
|
+
* background, and the active-tool dispatcher. Layers (wires, elements,
|
|
4
|
+
* selection, terminals, previews) are children of the viewport so they
|
|
5
|
+
* pan/zoom together.
|
|
6
|
+
*
|
|
7
|
+
* Z-order (back to front): grid → wires → elements → selection → terminals
|
|
8
|
+
* → wire preview → place ghost.
|
|
9
|
+
*/
|
|
10
|
+
export declare function CanvasSvg(): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=CanvasSvg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CanvasSvg.d.ts","sourceRoot":"","sources":["../../src/canvas/CanvasSvg.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyDH,wBAAgB,SAAS,4CAgRxB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Floating name tag that follows the hovered element on the canvas. Reads
|
|
3
|
+
* the hover signal published by `useHoverHighlight` and locates the
|
|
4
|
+
* element's `<g>` via the DOM (so it tracks pan, zoom, and live drags
|
|
5
|
+
* without re-rendering React). Shows `name (kind)` or just `id` for
|
|
6
|
+
* unnamed elements; portals to body so it isn't clipped.
|
|
7
|
+
*/
|
|
8
|
+
export declare function ElementHoverLabel(): import('react').ReactPortal | null;
|
|
9
|
+
//# sourceMappingURL=ElementHoverLabel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ElementHoverLabel.d.ts","sourceRoot":"","sources":["../../src/canvas/ElementHoverLabel.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAwBH,wBAAgB,iBAAiB,uCAkGhC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders one `<g>` per element. The library SVG fragment is inlined verbatim
|
|
3
|
+
* via `dangerouslySetInnerHTML` — the library JSON is build-time content
|
|
4
|
+
* (see `scripts/build-element-library.mjs`), not user input.
|
|
5
|
+
*
|
|
6
|
+
* Each `<g>` carries `data-element-id` so tools can hit-test via
|
|
7
|
+
* `event.target.closest('[data-element-id]')` without React state. Selection
|
|
8
|
+
* state is reflected as `data-selected="true"` so CSS / overlays can react
|
|
9
|
+
* without re-rendering this layer's children.
|
|
10
|
+
*
|
|
11
|
+
* To make every element comfortable to click — not just its thin strokes —
|
|
12
|
+
* we paint an invisible `<rect>` covering the library's viewBox before the
|
|
13
|
+
* symbol. `fill="transparent"` is hittable (unlike `none`); the visual lines
|
|
14
|
+
* still draw on top because they're added after.
|
|
15
|
+
*/
|
|
16
|
+
export declare function ElementLayer(): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=ElementLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ElementLayer.d.ts","sourceRoot":"","sources":["../../src/canvas/ElementLayer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiCH,wBAAgB,YAAY,4CAgF3B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders user-created free text annotations from `diagram.annotations`.
|
|
3
|
+
* Each annotation is a draggable, editable note unattached to any element.
|
|
4
|
+
*
|
|
5
|
+
* Three render states per annotation:
|
|
6
|
+
* 1. Idle → `<text>` painted at its position.
|
|
7
|
+
* 2. Selected (idle) → text plus a dashed bbox halo (matches element halo).
|
|
8
|
+
* 3. Editing → `<foreignObject>` hosting a contentEditable div;
|
|
9
|
+
* autoselects content on entry, commits on Enter or
|
|
10
|
+
* blur, drops empty content on commit (auto-cleanup
|
|
11
|
+
* of empty annotations created by the text tool).
|
|
12
|
+
*
|
|
13
|
+
* Hit-testing carries the annotation's id via `data-annotation-id` so tools
|
|
14
|
+
* can route the gesture without React state lookups, mirroring how elements
|
|
15
|
+
* use `data-element-id`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function FreeAnnotationLayer(): import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
//# sourceMappingURL=FreeAnnotationLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FreeAnnotationLayer.d.ts","sourceRoot":"","sources":["../../src/canvas/FreeAnnotationLayer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,wBAAgB,mBAAmB,mDAsBlC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders the in-progress marquee selection rect. Subscribes directly to
|
|
3
|
+
* `marquee-bus` to avoid going through React state for every pointermove.
|
|
4
|
+
*/
|
|
5
|
+
export declare function MarqueeOverlay(): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
//# sourceMappingURL=MarqueeOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarqueeOverlay.d.ts","sourceRoot":"","sources":["../../src/canvas/MarqueeOverlay.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,wBAAgB,cAAc,mDAe7B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Half-transparent preview of the kind being placed, following the cursor
|
|
3
|
+
* during the place tool.
|
|
4
|
+
*
|
|
5
|
+
* The cursor "carries" one of the new element's terminals (the tap-side
|
|
6
|
+
* pin — same one `dropElement` snaps to a bus, and the same one used for
|
|
7
|
+
* free-placement). Visually this means the pointer touches the pin you'd
|
|
8
|
+
* expect to drop onto a wire/bus, not the element's centroid.
|
|
9
|
+
*
|
|
10
|
+
* In drag-from-terminal mode (`placeFromTerminal != null`) we additionally
|
|
11
|
+
* draw a dashed wire from the source terminal to whichever pin of the ghost
|
|
12
|
+
* is closest — same visual language as `WirePreview`, so the user sees the
|
|
13
|
+
* connection that will be committed on release.
|
|
14
|
+
*/
|
|
15
|
+
export declare function PlaceGhost(): import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
+
//# sourceMappingURL=PlaceGhost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlaceGhost.d.ts","sourceRoot":"","sources":["../../src/canvas/PlaceGhost.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAUH,wBAAgB,UAAU,mDA0DzB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a non-scaling stroke rect around every selected element / bus
|
|
3
|
+
* using the library viewBox (devices) or BusGeometry (buses) as the base
|
|
4
|
+
* bbox, then applying the same transform.
|
|
5
|
+
*/
|
|
6
|
+
export declare function SelectionOverlay(): import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
//# sourceMappingURL=SelectionOverlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectionOverlay.d.ts","sourceRoot":"","sources":["../../src/canvas/SelectionOverlay.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,wBAAgB,gBAAgB,mDAmD/B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders a `<circle>` per terminal at its world coords. Hidden by default;
|
|
3
|
+
* the wire tool reveals them via the `.tool-wire` class on the canvas root.
|
|
4
|
+
* In select mode, terminals on currently-selected elements are also revealed
|
|
5
|
+
* so the user can grab one to drag-connect without switching tools.
|
|
6
|
+
* `data-connected` distinguishes solid (connected) from hollow (dangling).
|
|
7
|
+
*
|
|
8
|
+
* Selected stretchable elements (e.g. busbar) get their terminals suppressed
|
|
9
|
+
* here because `BusHandles` already draws a larger grip at the same world
|
|
10
|
+
* coords — showing both produces visible "double" control points.
|
|
11
|
+
*/
|
|
12
|
+
export declare function TerminalLayer(): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=TerminalLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TerminalLayer.d.ts","sourceRoot":"","sources":["../../src/canvas/TerminalLayer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,wBAAgB,aAAa,4CAiC5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Renders one polyline per Wire. Each polyline carries `data-wire-id` so
|
|
3
|
+
* hit-test resolves to the specific wire (not the whole electrical node)
|
|
4
|
+
* and `data-node-id` for "select-whole-node" affordances.
|
|
5
|
+
*
|
|
6
|
+
* Each visible wire is paired with a wider invisible hit polyline. A 1px
|
|
7
|
+
* wire is too thin to comfortably click; the hit poly catches pointer
|
|
8
|
+
* events within ~8px of the line and carries the same data attributes.
|
|
9
|
+
*/
|
|
10
|
+
export declare function WireLayer(): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=WireLayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WireLayer.d.ts","sourceRoot":"","sources":["../../src/canvas/WireLayer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wBAAgB,SAAS,4CA6CxB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dashed line from the chosen first terminal to the current cursor position
|
|
3
|
+
* while the wire tool is mid-drag. When the cursor is over a valid drop
|
|
4
|
+
* target (a terminal or a bus body), an additional ring + dot marks the
|
|
5
|
+
* exact landing point so the user can release with confidence.
|
|
6
|
+
*/
|
|
7
|
+
export declare function WirePreview(): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
//# sourceMappingURL=WirePreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WirePreview.d.ts","sourceRoot":"","sources":["../../src/canvas/WirePreview.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,wBAAgB,WAAW,mDA0D1B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BusId, ElementId, LibraryEntry, LibraryTerminal, Orientation, WireEnd } from '../model';
|
|
2
|
+
export interface DropResult {
|
|
3
|
+
newElementId: ElementId;
|
|
4
|
+
attachedToBus: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function dropElement(kind: string, at: [number, number]): DropResult;
|
|
7
|
+
/**
|
|
8
|
+
* The library terminal that should sit at the cursor while a free placement
|
|
9
|
+
* is in progress — same "tap-side" rule as `pickTapTerminal`, returned as a
|
|
10
|
+
* full terminal so callers can offset placement (or the place ghost) so the
|
|
11
|
+
* cursor visually holds that pin instead of the element's hotspot.
|
|
12
|
+
*
|
|
13
|
+
* Stretchable kinds don't have a meaningful tap; returns null and callers
|
|
14
|
+
* use the element's hotspot.
|
|
15
|
+
*/
|
|
16
|
+
export declare function pickPlaceCursorTerminal(lib: LibraryEntry): LibraryTerminal | null;
|
|
17
|
+
/**
|
|
18
|
+
* Resolved place-source: world coords + orientation of the terminal we're
|
|
19
|
+
* dragging from. Handles both real device terminals and a bare bus id
|
|
20
|
+
* (projected onto the bus axis at the cursor point, with orientation flipped
|
|
21
|
+
* to point toward the drag side so the new element body extends away).
|
|
22
|
+
*/
|
|
23
|
+
export interface PlaceSource {
|
|
24
|
+
ref: WireEnd;
|
|
25
|
+
world: [number, number];
|
|
26
|
+
orientation: Orientation;
|
|
27
|
+
/** True iff `ref` is a bus id (bare, no dot). */
|
|
28
|
+
isBus: boolean;
|
|
29
|
+
/** Set when isBus. */
|
|
30
|
+
busId?: BusId;
|
|
31
|
+
}
|
|
32
|
+
export declare function resolvePlaceSource(ref: WireEnd, cursorWorld: [number, number]): PlaceSource | null;
|
|
33
|
+
/**
|
|
34
|
+
* Pick which terminal of the new element should connect to the source.
|
|
35
|
+
* Prefer a terminal whose orientation is opposite to the source's (so the
|
|
36
|
+
* body extends naturally *away* from the source). Tie-break by world
|
|
37
|
+
* distance to source.
|
|
38
|
+
*/
|
|
39
|
+
export declare function pickConnectTerminal(lib: LibraryEntry, source: PlaceSource, placeAt: [number, number]): LibraryTerminal;
|
|
40
|
+
/**
|
|
41
|
+
* Place a new element with one of its terminals connected to `sourceRef` in
|
|
42
|
+
* a single undo step.
|
|
43
|
+
*/
|
|
44
|
+
export declare function dropElementFromTerminal(kind: string, sourceRef: WireEnd, cursorAt: [number, number]): DropResult | null;
|
|
45
|
+
//# sourceMappingURL=drop-on-bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-on-bus.d.ts","sourceRoot":"","sources":["../../src/canvas/drop-on-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,KAAK,EAGL,SAAS,EACT,YAAY,EACZ,eAAe,EACf,WAAW,EAIX,OAAO,EACR,MAAM,UAAU,CAAC;AAOlB,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,SAAS,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,UAAU,CAkD1E;AA6CD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,YAAY,GAChB,eAAe,GAAG,IAAI,CAIxB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,WAAW,EAAE,WAAW,CAAC;IACzB,iDAAiD;IACjD,KAAK,EAAE,OAAO,CAAC;IACf,sBAAsB;IACtB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,WAAW,GAAG,IAAI,CA8BpB;AASD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GACxB,eAAe,CAkBjB;AAYD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GACzB,UAAU,GAAG,IAAI,CA4CnB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fit-to-content viewport reset, shared by the explicit "fit" button in
|
|
3
|
+
* ViewToolbar and the automatic reset that fires on first mount / after
|
|
4
|
+
* loading a file.
|
|
5
|
+
*
|
|
6
|
+
* Element bboxes come from the live DOM (`data-element-id` nodes), so the
|
|
7
|
+
* canvas must already have rendered the diagram. `fitToContentSoon` defers
|
|
8
|
+
* via rAF until that's true (typical use: store update → next frame fit).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Fit all rendered elements to the viewport with padding. Falls back to a
|
|
12
|
+
* centered 100% reset when the canvas is empty. Returns false if the
|
|
13
|
+
* viewport / canvas isn't ready yet.
|
|
14
|
+
*/
|
|
15
|
+
export declare function fitToContent(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Run `fitToContent` after the next paint, retrying for a few frames in case
|
|
18
|
+
* the canvas hasn't mounted yet (initial mount race) or the diagram has
|
|
19
|
+
* just been swapped and the new DOM nodes aren't yet attached.
|
|
20
|
+
*/
|
|
21
|
+
export declare function fitToContentSoon(): void;
|
|
22
|
+
//# sourceMappingURL=fit-to-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fit-to-content.d.ts","sourceRoot":"","sources":["../../src/canvas/fit-to-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAiBH;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,OAAO,CA4CtC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grid snap helpers. Snapping is bound to the visual grid: when the user
|
|
3
|
+
* hides the grid (ViewToolbar / `G`), `.hide-grid` lands on the canvas
|
|
4
|
+
* root and snap() returns the value untouched. So "show grid" and "snap to
|
|
5
|
+
* grid" are one switch.
|
|
6
|
+
*
|
|
7
|
+
* Used by: SelectTool drag move, BusHandles span resize, drop-on-bus
|
|
8
|
+
* placement, drag-drop from palette.
|
|
9
|
+
*/
|
|
10
|
+
export declare const GRID_SIZE = 10;
|
|
11
|
+
export declare function isSnapEnabled(): boolean;
|
|
12
|
+
export declare function snap(v: number): number;
|
|
13
|
+
export declare function snapPoint(p: [number, number]): [number, number];
|
|
14
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../src/canvas/grid.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,SAAS,KAAK,CAAC;AAE5B,wBAAgB,aAAa,IAAI,OAAO,CAIvC;AAED,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtC;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAE/D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AnnotationId, BusId, ElementId, NodeId, WireEnd, WireId } from '../model';
|
|
2
|
+
export declare function hitElement(target: EventTarget | null): ElementId | null;
|
|
3
|
+
export declare function hitBus(target: EventTarget | null): BusId | null;
|
|
4
|
+
/**
|
|
5
|
+
* Returns either a device terminal ref ("X.Y") or a bare bus id under the
|
|
6
|
+
* cursor. Direct hit on a `data-terminal-id` node wins; otherwise if the
|
|
7
|
+
* click landed on a bus body fall back to the bus id so the wire tool can
|
|
8
|
+
* attach anywhere along the bus.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hitTerminal(target: EventTarget | null): WireEnd | null;
|
|
11
|
+
export declare function hitNode(target: EventTarget | null): NodeId | null;
|
|
12
|
+
export declare function hitWire(target: EventTarget | null): WireId | null;
|
|
13
|
+
export declare function hitAnnotation(target: EventTarget | null): AnnotationId | null;
|
|
14
|
+
//# sourceMappingURL=hit-test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hit-test.d.ts","sourceRoot":"","sources":["../../src/canvas/hit-test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,KAAK,EACL,SAAS,EACT,MAAM,EAEN,OAAO,EACP,MAAM,EACP,MAAM,UAAU,CAAC;AAOlB,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAEvE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAE/D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAMtE;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAEjE;AAED,wBAAgB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAEjE;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,GAAG,YAAY,GAAG,IAAI,CAK7E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ElementId } from '../model';
|
|
2
|
+
type Listener = (id: ElementId | null) => void;
|
|
3
|
+
export declare function publishHoverElement(id: ElementId | null): void;
|
|
4
|
+
export declare function getHoverElement(): ElementId | null;
|
|
5
|
+
export declare function subscribeHoverElement(fn: Listener): () => void;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=hover-bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover-bus.d.ts","sourceRoot":"","sources":["../../src/canvas/hover-bus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,KAAK,QAAQ,GAAG,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;AAK/C,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAI9D;AAED,wBAAgB,eAAe,IAAI,SAAS,GAAG,IAAI,CAElD;AAED,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,IAAI,CAK9D"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { CanvasSvg } from './CanvasSvg';
|
|
2
|
+
export { useViewport } from './useViewport';
|
|
3
|
+
export { useTools } from './useTools';
|
|
4
|
+
export { useKeyboardShortcuts } from './useKeyboardShortcuts';
|
|
5
|
+
export { transformAttr } from './transform-attr';
|
|
6
|
+
export { hitElement, hitTerminal, hitNode } from './hit-test';
|
|
7
|
+
export { getScale, subscribeScale } from './zoom-bus';
|
|
8
|
+
export { getViewportApi, setViewportApi } from './viewport-bus';
|
|
9
|
+
export { fitToContent, fitToContentSoon } from './fit-to-content';
|
|
10
|
+
export type { Viewport, ViewportApi } from './useViewport';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAClE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny pub/sub for the marquee selection rect (in SVG coords). Used by
|
|
3
|
+
* SelectTool to publish rect updates and by `<MarqueeOverlay>` to render
|
|
4
|
+
* without bouncing through the editor store.
|
|
5
|
+
*/
|
|
6
|
+
export interface MarqueeRect {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
}
|
|
12
|
+
type Listener = (rect: MarqueeRect | null) => void;
|
|
13
|
+
export declare function publishMarquee(rect: MarqueeRect | null): void;
|
|
14
|
+
export declare function getMarquee(): MarqueeRect | null;
|
|
15
|
+
export declare function subscribeMarquee(fn: Listener): () => void;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=marquee-bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marquee-bus.d.ts","sourceRoot":"","sources":["../../src/canvas/marquee-bus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,KAAK,QAAQ,GAAG,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAAC;AAKnD,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI,CAG7D;AAED,wBAAgB,UAAU,IAAI,WAAW,GAAG,IAAI,CAE/C;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,IAAI,CAKzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-wire-target.d.ts","sourceRoot":"","sources":["../../src/canvas/resolve-wire-target.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,OAAO,EACZ,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5B,UAAU,GAAG,IAAI,CAwBnB"}
|