@nexart/codemode-sdk 1.1.0 → 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 +81 -56
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +1 -1
- package/dist/index.d.ts +15 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -4
- package/dist/loop-engine.d.ts +1 -1
- package/dist/loop-engine.js +1 -1
- package/dist/p5-runtime.d.ts +1 -1
- package/dist/p5-runtime.js +1 -1
- 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 +75 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -1
- package/package.json +2 -2
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
|
|
|
@@ -139,7 +154,7 @@ const result = await executeCodeMode({
|
|
|
139
154
|
// Result includes protocol metadata
|
|
140
155
|
console.log(result.metadata.protocol); // 'nexart'
|
|
141
156
|
console.log(result.metadata.engine); // 'codemode'
|
|
142
|
-
console.log(result.metadata.protocolVersion); // '1.
|
|
157
|
+
console.log(result.metadata.protocolVersion); // '1.2.0'
|
|
143
158
|
console.log(result.metadata.deterministic); // true
|
|
144
159
|
console.log(result.image); // PNG Blob
|
|
145
160
|
```
|
|
@@ -152,7 +167,7 @@ console.log(result.image); // PNG Blob
|
|
|
152
167
|
| `width` | `number` | ✅ | Canvas width in pixels |
|
|
153
168
|
| `height` | `number` | ✅ | Canvas height in pixels |
|
|
154
169
|
| `seed` | `number` | ✅ | Seed for deterministic randomness |
|
|
155
|
-
| `vars` | `number[]` | ❌ | VAR values (0-
|
|
170
|
+
| `vars` | `number[]` | ❌ | VAR[0..9] values (0-100), defaults to all zeros |
|
|
156
171
|
| `mode` | `'static' \| 'loop'` | ✅ | Execution mode |
|
|
157
172
|
| `totalFrames` | `number` | ⚠️ | Required for loop mode |
|
|
158
173
|
|
|
@@ -166,8 +181,8 @@ interface ExecuteCodeModeResult {
|
|
|
166
181
|
metadata: {
|
|
167
182
|
protocol: 'nexart';
|
|
168
183
|
engine: 'codemode';
|
|
169
|
-
protocolVersion: '1.
|
|
170
|
-
phase:
|
|
184
|
+
protocolVersion: '1.2.0';
|
|
185
|
+
phase: 3;
|
|
171
186
|
deterministic: true;
|
|
172
187
|
seed: number;
|
|
173
188
|
vars: number[];
|
|
@@ -185,7 +200,7 @@ interface ExecuteCodeModeResult {
|
|
|
185
200
|
|
|
186
201
|
Protocol variables are first-class inputs that control artwork parameters.
|
|
187
202
|
|
|
188
|
-
**VAR Specification
|
|
203
|
+
**VAR Specification:**
|
|
189
204
|
|
|
190
205
|
| Property | Value | Enforcement |
|
|
191
206
|
|----------|-------|-------------|
|
|
@@ -242,6 +257,7 @@ function setup() {
|
|
|
242
257
|
| `t` | float | Normalized time [0.0, 1.0) |
|
|
243
258
|
| `time` | float | Elapsed seconds |
|
|
244
259
|
| `tGlobal` | float | Alias for `t` |
|
|
260
|
+
| `totalFrames` | int | Total frames in loop (v1.4.0+) |
|
|
245
261
|
|
|
246
262
|
---
|
|
247
263
|
|
|
@@ -272,23 +288,38 @@ Additionally in Loop Mode:
|
|
|
272
288
|
|
|
273
289
|
## Supported Functions
|
|
274
290
|
|
|
275
|
-
The SDK includes a
|
|
291
|
+
The SDK includes a comprehensive p5.js-like runtime with 130+ functions:
|
|
276
292
|
|
|
277
293
|
**Drawing:**
|
|
278
|
-
`background`, `clear`, `fill`, `noFill`, `stroke`, `noStroke`, `strokeWeight`
|
|
294
|
+
`background`, `clear`, `fill`, `noFill`, `stroke`, `noStroke`, `strokeWeight`, `strokeCap`, `strokeJoin`
|
|
279
295
|
|
|
280
296
|
**Shapes:**
|
|
281
|
-
`ellipse`, `circle`, `rect`, `square`, `line`, `point`, `triangle`, `quad`, `arc`
|
|
297
|
+
`ellipse`, `circle`, `rect`, `square`, `line`, `point`, `triangle`, `quad`, `arc`, `bezier`, `curve`
|
|
282
298
|
|
|
283
|
-
**Vertex:**
|
|
284
|
-
`beginShape`, `vertex`, `endShape`
|
|
299
|
+
**Vertex (v1.4.0):**
|
|
300
|
+
`beginShape`, `vertex`, `curveVertex`, `bezierVertex`, `endShape`
|
|
301
|
+
|
|
302
|
+
**Shape Helpers (v1.3.0):**
|
|
303
|
+
`polygon`, `star`
|
|
285
304
|
|
|
286
305
|
**Transform:**
|
|
287
|
-
`push`, `pop`, `translate`, `rotate`, `scale`, `resetMatrix`
|
|
306
|
+
`push`, `pop`, `translate`, `rotate`, `scale`, `resetMatrix`, `shearX`, `shearY`
|
|
288
307
|
|
|
289
308
|
**Color:**
|
|
290
309
|
`colorMode`, `color`, `lerpColor`, `red`, `green`, `blue`, `alpha`, `hue`, `saturation`, `brightness`
|
|
291
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
|
+
|
|
292
323
|
**Color Formats:**
|
|
293
324
|
All of the following are accepted by `fill()`, `stroke()`, `background()`:
|
|
294
325
|
- Grayscale: `fill(128)`, `fill(128, 127)`
|
|
@@ -300,13 +331,22 @@ All of the following are accepted by `fill()`, `stroke()`, `background()`:
|
|
|
300
331
|
`VAR` — Array of 10 values (VAR[0] through VAR[9])
|
|
301
332
|
|
|
302
333
|
**Math:**
|
|
303
|
-
`random`, `noise`, `map`, `constrain`, `lerp`, `dist`, `mag`, `norm`
|
|
334
|
+
`random`, `noise`, `map`, `constrain`, `lerp`, `dist`, `mag`, `norm`, `sq`, `int`, `fract`, `sign`
|
|
335
|
+
|
|
336
|
+
**Vectors (v1.3.0):**
|
|
337
|
+
`vec`, `vecAdd`, `vecSub`, `vecMult`, `vecMag`, `vecNorm`, `vecDist`
|
|
338
|
+
|
|
339
|
+
**Noise Extensions (v1.3.0):**
|
|
340
|
+
`fbm`, `ridgedNoise`, `curlNoise`
|
|
341
|
+
|
|
342
|
+
**Easing (v1.3.0):**
|
|
343
|
+
`easeIn`, `easeOut`, `easeInOut`, `easeCubic`, `easeExpo`
|
|
304
344
|
|
|
305
345
|
**Trig:**
|
|
306
346
|
`sin`, `cos`, `tan`, `asin`, `acos`, `atan`, `atan2`, `radians`, `degrees`
|
|
307
347
|
|
|
308
348
|
**Constants:**
|
|
309
|
-
`PI`, `TWO_PI`, `HALF_PI`, `QUARTER_PI`, `width`, `height`, `frameCount`
|
|
349
|
+
`PI`, `TWO_PI`, `TAU`, `HALF_PI`, `QUARTER_PI`, `width`, `height`, `frameCount`, `totalFrames`
|
|
310
350
|
|
|
311
351
|
---
|
|
312
352
|
|
|
@@ -347,13 +387,13 @@ const result = await executeCodeMode({
|
|
|
347
387
|
width: 1950,
|
|
348
388
|
height: 2400,
|
|
349
389
|
seed: 12345,
|
|
350
|
-
vars: [50, 75, 25, 0, 0, 0, 0, 0, 0, 0],
|
|
390
|
+
vars: [50, 75, 25, 0, 0, 0, 0, 0, 0, 0],
|
|
351
391
|
mode: 'static'
|
|
352
392
|
});
|
|
353
393
|
|
|
354
394
|
// Result includes full protocol metadata for verification
|
|
355
395
|
const { image, metadata } = result;
|
|
356
|
-
console.log(metadata.protocolVersion); // '1.
|
|
396
|
+
console.log(metadata.protocolVersion); // '1.2.0'
|
|
357
397
|
console.log(metadata.deterministic); // true
|
|
358
398
|
```
|
|
359
399
|
|
|
@@ -391,7 +431,6 @@ Ensure your server has this endpoint available (NexArt provides this).
|
|
|
391
431
|
@nexart/codemode-sdk/
|
|
392
432
|
├── index.ts # Main export
|
|
393
433
|
├── engine.ts # createEngine entry point
|
|
394
|
-
├── execute.ts # Canonical executeCodeMode API
|
|
395
434
|
├── types.ts # TypeScript types
|
|
396
435
|
├── static-engine.ts # Static mode implementation
|
|
397
436
|
├── loop-engine.ts # Loop mode implementation
|
|
@@ -401,22 +440,8 @@ Ensure your server has this endpoint available (NexArt provides this).
|
|
|
401
440
|
|
|
402
441
|
---
|
|
403
442
|
|
|
404
|
-
## Changelog
|
|
405
|
-
|
|
406
|
-
**1.0.2** — VAR is now optional (0-10 elements). Missing indices return 0. Out-of-range throws.
|
|
407
|
-
|
|
408
|
-
**1.0.1** — Protocol Lock formalized. VAR specification clarified. CHANGELOG added.
|
|
409
|
-
|
|
410
|
-
**1.0.0** — Protocol Lock. Phase 1 execution surface HARD LOCKED. executeCodeMode() canonical API.
|
|
411
|
-
|
|
412
|
-
**0.1.1** — Fixed beginShape / vertex / endShape rendering bug.
|
|
413
|
-
|
|
414
|
-
**0.1.0** — Initial release.
|
|
415
|
-
|
|
416
|
-
---
|
|
417
|
-
|
|
418
443
|
## License
|
|
419
444
|
|
|
420
445
|
MIT License
|
|
421
446
|
|
|
422
|
-
Copyright (c) 2024 NexArt
|
|
447
|
+
Copyright (c) 2024-2026 NexArt
|
package/dist/engine.d.ts
CHANGED
package/dist/engine.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NexArt Code Mode Runtime SDK
|
|
3
|
-
* Version: 0.
|
|
3
|
+
* Version: 1.4.0 (Protocol v1.2.0)
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
6
|
+
* ║ @nexart/codemode-sdk — Canonical Code Mode Authority ║
|
|
7
|
+
* ║ ║
|
|
8
|
+
* ║ This SDK defines the official Code Mode execution surface. ║
|
|
9
|
+
* ║ All implementations (NexArt, ByX, external) MUST use this SDK. ║
|
|
10
|
+
* ║ ║
|
|
11
|
+
* ║ Protocol: nexart ║
|
|
12
|
+
* ║ Engine: codemode ║
|
|
13
|
+
* ║ SDK Version: 1.4.0 ║
|
|
14
|
+
* ║ Protocol Version: 1.2.0 ║
|
|
15
|
+
* ║ Phase: 3 ║
|
|
16
|
+
* ║ Enforcement: HARD ║
|
|
17
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
7
18
|
*
|
|
8
19
|
* @example
|
|
9
20
|
* ```typescript
|
|
@@ -27,5 +38,5 @@
|
|
|
27
38
|
*/
|
|
28
39
|
export { createEngine } from './engine';
|
|
29
40
|
export type { Engine, EngineConfig, RunOptions, RenderResult, ProgressInfo, RenderMode, TimeVariables, } from './types';
|
|
30
|
-
export { DEFAULT_CONFIG } from './types';
|
|
41
|
+
export { DEFAULT_CONFIG, PROTOCOL_IDENTITY } from './types';
|
|
31
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"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NexArt Code Mode Runtime SDK
|
|
3
|
-
* Version: 0.
|
|
3
|
+
* Version: 1.4.0 (Protocol v1.2.0)
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
6
|
+
* ║ @nexart/codemode-sdk — Canonical Code Mode Authority ║
|
|
7
|
+
* ║ ║
|
|
8
|
+
* ║ This SDK defines the official Code Mode execution surface. ║
|
|
9
|
+
* ║ All implementations (NexArt, ByX, external) MUST use this SDK. ║
|
|
10
|
+
* ║ ║
|
|
11
|
+
* ║ Protocol: nexart ║
|
|
12
|
+
* ║ Engine: codemode ║
|
|
13
|
+
* ║ SDK Version: 1.4.0 ║
|
|
14
|
+
* ║ Protocol Version: 1.2.0 ║
|
|
15
|
+
* ║ Phase: 3 ║
|
|
16
|
+
* ║ Enforcement: HARD ║
|
|
17
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
7
18
|
*
|
|
8
19
|
* @example
|
|
9
20
|
* ```typescript
|
|
@@ -26,4 +37,4 @@
|
|
|
26
37
|
* ```
|
|
27
38
|
*/
|
|
28
39
|
export { createEngine } from './engine';
|
|
29
|
-
export { DEFAULT_CONFIG } from './types';
|
|
40
|
+
export { DEFAULT_CONFIG, PROTOCOL_IDENTITY } from './types';
|
package/dist/loop-engine.d.ts
CHANGED
package/dist/loop-engine.js
CHANGED
package/dist/p5-runtime.d.ts
CHANGED
package/dist/p5-runtime.js
CHANGED
package/dist/static-engine.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static-engine.d.ts","sourceRoot":"","sources":["../static-engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAgB,MAAM,SAAS,CAAC;AAItE,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"static-engine.d.ts","sourceRoot":"","sources":["../static-engine.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAgB,MAAM,SAAS,CAAC;AAItE,wBAAsB,aAAa,CACjC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAgGf"}
|
package/dist/static-engine.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NexArt Code Mode Runtime SDK - Static Engine
|
|
3
|
-
* Version: 0.
|
|
3
|
+
* Version: 1.4.0 (Protocol v1.2.0)
|
|
4
4
|
*
|
|
5
5
|
* Static mode renderer: executes setup() only, captures single PNG.
|
|
6
6
|
* Does NOT execute draw() - per NexArt Execution Specification v1.
|
|
@@ -23,12 +23,13 @@ export async function runStaticMode(config, options) {
|
|
|
23
23
|
canvas.height = height;
|
|
24
24
|
// Create p5 runtime
|
|
25
25
|
const p = createP5Runtime(canvas, width, height);
|
|
26
|
-
// Inject time variables (static = frame 0, t = 0)
|
|
26
|
+
// Inject time variables (static = frame 0, t = 0, totalFrames = 1)
|
|
27
27
|
injectTimeVariables(p, {
|
|
28
28
|
frameCount: 0,
|
|
29
29
|
t: 0,
|
|
30
30
|
time: 0,
|
|
31
31
|
tGlobal: 0,
|
|
32
|
+
totalFrames: 1, // Static mode has 1 frame
|
|
32
33
|
});
|
|
33
34
|
onProgress?.({
|
|
34
35
|
phase: 'setup',
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NexArt Code Mode Runtime SDK - Types
|
|
3
|
-
* Version: 0.
|
|
3
|
+
* Version: 1.4.0 (Protocol v1.2.0)
|
|
4
4
|
*
|
|
5
5
|
* Type definitions for the Code Mode runtime engine.
|
|
6
|
+
* This is the canonical type surface for @nexart/codemode-sdk.
|
|
6
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Protocol Constants
|
|
10
|
+
* These define the locked protocol identity.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PROTOCOL_IDENTITY: {
|
|
13
|
+
readonly protocol: "nexart";
|
|
14
|
+
readonly engine: "codemode";
|
|
15
|
+
readonly protocolVersion: "1.2.0";
|
|
16
|
+
readonly phase: 3;
|
|
17
|
+
readonly deterministic: true;
|
|
18
|
+
};
|
|
7
19
|
export type RenderMode = 'static' | 'loop';
|
|
8
20
|
export interface EngineConfig {
|
|
9
21
|
mode: RenderMode;
|
|
@@ -20,6 +32,8 @@ export interface RenderResult {
|
|
|
20
32
|
}
|
|
21
33
|
export interface RunOptions {
|
|
22
34
|
code: string;
|
|
35
|
+
seed?: number;
|
|
36
|
+
vars?: number[];
|
|
23
37
|
onPreview?: (canvas: HTMLCanvasElement) => void;
|
|
24
38
|
onProgress?: (progress: ProgressInfo) => void;
|
|
25
39
|
onComplete: (result: RenderResult) => void;
|
|
@@ -42,7 +56,27 @@ export interface TimeVariables {
|
|
|
42
56
|
t: number;
|
|
43
57
|
time: number;
|
|
44
58
|
tGlobal: number;
|
|
59
|
+
totalFrames: number;
|
|
45
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Protocol Variables (VAR[0..9])
|
|
63
|
+
* First-class protocol inputs for deterministic rendering.
|
|
64
|
+
*
|
|
65
|
+
* Rules (SDK v1.4.0, Protocol v1.2.0):
|
|
66
|
+
* - Input array can have 0-10 elements (protocol error if > 10)
|
|
67
|
+
* - All values MUST be finite numbers (protocol error if not)
|
|
68
|
+
* - Values MUST be in range 0-100 (protocol error if out of range, NO clamping)
|
|
69
|
+
* - Runtime VAR is ALWAYS 10 elements (padded with zeros for consistency)
|
|
70
|
+
* - Read-only inside sketches (write attempts throw protocol error)
|
|
71
|
+
* - Default: all zeros if not provided
|
|
72
|
+
*/
|
|
73
|
+
export interface ProtocolVariables {
|
|
74
|
+
VAR: readonly [number, number, number, number, number, number, number, number, number, number];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Default protocol variables (all zeros)
|
|
78
|
+
*/
|
|
79
|
+
export declare const DEFAULT_VARS: ProtocolVariables;
|
|
46
80
|
export declare const DEFAULT_CONFIG: {
|
|
47
81
|
readonly width: 1950;
|
|
48
82
|
readonly height: 2400;
|
|
@@ -51,4 +85,44 @@ export declare const DEFAULT_CONFIG: {
|
|
|
51
85
|
readonly minDuration: 1;
|
|
52
86
|
readonly maxDuration: 4;
|
|
53
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Protocol Metadata
|
|
90
|
+
* Attached to every execution result for verification.
|
|
91
|
+
*/
|
|
92
|
+
export interface ProtocolMetadata {
|
|
93
|
+
protocol: 'nexart';
|
|
94
|
+
engine: 'codemode';
|
|
95
|
+
protocolVersion: '1.2.0';
|
|
96
|
+
phase: 3;
|
|
97
|
+
deterministic: true;
|
|
98
|
+
seed: number;
|
|
99
|
+
vars: number[];
|
|
100
|
+
width: number;
|
|
101
|
+
height: number;
|
|
102
|
+
mode: RenderMode;
|
|
103
|
+
totalFrames?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Canonical Execution Input
|
|
107
|
+
* The single entry point for all Code Mode execution.
|
|
108
|
+
*/
|
|
109
|
+
export interface ExecuteCodeModeInput {
|
|
110
|
+
source: string;
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
seed: number;
|
|
114
|
+
vars?: number[];
|
|
115
|
+
mode: RenderMode;
|
|
116
|
+
totalFrames?: number;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Canonical Execution Result
|
|
120
|
+
* Every execution produces this structure.
|
|
121
|
+
*/
|
|
122
|
+
export interface ExecuteCodeModeResult {
|
|
123
|
+
image?: Blob;
|
|
124
|
+
video?: Blob;
|
|
125
|
+
frames?: ImageData[];
|
|
126
|
+
metadata: ProtocolMetadata;
|
|
127
|
+
}
|
|
54
128
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types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,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,QAAQ,EAAE,gBAAgB,CAAC;CAC5B"}
|
package/dist/types.js
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NexArt Code Mode Runtime SDK - Types
|
|
3
|
-
* Version: 0.
|
|
3
|
+
* Version: 1.4.0 (Protocol v1.2.0)
|
|
4
4
|
*
|
|
5
5
|
* Type definitions for the Code Mode runtime engine.
|
|
6
|
+
* This is the canonical type surface for @nexart/codemode-sdk.
|
|
6
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* Protocol Constants
|
|
10
|
+
* These define the locked protocol identity.
|
|
11
|
+
*/
|
|
12
|
+
export const PROTOCOL_IDENTITY = {
|
|
13
|
+
protocol: 'nexart',
|
|
14
|
+
engine: 'codemode',
|
|
15
|
+
protocolVersion: '1.2.0',
|
|
16
|
+
phase: 3,
|
|
17
|
+
deterministic: true,
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Default protocol variables (all zeros)
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_VARS = {
|
|
23
|
+
VAR: Object.freeze([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
|
|
24
|
+
};
|
|
7
25
|
export const DEFAULT_CONFIG = {
|
|
8
26
|
width: 1950,
|
|
9
27
|
height: 2400,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexart/codemode-sdk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "NexArt Code Mode Runtime SDK - Deterministic generative art rendering engine",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "NexArt Code Mode Runtime SDK - Deterministic generative art rendering engine (Protocol v1.2.0)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|