@nexart/codemode-sdk 1.1.1 → 1.5.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 +131 -238
- package/dist/engine.d.ts +39 -17
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +253 -52
- package/dist/index.d.ts +17 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -30
- package/dist/loop-engine.d.ts +2 -1
- package/dist/loop-engine.d.ts.map +1 -1
- package/dist/loop-engine.js +16 -10
- package/dist/p5-runtime.d.ts +3 -3
- package/dist/p5-runtime.d.ts.map +1 -1
- package/dist/p5-runtime.js +398 -13
- package/dist/static-engine.d.ts +1 -1
- package/dist/static-engine.d.ts.map +1 -1
- package/dist/static-engine.js +3 -2
- package/dist/types.d.ts +6 -5
- 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.5.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.5.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,52 @@ 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
|
|
57
|
+
## What's New in v1.5.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
|
+
**Critical Fix — NPM Package Sync**
|
|
65
60
|
|
|
66
|
-
|
|
61
|
+
- **Restored seeded Mulberry32 PRNG** for `random()`, `randomSeed()`, `randomGaussian()`
|
|
62
|
+
- **Restored seeded Perlin noise** for `noise()`, `noiseSeed()`
|
|
63
|
+
- Full sync between SDK source and npm package
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
- VAR specification clarified with enforcement tables
|
|
65
|
+
The v1.4.0 npm package had an outdated runtime that used `Math.random()` directly. This release restores determinism.
|
|
70
66
|
|
|
71
|
-
## v1.
|
|
67
|
+
## v1.4.0 (Protocol v1.2.0)
|
|
68
|
+
|
|
69
|
+
**Phase 3 — Pixel & Graphics**
|
|
70
|
+
|
|
71
|
+
- **Vertex Functions**: `curveVertex(x, y)`, `bezierVertex(cx1, cy1, cx2, cy2, x, y)` for smooth curves
|
|
72
|
+
- **Pixel System**: `loadPixels()`, `updatePixels()`, `pixels[]`, `get(x, y)`, `set(x, y, color)`
|
|
73
|
+
- **Graphics System**: `createGraphics(w, h)`, `image(pg, x, y, w, h)` for offscreen rendering
|
|
74
|
+
- **totalFrames**: Now injected into Loop Mode runtime
|
|
75
|
+
|
|
76
|
+
## v1.3.0 (Protocol v1.1.0)
|
|
77
|
+
|
|
78
|
+
**Phase 2 — Expressive Extensions**
|
|
79
|
+
|
|
80
|
+
- **Math Helpers**: `fract(n)`, `sign(n)`
|
|
81
|
+
- **Vector Helpers**: `vec`, `vecAdd`, `vecSub`, `vecMult`, `vecMag`, `vecNorm`, `vecDist`
|
|
82
|
+
- **Shape Helpers**: `polygon()`, `star()`
|
|
83
|
+
- **Blend Modes**: `blendMode(NORMAL|ADD|MULTIPLY|SCREEN)`
|
|
84
|
+
- **Noise Extensions**: `fbm()`, `ridgedNoise()`, `curlNoise()`
|
|
85
|
+
- **Easing Functions**: `easeIn`, `easeOut`, `easeInOut`, `easeCubic`, `easeExpo`
|
|
86
|
+
|
|
87
|
+
## v1.2.0
|
|
88
|
+
|
|
89
|
+
- Added `bezier()`, `curve()`, `strokeCap()`, `strokeJoin()`, `shearX()`, `shearY()`
|
|
90
|
+
- Added text system: `text()`, `textSize()`, `textFont()`, `textAlign()`, `textWidth()`
|
|
91
|
+
- Added `sq()`, `int()`, `TAU`, arc mode constants
|
|
92
|
+
|
|
93
|
+
## v1.1.1
|
|
94
|
+
|
|
95
|
+
- **Critical Fix**: `random()` now uses seeded Mulberry32 PRNG (was using Math.random)
|
|
96
|
+
- All randomness is now deterministic
|
|
97
|
+
|
|
98
|
+
## v1.0.x (Protocol Lock)
|
|
72
99
|
|
|
73
100
|
- **Protocol Lock**: Phase 1 execution surface is now LOCKED
|
|
74
101
|
- **Canonical Entry Point**: `executeCodeMode()` is the official execution API
|
|
75
|
-
- **Protocol Metadata**: All executions include protocol headers for verification
|
|
76
102
|
- **VAR[0..9] Protocol Variables**: First-class protocol inputs (read-only, 0-100)
|
|
77
|
-
- **Full CSS Color Support**: hex, rgb(), rgba(), hsl(), hsla()
|
|
78
103
|
- **Determinism Guarantee**: Same code + seed + vars = identical output
|
|
79
104
|
|
|
80
105
|
---
|
|
@@ -88,7 +113,7 @@ This SDK provides the **canonical runtime** for executing p5.js-style generative
|
|
|
88
113
|
- **Deterministic**: Seed-controlled randomness, no external state
|
|
89
114
|
- **Protocol-Compliant**: All outputs include verification metadata
|
|
90
115
|
|
|
91
|
-
The SDK enforces the **NexArt Code Mode Protocol v1.
|
|
116
|
+
The SDK enforces the **NexArt Code Mode Protocol v1.2.0** for reproducible, mint-safe generative art.
|
|
92
117
|
|
|
93
118
|
---
|
|
94
119
|
|
|
@@ -104,8 +129,7 @@ The SDK enforces the **NexArt Code Mode Protocol v1.0.0** for reproducible, mint
|
|
|
104
129
|
## Installation
|
|
105
130
|
|
|
106
131
|
```bash
|
|
107
|
-
|
|
108
|
-
cp -r sdk/codemode your-project/lib/codemode
|
|
132
|
+
npm install @nexart/codemode-sdk
|
|
109
133
|
```
|
|
110
134
|
|
|
111
135
|
---
|
|
@@ -140,7 +164,7 @@ const result = await executeCodeMode({
|
|
|
140
164
|
// Result includes protocol metadata
|
|
141
165
|
console.log(result.metadata.protocol); // 'nexart'
|
|
142
166
|
console.log(result.metadata.engine); // 'codemode'
|
|
143
|
-
console.log(result.metadata.protocolVersion); // '1.
|
|
167
|
+
console.log(result.metadata.protocolVersion); // '1.2.0'
|
|
144
168
|
console.log(result.metadata.deterministic); // true
|
|
145
169
|
console.log(result.image); // PNG Blob
|
|
146
170
|
```
|
|
@@ -167,8 +191,8 @@ interface ExecuteCodeModeResult {
|
|
|
167
191
|
metadata: {
|
|
168
192
|
protocol: 'nexart';
|
|
169
193
|
engine: 'codemode';
|
|
170
|
-
protocolVersion: '1.
|
|
171
|
-
phase:
|
|
194
|
+
protocolVersion: '1.2.0';
|
|
195
|
+
phase: 3;
|
|
172
196
|
deterministic: true;
|
|
173
197
|
seed: number;
|
|
174
198
|
vars: number[];
|
|
@@ -182,67 +206,11 @@ interface ExecuteCodeModeResult {
|
|
|
182
206
|
|
|
183
207
|
---
|
|
184
208
|
|
|
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
|
|
209
|
+
## Protocol Variables (VAR[0..9]) — Protocol v1.0.0
|
|
242
210
|
|
|
243
211
|
Protocol variables are first-class inputs that control artwork parameters.
|
|
244
212
|
|
|
245
|
-
**VAR Specification
|
|
213
|
+
**VAR Specification:**
|
|
246
214
|
|
|
247
215
|
| Property | Value | Enforcement |
|
|
248
216
|
|----------|-------|-------------|
|
|
@@ -256,20 +224,7 @@ Protocol variables are first-class inputs that control artwork parameters.
|
|
|
256
224
|
| Default | All zeros | If not provided |
|
|
257
225
|
|
|
258
226
|
```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
|
|
227
|
+
// Access in sketch code (missing indices return 0)
|
|
273
228
|
function setup() {
|
|
274
229
|
let density = map(VAR[0], 0, 100, 10, 200);
|
|
275
230
|
let speed = map(VAR[1], 0, 100, 0.5, 5);
|
|
@@ -285,14 +240,6 @@ function setup() {
|
|
|
285
240
|
- Values MUST be in range 0-100 (throws if out of range)
|
|
286
241
|
- Same code + same seed + same VARs = identical output
|
|
287
242
|
|
|
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
243
|
---
|
|
297
244
|
|
|
298
245
|
## Execution Rules
|
|
@@ -320,6 +267,7 @@ Get the resolved engine configuration.
|
|
|
320
267
|
| `t` | float | Normalized time [0.0, 1.0) |
|
|
321
268
|
| `time` | float | Elapsed seconds |
|
|
322
269
|
| `tGlobal` | float | Alias for `t` |
|
|
270
|
+
| `totalFrames` | int | Total frames in loop (v1.4.0+) |
|
|
323
271
|
|
|
324
272
|
---
|
|
325
273
|
|
|
@@ -348,95 +296,40 @@ Additionally in Loop Mode:
|
|
|
348
296
|
|
|
349
297
|
---
|
|
350
298
|
|
|
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
299
|
## Supported Functions
|
|
422
300
|
|
|
423
|
-
The SDK includes a
|
|
301
|
+
The SDK includes a comprehensive p5.js-like runtime with 130+ functions:
|
|
424
302
|
|
|
425
303
|
**Drawing:**
|
|
426
|
-
`background`, `clear`, `fill`, `noFill`, `stroke`, `noStroke`, `strokeWeight`
|
|
304
|
+
`background`, `clear`, `fill`, `noFill`, `stroke`, `noStroke`, `strokeWeight`, `strokeCap`, `strokeJoin`
|
|
427
305
|
|
|
428
306
|
**Shapes:**
|
|
429
|
-
`ellipse`, `circle`, `rect`, `square`, `line`, `point`, `triangle`, `quad`, `arc`
|
|
307
|
+
`ellipse`, `circle`, `rect`, `square`, `line`, `point`, `triangle`, `quad`, `arc`, `bezier`, `curve`
|
|
430
308
|
|
|
431
|
-
**Vertex:**
|
|
432
|
-
`beginShape`, `vertex`, `endShape`
|
|
309
|
+
**Vertex (v1.4.0):**
|
|
310
|
+
`beginShape`, `vertex`, `curveVertex`, `bezierVertex`, `endShape`
|
|
311
|
+
|
|
312
|
+
**Shape Helpers (v1.3.0):**
|
|
313
|
+
`polygon`, `star`
|
|
433
314
|
|
|
434
315
|
**Transform:**
|
|
435
|
-
`push`, `pop`, `translate`, `rotate`, `scale`, `resetMatrix`
|
|
316
|
+
`push`, `pop`, `translate`, `rotate`, `scale`, `resetMatrix`, `shearX`, `shearY`
|
|
436
317
|
|
|
437
318
|
**Color:**
|
|
438
319
|
`colorMode`, `color`, `lerpColor`, `red`, `green`, `blue`, `alpha`, `hue`, `saturation`, `brightness`
|
|
439
320
|
|
|
321
|
+
**Text:**
|
|
322
|
+
`text`, `textSize`, `textFont`, `textAlign`, `textWidth`
|
|
323
|
+
|
|
324
|
+
**Blend Modes (v1.3.0):**
|
|
325
|
+
`blendMode(NORMAL|ADD|MULTIPLY|SCREEN)`
|
|
326
|
+
|
|
327
|
+
**Pixel System (v1.4.0):**
|
|
328
|
+
`loadPixels`, `updatePixels`, `pixels[]`, `get`, `set`
|
|
329
|
+
|
|
330
|
+
**Graphics (v1.4.0):**
|
|
331
|
+
`createGraphics`, `image`
|
|
332
|
+
|
|
440
333
|
**Color Formats:**
|
|
441
334
|
All of the following are accepted by `fill()`, `stroke()`, `background()`:
|
|
442
335
|
- Grayscale: `fill(128)`, `fill(128, 127)`
|
|
@@ -448,48 +341,40 @@ All of the following are accepted by `fill()`, `stroke()`, `background()`:
|
|
|
448
341
|
`VAR` — Array of 10 values (VAR[0] through VAR[9])
|
|
449
342
|
|
|
450
343
|
**Math:**
|
|
451
|
-
`random`, `noise`, `map`, `constrain`, `lerp`, `dist`, `mag`, `norm`
|
|
344
|
+
`random`, `noise`, `map`, `constrain`, `lerp`, `dist`, `mag`, `norm`, `sq`, `int`, `fract`, `sign`
|
|
452
345
|
|
|
453
|
-
**
|
|
454
|
-
`
|
|
346
|
+
**Vectors (v1.3.0):**
|
|
347
|
+
`vec`, `vecAdd`, `vecSub`, `vecMult`, `vecMag`, `vecNorm`, `vecDist`
|
|
455
348
|
|
|
456
|
-
**
|
|
457
|
-
`
|
|
458
|
-
|
|
459
|
-
---
|
|
349
|
+
**Noise Extensions (v1.3.0):**
|
|
350
|
+
`fbm`, `ridgedNoise`, `curlNoise`
|
|
460
351
|
|
|
461
|
-
|
|
352
|
+
**Easing (v1.3.0):**
|
|
353
|
+
`easeIn`, `easeOut`, `easeInOut`, `easeCubic`, `easeExpo`
|
|
462
354
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
```
|
|
466
|
-
POST /api/encode-loop
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
Ensure your server has this endpoint available (NexArt provides this).
|
|
470
|
-
|
|
471
|
-
---
|
|
472
|
-
|
|
473
|
-
## Files
|
|
355
|
+
**Trig:**
|
|
356
|
+
`sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `radians`, `degrees`
|
|
474
357
|
|
|
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
|
-
```
|
|
358
|
+
**Constants:**
|
|
359
|
+
`PI`, `TWO_PI`, `TAU`, `HALF_PI`, `QUARTER_PI`, `width`, `height`, `frameCount`, `totalFrames`
|
|
485
360
|
|
|
486
361
|
---
|
|
487
362
|
|
|
488
|
-
##
|
|
363
|
+
## Frozen Execution Guarantees — v1.0.0
|
|
489
364
|
|
|
490
|
-
|
|
365
|
+
The following guarantees are LOCKED and will not change in v1.x:
|
|
491
366
|
|
|
492
|
-
|
|
367
|
+
| Guarantee | Description |
|
|
368
|
+
|-----------|-------------|
|
|
369
|
+
| Determinism | Same code + same seed + same VARs = identical output |
|
|
370
|
+
| Static Mode | `setup()` only, single PNG output |
|
|
371
|
+
| Loop Mode | Frame-authoritative, `draw()` per frame, MP4 output |
|
|
372
|
+
| Time Semantics | `t` ∈ [0,1), `frameCount` ∈ [0,totalFrames), `time` in seconds |
|
|
373
|
+
| Random | Seeded Mulberry32 PRNG via `random()` |
|
|
374
|
+
| Noise | Seeded Perlin noise via `noise()` |
|
|
375
|
+
| Canvas | Pre-initialized, no `createCanvas()` |
|
|
376
|
+
| VAR | Exactly 10 read-only protocol variables |
|
|
377
|
+
| Forbidden Patterns | 13 patterns rejected (see above) |
|
|
493
378
|
|
|
494
379
|
---
|
|
495
380
|
|
|
@@ -512,13 +397,13 @@ const result = await executeCodeMode({
|
|
|
512
397
|
width: 1950,
|
|
513
398
|
height: 2400,
|
|
514
399
|
seed: 12345,
|
|
515
|
-
vars: [50, 75, 25, 0, 0, 0, 0, 0, 0, 0],
|
|
400
|
+
vars: [50, 75, 25, 0, 0, 0, 0, 0, 0, 0],
|
|
516
401
|
mode: 'static'
|
|
517
402
|
});
|
|
518
403
|
|
|
519
404
|
// Result includes full protocol metadata for verification
|
|
520
405
|
const { image, metadata } = result;
|
|
521
|
-
console.log(metadata.protocolVersion); // '1.
|
|
406
|
+
console.log(metadata.protocolVersion); // '1.2.0'
|
|
522
407
|
console.log(metadata.deterministic); // true
|
|
523
408
|
```
|
|
524
409
|
|
|
@@ -538,27 +423,35 @@ try {
|
|
|
538
423
|
|
|
539
424
|
---
|
|
540
425
|
|
|
541
|
-
##
|
|
426
|
+
## Video Encoding
|
|
542
427
|
|
|
543
|
-
|
|
428
|
+
Loop Mode requires server-side video encoding. The SDK calls:
|
|
544
429
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
430
|
+
```
|
|
431
|
+
POST /api/encode-loop
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
Ensure your server has this endpoint available (NexArt provides this).
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## Files
|
|
439
|
+
|
|
440
|
+
```
|
|
441
|
+
@nexart/codemode-sdk/
|
|
442
|
+
├── index.ts # Main export
|
|
443
|
+
├── engine.ts # createEngine entry point
|
|
444
|
+
├── types.ts # TypeScript types
|
|
445
|
+
├── static-engine.ts # Static mode implementation
|
|
446
|
+
├── loop-engine.ts # Loop mode implementation
|
|
447
|
+
├── p5-runtime.ts # p5.js-like runtime
|
|
448
|
+
└── README.md # This file
|
|
449
|
+
```
|
|
556
450
|
|
|
557
451
|
---
|
|
558
452
|
|
|
559
|
-
##
|
|
453
|
+
## License
|
|
454
|
+
|
|
455
|
+
MIT License
|
|
560
456
|
|
|
561
|
-
|
|
562
|
-
- Extended p5.js compatibility
|
|
563
|
-
- WebGL rendering support
|
|
564
|
-
- GIF output option
|
|
457
|
+
Copyright (c) 2024-2026 NexArt
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NexArt Code Mode Runtime SDK
|
|
3
|
-
* Version: 0.1.0
|
|
2
|
+
* NexArt Code Mode Runtime SDK - Canonical Execution Entry Point
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
4
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
5
|
+
* ║ CODE MODE PROTOCOL v1.2.0 (Phase 3) — CANONICAL ENTRY POINT ║
|
|
6
|
+
* ║ ║
|
|
7
|
+
* ║ This is the ONLY official way to execute Code Mode. ║
|
|
8
|
+
* ║ All implementations (NexArt, ByX, external) MUST use this function. ║
|
|
9
|
+
* ║ ║
|
|
10
|
+
* ║ Authority: @nexart/codemode-sdk ║
|
|
11
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
13
12
|
*/
|
|
14
|
-
import
|
|
13
|
+
import { ExecuteCodeModeInput, ExecuteCodeModeResult } from './types';
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
15
|
+
* executeCodeMode — Canonical Code Mode Execution Entry Point
|
|
16
|
+
*
|
|
17
|
+
* This is the ONLY official way to execute Code Mode.
|
|
18
|
+
* All implementations MUST use this function.
|
|
19
|
+
*
|
|
20
|
+
* @param input - Execution parameters
|
|
21
|
+
* @returns Promise<ExecuteCodeModeResult> - Execution result with protocol metadata
|
|
17
22
|
*
|
|
18
|
-
* @
|
|
19
|
-
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const result = await executeCodeMode({
|
|
26
|
+
* source: `function setup() { background(255); ellipse(width/2, height/2, 100); }`,
|
|
27
|
+
* width: 1950,
|
|
28
|
+
* height: 2400,
|
|
29
|
+
* seed: 12345,
|
|
30
|
+
* vars: [50, 75, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
31
|
+
* mode: 'static'
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* console.log(result.metadata.protocolVersion); // '1.2.0'
|
|
35
|
+
* console.log(result.image); // PNG Blob
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function executeCodeMode(input: ExecuteCodeModeInput): Promise<ExecuteCodeModeResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Validate code without executing
|
|
20
41
|
*/
|
|
21
|
-
export declare function
|
|
22
|
-
|
|
23
|
-
|
|
42
|
+
export declare function validateCodeModeSource(source: string, mode: 'static' | 'loop'): {
|
|
43
|
+
valid: boolean;
|
|
44
|
+
errors: string[];
|
|
45
|
+
};
|
|
24
46
|
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EAKtB,MAAM,SAAS,CAAC;AA4MjB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CAqBhC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAuCpH"}
|