@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
package/README.md
CHANGED
|
@@ -1,36 +1,177 @@
|
|
|
1
1
|
# @nexart/ui-renderer
|
|
2
2
|
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
|
|
5
5
|
**Declarative and Code Mode System Authoring SDK for NexArt Protocol**
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
-
>
|
|
9
|
+
> **This SDK is a PREVIEW MIRROR, not an authority.**
|
|
10
10
|
>
|
|
11
|
-
>
|
|
12
|
-
> **Canonical, archival output is produced exclusively by @nexart/codemode-sdk.**
|
|
11
|
+
> It mirrors the behavior of @nexart/codemode-sdk faithfully for preview purposes.
|
|
13
12
|
>
|
|
14
|
-
>
|
|
13
|
+
> It is:
|
|
15
14
|
> - **NOT canonical** — Does not produce archival-quality output
|
|
16
|
-
> - **NOT archival** — Not
|
|
17
|
-
> - **NOT protocol-authoritative** —
|
|
15
|
+
> - **NOT archival** — Not the source of truth for production rendering
|
|
16
|
+
> - **NOT protocol-authoritative** — Delegates all Code Mode execution semantics
|
|
18
17
|
>
|
|
19
|
-
> Same
|
|
18
|
+
> Same inputs → same restrictions → same errors → same semantics as @nexart/codemode-sdk.
|
|
20
19
|
|
|
21
20
|
---
|
|
22
21
|
|
|
23
|
-
##
|
|
22
|
+
## PROTOCOL LOCK — v1.0.0 (MIRROR)
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
| Property | Value |
|
|
25
|
+
|----------|-------|
|
|
26
|
+
| Protocol Name | NexArt Code Mode |
|
|
27
|
+
| Version | v1.0.0 |
|
|
28
|
+
| Status | **HARD LOCKED** |
|
|
29
|
+
| This SDK | Mirror only — NOT authoritative |
|
|
30
|
+
| Canonical Authority | @nexart/codemode-sdk |
|
|
31
|
+
| Lock Date | December 2024 |
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
2. **Preview Rendering** — Visual approximation in the browser
|
|
29
|
-
3. **Compilation** — Export protocol-compatible JSON for canonical execution
|
|
33
|
+
**This SDK mirrors the frozen v1.0.0 protocol surface. Any future protocol change requires v2.0.0 in @nexart/codemode-sdk first.**
|
|
30
34
|
|
|
31
|
-
This SDK
|
|
35
|
+
This SDK mirrors:
|
|
36
|
+
- Execution model (Static and Loop modes)
|
|
37
|
+
- VAR[0..9] specification (exactly 10 read-only variables)
|
|
38
|
+
- Determinism behavior (seed + VAR → consistent preview)
|
|
39
|
+
- Time semantics (t, frameCount, time, tGlobal)
|
|
40
|
+
- Forbidden patterns list (13 patterns)
|
|
41
|
+
- Error message format (`[Code Mode Protocol Error]`)
|
|
32
42
|
|
|
33
|
-
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Protocol Alignment (v1.0.0)
|
|
46
|
+
|
|
47
|
+
This SDK mirrors NexArt Protocol behavior. It is NOT canonical.
|
|
48
|
+
|
|
49
|
+
**Canonical execution is performed exclusively by @nexart/codemode-sdk.**
|
|
50
|
+
|
|
51
|
+
This SDK exists for:
|
|
52
|
+
- Preview and prototyping
|
|
53
|
+
- Tooling and AI builders
|
|
54
|
+
- Development and experimentation
|
|
55
|
+
|
|
56
|
+
### Authority Boundaries
|
|
57
|
+
|
|
58
|
+
| Aspect | This SDK | @nexart/codemode-sdk |
|
|
59
|
+
|--------|----------|---------------------|
|
|
60
|
+
| Authority | None — mirror only | Canonical gate |
|
|
61
|
+
| Determinism | Mirrors protocol RNG | Authoritative RNG |
|
|
62
|
+
| VAR Handling | Protocol-aligned (read-only, 0-100) | Authoritative enforcement |
|
|
63
|
+
| Error Behavior | Mirrors protocol errors | Defines protocol errors |
|
|
64
|
+
| Output | Preview-quality | Archival-quality |
|
|
65
|
+
|
|
66
|
+
### HARD Enforcement Modes
|
|
67
|
+
|
|
68
|
+
This SDK mirrors the following protocol-enforced modes:
|
|
69
|
+
- **Code Mode** — Seeded RNG, VAR[0..9], forbidden patterns
|
|
70
|
+
- **SoundArt** — Audio-to-visual transformation via Code Mode
|
|
71
|
+
- **Noise** — Perlin/Cellular noise via Code Mode
|
|
72
|
+
- **Shapes** — Geometric generation via Code Mode
|
|
73
|
+
|
|
74
|
+
### Forbidden Patterns
|
|
75
|
+
|
|
76
|
+
The following patterns are rejected (mirroring @nexart/codemode-sdk exactly):
|
|
77
|
+
|
|
78
|
+
- `setTimeout`, `setInterval`, `requestAnimationFrame` — async timing
|
|
79
|
+
- `Date.now()`, `new Date()` — time-based entropy
|
|
80
|
+
- `Math.random()` — use `random()` instead (seeded)
|
|
81
|
+
- `fetch()`, `XMLHttpRequest` — external IO
|
|
82
|
+
- `createCanvas()` — canvas is pre-initialized
|
|
83
|
+
- `document.*`, `window.*` — DOM access forbidden
|
|
84
|
+
- `import`, `require()` — external imports forbidden
|
|
85
|
+
|
|
86
|
+
### VAR Protocol — LOCKED v1.0.0 (MIRROR)
|
|
87
|
+
|
|
88
|
+
VAR[0..9] is a read-only array of 10 protocol variables (0-100 recommended).
|
|
89
|
+
|
|
90
|
+
**VAR Specification (FROZEN — mirrors @nexart/codemode-sdk):**
|
|
91
|
+
|
|
92
|
+
| Property | Value | Enforcement |
|
|
93
|
+
|----------|-------|-------------|
|
|
94
|
+
| Count | Exactly 10 (VAR[0]..VAR[9]) | HARD — throws if not 10 |
|
|
95
|
+
| Type | number | HARD — throws if non-number |
|
|
96
|
+
| Range | 0-100 recommended | SOFT — warns, does NOT clamp |
|
|
97
|
+
| Mutability | Read-only | HARD — frozen, writes blocked |
|
|
98
|
+
| Injection | Before execution | Guaranteed |
|
|
99
|
+
| Lifecycle | Stable for entire render | Guaranteed |
|
|
100
|
+
| Default | All zeros | If not provided |
|
|
101
|
+
|
|
102
|
+
**This specification is INTENTIONAL and MUST NOT be extended in v1.x.**
|
|
103
|
+
|
|
104
|
+
**DO NOT** add support for dynamic-length VAR arrays.
|
|
105
|
+
**DO NOT** allow user-defined VAR counts.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// Correct usage
|
|
109
|
+
const size = map(VAR[0], 0, 100, 10, 200);
|
|
110
|
+
const count = floor(map(VAR[1], 0, 100, 5, 50));
|
|
111
|
+
|
|
112
|
+
// Error: VAR is read-only
|
|
113
|
+
VAR[0] = 50; // Blocked with warning
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Error examples:**
|
|
117
|
+
```typescript
|
|
118
|
+
// Protocol error: wrong length
|
|
119
|
+
vars: [50, 50, 50] // "[Code Mode Protocol Error] VAR array must have exactly 10 elements"
|
|
120
|
+
|
|
121
|
+
// Warning only: out of range (not clamped)
|
|
122
|
+
vars: [150, 50, 50, 50, 50, 50, 50, 50, 50, 50] // Warns but allows
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Supported Element Types
|
|
128
|
+
|
|
129
|
+
The SDK supports three element types, rendered in order:
|
|
130
|
+
|
|
131
|
+
### `background`
|
|
132
|
+
|
|
133
|
+
Opinionated presets with guardrails. Provides consistent, protocol-aligned backgrounds.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
{
|
|
137
|
+
type: 'background',
|
|
138
|
+
style: 'gradient', // gradient, solid, noise, grain
|
|
139
|
+
palette: 'warm' // warm, cool, neutral, vibrant
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `primitive`
|
|
144
|
+
|
|
145
|
+
Declarative generative components. Structured parameters, no raw code.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
{
|
|
149
|
+
type: 'primitive',
|
|
150
|
+
name: 'dots', // dots, lines, waves, grid, flowField, orbits
|
|
151
|
+
count: 100,
|
|
152
|
+
color: '#ffffff',
|
|
153
|
+
motion: { speed: 0.5 }
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### `sketch`
|
|
158
|
+
|
|
159
|
+
Raw Code Mode execution in a sandboxed environment. Full p5-like API access.
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
{
|
|
163
|
+
type: 'sketch',
|
|
164
|
+
code: `
|
|
165
|
+
function setup() {
|
|
166
|
+
background(0);
|
|
167
|
+
}
|
|
168
|
+
function draw() {
|
|
169
|
+
ellipse(width/2, height/2, 100);
|
|
170
|
+
}
|
|
171
|
+
`,
|
|
172
|
+
normalize: true
|
|
173
|
+
}
|
|
174
|
+
```
|
|
34
175
|
|
|
35
176
|
---
|
|
36
177
|
|
|
@@ -51,9 +192,9 @@ Or use directly in HTML:
|
|
|
51
192
|
|
|
52
193
|
## Quick Start
|
|
53
194
|
|
|
54
|
-
### Code Mode Systems
|
|
195
|
+
### Code Mode Systems with VAR
|
|
55
196
|
|
|
56
|
-
Create and preview Code Mode sketches
|
|
197
|
+
Create and preview Code Mode sketches using protocol variables:
|
|
57
198
|
|
|
58
199
|
```typescript
|
|
59
200
|
import { createSystem, previewSystem } from '@nexart/ui-renderer';
|
|
@@ -65,6 +206,7 @@ const system = createSystem({
|
|
|
65
206
|
height: 2400,
|
|
66
207
|
totalFrames: 120,
|
|
67
208
|
seed: 12345,
|
|
209
|
+
vars: [50, 75, 25, 0, 100, 50, 50, 50, 50, 50], // VAR[0..9]
|
|
68
210
|
source: `
|
|
69
211
|
function setup() {
|
|
70
212
|
noFill();
|
|
@@ -72,8 +214,9 @@ const system = createSystem({
|
|
|
72
214
|
}
|
|
73
215
|
function draw() {
|
|
74
216
|
background(246, 245, 242);
|
|
75
|
-
|
|
76
|
-
|
|
217
|
+
var count = floor(map(VAR[0], 0, 100, 5, 30));
|
|
218
|
+
for (var i = 0; i < count; i++) {
|
|
219
|
+
var x = width / 2 + cos(t * TWO_PI + i * 0.5) * map(VAR[1], 0, 100, 50, 400);
|
|
77
220
|
var y = height / 2 + sin(t * TWO_PI + i * 0.3) * 200;
|
|
78
221
|
ellipse(x, y, 50);
|
|
79
222
|
}
|
|
@@ -95,11 +238,13 @@ const staticSystem = createSystem({
|
|
|
95
238
|
width: 1950,
|
|
96
239
|
height: 2400,
|
|
97
240
|
seed: 12345,
|
|
241
|
+
vars: [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],
|
|
98
242
|
source: `
|
|
99
243
|
function setup() {
|
|
100
244
|
background(246, 245, 242);
|
|
101
245
|
fill(0);
|
|
102
|
-
|
|
246
|
+
var count = floor(map(VAR[0], 0, 100, 10, 200));
|
|
247
|
+
for (var i = 0; i < count; i++) {
|
|
103
248
|
ellipse(random(width), random(height), random(10, 50));
|
|
104
249
|
}
|
|
105
250
|
}
|
|
@@ -109,60 +254,6 @@ const staticSystem = createSystem({
|
|
|
109
254
|
previewSystem(staticSystem, canvas).render();
|
|
110
255
|
```
|
|
111
256
|
|
|
112
|
-
### Declarative Systems
|
|
113
|
-
|
|
114
|
-
### 1. Create a System
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
import { createSystem } from '@nexart/ui-renderer';
|
|
118
|
-
|
|
119
|
-
const system = createSystem({
|
|
120
|
-
seed: 29445825,
|
|
121
|
-
background: {
|
|
122
|
-
color: 'blue',
|
|
123
|
-
texture: 'noise'
|
|
124
|
-
},
|
|
125
|
-
elements: [
|
|
126
|
-
{
|
|
127
|
-
type: 'waves',
|
|
128
|
-
axis: 'x',
|
|
129
|
-
amplitude: 0.4,
|
|
130
|
-
frequency: 0.7
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
type: 'dots',
|
|
134
|
-
distribution: 'radial',
|
|
135
|
-
count: 400,
|
|
136
|
-
size: [1, 4]
|
|
137
|
-
}
|
|
138
|
-
],
|
|
139
|
-
motion: {
|
|
140
|
-
source: 'time',
|
|
141
|
-
speed: 0.2
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### 2. Preview the System
|
|
147
|
-
|
|
148
|
-
```typescript
|
|
149
|
-
import { previewSystem } from '@nexart/ui-renderer';
|
|
150
|
-
|
|
151
|
-
const canvas = document.getElementById('canvas');
|
|
152
|
-
const renderer = previewSystem(system, canvas, { mode: 'loop' });
|
|
153
|
-
|
|
154
|
-
renderer.start();
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### 3. Compile for Protocol
|
|
158
|
-
|
|
159
|
-
```typescript
|
|
160
|
-
import { compileSystem } from '@nexart/ui-renderer';
|
|
161
|
-
|
|
162
|
-
const compiled = compileSystem(system);
|
|
163
|
-
console.log(JSON.stringify(compiled, null, 2));
|
|
164
|
-
```
|
|
165
|
-
|
|
166
257
|
---
|
|
167
258
|
|
|
168
259
|
## API Reference
|
|
@@ -180,29 +271,8 @@ const system = createSystem({
|
|
|
180
271
|
height: number,
|
|
181
272
|
source: string, // Raw p5-like sketch code
|
|
182
273
|
seed?: number, // Optional: PRNG seed
|
|
183
|
-
totalFrames?: number
|
|
184
|
-
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**Declarative Input:**
|
|
188
|
-
```typescript
|
|
189
|
-
const system = createSystem({
|
|
190
|
-
version?: string, // Protocol version (default: '0.3')
|
|
191
|
-
seed: number, // Required: PRNG seed
|
|
192
|
-
background: {
|
|
193
|
-
color: string, // Required: background color
|
|
194
|
-
texture?: 'none' | 'noise' | 'grain',
|
|
195
|
-
gradient?: {
|
|
196
|
-
type: 'linear' | 'radial',
|
|
197
|
-
colors: string[],
|
|
198
|
-
angle?: number
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
elements: SystemElement[], // Required: array of primitives
|
|
202
|
-
motion?: {
|
|
203
|
-
source: 'none' | 'time' | 'seed',
|
|
204
|
-
speed?: number
|
|
205
|
-
}
|
|
274
|
+
totalFrames?: number, // Required for loop mode
|
|
275
|
+
vars?: number[] // Optional: VAR[0..9] (10 values, 0-100)
|
|
206
276
|
});
|
|
207
277
|
```
|
|
208
278
|
|
|
@@ -222,25 +292,6 @@ renderer.stop(); // Stop loop
|
|
|
222
292
|
renderer.destroy(); // Cleanup
|
|
223
293
|
```
|
|
224
294
|
|
|
225
|
-
### `compileSystem(system)`
|
|
226
|
-
|
|
227
|
-
Compile to protocol-compatible JSON.
|
|
228
|
-
|
|
229
|
-
```typescript
|
|
230
|
-
const compiled = compileSystem(system);
|
|
231
|
-
// {
|
|
232
|
-
// protocol: 'nexart',
|
|
233
|
-
// systemVersion: '0.2',
|
|
234
|
-
// seed: 29445825,
|
|
235
|
-
// background: {...},
|
|
236
|
-
// elements: [...],
|
|
237
|
-
// motion: {...},
|
|
238
|
-
// deterministic: true,
|
|
239
|
-
// compiledAt: '2024-12-26T...',
|
|
240
|
-
// compilerVersion: '0.2.0'
|
|
241
|
-
// }
|
|
242
|
-
```
|
|
243
|
-
|
|
244
295
|
### `validateSystem(input)`
|
|
245
296
|
|
|
246
297
|
Validate system input without creating.
|
|
@@ -254,98 +305,59 @@ if (!result.valid) {
|
|
|
254
305
|
|
|
255
306
|
### `getCapabilities()`
|
|
256
307
|
|
|
257
|
-
Discover SDK capabilities
|
|
308
|
+
Discover SDK capabilities.
|
|
258
309
|
|
|
259
310
|
```typescript
|
|
260
311
|
import { getCapabilities } from '@nexart/ui-renderer';
|
|
261
312
|
|
|
262
313
|
const caps = getCapabilities();
|
|
263
314
|
// {
|
|
264
|
-
// version: '0.
|
|
315
|
+
// version: '0.4.0',
|
|
265
316
|
// isCanonical: false,
|
|
266
317
|
// isArchival: false,
|
|
267
318
|
// renderer: '@nexart/ui-renderer',
|
|
268
|
-
//
|
|
269
|
-
//
|
|
270
|
-
//
|
|
271
|
-
// limits: {...} // Max values for safety
|
|
319
|
+
// delegatesTo: '@nexart/codemode-sdk',
|
|
320
|
+
// protocolVersion: '1.0.0',
|
|
321
|
+
// ...
|
|
272
322
|
// }
|
|
273
323
|
```
|
|
274
324
|
|
|
275
|
-
Use this to:
|
|
276
|
-
- Prevent AI hallucination of non-existent primitives
|
|
277
|
-
- Validate parameter ranges before system creation
|
|
278
|
-
- Build dynamic UIs that adapt to SDK capabilities
|
|
279
|
-
|
|
280
325
|
---
|
|
281
326
|
|
|
282
|
-
##
|
|
283
|
-
|
|
284
|
-
### Elements
|
|
285
|
-
|
|
286
|
-
| Type | Properties |
|
|
287
|
-
|------|------------|
|
|
288
|
-
| `dots` | distribution, count, size, color, opacity |
|
|
289
|
-
| `lines` | direction, count, thickness, color, opacity |
|
|
290
|
-
| `waves` | axis, amplitude, frequency, count, color, opacity |
|
|
291
|
-
| `grid` | rows, cols, cellSize, shape, color, opacity |
|
|
292
|
-
| `flowField` | resolution, strength, particles, color, opacity |
|
|
293
|
-
| `orbits` | count, radius, dotCount, speed, color, opacity |
|
|
294
|
-
|
|
295
|
-
### Background
|
|
296
|
-
|
|
297
|
-
| Property | Options |
|
|
298
|
-
|----------|---------|
|
|
299
|
-
| color | Any CSS color or name |
|
|
300
|
-
| texture | `none`, `noise`, `grain` |
|
|
301
|
-
| gradient | `{ type, colors, angle? }` |
|
|
327
|
+
## Delegation Logging
|
|
302
328
|
|
|
303
|
-
|
|
329
|
+
All Code Mode previews log their delegation:
|
|
304
330
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
331
|
+
```
|
|
332
|
+
[UIRenderer] Preview delegation → @nexart/codemode-sdk
|
|
333
|
+
[UIRenderer] Protocol version: 1.0.0
|
|
334
|
+
[UIRenderer] Mode: loop
|
|
335
|
+
```
|
|
310
336
|
|
|
311
337
|
---
|
|
312
338
|
|
|
313
|
-
##
|
|
314
|
-
|
|
315
|
-
This SDK is designed for AI code generation. Use `getCapabilities()` first:
|
|
316
|
-
|
|
317
|
-
```typescript
|
|
318
|
-
import { getCapabilities, createSystem, previewSystem } from '@nexart/ui-renderer';
|
|
319
|
-
|
|
320
|
-
// 1. Check what's available (prevents hallucination)
|
|
321
|
-
const caps = getCapabilities();
|
|
322
|
-
console.log(caps.primitives.map(p => p.type));
|
|
323
|
-
// ['dots', 'lines', 'waves', 'grid', 'flowField', 'orbits']
|
|
324
|
-
|
|
325
|
-
// 2. Create system using only valid primitives
|
|
326
|
-
const system = createSystem({
|
|
327
|
-
seed: Date.now(),
|
|
328
|
-
background: { color: 'blue' },
|
|
329
|
-
elements: [
|
|
330
|
-
{ type: 'waves', axis: 'x', amplitude: 0.5, frequency: 1 }
|
|
331
|
-
]
|
|
332
|
-
});
|
|
339
|
+
## Error Mirroring
|
|
333
340
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
341
|
+
If the protocol rejects code:
|
|
342
|
+
- Rendering stops immediately
|
|
343
|
+
- Black canvas is displayed
|
|
344
|
+
- Error is logged verbatim
|
|
345
|
+
- No "best effort" recovery
|
|
337
346
|
|
|
338
|
-
**AI Prompt Example:**
|
|
339
347
|
```
|
|
340
|
-
|
|
348
|
+
[UIRenderer Protocol Error] Forbidden pattern: Math.random() — use random() instead (seeded)
|
|
341
349
|
```
|
|
342
350
|
|
|
343
|
-
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## What This SDK Does NOT Guarantee
|
|
344
354
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
355
|
+
| Not Guaranteed | Explanation |
|
|
356
|
+
|----------------|-------------|
|
|
357
|
+
| Canonical output | Production runtime is the only authority |
|
|
358
|
+
| Archival quality | Output is for preview, not permanent storage |
|
|
359
|
+
| Cross-version stability | Internal rendering may change between SDK versions |
|
|
360
|
+
| Frame-perfect matching | Minor differences from production are expected |
|
|
349
361
|
|
|
350
362
|
---
|
|
351
363
|
|
|
@@ -356,21 +368,6 @@ The finite vocabulary prevents invalid systems and ensures protocol alignment.
|
|
|
356
368
|
- Safari 13+
|
|
357
369
|
- Edge 80+
|
|
358
370
|
|
|
359
|
-
No polyfills required.
|
|
360
|
-
|
|
361
|
-
---
|
|
362
|
-
|
|
363
|
-
## Comparison with @nexart/codemode-sdk
|
|
364
|
-
|
|
365
|
-
| Feature | @nexart/ui-renderer | @nexart/codemode-sdk |
|
|
366
|
-
|---------|---------------------|----------------------|
|
|
367
|
-
| Environment | Browser only | Node.js / Server |
|
|
368
|
-
| Purpose | Authoring / Preview | Production / Minting |
|
|
369
|
-
| Canonical | ❌ No | ✅ Yes |
|
|
370
|
-
| Archival | ❌ No | ✅ Yes |
|
|
371
|
-
| Output | Canvas / JSON | PNG / MP4 buffers |
|
|
372
|
-
| API | Declarative systems | Code execution |
|
|
373
|
-
|
|
374
371
|
---
|
|
375
372
|
|
|
376
373
|
## License
|
|
@@ -378,8 +375,3 @@ No polyfills required.
|
|
|
378
375
|
MIT License
|
|
379
376
|
|
|
380
377
|
Copyright (c) 2024 NexArt
|
|
381
|
-
|
|
382
|
-
---
|
|
383
|
-
|
|
384
|
-
> **Reminder:** This SDK authors systems. It does NOT invent new rendering rules.
|
|
385
|
-
> Canonical execution always happens via `@nexart/codemode-sdk`.
|
|
@@ -1,17 +1,30 @@
|
|
|
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
|
*/
|
|
7
27
|
import type { NexArtCodeSystem, PreviewOptions } from '../types';
|
|
8
|
-
interface P5Runtime {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
frameCount: number;
|
|
13
|
-
}
|
|
14
|
-
export declare function createP5Runtime(canvas: HTMLCanvasElement, width: number, height: number, seed: number): P5Runtime;
|
|
15
28
|
export interface CodeRenderer {
|
|
16
29
|
render: () => void;
|
|
17
30
|
start: () => void;
|
|
@@ -20,6 +33,14 @@ export interface CodeRenderer {
|
|
|
20
33
|
isCanonical: false;
|
|
21
34
|
isArchival: false;
|
|
22
35
|
}
|
|
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;
|
|
23
44
|
export declare function renderCodeModeSystem(system: NexArtCodeSystem, canvas: HTMLCanvasElement, options?: PreviewOptions): CodeRenderer;
|
|
24
45
|
export {};
|
|
25
46
|
//# 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
|
|
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;AA4CD,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;AAgFD,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"}
|