@nexart/ui-renderer 0.6.0 → 0.8.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 (40) hide show
  1. package/README.md +133 -322
  2. package/dist/capabilities.d.ts +5 -6
  3. package/dist/capabilities.d.ts.map +1 -1
  4. package/dist/capabilities.js +6 -7
  5. package/dist/compiler.d.ts +3 -2
  6. package/dist/compiler.d.ts.map +1 -1
  7. package/dist/compiler.js +4 -3
  8. package/dist/index.d.ts +33 -29
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +33 -29
  11. package/dist/preview/canvas-scaler.d.ts +49 -0
  12. package/dist/preview/canvas-scaler.d.ts.map +1 -0
  13. package/dist/preview/canvas-scaler.js +74 -0
  14. package/dist/preview/code-renderer.d.ts +11 -28
  15. package/dist/preview/code-renderer.d.ts.map +1 -1
  16. package/dist/preview/code-renderer.js +116 -661
  17. package/dist/preview/frame-budget.d.ts +43 -0
  18. package/dist/preview/frame-budget.d.ts.map +1 -0
  19. package/dist/preview/frame-budget.js +78 -0
  20. package/dist/preview/preview-engine.d.ts +42 -0
  21. package/dist/preview/preview-engine.d.ts.map +1 -0
  22. package/dist/preview/preview-engine.js +201 -0
  23. package/dist/preview/preview-runtime.d.ts +28 -0
  24. package/dist/preview/preview-runtime.d.ts.map +1 -0
  25. package/dist/preview/preview-runtime.js +512 -0
  26. package/dist/preview/preview-types.d.ts +116 -0
  27. package/dist/preview/preview-types.d.ts.map +1 -0
  28. package/dist/preview/preview-types.js +36 -0
  29. package/dist/preview/renderer.d.ts +3 -2
  30. package/dist/preview/renderer.d.ts.map +1 -1
  31. package/dist/preview/renderer.js +3 -2
  32. package/dist/preview/unified-renderer.d.ts.map +1 -1
  33. package/dist/preview/unified-renderer.js +45 -22
  34. package/dist/system.d.ts +2 -2
  35. package/dist/system.d.ts.map +1 -1
  36. package/dist/system.js +8 -10
  37. package/dist/types.d.ts +9 -5
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/types.js +9 -5
  40. package/package.json +3 -3
@@ -1,13 +1,12 @@
1
1
  /**
2
- * @nexart/ui-renderer v0.6.0 - Capabilities Discovery
2
+ * @nexart/ui-renderer v0.8.0 - Capabilities Discovery
3
3
  *
4
4
  * Exposes SDK capabilities for AI tools and builders.
5
- * Critical for preventing hallucination and SDK bypass.
5
+ * Lightweight preview runtime no protocol enforcement.
6
6
  *
7
- * ⚠️ PRIMITIVES ARE NON-CANONICAL
8
- * Primitives are helper generators that compile to Code Mode sketches.
9
- * They exist for convenience and rapid prototyping only.
10
- * The canonical output is always the compiled Code Mode source.
7
+ * ⚠️ PREVIEW ONLY
8
+ * This SDK provides preview rendering with performance limits.
9
+ * For canonical output: use @nexart/codemode-sdk
11
10
  */
