@nexart/ui-renderer 0.9.0 → 0.9.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/CHANGELOG.md CHANGED
@@ -4,6 +4,38 @@ All notable changes to @nexart/ui-renderer will be documented in this file.
4
4
 
5
5
  ---
6
6
 
7
+ ## [0.9.1] — 2026-01-24
8
+
9
+ ### Changed — Documentation & Positioning
10
+
11
+ **Non-Breaking, Metadata-Only Release**
12
+
13
+ This release repositions ui-renderer as a standalone, browser-first generative renderer — not merely a companion to codemode-sdk.
14
+
15
+ #### Documentation Reframed
16
+ - **Standalone positioning** — SDK is now described as "browser-first bounded generative renderer"
17
+ - **Removed "non-canonical" framing** — Replaced with "authoritative within bounded constraints"
18
+ - **Added "Standalone use cases"** — Backgrounds, editors, dashboards, mini-apps, education
19
+ - **Added "When to escalate"** — Minting, export, archival, verification
20
+ - **Added "Authority model" diagram** — Clear visual of where this SDK fits
21
+ - **Added "Trust & safety"** — Budgets, observability, what can differ
22
+ - **Moved codemode-sdk references** — Now in escalation section, not primary framing
23
+
24
+ #### Metadata Updates
25
+ - **Description**: "Browser-first bounded generative renderer for safe, fast, interactive visuals"
26
+ - **Keywords**: generative, renderer, canvas, creative-coding, preview, sandbox, bounded, runtime, miniapp
27
+ - **Homepage**: Added to package.json
28
+
29
+ ### Unchanged
30
+
31
+ - No changes to runtime behavior
32
+ - No changes to APIs or exports
33
+ - No changes to budget defaults
34
+ - No changes to canvas scaling
35
+ - Full backward compatibility with v0.9.0 and v0.8.x
36
+
37
+ ---
38
+
7
39
  ## [0.9.0] — 2026-01-24
8
40
 
9
41
  ### Added
package/README.md CHANGED
@@ -1,21 +1,82 @@
1
1
  # @nexart/ui-renderer
2
2
 
3
- Version: 0.9.0
3
+ **Version: 0.9.1**
4
4
 
5
- **Lightweight Preview Runtime for NexArt Protocol**
5
+ A browser-first bounded generative renderer for safe, fast, interactive visuals.
6
6
 
7
7
  ---
8
8
 
9
- > **This SDK is a PREVIEW RENDERER, not an authority.**
10
- >
11
- > It provides fast, lightweight previews for development and prototyping.
12
- >
13
- > It is:
14
- > - **NOT canonical** — Does not produce archival-quality output
15
- > - **NOT archival** — Not for minting, export, or permanent storage
16
- > - **NOT protocol-enforcing** — No validation errors, no pattern checking
17
- >
18
- > For canonical output, minting, or validation: use `@nexart/codemode-sdk`
9
+ ## What This SDK Does
10
+
11
+ This SDK provides a **bounded execution environment** for running generative code safely in the browser. It renders p5-like sketches with built-in safety limits:
12
+
13
+ - **Resolution cap** — Max 900px dimension for performance
14
+ - **Frame/time budgets** — Prevents runaway loops
15
+ - **Observable state** — Know exactly what the runtime is doing
16
+ - **Safe degradation** — Controlled behavior when limits hit
17
+
18
+ **Output is authoritative within bounded constraints.** What you see is what the sketch produces at preview resolution with preview budgets.
19
+
20
+ ---
21
+
22
+ ## Standalone Use Cases
23
+
24
+ This SDK is designed for:
25
+
26
+ - **Generative art backgrounds** — Dynamic visuals for web pages
27
+ - **Interactive creative coding editors** — Live preview while users code
28
+ - **Dashboard visuals** — Procedural data visualizations
29
+ - **Mini-app visuals** — Embedded generative elements
30
+ - **Educational demos** — Safe sandbox for teaching creative coding
31
+ - **UI-embedded procedural patterns** — Decorative generative elements
32
+
33
+ For these use cases, ui-renderer is the complete solution. No other SDK required.
34
+
35
+ ---
36
+
37
+ ## When to Escalate to Canonical Rendering
38
+
39
+ Use `@nexart/codemode-sdk` when you need:
40
+
41
+ - **Minting / export / archival** — Permanent, verifiable output
42
+ - **Reproducibility guarantees** — Exact same output every time, anywhere
43
+ - **Full resolution parity** — 1950×2400 or higher without scaling
44
+ - **Verification workflows** — Cryptographic digest matching
45
+
46
+ **ui-renderer → codemode-sdk is an escalation, not a requirement.**
47
+
48
+ Most interactive, preview, and display use cases are complete with ui-renderer alone.
49
+
50
+ ---
51
+
52
+ ## Authority Model
53
+
54
+ ```
55
+ ┌─────────────────────────────────────────────────────────┐
56
+ │ Your Application │
57
+ │ (React, Canvas, Three.js, editor, dashboard) │
58
+ └────────────────────────┬────────────────────────────────┘
59
+
60
+
61
+ ┌─────────────────────────────────────────────────────────┐
62
+ │ @nexart/ui-renderer │
63
+ │ Bounded browser runtime │
64
+ │ - Resolution scaling (max 900px) │
65
+ │ - Frame/time budgets │
66
+ │ - Observable stats │
67
+ │ - Controlled degradation │
68
+ └────────────────────────┬────────────────────────────────┘
69
+
70
+
71
+ ┌─────────────────────────────────────────────────────────┐
72
+ │ Output │
73
+ │ - Pixels on canvas │
74
+ │ - Runtime stats │
75
+ │ - Budget status │
76
+ │ │
77
+ │ ↳ Optional: toCanonicalRequest() for codemode-sdk │
78
+ └─────────────────────────────────────────────────────────┘
79
+ ```
19
80
 
