@vanduo-oss/vd3-cbun 1.1.0 → 1.2.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/CHANGELOG.md CHANGED
@@ -4,6 +4,35 @@ All notable changes to `@vanduo-oss/vd3-cbun` are documented here. This file
4
4
  tracks the PACKAGE only — never docs-site content. Per-component VERSION
5
5
  constants are listed alongside each bundle release.
6
6
 
7
+ ## 1.2.0 — 2026-07-22
8
+
9
+ Adds a sixth component, **`draw`** (`@vanduo-oss/vd3-cbun/draw` + `./draw/css`),
10
+ exposing `VdDraw` — a first-party **vector drawing tool** (SVG world group with
11
+ matrix pan/zoom, the flowchart architecture family) built around a
12
+ dependency-free **brush engine**: freehand strokes are variable-width, smoothed,
13
+ pressure/velocity-driven filled outline paths. It ships **brush presets** (`pen`,
14
+ `pencil`, `marker`, `highlighter`, `calligraphy` — `BRUSH_PRESETS`), a **color
15
+ palette** (swatches + custom color, opacity, brush size, recent colors), a
16
+ **stroke eraser**, and secondary diagram shapes (rectangle / ellipse / arrow /
17
+ text / sticky) with z-order, grouping, copy/paste/duplicate, snapping guides,
18
+ keyboard shortcuts, and PNG + SVG export. The built-in toolbar uses inline
19
+ Phosphor icons. Undo/redo funnels through a single `emitChange → recordHistory`
20
+ whole-document choke point (pan/zoom not recorded); `toJSON()` / `load()`
21
+ serialize `{ version, viewport, shapes }` — freehand strokes carry `brush` /
22
+ `color` / `opacity` / per-point `pressure` — through a `normalizeDocument()`
23
+ migration gateway (a v1 constant-width freehand loads as the default pen brush).
24
+ Chrome theming is CSS-only through a `--vd-draw-*` → `--vd-*` layer; marks carry
25
+ an explicit picked color. No new runtime dependency — `vue` stays the only peer,
26
+ and every input bundled for the entry lives under `src/draw/` (the metafile
27
+ isolation guard passes). The five existing components are untouched (tree-shake
28
+ contract). Additive minor: bundle `1.1.0 → 1.2.0`.
29
+
30
+ Component versions in this release: **charts 1.0.0, code-editor 1.0.0, draw
31
+ 1.1.0, flowchart 1.2.0, hex-grid 1.0.0, music-player 1.0.0** — `draw` entered the
32
+ `component-versions.json` manifest at `1.0.0`, and its serialization (freehand
33
+ `brush` / `color` / `pressure`) takes `VD_DRAW_VERSION` to `1.1.0`; the bundle's own semver
34
+ stays decoupled from the per-component `VERSION` constants.
35
+
7
36
  ## 1.1.0 — 2026-07-21
8
37
 
