@nexart/codemode-sdk 1.8.1 → 1.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -1
- package/COMMERCIAL.md +25 -23
- package/LICENSE.md +10 -41
- package/README.md +82 -11
- package/dist/sdk/codemode/core-index.d.ts +6 -4
- package/dist/sdk/codemode/core-index.d.ts.map +1 -1
- package/dist/sdk/codemode/core-index.js +6 -4
- package/dist/{entry → sdk/codemode/entry}/browser.d.ts +5 -2
- package/dist/sdk/codemode/entry/browser.d.ts.map +1 -0
- package/dist/{entry → sdk/codemode/entry}/browser.js +10 -4
- package/dist/{entry → sdk/codemode/entry}/node.d.ts +2 -1
- package/dist/sdk/codemode/entry/node.d.ts.map +1 -0
- package/dist/{entry → sdk/codemode/entry}/node.js +2 -1
- package/dist/sdk/codemode/p5-runtime.d.ts +3 -2
- package/dist/sdk/codemode/p5-runtime.d.ts.map +1 -1
- package/dist/sdk/codemode/p5-runtime.js +6 -4
- package/dist/{runtime.d.ts → sdk/codemode/runtime.d.ts} +2 -2
- package/dist/sdk/codemode/runtime.d.ts.map +1 -0
- package/dist/{runtime.js → sdk/codemode/runtime.js} +3 -2
- package/dist/sdk/codemode/static-engine.d.ts.map +1 -1
- package/dist/sdk/codemode/static-engine.js +24 -11
- package/dist/sdk/codemode/types.d.ts +2 -1
- package/dist/sdk/codemode/types.d.ts.map +1 -1
- package/dist/sdk/codemode/types.js +5 -3
- package/dist/sdk/codemode/version.d.ts +18 -0
- package/dist/sdk/codemode/version.d.ts.map +1 -0
- package/dist/sdk/codemode/version.js +17 -0
- package/examples/agent-quickstart.ts +159 -0
- package/examples/preflight-test.ts +1 -1
- package/package.json +2 -1
- package/dist/builder-manifest.d.ts +0 -79
- package/dist/builder-manifest.d.ts.map +0 -1
- package/dist/builder-manifest.js +0 -97
- package/dist/core-index.d.ts +0 -21
- package/dist/core-index.d.ts.map +0 -1
- package/dist/core-index.js +0 -26
- package/dist/engine.d.ts +0 -24
- package/dist/engine.d.ts.map +0 -1
- package/dist/engine.js +0 -67
- package/dist/entry/browser.d.ts.map +0 -1
- package/dist/entry/node.d.ts.map +0 -1
- package/dist/execute.d.ts +0 -46
- package/dist/execute.d.ts.map +0 -1
- package/dist/execute.js +0 -283
- package/dist/execution-sandbox.d.ts +0 -107
- package/dist/execution-sandbox.d.ts.map +0 -1
- package/dist/execution-sandbox.js +0 -207
- package/dist/index.d.ts +0 -31
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -63
- package/dist/loop-engine.d.ts +0 -22
- package/dist/loop-engine.d.ts.map +0 -1
- package/dist/loop-engine.js +0 -229
- package/dist/noise-bridge.d.ts +0 -44
- package/dist/noise-bridge.d.ts.map +0 -1
- package/dist/noise-bridge.js +0 -68
- package/dist/noise-engine.d.ts +0 -74
- package/dist/noise-engine.d.ts.map +0 -1
- package/dist/noise-engine.js +0 -132
- package/dist/noise-sketches/fractalNoise.d.ts +0 -11
- package/dist/noise-sketches/fractalNoise.d.ts.map +0 -1
- package/dist/noise-sketches/fractalNoise.js +0 -121
- package/dist/noise-sketches/index.d.ts +0 -21
- package/dist/noise-sketches/index.d.ts.map +0 -1
- package/dist/noise-sketches/index.js +0 -28
- package/dist/p5-runtime.d.ts +0 -75
- package/dist/p5-runtime.d.ts.map +0 -1
- package/dist/p5-runtime.js +0 -1031
- package/dist/runtime.d.ts.map +0 -1
- package/dist/sdk/codemode/index.d.ts +0 -31
- package/dist/sdk/codemode/index.d.ts.map +0 -1
- package/dist/sdk/codemode/index.js +0 -63
- package/dist/sdk/codemode/noise-bridge.d.ts +0 -44
- package/dist/sdk/codemode/noise-bridge.d.ts.map +0 -1
- package/dist/sdk/codemode/noise-bridge.js +0 -68
- package/dist/sdk/codemode/noise-engine.d.ts +0 -74
- package/dist/sdk/codemode/noise-engine.d.ts.map +0 -1
- package/dist/sdk/codemode/noise-engine.js +0 -132
- package/dist/sdk/codemode/noise-sketches/fractalNoise.d.ts +0 -11
- package/dist/sdk/codemode/noise-sketches/fractalNoise.d.ts.map +0 -1
- package/dist/sdk/codemode/noise-sketches/fractalNoise.js +0 -121
- package/dist/sdk/codemode/noise-sketches/index.d.ts +0 -21
- package/dist/sdk/codemode/noise-sketches/index.d.ts.map +0 -1
- package/dist/sdk/codemode/noise-sketches/index.js +0 -28
- package/dist/shared/noiseSnapshot.d.ts +0 -59
- package/dist/shared/noiseSnapshot.d.ts.map +0 -1
- package/dist/shared/noiseSnapshot.js +0 -72
- package/dist/sound-bridge.d.ts +0 -89
- package/dist/sound-bridge.d.ts.map +0 -1
- package/dist/sound-bridge.js +0 -128
- package/dist/soundart-engine.d.ts +0 -87
- package/dist/soundart-engine.d.ts.map +0 -1
- package/dist/soundart-engine.js +0 -173
- package/dist/soundart-sketches/chladniBloom.d.ts +0 -3
- package/dist/soundart-sketches/chladniBloom.d.ts.map +0 -1
- package/dist/soundart-sketches/chladniBloom.js +0 -53
- package/dist/soundart-sketches/dualVortex.d.ts +0 -3
- package/dist/soundart-sketches/dualVortex.d.ts.map +0 -1
- package/dist/soundart-sketches/dualVortex.js +0 -67
- package/dist/soundart-sketches/geometryIllusion.d.ts +0 -3
- package/dist/soundart-sketches/geometryIllusion.d.ts.map +0 -1
- package/dist/soundart-sketches/geometryIllusion.js +0 -89
- package/dist/soundart-sketches/index.d.ts +0 -39
- package/dist/soundart-sketches/index.d.ts.map +0 -1
- package/dist/soundart-sketches/index.js +0 -72
- package/dist/soundart-sketches/isoflow.d.ts +0 -3
- package/dist/soundart-sketches/isoflow.d.ts.map +0 -1
- package/dist/soundart-sketches/isoflow.js +0 -60
- package/dist/soundart-sketches/loomWeave.d.ts +0 -3
- package/dist/soundart-sketches/loomWeave.d.ts.map +0 -1
- package/dist/soundart-sketches/loomWeave.js +0 -59
- package/dist/soundart-sketches/noiseTerraces.d.ts +0 -3
- package/dist/soundart-sketches/noiseTerraces.d.ts.map +0 -1
- package/dist/soundart-sketches/noiseTerraces.js +0 -53
- package/dist/soundart-sketches/orb.d.ts +0 -3
- package/dist/soundart-sketches/orb.d.ts.map +0 -1
- package/dist/soundart-sketches/orb.js +0 -50
- package/dist/soundart-sketches/pixelGlyphs.d.ts +0 -3
- package/dist/soundart-sketches/pixelGlyphs.d.ts.map +0 -1
- package/dist/soundart-sketches/pixelGlyphs.js +0 -72
- package/dist/soundart-sketches/prismFlowFields.d.ts +0 -3
- package/dist/soundart-sketches/prismFlowFields.d.ts.map +0 -1
- package/dist/soundart-sketches/prismFlowFields.js +0 -51
- package/dist/soundart-sketches/radialBurst.d.ts +0 -3
- package/dist/soundart-sketches/radialBurst.d.ts.map +0 -1
- package/dist/soundart-sketches/radialBurst.js +0 -60
- package/dist/soundart-sketches/resonantSoundBodies.d.ts +0 -3
- package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +0 -1
- package/dist/soundart-sketches/resonantSoundBodies.js +0 -89
- package/dist/soundart-sketches/rings.d.ts +0 -11
- package/dist/soundart-sketches/rings.d.ts.map +0 -1
- package/dist/soundart-sketches/rings.js +0 -89
- package/dist/soundart-sketches/squares.d.ts +0 -3
- package/dist/soundart-sketches/squares.d.ts.map +0 -1
- package/dist/soundart-sketches/squares.js +0 -52
- package/dist/soundart-sketches/waveStripes.d.ts +0 -3
- package/dist/soundart-sketches/waveStripes.d.ts.map +0 -1
- package/dist/soundart-sketches/waveStripes.js +0 -44
- package/dist/static-engine.d.ts +0 -20
- package/dist/static-engine.d.ts.map +0 -1
- package/dist/static-engine.js +0 -157
- package/dist/types.d.ts +0 -191
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -32
|
@@ -1,207 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
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
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/index.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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.
|
package/dist/loop-engine.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/loop-engine.js
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
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 { DEFAULT_CONFIG } from './types';
|
|
20
|
-
import { createP5Runtime, injectProtocolVariables } from './p5-runtime';
|
|
21
|
-
import { FORBIDDEN_APIS, createSafeMath } from './execution-sandbox';
|
|
22
|
-
let isCancelled = false;
|
|
23
|
-
export function cancelLoopMode() {
|
|
24
|
-
isCancelled = true;
|
|
25
|
-
}
|
|
26
|
-
export async function runLoopMode(config, options) {
|
|
27
|
-
const { code, seed, vars, onPreview, onProgress, onComplete, onError } = options;
|
|
28
|
-
const width = config.width ?? DEFAULT_CONFIG.width;
|
|
29
|
-
const height = config.height ?? DEFAULT_CONFIG.height;
|
|
30
|
-
const duration = Math.max(DEFAULT_CONFIG.minDuration, Math.min(DEFAULT_CONFIG.maxDuration, config.duration ?? DEFAULT_CONFIG.duration));
|
|
31
|
-
const fps = config.fps ?? DEFAULT_CONFIG.fps;
|
|
32
|
-
const totalFrames = Math.floor(duration * fps);
|
|
33
|
-
isCancelled = false;
|
|
34
|
-
try {
|
|
35
|
-
onProgress?.({
|
|
36
|
-
phase: 'setup',
|
|
37
|
-
percent: 0,
|
|
38
|
-
message: 'Initializing canvas...',
|
|
39
|
-
});
|
|
40
|
-
// Create canvas
|
|
41
|
-
const canvas = document.createElement('canvas');
|
|
42
|
-
canvas.width = width;
|
|
43
|
-
canvas.height = height;
|
|
44
|
-
// Create p5 runtime with optional seed for determinism
|
|
45
|
-
const p = createP5Runtime(canvas, width, height, { seed });
|
|
46
|
-
// Inject protocol variables (VAR[0..9])
|
|
47
|
-
injectProtocolVariables(p, vars);
|
|
48
|
-
// Validate code
|
|
49
|
-
const hasDrawFunction = /function\s+draw\s*\(\s*\)/.test(code);
|
|
50
|
-
if (!hasDrawFunction) {
|
|
51
|
-
throw new Error('Loop Mode requires a draw() function.');
|
|
52
|
-
}
|
|
53
|
-
const forbiddenPatterns = [
|
|
54
|
-
{ pattern: /noLoop\s*\(\s*\)/, name: 'noLoop()' },
|
|
55
|
-
{ pattern: /setTimeout\s*\(/, name: 'setTimeout' },
|
|
56
|
-
{ pattern: /setInterval\s*\(/, name: 'setInterval' },
|
|
57
|
-
{ pattern: /requestAnimationFrame\s*\(/, name: 'requestAnimationFrame' },
|
|
58
|
-
];
|
|
59
|
-
for (const { pattern, name } of forbiddenPatterns) {
|
|
60
|
-
if (pattern.test(code)) {
|
|
61
|
-
throw new Error(`Forbidden function in Loop Mode: ${name}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
onProgress?.({
|
|
65
|
-
phase: 'setup',
|
|
66
|
-
percent: 5,
|
|
67
|
-
message: 'Parsing code...',
|
|
68
|
-
});
|
|
69
|
-
// Extract setup() and draw() functions
|
|
70
|
-
const setupMatch = code.match(/function\s+setup\s*\(\s*\)\s*\{([\s\S]*?)\}(?=\s*function|\s*$)/);
|
|
71
|
-
const drawMatch = code.match(/function\s+draw\s*\(\s*\)\s*\{([\s\S]*?)\}(?=\s*function|\s*$)/);
|
|
72
|
-
const setupCode = setupMatch ? setupMatch[1].trim() : '';
|
|
73
|
-
const drawCode = drawMatch ? drawMatch[1].trim() : '';
|
|
74
|
-
if (!drawCode) {
|
|
75
|
-
throw new Error('Loop Mode requires a draw() function with content.');
|
|
76
|
-
}
|
|
77
|
-
// Inject totalFrames into runtime
|
|
78
|
-
p.totalFrames = totalFrames;
|
|
79
|
-
// Create sandboxed execution context
|
|
80
|
-
// All forbidden APIs are injected as parameters to override globals
|
|
81
|
-
const safeMath = createSafeMath();
|
|
82
|
-
const forbiddenKeys = Object.keys(FORBIDDEN_APIS);
|
|
83
|
-
// Create wrapped functions with p5 context, time variables, VAR, totalFrames, and blocked globals
|
|
84
|
-
const wrappedSetup = new Function('p', 'frameCount', 't', 'time', 'tGlobal', 'VAR', 'totalFrames', 'Math', ...forbiddenKeys, `with(p) { ${setupCode} }`);
|
|
85
|
-
const wrappedDraw = new Function('p', 'frameCount', 't', 'time', 'tGlobal', 'VAR', 'totalFrames', 'Math', ...forbiddenKeys, `with(p) { ${drawCode} }`);
|
|
86
|
-
// Get forbidden values array for execution
|
|
87
|
-
const forbiddenValues = forbiddenKeys.map(k => FORBIDDEN_APIS[k]);
|
|
88
|
-
onProgress?.({
|
|
89
|
-
phase: 'setup',
|
|
90
|
-
percent: 10,
|
|
91
|
-
message: 'Executing setup()...',
|
|
92
|
-
});
|
|
93
|
-
// Execute setup() once with time = 0, VAR, totalFrames, and sandboxed context
|
|
94
|
-
wrappedSetup(p, 0, 0, 0, 0, p.VAR, totalFrames, safeMath, ...forbiddenValues);
|
|
95
|
-
// Capture frames
|
|
96
|
-
const frames = [];
|
|
97
|
-
onProgress?.({
|
|
98
|
-
phase: 'rendering',
|
|
99
|
-
frame: 0,
|
|
100
|
-
totalFrames,
|
|
101
|
-
percent: 10,
|
|
102
|
-
message: `Rendering frames (0/${totalFrames})...`,
|
|
103
|
-
});
|
|
104
|
-
for (let frame = 0; frame < totalFrames; frame++) {
|
|
105
|
-
if (isCancelled) {
|
|
106
|
-
throw new Error('Rendering cancelled');
|
|
107
|
-
}
|
|
108
|
-
// Calculate normalized time variables
|
|
109
|
-
// t = frame / totalFrames (range [0, 1))
|
|
110
|
-
const t = frame / totalFrames;
|
|
111
|
-
const time = t * duration;
|
|
112
|
-
// Update p5 runtime frameCount
|
|
113
|
-
p.frameCount = frame;
|
|
114
|
-
// CRITICAL: Reset canvas state before each draw() call
|
|
115
|
-
// This enforces stateless, frame-authoritative rendering
|
|
116
|
-
// 1. Clear canvas (transparent)
|
|
117
|
-
p.clear();
|
|
118
|
-
// 2. Reset blend mode to NORMAL (Protocol v1.1 requirement)
|
|
119
|
-
// Prevents blend mode state from persisting across frames
|
|
120
|
-
p.blendMode('NORMAL');
|
|
121
|
-
// Execute draw() with time variables, VAR, totalFrames, and sandboxed context
|
|
122
|
-
wrappedDraw(p, frame, t, time, t, p.VAR, totalFrames, safeMath, ...forbiddenValues);
|
|
123
|
-
// Capture frame as PNG blob
|
|
124
|
-
const blob = await new Promise((resolve, reject) => {
|
|
125
|
-
canvas.toBlob((b) => b ? resolve(b) : reject(new Error(`Failed to capture frame ${frame}`)), 'image/png');
|
|
126
|
-
});
|
|
127
|
-
frames.push(blob);
|
|
128
|
-
// Provide preview on first frame
|
|
129
|
-
if (frame === 0) {
|
|
130
|
-
onPreview?.(canvas);
|
|
131
|
-
}
|
|
132
|
-
// Update progress
|
|
133
|
-
const percent = 10 + Math.floor((frame / totalFrames) * 60);
|
|
134
|
-
onProgress?.({
|
|
135
|
-
phase: 'rendering',
|
|
136
|
-
frame: frame + 1,
|
|
137
|
-
totalFrames,
|
|
138
|
-
percent,
|
|
139
|
-
message: `Rendering frames (${frame + 1}/${totalFrames})...`,
|
|
140
|
-
});
|
|
141
|
-
// Yield to prevent blocking UI
|
|
142
|
-
if (frame % 10 === 0) {
|
|
143
|
-
await new Promise(resolve => setTimeout(resolve, 0));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
onProgress?.({
|
|
147
|
-
phase: 'encoding',
|
|
148
|
-
frame: totalFrames,
|
|
149
|
-
totalFrames,
|
|
150
|
-
percent: 70,
|
|
151
|
-
message: 'Encoding video...',
|
|
152
|
-
});
|
|
153
|
-
// Encode to video (MP4)
|
|
154
|
-
const videoBlob = await encodeFramesToMP4(frames, fps, width, height, (progress) => {
|
|
155
|
-
const percent = 70 + Math.floor(progress * 30);
|
|
156
|
-
onProgress?.({
|
|
157
|
-
phase: 'encoding',
|
|
158
|
-
frame: totalFrames,
|
|
159
|
-
totalFrames,
|
|
160
|
-
percent,
|
|
161
|
-
message: `Encoding video (${Math.floor(progress * 100)}%)...`,
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
onProgress?.({
|
|
165
|
-
phase: 'complete',
|
|
166
|
-
frame: totalFrames,
|
|
167
|
-
totalFrames,
|
|
168
|
-
percent: 100,
|
|
169
|
-
message: 'Complete',
|
|
170
|
-
});
|
|
171
|
-
const result = {
|
|
172
|
-
type: 'video',
|
|
173
|
-
blob: videoBlob,
|
|
174
|
-
frames: totalFrames,
|
|
175
|
-
duration,
|
|
176
|
-
};
|
|
177
|
-
onComplete(result);
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
181
|
-
onError?.(err);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Encode frames to MP4 video
|
|
186
|
-
* Uses server-side encoding endpoint for cross-browser reliability
|
|
187
|
-
*/
|
|
188
|
-
async function encodeFramesToMP4(frames, fps, width, height, onProgress) {
|
|
189
|
-
// Convert frames to base64 for server transport
|
|
190
|
-
const frameDataUrls = [];
|
|
191
|
-
for (let i = 0; i < frames.length; i++) {
|
|
192
|
-
const reader = new FileReader();
|
|
193
|
-
const dataUrl = await new Promise((resolve, reject) => {
|
|
194
|
-
reader.onload = () => resolve(reader.result);
|
|
195
|
-
reader.onerror = reject;
|
|
196
|
-
reader.readAsDataURL(frames[i]);
|
|
197
|
-
});
|
|
198
|
-
frameDataUrls.push(dataUrl);
|
|
199
|
-
onProgress?.(i / frames.length * 0.3);
|
|
200
|
-
}
|
|
201
|
-
// Send to server for encoding
|
|
202
|
-
const response = await fetch('/api/encode-loop', {
|
|
203
|
-
method: 'POST',
|
|
204
|
-
headers: { 'Content-Type': 'application/json' },
|
|
205
|
-
body: JSON.stringify({
|
|
206
|
-
frames: frameDataUrls,
|
|
207
|
-
fps,
|
|
208
|
-
width,
|
|
209
|
-
height,
|
|
210
|
-
}),
|
|
211
|
-
});
|
|
212
|
-
if (!response.ok) {
|
|
213
|
-
const errorText = await response.text();
|
|
214
|
-
throw new Error(`Video encoding failed: ${errorText}`);
|
|
215
|
-
}
|
|
216
|
-
onProgress?.(0.8);
|
|
217
|
-
const data = await response.json();
|
|
218
|
-
if (!data.video) {
|
|
219
|
-
throw new Error('No video data returned from encoder');
|
|
220
|
-
}
|
|
221
|
-
// Convert base64 to blob
|
|
222
|
-
const binaryString = atob(data.video.split(',')[1] || data.video);
|
|
223
|
-
const bytes = new Uint8Array(binaryString.length);
|
|
224
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
225
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
226
|
-
}
|
|
227
|
-
onProgress?.(1);
|
|
228
|
-
return new Blob([bytes], { type: 'video/mp4' });
|
|
229
|
-
}
|
package/dist/noise-bridge.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Noise Bridge - Injects N.* globals into Code Mode runtime
|
|
3
|
-
*
|
|
4
|
-
* This is the bridge between NoiseSnapshot data and the Code Mode p5-runtime.
|
|
5
|
-
* It creates frozen N.* globals that noise sketches can access deterministically.
|
|
6
|
-
*
|
|
7
|
-
* Similar to sound-bridge.ts for SoundArt, but for Noise parameters.
|
|
8
|
-
*/
|
|
9
|
-
import type { NoiseSnapshot, NoiseBlendMode } from '../../shared/noiseSnapshot';
|
|
10
|
-
/**
|
|
11
|
-
* The N.* global object type for noise sketches
|
|
12
|
-
*/
|
|
13
|
-
export interface NoiseGlobals {
|
|
14
|
-
scale: number;
|
|
15
|
-
octaves: number;
|
|
16
|
-
persistence: number;
|
|
17
|
-
lacunarity: number;
|
|
18
|
-
cellDensity: number;
|
|
19
|
-
cellDistortion: number;
|
|
20
|
-
blendMode: NoiseBlendMode;
|
|
21
|
-
isPerlinOnly: boolean;
|
|
22
|
-
isBlend: boolean;
|
|
23
|
-
isWarp: boolean;
|
|
24
|
-
isInterleave: boolean;
|
|
25
|
-
bgR: number;
|
|
26
|
-
bgG: number;
|
|
27
|
-
bgB: number;
|
|
28
|
-
noiseR: number;
|
|
29
|
-
noiseG: number;
|
|
30
|
-
noiseB: number;
|
|
31
|
-
seed: number;
|
|
32
|
-
zoom: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create N.* globals from a NoiseSnapshot
|
|
36
|
-
*/
|
|
37
|
-
export declare function createNoiseGlobals(snapshot: NoiseSnapshot): NoiseGlobals;
|
|
38
|
-
/**
|
|
39
|
-
* Inject N.* globals into code string
|
|
40
|
-
*
|
|
41
|
-
* This wraps the sketch code with N.* variable declarations
|
|
42
|
-
*/
|
|
43
|
-
export declare function injectNoiseGlobals(sketchCode: string, globals: NoiseGlobals): string;
|
|
44
|
-
//# sourceMappingURL=noise-bridge.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"noise-bridge.d.ts","sourceRoot":"","sources":["../noise-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,YAAY;IAE3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IAGnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IAGvB,SAAS,EAAE,cAAc,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,OAAO,CAAC;IAGtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IAGf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG,YAAY,CAsBxE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CA6BpF"}
|