@nexart/codemode-sdk 1.4.0 → 1.5.1

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