@nexart/codemode-sdk 1.5.0 → 1.6.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 (99) hide show
  1. package/CHANGELOG.md +326 -0
  2. package/CODE_MODE_PROTOCOL.md +471 -0
  3. package/LICENSE.md +62 -0
  4. package/README.md +296 -58
  5. package/builder.manifest.schema.json +62 -0
  6. package/dist/builder-manifest.d.ts +79 -0
  7. package/dist/builder-manifest.d.ts.map +1 -0
  8. package/dist/builder-manifest.js +97 -0
  9. package/dist/core-index.d.ts +21 -0
  10. package/dist/core-index.d.ts.map +1 -0
  11. package/dist/core-index.js +26 -0
  12. package/dist/engine.d.ts +17 -39
  13. package/dist/engine.d.ts.map +1 -1
  14. package/dist/engine.js +52 -253
  15. package/dist/execute.d.ts +46 -0
  16. package/dist/execute.d.ts.map +1 -0
  17. package/dist/execute.js +283 -0
  18. package/dist/execution-sandbox.d.ts +107 -0
  19. package/dist/execution-sandbox.d.ts.map +1 -0
  20. package/dist/execution-sandbox.js +207 -0
  21. package/dist/index.d.ts +24 -17
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +30 -16
  24. package/dist/loop-engine.d.ts +3 -0
  25. package/dist/loop-engine.d.ts.map +1 -1
  26. package/dist/loop-engine.js +17 -7
  27. package/dist/noise-bridge.d.ts +44 -0
  28. package/dist/noise-bridge.d.ts.map +1 -0
  29. package/dist/noise-bridge.js +68 -0
  30. package/dist/noise-engine.d.ts +74 -0
  31. package/dist/noise-engine.d.ts.map +1 -0
  32. package/dist/noise-engine.js +132 -0
  33. package/dist/noise-sketches/fractalNoise.d.ts +11 -0
  34. package/dist/noise-sketches/fractalNoise.d.ts.map +1 -0
  35. package/dist/noise-sketches/fractalNoise.js +121 -0
  36. package/dist/noise-sketches/index.d.ts +21 -0
  37. package/dist/noise-sketches/index.d.ts.map +1 -0
  38. package/dist/noise-sketches/index.js +28 -0
  39. package/dist/p5-runtime.d.ts +3 -1
  40. package/dist/p5-runtime.d.ts.map +1 -1
  41. package/dist/p5-runtime.js +2 -0
  42. package/dist/sound-bridge.d.ts +89 -0
  43. package/dist/sound-bridge.d.ts.map +1 -0
  44. package/dist/sound-bridge.js +128 -0
  45. package/dist/soundart-engine.d.ts +87 -0
  46. package/dist/soundart-engine.d.ts.map +1 -0
  47. package/dist/soundart-engine.js +173 -0
  48. package/dist/soundart-sketches/chladniBloom.d.ts +3 -0
  49. package/dist/soundart-sketches/chladniBloom.d.ts.map +1 -0
  50. package/dist/soundart-sketches/chladniBloom.js +53 -0
  51. package/dist/soundart-sketches/dualVortex.d.ts +3 -0
  52. package/dist/soundart-sketches/dualVortex.d.ts.map +1 -0
  53. package/dist/soundart-sketches/dualVortex.js +67 -0
  54. package/dist/soundart-sketches/geometryIllusion.d.ts +3 -0
  55. package/dist/soundart-sketches/geometryIllusion.d.ts.map +1 -0
  56. package/dist/soundart-sketches/geometryIllusion.js +89 -0
  57. package/dist/soundart-sketches/index.d.ts +39 -0
  58. package/dist/soundart-sketches/index.d.ts.map +1 -0
  59. package/dist/soundart-sketches/index.js +72 -0
  60. package/dist/soundart-sketches/isoflow.d.ts +3 -0
  61. package/dist/soundart-sketches/isoflow.d.ts.map +1 -0
  62. package/dist/soundart-sketches/isoflow.js +60 -0
  63. package/dist/soundart-sketches/loomWeave.d.ts +3 -0
  64. package/dist/soundart-sketches/loomWeave.d.ts.map +1 -0
  65. package/dist/soundart-sketches/loomWeave.js +59 -0
  66. package/dist/soundart-sketches/noiseTerraces.d.ts +3 -0
  67. package/dist/soundart-sketches/noiseTerraces.d.ts.map +1 -0
  68. package/dist/soundart-sketches/noiseTerraces.js +53 -0
  69. package/dist/soundart-sketches/orb.d.ts +3 -0
  70. package/dist/soundart-sketches/orb.d.ts.map +1 -0
  71. package/dist/soundart-sketches/orb.js +50 -0
  72. package/dist/soundart-sketches/pixelGlyphs.d.ts +3 -0
  73. package/dist/soundart-sketches/pixelGlyphs.d.ts.map +1 -0
  74. package/dist/soundart-sketches/pixelGlyphs.js +72 -0
  75. package/dist/soundart-sketches/prismFlowFields.d.ts +3 -0
  76. package/dist/soundart-sketches/prismFlowFields.d.ts.map +1 -0
  77. package/dist/soundart-sketches/prismFlowFields.js +51 -0
  78. package/dist/soundart-sketches/radialBurst.d.ts +3 -0
  79. package/dist/soundart-sketches/radialBurst.d.ts.map +1 -0
  80. package/dist/soundart-sketches/radialBurst.js +60 -0
  81. package/dist/soundart-sketches/resonantSoundBodies.d.ts +3 -0
  82. package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +1 -0
  83. package/dist/soundart-sketches/resonantSoundBodies.js +89 -0
  84. package/dist/soundart-sketches/rings.d.ts +11 -0
  85. package/dist/soundart-sketches/rings.d.ts.map +1 -0
  86. package/dist/soundart-sketches/rings.js +89 -0
  87. package/dist/soundart-sketches/squares.d.ts +3 -0
  88. package/dist/soundart-sketches/squares.d.ts.map +1 -0
  89. package/dist/soundart-sketches/squares.js +52 -0
  90. package/dist/soundart-sketches/waveStripes.d.ts +3 -0
  91. package/dist/soundart-sketches/waveStripes.d.ts.map +1 -0
  92. package/dist/soundart-sketches/waveStripes.js +44 -0
  93. package/dist/static-engine.d.ts +7 -0
  94. package/dist/static-engine.d.ts.map +1 -1
  95. package/dist/static-engine.js +69 -14
  96. package/dist/types.d.ts +67 -5
  97. package/dist/types.d.ts.map +1 -1
  98. package/dist/types.js +1 -1
  99. package/package.json +26 -15
