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.
Files changed (64) hide show
  1. package/README.md +188 -0
  2. package/bin/sketchmark.cjs +2008 -0
  3. package/dist/src/builders/index.d.ts +74 -0
  4. package/dist/src/builders/index.js +230 -0
  5. package/dist/src/compounds.d.ts +13 -0
  6. package/dist/src/compounds.js +118 -0
  7. package/dist/src/deck.d.ts +4 -0
  8. package/dist/src/deck.js +91 -0
  9. package/dist/src/diagnostics.d.ts +5 -0
  10. package/dist/src/diagnostics.js +113 -0
  11. package/dist/src/export/index.d.ts +8 -0
  12. package/dist/src/export/index.js +15 -0
  13. package/dist/src/index.d.ts +19 -0
  14. package/dist/src/index.js +35 -0
  15. package/dist/src/kernel.d.ts +8 -0
  16. package/dist/src/kernel.js +68 -0
  17. package/dist/src/normalize.d.ts +6 -0
  18. package/dist/src/normalize.js +191 -0
  19. package/dist/src/patch.d.ts +5 -0
  20. package/dist/src/patch.js +72 -0
  21. package/dist/src/path-sampling.d.ts +3 -0
  22. package/dist/src/path-sampling.js +275 -0
  23. package/dist/src/player/index.d.ts +68 -0
  24. package/dist/src/player/index.js +600 -0
  25. package/dist/src/project.d.ts +11 -0
  26. package/dist/src/project.js +107 -0
  27. package/dist/src/render/html.d.ts +2 -0
  28. package/dist/src/render/html.js +13 -0
  29. package/dist/src/render/raw-three.d.ts +7 -0
  30. package/dist/src/render/raw-three.js +17 -0
  31. package/dist/src/render/svg.d.ts +3 -0
  32. package/dist/src/render/svg.js +277 -0
  33. package/dist/src/render/three-html.d.ts +2 -0
  34. package/dist/src/render/three-html.js +303 -0
  35. package/dist/src/render/three-preview-svg.d.ts +3 -0
  36. package/dist/src/render/three-preview-svg.js +102 -0
  37. package/dist/src/scenes.d.ts +4 -0
  38. package/dist/src/scenes.js +25 -0
  39. package/dist/src/schema.d.ts +2 -0
  40. package/dist/src/schema.js +403 -0
  41. package/dist/src/sequences.d.ts +43 -0
  42. package/dist/src/sequences.js +109 -0
  43. package/dist/src/shapes/builtins.d.ts +2 -0
  44. package/dist/src/shapes/builtins.js +429 -0
  45. package/dist/src/shapes/common.d.ts +9 -0
  46. package/dist/src/shapes/common.js +75 -0
  47. package/dist/src/shapes/geometry.d.ts +22 -0
  48. package/dist/src/shapes/geometry.js +166 -0
  49. package/dist/src/shapes/index.d.ts +2 -0
  50. package/dist/src/shapes/index.js +18 -0
  51. package/dist/src/shapes/registry.d.ts +9 -0
  52. package/dist/src/shapes/registry.js +35 -0
  53. package/dist/src/shapes/types.d.ts +34 -0
  54. package/dist/src/shapes/types.js +2 -0
  55. package/dist/src/types.d.ts +439 -0
  56. package/dist/src/types.js +2 -0
  57. package/dist/src/utils.d.ts +25 -0
  58. package/dist/src/utils.js +157 -0
  59. package/dist/src/validate.d.ts +2 -0
  60. package/dist/src/validate.js +434 -0
  61. package/dist/tests/run.d.ts +1 -0
  62. package/dist/tests/run.js +651 -0
  63. package/package.json +52 -0
  64. 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.