@nexart/ui-renderer 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +138 -319
- package/dist/capabilities.d.ts +5 -7
- package/dist/capabilities.d.ts.map +1 -1
- package/dist/capabilities.js +6 -8
- package/dist/compiler.d.ts +3 -3
- package/dist/compiler.js +4 -4
- package/dist/index.d.ts +33 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -30
- package/dist/preview/canvas-scaler.d.ts +70 -0
- package/dist/preview/canvas-scaler.d.ts.map +1 -0
- package/dist/preview/canvas-scaler.js +112 -0
- package/dist/preview/code-renderer.d.ts +11 -28
- package/dist/preview/code-renderer.d.ts.map +1 -1
- package/dist/preview/code-renderer.js +118 -660
- package/dist/preview/frame-budget.d.ts +43 -0
- package/dist/preview/frame-budget.d.ts.map +1 -0
- package/dist/preview/frame-budget.js +78 -0
- package/dist/preview/preview-engine.d.ts +42 -0
- package/dist/preview/preview-engine.d.ts.map +1 -0
- package/dist/preview/preview-engine.js +204 -0
- package/dist/preview/preview-runtime.d.ts +28 -0
- package/dist/preview/preview-runtime.d.ts.map +1 -0
- package/dist/preview/preview-runtime.js +512 -0
- package/dist/preview/preview-types.d.ts +116 -0
- package/dist/preview/preview-types.d.ts.map +1 -0
- package/dist/preview/preview-types.js +36 -0
- package/dist/preview/renderer.d.ts +3 -3
- package/dist/preview/renderer.js +3 -3
- package/dist/preview/unified-renderer.d.ts.map +1 -1
- package/dist/preview/unified-renderer.js +48 -22
- package/dist/system.d.ts +2 -2
- package/dist/system.d.ts.map +1 -1
- package/dist/system.js +8 -10
- package/dist/types.d.ts +9 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +9 -5
- package/package.json +2 -2
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/ui-renderer - Frame Budget Manager
|
|
3
|
+
*
|
|
4
|
+
* Enforces hard execution limits to prevent browser freezes.
|
|
5
|
+
*
|
|
6
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
7
|
+
* ║ EXECUTION BUDGET — MANDATORY LIMITS ║
|
|
8
|
+
* ║ ║
|
|
9
|
+
* ║ Max frames: 30 ║
|
|
10
|
+
* ║ Max total time: 500ms ║
|
|
11
|
+
* ║ Target frame time: ~16ms ║
|
|
12
|
+
* ║ ║
|
|
13
|
+
* ║ If limits exceeded: stop immediately, do NOT throw. ║
|
|
14
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
15
|
+
*/
|
|
16
|
+
import { type FrameBudgetState } from './preview-types';
|
|
17
|
+
/**
|
|
18
|
+
* Create a new frame budget tracker
|
|
19
|
+
*/
|
|
20
|
+
export declare function createFrameBudget(): FrameBudgetState;
|
|
21
|
+
/**
|
|
22
|
+
* Check if budget allows another frame.
|
|
23
|
+
* Returns true if we can render, false if budget is exhausted.
|
|
24
|
+
*/
|
|
25
|
+
export declare function canRenderFrame(budget: FrameBudgetState): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Record that a frame was rendered
|
|
28
|
+
*/
|
|
29
|
+
export declare function recordFrame(budget: FrameBudgetState): void;
|
|
30
|
+
/**
|
|
31
|
+
* Get elapsed time in milliseconds
|
|
32
|
+
*/
|
|
33
|
+
export declare function getElapsedMs(budget: FrameBudgetState): number;
|
|
34
|
+
/**
|
|
35
|
+
* Reset the frame budget for a new render cycle
|
|
36
|
+
*/
|
|
37
|
+
export declare function resetBudget(budget: FrameBudgetState): void;
|
|
38
|
+
/**
|
|
39
|
+
* Check if we should skip this frame for performance.
|
|
40
|
+
* Uses frame stride to reduce rendering load while keeping animation smooth.
|
|
41
|
+
*/
|
|
42
|
+
export declare function shouldSkipFrame(frameCount: number): boolean;
|
|
43
|
+
//# sourceMappingURL=frame-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-budget.d.ts","sourceRoot":"","sources":["../../src/preview/frame-budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExE;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,gBAAgB,CAOpD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAqBhE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAE1D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAK1D;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAE3D"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/ui-renderer - Frame Budget Manager
|
|
3
|
+
*
|
|
4
|
+
* Enforces hard execution limits to prevent browser freezes.
|
|
5
|
+
*
|
|
6
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
7
|
+
* ║ EXECUTION BUDGET — MANDATORY LIMITS ║
|
|
8
|
+
* ║ ║
|
|
9
|
+
* ║ Max frames: 30 ║
|
|
10
|
+
* ║ Max total time: 500ms ║
|
|
11
|
+
* ║ Target frame time: ~16ms ║
|
|
12
|
+
* ║ ║
|
|
13
|
+
* ║ If limits exceeded: stop immediately, do NOT throw. ║
|
|
14
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
15
|
+
*/
|
|
16
|
+
import { PREVIEW_BUDGET } from './preview-types';
|
|
17
|
+
/**
|
|
18
|
+
* Create a new frame budget tracker
|
|
19
|
+
*/
|
|
20
|
+
export function createFrameBudget() {
|
|
21
|
+
return {
|
|
22
|
+
framesRendered: 0,
|
|
23
|
+
startTimeMs: performance.now(),
|
|
24
|
+
exhausted: false,
|
|
25
|
+
exhaustionReason: undefined,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Check if budget allows another frame.
|
|
30
|
+
* Returns true if we can render, false if budget is exhausted.
|
|
31
|
+
*/
|
|
32
|
+
export function canRenderFrame(budget) {
|
|
33
|
+
if (budget.exhausted) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
// Check frame limit
|
|
37
|
+
if (budget.framesRendered >= PREVIEW_BUDGET.MAX_FRAMES) {
|
|
38
|
+
budget.exhausted = true;
|
|
39
|
+
budget.exhaustionReason = 'frame_limit';
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
// Check time limit
|
|
43
|
+
const elapsedMs = performance.now() - budget.startTimeMs;
|
|
44
|
+
if (elapsedMs >= PREVIEW_BUDGET.MAX_TOTAL_TIME_MS) {
|
|
45
|
+
budget.exhausted = true;
|
|
46
|
+
budget.exhaustionReason = 'time_limit';
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Record that a frame was rendered
|
|
53
|
+
*/
|
|
54
|
+
export function recordFrame(budget) {
|
|
55
|
+
budget.framesRendered++;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get elapsed time in milliseconds
|
|
59
|
+
*/
|
|
60
|
+
export function getElapsedMs(budget) {
|
|
61
|
+
return performance.now() - budget.startTimeMs;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Reset the frame budget for a new render cycle
|
|
65
|
+
*/
|
|
66
|
+
export function resetBudget(budget) {
|
|
67
|
+
budget.framesRendered = 0;
|
|
68
|
+
budget.startTimeMs = performance.now();
|
|
69
|
+
budget.exhausted = false;
|
|
70
|
+
budget.exhaustionReason = undefined;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if we should skip this frame for performance.
|
|
74
|
+
* Uses frame stride to reduce rendering load while keeping animation smooth.
|
|
75
|
+
*/
|
|
76
|
+
export function shouldSkipFrame(frameCount) {
|
|
77
|
+
return frameCount % PREVIEW_BUDGET.FRAME_STRIDE !== 0;
|
|
78
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/ui-renderer - Preview Engine
|
|
3
|
+
*
|
|
4
|
+
* Lightweight, non-authoritative preview executor.
|
|
5
|
+
* Safe, interruptible, and performant.
|
|
6
|
+
*
|
|
7
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
8
|
+
* ║ PREVIEW ENGINE — NON-CANONICAL ║
|
|
9
|
+
* ║ ║
|
|
10
|
+
* ║ This engine is a preview-only runtime. ║
|
|
11
|
+
* ║ It does not guarantee determinism or protocol compliance. ║
|
|
12
|
+
* ║ ║
|
|
13
|
+
* ║ Usage: ║
|
|
14
|
+
* ║ - Editor live preview ║
|
|
15
|
+
* ║ - Builder dashboards ║
|
|
16
|
+
* ║ - Background generative art ║
|
|
17
|
+
* ║ - Static or loop previews ║
|
|
18
|
+
* ║ ║
|
|
19
|
+
* ║ NOT for: ║
|
|
20
|
+
* ║ - Minting / export ║
|
|
21
|
+
* ║ - ByX ║
|
|
22
|
+
* ║ - Protocol validation ║
|
|
23
|
+
* ║ ║
|
|
24
|
+
* ║ For canonical output: use @nexart/codemode-sdk ║
|
|
25
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
26
|
+
*/
|
|
27
|
+
import { type PreviewEngineConfig, type PreviewRenderResult, type PreviewRenderer } from './preview-types';
|
|
28
|
+
/**
|
|
29
|
+
* Create a preview renderer for the given configuration.
|
|
30
|
+
*
|
|
31
|
+
* This is the main entry point for preview rendering.
|
|
32
|
+
*/
|
|
33
|
+
export declare function createPreviewEngine(config: PreviewEngineConfig): PreviewRenderer;
|
|
34
|
+
/**
|
|
35
|
+
* Render a static preview (single frame).
|
|
36
|
+
*/
|
|
37
|
+
export declare function renderStaticPreview(config: PreviewEngineConfig): PreviewRenderResult;
|
|
38
|
+
/**
|
|
39
|
+
* Stop any active preview renderer.
|
|
40
|
+
*/
|
|
41
|
+
export declare function stopActivePreview(): void;
|
|
42
|
+
//# sourceMappingURL=preview-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-engine.d.ts","sourceRoot":"","sources":["../../src/preview/preview-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,eAAe,EAErB,MAAM,iBAAiB,CAAC;AAwMzB;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,eAAe,CAEhF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAKpF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAKxC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/ui-renderer - Preview Engine
|
|
3
|
+
*
|
|
4
|
+
* Lightweight, non-authoritative preview executor.
|
|
5
|
+
* Safe, interruptible, and performant.
|
|
6
|
+
*
|
|
7
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
8
|
+
* ║ PREVIEW ENGINE — NON-CANONICAL ║
|
|
9
|
+
* ║ ║
|
|
10
|
+
* ║ This engine is a preview-only runtime. ║
|
|
11
|
+
* ║ It does not guarantee determinism or protocol compliance. ║
|
|
12
|
+
* ║ ║
|
|
13
|
+
* ║ Usage: ║
|
|
14
|
+
* ║ - Editor live preview ║
|
|
15
|
+
* ║ - Builder dashboards ║
|
|
16
|
+
* ║ - Background generative art ║
|
|
17
|
+
* ║ - Static or loop previews ║
|
|
18
|
+
* ║ ║
|
|
19
|
+
* ║ NOT for: ║
|
|
20
|
+
* ║ - Minting / export ║
|
|
21
|
+
* ║ - ByX ║
|
|
22
|
+
* ║ - Protocol validation ║
|
|
23
|
+
* ║ ║
|
|
24
|
+
* ║ For canonical output: use @nexart/codemode-sdk ║
|
|
25
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
26
|
+
*/
|
|
27
|
+
import { createFrameBudget, canRenderFrame, recordFrame, getElapsedMs, resetBudget, shouldSkipFrame, } from './frame-budget';
|
|
28
|
+
import { calculateScaledDimensions, applyScaledDimensions, reapplyContextScale, } from './canvas-scaler';
|
|
29
|
+
import { createPreviewRuntime } from './preview-runtime';
|
|
30
|
+
let activePreviewRenderer = null;
|
|
31
|
+
class PreviewEngine {
|
|
32
|
+
constructor(config) {
|
|
33
|
+
this.runtime = null;
|
|
34
|
+
this.setupFn = null;
|
|
35
|
+
this.drawFn = null;
|
|
36
|
+
this.animationFrameId = null;
|
|
37
|
+
this.budget = createFrameBudget();
|
|
38
|
+
this.running = false;
|
|
39
|
+
this.internalFrameCount = 0;
|
|
40
|
+
this.isCanonical = false;
|
|
41
|
+
this.isArchival = false;
|
|
42
|
+
this.config = config;
|
|
43
|
+
this.canvas = config.canvas;
|
|
44
|
+
this.initialize();
|
|
45
|
+
}
|
|
46
|
+
initialize() {
|
|
47
|
+
const scaled = calculateScaledDimensions(this.config.width, this.config.height);
|
|
48
|
+
applyScaledDimensions(this.canvas, scaled);
|
|
49
|
+
// NOTE: Canvas resizing resets the 2D context transform.
|
|
50
|
+
// Reapply scale factor once after resize for correct rendering.
|
|
51
|
+
reapplyContextScale(this.canvas, scaled);
|
|
52
|
+
this.runtime = createPreviewRuntime(this.canvas, scaled.renderWidth, scaled.renderHeight, this.config.seed ?? 12345, this.config.vars ?? []);
|
|
53
|
+
const totalFrames = this.config.totalFrames ?? 120;
|
|
54
|
+
this.runtime.totalFrames = totalFrames;
|
|
55
|
+
try {
|
|
56
|
+
const fn = this.compileSource(this.config.source);
|
|
57
|
+
fn();
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.warn('[PreviewEngine] Error compiling source:', error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
compileSource(source) {
|
|
64
|
+
const runtime = this.runtime;
|
|
65
|
+
const self = this;
|
|
66
|
+
const globalVars = Object.keys(runtime);
|
|
67
|
+
const globalValues = Object.values(runtime);
|
|
68
|
+
globalVars.push('setup', 'draw');
|
|
69
|
+
const wrappedSource = `
|
|
70
|
+
${source}
|
|
71
|
+
if (typeof setup === 'function') __registerSetup(setup);
|
|
72
|
+
if (typeof draw === 'function') __registerDraw(draw);
|
|
73
|
+
`;
|
|
74
|
+
const registerSetup = (fn) => { self.setupFn = fn; };
|
|
75
|
+
const registerDraw = (fn) => { self.drawFn = fn; };
|
|
76
|
+
globalValues.push(registerSetup, registerDraw);
|
|
77
|
+
globalVars.push('__registerSetup', '__registerDraw');
|
|
78
|
+
const fn = new Function(...globalVars, wrappedSource);
|
|
79
|
+
return () => fn(...globalValues);
|
|
80
|
+
}
|
|
81
|
+
renderStatic() {
|
|
82
|
+
resetBudget(this.budget);
|
|
83
|
+
try {
|
|
84
|
+
if (this.setupFn) {
|
|
85
|
+
this.setupFn();
|
|
86
|
+
}
|
|
87
|
+
recordFrame(this.budget);
|
|
88
|
+
return {
|
|
89
|
+
success: true,
|
|
90
|
+
framesRendered: 1,
|
|
91
|
+
executionTimeMs: getElapsedMs(this.budget),
|
|
92
|
+
terminatedEarly: false,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.warn('[PreviewEngine] Static render error:', error);
|
|
97
|
+
return {
|
|
98
|
+
success: false,
|
|
99
|
+
framesRendered: 0,
|
|
100
|
+
executionTimeMs: getElapsedMs(this.budget),
|
|
101
|
+
terminatedEarly: true,
|
|
102
|
+
terminationReason: 'error',
|
|
103
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
startLoop() {
|
|
108
|
+
if (this.running)
|
|
109
|
+
return;
|
|
110
|
+
if (activePreviewRenderer && activePreviewRenderer !== this) {
|
|
111
|
+
activePreviewRenderer.stopLoop();
|
|
112
|
+
}
|
|
113
|
+
activePreviewRenderer = this;
|
|
114
|
+
this.running = true;
|
|
115
|
+
resetBudget(this.budget);
|
|
116
|
+
this.internalFrameCount = 0;
|
|
117
|
+
try {
|
|
118
|
+
if (this.setupFn) {
|
|
119
|
+
this.setupFn();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
console.warn('[PreviewEngine] Setup error:', error);
|
|
124
|
+
}
|
|
125
|
+
this.scheduleNextFrame();
|
|
126
|
+
}
|
|
127
|
+
scheduleNextFrame() {
|
|
128
|
+
if (!this.running)
|
|
129
|
+
return;
|
|
130
|
+
this.animationFrameId = requestAnimationFrame(() => {
|
|
131
|
+
if (!this.running)
|
|
132
|
+
return;
|
|
133
|
+
if (!canRenderFrame(this.budget)) {
|
|
134
|
+
this.running = false;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
this.internalFrameCount++;
|
|
138
|
+
if (!shouldSkipFrame(this.internalFrameCount)) {
|
|
139
|
+
try {
|
|
140
|
+
if (this.runtime) {
|
|
141
|
+
this.runtime.frameCount = this.internalFrameCount;
|
|
142
|
+
const totalFrames = this.config.totalFrames ?? 120;
|
|
143
|
+
this.runtime.t = this.internalFrameCount / totalFrames;
|
|
144
|
+
this.runtime.time = this.runtime.t;
|
|
145
|
+
this.runtime.tGlobal = this.runtime.t;
|
|
146
|
+
}
|
|
147
|
+
if (this.drawFn) {
|
|
148
|
+
this.drawFn();
|
|
149
|
+
}
|
|
150
|
+
recordFrame(this.budget);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
console.warn('[PreviewEngine] Draw error:', error);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
this.scheduleNextFrame();
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
stopLoop() {
|
|
160
|
+
this.running = false;
|
|
161
|
+
if (this.animationFrameId !== null) {
|
|
162
|
+
cancelAnimationFrame(this.animationFrameId);
|
|
163
|
+
this.animationFrameId = null;
|
|
164
|
+
}
|
|
165
|
+
if (activePreviewRenderer === this) {
|
|
166
|
+
activePreviewRenderer = null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
isRendering() {
|
|
170
|
+
return this.running;
|
|
171
|
+
}
|
|
172
|
+
destroy() {
|
|
173
|
+
this.stopLoop();
|
|
174
|
+
this.runtime = null;
|
|
175
|
+
this.setupFn = null;
|
|
176
|
+
this.drawFn = null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Create a preview renderer for the given configuration.
|
|
181
|
+
*
|
|
182
|
+
* This is the main entry point for preview rendering.
|
|
183
|
+
*/
|
|
184
|
+
export function createPreviewEngine(config) {
|
|
185
|
+
return new PreviewEngine(config);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Render a static preview (single frame).
|
|
189
|
+
*/
|
|
190
|
+
export function renderStaticPreview(config) {
|
|
191
|
+
const engine = new PreviewEngine(config);
|
|
192
|
+
const result = engine.renderStatic();
|
|
193
|
+
engine.destroy();
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Stop any active preview renderer.
|
|
198
|
+
*/
|
|
199
|
+
export function stopActivePreview() {
|
|
200
|
+
if (activePreviewRenderer) {
|
|
201
|
+
activePreviewRenderer.stopLoop();
|
|
202
|
+
activePreviewRenderer = null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/ui-renderer - Preview Runtime
|
|
3
|
+
*
|
|
4
|
+
* Simplified p5-like runtime for preview rendering.
|
|
5
|
+
* Same API surface as Code Mode, but optimized for performance.
|
|
6
|
+
*
|
|
7
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
8
|
+
* ║ PREVIEW RUNTIME — SAME API, SIMPLIFIED INTERNALS ║
|
|
9
|
+
* ║ ║
|
|
10
|
+
* ║ This runtime: ║
|
|
11
|
+
* ║ - Uses same function names as Code Mode ║
|
|
12
|
+
* ║ - Is NOT deterministic (performance > fidelity) ║
|
|
13
|
+
* ║ - May have simplified implementations ║
|
|
14
|
+
* ║ - Pixel operations may be capped ║
|
|
15
|
+
* ║ ║
|
|
16
|
+
* ║ For canonical output: use @nexart/codemode-sdk ║
|
|
17
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
18
|
+
*/
|
|
19
|
+
export interface PreviewP5Runtime {
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
mode: 'preview';
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
frameCount: number;
|
|
25
|
+
VAR: readonly number[];
|
|
26
|
+
}
|
|
27
|
+
export declare function createPreviewRuntime(canvas: HTMLCanvasElement, width: number, height: number, seed?: number, vars?: number[]): PreviewP5Runtime;
|
|
28
|
+
//# sourceMappingURL=preview-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-runtime.d.ts","sourceRoot":"","sources":["../../src/preview/preview-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;CACxB;AAiED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAc,EACpB,IAAI,GAAE,MAAM,EAAO,GAClB,gBAAgB,CA4YlB"}
|