@nexart/codemode-sdk 1.1.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +121 -238
  2. package/dist/engine.d.ts +1 -1
  3. package/dist/engine.js +1 -1
  4. package/dist/index.d.ts +19 -27
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +19 -34
  7. package/dist/loop-engine.d.ts +1 -4
  8. package/dist/loop-engine.d.ts.map +1 -1
  9. package/dist/loop-engine.js +12 -17
  10. package/dist/p5-runtime.d.ts +4 -56
  11. package/dist/p5-runtime.d.ts.map +1 -1
  12. package/dist/p5-runtime.js +22 -348
  13. package/dist/static-engine.d.ts +1 -4
  14. package/dist/static-engine.d.ts.map +1 -1
  15. package/dist/static-engine.js +10 -14
  16. package/dist/types.d.ts +7 -7
  17. package/dist/types.d.ts.map +1 -1
  18. package/dist/types.js +3 -3
  19. package/package.json +17 -23
  20. package/CHANGELOG.md +0 -109
  21. package/CODE_MODE_PROTOCOL.md +0 -312
  22. package/dist/core-index.d.ts +0 -21
  23. package/dist/core-index.d.ts.map +0 -1
  24. package/dist/core-index.js +0 -26
  25. package/dist/execute.d.ts +0 -46
  26. package/dist/execute.d.ts.map +0 -1
  27. package/dist/execute.js +0 -268
  28. package/dist/noise-bridge.d.ts +0 -44
  29. package/dist/noise-bridge.d.ts.map +0 -1
  30. package/dist/noise-bridge.js +0 -68
  31. package/dist/noise-engine.d.ts +0 -74
  32. package/dist/noise-engine.d.ts.map +0 -1
  33. package/dist/noise-engine.js +0 -132
  34. package/dist/noise-sketches/fractalNoise.d.ts +0 -11
  35. package/dist/noise-sketches/fractalNoise.d.ts.map +0 -1
  36. package/dist/noise-sketches/fractalNoise.js +0 -121
  37. package/dist/noise-sketches/index.d.ts +0 -21
  38. package/dist/noise-sketches/index.d.ts.map +0 -1
  39. package/dist/noise-sketches/index.js +0 -28
  40. package/dist/sound-bridge.d.ts +0 -89
  41. package/dist/sound-bridge.d.ts.map +0 -1
  42. package/dist/sound-bridge.js +0 -128
  43. package/dist/soundart-engine.d.ts +0 -87
  44. package/dist/soundart-engine.d.ts.map +0 -1
  45. package/dist/soundart-engine.js +0 -173
  46. package/dist/soundart-sketches/chladniBloom.d.ts +0 -3
  47. package/dist/soundart-sketches/chladniBloom.d.ts.map +0 -1
  48. package/dist/soundart-sketches/chladniBloom.js +0 -53
  49. package/dist/soundart-sketches/dualVortex.d.ts +0 -3
  50. package/dist/soundart-sketches/dualVortex.d.ts.map +0 -1
  51. package/dist/soundart-sketches/dualVortex.js +0 -67
  52. package/dist/soundart-sketches/geometryIllusion.d.ts +0 -3
  53. package/dist/soundart-sketches/geometryIllusion.d.ts.map +0 -1
  54. package/dist/soundart-sketches/geometryIllusion.js +0 -89
  55. package/dist/soundart-sketches/index.d.ts +0 -39
  56. package/dist/soundart-sketches/index.d.ts.map +0 -1
  57. package/dist/soundart-sketches/index.js +0 -72
  58. package/dist/soundart-sketches/isoflow.d.ts +0 -3
  59. package/dist/soundart-sketches/isoflow.d.ts.map +0 -1
  60. package/dist/soundart-sketches/isoflow.js +0 -60
  61. package/dist/soundart-sketches/loomWeave.d.ts +0 -3
  62. package/dist/soundart-sketches/loomWeave.d.ts.map +0 -1
  63. package/dist/soundart-sketches/loomWeave.js +0 -59
  64. package/dist/soundart-sketches/noiseTerraces.d.ts +0 -3
  65. package/dist/soundart-sketches/noiseTerraces.d.ts.map +0 -1
  66. package/dist/soundart-sketches/noiseTerraces.js +0 -53
  67. package/dist/soundart-sketches/orb.d.ts +0 -3
  68. package/dist/soundart-sketches/orb.d.ts.map +0 -1
  69. package/dist/soundart-sketches/orb.js +0 -50
  70. package/dist/soundart-sketches/pixelGlyphs.d.ts +0 -3
  71. package/dist/soundart-sketches/pixelGlyphs.d.ts.map +0 -1
  72. package/dist/soundart-sketches/pixelGlyphs.js +0 -72
  73. package/dist/soundart-sketches/prismFlowFields.d.ts +0 -3
  74. package/dist/soundart-sketches/prismFlowFields.d.ts.map +0 -1
  75. package/dist/soundart-sketches/prismFlowFields.js +0 -51
  76. package/dist/soundart-sketches/radialBurst.d.ts +0 -3
  77. package/dist/soundart-sketches/radialBurst.d.ts.map +0 -1
  78. package/dist/soundart-sketches/radialBurst.js +0 -60
  79. package/dist/soundart-sketches/resonantSoundBodies.d.ts +0 -3
  80. package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +0 -1
  81. package/dist/soundart-sketches/resonantSoundBodies.js +0 -89
  82. package/dist/soundart-sketches/rings.d.ts +0 -11
  83. package/dist/soundart-sketches/rings.d.ts.map +0 -1
  84. package/dist/soundart-sketches/rings.js +0 -89
  85. package/dist/soundart-sketches/squares.d.ts +0 -3
  86. package/dist/soundart-sketches/squares.d.ts.map +0 -1
  87. package/dist/soundart-sketches/squares.js +0 -52
  88. package/dist/soundart-sketches/waveStripes.d.ts +0 -3
  89. package/dist/soundart-sketches/waveStripes.d.ts.map +0 -1
  90. package/dist/soundart-sketches/waveStripes.js +0 -44
