@svgsketch/core 1.9.0 → 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/README.md +22 -38
- package/dist/index.d.mts +4239 -1467
- package/dist/index.d.ts +4239 -1467
- package/dist/index.js +17 -12
- package/dist/index.mjs +17 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@ npm install @svgsketch/core
|
|
|
14
14
|
## Quick start
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
|
-
import {
|
|
17
|
+
import { DocumentBuilder, Circle, Rectangle } from '@svgsketch/core';
|
|
18
18
|
|
|
19
|
-
const doc = new
|
|
19
|
+
const doc = new DocumentBuilder({ width: 400, height: 300 })
|
|
20
20
|
.title('Hello')
|
|
21
21
|
.add(new Circle(200, 150, 80).fill('#2563eb'))
|
|
22
22
|
.add(new Rectangle(10, 10, 100, 60).fill('#ef4444').cornerRadius(8));
|
|
@@ -32,7 +32,7 @@ const svgs = doc.toJSON(); // canonical `.svgs` document
|
|
|
32
32
|
| `types` | `HistorySnapshot`, `SerializedShape`, `SerializedSymbolDef`, … |
|
|
33
33
|
| `format` | `parseDocument`, `stringifyDocument`, `migrateSnapshot`, `validateSnapshot`, `substituteVariables` |
|
|
34
34
|
| `renderer` | `renderToSvg` |
|
|
35
|
-
| `sdk` | `
|
|
35
|
+
| `sdk` | `DocumentBuilder`, `Circle`, `Rectangle`, …, `Timeline`, `Track` |
|
|
36
36
|
| `codegen` | `generateCode` — SVG / React / Vue / D3 / CSS output |
|
|
37
37
|
|
|
38
38
|
## The `.svgs` format
|
|
@@ -52,39 +52,17 @@ designed for:
|
|
|
52
52
|
```jsonc
|
|
53
53
|
{
|
|
54
54
|
"schemaVersion": 1,
|
|
55
|
-
"documentMetadata": {
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
],
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
],
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
],
|
|
67
|
-
"measurements": [
|
|
68
|
-
/* dimensioning annotations */
|
|
69
|
-
],
|
|
70
|
-
"groups": [
|
|
71
|
-
/* { id, parentId, siblingIndex, … } */
|
|
72
|
-
],
|
|
73
|
-
"clipMaskGroups": [
|
|
74
|
-
/* <clipPath> / <mask> definitions */
|
|
75
|
-
],
|
|
76
|
-
"customPatterns": [
|
|
77
|
-
/* user-defined fill patterns */
|
|
78
|
-
],
|
|
79
|
-
"symbols": [
|
|
80
|
-
/* reusable component definitions */
|
|
81
|
-
],
|
|
82
|
-
"animationTimeline": {
|
|
83
|
-
/* tracks + keyframes */
|
|
84
|
-
},
|
|
85
|
-
"shapes": [
|
|
86
|
-
/* array — order IS z-order */
|
|
87
|
-
],
|
|
55
|
+
"documentMetadata": {/* title, author, license, … */},
|
|
56
|
+
"templateVariables": [/* { name, type, defaultValue, … } */],
|
|
57
|
+
"viewboxes": [/* { id, x, y, width, height } */],
|
|
58
|
+
"guides": [/* { id, orientation, position, … } */],
|
|
59
|
+
"measurements": [/* dimensioning annotations */],
|
|
60
|
+
"groups": [/* { id, parentId, siblingIndex, … } */],
|
|
61
|
+
"clipMaskGroups": [/* <clipPath> / <mask> definitions */],
|
|
62
|
+
"customPatterns": [/* user-defined fill patterns */],
|
|
63
|
+
"symbols": [/* reusable component definitions */],
|
|
64
|
+
"animationTimeline": {/* tracks + keyframes */},
|
|
65
|
+
"shapes": [/* array — order IS z-order */],
|
|
88
66
|
}
|
|
89
67
|
```
|
|
90
68
|
|
|
@@ -195,10 +173,16 @@ Errors block loading; warnings are surfaced but do not.
|
|
|
195
173
|
## Minimal example
|
|
196
174
|
|
|
197
175
|
```ts
|
|
198
|
-
import {
|
|
176
|
+
import {
|
|
177
|
+
DocumentBuilder,
|
|
178
|
+
Circle,
|
|
179
|
+
parseDocument,
|
|
180
|
+
substituteVariables,
|
|
181
|
+
renderToSvg,
|
|
182
|
+
} from '@svgsketch/core';
|
|
199
183
|
|
|
200
184
|
// Build
|
|
201
|
-
const doc = new
|
|
185
|
+
const doc = new DocumentBuilder({ width: 200, height: 200 })
|
|
202
186
|
.add(new Circle(100, 100, 75).fill('{{accent}}').id('c1'))
|
|
203
187
|
.defineVariable('accent', 'color', '#3498db');
|
|
204
188
|
|