@nexart/codemode-sdk 1.8.0 → 1.8.2

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 (138) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/COMMERCIAL.md +41 -0
  3. package/LICENSE.md +5 -5
  4. package/README.md +250 -700
  5. package/dist/sdk/codemode/core-index.d.ts +6 -4
  6. package/dist/sdk/codemode/core-index.d.ts.map +1 -1
  7. package/dist/sdk/codemode/core-index.js +6 -4
  8. package/dist/{entry → sdk/codemode/entry}/browser.d.ts +5 -2
  9. package/dist/sdk/codemode/entry/browser.d.ts.map +1 -0
  10. package/dist/{entry → sdk/codemode/entry}/browser.js +10 -4
  11. package/dist/{entry → sdk/codemode/entry}/node.d.ts +2 -1
  12. package/dist/sdk/codemode/entry/node.d.ts.map +1 -0
  13. package/dist/{entry → sdk/codemode/entry}/node.js +2 -1
  14. package/dist/{runtime.d.ts → sdk/codemode/runtime.d.ts} +2 -2
  15. package/dist/sdk/codemode/runtime.d.ts.map +1 -0
  16. package/dist/{runtime.js → sdk/codemode/runtime.js} +3 -2
  17. package/dist/sdk/codemode/static-engine.d.ts.map +1 -1
  18. package/dist/sdk/codemode/static-engine.js +24 -11
  19. package/dist/sdk/codemode/version.d.ts +18 -0
  20. package/dist/sdk/codemode/version.d.ts.map +1 -0
  21. package/dist/sdk/codemode/version.js +17 -0
  22. package/examples/agent-quickstart.ts +159 -0
  23. package/examples/preflight-test.ts +1 -1
  24. package/package.json +4 -2
  25. package/dist/builder-manifest.d.ts +0 -79
  26. package/dist/builder-manifest.d.ts.map +0 -1
  27. package/dist/builder-manifest.js +0 -97
  28. package/dist/core-index.d.ts +0 -21
  29. package/dist/core-index.d.ts.map +0 -1
  30. package/dist/core-index.js +0 -26
  31. package/dist/engine.d.ts +0 -24
  32. package/dist/engine.d.ts.map +0 -1
  33. package/dist/engine.js +0 -67
  34. package/dist/entry/browser.d.ts.map +0 -1
  35. package/dist/entry/node.d.ts.map +0 -1
  36. package/dist/execute.d.ts +0 -46
  37. package/dist/execute.d.ts.map +0 -1
  38. package/dist/execute.js +0 -283
  39. package/dist/execution-sandbox.d.ts +0 -107
  40. package/dist/execution-sandbox.d.ts.map +0 -1
  41. package/dist/execution-sandbox.js +0 -207
  42. package/dist/index.d.ts +0 -31
  43. package/dist/index.d.ts.map +0 -1
  44. package/dist/index.js +0 -63
  45. package/dist/loop-engine.d.ts +0 -22
  46. package/dist/loop-engine.d.ts.map +0 -1
  47. package/dist/loop-engine.js +0 -229
  48. package/dist/noise-bridge.d.ts +0 -44
  49. package/dist/noise-bridge.d.ts.map +0 -1
  50. package/dist/noise-bridge.js +0 -68
  51. package/dist/noise-engine.d.ts +0 -74
  52. package/dist/noise-engine.d.ts.map +0 -1
  53. package/dist/noise-engine.js +0 -132
  54. package/dist/noise-sketches/fractalNoise.d.ts +0 -11
  55. package/dist/noise-sketches/fractalNoise.d.ts.map +0 -1
  56. package/dist/noise-sketches/fractalNoise.js +0 -121
  57. package/dist/noise-sketches/index.d.ts +0 -21
  58. package/dist/noise-sketches/index.d.ts.map +0 -1
  59. package/dist/noise-sketches/index.js +0 -28
  60. package/dist/p5-runtime.d.ts +0 -75
  61. package/dist/p5-runtime.d.ts.map +0 -1
  62. package/dist/p5-runtime.js +0 -1031
  63. package/dist/runtime.d.ts.map +0 -1
  64. package/dist/sdk/codemode/index.d.ts +0 -31
  65. package/dist/sdk/codemode/index.d.ts.map +0 -1
  66. package/dist/sdk/codemode/index.js +0 -63
  67. package/dist/sdk/codemode/noise-bridge.d.ts +0 -44
  68. package/dist/sdk/codemode/noise-bridge.d.ts.map +0 -1
  69. package/dist/sdk/codemode/noise-bridge.js +0 -68
  70. package/dist/sdk/codemode/noise-engine.d.ts +0 -74
  71. package/dist/sdk/codemode/noise-engine.d.ts.map +0 -1
  72. package/dist/sdk/codemode/noise-engine.js +0 -132
  73. package/dist/sdk/codemode/noise-sketches/fractalNoise.d.ts +0 -11
  74. package/dist/sdk/codemode/noise-sketches/fractalNoise.d.ts.map +0 -1
  75. package/dist/sdk/codemode/noise-sketches/fractalNoise.js +0 -121
  76. package/dist/sdk/codemode/noise-sketches/index.d.ts +0 -21
  77. package/dist/sdk/codemode/noise-sketches/index.d.ts.map +0 -1
  78. package/dist/sdk/codemode/noise-sketches/index.js +0 -28
  79. package/dist/shared/noiseSnapshot.d.ts +0 -59
  80. package/dist/shared/noiseSnapshot.d.ts.map +0 -1
  81. package/dist/shared/noiseSnapshot.js +0 -72
  82. package/dist/sound-bridge.d.ts +0 -89
  83. package/dist/sound-bridge.d.ts.map +0 -1
  84. package/dist/sound-bridge.js +0 -128
  85. package/dist/soundart-engine.d.ts +0 -87
  86. package/dist/soundart-engine.d.ts.map +0 -1
  87. package/dist/soundart-engine.js +0 -173
  88. package/dist/soundart-sketches/chladniBloom.d.ts +0 -3
  89. package/dist/soundart-sketches/chladniBloom.d.ts.map +0 -1
  90. package/dist/soundart-sketches/chladniBloom.js +0 -53
  91. package/dist/soundart-sketches/dualVortex.d.ts +0 -3
  92. package/dist/soundart-sketches/dualVortex.d.ts.map +0 -1
  93. package/dist/soundart-sketches/dualVortex.js +0 -67
  94. package/dist/soundart-sketches/geometryIllusion.d.ts +0 -3
  95. package/dist/soundart-sketches/geometryIllusion.d.ts.map +0 -1
  96. package/dist/soundart-sketches/geometryIllusion.js +0 -89
  97. package/dist/soundart-sketches/index.d.ts +0 -39
  98. package/dist/soundart-sketches/index.d.ts.map +0 -1
  99. package/dist/soundart-sketches/index.js +0 -72
  100. package/dist/soundart-sketches/isoflow.d.ts +0 -3
  101. package/dist/soundart-sketches/isoflow.d.ts.map +0 -1
  102. package/dist/soundart-sketches/isoflow.js +0 -60
  103. package/dist/soundart-sketches/loomWeave.d.ts +0 -3
  104. package/dist/soundart-sketches/loomWeave.d.ts.map +0 -1
  105. package/dist/soundart-sketches/loomWeave.js +0 -59
  106. package/dist/soundart-sketches/noiseTerraces.d.ts +0 -3
  107. package/dist/soundart-sketches/noiseTerraces.d.ts.map +0 -1
  108. package/dist/soundart-sketches/noiseTerraces.js +0 -53
  109. package/dist/soundart-sketches/orb.d.ts +0 -3
  110. package/dist/soundart-sketches/orb.d.ts.map +0 -1
  111. package/dist/soundart-sketches/orb.js +0 -50
  112. package/dist/soundart-sketches/pixelGlyphs.d.ts +0 -3
  113. package/dist/soundart-sketches/pixelGlyphs.d.ts.map +0 -1
  114. package/dist/soundart-sketches/pixelGlyphs.js +0 -72
  115. package/dist/soundart-sketches/prismFlowFields.d.ts +0 -3
  116. package/dist/soundart-sketches/prismFlowFields.d.ts.map +0 -1
  117. package/dist/soundart-sketches/prismFlowFields.js +0 -51
  118. package/dist/soundart-sketches/radialBurst.d.ts +0 -3
  119. package/dist/soundart-sketches/radialBurst.d.ts.map +0 -1
  120. package/dist/soundart-sketches/radialBurst.js +0 -60
  121. package/dist/soundart-sketches/resonantSoundBodies.d.ts +0 -3
  122. package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +0 -1
  123. package/dist/soundart-sketches/resonantSoundBodies.js +0 -89
  124. package/dist/soundart-sketches/rings.d.ts +0 -11
  125. package/dist/soundart-sketches/rings.d.ts.map +0 -1
  126. package/dist/soundart-sketches/rings.js +0 -89
  127. package/dist/soundart-sketches/squares.d.ts +0 -3
  128. package/dist/soundart-sketches/squares.d.ts.map +0 -1
  129. package/dist/soundart-sketches/squares.js +0 -52
  130. package/dist/soundart-sketches/waveStripes.d.ts +0 -3
  131. package/dist/soundart-sketches/waveStripes.d.ts.map +0 -1
  132. package/dist/soundart-sketches/waveStripes.js +0 -44
  133. package/dist/static-engine.d.ts +0 -20
  134. package/dist/static-engine.d.ts.map +0 -1
  135. package/dist/static-engine.js +0 -157
  136. package/dist/types.d.ts +0 -191
  137. package/dist/types.d.ts.map +0 -1
  138. package/dist/types.js +0 -32
