@flowscape-ui/core-sdk 1.0.0 → 1.0.2
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/README.md +130 -70
- package/dist/index.cjs +1 -7347
- package/dist/index.js +1 -7314
- package/package.json +1 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
1
|
# 🎨 @flowscape-ui/core-sdk
|
|
4
2
|
|
|
5
|
-
**Powerful 2D canvas engine built on Konva**
|
|
3
|
+
**Powerful 2D canvas engine built on Konva.js**
|
|
6
4
|
|
|
7
5
|
[](https://www.npmjs.com/package/@flowscape-ui/core-sdk)
|
|
8
|
-
[](https://www.typescriptlang.org/)
|
|
10
|
-
[](https://bundlephobia.com/package/@flowscape-ui/core-sdk)
|
|
6
|
+
[](https://buymeacoffee.com/flowscape)
|
|
11
7
|
|
|
12
|
-
[Documentation](https://github.
|
|
13
|
-
|
|
14
|
-
</div>
|
|
8
|
+
[📖 Documentation](https://flowscape-ui.github.io/core-sdk-doc/) • [💡 Examples](https://flowscape-ui.github.io/core-sdk-doc/docs/guides/interactive-demo) • [📝 Changelog](#)
|
|
15
9
|
|
|
16
10
|
---
|
|
17
11
|
|
|
@@ -26,6 +20,8 @@
|
|
|
26
20
|
- 📦 **TypeScript-first** — full typing out of the box
|
|
27
21
|
- 🚀 **Optimized** — tree-shaking, ESM + CJS, source maps
|
|
28
22
|
|
|
23
|
+
---
|
|
24
|
+
|
|
29
25
|
## 📦 Installation
|
|
30
26
|
|
|
31
27
|
```bash
|
|
@@ -36,14 +32,21 @@ yarn add @flowscape-ui/core-sdk
|
|
|
36
32
|
bun add @flowscape-ui/core-sdk
|
|
37
33
|
```
|
|
38
34
|
|
|
35
|
+
---
|
|
36
|
+
|
|
39
37
|
## 🚀 Quick Start
|
|
40
38
|
|
|
41
39
|
```typescript
|
|
42
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
CoreEngine,
|
|
42
|
+
GridPlugin,
|
|
43
|
+
SelectionPlugin,
|
|
44
|
+
NodeHotkeysPlugin,
|
|
45
|
+
} from "@flowscape-ui/core-sdk";
|
|
43
46
|
|
|
44
47
|
// Create engine with plugins
|
|
45
|
-
const
|
|
46
|
-
container: document.getElementById(
|
|
48
|
+
const engine = new CoreEngine({
|
|
49
|
+
container: document.getElementById("canvas-container")!,
|
|
47
50
|
width: 1200,
|
|
48
51
|
height: 800,
|
|
49
52
|
plugins: [
|
|
@@ -54,25 +57,25 @@ const core = new CoreEngine({
|
|
|
54
57
|
});
|
|
55
58
|
|
|
56
59
|
// Add shapes
|
|
57
|
-
const rect =
|
|
60
|
+
const rect = engine.nodes.addShape({
|
|
58
61
|
x: 100,
|
|
59
62
|
y: 100,
|
|
60
63
|
width: 200,
|
|
61
64
|
height: 150,
|
|
62
|
-
fill:
|
|
65
|
+
fill: "#3b82f6",
|
|
63
66
|
cornerRadius: 8,
|
|
64
67
|
});
|
|
65
68
|
|
|
66
|
-
const text =
|
|
69
|
+
const text = engine.nodes.addText({
|
|
67
70
|
x: 120,
|
|
68
71
|
y: 140,
|
|
69
|
-
text:
|
|
72
|
+
text: "Hello Flowscape!",
|
|
70
73
|
fontSize: 24,
|
|
71
|
-
fill:
|
|
74
|
+
fill: "white",
|
|
72
75
|
});
|
|
73
76
|
|
|
74
77
|
// Grouping
|
|
75
|
-
const group =
|
|
78
|
+
const group = engine.nodes.addGroup({
|
|
76
79
|
x: 400,
|
|
77
80
|
y: 200,
|
|
78
81
|
});
|
|
@@ -80,6 +83,8 @@ rect.getNode().moveTo(group.getNode());
|
|
|
80
83
|
text.getNode().moveTo(group.getNode());
|
|
81
84
|
```
|
|
82
85
|
|
|
86
|
+
---
|
|
87
|
+
|
|
83
88
|
## 🏗️ Architecture
|
|
84
89
|
|
|
85
90
|
### Core Components
|
|
@@ -104,7 +109,6 @@ text.getNode().moveTo(group.getNode());
|
|
|
104
109
|
│ ┌──────────────────────────────┐ │
|
|
105
110
|
│ │ Camera Manager │ │
|
|
106
111
|
│ │ - Zoom (Ctrl+Wheel) │ │
|
|
107
|
-
│ │ - Pan (Space+Drag) │ │
|
|
108
112
|
│ └──────────────────────────────┘ │
|
|
109
113
|
└─────────────────────────────────────┘
|
|
110
114
|
```
|
|
@@ -114,41 +118,90 @@ text.getNode().moveTo(group.getNode());
|
|
|
114
118
|
Plugins extend engine functionality without modifying the core:
|
|
115
119
|
|
|
116
120
|
```typescript
|
|
117
|
-
import { Plugin } from
|
|
121
|
+
import { Plugin, CoreEngine } from "@flowscape-ui/core-sdk";
|
|
118
122
|
|
|
119
123
|
class CustomPlugin extends Plugin {
|
|
120
124
|
protected onAttach(core: CoreEngine): void {
|
|
121
125
|
// Initialize on attach
|
|
122
|
-
core.eventBus.on(
|
|
123
|
-
console.log(
|
|
126
|
+
core.eventBus.on("node:created", (node) => {
|
|
127
|
+
console.log("Node created:", node);
|
|
124
128
|
});
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
protected onDetach(core: CoreEngine): void {
|
|
128
132
|
// Cleanup on detach
|
|
129
|
-
core.eventBus.off(
|
|
133
|
+
core.eventBus.off("node:created");
|
|
130
134
|
}
|
|
131
135
|
}
|
|
132
136
|
|
|
133
137
|
// Usage
|
|
134
|
-
const
|
|
138
|
+
const engine = new CoreEngine({
|
|
135
139
|
container: element,
|
|
136
140
|
plugins: [new CustomPlugin()],
|
|
137
141
|
});
|
|
138
142
|
```
|
|
139
143
|
|
|
140
|
-
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 🧩 Built-in Plugins
|
|
147
|
+
|
|
148
|
+
| Plugin | Description |
|
|
149
|
+
| ------------------------ | ----------------------------------------------------- |
|
|
150
|
+
| **GridPlugin** | Adaptive grid with automatic scaling and snap-to-grid |
|
|
151
|
+
| **SelectionPlugin** | Selection, transformation, drag & drop, grouping |
|
|
152
|
+
| **AreaSelectionPlugin** | Area selection with frame (Shift+Drag) |
|
|
153
|
+
| **NodeHotkeysPlugin** | Copy/paste/cut nodes, delete, z-index management |
|
|
154
|
+
| **CameraHotkeysPlugin** | Zoom and pan controls with keyboard |
|
|
155
|
+
| **RulerPlugin** | Rulers with measurement units |
|
|
156
|
+
| **RulerGuidesPlugin** | Draggable guide lines from rulers |
|
|
157
|
+
| **RulerHighlightPlugin** | Ruler highlighting on hover |
|
|
158
|
+
| **RulerManagerPlugin** | Toggle rulers and manage guides |
|
|
159
|
+
| **LogoPlugin** | Watermark/logo on canvas |
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## ⌨️ Keyboard Shortcuts
|
|
141
164
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
| `
|
|
147
|
-
| `
|
|
148
|
-
| `
|
|
149
|
-
| `
|
|
150
|
-
| `
|
|
151
|
-
| `
|
|
165
|
+
### Node Operations (NodeHotkeysPlugin)
|
|
166
|
+
|
|
167
|
+
| Shortcut | Action |
|
|
168
|
+
| ---------------------- | ------------------------ |
|
|
169
|
+
| `Ctrl+C` | Copy selected nodes |
|
|
170
|
+
| `Ctrl+X` | Cut selected nodes |
|
|
171
|
+
| `Ctrl+V` | Paste nodes |
|
|
172
|
+
| `Delete` / `Backspace` | Delete selected nodes |
|
|
173
|
+
| `Ctrl+]` | Move node up (z-index) |
|
|
174
|
+
| `Ctrl+[` | Move node down (z-index) |
|
|
175
|
+
|
|
176
|
+
### Grouping (SelectionPlugin)
|
|
177
|
+
|
|
178
|
+
| Shortcut | Action |
|
|
179
|
+
| ----------------------- | --------------------------------- |
|
|
180
|
+
| `Ctrl+G` | Group selected nodes |
|
|
181
|
+
| `Ctrl+Shift+G` | Ungroup selected group |
|
|
182
|
+
| `Shift+Click` | Add/remove node to/from selection |
|
|
183
|
+
| `Shift` (during resize) | Lock aspect ratio |
|
|
184
|
+
|
|
185
|
+
### Camera Controls (CameraHotkeysPlugin)
|
|
186
|
+
|
|
187
|
+
| Shortcut | Action |
|
|
188
|
+
| ------------------- | ----------- |
|
|
189
|
+
| `Ctrl+Wheel` | Zoom in/out |
|
|
190
|
+
| `+` / `=` | Zoom in |
|
|
191
|
+
| `-` | Zoom out |
|
|
192
|
+
| `Arrow Keys` | Pan camera |
|
|
193
|
+
| `Middle Mouse+Drag` | Pan camera |
|
|
194
|
+
| `Right Mouse+Drag` | Pan camera |
|
|
195
|
+
|
|
196
|
+
### Ruler Controls (RulerManagerPlugin)
|
|
197
|
+
|
|
198
|
+
| Shortcut | Action |
|
|
199
|
+
| ---------------------- | ------------------------ |
|
|
200
|
+
| `Shift+R` | Toggle rulers visibility |
|
|
201
|
+
| `Delete` / `Backspace` | Delete active guide |
|
|
202
|
+
| Drag from ruler | Create guide line |
|
|
203
|
+
|
|
204
|
+
---
|
|
152
205
|
|
|
153
206
|
## 📚 Usage Examples
|
|
154
207
|
|
|
@@ -156,42 +209,42 @@ const core = new CoreEngine({
|
|
|
156
209
|
|
|
157
210
|
```typescript
|
|
158
211
|
// Rectangle with rounded corners
|
|
159
|
-
const rect =
|
|
212
|
+
const rect = engine.nodes.addShape({
|
|
160
213
|
x: 50,
|
|
161
214
|
y: 50,
|
|
162
215
|
width: 200,
|
|
163
216
|
height: 100,
|
|
164
|
-
fill:
|
|
217
|
+
fill: "#10b981",
|
|
165
218
|
cornerRadius: 12,
|
|
166
219
|
});
|
|
167
220
|
|
|
168
221
|
// Circle
|
|
169
|
-
const circle =
|
|
222
|
+
const circle = engine.nodes.addCircle({
|
|
170
223
|
x: 300,
|
|
171
224
|
y: 100,
|
|
172
225
|
radius: 50,
|
|
173
|
-
fill:
|
|
174
|
-
stroke:
|
|
226
|
+
fill: "#f59e0b",
|
|
227
|
+
stroke: "#d97706",
|
|
175
228
|
strokeWidth: 3,
|
|
176
229
|
});
|
|
177
230
|
|
|
178
231
|
// Text
|
|
179
|
-
const text =
|
|
232
|
+
const text = engine.nodes.addText({
|
|
180
233
|
x: 400,
|
|
181
234
|
y: 50,
|
|
182
|
-
text:
|
|
235
|
+
text: "Flowscape UI",
|
|
183
236
|
fontSize: 32,
|
|
184
|
-
fontFamily:
|
|
185
|
-
fill:
|
|
237
|
+
fontFamily: "Inter",
|
|
238
|
+
fill: "#1f2937",
|
|
186
239
|
});
|
|
187
240
|
|
|
188
241
|
// Image
|
|
189
|
-
const image =
|
|
242
|
+
const image = engine.nodes.addImage({
|
|
190
243
|
x: 100,
|
|
191
244
|
y: 200,
|
|
192
245
|
width: 200,
|
|
193
246
|
height: 150,
|
|
194
|
-
src:
|
|
247
|
+
src: "/path/to/image.jpg",
|
|
195
248
|
});
|
|
196
249
|
```
|
|
197
250
|
|
|
@@ -199,33 +252,33 @@ const image = core.nodes.addImage({
|
|
|
199
252
|
|
|
200
253
|
```typescript
|
|
201
254
|
// Subscribe to events
|
|
202
|
-
|
|
203
|
-
console.log(
|
|
255
|
+
engine.eventBus.on("node:created", (node) => {
|
|
256
|
+
console.log("Node created:", node);
|
|
204
257
|
});
|
|
205
258
|
|
|
206
|
-
|
|
207
|
-
console.log(
|
|
259
|
+
engine.eventBus.on("node:selected", (node) => {
|
|
260
|
+
console.log("Node selected:", node);
|
|
208
261
|
});
|
|
209
262
|
|
|
210
|
-
|
|
211
|
-
console.log(
|
|
263
|
+
engine.eventBus.on("camera:zoom", ({ scale }) => {
|
|
264
|
+
console.log("Zoom changed:", scale);
|
|
212
265
|
});
|
|
213
266
|
|
|
214
267
|
// Unsubscribe
|
|
215
268
|
const handler = (node) => console.log(node);
|
|
216
|
-
|
|
217
|
-
|
|
269
|
+
engine.eventBus.on("node:created", handler);
|
|
270
|
+
engine.eventBus.off("node:created", handler);
|
|
218
271
|
```
|
|
219
272
|
|
|
220
273
|
### Grouping and Management
|
|
221
274
|
|
|
222
275
|
```typescript
|
|
223
276
|
// Create group
|
|
224
|
-
const group =
|
|
277
|
+
const group = engine.nodes.addGroup({ x: 0, y: 0 });
|
|
225
278
|
|
|
226
279
|
// Add nodes to group
|
|
227
|
-
const rect1 =
|
|
228
|
-
const rect2 =
|
|
280
|
+
const rect1 = engine.nodes.addShape({ x: 10, y: 10, width: 50, height: 50 });
|
|
281
|
+
const rect2 = engine.nodes.addShape({ x: 70, y: 10, width: 50, height: 50 });
|
|
229
282
|
|
|
230
283
|
rect1.getNode().moveTo(group.getNode());
|
|
231
284
|
rect2.getNode().moveTo(group.getNode());
|
|
@@ -240,21 +293,23 @@ rect1.getNode().moveToTop(); // Move to top
|
|
|
240
293
|
|
|
241
294
|
```typescript
|
|
242
295
|
// Programmatic zoom
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
296
|
+
engine.camera.zoomIn(); // Zoom in
|
|
297
|
+
engine.camera.zoomOut(); // Zoom out
|
|
298
|
+
engine.camera.setZoom(1.5); // Set specific scale
|
|
246
299
|
|
|
247
300
|
// Panning
|
|
248
|
-
|
|
301
|
+
engine.camera.pan(100, 50); // Pan by dx, dy
|
|
249
302
|
|
|
250
303
|
// Center on node
|
|
251
|
-
const node =
|
|
252
|
-
|
|
304
|
+
const node = engine.nodes.addShape({ x: 500, y: 500, width: 100, height: 100 });
|
|
305
|
+
engine.camera.centerOn(node);
|
|
253
306
|
|
|
254
307
|
// Reset camera
|
|
255
|
-
|
|
308
|
+
engine.camera.reset();
|
|
256
309
|
```
|
|
257
310
|
|
|
311
|
+
---
|
|
312
|
+
|
|
258
313
|
## 🔧 Development
|
|
259
314
|
|
|
260
315
|
```bash
|
|
@@ -278,23 +333,28 @@ bun run lint:ts # TypeScript check
|
|
|
278
333
|
bun run lint:fix # Auto-fix
|
|
279
334
|
```
|
|
280
335
|
|
|
336
|
+
---
|
|
337
|
+
|
|
281
338
|
## 📖 Documentation
|
|
282
339
|
|
|
283
|
-
|
|
340
|
+
Full documentation is available at [flowscape-ui.github.io/core-sdk-doc/](https://flowscape-ui.github.io/core-sdk-doc/)
|
|
284
341
|
|
|
285
|
-
|
|
342
|
+
- [Getting Started](https://flowscape-ui.github.io/core-sdk-doc/docs/getting-started/installation)
|
|
343
|
+
- [Core Concepts](https://flowscape-ui.github.io/core-sdk-doc/docs/core-concepts/architecture)
|
|
344
|
+
- [Plugins](https://flowscape-ui.github.io/core-sdk-doc/docs/plugins/overview)
|
|
345
|
+
- [API Reference](https://flowscape-ui.github.io/core-sdk-doc/docs/api/reference)
|
|
346
|
+
- [Interactive Demo](https://flowscape-ui.github.io/core-sdk-doc/docs/guides/interactive-demo)
|
|
286
347
|
|
|
287
|
-
|
|
288
|
-
- `main` — stable version, auto-publish to npm
|
|
348
|
+
---
|
|
289
349
|
|
|
290
350
|
## 📄 License
|
|
291
351
|
|
|
292
|
-
MIT ©
|
|
352
|
+
MIT © Flowscape UI Team
|
|
293
353
|
|
|
294
354
|
---
|
|
295
355
|
|
|
296
356
|
<div align="center">
|
|
297
357
|
|
|
298
|
-
|
|
358
|
+
⭐ [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)
|
|
299
359
|
|
|
300
360
|
</div>
|