@nexart/codemode-sdk 1.1.1 → 1.4.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 (90) hide show
  1. package/README.md +121 -238
  2. package/dist/engine.d.ts +1 -1
  3. package/dist/engine.js +1 -1
  4. package/dist/index.d.ts +19 -27
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +19 -34
  7. package/dist/loop-engine.d.ts +1 -4
  8. package/dist/loop-engine.d.ts.map +1 -1
  9. package/dist/loop-engine.js +12 -17
  10. package/dist/p5-runtime.d.ts +4 -56
  11. package/dist/p5-runtime.d.ts.map +1 -1
  12. package/dist/p5-runtime.js +22 -348
  13. package/dist/static-engine.d.ts +1 -4
  14. package/dist/static-engine.d.ts.map +1 -1
  15. package/dist/static-engine.js +10 -14
  16. package/dist/types.d.ts +7 -7
  17. package/dist/types.d.ts.map +1 -1
  18. package/dist/types.js +3 -3
  19. package/package.json +17 -23
  20. package/CHANGELOG.md +0 -109
  21. package/CODE_MODE_PROTOCOL.md +0 -312
  22. package/dist/core-index.d.ts +0 -21
  23. package/dist/core-index.d.ts.map +0 -1
  24. package/dist/core-index.js +0 -26
  25. package/dist/execute.d.ts +0 -46
  26. package/dist/execute.d.ts.map +0 -1
  27. package/dist/execute.js +0 -268
  28. package/dist/noise-bridge.d.ts +0 -44
  29. package/dist/noise-bridge.d.ts.map +0 -1
  30. package/dist/noise-bridge.js +0 -68
  31. package/dist/noise-engine.d.ts +0 -74
  32. package/dist/noise-engine.d.ts.map +0 -1
  33. package/dist/noise-engine.js +0 -132
  34. package/dist/noise-sketches/fractalNoise.d.ts +0 -11
  35. package/dist/noise-sketches/fractalNoise.d.ts.map +0 -1
  36. package/dist/noise-sketches/fractalNoise.js +0 -121
  37. package/dist/noise-sketches/index.d.ts +0 -21
  38. package/dist/noise-sketches/index.d.ts.map +0 -1
  39. package/dist/noise-sketches/index.js +0 -28
  40. package/dist/sound-bridge.d.ts +0 -89
  41. package/dist/sound-bridge.d.ts.map +0 -1
  42. package/dist/sound-bridge.js +0 -128
  43. package/dist/soundart-engine.d.ts +0 -87
  44. package/dist/soundart-engine.d.ts.map +0 -1
  45. package/dist/soundart-engine.js +0 -173
  46. package/dist/soundart-sketches/chladniBloom.d.ts +0 -3
  47. package/dist/soundart-sketches/chladniBloom.d.ts.map +0 -1
  48. package/dist/soundart-sketches/chladniBloom.js +0 -53
  49. package/dist/soundart-sketches/dualVortex.d.ts +0 -3
  50. package/dist/soundart-sketches/dualVortex.d.ts.map +0 -1
  51. package/dist/soundart-sketches/dualVortex.js +0 -67
  52. package/dist/soundart-sketches/geometryIllusion.d.ts +0 -3
  53. package/dist/soundart-sketches/geometryIllusion.d.ts.map +0 -1
  54. package/dist/soundart-sketches/geometryIllusion.js +0 -89
  55. package/dist/soundart-sketches/index.d.ts +0 -39
  56. package/dist/soundart-sketches/index.d.ts.map +0 -1
  57. package/dist/soundart-sketches/index.js +0 -72
  58. package/dist/soundart-sketches/isoflow.d.ts +0 -3
  59. package/dist/soundart-sketches/isoflow.d.ts.map +0 -1
  60. package/dist/soundart-sketches/isoflow.js +0 -60
  61. package/dist/soundart-sketches/loomWeave.d.ts +0 -3
  62. package/dist/soundart-sketches/loomWeave.d.ts.map +0 -1
  63. package/dist/soundart-sketches/loomWeave.js +0 -59
  64. package/dist/soundart-sketches/noiseTerraces.d.ts +0 -3
  65. package/dist/soundart-sketches/noiseTerraces.d.ts.map +0 -1
  66. package/dist/soundart-sketches/noiseTerraces.js +0 -53
  67. package/dist/soundart-sketches/orb.d.ts +0 -3
  68. package/dist/soundart-sketches/orb.d.ts.map +0 -1
  69. package/dist/soundart-sketches/orb.js +0 -50
  70. package/dist/soundart-sketches/pixelGlyphs.d.ts +0 -3
  71. package/dist/soundart-sketches/pixelGlyphs.d.ts.map +0 -1
  72. package/dist/soundart-sketches/pixelGlyphs.js +0 -72
  73. package/dist/soundart-sketches/prismFlowFields.d.ts +0 -3
  74. package/dist/soundart-sketches/prismFlowFields.d.ts.map +0 -1
  75. package/dist/soundart-sketches/prismFlowFields.js +0 -51
  76. package/dist/soundart-sketches/radialBurst.d.ts +0 -3
  77. package/dist/soundart-sketches/radialBurst.d.ts.map +0 -1
  78. package/dist/soundart-sketches/radialBurst.js +0 -60
  79. package/dist/soundart-sketches/resonantSoundBodies.d.ts +0 -3
  80. package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +0 -1
  81. package/dist/soundart-sketches/resonantSoundBodies.js +0 -89
  82. package/dist/soundart-sketches/rings.d.ts +0 -11
  83. package/dist/soundart-sketches/rings.d.ts.map +0 -1
  84. package/dist/soundart-sketches/rings.js +0 -89
  85. package/dist/soundart-sketches/squares.d.ts +0 -3
  86. package/dist/soundart-sketches/squares.d.ts.map +0 -1
  87. package/dist/soundart-sketches/squares.js +0 -52
  88. package/dist/soundart-sketches/waveStripes.d.ts +0 -3
  89. package/dist/soundart-sketches/waveStripes.d.ts.map +0 -1
  90. package/dist/soundart-sketches/waveStripes.js +0 -44
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # NexArt Code Mode Runtime SDK
2
2
 
