@flowscape-ui/core-sdk 1.0.7 → 2.0.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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Flowscape UI
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Flowscape UI
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.
package/README.md CHANGED
@@ -1,383 +1,124 @@
1
- <div align="center">
2
-
3
- # 🎨 @flowscape-ui/core-sdk
4
-
5
- **High-performance 2D canvas engine for an interactive infinite canvas with nodes, pan/zoom, selection, history, and a plugin-friendly architecture built on Konva**
6
-
7
- [![npm version](https://img.shields.io/npm/v/@flowscape-ui/core-sdk.svg)](https://www.npmjs.com/package/@flowscape-ui/core-sdk)
8
- [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
- [![Bundle Size](https://img.shields.io/bundlephobia/minzip/@flowscape-ui/core-sdk)](https://bundlephobia.com/package/@flowscape-ui/core-sdk)
10
- [![X (Twitter)](https://img.shields.io/badge/X-@FlowscapeUI-000000?logo=x&logoColor=white)](https://x.com/FlowscapeUI)
11
-
12
- [![Documentation](https://img.shields.io/badge/📚_Documentation-FF4785?style=for-the-badge&logo=storybook&logoColor=white)](https://flowscape-ui.github.io/core-sdk/)
13
- [![Interactive Demo](https://img.shields.io/badge/🎮_Interactive_Demo-FF4785?style=for-the-badge&logo=storybook&logoColor=white)](https://flowscape-ui.github.io/core-sdk/?path=/story/interactive-playground--interactive-playground)
14
- [![Changelog](https://img.shields.io/badge/📝_Changelog-FF4785?style=for-the-badge&logo=storybook&logoColor=white)](./CHANGELOG.md)
15
-
16
- <img
17
- src="./assets/readme/preview.gif"
18
- alt="Flowscape Canvas Demo"
19
- width="900"
20
- />
21
-
22
- </div>
23
-
24
- ---
25
-
26
- ## 📦 Installation
27
-
28
- ```bash
29
- npm install @flowscape-ui/core-sdk
30
- # or
31
- pnpm add @flowscape-ui/core-sdk
32
- # or
33
- yarn add @flowscape-ui/core-sdk
34
- # or
35
- bun add @flowscape-ui/core-sdk
36
- ```
37
-
38
- ## Features
39
-
40
- - 🎯 **Framework-agnostic** - works with React, Vue, Svelte, Angular or vanilla JS
41
- - 🧩 **Plugin system** - extensible architecture with ready-to-use plugins
42
- - 📐 **Complete toolset** - grid, rulers, guides, area selection, alignment guides
43
- - ⌨️ **Hotkeys** - Ctrl+C/V/X, Delete, Ctrl+G for grouping, Ctrl+Z/Shift+Z for undo/redo
44
- - 🎨 **Rich shapes** - rectangles, circles, text, images, arrows, stars
45
- - 🔄 **Transformations** - rotation, scaling, movement with aspect ratio lock
46
- - ✏️ **Inline editing** - double-click text nodes to edit directly on canvas
47
- - 🕐 **History system** - full undo/redo support with Ctrl+Z
48
- - 📦 **TypeScript-first** - full typing out of the box
49
- - 🚀 **High performance** - handles 1000+ nodes without FPS drops
50
- - 🎨 **Addons API** - extend any component with custom functionality
51
-
52
- ## 🚀 Quick Start
53
-
54
- ```typescript
55
- import { CoreEngine, GridPlugin, SelectionPlugin, NodeHotkeysPlugin } from '@flowscape-ui/core-sdk';
56
-
57
- // Create engine with plugins
58
- const engine = new CoreEngine({
59
- container: document.getElementById('canvas-container')!,
60
- width: 1200,
61
- height: 800,
62
- plugins: [
63
- new GridPlugin({ enabled: true }),
64
- new SelectionPlugin({ dragEnabled: true }),
65
- new NodeHotkeysPlugin(), // Ctrl+C/V/X, Delete
66
- ],
67
- });
68
-
69
- // Add shapes
70
- const rect = engine.nodes.addShape({
71
- x: 100,
72
- y: 100,
73
- width: 200,
74
- height: 150,
75
- fill: '#3b82f6',
76
- cornerRadius: 8,
77
- });
78
-
79
- const text = engine.nodes.addText({
80
- x: 120,
81
- y: 140,
82
- text: 'Hello Flowscape!',
83
- fontSize: 24,
84
- fill: 'white',
85
- });
86
-
87
- // Grouping
88
- const group = engine.nodes.addGroup({
89
- x: 400,
90
- y: 200,
91
- });
92
- rect.getNode().moveTo(group.getNode());
93
- text.getNode().moveTo(group.getNode());
94
- ```
95
-
96
- ## 🔒 Public API Policy
97
-
98
- - All supported entities are exported only through the root package `@flowscape-ui/core-sdk`.
99
- - The `src/public-api.ts` file contains the complete list of stable exports; anything outside this file is considered internal API and may change without notice.
100
- - Do not import files directly via `@flowscape-ui/core-sdk/src/...` — such imports are not supported and may break during updates.
101
-
102
- ## 🏗️ Architecture
103
-
104
- ### Core Components
105
-
106
- ```
107
- ┌─────────────────────────────────────┐
108
- │ CoreEngine │
109
- │ ┌──────────────────────────────┐ │
110
- │ │ Plugin System │ │
111
- │ │ - GridPlugin │ │
112
- │ │ - SelectionPlugin │ │
113
- │ │ - RulerPlugin │ │
114
- │ │ - NodeHotkeysPlugin │ │
115
- │ └──────────────────────────────┘ │
116
- │ ┌──────────────────────────────┐ │
117
- │ │ Node Manager │ │
118
- │ │ - ShapeNode │ │
119
- │ │ - TextNode │ │
120
- │ │ - ImageNode │ │
121
- │ │ - GroupNode │ │
122
- │ └──────────────────────────────┘ │
123
- │ ┌──────────────────────────────┐ │
124
- │ │ Camera Manager │ │
125
- │ │ - Zoom (Ctrl+Wheel) │ │
126
- │ └──────────────────────────────┘ │
127
- └─────────────────────────────────────┘
128
- ```
129
-
130
- ### Plugin System
131
-
132
- Plugins extend engine functionality without modifying the core:
133
-
134
- ```typescript
135
- import { Plugin, CoreEngine } from '@flowscape-ui/core-sdk';
136
-
137
- class CustomPlugin extends Plugin {
138
- protected onAttach(core: CoreEngine): void {
139
- // Initialize on attach
140
- core.eventBus.on('node:created', (node) => {
141
- console.log('Node created:', node);
142
- });
143
- }
144
-
145
- protected onDetach(core: CoreEngine): void {
146
- // Cleanup on detach
147
- core.eventBus.off('node:created');
148
- }
149
- }
150
-
151
- // Usage
152
- const engine = new CoreEngine({
153
- container: element,
154
- plugins: [new CustomPlugin()],
155
- });
156
- ```
157
-
158
- ---
159
-
160
- | Plugin | Description |
161
- | ---------------------- | ------------------------------------------------ |
162
- | `GridPlugin` | Adaptive grid with automatic scaling |
163
- | `SelectionPlugin` | Selection, transformation, drag & drop, grouping |
164
- | `NodeHotkeysPlugin` | Copy/paste/cut nodes, delete, z-index management |
165
- | `CameraHotkeysPlugin` | Zoom and pan controls with keyboard |
166
- | `RulerPlugin` | Rulers with measurement units |
167
- | `RulerGuidesPlugin` | Draggable guide lines from rulers |
168
- | `RulerHighlightPlugin` | Ruler highlighting on hover |
169
- | `RulerManagerPlugin` | Toggle rulers and manage guides |
170
- | `AreaSelectionPlugin` | Area selection with frame (Shift+Drag) |
171
- | `VisualGuidesPlugin` | Smart alignment guides during movement/resize |
172
- | `HistoryPlugin` | Undo/redo functionality with Ctrl+Z |
173
- | `PersistencePlugin` | Local persistence: auto-save, export/import JSON |
174
- | `LogoPlugin` | Watermark/logo on canvas |
175
-
176
- | Plugin | Description |
177
- | ------------------------ | ----------------------------------------------------- |
178
- | **GridPlugin** | Adaptive grid with automatic scaling and snap-to-grid |
179
- | **SelectionPlugin** | Selection, transformation, drag & drop, grouping |
180
- | **AreaSelectionPlugin** | Area selection with frame (Shift+Drag) |
181
- | **NodeHotkeysPlugin** | Copy/paste/cut nodes, delete, z-index management |
182
- | **CameraHotkeysPlugin** | Zoom and pan controls with keyboard |
183
- | **RulerPlugin** | Rulers with measurement units |
184
- | **RulerGuidesPlugin** | Draggable guide lines from rulers |
185
- | **RulerHighlightPlugin** | Ruler highlighting on hover |
186
- | **RulerManagerPlugin** | Toggle rulers and manage guides |
187
- | **LogoPlugin** | Watermark/logo on canvas |
188
-
189
- ---
190
-
191
- ## ⌨️ Keyboard Shortcuts
192
-
193
- ### Node Operations (NodeHotkeysPlugin)
194
-
195
- | Shortcut | Action |
196
- | ---------------------- | ---------------------------- |
197
- | `Ctrl+C` | Copy selected nodes |
198
- | `Ctrl+X` | Cut selected nodes |
199
- | `Ctrl+V` | Paste nodes |
200
- | `Delete` / `Backspace` | Delete selected nodes |
201
- | `Ctrl+]` | Move node forward (z-index) |
202
- | `Ctrl+[` | Move node backward (z-index) |
203
- | `Ctrl+Shift+]` | Bring to front |
204
- | `Ctrl+Shift+[` | Send to back |
205
-
206
- ### Grouping (SelectionPlugin)
207
-
208
- | Shortcut | Action |
209
- | ----------------------- | --------------------------------- |
210
- | `Ctrl+G` | Group selected nodes |
211
- | `Ctrl+Shift+G` | Ungroup selected group |
212
- | `Shift+Click` | Add/remove node to/from selection |
213
- | `Shift` (during resize) | Lock aspect ratio |
214
-
215
- #### History (HistoryPlugin)
216
-
217
- | Shortcut | Action |
218
- | -------------- | ------ |
219
- | `Ctrl+Z` | Undo |
220
- | `Ctrl+Shift+Z` | Redo |
221
-
222
- #### Camera Controls (CameraHotkeysPlugin)
223
-
224
- | Shortcut | Action |
225
- | ------------------- | ----------- |
226
- | `Ctrl+Wheel` | Zoom in/out |
227
- | `+` / `=` | Zoom in |
228
- | `-` | Zoom out |
229
- | `Arrow Keys` | Pan camera |
230
- | `Middle Mouse+Drag` | Pan camera |
231
- | `Right Mouse+Drag` | Pan camera |
232
-
233
- ### Ruler Controls (RulerManagerPlugin)
234
-
235
- | Shortcut | Action |
236
- | ---------------------- | ------------------------ |
237
- | `Shift+R` | Toggle rulers visibility |
238
- | `Delete` / `Backspace` | Delete active guide |
239
- | Drag from ruler | Create guide line |
240
-
241
- ---
242
-
243
- ## 📚 Usage Examples
244
-
245
- ### Creating Shapes
246
-
247
- ```typescript
248
- // Rectangle with rounded corners
249
- const rect = engine.nodes.addShape({
250
- x: 50,
251
- y: 50,
252
- width: 200,
253
- height: 100,
254
- fill: '#10b981',
255
- cornerRadius: 12,
256
- });
257
-
258
- // Circle
259
- const circle = engine.nodes.addCircle({
260
- x: 300,
261
- y: 100,
262
- radius: 50,
263
- fill: '#f59e0b',
264
- stroke: '#d97706',
265
- strokeWidth: 3,
266
- });
267
-
268
- // Text
269
- const text = engine.nodes.addText({
270
- x: 400,
271
- y: 50,
272
- text: 'Flowscape UI',
273
- fontSize: 32,
274
- fontFamily: 'Inter',
275
- fill: '#1f2937',
276
- });
277
-
278
- // Image
279
- const image = engine.nodes.addImage({
280
- x: 100,
281
- y: 200,
282
- width: 200,
283
- height: 150,
284
- src: '/path/to/image.jpg',
285
- });
286
- ```
287
-
288
- ### Working with Events
289
-
290
- ```typescript
291
- // Subscribe to events
292
- engine.eventBus.on('node:created', (node) => {
293
- console.log('Node created:', node);
294
- });
295
-
296
- engine.eventBus.on('node:selected', (node) => {
297
- console.log('Node selected:', node);
298
- });
299
-
300
- engine.eventBus.on('camera:zoom', ({ scale }) => {
301
- console.log('Zoom changed:', scale);
302
- });
303
-
304
- // Unsubscribe
305
- const handler = (node) => console.log(node);
306
- engine.eventBus.on('node:created', handler);
307
- engine.eventBus.off('node:created', handler);
308
- ```
309
-
310
- ### Grouping and Management
311
-
312
- ```typescript
313
- // Create group
314
- const group = engine.nodes.addGroup({ x: 0, y: 0 });
315
-
316
- // Add nodes to group
317
- const rect1 = engine.nodes.addShape({ x: 10, y: 10, width: 50, height: 50 });
318
- const rect2 = engine.nodes.addShape({ x: 70, y: 10, width: 50, height: 50 });
319
-
320
- rect1.getNode().moveTo(group.getNode());
321
- rect2.getNode().moveTo(group.getNode());
322
-
323
- // Manage z-index
324
- rect1.getNode().moveUp(); // Move up one level
325
- rect2.getNode().moveDown(); // Move down one level
326
- rect1.getNode().moveToTop(); // Move to top
327
- ```
328
-
329
- ### Camera and Navigation
330
-
331
- ```typescript
332
- // Programmatic zoom
333
- engine.camera.zoomIn(); // Zoom in
334
- engine.camera.zoomOut(); // Zoom out
335
- engine.camera.setZoom(1.5); // Set specific scale
336
-
337
- // Panning
338
- engine.camera.pan(100, 50); // Pan by dx, dy
339
-
340
- // Center on node
341
- const node = engine.nodes.addShape({ x: 500, y: 500, width: 100, height: 100 });
342
- engine.camera.centerOn(node);
343
-
344
- // Reset camera
345
- engine.camera.reset();
346
- ```
347
-
348
- ---
349
-
350
- ## 🔧 Development
351
-
352
- ```bash
353
- # Install dependencies
354
- bun install
355
-
356
- # Run playground
357
- bun run dev
358
-
359
- # Build library
360
- bun run build
361
-
362
- # Tests
363
- bun run test # Watch mode
364
- bun run test:run # Single run
365
- bun run test:coverage # With coverage
366
-
367
- # Linting
368
- bun run lint # ESLint
369
- bun run lint:ts # TypeScript check
370
- bun run lint:fix # Auto-fix
371
- ```
372
-
373
- ## 📄 License
374
-
375
- MIT © Flowscape UI Team
376
-
377
- ---
378
-
379
- <div align="center">
380
-
381
- ⭐ [Star on GitHub](https://github.com/Flowscape-UI/core-sdk) • 🐛 [Report Bug](https://github.com/Flowscape-UI/core-sdk/issues) • 💡 [Request Feature](https://github.com/Flowscape-UI/core-sdk/issues)
382
-
383
- </div>
1
+ <div align="center">
2
+
3
+ # 🎨 @flowscape-ui/core-sdk
4
+
5
+ **A scene-based 2D engine for building interactive editor products on infinite canvas**
6
+
7
+ [![Version](https://img.shields.io/badge/version-2.0.0-0ea5e9.svg)](https://www.npmjs.com/package/@flowscape-ui/core-sdk)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
+ [![Bundle Size](https://img.shields.io/bundlephobia/minzip/@flowscape-ui/core-sdk)](https://bundlephobia.com/package/@flowscape-ui/core-sdk)
10
+ [![X (Twitter)](https://img.shields.io/badge/X-@FlowscapeUI-000000?logo=x&logoColor=white)](https://x.com/FlowscapeUI)
11
+
12
+ [![Documentation](https://img.shields.io/badge/📚_Documentation-FF4785?style=for-the-badge&logo=storybook&logoColor=white)](https://flowscape-ui.github.io/core-sdk/)
13
+ [![Interactive Demo](https://img.shields.io/badge/🎮_Interactive_Demo-FF4785?style=for-the-badge&logo=storybook&logoColor=white)](https://flowscape-ui.github.io/core-sdk/?path=/story/interactive-playground--interactive-playground)
14
+ [![Changelog](https://img.shields.io/badge/📝_Changelog-FF4785?style=for-the-badge&logo=storybook&logoColor=white)](./CHANGELOG.md)
15
+
16
+ <img
17
+ src="./assets/readme/preview.gif"
18
+ alt="Flowscape Canvas Demo"
19
+ width="900"
20
+ />
21
+
22
+ </div>
23
+
24
+ ---
25
+
26
+ ## What is Flowscape?
27
+
28
+ Flowscape is a 2D engine for building products like whiteboards, visual builders, diagram tools, and design editors.
29
+ It is not a UI framework and not a template SDK.
30
+ It gives you a structured scene, nodes, camera, and rendering pipeline so you can build your own editor architecture.
31
+
32
+ ## Why use it?
33
+
34
+ - Scene architecture with 4 layers: `Background`, `World`, `Overlay`, `UI`
35
+ - Node-based model with transforms, hierarchy, bounds (`OBB`, `AABB`), hit testing
36
+ - Built-in pan/zoom input controllers for editor-like interactions
37
+ - TypeScript-first API
38
+ - Renderer architecture that can evolve without rewriting product logic
39
+ - Works in browser apps and can be used inside desktop/mobile stacks via web technologies
40
+
41
+ ## 📦 Installation
42
+
43
+ ```bash
44
+ npm install @flowscape-ui/core-sdk
45
+ # or
46
+ pnpm add @flowscape-ui/core-sdk
47
+ # or
48
+ yarn add @flowscape-ui/core-sdk
49
+ # or
50
+ bun add @flowscape-ui/core-sdk
51
+ ```
52
+
53
+ ## 🚀 Quick Start
54
+
55
+ ```ts
56
+ import {
57
+ Scene,
58
+ NodeRect,
59
+ RendererLayerBackgroundCanvas,
60
+ RendererLayerWorldCanvas,
61
+ CanvasRendererHost,
62
+ LayerWorldInputController,
63
+ } from '@flowscape-ui/core-sdk';
64
+
65
+ const container = document.getElementById('app');
66
+ if (!container) throw new Error('Container #app not found');
67
+
68
+ const scene = new Scene(container.clientWidth, container.clientHeight);
69
+
70
+ // Background layer
71
+ const bgRenderer = new RendererLayerBackgroundCanvas();
72
+ scene.layerManager.add(scene.layerBackground, bgRenderer, scene.layerBackground);
73
+ scene.layerBackground.setFill('#101010');
74
+
75
+ // World layer
76
+ const worldRenderer = new RendererLayerWorldCanvas();
77
+ scene.layerManager.add(scene.layerWorld, worldRenderer, scene.layerWorld);
78
+
79
+ // Render host
80
+ const host = new CanvasRendererHost(container, -1);
81
+ scene.hostManager.add(host);
82
+
83
+ // Input controller (pan/zoom)
84
+ scene.inputManager.add(scene.layerWorld, new LayerWorldInputController(), {
85
+ stage: host.getRenderNode(),
86
+ world: scene.layerWorld,
87
+ options: {
88
+ enabled: true,
89
+ panMode: 'right',
90
+ zoomEnabled: true,
91
+ zoomFactor: 1.08,
92
+ preventWheelDefault: false,
93
+ keyboardPanSpeed: 900,
94
+ keyboardPanShiftMultiplier: 1.5,
95
+ },
96
+ emitChange: () => scene.invalidate(),
97
+ });
98
+
99
+ // Add a node
100
+ const rect = new NodeRect(1);
101
+ rect.setPosition(300, 220);
102
+ rect.setSize(220, 140);
103
+ rect.setFill('#2f7cf6');
104
+ scene.layerWorld.addNode(rect);
105
+
106
+ scene.invalidate();
107
+ ```
108
+
109
+ ## 🔒 Public API Policy
110
+
111
+ - Import only from `@flowscape-ui/core-sdk`
112
+ - Do not import internals from `src/...`
113
+ - Internal files can change between releases
114
+
115
+ ## 📚 Links
116
+
117
+ - Documentation: https://flowscape-ui.github.io/core-sdk/
118
+ - Interactive demo: https://flowscape-ui.github.io/core-sdk/?path=/story/interactive-playground--interactive-playground
119
+ - GitHub Issues: https://github.com/Flowscape-UI/core-sdk/issues
120
+ - Changelog: `./CHANGELOG.md`
121
+
122
+ ## 📄 License
123
+
124
+ MIT © Flowscape UI Team