9
38
  Adds a fifth component, **`code-editor`** (`@vanduo-oss/vd3-cbun/code-editor` +
package/README.md CHANGED
@@ -3,15 +3,16 @@
3
3
  [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
4
4
 
5
5
  The Vanduo **components bundle** for the vd3 line: Vue3-only charts, code-editor,
6
- flowchart, hex-grid, and music-player consolidated into ONE package with
6
+ draw, flowchart, hex-grid, and music-player consolidated into ONE package with
7
7
  tree-shakeable subpath exports. It replaces the four per-repo publishes
8
8
  (`@vanduo-oss/charts`, `@vanduo-oss/flowchart`, `@vanduo-oss/hex-grid`,
9
9
  `@vanduo-oss/music-player`) of the old line.
10
10
 
11
- **Status: 1.1.0.** Five Vue3-only component families — charts, code-editor,
11
+ **Status: 1.2.0.** Six Vue3-only component families — charts, code-editor, draw,
12
12
  flowchart, hex-grid, music-player — each on its own tree-shakeable subpath, with
13
- the esbuild metafile isolation guard in place. (1.1.0 adds the first-party
14
- `code-editor` component; see the [changelog](./CHANGELOG.md).)
13
+ the esbuild metafile isolation guard in place. (1.2.0 adds the first-party
14
+ `draw` vector drawing tool — a brush engine + color palette; see the
15
+ [changelog](./CHANGELOG.md).)
15
16
 
16
17
  ## Install
17
18
 
@@ -35,6 +36,9 @@ import '@vanduo-oss/vd3-cbun/charts/css';
35
36
  import { VdCodeEditor } from '@vanduo-oss/vd3-cbun/code-editor';
36
37
  import '@vanduo-oss/vd3-cbun/code-editor/css';
37
38
 
39
+ import { VdDraw } from '@vanduo-oss/vd3-cbun/draw';
40
+ import '@vanduo-oss/vd3-cbun/draw/css';
41
+
38
42
  import { VdFlowchart } from '@vanduo-oss/vd3-cbun/flowchart';
39
43
  import '@vanduo-oss/vd3-cbun/flowchart/css';
40
44
 
@@ -79,15 +83,15 @@ The bundle's own semver (`package.json` version) is decoupled from the
79
83
  components inside it. Each component carries a VERSION constant tracked in
80
84
  `component-versions.json` at the repo root and asserted in tests against the
81
85
  exported `VD3_CBUN_VERSIONS` map. charts, code-editor, hex-grid, and
82
- music-player sit at `1.0.0`; **flowchart continues its old-line lineage at
86
+ music-player sit at `1.0.0`, draw at `1.1.0`; **flowchart continues its old-line lineage at
83
87
  `1.2.0`** because `VD_FLOWCHART_VERSION` is load-bearing — it is serialized
84
88
  into user documents via `toJSON().version`. A new component enters the manifest
85
- at `1.0.0` (`code-editor` did, in bundle 1.1.0).
89
+ at `1.0.0` (`draw` did, in bundle 1.2.0).
86
90
 
87
91
  ## Theming
88
92
 
89
- All five components render against Vanduo's `--vd-*` design tokens — the same
90
- tokens `@vanduo-oss/vd3` defines. charts, code-editor, flowchart, and hex-grid
93
+ All six components render against Vanduo's `--vd-*` design tokens — the same
94
+ tokens `@vanduo-oss/vd3` defines. charts, code-editor, draw, flowchart, and hex-grid
91
95
  carry built-in fallbacks and degrade gracefully without them; **music-player
92
96
  expects the tokens**
93
97
  and renders with unset colors/backgrounds if none are provided. For correct
@@ -127,6 +131,8 @@ tokens works — but it is the canonical source.)
127
131
  | `@vanduo-oss/vd3-cbun/charts/css` | Charts stylesheet (`dist/charts/vd3-charts.css`) |
128
132
  | `@vanduo-oss/vd3-cbun/code-editor` | `VdCodeEditor` + `VdCodeEditorCore`, `tokenize`, `highlight`, `LANGUAGES` |
129
133
  | `@vanduo-oss/vd3-cbun/code-editor/css` | Code-editor stylesheet (`dist/code-editor/vd3-code-editor.css`) |
134
+ | `@vanduo-oss/vd3-cbun/draw` | `VdDraw` + `VdDrawCore`, `BRUSH_PRESETS`, `DRAW_TOOLS`, `VD_DRAW_VERSION` |
135
+ | `@vanduo-oss/vd3-cbun/draw/css` | Draw stylesheet (`dist/draw/vd3-draw.css`) |
130
136
  | `@vanduo-oss/vd3-cbun/flowchart` | `VdFlowchart` + `VdFlowchartCore`, `computeLayout`, `FLOWCHART_*` |
131
137
  | `@vanduo-oss/vd3-cbun/flowchart/css` | Flowchart stylesheet (`dist/flowchart/vd3-flowchart.css`) |
132
138
  | `@vanduo-oss/vd3-cbun/hex-grid` | `VdHexGrid` + `VdHexGridCore`, `VD_HEX_VERSION` |
package/SKILL.md CHANGED
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  name: vanduo-vd3-cbun
3
- description: Use when adding Vanduo vd3 components with @vanduo-oss/vd3-cbun — the Vue 3 components bundle (charts, code-editor, flowchart, hex-grid, music-player) with tree-shakeable subpath exports. Covers install, per-subpath imports, CSS, theming, and per-component versioning.
3
+ description: Use when adding Vanduo vd3 components with @vanduo-oss/vd3-cbun — the Vue 3 components bundle (charts, code-editor, draw, flowchart, hex-grid, music-player) with tree-shakeable subpath exports. Covers install, per-subpath imports, CSS, theming, and per-component versioning.
4
4
  ---
5
5
 
6
6
  # @vanduo-oss/vd3-cbun
7
7
 
8
- One bundle, five Vue 3 components, each on its own tree-shakeable subpath
9
- (`./charts`, `./code-editor`, `./flowchart`, `./hex-grid`, `./music-player`).
8
+ One bundle, six Vue 3 components, each on its own tree-shakeable subpath
9
+ (`./charts`, `./code-editor`, `./draw`, `./flowchart`, `./hex-grid`, `./music-player`).
10
10
  `vue >=3.3.0` is a required peer. The root import exposes only `VD3_CBUN_VERSIONS` — the per-
11
11
  component VERSION map. Every subpath re-exports the Vue wrapper AND the
12
12
  framework-agnostic core alongside it (the core aliased with a `Core` suffix
@@ -68,6 +68,34 @@ Key props: `language`, `readOnly`, `lineNumbers`, `tabSize`, `wrap`,
68
68
  `blur`, `ready`. CSS ships at `@vanduo-oss/vd3-cbun/code-editor/css`.
69
69
  `VD_CODE_EDITOR_VERSION` is `1.0.0`.
70
70
 
71
+ ## Draw
72
+
73
+ ```js
74
+ import { VdDraw, VdDrawCore } from '@vanduo-oss/vd3-cbun/draw';
75
+ import '@vanduo-oss/vd3-cbun/draw/css';
76
+ ```
77
+
78
+ `VdDraw` is the Vue 3 wrapper; the framework-agnostic editor core shares the
79
+ class name, so it is re-exported as `VdDrawCore`. It is a first-party **vector
80
+ drawing tool** (SVG world group with matrix pan/zoom) with a **brush engine** —
81
+ freehand strokes are variable-width, smoothed, pressure/velocity-driven filled
82
+ outline paths — and brush presets (`pen`, `pencil`, `marker`, `highlighter`,
83
+ `calligraphy`, in `BRUSH_PRESETS`), a **color palette** (swatches + custom color,
84
+ opacity, size, recent colors), a **stroke eraser**, plus secondary diagram
85
+ shapes (rectangle / ellipse / arrow / text / sticky), z-order, grouping,
86
+ copy/paste/duplicate, snapping guides, and PNG + SVG export. The built-in toolbar
87
+ uses inline Phosphor icons. Undo/redo runs through a single `emitChange →
88
+ recordHistory` choke point (whole-document snapshots; pan/zoom not recorded);
89
+ `toJSON()` / `load()` serialize `{ version, viewport, shapes }` (freehand strokes
90
+ carry `brush` / `color` / `opacity` / per-point `pressure`) via a
91
+ `normalizeDocument()` migration gateway. Chrome theming is CSS-only via a
92
+ `--vd-draw-*` → `--vd-*` layer; marks carry an explicit picked color. The subpath
93
+ also re-exports `BRUSH_PRESETS`, `DRAW_TOOLS`, `DRAW_SHAPE_TYPES`, and
94
+ `VD_DRAW_VERSION`. Key props: `data`, `tool`, `readonly`, `gridSize`, `snap`,
95
+ `autoFit`, `history`, `historyLimit`; events: `change`, `select`, `viewport`,
96
+ `ready`. CSS ships at `@vanduo-oss/vd3-cbun/draw/css`. `VD_DRAW_VERSION` is
97
+ `1.1.0`.
98
+
71
99
  ## Flowchart
72
100
 
73
101
  ```js
@@ -129,8 +157,8 @@ core (no name collision, so it keeps its own name) re-exported alongside
129
157
 
130
158
  ## Theming
131
159
 
132
- All four components render against Vanduo's `--vd-*` design tokens — the same
133
- tokens `@vanduo-oss/vd3` defines. charts, flowchart, and hex-grid ship built-in
160
+ All six components render against Vanduo's `--vd-*` design tokens — the same
161
+ tokens `@vanduo-oss/vd3` defines. charts, code-editor, draw, flowchart, and hex-grid ship built-in
134
162
  fallbacks and degrade gracefully without them; **music-player expects the tokens**
135
163
  and renders with unset colors/backgrounds if none are present. Provide them on an
136
164
  ancestor element — simplest is to import the vd3 stylesheet (`@vanduo-oss/vd3/css`,
@@ -0,0 +1,249 @@
1
+ // Type definitions for the framework-agnostic draw tool core.
2
+ // Hand-written to mirror the runtime in ./core.js + ./shapes.js. Self-contained
3
+ // (the shipped .d.ts trio is index/core/vue — no shapes.d.ts), so every draw
4
+ // type and constant is declared here.
5
+
6
+ export type DrawTool =
7
+ 'select' | 'hand' | 'draw' | 'eraser' | 'rectangle' | 'ellipse' | 'line' | 'text' | 'sticky';
8
+
9
+ export type DrawShapeType = 'rectangle' | 'ellipse' | 'line' | 'freehand' | 'text' | 'sticky';
10
+
11
+ export type BrushName = 'pen' | 'pencil' | 'marker' | 'highlighter' | 'calligraphy';
12
+
13
+ export interface BrushPreset {
14
+ size: number;
15
+ thinning: number;
16
+ smoothing: number;
17
+ streamline: number;
18
+ taperStart: number;
19
+ taperEnd: number;
20
+ opacity: number;
21
+ blend: string;
22
+ nibAngle?: number;
23
+ }
24
+
25
+ export interface DrawViewport {
26
+ x: number;
27
+ y: number;
28
+ scale: number;
29
+ }
30
+
31
+ /** A world-space point `[x, y]` with an optional third `pressure` (0–1) slot. */
32
+ export type DrawPoint = [number, number] | [number, number, number];
33
+
34
+ /**
35
+ * A shape in the document. Box shapes (rectangle/ellipse/text/sticky) use
36
+ * x/y/w/h; line/freehand use `points`. `color` is the stroke color for shapes /
37
+ * lines and the fill color for freehand brush strokes.
38
+ */
39
+ export interface DrawShape {
40
+ id: string;
41
+ type: DrawShapeType;
42
+ x?: number;
43
+ y?: number;
44
+ w?: number;
45
+ h?: number;
46
+ rotation?: number;
47
+ points?: DrawPoint[];
48
+ /** freehand: the brush preset. */
49
+ brush?: BrushName;
50
+ /** stroke color (shapes/line) or fill color (freehand). */
51
+ color?: string;
52
+ fill?: string;
53
+ /** freehand brush size. */
54
+ size?: number;
55
+ /** shapes/line stroke width. */
56
+ strokeWidth?: number;
57
+ opacity?: number;
58
+ text?: string;
59
+ arrowStart?: boolean;
60
+ arrowEnd?: boolean;
61
+ groupId?: string;
62
+ }
63
+
64
+ export interface DrawDocument {
65
+ version: string;
66
+ viewport: DrawViewport;
67
+ shapes: DrawShape[];
68
+ }
69
+
70
+ export interface DrawBounds {
71
+ x: number;
72
+ y: number;
73
+ w: number;
74
+ h: number;
75
+ }
76
+
77
+ export interface DrawChangeEvent {
78
+ reason: string;
79
+ document: DrawDocument;
80
+ shape?: DrawShape;
81
+ shapeId?: string;
82
+ shapeIds?: string[];
83
+ groupId?: string;
84
+ }
85
+
86
+ export interface DrawSelectEvent {
87
+ ids: string[];
88
+ shapes: DrawShape[];
89
+ }
90
+
91
+ export interface DrawViewportEvent {
92
+ reason: string;
93
+ viewport: DrawViewport;
94
+ document: DrawDocument;
95
+ }
96
+
97
+ export interface DrawHistoryEvent {
98
+ reason: string;
99
+ canUndo: boolean;
100
+ canRedo: boolean;
101
+ }
102
+
103
+ export interface DrawEventMap {
104
+ change: DrawChangeEvent;
105
+ select: DrawSelectEvent;
106
+ viewport: DrawViewportEvent;
107
+ history: DrawHistoryEvent;
108
+ ready: VdDraw;
109
+ }
110
+
111
+ export interface VdDrawOptions {
112
+ element?: Element | string;
113
+ /** Alias for `element`. */
114
+ target?: Element | string;
115
+ data?: Partial<DrawDocument> | string;
116
+ readonly?: boolean;
117
+ tool?: DrawTool;
118
+ gridSize?: number;
119
+ /** Show the background grid (default true). */
120
+ showGrid?: boolean;
121
+ /** Snap to nearby edges/centres while moving/resizing (default true). */
122
+ snap?: boolean;
123
+ /** Fit to content once the canvas reports a measurable size. */
124
+ autoFit?: boolean;
125
+ /** Enable built-in undo/redo (default true). */
126
+ history?: boolean;
127
+ /** Maximum retained history entries (default 100). */
128
+ historyLimit?: number;
129
+ /** Initial current-style color / opacity / brush size / brush preset. */
130
+ color?: string;
131
+ opacity?: number;
132
+ brushSize?: number;
133
+ brush?: BrushName;
134
+ }
135
+
136
+ export interface StylePatch {
137
+ color?: string;
138
+ fill?: string;
139
+ strokeWidth?: number;
140
+ opacity?: number;
141
+ size?: number;
142
+ brush?: BrushName;
143
+ }
144
+
145
+ export class VdDraw {
146
+ constructor(options?: VdDrawOptions);
147
+
148
+ readonly element: Element;
149
+ readonly readonly: boolean;
150
+ gridSize: number;
151
+ tool: DrawTool;
152
+ snap: boolean;
153
+ showGrid: boolean;
154
+ destroyed: boolean;
155
+ /** The current drawing style new marks adopt. */
156
+ style: { color: string; opacity: number; size: number; brush: BrushName };
157
+
158
+ // Events
159
+ on<K extends keyof DrawEventMap>(event: K, callback: (payload: DrawEventMap[K]) => void): this;
160
+ off<K extends keyof DrawEventMap>(event: K, callback: (payload: DrawEventMap[K]) => void): this;
161
+
162
+ // Tool + current style
163
+ setTool(tool: DrawTool): this;
164
+ setColor(color: string): this;
165
+ setOpacity(opacity: number): this;
166
+ setBrushSize(size: number): this;
167
+ setBrush(brush: BrushName): this;
168
+
169
+ // Grid
170
+ setGridSize(size: number): this;
171
+ setGridVisible(visible: boolean): this;
172
+ toggleGrid(): this;
173
+
174
+ // Shapes
175
+ getShape(id: string): DrawShape | null;
176
+ addShape(partial?: Partial<DrawShape>): DrawShape;
177
+ updateShape(
178
+ id: string,
179
+ patch?: Partial<DrawShape>,
180
+ options?: { reason?: string },
181
+ ): DrawShape | null;
182
+ removeShape(id: string): boolean;
183
+
184
+ // Selection
185
+ getSelectedShapes(): DrawShape[];
186
+ select(ids: string | string[] | null, options?: { additive?: boolean }): this;
187
+ selectAll(): this;
188
+ deselect(): this;
189
+ selectInBounds(box: DrawBounds, options?: { additive?: boolean }): this;
190
+
191
+ // Manipulation
192
+ nudge(dx: number, dy: number): this;
193
+ setSelectionBounds(target: DrawBounds): this;
194
+ deleteSelection(): boolean;
195
+ setStyle(patch: StylePatch): this;
196
+
197
+ // Z-order
198
+ bringForward(): this;
199
+ sendBackward(): this;
200
+ bringToFront(): this;
201
+ sendToBack(): this;
202
+
203
+ // Grouping
204
+ group(): this;
205
+ ungroup(): this;
206
+
207
+ // Clipboard
208
+ copy(): this;
209
+ cut(): this;
210
+ paste(options?: { offset?: number }): this;
211
+ duplicate(): this;
212
+
213
+ // Export
214
+ toSVG(): string;
215
+ toPNG(options?: { scale?: number }): Promise<string>;
216
+
217
+ // Viewport
218
+ setViewport(patch: Partial<DrawViewport>): this;
219
+ scaleAround(factor: number, localX: number, localY: number): this;
220
+ zoomIn(): this;
221
+ zoomOut(): this;
222
+ resetView(): this;
223
+ fitView(): this;
224
+
225
+ // History
226
+ undo(): this;
227
+ redo(): this;
228
+ canUndo(): boolean;
229
+ canRedo(): boolean;
230
+ clearHistory(): this;
231
+
232
+ // Document
233
+ clear(): this;
234
+ load(data: Partial<DrawDocument> | string): this;
235
+ toJSON(): DrawDocument;
236
+
237
+ // Text editing
238
+ startTextEdit(id: string): boolean;
239
+ stopTextEdit(options?: { commit?: boolean }): void;
240
+
241
+ // Rendering + lifecycle
242
+ render(flags?: { scene?: boolean; overlay?: boolean }): void;
243
+ destroy(): void;
244
+ }
245
+
246
+ export const VD_DRAW_VERSION: string;
247
+ export const DRAW_TOOLS: readonly DrawTool[];
248
+ export const DRAW_SHAPE_TYPES: readonly DrawShapeType[];
249
+ export const BRUSH_PRESETS: Readonly<Record<BrushName, BrushPreset>>;