20
81
  ---
21
82
 
@@ -46,63 +107,36 @@ const runtime = createPreviewRuntime({
46
107
  runtime.startLoop();
47
108
  ```
48
109
 
49
- Preview mode may visually differ due to scaling/budgets. For canonical output and verification, run the same code with `@nexart/codemode-sdk`.
50
-
51
- ### Detecting Preview Mode
110
+ ### Detecting Runtime Mode
52
111
 
53
112
  ```typescript
54
113
  const stats = runtime.getPreviewStats();
55
114
 
56
- if (stats.mode === 'preview') {
57
- console.log('Running in preview mode');
58
- console.log('Scale:', stats.scale);
59
- console.log('Frames:', stats.frames);
60
- }
115
+ console.log('Mode:', stats.mode); // 'preview'
116
+ console.log('Scale:', stats.scale); // 0.46
117
+ console.log('Frames:', stats.frames); // current frame count
118
+ console.log('Budget OK:', !stats.budgetExceeded);
61
119
  ```
62
120
 
63
- ### Handling Budget Exceeded
121
+ ### Handling Budget Limits
64
122
 
65
123
  ```typescript
66
124
  const stats = runtime.getPreviewStats();
67
125
 
68
126
  if (stats.budgetExceeded) {
69
- console.log('Exceeded:', stats.budgetExceeded.reason);
127
+ console.log('Reason:', stats.budgetExceeded.reason);
70
128
  // Options:
71
- // 1. Reduce sketch complexity (fewer iterations, simpler shapes)
72
- // 2. Increase maxFrames or maxTimeMs in config
73
- // 3. Use @nexart/codemode-sdk for canonical execution
129
+ // 1. Simplify sketch (fewer iterations)
130
+ // 2. Increase maxFrames or maxTimeMs
131
+ // 3. Use budgetBehavior: 'degrade' to continue with frame skipping
74
132
  }
75
133
  ```
76
134
 
77
135
  ---
78
136
 
79
- ## Preview vs Canonical
80
-
81
- | Aspect | Preview (@nexart/ui-renderer) | Canonical (@nexart/codemode-sdk) |
82
- |--------|-------------------------------|----------------------------------|
83
- | **Purpose** | Fast browser previews | Authoritative rendering |
84
- | **Determinism** | Approximate | Guaranteed |
85
- | **Resolution** | Max 900px | Full resolution (1950×2400) |
86
- | **FPS** | Native RAF (~60 FPS) | Full frame rate |
87
- | **Budget** | 1800 frames / 5 min | Unlimited |
88
- | **Use for** | Editor, dashboard, prototyping | Minting, export, archival |
137
+ ## Trust & Safety
89
138
 
90
- **Rule of thumb:**
91
- - Use **ui-renderer** for quick visual feedback during development
92
- - Use **codemode-sdk** for final output, minting, or any permanent storage
93
-
94
- ---
95
-
96
- ## v0.9.0 — Budget Callbacks + Observability
97
-
98
- ### New Features
99
-
100
- 1. **No more silent stops** — Budget exceeded now triggers callbacks and optional overlay
101
- 2. **getPreviewStats()** — Full observability into runtime state
102
- 3. **createPreviewRuntime()** — Recommended entrypoint for agents
103
- 4. **toCanonicalRequest()** — Handoff helper for @nexart/codemode-sdk
104
-
105
- ### Budget Configuration
139
+ ### Budgets Prevent Runaway Code
106
140
 
107
141
  ```typescript
108
142
  const runtime = createPreviewRuntime({
@@ -112,99 +146,83 @@ const runtime = createPreviewRuntime({
112
146
  width: 1950,
113
147
  height: 2400,
114
148
 
115
- // Budget options (all optional)
116
- maxFrames: 1800, // Max frames before budget exceeded
117
- maxTimeMs: 300000, // Max time (5 min default)
118
- budgetBehavior: 'stop', // 'stop' (with overlay) or 'degrade' (skip frames)
119
- showOverlay: true, // Show overlay when stopped
149
+ maxFrames: 1800, // Max frames before stop (default)
150
+ maxTimeMs: 300000, // Max 5 minutes (default)
151
+ budgetBehavior: 'stop', // 'stop' or 'degrade'
152
+ showOverlay: true, // Visual indicator when stopped
120
153
 
121
154
  onBudgetExceeded: (info) => {
122
- console.log('Budget exceeded:', info.reason);
123
- console.log('Frames:', info.framesRendered);
124
- console.log('Time:', info.totalTimeMs);
155
+ // No silent failures — you always know
156
+ console.log('Stopped:', info.reason);
125
157
  },
126
158
  });
127
159
  ```
128
160
 
129
- ### Preview Stats
161
+ ### Observable State
130
162
 
131
163
  ```typescript
132
164
  const stats = runtime.getPreviewStats();
133
165
  // {
134
166
  // mode: 'preview',
135
- // scale: 0.46, // Canvas scale factor
136
- // semanticWidth: 1950, // Original width (for sketch math)
137
- // semanticHeight: 2400, // Original height
138
- // bufferWidth: 897, // Actual canvas width
139
- // bufferHeight: 900, // Actual canvas height
140
- // frames: 150, // Frames rendered
141
- // stride: 1, // Current stride (1 = every frame)
142
- // totalTimeMs: 18750, // Total time
167
+ // scale: 0.46,
168
+ // semanticWidth: 1950,
169
+ // semanticHeight: 2400,
170
+ // bufferWidth: 897,
171
+ // bufferHeight: 900,
172
+ // frames: 150,
173
+ // stride: 1,
174
+ // totalTimeMs: 18750,
143
175
  // budgetExceeded?: { reason: 'frame_limit' | 'time_limit' }
144
176
  // }
145
177
  ```
146
178
 
147
- ### Canonical Handoff
179
+ ### What Can Differ vs Canonical
148
180
 
149
- ```typescript
150
- import { toCanonicalRequest } from '@nexart/ui-renderer';
181
+ | Aspect | ui-renderer | codemode-sdk |
182
+ |--------|-------------|--------------|
183
+ | Resolution | Scaled to max 900px | Full resolution |
184
+ | Frame budget | 1800 frames / 5 min | Unlimited |
185
+ | Fine details | May be lost at scale | Pixel-perfect |
186
+ | Semantics | Consistent | Authoritative |
151
187
 
152
- const config = { canvas, source, mode: 'loop', width: 1950, height: 2400, seed: 12345 };
153
- const req = toCanonicalRequest(config);
154
-
155
- // Pass to backend for canonical rendering:
156
- // await fetch('/api/render', { body: JSON.stringify(req) });
157
- ```
188
+ **Scaling may change fine details. Budgets may skip work. Core semantics are preserved.**
158
189
 
159
190
  ---
160
191
 
161
- ## Troubleshooting
162
-
163
- ### "My sketch stops animating"
164
-
165
- Check `getPreviewStats().budgetExceeded`:
192
+ ## Bounded Execution vs Canonical
166
193
 
167
- ```typescript
168
- const stats = runtime.getPreviewStats();
169
- if (stats.budgetExceeded) {
170
- console.log('Stopped because:', stats.budgetExceeded.reason);
171
- }
172
- ```
194
+ | Aspect | Preview (this SDK) | Canonical (@nexart/codemode-sdk) |
195
+ |--------|-------------------|----------------------------------|
196
+ | **Purpose** | Fast browser visuals | Authoritative rendering |
197
+ | **Resolution** | Max 900px | Full resolution |
198
+ | **Budget** | 1800 frames / 5 min | Unlimited |
199
+ | **Determinism** | Consistent | Guaranteed |
200
+ | **Use for** | Editors, dashboards, display | Minting, export, archival |
173
201
 
174
- **Solutions:**
175
- 1. Reduce sketch complexity (fewer loop iterations, simpler shapes)
176
- 2. Increase budget: `maxFrames: 3600` or `maxTimeMs: 600000`
177
- 3. Use `budgetBehavior: 'degrade'` to continue at reduced frame rate
178
- 4. For long-running animations, use `@nexart/codemode-sdk`
202
+ ---
179
203
 
180
- ### "Canvas is too small"
204
+ ## Optional: Canonical Handoff
181
205
 
182
- Preview scales canvases to max 900px for performance:
206
+ When you need to escalate to canonical rendering:
183
207
 
184
208
  ```typescript
185
- const stats = runtime.getPreviewStats();
186
- console.log('Buffer size:', stats.bufferWidth, 'x', stats.bufferHeight);
187
- console.log('Semantic size:', stats.semanticWidth, 'x', stats.semanticHeight);
188
- ```
189
-
190
- Your sketch code sees `width` and `height` as the original values (1950×2400).
191
- The canvas buffer is scaled down, but your geometry math stays correct.
209
+ import { toCanonicalRequest } from '@nexart/ui-renderer';
192
210
 
193
- ### "Animation looks choppy"
211
+ const config = {
212
+ canvas,
213
+ source: sketchCode,
214
+ mode: 'loop',
215
+ width: 1950,
216
+ height: 2400,
217
+ seed: 12345
218
+ };
194
219
 
195
- Preview runs at native RAF cadence (~60 FPS). If animations appear choppy:
220
+ const req = toCanonicalRequest(config);
196
221
 
197
- 1. Check if budget exceeded (degrade mode skips frames):
198
- ```typescript
199
- const stats = runtime.getPreviewStats();
200
- if (stats.budgetExceeded && stats.stride > 1) {
201
- console.log('Running in degraded mode, skipping frames');
202
- }
222
+ // Pass to backend with @nexart/codemode-sdk:
223
+ // await fetch('/api/render', { body: JSON.stringify(req) });
203
224
  ```
204
225
 
205
- 2. Reduce sketch complexity (heavy draw() calls)
206
- 3. Check browser performance (GPU acceleration, tab throttling)
207
-
208
226
  ---
209
227
 
210
228
  ## Install
@@ -213,7 +231,7 @@ if (stats.budgetExceeded && stats.stride > 1) {
213
231
  npm install @nexart/ui-renderer
214
232
  ```
215
233
 
216
- Or use directly in HTML:
234
+ Or use directly:
217
235
  ```html
218
236
  <script type="module">
219
237
  import { createPreviewRuntime } from 'https://unpkg.com/@nexart/ui-renderer/dist/index.js';
@@ -224,9 +242,9 @@ Or use directly in HTML:
224
242
 
225
243
  ## API Reference
226
244
 
227
- ### `createPreviewRuntime(config)` Recommended
245
+ ### `createPreviewRuntime(config)` Recommended
228
246
 
229
- Create a preview renderer. This is the recommended entrypoint.
247
+ Create a bounded preview renderer.
230
248
 
231
249
  ```typescript
232
250
  const runtime = createPreviewRuntime({
@@ -235,11 +253,11 @@ const runtime = createPreviewRuntime({
235
253
  mode: 'static' | 'loop',
236
254
  width: number,
237
255
  height: number,
238
- seed?: number, // PRNG seed
256
+ seed?: number,
239
257
  vars?: number[], // VAR[0..9] (0-100 range)
240
258
  totalFrames?: number, // For loop mode (default: 120)
241
259
 
242
- // v0.9.0 budget options
260
+ // Budget options
243
261
  onBudgetExceeded?: (info: BudgetExceededInfo) => void,
244
262
  budgetBehavior?: 'stop' | 'degrade',
245
263
  showOverlay?: boolean,
@@ -255,34 +273,11 @@ runtime.previewScale; // Canvas scale factor
255
273
  runtime.destroy(); // Clean up
256
274
  ```
257
275
 
258
- ### `createSystem(input)` + `previewSystem(system, canvas)`
259
-
260
- Legacy API for declarative systems. Still supported:
261
-
262
- ```typescript
263
- import { createSystem, previewSystem } from '@nexart/ui-renderer';
264
-
265
- const system = createSystem({
266
- type: 'code',
267
- mode: 'loop',
268
- width: 1950,
269
- height: 2400,
270
- source: sketchCode,
271
- seed: 12345,
272
- vars: [50, 75, 25],
273
- });
274
-
275
- const renderer = previewSystem(system, canvas);
276
- renderer.start();
277
- ```
278
-
279
276
  ### `toCanonicalRequest(config)`
280
277
 
281
- Generate a request object for handoff to `@nexart/codemode-sdk`:
278
+ Generate a handoff object for `@nexart/codemode-sdk`:
282
279
 
283
280
  ```typescript
284
- import { toCanonicalRequest } from '@nexart/ui-renderer';
285
-
286
281
  const req = toCanonicalRequest(config);
287
282
  // { seed, vars, code, settings, renderer: 'preview', uiRendererVersion }
288
283
  ```
@@ -292,17 +287,53 @@ const req = toCanonicalRequest(config);
292
287
  Discover SDK capabilities:
293
288
 
294
289
  ```typescript
295
- import { getCapabilities } from '@nexart/ui-renderer';
296
-
297
290
  const caps = getCapabilities();
298
291
  // { version, isCanonical, previewBudget, canvasLimits, ... }
299
292
  ```
300
293
 
301
294
  ---
302
295
 
296
+ ## Troubleshooting
297
+
298
+ ### "My sketch stops animating"
299
+
300
+ Check `getPreviewStats().budgetExceeded`:
301
+
302
+ ```typescript
303
+ const stats = runtime.getPreviewStats();
304
+ if (stats.budgetExceeded) {
305
+ console.log('Stopped because:', stats.budgetExceeded.reason);
306
+ }
307
+ ```
308
+
309
+ **Solutions:**
310
+ 1. Reduce sketch complexity
311
+ 2. Increase budget: `maxFrames: 3600` or `maxTimeMs: 600000`
312
+ 3. Use `budgetBehavior: 'degrade'` to continue with frame skipping
313
+
314
+ ### "Canvas is too small"
315
+
316
+ Preview scales to max 900px for performance:
317
+
318
+ ```typescript
319
+ const stats = runtime.getPreviewStats();
320
+ console.log('Buffer:', stats.bufferWidth, 'x', stats.bufferHeight);
321
+ console.log('Semantic:', stats.semanticWidth, 'x', stats.semanticHeight);
322
+ ```
323
+
324
+ Your sketch code sees original `width`/`height`. Canvas buffer is scaled.
325
+
326
+ ### "Animation looks choppy"
327
+
328
+ 1. Check if in degraded mode (skipping frames)
329
+ 2. Reduce sketch complexity
330
+ 3. Check browser performance
331
+
332
+ ---
333
+
303
334
  ## Available Helpers
304
335
 
305
- The preview runtime includes all standard p5-like functions:
336
+ All standard p5-like functions included:
306
337
 
307
338
  | Helper | Description |
308
339
  |--------|-------------|
@@ -316,15 +347,25 @@ The preview runtime includes all standard p5-like functions:
316
347
 
317
348
  ---
318
349
 
319
- ## What This SDK Does NOT Do
350
+ ## Legacy API
320
351
 
321
- | Not Done | Explanation |
322
- |----------|-------------|
323
- | Protocol enforcement | No pattern checking or validation errors |
324
- | Canonical output | Use @nexart/codemode-sdk for minting |
325
- | Determinism guarantee | Preview may vary slightly |
326
- | Full frame count | Limited by budget (default 1800 frames) |
327
- | Full resolution | Limited to 900px max dimension |
352
+ Still supported for backward compatibility:
353
+
354
+ ```typescript
355
+ import { createSystem, previewSystem } from '@nexart/ui-renderer';
356
+
357
+ const system = createSystem({
358
+ type: 'code',
359
+ mode: 'loop',
360
+ width: 1950,
361
+ height: 2400,
362
+ source: sketchCode,
363
+ seed: 12345,
364
+ });
365
+
366
+ const renderer = previewSystem(system, canvas);
367
+ renderer.start();
368
+ ```
328
369
 
329
370
  ---
330
371
 
@@ -339,6 +380,4 @@ The preview runtime includes all standard p5-like functions:
339
380
 
340
381
  ## License
341
382
 
342
- MIT License
343
-
344
- Copyright (c) 2024-2026 NexArt
383
+ MIT License — Copyright (c) 2024-2026 NexArt
package/dist/index.d.ts CHANGED
@@ -65,7 +65,7 @@ export type { Capabilities, PrimitiveCapability, ParameterSpec, } from './capabi
65
65
  * ```
66
66
  */
67
67
  export { createPreviewEngine as createPreviewRuntime } from './preview/preview-engine';
68
- export declare const SDK_VERSION = "0.9.0";
68
+ export declare const SDK_VERSION = "0.9.1";
69
69
  export declare const PROTOCOL_VERSION = "0.9";
70
70
  export declare const IS_CANONICAL = false;
71
71
  export declare const IS_ARCHIVAL = false;
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ export { AESTHETIC_DEFAULTS, SDK_VERSION as TYPE_SDK_VERSION } from './types';
65
65
  * ```
66
66
  */
67
67
  export { createPreviewEngine as createPreviewRuntime } from './preview/preview-engine';
68
- export const SDK_VERSION = '0.9.0';
68
+ export const SDK_VERSION = '0.9.1';
69
69
  export const PROTOCOL_VERSION = '0.9';
70
70
  export const IS_CANONICAL = false;
71
71
  export const IS_ARCHIVAL = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexart/ui-renderer",
3
- "version": "0.9.0",
4
- "description": "Lightweight Preview Runtime for NexArt Protocol. Non-canonical, browser-first, with budget callbacks and observability for AI coding agents.",
3
+ "version": "0.9.1",
4
+ "description": "Browser-first bounded generative renderer for safe, fast, interactive visuals. Resolution scaling, frame budgets, observable state.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./dist/index.js",
@@ -33,21 +33,24 @@
33
33
  "typescript": "^5.0.0"
34
34
  },
35
35
  "keywords": [
36
- "nexart",
37
- "generative-art",
36
+ "generative",
37
+ "renderer",
38
38
  "canvas",
39
- "browser",
40
- "declarative",
41
- "protocol",
42
- "authoring",
39
+ "creative-coding",
43
40
  "preview",
44
- "ai-agent",
45
- "deterministic"
41
+ "sandbox",
42
+ "bounded",
43
+ "runtime",
44
+ "miniapp",
45
+ "browser",
46
+ "deterministic",
47
+ "ai-agent"
46
48
  ],
47
49
  "repository": {
48
50
  "type": "git",
49
51
  "url": "https://github.com/artnames/nexart-ui-renderer.git"
50
52
  },
53
+ "homepage": "https://github.com/artnames/nexart-ui-renderer#readme",
51
54
  "author": "NexArt",
52
55
  "publishConfig": {
53
56
  "access": "public"