@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.
- package/README.md +121 -238
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +1 -1
- package/dist/index.d.ts +19 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -34
- package/dist/loop-engine.d.ts +1 -4
- package/dist/loop-engine.d.ts.map +1 -1
- package/dist/loop-engine.js +12 -17
- package/dist/p5-runtime.d.ts +4 -56
- package/dist/p5-runtime.d.ts.map +1 -1
- package/dist/p5-runtime.js +22 -348
- package/dist/static-engine.d.ts +1 -4
- package/dist/static-engine.d.ts.map +1 -1
- package/dist/static-engine.js +10 -14
- package/dist/types.d.ts +7 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -3
- package/package.json +17 -23
- package/CHANGELOG.md +0 -109
- package/CODE_MODE_PROTOCOL.md +0 -312
- package/dist/core-index.d.ts +0 -21
- package/dist/core-index.d.ts.map +0 -1
- package/dist/core-index.js +0 -26
- package/dist/execute.d.ts +0 -46
- package/dist/execute.d.ts.map +0 -1
- package/dist/execute.js +0 -268
- package/dist/noise-bridge.d.ts +0 -44
- package/dist/noise-bridge.d.ts.map +0 -1
- package/dist/noise-bridge.js +0 -68
- package/dist/noise-engine.d.ts +0 -74
- package/dist/noise-engine.d.ts.map +0 -1
- package/dist/noise-engine.js +0 -132
- package/dist/noise-sketches/fractalNoise.d.ts +0 -11
- package/dist/noise-sketches/fractalNoise.d.ts.map +0 -1
- package/dist/noise-sketches/fractalNoise.js +0 -121
- package/dist/noise-sketches/index.d.ts +0 -21
- package/dist/noise-sketches/index.d.ts.map +0 -1
- package/dist/noise-sketches/index.js +0 -28
- package/dist/sound-bridge.d.ts +0 -89
- package/dist/sound-bridge.d.ts.map +0 -1
- package/dist/sound-bridge.js +0 -128
- package/dist/soundart-engine.d.ts +0 -87
- package/dist/soundart-engine.d.ts.map +0 -1
- package/dist/soundart-engine.js +0 -173
- package/dist/soundart-sketches/chladniBloom.d.ts +0 -3
- package/dist/soundart-sketches/chladniBloom.d.ts.map +0 -1
- package/dist/soundart-sketches/chladniBloom.js +0 -53
- package/dist/soundart-sketches/dualVortex.d.ts +0 -3
- package/dist/soundart-sketches/dualVortex.d.ts.map +0 -1
- package/dist/soundart-sketches/dualVortex.js +0 -67
- package/dist/soundart-sketches/geometryIllusion.d.ts +0 -3
- package/dist/soundart-sketches/geometryIllusion.d.ts.map +0 -1
- package/dist/soundart-sketches/geometryIllusion.js +0 -89
- package/dist/soundart-sketches/index.d.ts +0 -39
- package/dist/soundart-sketches/index.d.ts.map +0 -1
- package/dist/soundart-sketches/index.js +0 -72
- package/dist/soundart-sketches/isoflow.d.ts +0 -3
- package/dist/soundart-sketches/isoflow.d.ts.map +0 -1
- package/dist/soundart-sketches/isoflow.js +0 -60
- package/dist/soundart-sketches/loomWeave.d.ts +0 -3
- package/dist/soundart-sketches/loomWeave.d.ts.map +0 -1
- package/dist/soundart-sketches/loomWeave.js +0 -59
- package/dist/soundart-sketches/noiseTerraces.d.ts +0 -3
- package/dist/soundart-sketches/noiseTerraces.d.ts.map +0 -1
- package/dist/soundart-sketches/noiseTerraces.js +0 -53
- package/dist/soundart-sketches/orb.d.ts +0 -3
- package/dist/soundart-sketches/orb.d.ts.map +0 -1
- package/dist/soundart-sketches/orb.js +0 -50
- package/dist/soundart-sketches/pixelGlyphs.d.ts +0 -3
- package/dist/soundart-sketches/pixelGlyphs.d.ts.map +0 -1
- package/dist/soundart-sketches/pixelGlyphs.js +0 -72
- package/dist/soundart-sketches/prismFlowFields.d.ts +0 -3
- package/dist/soundart-sketches/prismFlowFields.d.ts.map +0 -1
- package/dist/soundart-sketches/prismFlowFields.js +0 -51
- package/dist/soundart-sketches/radialBurst.d.ts +0 -3
- package/dist/soundart-sketches/radialBurst.d.ts.map +0 -1
- package/dist/soundart-sketches/radialBurst.js +0 -60
- package/dist/soundart-sketches/resonantSoundBodies.d.ts +0 -3
- package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +0 -1
- package/dist/soundart-sketches/resonantSoundBodies.js +0 -89
- package/dist/soundart-sketches/rings.d.ts +0 -11
- package/dist/soundart-sketches/rings.d.ts.map +0 -1
- package/dist/soundart-sketches/rings.js +0 -89
- package/dist/soundart-sketches/squares.d.ts +0 -3
- package/dist/soundart-sketches/squares.d.ts.map +0 -1
- package/dist/soundart-sketches/squares.js +0 -52
- package/dist/soundart-sketches/waveStripes.d.ts +0 -3
- package/dist/soundart-sketches/waveStripes.d.ts.map +0 -1
- 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
|
|
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
|
|
14
|
-
║ Protocol Version: 1.
|
|
15
|
-
║ Phase:
|
|
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.
|
|
21
|
+
## PROTOCOL LOCK — v1.x
|
|
22
22
|
|
|
23
23
|
| Property | Value |
|
|
24
24
|
|----------|-------|
|
|
25
25
|
| Protocol Name | NexArt Code Mode |
|
|
26
|
-
| Version | v1.
|
|
27
|
-
| Status | **
|
|
28
|
-
| Phase |
|
|
29
|
-
| Lock Date |
|
|
26
|
+
| Version | v1.2.0 |
|
|
27
|
+
| Status | **STABLE** |
|
|
28
|
+
| Phase | 3 |
|
|
29
|
+
| Lock Date | January 2026 |
|
|
30
30
|
|
|
31
|
-
**
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
- VAR specification clarified with enforcement tables
|
|
66
|
+
## v1.3.0 (Protocol v1.1.0)
|
|
70
67
|
|
|
71
|
-
|
|
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.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
171
|
-
phase:
|
|
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
|
-
##
|
|
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
|
|
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
|
-
//
|
|
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
|
|
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
|
-
**
|
|
454
|
-
`
|
|
336
|
+
**Vectors (v1.3.0):**
|
|
337
|
+
`vec`, `vecAdd`, `vecSub`, `vecMult`, `vecMag`, `vecNorm`, `vecDist`
|
|
455
338
|
|
|
456
|
-
**
|
|
457
|
-
`
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
353
|
+
## Frozen Execution Guarantees — v1.0.0
|
|
489
354
|
|
|
490
|
-
|
|
355
|
+
The following guarantees are LOCKED and will not change in v1.x:
|
|
491
356
|
|
|
492
|
-
|
|
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],
|
|
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.
|
|
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
|
-
##
|
|
416
|
+
## Video Encoding
|
|
542
417
|
|
|
543
|
-
|
|
418
|
+
Loop Mode requires server-side video encoding. The SDK calls:
|
|
544
419
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
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
|
-
##
|
|
443
|
+
## License
|
|
444
|
+
|
|
445
|
+
MIT License
|
|
560
446
|
|
|
561
|
-
|
|
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
package/dist/engine.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NexArt Code Mode Runtime SDK
|
|
3
|
-
* Version: 1.
|
|
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.
|
|
14
|
-
* ║ Protocol Version: 1.
|
|
15
|
-
* ║ Phase:
|
|
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 {
|
|
21
|
+
* import { createEngine } from '@nexart/codemode-sdk';
|
|
22
22
|
*
|
|
23
|
-
* const
|
|
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
|
-
*
|
|
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|