@nexart/ui-renderer 0.8.1 → 0.8.2
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 +14 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/preview/canvas-scaler.d.ts +10 -0
- package/dist/preview/canvas-scaler.d.ts.map +1 -1
- package/dist/preview/canvas-scaler.js +10 -0
- package/dist/preview/code-renderer.d.ts.map +1 -1
- package/dist/preview/code-renderer.js +15 -1
- package/dist/preview/preview-engine.d.ts.map +1 -1
- package/dist/preview/preview-engine.js +9 -1
- package/dist/preview/unified-renderer.d.ts.map +1 -1
- package/dist/preview/unified-renderer.js +9 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @nexart/ui-renderer
|
|
2
2
|
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.2
|
|
4
4
|
|
|
5
5
|
**Lightweight Preview Runtime for NexArt Protocol**
|
|
6
6
|
|
|
@@ -19,6 +19,18 @@ Version: 0.8.1
|
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+
## v0.8.2 — Runtime Dimensions Fix
|
|
23
|
+
|
|
24
|
+
Fixed critical bug where preview scaling affected `width`/`height` inside sketches.
|
|
25
|
+
|
|
26
|
+
- **Runtime uses original dimensions**: `width` and `height` now match Code Mode exactly
|
|
27
|
+
- **Canvas buffer still scaled for performance**: Rendering is fast, semantics are correct
|
|
28
|
+
- **Loop animations work correctly**: Geometry math and timing no longer break
|
|
29
|
+
|
|
30
|
+
**Key rule enforced:** Preview scaling is a rendering concern, not a semantic one.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
22
34
|
## v0.8.1 — Canvas Scaling Fix
|
|
23
35
|
|
|
24
36
|
Fixed canvas zoom/cropping bug caused by resolution downscaling in v0.8.0.
|
|
@@ -213,7 +225,7 @@ import { getCapabilities } from '@nexart/ui-renderer';
|
|
|
213
225
|
|
|
214
226
|
const caps = getCapabilities();
|
|
215
227
|
// {
|
|
216
|
-
// version: '0.8.
|
|
228
|
+
// version: '0.8.2',
|
|
217
229
|
// isCanonical: false,
|
|
218
230
|
// isArchival: false,
|
|
219
231
|
// previewBudget: { MAX_FRAMES: 30, MAX_TOTAL_TIME_MS: 500, FRAME_STRIDE: 3 },
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @nexart/ui-renderer
|
|
3
|
-
* Version: 0.8.
|
|
3
|
+
* Version: 0.8.2
|
|
4
4
|
*
|
|
5
5
|
* Lightweight Preview Runtime for NexArt Protocol
|
|
6
6
|
*
|
|
@@ -46,7 +46,7 @@ export { calculateScaledDimensions, applyScaledDimensions, type ScaledDimensions
|
|
|
46
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';
|
|
47
47
|
export { AESTHETIC_DEFAULTS, SDK_VERSION as TYPE_SDK_VERSION } from './types';
|
|
48
48
|
export type { Capabilities, PrimitiveCapability, ParameterSpec, } from './capabilities';
|
|
49
|
-
export declare const SDK_VERSION = "0.8.
|
|
49
|
+
export declare const SDK_VERSION = "0.8.2";
|
|
50
50
|
export declare const PROTOCOL_VERSION = "0.8";
|
|
51
51
|
export declare const IS_CANONICAL = false;
|
|
52
52
|
export declare const IS_ARCHIVAL = false;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @nexart/ui-renderer
|
|
3
|
-
* Version: 0.8.
|
|
3
|
+
* Version: 0.8.2
|
|
4
4
|
*
|
|
5
5
|
* Lightweight Preview Runtime for NexArt Protocol
|
|
6
6
|
*
|
|
@@ -44,7 +44,7 @@ export { PREVIEW_BUDGET, CANVAS_LIMITS, } from './preview/preview-types';
|
|
|
44
44
|
export { createFrameBudget, canRenderFrame, recordFrame, resetBudget, shouldSkipFrame, } from './preview/frame-budget';
|
|
45
45
|
export { calculateScaledDimensions, applyScaledDimensions, } from './preview/canvas-scaler';
|
|
46
46
|
export { AESTHETIC_DEFAULTS, SDK_VERSION as TYPE_SDK_VERSION } from './types';
|
|
47
|
-
export const SDK_VERSION = '0.8.
|
|
47
|
+
export const SDK_VERSION = '0.8.2';
|
|
48
48
|
export const PROTOCOL_VERSION = '0.8';
|
|
49
49
|
export const IS_CANONICAL = false;
|
|
50
50
|
export const IS_ARCHIVAL = false;
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
* ║ Max dimension: 900px ║
|
|
11
11
|
* ║ Preserves aspect ratio ║
|
|
12
12
|
* ║ Uses CSS scaling for display ║
|
|
13
|
+
* ╠══════════════════════════════════════════════════════════════════════════╣
|
|
14
|
+
* ║ ARCHITECTURAL INVARIANT (v0.8.2+): ║
|
|
15
|
+
* ║ ║
|
|
16
|
+
* ║ Scaling is a RENDERING concern, NOT a SEMANTIC one. ║
|
|
17
|
+
* ║ ║
|
|
18
|
+
* ║ - Canvas buffer: scaled (renderWidth × renderHeight) ║
|
|
19
|
+
* ║ - Runtime width/height: ALWAYS original protocol dimensions ║
|
|
20
|
+
* ║ - Context transform: ctx.scale() maps original → render space ║
|
|
21
|
+
* ║ ║
|
|
22
|
+
* ║ This ensures sketch math works identically in preview and Code Mode. ║
|
|
13
23
|
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
14
24
|
*/
|
|
15
25
|
export interface ScaledDimensions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-scaler.d.ts","sourceRoot":"","sources":["../../src/preview/canvas-scaler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"canvas-scaler.d.ts","sourceRoot":"","sources":["../../src/preview/canvas-scaler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,gBAAgB,GAC3B,IAAI,CAaN;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,wBAAwB,EAC7B,MAAM,EAAE,iBAAiB,GACxB,IAAI,CAKN"}
|
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
* ║ Max dimension: 900px ║
|
|
11
11
|
* ║ Preserves aspect ratio ║
|
|
12
12
|
* ║ Uses CSS scaling for display ║
|
|
13
|
+
* ╠══════════════════════════════════════════════════════════════════════════╣
|
|
14
|
+
* ║ ARCHITECTURAL INVARIANT (v0.8.2+): ║
|
|
15
|
+
* ║ ║
|
|
16
|
+
* ║ Scaling is a RENDERING concern, NOT a SEMANTIC one. ║
|
|
17
|
+
* ║ ║
|
|
18
|
+
* ║ - Canvas buffer: scaled (renderWidth × renderHeight) ║
|
|
19
|
+
* ║ - Runtime width/height: ALWAYS original protocol dimensions ║
|
|
20
|
+
* ║ - Context transform: ctx.scale() maps original → render space ║
|
|
21
|
+
* ║ ║
|
|
22
|
+
* ║ This ensures sketch math works identically in preview and Code Mode. ║
|
|
13
23
|
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
14
24
|
*/
|
|
15
25
|
import { CANVAS_LIMITS } from './preview-types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-renderer.d.ts","sourceRoot":"","sources":["../../src/preview/code-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA0BjE,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;AAwBD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,cAAmB,GAC3B,YAAY,
|
|
1
|
+
{"version":3,"file":"code-renderer.d.ts","sourceRoot":"","sources":["../../src/preview/code-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA0BjE,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;AAwBD,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,cAAmB,GAC3B,YAAY,CA0Pd"}
|
|
@@ -70,7 +70,21 @@ export function renderCodeModeSystem(system, canvas, options = {}) {
|
|
|
70
70
|
let setupFn = null;
|
|
71
71
|
let drawFn = null;
|
|
72
72
|
const compileSource = () => {
|
|
73
|
-
|
|
73
|
+
// ╔═══════════════════════════════════════════════════════════════════════╗
|
|
74
|
+
// ║ ARCHITECTURAL INVARIANT — DO NOT CHANGE ║
|
|
75
|
+
// ║ ║
|
|
76
|
+
// ║ Runtime width/height MUST always equal protocol dimensions. ║
|
|
77
|
+
// ║ DO NOT pass scaled values (renderWidth/renderHeight) here. ║
|
|
78
|
+
// ║ ║
|
|
79
|
+
// ║ Scaling is a RENDERING concern handled by ctx.scale(). ║
|
|
80
|
+
// ║ width/height are SEMANTIC values used by sketch math. ║
|
|
81
|
+
// ║ ║
|
|
82
|
+
// ║ Passing scaled dimensions breaks loop animations and geometry. ║
|
|
83
|
+
// ║ This invariant is locked for v0.x — see CHANGELOG v0.8.2. ║
|
|
84
|
+
// ╚═══════════════════════════════════════════════════════════════════════╝
|
|
85
|
+
runtime = createPreviewRuntime(canvas, scaled.originalWidth, // ← Protocol dimension (e.g. 1950)
|
|
86
|
+
scaled.originalHeight, // ← Protocol dimension (e.g. 2400)
|
|
87
|
+
system.seed ?? 12345, normalizedVars);
|
|
74
88
|
const totalFrames = system.totalFrames ?? 120;
|
|
75
89
|
runtime.totalFrames = totalFrames;
|
|
76
90
|
try {
|
|
@@ -1 +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;
|
|
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;AA8MzB;;;;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"}
|
|
@@ -49,7 +49,15 @@ class PreviewEngine {
|
|
|
49
49
|
// NOTE: Canvas resizing resets the 2D context transform.
|
|
50
50
|
// Reapply scale factor once after resize for correct rendering.
|
|
51
51
|
reapplyContextScale(this.canvas, scaled);
|
|
52
|
-
|
|
52
|
+
// ╔═══════════════════════════════════════════════════════════════════════╗
|
|
53
|
+
// ║ ARCHITECTURAL INVARIANT — DO NOT CHANGE ║
|
|
54
|
+
// ║ Runtime width/height MUST equal protocol dimensions. ║
|
|
55
|
+
// ║ DO NOT pass renderWidth/renderHeight — breaks loop animations. ║
|
|
56
|
+
// ║ Scaling is handled by ctx.scale(), not by changing width/height. ║
|
|
57
|
+
// ╚═══════════════════════════════════════════════════════════════════════╝
|
|
58
|
+
this.runtime = createPreviewRuntime(this.canvas, scaled.originalWidth, // ← Protocol dimension
|
|
59
|
+
scaled.originalHeight, // ← Protocol dimension
|
|
60
|
+
this.config.seed ?? 12345, this.config.vars ?? []);
|
|
53
61
|
const totalFrames = this.config.totalFrames ?? 120;
|
|
54
62
|
this.runtime.totalFrames = totalFrames;
|
|
55
63
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unified-renderer.d.ts","sourceRoot":"","sources":["../../src/preview/unified-renderer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAkB,cAAc,EAAoE,MAAM,UAAU,CAAC;AAmBhJ,MAAM,WAAW,eAAe;IAC9B,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;AA6ED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,cAAmB,GAC3B,eAAe,
|
|
1
|
+
{"version":3,"file":"unified-renderer.d.ts","sourceRoot":"","sources":["../../src/preview/unified-renderer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAkB,cAAc,EAAoE,MAAM,UAAU,CAAC;AAmBhJ,MAAM,WAAW,eAAe;IAC9B,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;AA6ED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,iBAAiB,EACzB,OAAO,GAAE,cAAmB,GAC3B,eAAe,CAqQjB"}
|
|
@@ -225,7 +225,15 @@ export function renderUnifiedSystem(system, canvas, options = {}) {
|
|
|
225
225
|
return;
|
|
226
226
|
try {
|
|
227
227
|
let frameCount = 0;
|
|
228
|
-
|
|
228
|
+
// ╔═══════════════════════════════════════════════════════════════════════╗
|
|
229
|
+
// ║ ARCHITECTURAL INVARIANT — DO NOT CHANGE ║
|
|
230
|
+
// ║ Runtime width/height MUST equal protocol dimensions. ║
|
|
231
|
+
// ║ DO NOT pass renderWidth/renderHeight — breaks loop animations. ║
|
|
232
|
+
// ║ Scaling is handled by ctx.scale(), not by changing width/height. ║
|
|
233
|
+
// ╚═══════════════════════════════════════════════════════════════════════╝
|
|
234
|
+
const p = createPreviewRuntime(canvas, scaled.originalWidth, // ← Protocol dimension
|
|
235
|
+
scaled.originalHeight, // ← Protocol dimension
|
|
236
|
+
system.seed);
|
|
229
237
|
runSetup(p);
|
|
230
238
|
resetBudget(budget);
|
|
231
239
|
isRunning = true;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @nexart/ui-renderer v0.8.
|
|
2
|
+
* @nexart/ui-renderer v0.8.2 - Type Definitions
|
|
3
3
|
*
|
|
4
4
|
* Lightweight Preview Runtime for NexArt Protocol.
|
|
5
5
|
* This SDK is non-canonical and for preview only.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - Max total time: 500ms
|
|
10
10
|
* - Max canvas dimension: 900px
|
|
11
11
|
*/
|
|
12
|
-
export declare const SDK_VERSION = "0.8.
|
|
12
|
+
export declare const SDK_VERSION = "0.8.2";
|
|
13
13
|
export declare const AESTHETIC_DEFAULTS: {
|
|
14
14
|
readonly background: {
|
|
15
15
|
readonly r: 246;
|
package/dist/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @nexart/ui-renderer v0.8.
|
|
2
|
+
* @nexart/ui-renderer v0.8.2 - Type Definitions
|
|
3
3
|
*
|
|
4
4
|
* Lightweight Preview Runtime for NexArt Protocol.
|
|
5
5
|
* This SDK is non-canonical and for preview only.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - Max total time: 500ms
|
|
10
10
|
* - Max canvas dimension: 900px
|
|
11
11
|
*/
|
|
12
|
-
export const SDK_VERSION = '0.8.
|
|
12
|
+
export const SDK_VERSION = '0.8.2';
|
|
13
13
|
export const AESTHETIC_DEFAULTS = {
|
|
14
14
|
background: { r: 246, g: 245, b: 242 },
|
|
15
15
|
foreground: { r: 45, g: 45, b: 45 },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexart/ui-renderer",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Lightweight Preview Runtime for NexArt Protocol. Non-canonical, performance-optimized with budget limits (max 30 frames, 500ms, 900px canvas).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|