@@ -1,97 +0,0 @@
1
- /**
2
- * NexArt Code Mode SDK - Builder Manifest
3
- * Version: 1.6.0 (Protocol v1.2.0)
4
- *
5
- * ╔══════════════════════════════════════════════════════════════════════════╗
6
- * ║ BUILDER MANIFEST — PASSIVE ATTRIBUTION (WRITE-ONLY) ║
7
- * ║ ║
8
- * ║ The Builder Manifest is a declaration of intent, not a capability. ║
9
- * ║ The SDK does not expose any API to read or inspect manifests. ║
10
- * ║ ║
11
- * ║ This is: ║
12
- * ║ - Declarative (write-only, no read API exposed) ║
13
- * ║ - Optional (no errors if missing or invalid) ║
14
- * ║ - Non-enforced (no validation logic) ║
15
- * ║ - Non-rewarding (no incentives, no tracking) ║
16
- * ║ ║
17
- * ║ There is: ║
18
- * ║ - No SDK API to read manifests ║
19
- * ║ - No validation ║
20
- * ║ - No attribution logic ║
21
- * ║ - No tracking, analytics, or network calls ║
22
- * ║ ║
23
- * ║ Execution behavior is identical with or without a manifest. ║
24
- * ╚══════════════════════════════════════════════════════════════════════════╝
25
- */
26
- /** Internal storage - not accessible to SDK consumers */
27
- let currentManifest = null;
28
- /**
29
- * Register a builder manifest for attribution.
30
- *
31
- * This is optional and does not affect execution behavior.
32
- * The manifest is stored in-memory only and is not:
33
- * - Serialized to disk
34
- * - Sent over the network
35
- * - Logged to console
36
- * - Used for validation or enforcement
37
- *
38
- * @param manifest - Optional builder manifest. Pass undefined to clear.
39
- *
40
- * @example
41
- * ```typescript
42
- * import { registerBuilderManifest } from "@nexart/codemode-sdk";
43
- *
44
- * registerBuilderManifest({
45
- * protocol: "nexart",
46
- * manifestVersion: "0.1",
47
- * app: { name: "My App", url: "https://myapp.com" }
48
- * });
49
- * ```
50
- */
51
- export function registerBuilderManifest(manifest) {
52
- if (!manifest) {
53
- currentManifest = null;
54
- return;
55
- }
56
- if (manifest.protocol !== 'nexart') {
57
- currentManifest = null;
58
- return;
59
- }
60
- if (typeof manifest.manifestVersion !== 'string') {
61
- currentManifest = null;
62
- return;
63
- }
64
- currentManifest = manifest;
65
- }
66
- /**
67
- * Get the currently registered builder manifest.
68
- *
69
- * ╔══════════════════════════════════════════════════════════════════════════╗
70
- * ║ INTERNAL FUNCTION — NOT EXPORTED TO SDK CONSUMERS ║
71
- * ║ ║
72
- * ║ This function exists only for internal SDK execution context. ║
73
- * ║ It is NOT part of the public API and must NOT be exported from index. ║
74
- * ║ Runtime code and sketch code cannot access this function. ║
75
- * ╚══════════════════════════════════════════════════════════════════════════╝
76
- *
77
- * @internal
78
- */
79
- export function getBuilderManifest() {
80
- return currentManifest;
81
- }
82
- /**
83
- * Clear the registered builder manifest.
84
- *
85
- * ╔══════════════════════════════════════════════════════════════════════════╗
86
- * ║ INTERNAL FUNCTION — NOT EXPORTED TO SDK CONSUMERS ║
87
- * ║ ║
88
- * ║ This function exists only for internal SDK execution context. ║
89
- * ║ It is NOT part of the public API and must NOT be exported from index. ║
90
- * ║ Runtime code and sketch code cannot access this function. ║
91
- * ╚══════════════════════════════════════════════════════════════════════════╝
92
- *
93
- * @internal
94
- */
95
- export function clearBuilderManifest() {
96
- currentManifest = null;
97
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * @nexart/codemode-sdk v1.4.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.2.0 (Phase 3)
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.8.0";
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.4.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.2.0 (Phase 3)
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.8.0';
26
- export const SDK_NAME = '@nexart/codemode-sdk';
package/dist/engine.d.ts DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * NexArt Code Mode Runtime SDK
3
- * Version: 0.1.0
4
- *
5
- * Main entry point for the Code Mode runtime engine.
6
- *
7
- * Usage:
8
- * const engine = createEngine({ mode: 'static' });
9
- * engine.run({
10
- * code: 'function setup() { background(255); ellipse(width/2, height/2, 100); }',
11
- * onComplete: (result) => console.log(result.blob)
12
- * });
13
- */
14
- import type { Engine, EngineConfig } from './types';
15
- /**
16
- * Create a NexArt Code Mode rendering engine.
17
- *
18
- * @param config - Engine configuration
19
- * @returns Engine instance
20
- */
21
- export declare function createEngine(config: EngineConfig): Engine;
22
- export type { Engine, EngineConfig, RunOptions, RenderResult, ProgressInfo } from './types';
23
- export { DEFAULT_CONFIG } from './types';
24
- //# sourceMappingURL=engine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAc,MAAM,SAAS,CAAC;AAKhE;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CA+CzD;AAGD,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
package/dist/engine.js DELETED
@@ -1,67 +0,0 @@
1
- /**
2
- * NexArt Code Mode Runtime SDK
3
- * Version: 0.1.0
4
- *
5
- * Main entry point for the Code Mode runtime engine.
6
- *
7
- * Usage:
8
- * const engine = createEngine({ mode: 'static' });
9
- * engine.run({
10
- * code: 'function setup() { background(255); ellipse(width/2, height/2, 100); }',
11
- * onComplete: (result) => console.log(result.blob)
12
- * });
13
- */
14
- import { DEFAULT_CONFIG } from './types';
15
- import { runStaticMode } from './static-engine';
16
- import { runLoopMode, cancelLoopMode } from './loop-engine';
17
- /**
18
- * Create a NexArt Code Mode rendering engine.
19
- *
20
- * @param config - Engine configuration
21
- * @returns Engine instance
22
- */
23
- export function createEngine(config) {
24
- const resolvedConfig = {
25
- mode: config.mode,
26
- width: config.width ?? DEFAULT_CONFIG.width,
27
- height: config.height ?? DEFAULT_CONFIG.height,
28
- duration: config.duration ?? DEFAULT_CONFIG.duration,
29
- fps: config.fps ?? DEFAULT_CONFIG.fps,
30
- };
31
- let isRunning = false;
32
- const run = async (options) => {
33
- if (isRunning) {
34
- throw new Error('Engine is already running. Call stop() first.');
35
- }
36
- isRunning = true;
37
- try {
38
- if (resolvedConfig.mode === 'static') {
39
- await runStaticMode(resolvedConfig, options);
40
- }
41
- else if (resolvedConfig.mode === 'loop') {
42
- await runLoopMode(resolvedConfig, options);
43
- }
44
- else {
45
- throw new Error(`Unknown mode: ${resolvedConfig.mode}`);
46
- }
47
- }
48
- finally {
49
- isRunning = false;
50
- }
51
- };
52
- const stop = () => {
53
- if (resolvedConfig.mode === 'loop') {
54
- cancelLoopMode();
55
- }
56
- isRunning = false;
57
- };
58
- const getConfig = () => {
59
- return { ...resolvedConfig };
60
- };
61
- return {
62
- run,
63
- stop,
64
- getConfig,
65
- };
66
- }
67
- export { DEFAULT_CONFIG } from './types';
@@ -1 +0,0 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../entry/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,YAAY,EACV,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,cAAc,GACf,MAAM,UAAU,CAAC;AAKlB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,OAAO,EACP,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,SAAS,EACT,eAAe,GAChB,MAAM,eAAe,CAAC;AAKvB,OAAO,EACL,WAAW,EACX,cAAc,GACf,MAAM,gBAAgB,CAAC;AAKxB,OAAO,EACL,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,YAAY,GACb,MAAM,WAAW,CAAC;AAKnB,OAAO,EACL,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,cAAc,EACd,YAAY,EACZ,aAAa,IAAI,iBAAiB,GACnC,MAAM,YAAY,CAAC;AAKpB,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,QAAQ,yBAAyB,CAAC;AAC/C,eAAO,MAAM,SAAS,YAAY,CAAC;AAEnC;;;;;;;;;;;GAWG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../entry/node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,cAAc,WAAW,CAAC;AAK1B,OAAO,EACL,aAAa,GACd,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EACL,eAAe,GAChB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAClD,eAAO,MAAM,SAAS,SAAS,CAAC"}
package/dist/execute.d.ts DELETED
@@ -1,46 +0,0 @@
1
- /**
2
- * NexArt Code Mode Runtime SDK - Canonical Execution Entry Point
3
- *
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
- * ╚══════════════════════════════════════════════════════════════════════════╝
12
- */
13
- import { ExecuteCodeModeInput, ExecuteCodeModeResult } from './types';
14
- /**
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
22
- *
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
41
- */
42
- export declare function validateCodeModeSource(source: string, mode: 'static' | 'loop'): {
43
- valid: boolean;
44
- errors: string[];
45
- };
46
- //# sourceMappingURL=execute.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EAMtB,MAAM,SAAS,CAAC;AAuNjB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC,CAmChC;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"}
package/dist/execute.js DELETED
@@ -1,283 +0,0 @@
1
- /**
2
- * NexArt Code Mode Runtime SDK - Canonical Execution Entry Point
3
- *
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
- * ╚══════════════════════════════════════════════════════════════════════════╝
12
- */
13
- import { runStaticMode } from './static-engine';
14
- import { runLoopMode } from './loop-engine';
15
- import { PROTOCOL_IDENTITY, DEFAULT_CONFIG, } from './types';
16
- import { getBuilderManifest } from './builder-manifest';
17
- /**
18
- * Validate and normalize VAR array to 10 elements.
19
- *
20
- * Rules (SDK v1.0.2, Protocol v1.0.0):
21
- * - VAR is OPTIONAL: omit or pass [] for empty (defaults to all zeros)
22
- * - VAR input length MUST be 0-10 elements (protocol error if > 10)
23
- * - VAR values MUST be finite numbers (protocol error if not)
24
- * - VAR values MUST be in range 0-100 (protocol error if out of range, NO clamping)
25
- * - VAR is read-only inside sketches
26
- * - Output is ALWAYS 10 elements (padded with zeros) for protocol consistency
27
- */
28
- function normalizeVars(vars) {
29
- if (!vars || !Array.isArray(vars)) {
30
- console.log('[CodeMode] No vars provided, using defaults [0,0,0,0,0,0,0,0,0,0]');
31
- return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
32
- }
33
- if (vars.length > 10) {
34
- throw new Error(`[Code Mode Protocol Error] VAR array must have at most 10 elements, got ${vars.length}`);
35
- }
36
- const result = [];
37
- for (let i = 0; i < vars.length; i++) {
38
- const v = vars[i];
39
- if (typeof v !== 'number' || !Number.isFinite(v)) {
40
- throw new Error(`[Code Mode Protocol Error] VAR[${i}] must be a finite number, got ${typeof v === 'number' ? v : typeof v}`);
41
- }
42
- if (v < 0 || v > 100) {
43
- throw new Error(`[Code Mode Protocol Error] VAR[${i}] = ${v} is out of range. Values must be 0-100.`);
44
- }
45
- result.push(v);
46
- }
47
- // Pad with zeros to always have 10 elements for protocol consistency
48
- while (result.length < 10) {
49
- result.push(0);
50
- }
51
- return result;
52
- }
53
- /**
54
- * Validate execution input
55
- */
56
- function validateInput(input) {
57
- if (!input.source || typeof input.source !== 'string') {
58
- throw new Error('[Code Mode Protocol Error] source is required and must be a string');
59
- }
60
- if (typeof input.width !== 'number' || input.width <= 0) {
61
- throw new Error('[Code Mode Protocol Error] width must be a positive number');
62
- }
63
- if (typeof input.height !== 'number' || input.height <= 0) {
64
- throw new Error('[Code Mode Protocol Error] height must be a positive number');
65
- }
66
- if (typeof input.seed !== 'number') {
67
- throw new Error('[Code Mode Protocol Error] seed is required and must be a number');
68
- }
69
- if (input.mode !== 'static' && input.mode !== 'loop') {
70
- throw new Error('[Code Mode Protocol Error] mode must be "static" or "loop"');
71
- }
72
- if (input.mode === 'loop') {
73
- if (typeof input.totalFrames !== 'number' || input.totalFrames <= 0) {
74
- throw new Error('[Code Mode Protocol Error] totalFrames is required for loop mode and must be a positive number');
75
- }
76
- }
77
- // Validate forbidden patterns per CODE_MODE_PROTOCOL.md
78
- const forbiddenPatterns = [
79
- // Async timing (breaks determinism)
80
- { pattern: /setTimeout\s*\(/, name: 'setTimeout' },
81
- { pattern: /setInterval\s*\(/, name: 'setInterval' },
82
- { pattern: /requestAnimationFrame\s*\(/, name: 'requestAnimationFrame' },
83
- // Time-based entropy (breaks determinism)
84
- { pattern: /Date\.now\s*\(/, name: 'Date.now() — use time variable instead' },
85
- { pattern: /new\s+Date\s*\(/, name: 'new Date() — use time variable instead' },
86
- // Unseeded random (use random() instead)
87
- { pattern: /Math\.random\s*\(/, name: 'Math.random() — use random() instead (seeded)' },
88
- // External IO (breaks determinism)
89
- { pattern: /fetch\s*\(/, name: 'fetch() — external IO forbidden' },
90
- { pattern: /XMLHttpRequest/, name: 'XMLHttpRequest — external IO forbidden' },
91
- // Canvas is pre-initialized
92
- { pattern: /createCanvas\s*\(/, name: 'createCanvas() — canvas is pre-initialized' },
93
- // DOM manipulation forbidden
94
- { pattern: /document\./, name: 'DOM access — document.* forbidden' },
95
- { pattern: /window\./, name: 'DOM access — window.* forbidden' },
96
- // External imports forbidden
97
- { pattern: /\bimport\s+/, name: 'import — external imports forbidden' },
98
- { pattern: /\brequire\s*\(/, name: 'require() — external imports forbidden' },
99
- ];
100
- for (const { pattern, name } of forbiddenPatterns) {
101
- if (pattern.test(input.source)) {
102
- throw new Error(`[Code Mode Protocol Error] Forbidden pattern: ${name}`);
103
- }
104
- }
105
- // Loop mode specific validation
106
- if (input.mode === 'loop') {
107
- if (!/function\s+draw\s*\(\s*\)/.test(input.source)) {
108
- throw new Error('[Code Mode Protocol Error] Loop mode requires a draw() function');
109
- }
110
- if (/noLoop\s*\(\s*\)/.test(input.source)) {
111
- throw new Error('[Code Mode Protocol Error] noLoop() is forbidden in Loop mode');
112
- }
113
- }
114
- }
115
- /**
116
- * Create protocol metadata for the execution result
117
- */
118
- function createMetadata(input, vars) {
119
- return {
120
- ...PROTOCOL_IDENTITY,
121
- seed: input.seed,
122
- vars,
123
- width: input.width,
124
- height: input.height,
125
- mode: input.mode,
126
- ...(input.mode === 'loop' && input.totalFrames ? { totalFrames: input.totalFrames } : {}),
127
- };
128
- }
129
- /**
130
- * Execute Code Mode in Static mode - delegates to static-engine.ts
131
- */
132
- async function executeStatic(input, vars) {
133
- console.log('[CodeMode] Rendered via @nexart/codemode-sdk (Protocol v1.2.0)');
134
- console.log('[CodeMode] Execution: Static mode — delegating to static-engine');
135
- return new Promise((resolve, reject) => {
136
- runStaticMode({
137
- mode: 'static',
138
- width: input.width,
139
- height: input.height,
140
- }, {
141
- code: input.source,
142
- seed: input.seed,
143
- vars: vars,
144
- onComplete: (result) => {
145
- resolve({
146
- image: 'blob' in result ? result.blob : undefined,
147
- frames: 'imageData' in result ? [result.imageData] : undefined,
148
- metadata: createMetadata(input, vars),
149
- });
150
- },
151
- onError: (error) => {
152
- reject(error);
153
- },
154
- });
155
- });
156
- }
157
- /**
158
- * Execute Code Mode in Loop mode - delegates to loop-engine.ts
159
- */
160
- async function executeLoop(input, vars) {
161
- console.log('[CodeMode] Rendered via @nexart/codemode-sdk (Protocol v1.2.0)');
162
- console.log(`[CodeMode] Execution: Loop mode — delegating to loop-engine (${input.totalFrames} frames)`);
163
- const fps = DEFAULT_CONFIG.fps;
164
- const duration = (input.totalFrames || 60) / fps;
165
- return new Promise((resolve, reject) => {
166
- runLoopMode({
167
- mode: 'loop',
168
- width: input.width,
169
- height: input.height,
170
- duration: duration,
171
- fps: fps,
172
- }, {
173
- code: input.source,
174
- seed: input.seed,
175
- vars: vars,
176
- onComplete: (result) => {
177
- resolve({
178
- video: 'blob' in result && result.type === 'video' ? result.blob : undefined,
179
- metadata: createMetadata(input, vars),
180
- });
181
- },
182
- onError: (error) => {
183
- reject(error);
184
- },
185
- });
186
- });
187
- }
188
- /**
189
- * executeCodeMode — Canonical Code Mode Execution Entry Point
190
- *
191
- * This is the ONLY official way to execute Code Mode.
192
- * All implementations MUST use this function.
193
- *
194
- * @param input - Execution parameters
195
- * @returns Promise<ExecuteCodeModeResult> - Execution result with protocol metadata
196
- *
197
- * @example
198
- * ```typescript
199
- * const result = await executeCodeMode({
200
- * source: `function setup() { background(255); ellipse(width/2, height/2, 100); }`,
201
- * width: 1950,
202
- * height: 2400,
203
- * seed: 12345,
204
- * vars: [50, 75, 0, 0, 0, 0, 0, 0, 0, 0],
205
- * mode: 'static'
206
- * });
207
- *
208
- * console.log(result.metadata.protocolVersion); // '1.2.0'
209
- * console.log(result.image); // PNG Blob
210
- * ```
211
- */
212
- export async function executeCodeMode(input) {
213
- // Validate input
214
- validateInput(input);
215
- // Normalize VAR values
216
- const vars = normalizeVars(input.vars);
217
- // ╔═══════════════════════════════════════════════════════════════════════╗
218
- // ║ BUILDER MANIFEST CONTEXT (v1.6.0) ║
219
- // ║ ║
220
- // ║ Internal context for builder attribution. ║
221
- // ║ This is NOT exposed to sketch code, NOT serialized, NOT logged. ║
222
- // ║ Does NOT affect execution behavior or determinism. ║
223
- // ╚═══════════════════════════════════════════════════════════════════════╝
224
- const _executionContext = {
225
- builderManifest: getBuilderManifest(),
226
- };
227
- // Note: _executionContext is intentionally unused.
228
- // It prepares the SDK for future attribution without activating anything.
229
- void _executionContext;
230
- // Log protocol execution
231
- console.log('[CodeMode] ════════════════════════════════════════════════');
232
- console.log('[CodeMode] Protocol v1.2.0 — Phase 3 — HARD Enforcement');
233
- console.log(`[CodeMode] Mode: ${input.mode}`);
234
- console.log(`[CodeMode] Seed: ${input.seed}`);
235
- console.log(`[CodeMode] VAR: [${vars.join(', ')}]`);
236
- console.log('[CodeMode] ════════════════════════════════════════════════');
237
- // Execute based on mode
238
- if (input.mode === 'static') {
239
- return executeStatic(input, vars);
240
- }
241
- else {
242
- return executeLoop(input, vars);
243
- }
244
- }
245
- /**
246
- * Validate code without executing
247
- */
248
- export function validateCodeModeSource(source, mode) {
249
- const errors = [];
250
- // Same forbidden patterns as validateInput per CODE_MODE_PROTOCOL.md
251
- const forbiddenPatterns = [
252
- { pattern: /setTimeout\s*\(/, name: 'setTimeout' },
253
- { pattern: /setInterval\s*\(/, name: 'setInterval' },
254
- { pattern: /requestAnimationFrame\s*\(/, name: 'requestAnimationFrame' },
255
- { pattern: /Date\.now\s*\(/, name: 'Date.now() — use time variable instead' },
256
- { pattern: /new\s+Date\s*\(/, name: 'new Date() — use time variable instead' },
257
- { pattern: /Math\.random\s*\(/, name: 'Math.random() — use random() instead (seeded)' },
258
- { pattern: /fetch\s*\(/, name: 'fetch() — external IO forbidden' },
259
- { pattern: /XMLHttpRequest/, name: 'XMLHttpRequest — external IO forbidden' },
260
- { pattern: /createCanvas\s*\(/, name: 'createCanvas() — canvas is pre-initialized' },
261
- { pattern: /document\./, name: 'DOM access — document.* forbidden' },
262
- { pattern: /window\./, name: 'DOM access — window.* forbidden' },
263
- { pattern: /\bimport\s+/, name: 'import — external imports forbidden' },
264
- { pattern: /\brequire\s*\(/, name: 'require() — external imports forbidden' },
265
- ];
266
- for (const { pattern, name } of forbiddenPatterns) {
267
- if (pattern.test(source)) {
268
- errors.push(`Forbidden pattern: ${name}`);
269
- }
270
- }
271
- if (mode === 'loop') {
272
- if (!/function\s+draw\s*\(\s*\)/.test(source)) {
273
- errors.push('Loop mode requires a draw() function');
274
- }
275
- if (/noLoop\s*\(\s*\)/.test(source)) {
276
- errors.push('noLoop() is forbidden in Loop mode');
277
- }
278
- }
279
- return {
280
- valid: errors.length === 0,
281
- errors,
282
- };
283
- }