@nexart/codemode-sdk 1.6.0 → 1.7.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 (115) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +91 -5
  3. package/dist/core-index.d.ts +1 -1
  4. package/dist/core-index.js +1 -1
  5. package/dist/entry/browser.d.ts +37 -0
  6. package/dist/entry/browser.d.ts.map +1 -0
  7. package/dist/entry/browser.js +55 -0
  8. package/dist/entry/node.d.ts +21 -0
  9. package/dist/entry/node.d.ts.map +1 -0
  10. package/dist/entry/node.js +32 -0
  11. package/dist/index.d.ts +14 -33
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +41 -33
  14. package/dist/sdk/codemode/builder-manifest.d.ts +79 -0
  15. package/dist/sdk/codemode/builder-manifest.d.ts.map +1 -0
  16. package/dist/sdk/codemode/builder-manifest.js +97 -0
  17. package/dist/sdk/codemode/core-index.d.ts +21 -0
  18. package/dist/sdk/codemode/core-index.d.ts.map +1 -0
  19. package/dist/sdk/codemode/core-index.js +26 -0
  20. package/dist/sdk/codemode/engine.d.ts +24 -0
  21. package/dist/sdk/codemode/engine.d.ts.map +1 -0
  22. package/dist/sdk/codemode/engine.js +67 -0
  23. package/dist/sdk/codemode/execute.d.ts +46 -0
  24. package/dist/sdk/codemode/execute.d.ts.map +1 -0
  25. package/dist/sdk/codemode/execute.js +283 -0
  26. package/dist/sdk/codemode/execution-sandbox.d.ts +107 -0
  27. package/dist/sdk/codemode/execution-sandbox.d.ts.map +1 -0
  28. package/dist/sdk/codemode/execution-sandbox.js +207 -0
  29. package/dist/sdk/codemode/index.d.ts +31 -0
  30. package/dist/sdk/codemode/index.d.ts.map +1 -0
  31. package/dist/sdk/codemode/index.js +63 -0
  32. package/dist/sdk/codemode/loop-engine.d.ts +22 -0
  33. package/dist/sdk/codemode/loop-engine.d.ts.map +1 -0
  34. package/dist/sdk/codemode/loop-engine.js +229 -0
  35. package/dist/sdk/codemode/noise-bridge.d.ts +44 -0
  36. package/dist/sdk/codemode/noise-bridge.d.ts.map +1 -0
  37. package/dist/sdk/codemode/noise-bridge.js +68 -0
  38. package/dist/sdk/codemode/noise-engine.d.ts +74 -0
  39. package/dist/sdk/codemode/noise-engine.d.ts.map +1 -0
  40. package/dist/sdk/codemode/noise-engine.js +132 -0
  41. package/dist/sdk/codemode/noise-sketches/fractalNoise.d.ts +11 -0
  42. package/dist/sdk/codemode/noise-sketches/fractalNoise.d.ts.map +1 -0
  43. package/dist/sdk/codemode/noise-sketches/fractalNoise.js +121 -0
  44. package/dist/sdk/codemode/noise-sketches/index.d.ts +21 -0
  45. package/dist/sdk/codemode/noise-sketches/index.d.ts.map +1 -0
  46. package/dist/sdk/codemode/noise-sketches/index.js +28 -0
  47. package/dist/sdk/codemode/p5-runtime.d.ts +75 -0
  48. package/dist/sdk/codemode/p5-runtime.d.ts.map +1 -0
  49. package/dist/sdk/codemode/p5-runtime.js +1031 -0
  50. package/dist/sdk/codemode/sound-bridge.d.ts +89 -0
  51. package/dist/sdk/codemode/sound-bridge.d.ts.map +1 -0
  52. package/dist/sdk/codemode/sound-bridge.js +128 -0
  53. package/dist/sdk/codemode/soundart-engine.d.ts +87 -0
  54. package/dist/sdk/codemode/soundart-engine.d.ts.map +1 -0
  55. package/dist/sdk/codemode/soundart-engine.js +173 -0
  56. package/dist/sdk/codemode/soundart-sketches/chladniBloom.d.ts +3 -0
  57. package/dist/sdk/codemode/soundart-sketches/chladniBloom.d.ts.map +1 -0
  58. package/dist/sdk/codemode/soundart-sketches/chladniBloom.js +53 -0
  59. package/dist/sdk/codemode/soundart-sketches/dualVortex.d.ts +3 -0
  60. package/dist/sdk/codemode/soundart-sketches/dualVortex.d.ts.map +1 -0
  61. package/dist/sdk/codemode/soundart-sketches/dualVortex.js +67 -0
  62. package/dist/sdk/codemode/soundart-sketches/geometryIllusion.d.ts +3 -0
  63. package/dist/sdk/codemode/soundart-sketches/geometryIllusion.d.ts.map +1 -0
  64. package/dist/sdk/codemode/soundart-sketches/geometryIllusion.js +89 -0
  65. package/dist/sdk/codemode/soundart-sketches/index.d.ts +39 -0
  66. package/dist/sdk/codemode/soundart-sketches/index.d.ts.map +1 -0
  67. package/dist/sdk/codemode/soundart-sketches/index.js +72 -0
  68. package/dist/sdk/codemode/soundart-sketches/isoflow.d.ts +3 -0
  69. package/dist/sdk/codemode/soundart-sketches/isoflow.d.ts.map +1 -0
  70. package/dist/sdk/codemode/soundart-sketches/isoflow.js +60 -0
  71. package/dist/sdk/codemode/soundart-sketches/loomWeave.d.ts +3 -0
  72. package/dist/sdk/codemode/soundart-sketches/loomWeave.d.ts.map +1 -0
  73. package/dist/sdk/codemode/soundart-sketches/loomWeave.js +59 -0
  74. package/dist/sdk/codemode/soundart-sketches/noiseTerraces.d.ts +3 -0
  75. package/dist/sdk/codemode/soundart-sketches/noiseTerraces.d.ts.map +1 -0
  76. package/dist/sdk/codemode/soundart-sketches/noiseTerraces.js +53 -0
  77. package/dist/sdk/codemode/soundart-sketches/orb.d.ts +3 -0
  78. package/dist/sdk/codemode/soundart-sketches/orb.d.ts.map +1 -0
  79. package/dist/sdk/codemode/soundart-sketches/orb.js +50 -0
  80. package/dist/sdk/codemode/soundart-sketches/pixelGlyphs.d.ts +3 -0
  81. package/dist/sdk/codemode/soundart-sketches/pixelGlyphs.d.ts.map +1 -0
  82. package/dist/sdk/codemode/soundart-sketches/pixelGlyphs.js +72 -0
  83. package/dist/sdk/codemode/soundart-sketches/prismFlowFields.d.ts +3 -0
  84. package/dist/sdk/codemode/soundart-sketches/prismFlowFields.d.ts.map +1 -0
  85. package/dist/sdk/codemode/soundart-sketches/prismFlowFields.js +51 -0
  86. package/dist/sdk/codemode/soundart-sketches/radialBurst.d.ts +3 -0
  87. package/dist/sdk/codemode/soundart-sketches/radialBurst.d.ts.map +1 -0
  88. package/dist/sdk/codemode/soundart-sketches/radialBurst.js +60 -0
  89. package/dist/sdk/codemode/soundart-sketches/resonantSoundBodies.d.ts +3 -0
  90. package/dist/sdk/codemode/soundart-sketches/resonantSoundBodies.d.ts.map +1 -0
  91. package/dist/sdk/codemode/soundart-sketches/resonantSoundBodies.js +89 -0
  92. package/dist/sdk/codemode/soundart-sketches/rings.d.ts +11 -0
  93. package/dist/sdk/codemode/soundart-sketches/rings.d.ts.map +1 -0
  94. package/dist/sdk/codemode/soundart-sketches/rings.js +89 -0
  95. package/dist/sdk/codemode/soundart-sketches/squares.d.ts +3 -0
  96. package/dist/sdk/codemode/soundart-sketches/squares.d.ts.map +1 -0
  97. package/dist/sdk/codemode/soundart-sketches/squares.js +52 -0
  98. package/dist/sdk/codemode/soundart-sketches/waveStripes.d.ts +3 -0
  99. package/dist/sdk/codemode/soundart-sketches/waveStripes.d.ts.map +1 -0
  100. package/dist/sdk/codemode/soundart-sketches/waveStripes.js +44 -0
  101. package/dist/sdk/codemode/static-engine.d.ts +20 -0
  102. package/dist/sdk/codemode/static-engine.d.ts.map +1 -0
  103. package/dist/sdk/codemode/static-engine.js +144 -0
  104. package/dist/sdk/codemode/types.d.ts +191 -0
  105. package/dist/sdk/codemode/types.d.ts.map +1 -0
  106. package/dist/sdk/codemode/types.js +32 -0
  107. package/dist/shared/noiseSnapshot.d.ts +59 -0
  108. package/dist/shared/noiseSnapshot.d.ts.map +1 -0
  109. package/dist/shared/noiseSnapshot.js +72 -0
  110. package/dist/shared/soundSnapshot.d.ts +94 -0
  111. package/dist/shared/soundSnapshot.d.ts.map +1 -0
  112. package/dist/shared/soundSnapshot.js +128 -0
  113. package/dist/static-engine.d.ts.map +1 -1
  114. package/dist/static-engine.js +24 -11
  115. package/package.json +28 -4