@@ -1,12 +1,9 @@
1
1
  /**
2
2
  * NexArt Code Mode Runtime SDK - Static Engine
3
- * Protocol: v1.0.0 (Phase 1) — HARD ENFORCEMENT
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.
7
- *
8
- * Determinism Guarantee:
9
- * Same code + same seed + same VARs = identical PNG output
10
7
  */
11
8
  import type { EngineConfig, RunOptions } from './types';
12
9
  export declare function runStaticMode(config: EngineConfig, options: RunOptions): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"static-engine.d.ts","sourceRoot":"","sources":["../static-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;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,CAkGf"}
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"}
@@ -1,17 +1,14 @@
1
1
  /**
2
2
  * NexArt Code Mode Runtime SDK - Static Engine
3
- * Protocol: v1.0.0 (Phase 1) — HARD ENFORCEMENT
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.
7
- *
8
- * Determinism Guarantee:
9
- * Same code + same seed + same VARs = identical PNG output
10
7
  */
11
8
  import { DEFAULT_CONFIG } from './types';
12
- import { createP5Runtime, injectTimeVariables, injectProtocolVariables } from './p5-runtime';
9
+ import { createP5Runtime, injectTimeVariables } from './p5-runtime';
13
10
  export async function runStaticMode(config, options) {
14
- const { code, seed, vars, onPreview, onProgress, onComplete, onError } = options;
11
+ const { code, onPreview, onProgress, onComplete, onError } = options;
15
12
  const width = config.width ?? DEFAULT_CONFIG.width;
16
13
  const height = config.height ?? DEFAULT_CONFIG.height;
17
14
  try {
@@ -24,17 +21,16 @@ export async function runStaticMode(config, options) {
24
21
  const canvas = document.createElement('canvas');
25
22
  canvas.width = width;
26
23
  canvas.height = height;
27
- // Create p5 runtime with optional seed for determinism
28
- const p = createP5Runtime(canvas, width, height, { seed });
29
- // Inject time variables (static = frame 0, t = 0)
24
+ // Create p5 runtime
25
+ const p = createP5Runtime(canvas, width, height);
26
+ // Inject time variables (static = frame 0, t = 0, totalFrames = 1)
30
27
  injectTimeVariables(p, {
31
28
  frameCount: 0,
32
29
  t: 0,
33
30
  time: 0,
34
31
  tGlobal: 0,
32
+ totalFrames: 1, // Static mode has 1 frame
35
33
  });
36
- // Inject protocol variables (VAR[0..9])
37
- injectProtocolVariables(p, vars);
38
34
  onProgress?.({
39
35
  phase: 'setup',
40
36
  percent: 10,
@@ -55,10 +51,10 @@ export async function runStaticMode(config, options) {
55
51
  percent: 30,
56
52
  message: 'Executing setup()...',
57
53
  });
58
- // Create wrapped setup function with p5 context and VAR
59
- const wrappedSetup = new Function('p', 'frameCount', 't', 'time', 'tGlobal', 'VAR', `with(p) { ${setupCode} }`);
54
+ // Create wrapped setup function with p5 context
55
+ const wrappedSetup = new Function('p', 'frameCount', 't', 'time', 'tGlobal', `with(p) { ${setupCode} }`);
60
56
  // Execute setup() only
61
- wrappedSetup(p, 0, 0, 0, 0, p.VAR);
57
+ wrappedSetup(p, 0, 0, 0, 0);
62
58
  // Provide preview callback
63
59
  onPreview?.(canvas);
64
60
  onProgress?.({
package/dist/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * NexArt Code Mode Runtime SDK - Types
3
- * Version: 1.0.2 (Protocol v1.0.0)
3
+ * Version: 1.4.0 (Protocol v1.2.0)
4
4
  *
5
5
  * Type definitions for the Code Mode runtime engine.
6
6
  * This is the canonical type surface for @nexart/codemode-sdk.
@@ -12,8 +12,8 @@
12
12
  export declare const PROTOCOL_IDENTITY: {
13
13
  readonly protocol: "nexart";
14
14
  readonly engine: "codemode";
15
- readonly protocolVersion: "1.0.0";
16
- readonly phase: 1;
15
+ readonly protocolVersion: "1.2.0";
16
+ readonly phase: 3;
17
17
  readonly deterministic: true;
18
18
  };
19
19
  export type RenderMode = 'static' | 'loop';
@@ -56,13 +56,13 @@ export interface TimeVariables {
56
56
  t: number;
57
57
  time: number;
58
58
  tGlobal: number;
59
+ totalFrames: number;
59
60
  }
60
61
  /**
61
62
  * Protocol Variables (VAR[0..9])
62
63
  * First-class protocol inputs for deterministic rendering.
63
- * Used by SoundArt, Shapes, Noise, and ByX collections.
64
64
  *
65
- * Rules (SDK v1.0.2, Protocol v1.0.0):
65
+ * Rules (SDK v1.4.0, Protocol v1.2.0):
66
66
  * - Input array can have 0-10 elements (protocol error if > 10)
67
67
  * - All values MUST be finite numbers (protocol error if not)
68
68
  * - Values MUST be in range 0-100 (protocol error if out of range, NO clamping)
@@ -92,8 +92,8 @@ export declare const DEFAULT_CONFIG: {
92
92
  export interface ProtocolMetadata {
93
93
  protocol: 'nexart';
94
94
  engine: 'codemode';
95
- protocolVersion: '1.0.0';
96
- phase: 1;
95
+ protocolVersion: '1.2.0';
96
+ phase: 3;
97
97
  deterministic: true;
98
98
  seed: number;
99
99
  vars: number[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;CAMpB,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,QAAQ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;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,iBAE1B,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;CAOjB,CAAC;AAEX;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,CAAC,CAAC;IACT,aAAa,EAAE,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;IACjB,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,6 +1,6 @@
1
1
  /**
2
2
  * NexArt Code Mode Runtime SDK - Types
3
- * Version: 1.0.2 (Protocol v1.0.0)
3
+ * Version: 1.4.0 (Protocol v1.2.0)
4
4
  *
5
5
  * Type definitions for the Code Mode runtime engine.
6
6
  * This is the canonical type surface for @nexart/codemode-sdk.
@@ -12,8 +12,8 @@
12
12
  export const PROTOCOL_IDENTITY = {
13
13
  protocol: 'nexart',
14
14
  engine: 'codemode',
15
- protocolVersion: '1.0.0',
16
- phase: 1,
15
+ protocolVersion: '1.2.0',
16
+ phase: 3,
17
17
  deterministic: true,
18
18
  };
19
19
  /**
package/package.json CHANGED
@@ -1,42 +1,36 @@
1
1
  {
2
2
  "name": "@nexart/codemode-sdk",
3
- "version": "1.1.1",
4
- "description": "NexArt Code Mode SDK - Canonical execution engine for deterministic generative art",
3
+ "version": "1.4.0",
4
+ "description": "NexArt Code Mode Runtime SDK - Deterministic generative art rendering engine (Protocol v1.2.0)",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
5
8
  "type": "module",
6
- "main": "./dist/core-index.js",
7
- "types": "./dist/core-index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/core-index.d.ts",
11
- "import": "./dist/core-index.js"
12
- }
13
- },
14
9
  "files": [
15
- "dist",
16
- "README.md",
17
- "CHANGELOG.md",
18
- "CODE_MODE_PROTOCOL.md"
10
+ "dist"
19
11
  ],
20
12
  "scripts": {
21
13
  "build": "tsc",
22
- "test": "npx tsx smoke-test.ts",
23
- "prepublishOnly": "npm run build && npm run test"
14
+ "prepublishOnly": "npm run build"
15
+ },
16
+ "devDependencies": {
17
+ "typescript": "^5.0.0"
24
18
  },
25
19
  "keywords": [
26
- "nexart",
27
20
  "generative-art",
28
- "nft",
29
21
  "p5js",
22
+ "canvas",
23
+ "rendering",
30
24
  "deterministic",
31
- "codemode"
25
+ "nft",
26
+ "creative-coding"
32
27
  ],
33
- "author": "NexArt",
34
- "license": "MIT",
35
28
  "repository": {
36
29
  "type": "git",
37
30
  "url": "https://github.com/artnames/nexart-codemode-sdk.git"
38
31
  },
39
- "devDependencies": {
40
- "typescript": "^5.0.0"
32
+ "author": "NexArt",
33
+ "publishConfig": {
34
+ "access": "public"
41
35
  }
42
36
  }
package/CHANGELOG.md DELETED
@@ -1,109 +0,0 @@
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
@@ -1,312 +0,0 @@
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**
@@ -1,21 +0,0 @@
1
- /**
2
- * @nexart/codemode-sdk v1.1.0 — Core Exports
3
- *
4
- * Canonical execution engine for NexArt Code Mode.
5
- * This is the single source of truth for Code Mode semantics.
6
- *
7
- * Protocol: v1.0.0 (LOCKED)
8
- * Enforcement: HARD
9
- */
10
- export { executeCodeMode, validateCodeModeSource, } from './execute';
11
- export { type RenderMode, type TimeVariables, type ProtocolMetadata, type EngineConfig, type RenderResult, type RunOptions, type ProgressInfo, type Engine, type ExecuteCodeModeInput, type ExecuteCodeModeResult, PROTOCOL_IDENTITY, DEFAULT_VARS, DEFAULT_CONFIG, } from './types';
12
- export { createP5Runtime, injectTimeVariables, createProtocolVAR, VAR_COUNT, VAR_MIN, VAR_MAX, CODE_MODE_PROTOCOL_VERSION, CODE_MODE_PROTOCOL_PHASE, CODE_MODE_ENFORCEMENT, type P5Runtime, type P5RuntimeConfig, } from './p5-runtime';
13
- export { runStaticMode, } from './static-engine';
14
- export { runLoopMode, cancelLoopMode, } from './loop-engine';
15
- export { createEngine, } from './engine';
16
- /**
17
- * SDK Identity
18
- */
19
- export declare const SDK_VERSION = "1.1.1";
20
- export declare const SDK_NAME = "@nexart/codemode-sdk";
21
- //# sourceMappingURL=core-index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core-index.d.ts","sourceRoot":"","sources":["../core-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,eAAe,EACf,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,OAAO,EACP,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,WAAW,EACX,cAAc,GACf,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,YAAY,GACb,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,QAAQ,yBAAyB,CAAC"}
@@ -1,26 +0,0 @@
1
- /**
2
- * @nexart/codemode-sdk v1.1.0 — Core Exports
3
- *
4
- * Canonical execution engine for NexArt Code Mode.
5
- * This is the single source of truth for Code Mode semantics.
6
- *
7
- * Protocol: v1.0.0 (LOCKED)
8
- * Enforcement: HARD
9
- */
10
- // Core execution
11
- export { executeCodeMode, validateCodeModeSource, } from './execute';
12
- // Protocol types
13
- export { PROTOCOL_IDENTITY, DEFAULT_VARS, DEFAULT_CONFIG, } from './types';
14
- // Runtime
15
- export { createP5Runtime, injectTimeVariables, createProtocolVAR, VAR_COUNT, VAR_MIN, VAR_MAX, CODE_MODE_PROTOCOL_VERSION, CODE_MODE_PROTOCOL_PHASE, CODE_MODE_ENFORCEMENT, } from './p5-runtime';
16
- // Static engine
17
- export { runStaticMode, } from './static-engine';
18
- // Loop engine
19
- export { runLoopMode, cancelLoopMode, } from './loop-engine';
20
- // Engine utilities
21
- export { createEngine, } from './engine';
22
- /**
23
- * SDK Identity
24
- */
25
- export const SDK_VERSION = '1.1.1';
26
- export const SDK_NAME = '@nexart/codemode-sdk';