12
11
  const SHARED_PARAMS = {
13
12
  count: {
@@ -59,7 +58,7 @@ function createPrimitive(name, category, description) {
59
58
  }
60
59
  export function getCapabilities() {
61
60
  return {
62
- version: '0.6.0',
61
+ version: '0.8.0',
63
62
  isCanonical: false,
64
63
  isArchival: false,
65
64
  renderer: '@nexart/ui-renderer',
@@ -1,7 +1,8 @@
1
1
  /**
2
- * @nexart/ui-renderer v0.3.0 - System Compiler
2
+ * @nexart/ui-renderer v0.8.0 - System Compiler
3
3
  *
4
- * Compiles validated systems into canonical protocol-compatible JSON.
4
+ * Compiles validated systems into protocol-compatible JSON.
5
+ * Lightweight preview runtime — no protocol enforcement.
5
6
  */
6
7
  import type { NexArtSystem } from './types';
7
8
  export interface CompiledDeclarativeSystem {
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAsD,MAAM,SAAS,CAAC;AAGhG,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,aAAa,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,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Aa,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAMlE;AAyFD,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAG5D"}
package/dist/compiler.js CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
- * @nexart/ui-renderer v0.3.0 - System Compiler
2
+ * @nexart/ui-renderer v0.8.0 - System Compiler
3
3
  *
4
- * Compiles validated systems into canonical protocol-compatible JSON.
4
+ * Compiles validated systems into protocol-compatible JSON.
5
+ * Lightweight preview runtime — no protocol enforcement.
5
6
  */
6
7
  import { isCodeModeSystem } from './system';
7
- const COMPILER_VERSION = '0.3.0';
8
+ const COMPILER_VERSION = '0.8.0';
8
9
  export function compileSystem(system) {
9
10
  if (isCodeModeSystem(system)) {
10
11
  return compileCodeSystem(system);
package/dist/index.d.ts CHANGED
@@ -1,34 +1,34 @@
1
1
  /**
2
2
  * @nexart/ui-renderer
3
- * Version: 0.6.0
3
+ * Version: 0.8.0
4
4
  *
5
- * Opinionated Generative Design System SDK for NexArt Protocol
5
+ * Lightweight Preview Runtime for NexArt Protocol
6
6
  *
7
- * ⚠️ IMPORTANT DISCLAIMER
8
- *
9
- * This SDK is for authoring and preview only.
10
- * Canonical, archival output is produced exclusively by @nexart/codemode-sdk.
11
- *
12
- * This renderer is:
13
- * - NOT canonical
14
- * - NOT archival
15
- * - NOT protocol-authoritative
16
- *
17
- * Use it for:
18
- * - Creating NexArt systems with background/primitive/sketch elements
19
- * - Previewing systems in the browser
20
- * - Building AI-friendly generative backgrounds
21
- * - Building platforms, tools, and integrations
22
- *
23
- * Design Philosophy:
24
- * - Beauty by default > unlimited freedom
25
- * - Aesthetic guardrails ensure pleasing output automatically
26
- * - All elements compile to Code Mode for deterministic rendering
27
- *
28
- * ⚠️ PRIMITIVES ARE NON-CANONICAL
29
- * Primitives are helper generators that compile to Code Mode sketches.
30
- * They exist for convenience and rapid prototyping only.
31
- * The canonical output is always the compiled Code Mode source.
7
+ * ╔══════════════════════════════════════════════════════════════════════════╗
8
+ * ║ PREVIEW RUNTIME — NON-AUTHORITATIVE ║
9
+ * ║ ║
10
+ * ║ This renderer is a preview-only runtime.
11
+ * ║ It does not guarantee determinism or protocol compliance. ║
12
+ * ║ ║
13
+ * ║ Performance Limits: ║
14
+ * - Max frames: 30 ║
15
+ * - Max total time: 500ms ║
16
+ * ║ - Max canvas dimension: 900px ║
17
+ * ║ - Frame stride: render every 3rd frame ║
18
+ * ║ ║
19
+ * ║ Use Cases: ║
20
+ * - Editor live preview ║
21
+ * - Builder dashboards ║
22
+ * ║ - Background generative art ║
23
+ * ║ - Static or loop previews ║
24
+ * ║ ║
25
+ * ║ NOT For: ║
26
+ * - Minting / export ║
27
+ * ║ - ByX ║
28
+ * ║ - Protocol validation ║
29
+ * ║ ║
30
+ * ║ For canonical output: use @nexart/codemode-sdk ║
31
+ * ╚══════════════════════════════════════════════════════════════════════════╝
32
32
  */
33
33
  export { createSystem, validateSystem, isCodeModeSystem, isDeclarativeSystem, isUnifiedModeSystem } from './system';
34
34
  export { compileSystem, serializeSystem } from './compiler';
@@ -39,11 +39,15 @@ export { compileBackgroundPreset, getPaletteColors } from './presets/backgrounds
39
39
  export { compilePrimitive } from './presets/primitives';
40
40
  export { wrapSketch, validateSketchSafety } from './presets/sketch-wrapper';
41
41
  export { getCapabilities, getPrimitiveTypes, getPrimitivesByCategory, getPrimitiveInfo, isPrimitiveValid, getMotionSources, getBackgroundTextures, } from './capabilities';
42
+ export { createPreviewEngine, renderStaticPreview, stopActivePreview, } from './preview/preview-engine';
43
+ export { PREVIEW_BUDGET, CANVAS_LIMITS, type RuntimeProfile, type PreviewMode, type PreviewEngineConfig, type PreviewRenderResult, type PreviewRenderer, type FrameBudgetState, } from './preview/preview-types';
44
+ export { createFrameBudget, canRenderFrame, recordFrame, resetBudget, shouldSkipFrame, } from './preview/frame-budget';
45
+ export { calculateScaledDimensions, applyScaledDimensions, type ScaledDimensions, } from './preview/canvas-scaler';
42
46
  export type { NexArtSystemInput, NexArtSystem, DeclarativeSystemInput, DeclarativeSystem, CodeSystem, NexArtCodeSystem, UnifiedSystemInput, UnifiedSystem, UnifiedElement, BackgroundElement, PrimitiveElement, SketchElement, BackgroundPreset, PrimitiveName, ColorPalette, MotionSpeed, StrokeWeightAuto, LoopConfig, DeclarativeElement, SystemElement, DotsElement, LinesElement, WavesElement, GridElement, FlowFieldElement, OrbitsElement, BackgroundConfig, MotionConfig, PreviewOptions, ValidationResult, } from './types';
43
47
  export { AESTHETIC_DEFAULTS, SDK_VERSION as TYPE_SDK_VERSION } from './types';
44
48
  export type { Capabilities, PrimitiveCapability, ParameterSpec, } from './capabilities';
45
- export declare const SDK_VERSION = "0.6.0";
46
- export declare const PROTOCOL_VERSION = "0.6";
49
+ export declare const SDK_VERSION = "0.8.0";
50
+ export declare const PROTOCOL_VERSION = "0.8";
47
51
  export declare const IS_CANONICAL = false;
48
52
  export declare const IS_ARCHIVAL = false;
49
53
  export declare const RENDERER = "@nexart/ui-renderer";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACpH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE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WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,kBAAkB,EAAE,WAAW,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE9E,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,aAAa,GACd,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,gBAAgB,QAAQ,CAAC;AACtC,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,WAAW,QAAQ,CAAC;AACjC,eAAO,MAAM,QAAQ,wBAAwB,CAAC;AAC9C,eAAO,MAAM,wBAAwB,QAAQ,CAAC"}
package/dist/index.js CHANGED
@@ -1,34 +1,34 @@
1
1
  /**
2
2
  * @nexart/ui-renderer
3
- * Version: 0.6.0
3
+ * Version: 0.8.0
4
4
  *
5
- * Opinionated Generative Design System SDK for NexArt Protocol
5
+ * Lightweight Preview Runtime for NexArt Protocol
6
6
  *
7
- * ⚠️ IMPORTANT DISCLAIMER
8
- *
9
- * This SDK is for authoring and preview only.
10
- * Canonical, archival output is produced exclusively by @nexart/codemode-sdk.
11
- *
12
- * This renderer is:
13
- * - NOT canonical
14
- * - NOT archival
15
- * - NOT protocol-authoritative
16
- *
17
- * Use it for:
18
- * - Creating NexArt systems with background/primitive/sketch elements
19
- * - Previewing systems in the browser
20
- * - Building AI-friendly generative backgrounds
21
- * - Building platforms, tools, and integrations
22
- *
23
- * Design Philosophy:
24
- * - Beauty by default > unlimited freedom
25
- * - Aesthetic guardrails ensure pleasing output automatically
26
- * - All elements compile to Code Mode for deterministic rendering
27
- *
28
- * ⚠️ PRIMITIVES ARE NON-CANONICAL
29
- * Primitives are helper generators that compile to Code Mode sketches.
30
- * They exist for convenience and rapid prototyping only.
31
- * The canonical output is always the compiled Code Mode source.
7
+ * ╔══════════════════════════════════════════════════════════════════════════╗
8
+ * ║ PREVIEW RUNTIME — NON-AUTHORITATIVE ║
9
+ * ║ ║
10
+ * ║ This renderer is a preview-only runtime.
11
+ * ║ It does not guarantee determinism or protocol compliance. ║
12
+ * ║ ║
13
+ * ║ Performance Limits: ║
14
+ * - Max frames: 30 ║
15
+ * - Max total time: 500ms ║
16
+ * ║ - Max canvas dimension: 900px ║
17
+ * ║ - Frame stride: render every 3rd frame ║
18
+ * ║ ║
19
+ * ║ Use Cases: ║
20
+ * - Editor live preview ║
21
+ * - Builder dashboards ║
22
+ * ║ - Background generative art ║
23
+ * ║ - Static or loop previews ║
24
+ * ║ ║
25
+ * ║ NOT For: ║
26
+ * - Minting / export ║
27
+ * ║ - ByX ║
28
+ * ║ - Protocol validation ║
29
+ * ║ ║
30
+ * ║ For canonical output: use @nexart/codemode-sdk ║
31
+ * ╚══════════════════════════════════════════════════════════════════════════╝
32
32
  */
33
33
  export { createSystem, validateSystem, isCodeModeSystem, isDeclarativeSystem, isUnifiedModeSystem } from './system';
34
34
  export { compileSystem, serializeSystem } from './compiler';
@@ -39,9 +39,13 @@ export { compileBackgroundPreset, getPaletteColors } from './presets/backgrounds
39
39
  export { compilePrimitive } from './presets/primitives';
40
40
  export { wrapSketch, validateSketchSafety } from './presets/sketch-wrapper';
41
41
  export { getCapabilities, getPrimitiveTypes, getPrimitivesByCategory, getPrimitiveInfo, isPrimitiveValid, getMotionSources, getBackgroundTextures, } from './capabilities';
42
+ export { createPreviewEngine, renderStaticPreview, stopActivePreview, } from './preview/preview-engine';
43
+ export { PREVIEW_BUDGET, CANVAS_LIMITS, } from './preview/preview-types';
44
+ export { createFrameBudget, canRenderFrame, recordFrame, resetBudget, shouldSkipFrame, } from './preview/frame-budget';
45
+ export { calculateScaledDimensions, applyScaledDimensions, } from './preview/canvas-scaler';
42
46
  export { AESTHETIC_DEFAULTS, SDK_VERSION as TYPE_SDK_VERSION } from './types';
43
- export const SDK_VERSION = '0.6.0';
44
- export const PROTOCOL_VERSION = '0.6';
47
+ export const SDK_VERSION = '0.8.0';
48
+ export const PROTOCOL_VERSION = '0.8';
45
49
  export const IS_CANONICAL = false;
46
50
  export const IS_ARCHIVAL = false;
47
51
  export const RENDERER = '@nexart/ui-renderer';
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @nexart/ui-renderer - Canvas Scaler
3
+ *
4
+ * Scales canvas resolution for preview rendering.
5
+ * Preview renderer does NOT render at full mint resolution.
6
+ *
7
+ * ╔══════════════════════════════════════════════════════════════════════════╗
8
+ * ║ CANVAS SCALING — PERFORMANCE CRITICAL ║
9
+ * ║ ║
10
+ * ║ Max dimension: 900px ║
11
+ * ║ Preserves aspect ratio ║
12
+ * ║ Uses CSS scaling for display ║
13
+ * ╚══════════════════════════════════════════════════════════════════════════╝
14
+ */
15
+ export interface ScaledDimensions {
16
+ /** Scaled width for rendering */
17
+ renderWidth: number;
18
+ /** Scaled height for rendering */
19
+ renderHeight: number;
20
+ /** Original width */
21
+ originalWidth: number;
22
+ /** Original height */
23
+ originalHeight: number;
24
+ /** Scale factor applied */
25
+ scaleFactor: number;
26
+ /** Whether scaling was applied */
27
+ wasScaled: boolean;
28
+ }
29
+ /**
30
+ * Calculate scaled dimensions for preview rendering.
31
+ * Maintains aspect ratio, caps at MAX_DIMENSION.
32
+ */
33
+ export declare function calculateScaledDimensions(width: number, height: number): ScaledDimensions;
34
+ /**
35
+ * Apply scaled dimensions to a canvas element.
36
+ * Sets canvas internal resolution and CSS display size.
37
+ */
38
+ export declare function applyScaledDimensions(canvas: HTMLCanvasElement, dimensions: ScaledDimensions): void;
39
+ /**
40
+ * Scale coordinates from original space to render space.
41
+ * Used when the sketch uses original coordinates but canvas is scaled.
42
+ */
43
+ export declare function scaleCoordinate(value: number, scaleFactor: number): number;
44
+ /**
45
+ * Create a scaling transform for the canvas context.
46
+ * This allows sketches to use original coordinates while rendering at scaled resolution.
47
+ */
48
+ export declare function applyScaleTransform(ctx: CanvasRenderingContext2D, scaleFactor: number): void;
49
+ //# sourceMappingURL=canvas-scaler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-scaler.d.ts","sourceRoot":"","sources":["../../src/preview/canvas-scaler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,2BAA2B;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,gBAAgB,CA0BlB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,gBAAgB,GAC3B,IAAI,CAWN;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,MAAM,CAER;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,wBAAwB,EAC7B,WAAW,EAAE,MAAM,GAClB,IAAI,CAIN"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @nexart/ui-renderer - Canvas Scaler
3
+ *
4
+ * Scales canvas resolution for preview rendering.
5
+ * Preview renderer does NOT render at full mint resolution.
6
+ *
7
+ * ╔══════════════════════════════════════════════════════════════════════════╗
8
+ * ║ CANVAS SCALING — PERFORMANCE CRITICAL ║
9
+ * ║ ║
10
+ * ║ Max dimension: 900px ║
11
+ * ║ Preserves aspect ratio ║
12
+ * ║ Uses CSS scaling for display ║
13
+ * ╚══════════════════════════════════════════════════════════════════════════╝
14
+ */
15
+ import { CANVAS_LIMITS } from './preview-types';
16
+ /**
17
+ * Calculate scaled dimensions for preview rendering.
18
+ * Maintains aspect ratio, caps at MAX_DIMENSION.
19
+ */
20
+ export function calculateScaledDimensions(width, height) {
21
+ const maxDim = Math.max(width, height);
22
+ // If already within limits, no scaling needed
23
+ if (maxDim <= CANVAS_LIMITS.MAX_DIMENSION) {
24
+ return {
25
+ renderWidth: width,
26
+ renderHeight: height,
27
+ originalWidth: width,
28
+ originalHeight: height,
29
+ scaleFactor: 1,
30
+ wasScaled: false,
31
+ };
32
+ }
33
+ // Calculate scale factor to fit within limits
34
+ const scaleFactor = CANVAS_LIMITS.MAX_DIMENSION / maxDim;
35
+ return {
36
+ renderWidth: Math.round(width * scaleFactor),
37
+ renderHeight: Math.round(height * scaleFactor),
38
+ originalWidth: width,
39
+ originalHeight: height,
40
+ scaleFactor,
41
+ wasScaled: true,
42
+ };
43
+ }
44
+ /**
45
+ * Apply scaled dimensions to a canvas element.
46
+ * Sets canvas internal resolution and CSS display size.
47
+ */
48
+ export function applyScaledDimensions(canvas, dimensions) {
49
+ // Set canvas internal resolution (what we actually render)
50
+ canvas.width = dimensions.renderWidth;
51
+ canvas.height = dimensions.renderHeight;
52
+ // Set CSS display size (visual size in the UI)
53
+ // This allows the canvas to display at a larger size while rendering at lower resolution
54
+ if (dimensions.wasScaled) {
55
+ canvas.style.width = `${dimensions.originalWidth}px`;
56
+ canvas.style.height = `${dimensions.originalHeight}px`;
57
+ }
58
+ }
59
+ /**
60
+ * Scale coordinates from original space to render space.
61
+ * Used when the sketch uses original coordinates but canvas is scaled.
62
+ */
63
+ export function scaleCoordinate(value, scaleFactor) {
64
+ return value * scaleFactor;
65
+ }
66
+ /**
67
+ * Create a scaling transform for the canvas context.
68
+ * This allows sketches to use original coordinates while rendering at scaled resolution.
69
+ */
70
+ export function applyScaleTransform(ctx, scaleFactor) {
71
+ if (scaleFactor !== 1) {
72
+ ctx.scale(scaleFactor, scaleFactor);
73
+ }
74
+ }
@@ -1,28 +1,20 @@
1
1
  /**
2
- * @nexart/ui-renderer v0.6.0 - Code Mode Renderer
2
+ * @nexart/ui-renderer v0.8.0 - Code Mode Renderer
3
3
  *
4
4
  * ╔══════════════════════════════════════════════════════════════════════════╗
5
- * ║ PREVIEW RENDERER — MIRRORS @nexart/codemode-sdk BEHAVIOR
5
+ * ║ PREVIEW RENDERER — LIGHTWEIGHT, NON-AUTHORITATIVE
6
6
  * ║ ║
7
- * ║ This file is a MIRROR, not an authority. ║
7
+ * ║ This renderer is a preview-only runtime. ║
8
+ * ║ It does not guarantee determinism or protocol compliance. ║
8
9
  * ║ ║
9
- * ║ Authority: @nexart/codemode-sdk (Protocol v1.0.0)
10
+ * ║ Performance Limits (MANDATORY):
11
+ * ║ - Max frames: 30 ║
12
+ * ║ - Max total time: 500ms ║
13
+ * ║ - Max canvas dimension: 900px ║
14
+ * ║ - Frame stride: render every 3rd frame ║
15
+ * ║ ║
16
+ * ║ For minting, export, or validation: use @nexart/codemode-sdk ║
10
17
  * ╚══════════════════════════════════════════════════════════════════════════╝
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, 0-10 input → 10 runtime, 0-100 strict, 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.
26
18
  */
27
19
  import type { NexArtCodeSystem, PreviewOptions } from '../types';
28
20
  export interface CodeRenderer {
@@ -33,14 +25,5 @@ export interface CodeRenderer {
33
25
  isCanonical: false;
34
26
  isArchival: false;
35
27
  }
36
- interface P5Runtime {
37
- [key: string]: any;
38
- width: number;
39
- height: number;
40
- frameCount: number;
41
- VAR: readonly number[];
42
- }
43
- export declare function createP5Runtime(canvas: HTMLCanvasElement, width: number, height: number, seed: number, vars?: number[]): P5Runtime;
44
28
  export declare function renderCodeModeSystem(system: NexArtCodeSystem, canvas: HTMLCanvasElement, options?: PreviewOptions): CodeRenderer;
45
- export {};
46
29
  //# sourceMappingURL=code-renderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-renderer.d.ts","sourceRoot":"","sources":["../../src/preview/code-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAMjE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,KAAK,CAAC;IACnB,UAAU,EAAE,KAAK,CAAC;CACnB;AAuDD,UAAU,SAAS;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;CACxB;AA+GD,wBAAgB,eAAe,CAC7B,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,EAAmC,GAC9C,SAAS,CA0eX;AAsCD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,cAAmB,GAC3B,YAAY,CA4Md"}
1
+ {"version":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