3
- **Version: 1.0.2 (Protocol v1.0.0)**
3
+ **Version: 1.4.0 (Protocol v1.2.0)**
4
4
 
5
5
  ╔══════════════════════════════════════════════════════════════════════════════╗
6
6
  ║ @nexart/codemode-sdk — Canonical Code Mode Authority ║
@@ -10,32 +10,32 @@
10
10
  ║ ║
11
11
  ║ Protocol: nexart ║
12
12
  ║ Engine: codemode ║
13
- ║ SDK Version: 1.0.2
14
- ║ Protocol Version: 1.0.0 ║
15
- ║ Phase: 1
13
+ ║ SDK Version: 1.4.0 ║
14
+ ║ Protocol Version: 1.2.0 ║
15
+ ║ Phase: 3
16
16
  ║ Enforcement: HARD ║
17
17
  ╚══════════════════════════════════════════════════════════════════════════════╝
18
18
 
19
19
  ---
20
20
 
21
- ## PROTOCOL LOCK — v1.0.0
21
+ ## PROTOCOL LOCK — v1.x
22
22
 
23
23
  | Property | Value |
24
24
  |----------|-------|
25
25
  | Protocol Name | NexArt Code Mode |
26
- | Version | v1.0.0 |
27
- | Status | **HARD LOCKED** |
28
- | Phase | 1 |
29
- | Lock Date | December 2024 |
26
+ | Version | v1.2.0 |
27
+ | Status | **STABLE** |
28
+ | Phase | 3 |
29
+ | Lock Date | January 2026 |
30
30
 
31
- **This protocol surface is frozen. Any breaking change requires v2.0.0.**
31
+ **Core protocol surface is frozen. Any breaking change requires v2.0.0.**
32
32
 
33
33
  The following are locked and will not change in v1.x:
34
34
 
35
35
  - Execution model (Static and Loop modes)
36
36
  - VAR[0..9] specification (0-10 read-only variables, missing indices return 0)
37
37
  - Determinism guarantee (seed + VAR → identical output)
38
- - Time semantics (t, frameCount, time, tGlobal)
38
+ - Time semantics (t, frameCount, time, tGlobal, totalFrames)
39
39
  - Random and noise behavior (seeded Mulberry32, Perlin)
40
40
  - Forbidden patterns list (13 patterns)
41
41
  - Canvas pre-initialization (no createCanvas)
