sketchmark 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 +188 -0
- package/bin/sketchmark.cjs +2008 -0
- package/dist/src/builders/index.d.ts +74 -0
- package/dist/src/builders/index.js +230 -0
- package/dist/src/compounds.d.ts +13 -0
- package/dist/src/compounds.js +118 -0
- package/dist/src/deck.d.ts +4 -0
- package/dist/src/deck.js +91 -0
- package/dist/src/diagnostics.d.ts +5 -0
- package/dist/src/diagnostics.js +113 -0
- package/dist/src/export/index.d.ts +8 -0
- package/dist/src/export/index.js +15 -0
- package/dist/src/index.d.ts +19 -0
- package/dist/src/index.js +35 -0
- package/dist/src/kernel.d.ts +8 -0
- package/dist/src/kernel.js +68 -0
- package/dist/src/normalize.d.ts +6 -0
- package/dist/src/normalize.js +191 -0
- package/dist/src/patch.d.ts +5 -0
- package/dist/src/patch.js +72 -0
- package/dist/src/path-sampling.d.ts +3 -0
- package/dist/src/path-sampling.js +275 -0
- package/dist/src/player/index.d.ts +68 -0
- package/dist/src/player/index.js +600 -0
- package/dist/src/project.d.ts +11 -0
- package/dist/src/project.js +107 -0
- package/dist/src/render/html.d.ts +2 -0
- package/dist/src/render/html.js +13 -0
- package/dist/src/render/raw-three.d.ts +7 -0
- package/dist/src/render/raw-three.js +17 -0
- package/dist/src/render/svg.d.ts +3 -0
- package/dist/src/render/svg.js +277 -0
- package/dist/src/render/three-html.d.ts +2 -0
- package/dist/src/render/three-html.js +303 -0
- package/dist/src/render/three-preview-svg.d.ts +3 -0
- package/dist/src/render/three-preview-svg.js +102 -0
- package/dist/src/scenes.d.ts +4 -0
- package/dist/src/scenes.js +25 -0
- package/dist/src/schema.d.ts +2 -0
- package/dist/src/schema.js +403 -0
- package/dist/src/sequences.d.ts +43 -0
- package/dist/src/sequences.js +109 -0
- package/dist/src/shapes/builtins.d.ts +2 -0
- package/dist/src/shapes/builtins.js +429 -0
- package/dist/src/shapes/common.d.ts +9 -0
- package/dist/src/shapes/common.js +75 -0
- package/dist/src/shapes/geometry.d.ts +22 -0
- package/dist/src/shapes/geometry.js +166 -0
- package/dist/src/shapes/index.d.ts +2 -0
- package/dist/src/shapes/index.js +18 -0
- package/dist/src/shapes/registry.d.ts +9 -0
- package/dist/src/shapes/registry.js +35 -0
- package/dist/src/shapes/types.d.ts +34 -0
- package/dist/src/shapes/types.js +2 -0
- package/dist/src/types.d.ts +439 -0
- package/dist/src/types.js +2 -0
- package/dist/src/utils.d.ts +25 -0
- package/dist/src/utils.js +157 -0
- package/dist/src/validate.d.ts +2 -0
- package/dist/src/validate.js +434 -0
- package/dist/tests/run.d.ts +1 -0
- package/dist/tests/run.js +651 -0
- package/package.json +52 -0
- package/schema/visual.schema.json +930 -0
package/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Sketchmark
|
|
2
|
+
|
|
3
|
+
Primitive-first JSON visual language for AI-generated explanations.
|
|
4
|
+
|
|
5
|
+
The canonical document format is a predictable scene graph of primitives. Higher-level helpers such as `node()`, `flow()`, `packet()`, and `callout()` are builder-time conveniences only: they expand into primitives before validation and rendering.
|
|
6
|
+
|
|
7
|
+
## Core Principles
|
|
8
|
+
|
|
9
|
+
- JSON is the source of truth.
|
|
10
|
+
- The canonical document contains primitives only.
|
|
11
|
+
- Box primitives use top-left `x`, `y`, `width`, and `height`.
|
|
12
|
+
- Circles use `cx`, `cy`, and `radius`.
|
|
13
|
+
- Lines and arrows use `from` and `to`.
|
|
14
|
+
- Missing geometry is an error, not an auto-layout hint.
|
|
15
|
+
- No collision avoidance, auto-routing, auto-resize, or hidden object synthesis.
|
|
16
|
+
- All computed values come from explicit builders, references, or `follow`.
|
|
17
|
+
|
|
18
|
+
## Example
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"version": 1,
|
|
23
|
+
"canvas": {
|
|
24
|
+
"width": 1280,
|
|
25
|
+
"height": 720,
|
|
26
|
+
"background": "#f8fafc",
|
|
27
|
+
"duration": 8,
|
|
28
|
+
"fps": 30
|
|
29
|
+
},
|
|
30
|
+
"elements": [
|
|
31
|
+
{
|
|
32
|
+
"id": "browser_box",
|
|
33
|
+
"type": "rect",
|
|
34
|
+
"x": 120,
|
|
35
|
+
"y": 160,
|
|
36
|
+
"width": 180,
|
|
37
|
+
"height": 80,
|
|
38
|
+
"radius": 12,
|
|
39
|
+
"fill": "#ffffff",
|
|
40
|
+
"stroke": "#2563eb"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "browser_label",
|
|
44
|
+
"type": "text",
|
|
45
|
+
"text": "Browser",
|
|
46
|
+
"x": 210,
|
|
47
|
+
"y": 200,
|
|
48
|
+
"align": "center",
|
|
49
|
+
"valign": "middle",
|
|
50
|
+
"fontSize": 18
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Builders
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { scene } from "sketchmark";
|
|
60
|
+
import { node, arrow } from "sketchmark/builders";
|
|
61
|
+
|
|
62
|
+
const browser = node({
|
|
63
|
+
id: "browser",
|
|
64
|
+
label: "Browser",
|
|
65
|
+
x: 120,
|
|
66
|
+
y: 160,
|
|
67
|
+
width: 180,
|
|
68
|
+
height: 80
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const resolver = node({
|
|
72
|
+
id: "resolver",
|
|
73
|
+
label: "DNS Resolver",
|
|
74
|
+
x: 380,
|
|
75
|
+
y: 160,
|
|
76
|
+
width: 180,
|
|
77
|
+
height: 80
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export default scene({
|
|
81
|
+
canvas: { width: 1280, height: 720, background: "#f8fafc", duration: 8 },
|
|
82
|
+
elements: [
|
|
83
|
+
...browser,
|
|
84
|
+
...resolver,
|
|
85
|
+
arrow({
|
|
86
|
+
id: "query_arrow",
|
|
87
|
+
from: "browser_box.right",
|
|
88
|
+
to: "resolver_box.left",
|
|
89
|
+
stroke: "#2563eb",
|
|
90
|
+
strokeWidth: 3
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Exports
|
|
97
|
+
|
|
98
|
+
Build first:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run build
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Open a browser preview:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
node bin/sketchmark.cjs preview examples/dns.visual.json
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The preview opens an inline editor with live render, play/scrub controls, scene/sequence selectors, and a save button for the source JSON.
|
|
111
|
+
|
|
112
|
+
Render files:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
node bin/sketchmark.cjs render examples/dns.visual.json out.svg
|
|
116
|
+
node bin/sketchmark.cjs render examples/dns.visual.json out.html
|
|
117
|
+
node bin/sketchmark.cjs render examples/dns.visual.json out.png --time 1.5
|
|
118
|
+
node bin/sketchmark.cjs render examples/dns.visual.json transparent.png --transparent
|
|
119
|
+
node bin/sketchmark.cjs render examples/dns.visual.json out.pdf
|
|
120
|
+
node bin/sketchmark.cjs render examples/dns.visual.json out.mp4 --fps 30 --duration 4
|
|
121
|
+
node bin/sketchmark.cjs render examples/dns.visual.json transparent.webm --transparent --fps 30 --duration 4
|
|
122
|
+
node bin/sketchmark.cjs lint examples/dns.visual.json
|
|
123
|
+
node bin/sketchmark.cjs screenshot-lint examples/dns.visual.json
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
SVG and HTML are built in. PNG/JPG/PDF/MP4/WebM use `sharp`; video also requires `ffmpeg`. Use WebM for transparent video; MP4 is intentionally opaque. Structured Three image/video export uses a deterministic isometric SVG preview adapter, while HTML uses the live Three renderer.
|
|
127
|
+
|
|
128
|
+
## Browser Player
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
import { SketchmarkPlayer, createSketchmarkPlayer } from "sketchmark/player";
|
|
132
|
+
|
|
133
|
+
const player = new SketchmarkPlayer(document.getElementById("preview")!, {
|
|
134
|
+
document: visualDocument,
|
|
135
|
+
autoplay: true,
|
|
136
|
+
loop: true
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
player.seek(2);
|
|
140
|
+
player.pause();
|
|
141
|
+
player.setDocument(nextVisualDocument);
|
|
142
|
+
await player.download("svg", { title: "visual" });
|
|
143
|
+
await player.download("png", { title: "visual" });
|
|
144
|
+
await player.download("mp4", { title: "visual" });
|
|
145
|
+
player.destroy();
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The player is UI-free. It renders the primitive JSON document into the supplied element, and its browser export provider can download SVG, PNG, JPG, HTML, JSON, and MP4. MP4 uses WebCodecs/H.264 when available and falls back to WebM if the browser cannot encode MP4.
|
|
149
|
+
|
|
150
|
+
Project and sequence examples:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
node bin/sketchmark.cjs preview examples/project.visual.json --sequence main
|
|
154
|
+
node bin/sketchmark.cjs render examples/project.visual.json out.mp4 --sequence main
|
|
155
|
+
node bin/sketchmark.cjs timeline examples/project.visual.json --sequence main --fps 12
|
|
156
|
+
node bin/sketchmark.cjs render examples/deck.visual.json deck.html --deck --scene slide
|
|
157
|
+
node bin/sketchmark.cjs render examples/deck.visual.json deck.pptx --deck --scene slide
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Feature catalog:
|
|
161
|
+
|
|
162
|
+
The `examples/features/` folder contains 21 primitive-first examples covering the main language surface: primitives, references, groups, animation, keyframes, packet follow, path follow, patch-friendly ids, diagrams, charts, scenes, sequences, deck steps, images, structured 3D, and mixed 2D/3D sequences.
|
|
163
|
+
|
|
164
|
+
Structured Three HTML example:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
node bin/sketchmark.cjs render examples/three-cube.visual.json cube.html
|
|
168
|
+
node bin/sketchmark.cjs render examples/three-cube.visual.json cube.png
|
|
169
|
+
node bin/sketchmark.cjs render examples/three-cube.visual.json cube.mp4 --duration 2 --fps 24
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Raw Three escape hatch:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { renderRawThreeModuleHtml } from "sketchmark";
|
|
176
|
+
|
|
177
|
+
const html = renderRawThreeModuleHtml({
|
|
178
|
+
width: 1280,
|
|
179
|
+
height: 720,
|
|
180
|
+
moduleUrl: "./scene.js"
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The module must export `createSketchmarkThreeScene({ canvas, width, height, background })`.
|
|
185
|
+
|
|
186
|
+
## AI Reference
|
|
187
|
+
|
|
188
|
+
Use [AI.md](./AI.md) as the compact model-facing reference. It teaches only the primitive JSON surface and points to advanced features without making them default.
|