@nexart/codemode-sdk 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/CODE_MODE_PROTOCOL.md +312 -0
- package/README.md +200 -58
- package/dist/core-index.d.ts +21 -0
- package/dist/core-index.d.ts.map +1 -0
- package/dist/core-index.js +26 -0
- package/dist/execute.d.ts +46 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +268 -0
- package/dist/index.d.ts +36 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -17
- package/dist/loop-engine.d.ts +4 -1
- package/dist/loop-engine.d.ts.map +1 -1
- package/dist/loop-engine.js +17 -12
- package/dist/noise-bridge.d.ts +44 -0
- package/dist/noise-bridge.d.ts.map +1 -0
- package/dist/noise-bridge.js +68 -0
- package/dist/noise-engine.d.ts +74 -0
- package/dist/noise-engine.d.ts.map +1 -0
- package/dist/noise-engine.js +132 -0
- package/dist/noise-sketches/fractalNoise.d.ts +11 -0
- package/dist/noise-sketches/fractalNoise.d.ts.map +1 -0
- package/dist/noise-sketches/fractalNoise.js +121 -0
- package/dist/noise-sketches/index.d.ts +21 -0
- package/dist/noise-sketches/index.d.ts.map +1 -0
- package/dist/noise-sketches/index.js +28 -0
- package/dist/p5-runtime.d.ts +56 -4
- package/dist/p5-runtime.d.ts.map +1 -1
- package/dist/p5-runtime.js +348 -22
- package/dist/sound-bridge.d.ts +89 -0
- package/dist/sound-bridge.d.ts.map +1 -0
- package/dist/sound-bridge.js +128 -0
- package/dist/soundart-engine.d.ts +87 -0
- package/dist/soundart-engine.d.ts.map +1 -0
- package/dist/soundart-engine.js +173 -0
- package/dist/soundart-sketches/chladniBloom.d.ts +3 -0
- package/dist/soundart-sketches/chladniBloom.d.ts.map +1 -0
- package/dist/soundart-sketches/chladniBloom.js +53 -0
- package/dist/soundart-sketches/dualVortex.d.ts +3 -0
- package/dist/soundart-sketches/dualVortex.d.ts.map +1 -0
- package/dist/soundart-sketches/dualVortex.js +67 -0
- package/dist/soundart-sketches/geometryIllusion.d.ts +3 -0
- package/dist/soundart-sketches/geometryIllusion.d.ts.map +1 -0
- package/dist/soundart-sketches/geometryIllusion.js +89 -0
- package/dist/soundart-sketches/index.d.ts +39 -0
- package/dist/soundart-sketches/index.d.ts.map +1 -0
- package/dist/soundart-sketches/index.js +72 -0
- package/dist/soundart-sketches/isoflow.d.ts +3 -0
- package/dist/soundart-sketches/isoflow.d.ts.map +1 -0
- package/dist/soundart-sketches/isoflow.js +60 -0
- package/dist/soundart-sketches/loomWeave.d.ts +3 -0
- package/dist/soundart-sketches/loomWeave.d.ts.map +1 -0
- package/dist/soundart-sketches/loomWeave.js +59 -0
- package/dist/soundart-sketches/noiseTerraces.d.ts +3 -0
- package/dist/soundart-sketches/noiseTerraces.d.ts.map +1 -0
- package/dist/soundart-sketches/noiseTerraces.js +53 -0
- package/dist/soundart-sketches/orb.d.ts +3 -0
- package/dist/soundart-sketches/orb.d.ts.map +1 -0
- package/dist/soundart-sketches/orb.js +50 -0
- package/dist/soundart-sketches/pixelGlyphs.d.ts +3 -0
- package/dist/soundart-sketches/pixelGlyphs.d.ts.map +1 -0
- package/dist/soundart-sketches/pixelGlyphs.js +72 -0
- package/dist/soundart-sketches/prismFlowFields.d.ts +3 -0
- package/dist/soundart-sketches/prismFlowFields.d.ts.map +1 -0
- package/dist/soundart-sketches/prismFlowFields.js +51 -0
- package/dist/soundart-sketches/radialBurst.d.ts +3 -0
- package/dist/soundart-sketches/radialBurst.d.ts.map +1 -0
- package/dist/soundart-sketches/radialBurst.js +60 -0
- package/dist/soundart-sketches/resonantSoundBodies.d.ts +3 -0
- package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +1 -0
- package/dist/soundart-sketches/resonantSoundBodies.js +89 -0
- package/dist/soundart-sketches/rings.d.ts +11 -0
- package/dist/soundart-sketches/rings.d.ts.map +1 -0
- package/dist/soundart-sketches/rings.js +89 -0
- package/dist/soundart-sketches/squares.d.ts +3 -0
- package/dist/soundart-sketches/squares.d.ts.map +1 -0
- package/dist/soundart-sketches/squares.js +52 -0
- package/dist/soundart-sketches/waveStripes.d.ts +3 -0
- package/dist/soundart-sketches/waveStripes.d.ts.map +1 -0
- package/dist/soundart-sketches/waveStripes.js +44 -0
- package/dist/static-engine.d.ts +4 -1
- package/dist/static-engine.d.ts.map +1 -1
- package/dist/static-engine.js +13 -8
- package/dist/types.d.ts +75 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -1
- package/package.json +23 -17
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to @nexart/codemode-sdk will be documented in this file.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## [1.1.1] — 2024-12-31
|
|
8
|
+
|
|
9
|
+
### Critical Bug Fix: Seeded Random
|
|
10
|
+
|
|
11
|
+
**BREAKING FIX**: The published npm package (v1.1.0 and earlier) had a critical bug where `random()` used `Math.random()` instead of the seeded Mulberry32 PRNG. This broke determinism guarantees.
|
|
12
|
+
|
|
13
|
+
#### Fixed
|
|
14
|
+
- `random()` now correctly uses seeded Mulberry32 PRNG
|
|
15
|
+
- `randomSeed(seed)` now properly recreates the RNG with new seed
|
|
16
|
+
- `randomGaussian()` now uses seeded Box-Muller transform
|
|
17
|
+
- `noise()` now uses proper seeded Perlin noise with octaves
|
|
18
|
+
- `noiseSeed(seed)` now properly recreates the noise generator
|
|
19
|
+
- `lerpColor()` now properly interpolates colors (was returning c1)
|
|
20
|
+
|
|
21
|
+
#### Changed
|
|
22
|
+
- Rebuilt package with proper TypeScript compilation
|
|
23
|
+
- Added standalone package.json and tsconfig.json for clean builds
|
|
24
|
+
- New entry point: `core-index.ts` (excludes external dependencies)
|
|
25
|
+
|
|
26
|
+
#### Verification
|
|
27
|
+
```javascript
|
|
28
|
+
// Same seed = same output (determinism restored)
|
|
29
|
+
randomSeed(42);
|
|
30
|
+
console.log(random()); // Always 0.8379...
|
|
31
|
+
console.log(random()); // Always 0.9032...
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## [1.1.0] — 2024-12-30
|
|
37
|
+
|
|
38
|
+
### Minor Bump for npm Publishing (DEPRECATED)
|
|
39
|
+
|
|
40
|
+
**WARNING**: This version had a critical bug. Use v1.1.1 or later.
|
|
41
|
+
|
|
42
|
+
- Updated SDK version from 1.0.2 to 1.1.0
|
|
43
|
+
- Protocol version remains v1.0.0 (unchanged)
|
|
44
|
+
- No breaking changes from 1.0.2
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## [1.0.2] — 2024-12-30
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- **VAR input is now optional (0-10 elements)**
|
|
53
|
+
- Omit `vars` or pass `[]` for empty (defaults to all zeros)
|
|
54
|
+
- Input length must be 0-10 (throws if > 10)
|
|
55
|
+
- Values must be finite numbers in [0, 100] (throws if out of range, NO clamping)
|
|
56
|
+
- Runtime VAR is ALWAYS 10 elements (padded with zeros for consistency)
|
|
57
|
+
- **VAR enforcement updated**
|
|
58
|
+
- Read-only via Proxy (throws on write attempts)
|
|
59
|
+
- Out-of-range values now throw (previously warned)
|
|
60
|
+
- **Backwards compatible**: existing code passing 10 elements works unchanged
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## [1.0.1] — 2024-12-29
|
|
65
|
+
|
|
66
|
+
### Documentation
|
|
67
|
+
|
|
68
|
+
- Protocol Lock section formalized with HARD LOCKED status
|
|
69
|
+
- VAR specification clarified with enforcement tables
|
|
70
|
+
- CHANGELOG added to track version history
|
|
71
|
+
- Smoke tests added for cross-SDK verification
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## [1.0.0] — 2024-12-29
|
|
76
|
+
|
|
77
|
+
### Protocol Lock
|
|
78
|
+
|
|
79
|
+
**NexArt Code Mode Protocol v1.0.0 is now HARD LOCKED.**
|
|
80
|
+
|
|
81
|
+
This version establishes the canonical Code Mode execution surface for:
|
|
82
|
+
- NexArt app
|
|
83
|
+
- ByX curated collections
|
|
84
|
+
- External builders and AI platforms
|
|
85
|
+
|
|
86
|
+
### Frozen
|
|
87
|
+
|
|
88
|
+
The following are locked and will not change in v1.x:
|
|
89
|
+
|
|
90
|
+
- **Execution Model**: Static (setup-only) and Loop (frame-authoritative) modes
|
|
91
|
+
- **VAR[0..9]**: Exactly 10 read-only protocol variables (0-100 recommended)
|
|
92
|
+
- **Determinism**: Same code + same seed + same VARs = identical output
|
|
93
|
+
- **Time Semantics**: t ∈ [0,1), frameCount, time, tGlobal
|
|
94
|
+
- **Random**: Seeded Mulberry32 PRNG via random()
|
|
95
|
+
- **Noise**: Seeded Perlin noise via noise()
|
|
96
|
+
- **Forbidden Patterns**: 13 patterns rejected with [Code Mode Protocol Error]
|
|
97
|
+
- **Canvas**: Pre-initialized, no createCanvas()
|
|
98
|
+
|
|
99
|
+
### API
|
|
100
|
+
|
|
101
|
+
- `executeCodeMode()` — Canonical entry point for all Code Mode execution
|
|
102
|
+
- `validateCodeModeSource()` — Pre-flight validation without execution
|
|
103
|
+
- `createEngine()` — Legacy API (still supported)
|
|
104
|
+
|
|
105
|
+
### Notes
|
|
106
|
+
|
|
107
|
+
- Any breaking change requires v2.0.0
|
|
108
|
+
- VAR count is fixed at 10 and will not be extended
|
|
109
|
+
- This version enables external builders to depend on stable protocol semantics
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# Code Mode Protocol v1.0.0 — Phase 1
|
|
2
|
+
|
|
3
|
+
> **Status:** LOCKED
|
|
4
|
+
> **Enforcement:** HARD
|
|
5
|
+
> **Effective Date:** December 2024
|
|
6
|
+
|
|
7
|
+
This document is **normative**. It defines the official Code Mode execution surface for NexArt Protocol. All implementations (NexArt app, ByX, external builders) MUST conform to this specification.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Protocol Identity
|
|
12
|
+
|
|
13
|
+
| Property | Value |
|
|
14
|
+
|----------|-------|
|
|
15
|
+
| Protocol | `nexart` |
|
|
16
|
+
| Engine | `codemode` |
|
|
17
|
+
| Version | `1.0.0` |
|
|
18
|
+
| Phase | `1` |
|
|
19
|
+
| Deterministic | `true` |
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 2. Execution Modes
|
|
24
|
+
|
|
25
|
+
### 2.1 Static Mode
|
|
26
|
+
- Executes `setup()` once
|
|
27
|
+
- `draw()` is **NOT** executed
|
|
28
|
+
- Output: Single PNG image
|
|
29
|
+
- Time variables: All `0`
|
|
30
|
+
|
|
31
|
+
### 2.2 Loop Mode
|
|
32
|
+
- Executes `setup()` once
|
|
33
|
+
- Executes `draw()` for each frame
|
|
34
|
+
- Canvas is cleared before each `draw()` call
|
|
35
|
+
- Output: MP4 video (1-4 seconds, 30 FPS)
|
|
36
|
+
- Requires `totalFrames` to be specified
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## 3. Protocol Variables (VAR[0..9])
|
|
41
|
+
|
|
42
|
+
### 3.1 Definition
|
|
43
|
+
- Input: 0-10 elements allowed (protocol error if > 10)
|
|
44
|
+
- Runtime: ALWAYS 10 elements (padded with zeros)
|
|
45
|
+
- Type: `readonly number[]`
|
|
46
|
+
- Range: `0` to `100` (strict — protocol error if out of range)
|
|
47
|
+
- Default: All zeros `[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]`
|
|
48
|
+
|
|
49
|
+
### 3.2 Access
|
|
50
|
+
```javascript
|
|
51
|
+
// ✅ Allowed - reading (missing indices return 0)
|
|
52
|
+
let size = VAR[0]; // Returns provided value or 0
|
|
53
|
+
let opacity = map(VAR[1], 0, 100, 0, 255);
|
|
54
|
+
|
|
55
|
+
// ❌ Forbidden - writing (throws protocol error)
|
|
56
|
+
VAR[0] = 50; // [Code Mode Protocol Error] VAR is read-only
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 3.3 Enforcement
|
|
60
|
+
| Condition | Enforcement |
|
|
61
|
+
|-----------|-------------|
|
|
62
|
+
| Input length > 10 | HARD — throws protocol error |
|
|
63
|
+
| Value outside 0-100 | HARD — throws protocol error |
|
|
64
|
+
| Non-number value | HARD — throws protocol error |
|
|
65
|
+
| Write attempt | HARD — throws protocol error |
|
|
66
|
+
| Missing input | Runtime padded with zeros |
|
|
67
|
+
|
|
68
|
+
- Input is normalized to 10 elements (padded with zeros)
|
|
69
|
+
- VAR is wrapped in a write-blocking Proxy
|
|
70
|
+
- Write attempts MUST throw an error
|
|
71
|
+
- Write attempts MUST NOT modify values
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 4. Supported Globals
|
|
76
|
+
|
|
77
|
+
### 4.1 Canvas Environment
|
|
78
|
+
| Global | Type | Description |
|
|
79
|
+
|--------|------|-------------|
|
|
80
|
+
| `width` | `number` | Canvas width (default: 1950) |
|
|
81
|
+
| `height` | `number` | Canvas height (default: 2400) |
|
|
82
|
+
|
|
83
|
+
### 4.2 Time Variables
|
|
84
|
+
| Global | Type | Description |
|
|
85
|
+
|--------|------|-------------|
|
|
86
|
+
| `frameCount` | `number` | Current frame (0, 1, 2, ...) |
|
|
87
|
+
| `t` | `number` | Normalized time [0.0, 1.0) |
|
|
88
|
+
| `time` | `number` | Elapsed seconds |
|
|
89
|
+
| `tGlobal` | `number` | Alias for `t` |
|
|
90
|
+
|
|
91
|
+
### 4.3 Math Constants
|
|
92
|
+
| Global | Value |
|
|
93
|
+
|--------|-------|
|
|
94
|
+
| `PI` | `3.141592653589793` |
|
|
95
|
+
| `TWO_PI` | `6.283185307179586` |
|
|
96
|
+
| `HALF_PI` | `1.5707963267948966` |
|
|
97
|
+
| `QUARTER_PI` | `0.7853981633974483` |
|
|
98
|
+
| `TAU` | `6.283185307179586` |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 5. Supported Functions (Phase 1)
|
|
103
|
+
|
|
104
|
+
### 5.1 Drawing Primitives
|
|
105
|
+
- `line(x1, y1, x2, y2)`
|
|
106
|
+
- `rect(x, y, w, h, [r])`
|
|
107
|
+
- `ellipse(x, y, w, h)`
|
|
108
|
+
- `circle(x, y, d)`
|
|
109
|
+
- `triangle(x1, y1, x2, y2, x3, y3)`
|
|
110
|
+
- `quad(x1, y1, x2, y2, x3, y3, x4, y4)`
|
|
111
|
+
- `arc(x, y, w, h, start, stop, [mode])`
|
|
112
|
+
- `point(x, y)`
|
|
113
|
+
- `beginShape()` / `vertex(x, y)` / `endShape([close])`
|
|
114
|
+
- `bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2)`
|
|
115
|
+
- `curve(x1, y1, x2, y2, x3, y3, x4, y4)`
|
|
116
|
+
|
|
117
|
+
### 5.2 Style
|
|
118
|
+
- `fill(...)` — Supports all CSS color formats
|
|
119
|
+
- `noFill()`
|
|
120
|
+
- `stroke(...)` — Supports all CSS color formats
|
|
121
|
+
- `noStroke()`
|
|
122
|
+
- `strokeWeight(w)`
|
|
123
|
+
- `strokeCap(cap)`
|
|
124
|
+
- `strokeJoin(join)`
|
|
125
|
+
- `background(...)` — Supports all CSS color formats
|
|
126
|
+
- `colorMode(mode, [max1], [max2], [max3], [maxA])`
|
|
127
|
+
|
|
128
|
+
### 5.3 Color Functions
|
|
129
|
+
- `color(...)` — Create color object
|
|
130
|
+
- `lerpColor(c1, c2, amt)` — Interpolate colors
|
|
131
|
+
- `red(c)` / `green(c)` / `blue(c)` / `alpha(c)` — Extract components
|
|
132
|
+
- `hue(c)` / `saturation(c)` / `brightness(c)` — HSB extraction
|
|
133
|
+
|
|
134
|
+
### 5.4 Transforms
|
|
135
|
+
- `push()` / `pop()`
|
|
136
|
+
- `translate(x, y)`
|
|
137
|
+
- `rotate(angle)`
|
|
138
|
+
- `scale(s)` / `scale(sx, sy)`
|
|
139
|
+
- `resetMatrix()`
|
|
140
|
+
- `shearX(angle)` / `shearY(angle)`
|
|
141
|
+
|
|
142
|
+
### 5.5 Random (Seeded)
|
|
143
|
+
- `random([min], [max])` — Seeded pseudo-random
|
|
144
|
+
- `randomSeed(seed)` — Set random seed
|
|
145
|
+
- `randomGaussian([mean], [sd])` — Seeded Gaussian
|
|
146
|
+
|
|
147
|
+
### 5.6 Noise (Seeded)
|
|
148
|
+
- `noise(x, [y], [z])` — Seeded Perlin noise
|
|
149
|
+
- `noiseSeed(seed)` — Set noise seed
|
|
150
|
+
- `noiseDetail(octaves, [falloff])` — Configure noise
|
|
151
|
+
|
|
152
|
+
### 5.7 Math Utilities
|
|
153
|
+
- `map(value, start1, stop1, start2, stop2)`
|
|
154
|
+
- `constrain(value, min, max)`
|
|
155
|
+
- `lerp(start, stop, amt)`
|
|
156
|
+
- `dist(x1, y1, x2, y2)`
|
|
157
|
+
- `mag(x, y)`
|
|
158
|
+
- `norm(value, start, stop)`
|
|
159
|
+
- `abs()` / `floor()` / `ceil()` / `round()` / `sqrt()` / `pow()` / `exp()` / `log()`
|
|
160
|
+
- `sin()` / `cos()` / `tan()` / `asin()` / `acos()` / `atan()` / `atan2()`
|
|
161
|
+
- `min()` / `max()`
|
|
162
|
+
- `radians(degrees)` / `degrees(radians)`
|
|
163
|
+
|
|
164
|
+
### 5.8 Text
|
|
165
|
+
- `text(str, x, y)`
|
|
166
|
+
- `textSize(size)`
|
|
167
|
+
- `textFont(font)`
|
|
168
|
+
- `textAlign(horizAlign, [vertAlign])`
|
|
169
|
+
- `textWidth(str)`
|
|
170
|
+
|
|
171
|
+
### 5.9 Image/Pixel
|
|
172
|
+
- `loadPixels()` / `updatePixels()`
|
|
173
|
+
- `get(x, y)` / `set(x, y, color)`
|
|
174
|
+
- `pixels[]` — Pixel array
|
|
175
|
+
- `createGraphics(w, h)` — Offscreen buffer
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 6. Forbidden Patterns
|
|
180
|
+
|
|
181
|
+
The following patterns are **explicitly forbidden** and MUST throw errors:
|
|
182
|
+
|
|
183
|
+
| Pattern | Reason |
|
|
184
|
+
|---------|--------|
|
|
185
|
+
| `setTimeout()` | Async timing breaks determinism |
|
|
186
|
+
| `setInterval()` | Async timing breaks determinism |
|
|
187
|
+
| `requestAnimationFrame()` | Async timing breaks determinism |
|
|
188
|
+
| `noLoop()` (in Loop Mode) | Incompatible with frame capture |
|
|
189
|
+
| `createCanvas()` | Canvas is pre-initialized |
|
|
190
|
+
| `fetch()` / `XMLHttpRequest` | External IO breaks determinism |
|
|
191
|
+
| `import` / `require` | No external modules |
|
|
192
|
+
| DOM manipulation | No direct DOM access |
|
|
193
|
+
| `Date.now()` / `new Date()` | Time-based entropy breaks determinism |
|
|
194
|
+
| `Math.random()` | Use `random()` instead (seeded) |
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 7. Determinism Guarantees
|
|
199
|
+
|
|
200
|
+
### 7.1 Invariant
|
|
201
|
+
```
|
|
202
|
+
Same code + Same seed + Same VARs = Identical output
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### 7.2 Sources of Randomness
|
|
206
|
+
- **Allowed:** `random()`, `noise()` — Both are seeded
|
|
207
|
+
- **Forbidden:** `Math.random()`, `Date`, browser entropy
|
|
208
|
+
|
|
209
|
+
### 7.3 Verification
|
|
210
|
+
Any execution can be verified by re-running with the same inputs.
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 8. Canonical Execution API
|
|
215
|
+
|
|
216
|
+
### 8.1 Entry Point
|
|
217
|
+
```typescript
|
|
218
|
+
executeCodeMode({
|
|
219
|
+
source: string,
|
|
220
|
+
width: number,
|
|
221
|
+
height: number,
|
|
222
|
+
seed: number,
|
|
223
|
+
vars?: number[],
|
|
224
|
+
mode: 'static' | 'loop',
|
|
225
|
+
totalFrames?: number
|
|
226
|
+
}) => Promise<ExecutionResult>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### 8.2 Result Structure
|
|
230
|
+
```typescript
|
|
231
|
+
interface ExecutionResult {
|
|
232
|
+
image?: Blob; // Static mode: PNG
|
|
233
|
+
video?: Blob; // Loop mode: MP4
|
|
234
|
+
frames?: ImageData[]; // Optional: raw frames
|
|
235
|
+
metadata: {
|
|
236
|
+
protocol: 'nexart';
|
|
237
|
+
engine: 'codemode';
|
|
238
|
+
protocolVersion: '1.0.0';
|
|
239
|
+
phase: 1;
|
|
240
|
+
deterministic: true;
|
|
241
|
+
seed: number;
|
|
242
|
+
vars: number[];
|
|
243
|
+
width: number;
|
|
244
|
+
height: number;
|
|
245
|
+
mode: 'static' | 'loop';
|
|
246
|
+
totalFrames?: number;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## 9. Implementation Requirements
|
|
254
|
+
|
|
255
|
+
### 9.1 SDK Authority
|
|
256
|
+
- `@nexart/codemode-sdk` is the single source of truth
|
|
257
|
+
- NexArt app, ByX, and external clients MUST delegate to this SDK
|
|
258
|
+
- No other renderer may redefine Code Mode semantics
|
|
259
|
+
|
|
260
|
+
### 9.2 Logging
|
|
261
|
+
All executions MUST log:
|
|
262
|
+
```
|
|
263
|
+
[CodeMode] Rendered via @nexart/codemode-sdk (Protocol v1.0.0)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 9.3 Error Handling
|
|
267
|
+
- Missing `draw()` in Loop Mode → Error
|
|
268
|
+
- Missing `totalFrames` in Loop Mode → Error
|
|
269
|
+
- VAR mutation attempt → Warning + Error log (no crash)
|
|
270
|
+
- Unsupported function → Clear error message
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## 10. Non-Goals (Phase 1)
|
|
275
|
+
|
|
276
|
+
The following are **explicitly NOT part of Phase 1**:
|
|
277
|
+
|
|
278
|
+
- ❌ Sliders or UI controls
|
|
279
|
+
- ❌ Additional VAR slots beyond 10
|
|
280
|
+
- ❌ New drawing primitives
|
|
281
|
+
- ❌ WebGL or 3D rendering
|
|
282
|
+
- ❌ Audio input/output
|
|
283
|
+
- ❌ External asset loading
|
|
284
|
+
- ❌ Performance optimizations
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## 11. Future Phases
|
|
289
|
+
|
|
290
|
+
| Phase | Scope |
|
|
291
|
+
|-------|-------|
|
|
292
|
+
| Phase 2 | Additional primitives, shader support |
|
|
293
|
+
| Phase 3 | External asset loading (controlled) |
|
|
294
|
+
| Phase 4 | WebGL/3D support |
|
|
295
|
+
|
|
296
|
+
Each phase requires a protocol version bump and formal specification.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## 12. Changelog
|
|
301
|
+
|
|
302
|
+
### v1.0.0 (December 2024)
|
|
303
|
+
- Initial locked specification
|
|
304
|
+
- VAR[0..9] read-only protocol variables
|
|
305
|
+
- Full CSS color support
|
|
306
|
+
- Seeded random/noise
|
|
307
|
+
- Static + Loop modes
|
|
308
|
+
- HARD enforcement enabled
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
**End of Specification**
|