@@ -54,27 +54,42 @@ The answer is: "Whatever @nexart/codemode-sdk does — that is the protocol."
54
54
 
55
55
  ---
56
56
 
57
- ## What's New in v1.0.2
57
+ ## What's New in v1.4.0 (Protocol v1.2.0)
58
58
 
59
- - **VAR input is now optional (0-10 elements)**
60
- - Omit `vars` or pass `[]` for empty (defaults to all zeros)
61
- - Input length must be 0-10 (throws if > 10)
62
- - Values must be finite numbers in [0, 100] (throws if out of range)
63
- - Runtime VAR is ALWAYS 10 elements (padded with zeros for consistency)
64
- - **Backwards compatible**: existing code passing 10 elements works unchanged
59
+ **Phase 3 Pixel & Graphics**
65
60
 
66
- ## v1.0.1
61
+ - **Vertex Functions**: `curveVertex(x, y)`, `bezierVertex(cx1, cy1, cx2, cy2, x, y)` for smooth curves
62
+ - **Pixel System**: `loadPixels()`, `updatePixels()`, `pixels[]`, `get(x, y)`, `set(x, y, color)`
63
+ - **Graphics System**: `createGraphics(w, h)`, `image(pg, x, y, w, h)` for offscreen rendering
64
+ - **totalFrames**: Now injected into Loop Mode runtime
67
65
 
68
- - Protocol Lock section formalized with HARD LOCKED status
69
- - VAR specification clarified with enforcement tables
66
+ ## v1.3.0 (Protocol v1.1.0)
70
67
 
71
- ## v1.0.0 (Protocol Lock)
68
+ **Phase 2 Expressive Extensions**
69
+
70
+ - **Math Helpers**: `fract(n)`, `sign(n)`
71
+ - **Vector Helpers**: `vec`, `vecAdd`, `vecSub`, `vecMult`, `vecMag`, `vecNorm`, `vecDist`
72
+ - **Shape Helpers**: `polygon()`, `star()`
73
+ - **Blend Modes**: `blendMode(NORMAL|ADD|MULTIPLY|SCREEN)`
74
+ - **Noise Extensions**: `fbm()`, `ridgedNoise()`, `curlNoise()`
75
+ - **Easing Functions**: `easeIn`, `easeOut`, `easeInOut`, `easeCubic`, `easeExpo`
76
+
77
+ ## v1.2.0
78
+
79
+ - Added `bezier()`, `curve()`, `strokeCap()`, `strokeJoin()`, `shearX()`, `shearY()`
80
+ - Added text system: `text()`, `textSize()`, `textFont()`, `textAlign()`, `textWidth()`
81
+ - Added `sq()`, `int()`, `TAU`, arc mode constants
82
+
83
+ ## v1.1.1
84
+
85
+ - **Critical Fix**: `random()` now uses seeded Mulberry32 PRNG (was using Math.random)
86
+ - All randomness is now deterministic
87
+
88
+ ## v1.0.x (Protocol Lock)
72
89
 
73
90
  - **Protocol Lock**: Phase 1 execution surface is now LOCKED
74
91
  - **Canonical Entry Point**: `executeCodeMode()` is the official execution API
75
- - **Protocol Metadata**: All executions include protocol headers for verification
76
92
  - **VAR[0..9] Protocol Variables**: First-class protocol inputs (read-only, 0-100)
77
- - **Full CSS Color Support**: hex, rgb(), rgba(), hsl(), hsla()
78
93
  - **Determinism Guarantee**: Same code + seed + vars = identical output
79
94
 
80
95
  ---
@@ -88,7 +103,7 @@ This SDK provides the **canonical runtime** for executing p5.js-style generative
88
103
  - **Deterministic**: Seed-controlled randomness, no external state
89
104
  - **Protocol-Compliant**: All outputs include verification metadata
90
105
 
91
- The SDK enforces the **NexArt Code Mode Protocol v1.0.0** for reproducible, mint-safe generative art.
106
+ The SDK enforces the **NexArt Code Mode Protocol v1.2.0** for reproducible, mint-safe generative art.
92
107
 
93
108
  ---
94
109
 
@@ -104,8 +119,7 @@ The SDK enforces the **NexArt Code Mode Protocol v1.0.0** for reproducible, mint
104
119
  ## Installation
