@nexart/ui-renderer 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -203
- package/dist/preview/code-renderer.d.ts +31 -10
- package/dist/preview/code-renderer.d.ts.map +1 -1
- package/dist/preview/code-renderer.js +135 -27
- package/dist/system.d.ts.map +1 -1
- package/dist/system.js +17 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -2
- package/dist/preview/primitives/sketch.d.ts +0 -14
- package/dist/preview/primitives/sketch.d.ts.map +0 -1
- package/dist/preview/primitives/sketch.js +0 -407
|
@@ -1,10 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @nexart/ui-renderer v0.
|
|
2
|
+
* @nexart/ui-renderer v0.4.0 - Code Mode Renderer
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
5
|
+
* ║ PREVIEW RENDERER — MIRRORS @nexart/codemode-sdk BEHAVIOR ║
|
|
6
|
+
* ║ ║
|
|
7
|
+
* ║ This file is a MIRROR, not an authority. ║
|
|
8
|
+
* ║ ║
|
|
9
|
+
* ║ Authority: @nexart/codemode-sdk (Protocol v1.0.0) ║
|
|
10
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
11
|
+
*
|
|
12
|
+
* ARCHITECTURAL NOTE:
|
|
13
|
+
* -------------------
|
|
14
|
+
* Live preview animation requires local p5 runtime execution because:
|
|
15
|
+
* - @nexart/codemode-sdk.executeCodeMode() returns blobs (PNG/MP4), not frames
|
|
16
|
+
* - Real-time animation in the browser requires frame-by-frame canvas updates
|
|
17
|
+
* - The SDK's loop mode produces video files, not real-time rendering
|
|
18
|
+
*
|
|
19
|
+
* To ensure faithful mirroring, this renderer:
|
|
20
|
+
* 1. Uses identical forbidden pattern validation as the SDK
|
|
21
|
+
* 2. Uses identical VAR handling (read-only, 10 elements, 0-100 range, errors not clamps)
|
|
22
|
+
* 3. Uses identical seeded RNG (Mulberry32) and Perlin noise
|
|
23
|
+
* 4. Uses identical time variable semantics (frameCount, t, time, tGlobal)
|
|
24
|
+
*
|
|
25
|
+
* For archival/canonical output, use @nexart/codemode-sdk directly.
|
|
6
26
|
*/
|
|
27
|
+
const PROTOCOL_VERSION = '1.0.0';
|
|
7
28
|
let activeRendererInstance = null;
|
|
29
|
+
/**
|
|
30
|
+
* Validate and normalize VAR array to exactly 10 values.
|
|
31
|
+
* MIRRORS @nexart/codemode-sdk behavior exactly.
|
|
32
|
+
*
|
|
33
|
+
* Rules:
|
|
34
|
+
* - VAR MUST be exactly 10 elements (protocol error if not)
|
|
35
|
+
* - VAR values MUST be numbers (protocol error if not)
|
|
36
|
+
* - VAR values 0-100 recommended (warns if out of range, but does NOT clamp)
|
|
37
|
+
* - VAR is read-only inside sketches
|
|
38
|
+
*/
|
|
39
|
+
function normalizeVars(vars) {
|
|
40
|
+
if (!vars || !Array.isArray(vars)) {
|
|
41
|
+
console.log('[UIRenderer] No vars provided, using protocol defaults [0,0,0,0,0,0,0,0,0,0]');
|
|
42
|
+
return [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
43
|
+
}
|
|
44
|
+
if (vars.length !== 10) {
|
|
45
|
+
throw new Error(`[Code Mode Protocol Error] VAR array must have exactly 10 elements, got ${vars.length}`);
|
|
46
|
+
}
|
|
47
|
+
const result = [];
|
|
48
|
+
for (let i = 0; i < 10; i++) {
|
|
49
|
+
const v = vars[i];
|
|
50
|
+
if (typeof v !== 'number') {
|
|
51
|
+
throw new Error(`[Code Mode Protocol Error] VAR[${i}] must be a number, got ${typeof v}`);
|
|
52
|
+
}
|
|
53
|
+
if (v < 0 || v > 100) {
|
|
54
|
+
console.warn(`[UIRenderer] VAR[${i}] = ${v} is outside recommended range 0-100`);
|
|
55
|
+
}
|
|
56
|
+
result.push(v);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
8
60
|
function createSeededRNG(seed = 123456) {
|
|
9
61
|
let a = seed >>> 0;
|
|
10
62
|
return () => {
|
|
@@ -54,7 +106,27 @@ function createSeededNoise(seed = 0) {
|
|
|
54
106
|
return (lerp(lerp(lerp(grad(permutation[AA], x, y, z), grad(permutation[BA], x - 1, y, z), u), lerp(grad(permutation[AB], x, y - 1, z), grad(permutation[BB], x - 1, y - 1, z), u), v), lerp(lerp(grad(permutation[AA + 1], x, y, z - 1), grad(permutation[BA + 1], x - 1, y, z - 1), u), lerp(grad(permutation[AB + 1], x, y - 1, z - 1), grad(permutation[BB + 1], x - 1, y - 1, z - 1), u), v), w) + 1) / 2;
|
|
55
107
|
};
|
|
56
108
|
}
|
|
57
|
-
|
|
109
|
+
function createProtectedVAR(vars) {
|
|
110
|
+
const frozenVars = Object.freeze([...vars]);
|
|
111
|
+
return new Proxy(frozenVars, {
|
|
112
|
+
get(target, prop) {
|
|
113
|
+
if (typeof prop === 'string' && !isNaN(Number(prop))) {
|
|
114
|
+
const index = Number(prop);
|
|
115
|
+
if (index >= 0 && index < 10) {
|
|
116
|
+
return target[index];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (prop === 'length')
|
|
120
|
+
return 10;
|
|
121
|
+
return target[prop];
|
|
122
|
+
},
|
|
123
|
+
set(target, prop, value) {
|
|
124
|
+
console.warn(`[UIRenderer Protocol Warning] VAR is read-only. Attempted write to VAR[${String(prop)}] blocked.`);
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
export function createP5Runtime(canvas, width, height, seed, vars = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) {
|
|
58
130
|
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
59
131
|
let currentFill = 'rgba(255, 255, 255, 1)';
|
|
60
132
|
let currentStroke = 'rgba(0, 0, 0, 1)';
|
|
@@ -105,10 +177,12 @@ export function createP5Runtime(canvas, width, height, seed) {
|
|
|
105
177
|
}
|
|
106
178
|
return 'rgba(0, 0, 0, 1)';
|
|
107
179
|
};
|
|
180
|
+
const protectedVAR = createProtectedVAR(vars);
|
|
108
181
|
const p = {
|
|
109
182
|
width,
|
|
110
183
|
height,
|
|
111
184
|
frameCount: 0,
|
|
185
|
+
VAR: protectedVAR,
|
|
112
186
|
PI: Math.PI,
|
|
113
187
|
TWO_PI: Math.PI * 2,
|
|
114
188
|
HALF_PI: Math.PI / 2,
|
|
@@ -492,7 +566,37 @@ function injectTimeVariables(p, time) {
|
|
|
492
566
|
p.time = time.time;
|
|
493
567
|
p.tGlobal = time.tGlobal;
|
|
494
568
|
}
|
|
569
|
+
/**
|
|
570
|
+
* Validate forbidden patterns in code.
|
|
571
|
+
* MIRRORS @nexart/codemode-sdk forbidden patterns exactly.
|
|
572
|
+
* Error messages match SDK wording for consistency.
|
|
573
|
+
*/
|
|
574
|
+
function validateForbiddenPatterns(code) {
|
|
575
|
+
const forbiddenPatterns = [
|
|
576
|
+
{ pattern: /setTimeout\s*\(/, name: 'setTimeout' },
|
|
577
|
+
{ pattern: /setInterval\s*\(/, name: 'setInterval' },
|
|
578
|
+
{ pattern: /requestAnimationFrame\s*\(/, name: 'requestAnimationFrame' },
|
|
579
|
+
{ pattern: /Date\.now\s*\(/, name: 'Date.now() — use time variable instead' },
|
|
580
|
+
{ pattern: /new\s+Date\s*\(/, name: 'new Date() — use time variable instead' },
|
|
581
|
+
{ pattern: /Math\.random\s*\(/, name: 'Math.random() — use random() instead (seeded)' },
|
|
582
|
+
{ pattern: /fetch\s*\(/, name: 'fetch() — external IO forbidden' },
|
|
583
|
+
{ pattern: /XMLHttpRequest/, name: 'XMLHttpRequest — external IO forbidden' },
|
|
584
|
+
{ pattern: /createCanvas\s*\(/, name: 'createCanvas() — canvas is pre-initialized' },
|
|
585
|
+
{ pattern: /document\./, name: 'DOM access — document.* forbidden' },
|
|
586
|
+
{ pattern: /window\./, name: 'DOM access — window.* forbidden' },
|
|
587
|
+
{ pattern: /\bimport\s+/, name: 'import — external imports forbidden' },
|
|
588
|
+
{ pattern: /\brequire\s*\(/, name: 'require() — external imports forbidden' },
|
|
589
|
+
];
|
|
590
|
+
for (const { pattern, name } of forbiddenPatterns) {
|
|
591
|
+
if (pattern.test(code)) {
|
|
592
|
+
throw new Error(`[Code Mode Protocol Error] Forbidden pattern: ${name}`);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
495
596
|
export function renderCodeModeSystem(system, canvas, options = {}) {
|
|
597
|
+
console.log('[UIRenderer] Preview delegation → @nexart/codemode-sdk');
|
|
598
|
+
console.log(`[UIRenderer] Protocol version: ${PROTOCOL_VERSION}`);
|
|
599
|
+
console.log(`[UIRenderer] Mode: ${system.mode}`);
|
|
496
600
|
if (activeRendererInstance) {
|
|
497
601
|
activeRendererInstance.destroy();
|
|
498
602
|
activeRendererInstance = null;
|
|
@@ -504,6 +608,7 @@ export function renderCodeModeSystem(system, canvas, options = {}) {
|
|
|
504
608
|
let animationId = null;
|
|
505
609
|
let isRunning = false;
|
|
506
610
|
let isDestroyed = false;
|
|
611
|
+
const normalizedVars = normalizeVars(system.vars);
|
|
507
612
|
const extractFunctions = (code) => {
|
|
508
613
|
const setupMatch = code.match(/function\s+setup\s*\(\s*\)\s*\{([\s\S]*?)\}(?=\s*function|\s*$)/);
|
|
509
614
|
const drawMatch = code.match(/function\s+draw\s*\(\s*\)\s*\{([\s\S]*?)\}(?=\s*function|\s*$)/);
|
|
@@ -512,18 +617,10 @@ export function renderCodeModeSystem(system, canvas, options = {}) {
|
|
|
512
617
|
drawCode: drawMatch ? drawMatch[1].trim() : null,
|
|
513
618
|
};
|
|
514
619
|
};
|
|
515
|
-
const validateCode = (code) => {
|
|
516
|
-
const forbiddenPatterns = ['setTimeout', 'setInterval', 'requestAnimationFrame'];
|
|
517
|
-
for (const pattern of forbiddenPatterns) {
|
|
518
|
-
if (code.includes(pattern)) {
|
|
519
|
-
throw new Error(`Forbidden async timing function: ${pattern}`);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
};
|
|
523
620
|
const drawBadge = () => {
|
|
524
621
|
if (!showBadge)
|
|
525
622
|
return;
|
|
526
|
-
const text = '⚠️ Preview
|
|
623
|
+
const text = '⚠️ Preview (mirrors @nexart/codemode-sdk)';
|
|
527
624
|
ctx.font = '12px -apple-system, sans-serif';
|
|
528
625
|
const metrics = ctx.measureText(text);
|
|
529
626
|
const padding = 8;
|
|
@@ -541,14 +638,23 @@ export function renderCodeModeSystem(system, canvas, options = {}) {
|
|
|
541
638
|
ctx.fillStyle = '#ff9999';
|
|
542
639
|
ctx.fillText(text, x + padding, y + 16);
|
|
543
640
|
};
|
|
641
|
+
const renderBlackCanvas = (error) => {
|
|
642
|
+
ctx.fillStyle = '#000000';
|
|
643
|
+
ctx.fillRect(0, 0, system.width, system.height);
|
|
644
|
+
ctx.fillStyle = '#ff6666';
|
|
645
|
+
ctx.font = '14px monospace';
|
|
646
|
+
ctx.fillText('[Protocol Error]', 20, 30);
|
|
647
|
+
ctx.fillText(error.message, 20, 50);
|
|
648
|
+
};
|
|
544
649
|
const renderStatic = () => {
|
|
545
650
|
try {
|
|
546
|
-
|
|
651
|
+
console.log('[UIRenderer] Delegating static render via protocol-aligned runtime');
|
|
652
|
+
validateForbiddenPatterns(system.source);
|
|
547
653
|
const { setupCode } = extractFunctions(system.source);
|
|
548
|
-
const p = createP5Runtime(canvas, system.width, system.height, system.seed);
|
|
654
|
+
const p = createP5Runtime(canvas, system.width, system.height, system.seed, normalizedVars);
|
|
549
655
|
injectTimeVariables(p, { frameCount: 0, t: 0, time: 0, tGlobal: 0 });
|
|
550
|
-
const wrappedSetup = new Function('p', 'frameCount', 't', 'time', 'tGlobal', `with(p) { ${setupCode} }`);
|
|
551
|
-
wrappedSetup(p, 0, 0, 0, 0);
|
|
656
|
+
const wrappedSetup = new Function('p', 'frameCount', 't', 'time', 'tGlobal', 'VAR', `with(p) { ${setupCode} }`);
|
|
657
|
+
wrappedSetup(p, 0, 0, 0, 0, p.VAR);
|
|
552
658
|
drawBadge();
|
|
553
659
|
onPreview?.(canvas);
|
|
554
660
|
canvas.toBlob((blob) => {
|
|
@@ -559,26 +665,27 @@ export function renderCodeModeSystem(system, canvas, options = {}) {
|
|
|
559
665
|
}
|
|
560
666
|
catch (error) {
|
|
561
667
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
668
|
+
console.error('[UIRenderer Protocol Error]', err.message);
|
|
669
|
+
renderBlackCanvas(err);
|
|
562
670
|
onError?.(err);
|
|
563
|
-
throw err;
|
|
564
671
|
}
|
|
565
672
|
};
|
|
566
673
|
const renderLoop = () => {
|
|
567
674
|
if (isDestroyed)
|
|
568
675
|
return;
|
|
569
676
|
try {
|
|
570
|
-
|
|
677
|
+
console.log('[UIRenderer] Delegating loop render via protocol-aligned runtime');
|
|
678
|
+
validateForbiddenPatterns(system.source);
|
|
571
679
|
const { setupCode, drawCode } = extractFunctions(system.source);
|
|
572
680
|
if (!drawCode) {
|
|
573
|
-
throw new Error('Loop mode requires a draw() function');
|
|
681
|
+
throw new Error('[Protocol Error] Loop mode requires a draw() function');
|
|
574
682
|
}
|
|
575
683
|
const totalFrames = system.totalFrames ?? 60;
|
|
576
684
|
let frame = 0;
|
|
577
|
-
const p = createP5Runtime(canvas, system.width, system.height, system.seed);
|
|
578
|
-
const
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
wrappedSetup(p, 0, 0, 0, 0);
|
|
685
|
+
const p = createP5Runtime(canvas, system.width, system.height, system.seed, normalizedVars);
|
|
686
|
+
const wrappedSetup = new Function('p', 'frameCount', 't', 'time', 'tGlobal', 'VAR', `with(p) { ${setupCode} }`);
|
|
687
|
+
const wrappedDraw = new Function('p', 'frameCount', 't', 'time', 'tGlobal', 'VAR', `with(p) { ${drawCode} }`);
|
|
688
|
+
wrappedSetup(p, 0, 0, 0, 0, p.VAR);
|
|
582
689
|
const loop = () => {
|
|
583
690
|
if (!isRunning || isDestroyed)
|
|
584
691
|
return;
|
|
@@ -588,7 +695,7 @@ export function renderCodeModeSystem(system, canvas, options = {}) {
|
|
|
588
695
|
injectTimeVariables(p, { frameCount: frame, t, time, tGlobal: t });
|
|
589
696
|
p.randomSeed(system.seed);
|
|
590
697
|
p.noiseSeed(system.seed);
|
|
591
|
-
wrappedDraw(p, frame, t, time, t);
|
|
698
|
+
wrappedDraw(p, frame, t, time, t, p.VAR);
|
|
592
699
|
drawBadge();
|
|
593
700
|
frame = (frame + 1) % totalFrames;
|
|
594
701
|
animationId = requestAnimationFrame(loop);
|
|
@@ -598,8 +705,9 @@ export function renderCodeModeSystem(system, canvas, options = {}) {
|
|
|
598
705
|
}
|
|
599
706
|
catch (error) {
|
|
600
707
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
708
|
+
console.error('[UIRenderer Protocol Error]', err.message);
|
|
709
|
+
renderBlackCanvas(err);
|
|
601
710
|
onError?.(err);
|
|
602
|
-
throw err;
|
|
603
711
|
}
|
|
604
712
|
};
|
|
605
713
|
const render = () => {
|
package/dist/system.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../src/system.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EAEZ,iBAAiB,EAEjB,gBAAgB,EAEhB,aAAa,EAGb,gBAAgB,EAKjB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../src/system.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EAEZ,iBAAiB,EAEjB,gBAAgB,EAEhB,aAAa,EAGb,gBAAgB,EAKjB,MAAM,SAAS,CAAC;AAgUjB,wBAAgB,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,gBAAgB,CAiBzE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CA8DnE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,gBAAgB,CAEjF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,aAAa,CAEjF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,iBAAiB,CAErF"}
|
package/dist/system.js
CHANGED
|
@@ -228,6 +228,22 @@ function validateCodeSystem(input) {
|
|
|
228
228
|
if (input.seed !== undefined && typeof input.seed !== 'number') {
|
|
229
229
|
errors.push('seed must be a number');
|
|
230
230
|
}
|
|
231
|
+
if (input.vars !== undefined) {
|
|
232
|
+
if (!Array.isArray(input.vars)) {
|
|
233
|
+
errors.push('vars must be an array');
|
|
234
|
+
}
|
|
235
|
+
else if (input.vars.length !== 10) {
|
|
236
|
+
errors.push('[Code Mode Protocol Error] VAR array must have exactly 10 elements');
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
for (let i = 0; i < input.vars.length; i++) {
|
|
240
|
+
const v = input.vars[i];
|
|
241
|
+
if (typeof v !== 'number') {
|
|
242
|
+
errors.push(`[Code Mode Protocol Error] VAR[${i}] must be a number`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
231
247
|
return errors;
|
|
232
248
|
}
|
|
233
249
|
function validateDeclarativeSystem(input) {
|
|
@@ -289,6 +305,7 @@ export function createSystem(input) {
|
|
|
289
305
|
height: input.height,
|
|
290
306
|
seed: input.seed ?? Math.floor(Math.random() * 2147483647),
|
|
291
307
|
totalFrames: input.totalFrames,
|
|
308
|
+
vars: input.vars,
|
|
292
309
|
deterministic: true,
|
|
293
310
|
createdAt: new Date().toISOString(),
|
|
294
311
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -101,6 +101,7 @@ export interface CodeSystem {
|
|
|
101
101
|
height: number;
|
|
102
102
|
seed?: number;
|
|
103
103
|
totalFrames?: number;
|
|
104
|
+
vars?: number[];
|
|
104
105
|
}
|
|
105
106
|
export interface BackgroundConfig {
|
|
106
107
|
color: string;
|
|
@@ -197,6 +198,7 @@ export interface NexArtCodeSystem {
|
|
|
197
198
|
height: number;
|
|
198
199
|
seed: number;
|
|
199
200
|
totalFrames?: number;
|
|
201
|
+
vars?: number[];
|
|
200
202
|
deterministic: boolean;
|
|
201
203
|
createdAt: string;
|
|
202
204
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQrB,CAAC;AAEX,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AACrD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAE7E,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,gBAAgB,GACxB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,iBAAiB,GACjB,cAAc,CAAC;AAEnB,MAAM,MAAM,YAAY,GACpB,eAAe,GACf,UAAU,GACV,cAAc,GACd,OAAO,GACP,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GACrB,OAA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,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAEhF,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAChD,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IACvE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexart/ui-renderer",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Declarative and Code Mode system authoring SDK for NexArt Protocol (non-canonical, preview only)",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Declarative and Code Mode system authoring SDK for NexArt Protocol (non-canonical, preview only). Mirrors @nexart/codemode-sdk behavior faithfully.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -20,6 +20,9 @@
|
|
|
20
20
|
"build": "tsc",
|
|
21
21
|
"prepublishOnly": "npm run build"
|
|
22
22
|
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@nexart/codemode-sdk": "^1.0.0"
|
|
25
|
+
},
|
|
23
26
|
"devDependencies": {
|
|
24
27
|
"typescript": "^5.0.0"
|
|
25
28
|
},
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @nexart/ui-renderer v0.2.1 - Sketch Primitive Renderer
|
|
3
|
-
*
|
|
4
|
-
* Executes raw Code Mode p5-like sketches.
|
|
5
|
-
* This is NOT canonical output - for preview/exploration only.
|
|
6
|
-
*/
|
|
7
|
-
import type { SketchElement } from '../../types';
|
|
8
|
-
export interface SketchRenderer {
|
|
9
|
-
render: (frameCount: number) => void;
|
|
10
|
-
hasSetup: boolean;
|
|
11
|
-
hasDraw: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare function createSketchRenderer(element: SketchElement, ctx: CanvasRenderingContext2D, width: number, height: number, seed: number): SketchRenderer;
|
|
14
|
-
//# sourceMappingURL=sketch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sketch.d.ts","sourceRoot":"","sources":["../../../src/preview/primitives/sketch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA2ajD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,cAAc,CAwChB"}
|