@@ -0,0 +1,107 @@
1
+ /**
2
+ * NexArt Code Mode SDK - Execution Sandbox
3
+ * Version: 1.6.0 (Protocol v1.2.0)
4
+ *
5
+ * ╔══════════════════════════════════════════════════════════════════════════╗
6
+ * ║ EXECUTION BOUNDARY — HARD ENFORCEMENT ║
7
+ * ║ ║
8
+ * ║ This module enforces determinism by blocking all external entropy ║
9
+ * ║ sources at RUNTIME, not just via static pattern scanning. ║
10
+ * ║ ║
11
+ * ║ Blocked APIs (throw [Code Mode Protocol Error]): ║
12
+ * ║ - Date, Date.now, Date.parse, new Date() ║
13
+ * ║ - performance, performance.now ║
14
+ * ║ - process (Node.js) ║
15
+ * ║ - navigator ║
16
+ * ║ - globalThis ║
17
+ * ║ - crypto.getRandomValues ║
18
+ * ║ - Math.random (use seeded random() instead) ║
19
+ * ║ - setTimeout, setInterval, requestAnimationFrame ║
20
+ * ║ - fetch, XMLHttpRequest ║
21
+ * ║ - document, window ║
22
+ * ║ - import, require ║
23
+ * ║ ║
24
+ * ║ All blocked symbols throw immediately on access — no silent undefined. ║
25
+ * ╚══════════════════════════════════════════════════════════════════════════╝
26
+ */
27
+ /**
28
+ * Forbidden APIs - these are injected into the execution scope to override globals
29
+ */
30
+ export declare const FORBIDDEN_APIS: {
31
+ readonly Date: (...args: any[]) => never;
32
+ readonly performance: object;
33
+ readonly process: object;
34
+ readonly navigator: object;
35
+ readonly globalThis: object;
36
+ readonly crypto: object;
37
+ readonly setTimeout: (...args: any[]) => never;
38
+ readonly setInterval: (...args: any[]) => never;
39
+ readonly clearTimeout: (...args: any[]) => never;
40
+ readonly clearInterval: (...args: any[]) => never;
41
+ readonly requestAnimationFrame: (...args: any[]) => never;
42
+ readonly cancelAnimationFrame: (...args: any[]) => never;
43
+ readonly fetch: (...args: any[]) => never;
44
+ readonly XMLHttpRequest: (...args: any[]) => never;
45
+ readonly WebSocket: (...args: any[]) => never;
46
+ readonly document: object;
47
+ readonly window: object;
48
+ readonly self: object;
49
+ readonly top: object;
50
+ readonly parent: object;
51
+ readonly frames: object;
52
+ readonly location: object;
53
+ readonly history: object;
54
+ readonly localStorage: object;
55
+ readonly sessionStorage: object;
56
+ readonly indexedDB: object;
57
+ readonly caches: object;
58
+ readonly Notification: (...args: any[]) => never;
59
+ readonly Worker: (...args: any[]) => never;
60
+ readonly SharedWorker: (...args: any[]) => never;
61
+ readonly ServiceWorker: object;
62
+ readonly Blob: (...args: any[]) => never;
63
+ readonly File: (...args: any[]) => never;
64
+ readonly FileReader: (...args: any[]) => never;
65
+ readonly URL: (...args: any[]) => never;
66
+ readonly URLSearchParams: (...args: any[]) => never;
67
+ readonly Headers: (...args: any[]) => never;
68
+ readonly Request: (...args: any[]) => never;
69
+ readonly Response: (...args: any[]) => never;
70
+ readonly EventSource: (...args: any[]) => never;
71
+ readonly Image: (...args: any[]) => never;
72
+ readonly Audio: (...args: any[]) => never;
73
+ readonly Video: (...args: any[]) => never;
74
+ readonly eval: (...args: any[]) => never;
75
+ readonly Function: (...args: any[]) => never;
76
+ };
77
+ /**
78
+ * Create a safe Math object with random() blocked
79
+ */
80
+ export declare function createSafeMath(): typeof Math;
81
+ /**
82
+ * List of all forbidden API names for documentation
83
+ */
84
+ export declare const FORBIDDEN_API_NAMES: string[];
85
+ /**
86
+ * Build the complete sandbox context for sketch execution.
87
+ * This includes the p5 runtime plus all forbidden API stubs.
88
+ */
89
+ export declare function buildSandboxContext(p5Runtime: Record<string, any>): Record<string, any>;
90
+ /**
91
+ * Create a sandboxed function that executes user code with blocked globals.
92
+ *
93
+ * The function is constructed with:
94
+ * 1. All forbidden APIs as explicit parameters (override globals)
95
+ * 2. The p5 runtime as explicit parameters
96
+ * 3. A `with(context)` wrapper for additional safety
97
+ */
98
+ export declare function createSandboxedExecutor(code: string, additionalParams?: string[]): Function;
99
+ /**
100
+ * Execute user code in a sandboxed environment.
101
+ *
102
+ * @param code - The user sketch code to execute
103
+ * @param p5Runtime - The p5-like runtime object
104
+ * @param additionalContext - Additional context variables (frameCount, t, etc.)
105
+ */
106
+ export declare function executeSandboxed(code: string, p5Runtime: Record<string, any>, additionalContext?: Record<string, any>): void;
107
+ //# sourceMappingURL=execution-sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-sandbox.d.ts","sourceRoot":"","sources":["../../../execution-sandbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAyDH;;GAEG;AACH,eAAO,MAAM,cAAc;6BAvD2B,GAAG,EAAE,KAAK,KAAK;;;;;;mCAAf,GAAG,EAAE,KAAK,KAAK;oCAAf,GAAG,EAAE,KAAK,KAAK;qCAAf,GAAG,EAAE,KAAK,KAAK;sCAAf,GAAG,EAAE,KAAK,KAAK;8CAAf,GAAG,EAAE,KAAK,KAAK;6CAAf,GAAG,EAAE,KAAK,KAAK;8BAAf,GAAG,EAAE,KAAK,KAAK;uCAAf,GAAG,EAAE,KAAK,KAAK;kCAAf,GAAG,EAAE,KAAK,KAAK;;;;;;;;;;;;;qCAAf,GAAG,EAAE,KAAK,KAAK;+BAAf,GAAG,EAAE,KAAK,KAAK;qCAAf,GAAG,EAAE,KAAK,KAAK;;6BAAf,GAAG,EAAE,KAAK,KAAK;6BAAf,GAAG,EAAE,KAAK,KAAK;mCAAf,GAAG,EAAE,KAAK,KAAK;4BAAf,GAAG,EAAE,KAAK,KAAK;wCAAf,GAAG,EAAE,KAAK,KAAK;gCAAf,GAAG,EAAE,KAAK,KAAK;gCAAf,GAAG,EAAE,KAAK,KAAK;iCAAf,GAAG,EAAE,KAAK,KAAK;oCAAf,GAAG,EAAE,KAAK,KAAK;8BAAf,GAAG,EAAE,KAAK,KAAK;8BAAf,GAAG,EAAE,KAAK,KAAK;8BAAf,GAAG,EAAE,KAAK,KAAK;6BAAf,GAAG,EAAE,KAAK,KAAK;iCAAf,GAAG,EAAE,KAAK,KAAK;CAqG3D,CAAC;AAEX;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,IAAI,CAU5C;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,UAA8B,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAavF;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,gBAAgB,GAAE,MAAM,EAAO,GAC9B,QAAQ,CAiBV;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC9B,iBAAiB,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAC1C,IAAI,CAsBN"}
@@ -0,0 +1,207 @@
1
+ /**
2
+ * NexArt Code Mode SDK - Execution Sandbox
3
+ * Version: 1.6.0 (Protocol v1.2.0)
4
+ *
5
+ * ╔══════════════════════════════════════════════════════════════════════════╗
6
+ * ║ EXECUTION BOUNDARY — HARD ENFORCEMENT ║
7
+ * ║ ║
8
+ * ║ This module enforces determinism by blocking all external entropy ║
9
+ * ║ sources at RUNTIME, not just via static pattern scanning. ║
10
+ * ║ ║
11
+ * ║ Blocked APIs (throw [Code Mode Protocol Error]): ║
12
+ * ║ - Date, Date.now, Date.parse, new Date() ║
13
+ * ║ - performance, performance.now ║
14
+ * ║ - process (Node.js) ║
15
+ * ║ - navigator ║
16
+ * ║ - globalThis ║
17
+ * ║ - crypto.getRandomValues ║
18
+ * ║ - Math.random (use seeded random() instead) ║
19
+ * ║ - setTimeout, setInterval, requestAnimationFrame ║
20
+ * ║ - fetch, XMLHttpRequest ║
21
+ * ║ - document, window ║
22
+ * ║ - import, require ║
23
+ * ║ ║
24
+ * ║ All blocked symbols throw immediately on access — no silent undefined. ║
25
+ * ╚══════════════════════════════════════════════════════════════════════════╝
26
+ */
27
+ /**
28
+ * Create a throwing stub for a forbidden API
29
+ */
30
+ function createForbiddenStub(name) {
31
+ const stub = function () {
32
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name}`);
33
+ };
34
+ return new Proxy(stub, {
35
+ get(_target, prop) {
36
+ if (prop === Symbol.toPrimitive || prop === 'toString' || prop === 'valueOf') {
37
+ return () => { throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name}`); };
38
+ }
39
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name}.${String(prop)}`);
40
+ },
41
+ apply() {
42
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name}()`);
43
+ },
44
+ construct() {
45
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: new ${name}()`);
46
+ },
47
+ set() {
48
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name} (assignment blocked)`);
49
+ },
50
+ has() {
51
+ return true;
52
+ }
53
+ });
54
+ }
55
+ /**
56
+ * Create a frozen object that throws on any property access
57
+ */
58
+ function createForbiddenObject(name) {
59
+ return new Proxy({}, {
60
+ get(_target, prop) {
61
+ if (prop === Symbol.toPrimitive || prop === 'toString' || prop === 'valueOf') {
62
+ return () => { throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name}`); };
63
+ }
64
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name}.${String(prop)}`);
65
+ },
66
+ set() {
67
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name} (assignment blocked)`);
68
+ },
69
+ has() {
70
+ return true;
71
+ },
72
+ apply() {
73
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: ${name}()`);
74
+ },
75
+ construct() {
76
+ throw new Error(`[Code Mode Protocol Error] Forbidden API: new ${name}()`);
77
+ }
78
+ });
79
+ }
80
+ /**
81
+ * Forbidden APIs - these are injected into the execution scope to override globals
82
+ */
83
+ export const FORBIDDEN_APIS = {
84
+ Date: createForbiddenStub('Date'),
85
+ performance: createForbiddenObject('performance'),
86
+ process: createForbiddenObject('process'),
87
+ navigator: createForbiddenObject('navigator'),
88
+ globalThis: createForbiddenObject('globalThis'),
89
+ crypto: createForbiddenObject('crypto'),
90
+ setTimeout: createForbiddenStub('setTimeout'),
91
+ setInterval: createForbiddenStub('setInterval'),
92
+ clearTimeout: createForbiddenStub('clearTimeout'),
93
+ clearInterval: createForbiddenStub('clearInterval'),
94
+ requestAnimationFrame: createForbiddenStub('requestAnimationFrame'),
95
+ cancelAnimationFrame: createForbiddenStub('cancelAnimationFrame'),
96
+ fetch: createForbiddenStub('fetch'),
97
+ XMLHttpRequest: createForbiddenStub('XMLHttpRequest'),
98
+ WebSocket: createForbiddenStub('WebSocket'),
99
+ document: createForbiddenObject('document'),
100
+ window: createForbiddenObject('window'),
101
+ self: createForbiddenObject('self'),
102
+ top: createForbiddenObject('top'),
103
+ parent: createForbiddenObject('parent'),
104
+ frames: createForbiddenObject('frames'),
105
+ location: createForbiddenObject('location'),
106
+ history: createForbiddenObject('history'),
107
+ localStorage: createForbiddenObject('localStorage'),
108
+ sessionStorage: createForbiddenObject('sessionStorage'),
109
+ indexedDB: createForbiddenObject('indexedDB'),
110
+ caches: createForbiddenObject('caches'),
111
+ Notification: createForbiddenStub('Notification'),
112
+ Worker: createForbiddenStub('Worker'),
113
+ SharedWorker: createForbiddenStub('SharedWorker'),
114
+ ServiceWorker: createForbiddenObject('ServiceWorker'),
115
+ Blob: createForbiddenStub('Blob'),
116
+ File: createForbiddenStub('File'),
117
+ FileReader: createForbiddenStub('FileReader'),
118
+ URL: createForbiddenStub('URL'),
119
+ URLSearchParams: createForbiddenStub('URLSearchParams'),
120
+ Headers: createForbiddenStub('Headers'),
121
+ Request: createForbiddenStub('Request'),
122
+ Response: createForbiddenStub('Response'),
123
+ EventSource: createForbiddenStub('EventSource'),
124
+ Image: createForbiddenStub('Image'),
125
+ Audio: createForbiddenStub('Audio'),
126
+ Video: createForbiddenStub('Video'),
127
+ eval: createForbiddenStub('eval'),
128
+ Function: createForbiddenStub('Function'),
129
+ };
130
+ /**
131
+ * Create a safe Math object with random() blocked
132
+ */
133
+ export function createSafeMath() {
134
+ const safeMath = Object.create(Math);
135
+ Object.defineProperty(safeMath, 'random', {
136
+ get() {
137
+ throw new Error('[Code Mode Protocol Error] Forbidden API: Math.random() — use random() instead (seeded)');
138
+ },
139
+ configurable: false,
140
+ enumerable: true
141
+ });
142
+ return Object.freeze(safeMath);
143
+ }
144
+ /**
145
+ * List of all forbidden API names for documentation
146
+ */
147
+ export const FORBIDDEN_API_NAMES = Object.keys(FORBIDDEN_APIS);
148
+ /**
149
+ * Build the complete sandbox context for sketch execution.
150
+ * This includes the p5 runtime plus all forbidden API stubs.
151
+ */
152
+ export function buildSandboxContext(p5Runtime) {
153
+ const safeMath = createSafeMath();
154
+ const context = {
155
+ ...FORBIDDEN_APIS,
156
+ Math: safeMath,
157
+ };
158
+ for (const key of Object.keys(p5Runtime)) {
159
+ context[key] = p5Runtime[key];
160
+ }
161
+ return context;
162
+ }
163
+ /**
164
+ * Create a sandboxed function that executes user code with blocked globals.
165
+ *
166
+ * The function is constructed with:
167
+ * 1. All forbidden APIs as explicit parameters (override globals)
168
+ * 2. The p5 runtime as explicit parameters
169
+ * 3. A `with(context)` wrapper for additional safety
170
+ */
171
+ export function createSandboxedExecutor(code, additionalParams = []) {
172
+ const forbiddenParamNames = Object.keys(FORBIDDEN_APIS);
173
+ const allParams = [
174
+ 'context',
175
+ 'Math',
176
+ ...forbiddenParamNames,
177
+ ...additionalParams
178
+ ];
179
+ const wrappedCode = `
180
+ "use strict";
181
+ with(context) {
182
+ ${code}
183
+ }
184
+ `;
185
+ return new Function(...allParams, wrappedCode);
186
+ }
187
+ /**
188
+ * Execute user code in a sandboxed environment.
189
+ *
190
+ * @param code - The user sketch code to execute
191
+ * @param p5Runtime - The p5-like runtime object
192
+ * @param additionalContext - Additional context variables (frameCount, t, etc.)
193
+ */
194
+ export function executeSandboxed(code, p5Runtime, additionalContext = {}) {
195
+ const safeMath = createSafeMath();
196
+ const fullContext = {
197
+ ...p5Runtime,
198
+ ...additionalContext,
199
+ Math: safeMath,
200
+ ...FORBIDDEN_APIS,
201
+ };
202
+ const forbiddenValues = Object.keys(FORBIDDEN_APIS).map(key => FORBIDDEN_APIS[key]);
203
+ const additionalParamNames = Object.keys(additionalContext);
204
+ const additionalValues = Object.values(additionalContext);
205
+ const executor = createSandboxedExecutor(code, additionalParamNames);
206
+ executor(fullContext, safeMath, ...forbiddenValues, ...additionalValues);
207
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * NexArt Code Mode Runtime SDK - App Integration Layer
3
+ *
4
+ * ╔══════════════════════════════════════════════════════════════════════════╗
5
+ * ║ LOCAL SDK WRAPPER ║
6
+ * ║ ║
7
+ * ║ This file re-exports the core runtime from @nexart/codemode-sdk (npm) ║
8
+ * ║ and adds app-specific integrations (SoundArt, Noise, etc.) ║
9
+ * ║ ║
10
+ * ║ For core Code Mode: import from '@nexart/codemode-sdk' ║
11
+ * ║ For app integrations: import from 'sdk/codemode' ║
12
+ * ╚══════════════════════════════════════════════════════════════════════════╝
13
+ */
14
+ export { executeCodeMode, validateCodeModeSource, DEFAULT_CONFIG, PROTOCOL_IDENTITY, } from '@nexart/codemode-sdk';
15
+ export type { ExecuteCodeModeInput, ExecuteCodeModeResult, ProtocolMetadata, RenderResult, TimeVariables, } from '@nexart/codemode-sdk';
16
+ export { createP5Runtime, injectTimeVariables, injectProtocolVariables, createProtocolVAR } from './p5-runtime';
17
+ export type { P5Runtime, P5RuntimeConfig } from './p5-runtime';
18
+ export { createEngine } from './engine';
19
+ export type { Engine, EngineConfig, RunOptions, ProgressInfo, RenderMode, } from './types';
20
+ export { DEFAULT_CONFIG as LOCAL_DEFAULT_CONFIG } from './types';
21
+ export { renderSoundArtViaCodeMode, canRenderViaCodeMode, getCodeModeAvailableStyles, type SoundArtEngineConfig, type SoundArtRenderOptions, type SoundArtRenderResult, type SoundArtMetadata, } from './soundart-engine';
22
+ export { type SoundSnapshot, type SoundFeatures, createSoundSnapshot, createEmptySoundSnapshot, freezeSoundSnapshot, } from '../../shared/soundSnapshot';
23
+ export { injectSoundGlobals, createSoundGlobals, createEmptySoundGlobals, generateSoundPalette, inferGenreProfile, createSoundHelpers, type SoundGlobals, type GenreProfile, } from './sound-bridge';
24
+ export { getSoundArtSketch, getAvailableSoundArtSketches, isSoundArtSketchAvailable, type SoundArtSketchName, } from './soundart-sketches';
25
+ export { renderNoiseViaCodeMode, compileNoiseSystem, canRenderNoiseViaCodeMode, type NoiseEngineConfig, type NoiseRenderOptions, type NoiseRenderResult, type NoiseMetadata, } from './noise-engine';
26
+ export { type NoiseSnapshot, type NoiseParams, type NoiseBlendMode, createNoiseSnapshot, validateNoiseSnapshot, } from '../../shared/noiseSnapshot';
27
+ export { createNoiseGlobals, injectNoiseGlobals, type NoiseGlobals, } from './noise-bridge';
28
+ export { getNoiseSketch, getAvailableNoiseSketchNames, isValidNoiseSketch, type NoiseSketchName, } from './noise-sketches';
29
+ export { registerBuilderManifest } from './builder-manifest';
30
+ export type { NexArtBuilderManifest } from './types';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAKH,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACd,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAChH,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACV,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,cAAc,IAAI,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAGjE,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,4BAA4B,EAC5B,yBAAyB,EACzB,KAAK,kBAAkB,GACxB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,YAAY,GAClB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,kBAAkB,EAClB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAkB1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,YAAY,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * NexArt Code Mode Runtime SDK - App Integration Layer
3
+ *
4
+ * ╔══════════════════════════════════════════════════════════════════════════╗
5
+ * ║ LOCAL SDK WRAPPER ║
6
+ * ║ ║
7
+ * ║ This file re-exports the core runtime from @nexart/codemode-sdk (npm) ║
8
+ * ║ and adds app-specific integrations (SoundArt, Noise, etc.) ║
9
+ * ║ ║
10
+ * ║ For core Code Mode: import from '@nexart/codemode-sdk' ║
11
+ * ║ For app integrations: import from 'sdk/codemode' ║
12
+ * ╚══════════════════════════════════════════════════════════════════════════╝
13
+ */
14
+ // ═══════════════════════════════════════════════════════════════════════════
15
+ // CORE RUNTIME - Re-exported from @nexart/codemode-sdk (npm package)
16
+ // ═══════════════════════════════════════════════════════════════════════════
17
+ export { executeCodeMode, validateCodeModeSource, DEFAULT_CONFIG, PROTOCOL_IDENTITY, } from '@nexart/codemode-sdk';
18
+ // ═══════════════════════════════════════════════════════════════════════════
19
+ // LOCAL P5 RUNTIME - Used by app integrations (SoundArt, Noise)
20
+ // The npm package also exports createP5Runtime, but we keep local for
21
+ // app-specific extensions that need tighter integration
22
+ // ═══════════════════════════════════════════════════════════════════════════
23
+ export { createP5Runtime, injectTimeVariables, injectProtocolVariables, createProtocolVAR } from './p5-runtime';
24
+ // ═══════════════════════════════════════════════════════════════════════════
25
+ // LEGACY ENGINE API (kept for backwards compatibility)
26
+ // ═══════════════════════════════════════════════════════════════════════════
27
+ export { createEngine } from './engine';
28
+ export { DEFAULT_CONFIG as LOCAL_DEFAULT_CONFIG } from './types';
29
+ // SoundArt → Code Mode integration
30
+ export { renderSoundArtViaCodeMode, canRenderViaCodeMode, getCodeModeAvailableStyles, } from './soundart-engine';
31
+ export { createSoundSnapshot, createEmptySoundSnapshot, freezeSoundSnapshot, } from '../../shared/soundSnapshot';
32
+ export { injectSoundGlobals, createSoundGlobals, createEmptySoundGlobals, generateSoundPalette, inferGenreProfile, createSoundHelpers, } from './sound-bridge';
33
+ export { getSoundArtSketch, getAvailableSoundArtSketches, isSoundArtSketchAvailable, } from './soundart-sketches';
34
+ // Noise → Code Mode integration
35
+ export { renderNoiseViaCodeMode, compileNoiseSystem, canRenderNoiseViaCodeMode, } from './noise-engine';
36
+ export { createNoiseSnapshot, validateNoiseSnapshot, } from '../../shared/noiseSnapshot';
37
+ export { createNoiseGlobals, injectNoiseGlobals, } from './noise-bridge';
38
+ export { getNoiseSketch, getAvailableNoiseSketchNames, isValidNoiseSketch, } from './noise-sketches';
39
+ // ═══════════════════════════════════════════════════════════════════════════
40
+ // BUILDER MANIFEST (v1.6.0) — Passive Attribution
41
+ //
42
+ // The Builder Manifest is a declaration of intent, not a capability.
43
+ // The SDK does not expose any API to read or inspect manifests.
44
+ //
45
+ // This is:
46
+ // - Declarative (write-only)
47
+ // - Optional (no errors if missing)
48
+ // - Non-enforced (no validation)
49
+ // - Non-rewarding (no incentives)
50
+ //
51
+ // There is NO SDK API to read manifests, NO validation, NO attribution
52
+ // logic, and NO tracking. Execution behavior is identical with or without
53
+ // a manifest registered.
54
+ // ═══════════════════════════════════════════════════════════════════════════
55
+ export { registerBuilderManifest } from './builder-manifest';
56
+ // ═══════════════════════════════════════════════════════════════════════════
57
+ // EXECUTION BOUNDARY (Internal — Not Exported)
58
+ //
59
+ // The execution sandbox blocks all external entropy sources at runtime.
60
+ // See EXECUTION_BOUNDARY.md for details.
61
+ // ═══════════════════════════════════════════════════════════════════════════
62
+ // Note: FORBIDDEN_APIS and createSafeMath are NOT exported.
63
+ // They are internal implementation details used by the engines.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * NexArt Code Mode Runtime SDK - Loop Engine
3
+ * Protocol: v1.2.0 (Phase 3) — HARD ENFORCEMENT
4
+ *
5
+ * Loop mode renderer: frame-authoritative, stateless execution.
6
+ * - Executes setup() once
7
+ * - Executes draw() once per frame
8
+ * - Clears canvas before each frame (transparent)
9
+ * - Resets blend mode to NORMAL before each frame
10
+ * - Injects normalized time variables
11
+ * - No canvas persistence between frames
12
+ *
13
+ * Determinism Guarantee:
14
+ * Same code + same seed + same VARs = identical frame sequence
15
+ *
16
+ * Security:
17
+ * All external entropy sources are blocked at runtime via execution sandbox.
18
+ */
19
+ import type { EngineConfig, RunOptions } from './types';
20
+ export declare function cancelLoopMode(): void;
21
+ export declare function runLoopMode(config: EngineConfig, options: RunOptions): Promise<void>;
22
+ //# sourceMappingURL=loop-engine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop-engine.d.ts","sourceRoot":"","sources":["../../../loop-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAA+B,MAAM,SAAS,CAAC;AAOrF,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CA+Mf"}