105
120
 
106
121
  ```bash
107
- # Copy the sdk/codemode folder to your project
108
- cp -r sdk/codemode your-project/lib/codemode
122
+ npm install @nexart/codemode-sdk
109
123
  ```
110
124
 
111
125
  ---
@@ -140,7 +154,7 @@ const result = await executeCodeMode({
140
154
  // Result includes protocol metadata
141
155
  console.log(result.metadata.protocol); // 'nexart'
142
156
  console.log(result.metadata.engine); // 'codemode'
143
- console.log(result.metadata.protocolVersion); // '1.0.0'
157
+ console.log(result.metadata.protocolVersion); // '1.2.0'
144
158
  console.log(result.metadata.deterministic); // true
145
159
  console.log(result.image); // PNG Blob
146
160
  ```
@@ -167,8 +181,8 @@ interface ExecuteCodeModeResult {
167
181
  metadata: {
168
182
  protocol: 'nexart';
169
183
  engine: 'codemode';
170
- protocolVersion: '1.0.0';
171
- phase: 1;
184
+ protocolVersion: '1.2.0';
185
+ phase: 3;
172
186
  deterministic: true;
173
187
  seed: number;
174
188
  vars: number[];
@@ -182,67 +196,11 @@ interface ExecuteCodeModeResult {
182
196
 
183
197
  ---
184
198
 
185
- ## Legacy API
186
-
187
- > ⚠️ **Note**: The `createEngine()` API is still supported but new implementations should use `executeCodeMode()`.
188
-
189
- ### `createEngine(config: EngineConfig): Engine`
190
-
191
- Create a rendering engine instance.
192
-
193
- ```typescript
194
- import { createEngine } from './codemode';
195
-
196
- const engine = createEngine({
197
- mode: 'static', // 'static' | 'loop'
198
- width: 1950, // Optional, default: 1950
199
- height: 2400, // Optional, default: 2400
200
- duration: 2, // Loop mode only, 1-4 seconds
201
- fps: 30, // Loop mode only, default: 30
202
- });
203
- ```
204
-
205
- ### `engine.run(options: RunOptions): Promise<void>`
206
-
207
- Execute code and produce output.
208
-
209
- ```typescript
210
- await engine.run({
211
- code: `
212
- function setup() {
213
- background(255);
214
- fill(0);
215
- // Use VAR for external control
216
- let size = map(VAR[0], 0, 100, 50, 200);
217
- ellipse(width/2, height/2, size);
218
- }
219
- `,
220
- seed: 12345, // Optional: seed for deterministic randomness
221
- vars: [50, 75, 0, 0, 0, 0, 0, 0, 0, 0], // Optional: VAR[0..9] values (0-100)
222
- onPreview: (canvas) => {
223
- // Optional: called with canvas after first frame
224
- },
225
- onProgress: (info) => {
226
- // Optional: progress updates
227
- console.log(info.message, info.percent + '%');
228
- },
229
- onComplete: (result) => {
230
- // Required: called with final result
231
- console.log(result.type); // 'image' | 'video'
232
- console.log(result.blob); // Blob
233
- },
234
- onError: (error) => {
235
- // Optional: called on error
236
- console.error(error);
237
- },
238
- });
239
- ```
240
-
241
- ### Protocol Variables (VAR[0..9]) — Protocol v1.0.0
199
+ ## Protocol Variables (VAR[0..9]) — Protocol v1.0.0
242
200
 
243
201
  Protocol variables are first-class inputs that control artwork parameters.
244
202
 
245
- **VAR Specification (SDK v1.0.2):**
203
+ **VAR Specification:**
246
204
 
247
205
  | Property | Value | Enforcement |
248
206
  |----------|-------|-------------|
@@ -256,20 +214,7 @@ Protocol variables are first-class inputs that control artwork parameters.
256
214
  | Default | All zeros | If not provided |
257
215
 
258
216
  ```typescript
259
- // Pass values when running (0-10 elements)
260
- await engine.run({
261
- code: myCode,
262
- vars: [80, 50, 25], // VAR[0]=80, VAR[1]=50, VAR[2]=25, VAR[3..9]=0
263
- onComplete: (result) => { /* ... */ },
264
- });
265
-
266
- // Or omit entirely (all zeros)
267
- await engine.run({
268
- code: myCode,
269
- onComplete: (result) => { /* ... */ },
270
- });
271
-
272
- // Access in sketch code
217
+ // Access in sketch code (missing indices return 0)
273
218
  function setup() {
274
219
  let density = map(VAR[0], 0, 100, 10, 200);
275
220
  let speed = map(VAR[1], 0, 100, 0.5, 5);
@@ -285,14 +230,6 @@ function setup() {
285
230
  - Values MUST be in range 0-100 (throws if out of range)
286
231
  - Same code + same seed + same VARs = identical output
287
232
 
288
- ### `engine.stop(): void`
289
-
290
- Cancel a running render (Loop mode only).
291
-
292
- ### `engine.getConfig(): EngineConfig`
293
-
294
- Get the resolved engine configuration.
295
-
296
233
  ---
297
234
 
298
235
  ## Execution Rules
@@ -320,6 +257,7 @@ Get the resolved engine configuration.
320
257
  | `t` | float | Normalized time [0.0, 1.0) |
321
258
  | `time` | float | Elapsed seconds |
322
259
  | `tGlobal` | float | Alias for `t` |
260
+ | `totalFrames` | int | Total frames in loop (v1.4.0+) |
323
261
 
324
262
  ---
325
263
 
@@ -348,95 +286,40 @@ Additionally in Loop Mode:
348
286
 
349
287
  ---
350
288
 
351
- ## Example: Static Mode
352
-
353
- ```typescript
354
- import { createEngine } from './codemode';
355
-
356
- const engine = createEngine({ mode: 'static' });
357
-
358
- await engine.run({
359
- code: `
360
- function setup() {
361
- background(30);
362
- noStroke();
363
- for (let i = 0; i < 100; i++) {
364
- fill(random(255), random(255), random(255));
365
- ellipse(random(width), random(height), 50);
366
- }
367
- }
368
- `,
369
- onComplete: (result) => {
370
- // result.type === 'image'
371
- // result.blob is a PNG Blob
372
- const url = URL.createObjectURL(result.blob);
373
- document.body.innerHTML = `<img src="${url}" />`;
374
- },
375
- });
376
- ```
377
-
378
- ---
379
-
380
- ## Example: Loop Mode
381
-
382
- ```typescript
383
- import { createEngine } from './codemode';
384
-
385
- const engine = createEngine({
386
- mode: 'loop',
387
- duration: 2, // 2 second loop
388
- });
389
-
390
- await engine.run({
391
- code: `
392
- function setup() {
393
- // Called once
394
- }
395
-
396
- function draw() {
397
- background(30);
398
-
399
- // t goes from 0 to 1 over the loop duration
400
- let x = width/2 + cos(t * TWO_PI) * 200;
401
- let y = height/2 + sin(t * TWO_PI) * 200;
402
-
403
- fill(255);
404
- ellipse(x, y, 80);
405
- }
406
- `,
407
- onProgress: (info) => {
408
- console.log(info.message);
409
- },
410
- onComplete: (result) => {
411
- // result.type === 'video'
412
- // result.blob is an MP4 Blob
413
- const url = URL.createObjectURL(result.blob);
414
- document.body.innerHTML = `<video src="${url}" autoplay loop />`;
415
- },
416
- });
417
- ```
418
-
419
- ---
420
-
421
289
  ## Supported Functions
422
290
 
423
- The SDK includes a minimal p5.js-like runtime with:
291
+ The SDK includes a comprehensive p5.js-like runtime with 130+ functions:
424
292
 
425
293
  **Drawing:**
426
- `background`, `clear`, `fill`, `noFill`, `stroke`, `noStroke`, `strokeWeight`
294
+ `background`, `clear`, `fill`, `noFill`, `stroke`, `noStroke`, `strokeWeight`, `strokeCap`, `strokeJoin`
427
295
 
428
296
  **Shapes:**
429
- `ellipse`, `circle`, `rect`, `square`, `line`, `point`, `triangle`, `quad`, `arc`
297
+ `ellipse`, `circle`, `rect`, `square`, `line`, `point`, `triangle`, `quad`, `arc`, `bezier`, `curve`
430
298
 
431
- **Vertex:**
432
- `beginShape`, `vertex`, `endShape`
299
+ **Vertex (v1.4.0):**
300
+ `beginShape`, `vertex`, `curveVertex`, `bezierVertex`, `endShape`
301
+
302
+ **Shape Helpers (v1.3.0):**
303
+ `polygon`, `star`
433
304
 
434
305
  **Transform:**
435
- `push`, `pop`, `translate`, `rotate`, `scale`, `resetMatrix`
306
+ `push`, `pop`, `translate`, `rotate`, `scale`, `resetMatrix`, `shearX`, `shearY`
436
307
 
437
308
  **Color:**
438
309
  `colorMode`, `color`, `lerpColor`, `red`, `green`, `blue`, `alpha`, `hue`, `saturation`, `brightness`
439
310
 
311
+ **Text:**
312
+ `text`, `textSize`, `textFont`, `textAlign`, `textWidth`
313
+
314
+ **Blend Modes (v1.3.0):**
315
+ `blendMode(NORMAL|ADD|MULTIPLY|SCREEN)`
316
+
317
+ **Pixel System (v1.4.0):**
318
+ `loadPixels`, `updatePixels`, `pixels[]`, `get`, `set`
319
+
320
+ **Graphics (v1.4.0):**
321
+ `createGraphics`, `image`
322
+
440
323
  **Color Formats:**
441
324
  All of the following are accepted by `fill()`, `stroke()`, `background()`:
442
325
  - Grayscale: `fill(128)`, `fill(128, 127)`
@@ -448,48 +331,40 @@ All of the following are accepted by `fill()`, `stroke()`, `background()`:
448
331
  `VAR` — Array of 10 values (VAR[0] through VAR[9])
449
332
 
450
333
  **Math:**
451
- `random`, `noise`, `map`, `constrain`, `lerp`, `dist`, `mag`, `norm`
334
+ `random`, `noise`, `map`, `constrain`, `lerp`, `dist`, `mag`, `norm`, `sq`, `int`, `fract`, `sign`
452
335
 
453
- **Trig:**
454
- `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `radians`, `degrees`
336
+ **Vectors (v1.3.0):**
337
+ `vec`, `vecAdd`, `vecSub`, `vecMult`, `vecMag`, `vecNorm`, `vecDist`
455
338
 
456
- **Constants:**
457
- `PI`, `TWO_PI`, `HALF_PI`, `QUARTER_PI`, `width`, `height`, `frameCount`
339
+ **Noise Extensions (v1.3.0):**
340
+ `fbm`, `ridgedNoise`, `curlNoise`
458
341
 
459
- ---
460
-
461
- ## Video Encoding
462
-
463
- Loop Mode requires server-side video encoding. The SDK calls:
342
+ **Easing (v1.3.0):**
343
+ `easeIn`, `easeOut`, `easeInOut`, `easeCubic`, `easeExpo`
464
344
 
465
- ```
466
- POST /api/encode-loop
467
- ```
468
-
469
- Ensure your server has this endpoint available (NexArt provides this).
470
-
471
- ---
472
-
473
- ## Files
345
+ **Trig:**
346
+ `sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `radians`, `degrees`
474
347
 
475
- ```
476
- sdk/codemode/
477
- ├── index.ts # Main export
478
- ├── engine.ts # createEngine entry point
479
- ├── types.ts # TypeScript types
480
- ├── static-engine.ts # Static mode implementation
481
- ├── loop-engine.ts # Loop mode implementation
482
- ├── p5-runtime.ts # p5.js-like runtime
483
- └── README.md # This file
484
- ```
348
+ **Constants:**
349
+ `PI`, `TWO_PI`, `TAU`, `HALF_PI`, `QUARTER_PI`, `width`, `height`, `frameCount`, `totalFrames`
485
350
 
486
351
  ---
487
352
 
488
- ## License
353
+ ## Frozen Execution Guarantees — v1.0.0
489
354
 
490
- MIT License
355
+ The following guarantees are LOCKED and will not change in v1.x:
491
356
 
492
- Copyright (c) 2024 NexArt
357
+ | Guarantee | Description |
358
+ |-----------|-------------|
359
+ | Determinism | Same code + same seed + same VARs = identical output |
360
+ | Static Mode | `setup()` only, single PNG output |
361
+ | Loop Mode | Frame-authoritative, `draw()` per frame, MP4 output |
362
+ | Time Semantics | `t` ∈ [0,1), `frameCount` ∈ [0,totalFrames), `time` in seconds |
363
+ | Random | Seeded Mulberry32 PRNG via `random()` |
364
+ | Noise | Seeded Perlin noise via `noise()` |
365
+ | Canvas | Pre-initialized, no `createCanvas()` |
366
+ | VAR | Exactly 10 read-only protocol variables |
367
+ | Forbidden Patterns | 13 patterns rejected (see above) |
493
368
 
494
369
  ---
495
370
 
@@ -512,13 +387,13 @@ const result = await executeCodeMode({
512
387
  width: 1950,
513
388
  height: 2400,
514
389
  seed: 12345,
515
- vars: [50, 75, 25, 0, 0, 0, 0, 0, 0, 0], // Exactly 10 values
390
+ vars: [50, 75, 25, 0, 0, 0, 0, 0, 0, 0],
516
391
  mode: 'static'
517
392
  });
518
393
 
519
394
  // Result includes full protocol metadata for verification
520
395
  const { image, metadata } = result;
521
- console.log(metadata.protocolVersion); // '1.0.0'
396
+ console.log(metadata.protocolVersion); // '1.2.0'
522
397
  console.log(metadata.deterministic); // true
523
398
  ```
524
399
 
@@ -538,27 +413,35 @@ try {
538
413
 
539
414
  ---
540
415
 
541
- ## Frozen Execution Guarantees — v1.0.0
416
+ ## Video Encoding
542
417
 
543
- The following guarantees are LOCKED and will not change in v1.x:
418
+ Loop Mode requires server-side video encoding. The SDK calls:
544
419
 
545
- | Guarantee | Description |
546
- |-----------|-------------|
547
- | Determinism | Same code + same seed + same VARs = identical output |
548
- | Static Mode | `setup()` only, single PNG output |
549
- | Loop Mode | Frame-authoritative, `draw()` per frame, MP4 output |
550
- | Time Semantics | `t` ∈ [0,1), `frameCount` ∈ [0,totalFrames), `time` in seconds |
551
- | Random | Seeded Mulberry32 PRNG via `random()` |
552
- | Noise | Seeded Perlin noise via `noise()` |
553
- | Canvas | Pre-initialized, no `createCanvas()` |
554
- | VAR | Exactly 10 read-only protocol variables |
555
- | Forbidden Patterns | 13 patterns rejected (see above) |
420
+ ```
421
+ POST /api/encode-loop
422
+ ```
423
+
424
+ Ensure your server has this endpoint available (NexArt provides this).
425
+
426
+ ---
427
+
428
+ ## Files
429
+
430
+ ```
431
+ @nexart/codemode-sdk/
432
+ ├── index.ts # Main export
433
+ ├── engine.ts # createEngine entry point
434
+ ├── types.ts # TypeScript types
435
+ ├── static-engine.ts # Static mode implementation
436
+ ├── loop-engine.ts # Loop mode implementation
437
+ ├── p5-runtime.ts # p5.js-like runtime
438
+ └── README.md # This file
439
+ ```
556
440
 
557
441
  ---
558
442
 
559
- ## Future Work (Phase 2+)
443
+ ## License
444
+
445
+ MIT License
560
446
 
561
- - GSL v1 SDK (protocol layer) separate package
562
- - Extended p5.js compatibility
563
- - WebGL rendering support
564
- - GIF output option
447
+ Copyright (c) 2024-2026 NexArt
package/dist/engine.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * NexArt Code Mode Runtime SDK
3
- * Version: 0.1.0
3
+ * Version: 1.4.0 (Protocol v1.2.0)
4
4
  *
5
5
  * Main entry point for the Code Mode runtime engine.
6
6
  *
package/dist/engine.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * NexArt Code Mode Runtime SDK
3
- * Version: 0.1.0
3
+ * Version: 1.4.0 (Protocol v1.2.0)
4
4
  *
5
5
  * Main entry point for the Code Mode runtime engine.
6
6
  *
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * NexArt Code Mode Runtime SDK
3
- * Version: 1.1.0 (Protocol v1.0.0)
3
+ * Version: 1.4.0 (Protocol v1.2.0)
4
4
  *
5
5
  * ╔══════════════════════════════════════════════════════════════════════════╗
6
6
  * ║ @nexart/codemode-sdk — Canonical Code Mode Authority ║
@@ -10,41 +10,33 @@
10
10
  * ║ ║
11
11
  * ║ Protocol: nexart ║
12
12
  * ║ Engine: codemode ║
13
- * ║ SDK Version: 1.1.0 ║
14
- * ║ Protocol Version: 1.0.0 ║
15
- * ║ Phase: 1
13
+ * ║ SDK Version: 1.4.0 ║
14
+ * ║ Protocol Version: 1.2.0 ║
15
+ * ║ Phase: 3
16
16
  * ║ Enforcement: HARD ║
17
17
  * ╚══════════════════════════════════════════════════════════════════════════╝
18
18
  *
19
19
  * @example
20
20
  * ```typescript
21
- * import { executeCodeMode } from '@nexart/codemode-sdk';
21
+ * import { createEngine } from '@nexart/codemode-sdk';
22
22
  *
23
- * const result = await executeCodeMode({
24
- * source: `function setup() { background(255); ellipse(width/2, height/2, 100); }`,
25
- * width: 1950,
26
- * height: 2400,
27
- * seed: 12345,
28
- * vars: [50, 0, 0, 0, 0, 0, 0, 0, 0, 0],
29
- * mode: 'static'
30
- * });
23
+ * const engine = createEngine({ mode: 'static' });
31
24
  *
32
- * console.log(result.metadata.protocolVersion); // '1.0.0'
25
+ * engine.run({
26
+ * code: `
27
+ * function setup() {
28
+ * background(255);
29
+ * fill(0);
30
+ * ellipse(width/2, height/2, 100);
31
+ * }
32
+ * `,
33
+ * onComplete: (result) => {
34
+ * console.log('Rendered:', result.type, result.blob.size, 'bytes');
35
+ * }
36
+ * });
33
37
  * ```
34
38
  */
35
- export { executeCodeMode, validateCodeModeSource } from './execute';
36
- export type { ExecuteCodeModeInput, ExecuteCodeModeResult, ProtocolMetadata, } from './types';
37
- export { PROTOCOL_IDENTITY } from './types';
38
39
  export { createEngine } from './engine';
39
40
  export type { Engine, EngineConfig, RunOptions, RenderResult, ProgressInfo, RenderMode, TimeVariables, } from './types';
40
- export { DEFAULT_CONFIG } from './types';
41
- export { renderSoundArtViaCodeMode, canRenderViaCodeMode, getCodeModeAvailableStyles, type SoundArtEngineConfig, type SoundArtRenderOptions, type SoundArtRenderResult, type SoundArtMetadata, } from './soundart-engine';
42
- export { type SoundSnapshot, type SoundFeatures, createSoundSnapshot, createEmptySoundSnapshot, freezeSoundSnapshot, } from '../../shared/soundSnapshot';
43
- export { injectSoundGlobals, createSoundGlobals, createEmptySoundGlobals, generateSoundPalette, inferGenreProfile, createSoundHelpers, type SoundGlobals, type GenreProfile, } from './sound-bridge';
44
- export { getSoundArtSketch, getAvailableSoundArtSketches, isSoundArtSketchAvailable, type SoundArtSketchName, } from './soundart-sketches';
45
- export { createP5Runtime, type P5Runtime, type P5RuntimeConfig } from './p5-runtime';
46
- export { renderNoiseViaCodeMode, compileNoiseSystem, canRenderNoiseViaCodeMode, type NoiseEngineConfig, type NoiseRenderOptions, type NoiseRenderResult, type NoiseMetadata, } from './noise-engine';
47
- export { type NoiseSnapshot, type NoiseParams, type NoiseBlendMode, createNoiseSnapshot, validateNoiseSnapshot, } from '../../shared/noiseSnapshot';
48
- export { createNoiseGlobals, injectNoiseGlobals, type NoiseGlobals, } from './noise-bridge';
49
- export { getNoiseSketch, getAvailableNoiseSketchNames, isValidNoiseSketch, type NoiseSketchName, } from './noise-sketches';
41
+ export { DEFAULT_CONFIG, PROTOCOL_IDENTITY } from './types';
50
42
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAKH,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACpE,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAK5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACV,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,yBAAyB,EACzB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAGrF,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,kBAAkB,EAClB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACV,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}