package/CHANGELOG.md ADDED
@@ -0,0 +1,326 @@
1
+ # Changelog
2
+
3
+ All notable changes to @nexart/codemode-sdk will be documented in this file.
4
+
5
+ ---
6
+
7
+ ## [1.6.0] — 2026-01-12
8
+
9
+ ### Added — Licensing & Builder Identity Scaffolding
10
+
11
+ **Non-Breaking, Metadata-Only Release**
12
+
13
+ This release introduces scaffolding for future licensing and builder identity features. All additions are informational only — no behavior changes, no enforcement, no runtime validation.
14
+
15
+ #### Licensing (Informational Only)
16
+ - **LICENSE.md**: Draft commercial licensing terms with enforcement NOT active
17
+ - README section: "Commercial usage of NexArt Protocol requires a license. Enforcement is not active yet."
18
+
19
+ #### Builder Manifest Schema (Optional)
20
+ - **builder.manifest.schema.json**: JSON schema for optional builder attribution
21
+ - Fields: `builder_id`, `project_name`, `contact`, `website`, `intended_use`
22
+ - NOT validated, NOT loaded at runtime, NOT required
23
+
24
+ #### Documentation
25
+ - Positioned SDK as "canonical execution surface"
26
+ - Explained determinism guarantees explicitly
27
+ - Referenced real products (ByX, Frontierra)
28
+
29
+ ### Unchanged
30
+
31
+ - No changes to execution or determinism
32
+ - No changes to protocol version (remains v1.2.0)
33
+ - No runtime validation or enforcement
34
+ - No new required files or dependencies
35
+ - Full backward compatibility with v1.5.x
36
+ - Existing sketches run unchanged
37
+
38
+ ### Verification
39
+
40
+ Run `npx tsx scripts/check-determinism.ts` — must pass before release.
41
+
42
+ ---
43
+
44
+ ## [1.5.1] — 2026-01-05
45
+
46
+ ### Added
47
+
48
+ - **Builder Manifest Support (Write-Only, Passive)**: Optional declarative metadata for builder attribution
49
+ - New `NexArtBuilderManifest` type for structured attribution data
50
+ - `registerBuilderManifest(manifest?)` — The ONLY public API (write-only)
51
+
52
+ ### Design Philosophy
53
+
54
+ **The Builder Manifest is a declaration of intent, not a capability.**
55
+
56
+ The SDK does not expose any API to read or inspect manifests. This establishes the correct long-term posture: identity declaration first, incentives later, governance before economics.
57
+
58
+ ### API Surface
59
+
60
+ | Function | Exported | Description |
61
+ |----------|----------|-------------|
62
+ | `registerBuilderManifest()` | ✅ Yes | Write-only manifest registration |
63
+ | `getBuilderManifest()` | ❌ No | Internal only |
64
+ | `clearBuilderManifest()` | ❌ No | Internal only |
65
+
66
+ ### What This Is
67
+
68
+ - **Declarative** — Write-only, no read API exposed
69
+ - **Optional** — No errors if missing or invalid
70
+ - **Non-enforced** — No validation logic
71
+ - **Non-rewarding** — No incentives, no tracking
72
+
73
+ ### What This Is NOT
74
+
75
+ - No rewards
76
+ - No analytics
77
+ - No counters
78
+ - No API endpoints
79
+ - No dashboards
80
+ - No validation logic
81
+ - No network calls
82
+ - No errors for missing/invalid manifests
83
+
84
+ ### Safety Guarantees
85
+
86
+ - ✅ No code path allows runtime or userland access to the manifest
87
+ - ✅ No execution behavior changes with or without a manifest
88
+ - ✅ Determinism is unaffected
89
+ - ✅ SDK behavior is identical with or without a manifest
90
+
91
+ ### Usage
92
+
93
+ ```typescript
94
+ import { registerBuilderManifest } from "@nexart/codemode-sdk";
95
+
96
+ registerBuilderManifest({
97
+ protocol: "nexart",
98
+ manifestVersion: "0.1",
99
+ app: { name: "My App", url: "https://myapp.com" }
100
+ });
101
+ ```
102
+
103
+ ---
104
+
105
+ ## [1.4.0] — 2026-01-02
106
+
107
+ ### Added — Protocol v1.2 Implementation
108
+
109
+ This release implements Protocol v1.2.0 (Phase 3) with vertex primitives, pixel manipulation, and offscreen graphics.
110
+
111
+ #### New Vertex Functions
112
+ - `curveVertex(x, y)` — Add Catmull-Rom spline vertex within beginShape/endShape
113
+ - `bezierVertex(cx1, cy1, cx2, cy2, x, y)` — Add cubic bezier vertex within beginShape/endShape
114
+
115
+ #### New Pixel System
116
+ - `loadPixels()` — Load canvas pixels into `pixels[]` array
117
+ - `updatePixels()` — Write `pixels[]` array back to canvas
118
+ - `pixels[]` — RGBA pixel array (length = width × height × 4)
119
+ - `get(x, y)` — Get pixel color at (x, y) as [R, G, B, A] array
120
+ - `set(x, y, color)` — Set pixel color at (x, y)
121
+
122
+ #### New Graphics System
123
+ - `createGraphics(w, h)` — Create offscreen canvas with full runtime
124
+ - `image(pg, x, y, w, h)` — Draw graphics object to main canvas
125
+
126
+ #### New Time Variable
127
+ - `totalFrames` — Total frames in loop mode, now injected into runtime
128
+
129
+ #### Protocol
130
+ - Protocol version bumped to v1.2.0 (Phase 3)
131
+ - All new functions are deterministic
132
+ - Pixel manipulation follows p5.js semantics
133
+ - Offscreen graphics inherit seed from main canvas
134
+
135
+ ---
136
+
137
+ ## [1.3.0] — 2026-01-02
138
+
139
+ ### Added — Protocol v1.1 Implementation
140
+
141
+ This release implements Protocol v1.1.0 with expressive extensions for generative art.
142
+
143
+ #### New Math Helpers
144
+ - `fract(n)` — Fractional part: `n - floor(n)`
145
+ - `sign(n)` — Sign: `-1`, `0`, or `1`
146
+
147
+ #### New Vector Helpers (stateless, plain objects)
148
+ - `vec(x, y)` — Create vector `{ x, y }`
149
+ - `vecAdd(a, b)` — Add vectors
150
+ - `vecSub(a, b)` — Subtract vectors
151
+ - `vecMult(v, s)` — Scale vector
152
+ - `vecMag(v)` — Magnitude
153
+ - `vecNorm(v)` — Normalize to unit vector
154
+ - `vecDist(a, b)` — Distance between vectors
155
+
156
+ #### New Shape Helpers
157
+ - `polygon(cx, cy, radius, sides, rotation)` — Regular polygon
158
+ - `star(cx, cy, innerRadius, outerRadius, points, rotation)` — Star shape
159
+
160
+ #### New Blend Modes
161
+ - `blendMode(mode)` — Set compositing mode
162
+ - Supported: `NORMAL`, `ADD`, `MULTIPLY`, `SCREEN`
163
+ - Unsupported modes throw protocol error
164
+
165
+ #### New Noise Extensions
166
+ - `fbm(x, y, octaves, falloff)` — Fractal Brownian Motion
167
+ - `ridgedNoise(x, y)` — Ridged/turbulent noise
168
+ - `curlNoise(x, y)` — Returns `{x, y}` curl noise vector
169
+
170
+ #### New Easing Functions
171
+ - `easeIn(t)` — Quadratic ease in
172
+ - `easeOut(t)` — Quadratic ease out
173
+ - `easeInOut(t)` — Quadratic ease in-out
174
+ - `easeCubic(t)` — Cubic ease in-out
175
+ - `easeExpo(t)` — Exponential ease in-out
176
+
177
+ #### Protocol
178
+ - Protocol version bumped to v1.1.0 (Phase 2)
179
+ - All new functions are pure and deterministic
180
+ - Vectors are plain objects (no p5.Vector)
181
+ - Blend mode resets per frame in Loop Mode
182
+
183
+ ---
184
+
185
+ ## [1.2.0] — 2026-01-02
186
+
187
+ ### Added — Capability Parity Update
188
+
189
+ This release addresses gaps identified in the Code Mode Capability Audit, bringing the SDK closer to protocol parity.
190
+
191
+ #### New Drawing Functions
192
+ - `bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2)` — Cubic bezier curves
193
+ - `curve(x1, y1, x2, y2, x3, y3, x4, y4)` — Catmull-Rom splines
194
+
195
+ #### New Style Functions
196
+ - `strokeCap(cap)` — Set line cap style (ROUND, SQUARE, PROJECT)
197
+ - `strokeJoin(join)` — Set line join style (MITER, BEVEL, ROUND)
198
+
199
+ #### New Transform Functions
200
+ - `shearX(angle)` — Shear along X axis
201
+ - `shearY(angle)` — Shear along Y axis
202
+
203
+ #### New Text System
204
+ - `text(str, x, y)` — Render text
205
+ - `textSize(size)` — Set font size
206
+ - `textFont(font)` — Set font family
207
+ - `textAlign(horizAlign, vertAlign)` — Set text alignment
208
+ - `textWidth(str)` — Measure text width
209
+
210
+ #### New Math Functions
211
+ - `int(n)` — Floor to integer
212
+ - `sq(n)` — Square (n * n)
213
+
214
+ #### New Constants
215
+ - `TAU` — Equal to TWO_PI (6.283...)
216
+ - `PIE`, `CHORD`, `OPEN` — Arc mode constants
217
+ - `LEFT`, `RIGHT`, `TOP`, `BOTTOM`, `BASELINE` — Text alignment constants
218
+
219
+ #### Protocol
220
+ - Protocol documentation updated to v1.0.1 with these additions
221
+
222
+ ---
223
+
224
+ ## [1.1.1] — 2024-12-31
225
+
226
+ ### Critical Bug Fix: Seeded Random
227
+
228
+ **BREAKING FIX**: The published npm package (v1.1.0 and earlier) had a critical bug where `random()` used `Math.random()` instead of the seeded Mulberry32 PRNG. This broke determinism guarantees.
229
+
230
+ #### Fixed
231
+ - `random()` now correctly uses seeded Mulberry32 PRNG
232
+ - `randomSeed(seed)` now properly recreates the RNG with new seed
233
+ - `randomGaussian()` now uses seeded Box-Muller transform
234
+ - `noise()` now uses proper seeded Perlin noise with octaves
235
+ - `noiseSeed(seed)` now properly recreates the noise generator
236
+ - `lerpColor()` now properly interpolates colors (was returning c1)
237
+
238
+ #### Changed
239
+ - Rebuilt package with proper TypeScript compilation
240
+ - Added standalone package.json and tsconfig.json for clean builds
241
+ - New entry point: `core-index.ts` (excludes external dependencies)
242
+
243
+ #### Verification
244
+ ```javascript
245
+ // Same seed = same output (determinism restored)
246
+ randomSeed(42);
247
+ console.log(random()); // Always 0.8379...
248
+ console.log(random()); // Always 0.9032...
249
+ ```
250
+
251
+ ---
252
+
253
+ ## [1.1.0] — 2024-12-30
254
+
255
+ ### Minor Bump for npm Publishing (DEPRECATED)
256
+
257
+ **WARNING**: This version had a critical bug. Use v1.1.1 or later.
258
+
259
+ - Updated SDK version from 1.0.2 to 1.1.0
260
+ - Protocol version remains v1.0.0 (unchanged)
261
+ - No breaking changes from 1.0.2
262
+
263
+ ---
264
+
265
+ ## [1.0.2] — 2024-12-30
266
+
267
+ ### Changed
268
+
269
+ - **VAR input is now optional (0-10 elements)**
270
+ - Omit `vars` or pass `[]` for empty (defaults to all zeros)
271
+ - Input length must be 0-10 (throws if > 10)
272
+ - Values must be finite numbers in [0, 100] (throws if out of range, NO clamping)
273
+ - Runtime VAR is ALWAYS 10 elements (padded with zeros for consistency)
274
+ - **VAR enforcement updated**
275
+ - Read-only via Proxy (throws on write attempts)
276
+ - Out-of-range values now throw (previously warned)
277
+ - **Backwards compatible**: existing code passing 10 elements works unchanged
278
+
279
+ ---
280
+
281
+ ## [1.0.1] — 2024-12-29
282
+
283
+ ### Documentation
284
+
285
+ - Protocol Lock section formalized with HARD LOCKED status
286
+ - VAR specification clarified with enforcement tables
287
+ - CHANGELOG added to track version history
288
+ - Smoke tests added for cross-SDK verification
289
+
290
+ ---
291
+
292
+ ## [1.0.0] — 2024-12-29
293
+
294
+ ### Protocol Lock
295
+
296
+ **NexArt Code Mode Protocol v1.0.0 is now HARD LOCKED.**
297
+
298
+ This version establishes the canonical Code Mode execution surface for:
299
+ - NexArt app
300
+ - ByX curated collections
301
+ - External builders and AI platforms
302
+
303
+ ### Frozen
304
+
305
+ The following are locked and will not change in v1.x:
306
+
307
+ - **Execution Model**: Static (setup-only) and Loop (frame-authoritative) modes
308
+ - **VAR[0..9]**: Exactly 10 read-only protocol variables (0-100 recommended)
309
+ - **Determinism**: Same code + same seed + same VARs = identical output
310
+ - **Time Semantics**: t ∈ [0,1), frameCount, time, tGlobal
311
+ - **Random**: Seeded Mulberry32 PRNG via random()
312
+ - **Noise**: Seeded Perlin noise via noise()
313
+ - **Forbidden Patterns**: 13 patterns rejected with [Code Mode Protocol Error]
314
+ - **Canvas**: Pre-initialized, no createCanvas()
315
+
316
+ ### API
317
+
318
+ - `executeCodeMode()` — Canonical entry point for all Code Mode execution
319
+ - `validateCodeModeSource()` — Pre-flight validation without execution
320
+ - `createEngine()` — Legacy API (still supported)
321
+
322
+ ### Notes
323
+
324
+ - Any breaking change requires v2.0.0
325
+ - VAR count is fixed at 10 and will not be extended
326
+ - This version enables external builders to depend on stable protocol semantics