@nexart/ui-renderer 0.4.0 → 0.6.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @nexart/ui-renderer
2
2
 
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
 
5
5
  **Declarative and Code Mode System Authoring SDK for NexArt Protocol**
6
6
 
@@ -34,7 +34,7 @@ Version: 0.4.0
34
34
 
35
35
  This SDK mirrors:
36
36
  - Execution model (Static and Loop modes)
37
- - VAR[0..9] specification (exactly 10 read-only variables)
37
+ - VAR[0..9] specification (0-10 input, always 10 at runtime)
38
38
  - Determinism behavior (seed + VAR → consistent preview)
39
39
  - Time semantics (t, frameCount, time, tGlobal)
40
40
  - Forbidden patterns list (13 patterns)
@@ -83,43 +83,47 @@ The following patterns are rejected (mirroring @nexart/codemode-sdk exactly):
83
83
  - `document.*`, `window.*` — DOM access forbidden
84
84
  - `import`, `require()` — external imports forbidden
85
85
 
86
- ### VAR Protocol — LOCKED v1.0.0 (MIRROR)
86
+ ### VAR Protocol — v1.0.0 (MIRROR of SDK v1.1.0)
87
87
 
88
- VAR[0..9] is a read-only array of 10 protocol variables (0-100 recommended).
88
+ VAR[0..9] is a read-only array of 10 protocol variables (0-100 strict range).
89
89
 
90
- **VAR Specification (FROZEN — mirrors @nexart/codemode-sdk):**
90
+ **VAR Specification (mirrors @nexart/codemode-sdk v1.1.0):**
91
91
 
92
92
  | Property | Value | Enforcement |
93
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 | SOFTwarns, does NOT clamp |
97
- | Mutability | Read-only | HARD — frozen, writes blocked |
94
+ | Input count | 0-10 (VAR[0]..VAR[9]) | HARD — throws if > 10 |
95
+ | Runtime count | Always 10 | Padded with zeros |
96
+ | Type | finite number | HARDthrows if non-number |
97
+ | Range | 0-100 | HARD — throws if out of range |
98
+ | Mutability | Read-only | HARD — frozen, writes throw |
98
99
  | Injection | Before execution | Guaranteed |
99
100
  | Lifecycle | Stable for entire render | Guaranteed |
100
101
  | Default | All zeros | If not provided |
101
102
 
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.
103
+ **This specification mirrors @nexart/codemode-sdk v1.1.0 exactly.**
106
104
 
107
105
  ```typescript
108
106
  // Correct usage
109
107
  const size = map(VAR[0], 0, 100, 10, 200);
110
108
  const count = floor(map(VAR[1], 0, 100, 5, 50));
111
109
 
110
+ // VAR[5] returns 0 if input had fewer than 6 elements
111
+ const value = VAR[5]; // Returns 0 if not provided
112
+
112
113
  // Error: VAR is read-only
113
- VAR[0] = 50; // Blocked with warning
114
+ VAR[0] = 50; // Throws: "[Code Mode Protocol Error] VAR is read-only..."
114
115
  ```
115
116
 
116
117
  **Error examples:**
117
118
  ```typescript
118
- // Protocol error: wrong length
119
- vars: [50, 50, 50] // "[Code Mode Protocol Error] VAR array must have exactly 10 elements"
119
+ // Protocol error: too many elements
120
+ vars: [1,2,3,4,5,6,7,8,9,10,11] // Throws: "VAR array must have at most 10 elements, got 11"
120
121
 
121
- // Warning only: out of range (not clamped)
122
- vars: [150, 50, 50, 50, 50, 50, 50, 50, 50, 50] // Warns but allows
122
+ // Protocol error: out of range
123
+ vars: [150, 50, 50] // Throws: "VAR[0] = 150 is out of range. Values must be 0-100."
124
+
125
+ // Valid: fewer than 10 elements (padded with zeros)
126
+ vars: [50, 75, 25] // Works! VAR[3..9] will be 0
123
127
  ```
124
128
 
125
129
  ---
@@ -142,15 +146,59 @@ Opinionated presets with guardrails. Provides consistent, protocol-aligned backg
142
146
 
143
147
  ### `primitive`
144
148
 
145
- Declarative generative components. Structured parameters, no raw code.
149
+ Declarative generative components. Structured parameters, no raw code. **30 primitives available:**
150
+
151
+ **Basic Shapes:**
152
+ - `dots` — Grid/random dot patterns
153
+ - `lines` — Vertical wavy lines
154
+ - `waves` — Horizontal wave patterns
155
+ - `stripes` — Simple horizontal stripes
156
+ - `circles` — Concentric pulsing circles
157
+ - `grid` — Rotating square grid
158
+
159
+ **Geometric:**
160
+ - `polygons` — Random rotating polygons (3-7 sides)
161
+ - `diamonds` — Diamond grid with noise rotation
162
+ - `hexgrid` — Honeycomb hexagonal grid
163
+ - `stars` — Scattered rotating star shapes
164
+ - `concentricSquares` — Nested rotating squares
165
+
166
+ **Radial:**
167
+ - `spirals` — Multiple expanding spirals
168
+ - `rays` — Lines emanating from center
169
+ - `orbits` — Wobbling orbital rings
170
+ - `rings` — Alternating concentric rings
171
+ - `arcs` — Random partial circles
172
+ - `radialLines` — Lines from inner to outer radius
173
+ - `petals` — Flower petal pattern
174
+
175
+ **Flow & Motion:**
176
+ - `flow` — Particle flow field
177
+ - `particles` — Scattered particles with tails
178
+ - `bubbles` — Rising floating bubbles
179
+
180
+ **Patterns:**
181
+ - `crosshatch` — Cross-hatched shading lines
182
+ - `chevrons` — V-shaped wave patterns
183
+ - `zigzag` — Zigzag horizontal lines
184
+ - `weave` — Interlocking woven pattern
185
+ - `moire` — Overlapping circle interference
186
+
187
+ **Organic:**
188
+ - `curves` — Random bezier curves
189
+ - `noise` — Perlin noise vector field
190
+ - `mesh` — Deformed triangular mesh
191
+ - `branches` — Fractal tree branches
146
192
 
147
193
  ```typescript
148
194
  {
149
195
  type: 'primitive',
150
- name: 'dots', // dots, lines, waves, grid, flowField, orbits
151
- count: 100,
196
+ name: 'spirals', // Any of the 30 primitives above
197
+ count: 12,
152
198
  color: '#ffffff',
153
- motion: { speed: 0.5 }
199
+ motion: 'medium', // 'slow', 'medium', 'fast'
200
+ strokeWeight: 'thin', // 'thin', 'medium', 'thick', or number
201
+ opacity: 0.8
154
202
  }
155
203
  ```
156
204
 
@@ -272,7 +320,7 @@ const system = createSystem({
272
320
  source: string, // Raw p5-like sketch code
273
321
  seed?: number, // Optional: PRNG seed
274
322
  totalFrames?: number, // Required for loop mode
275
- vars?: number[] // Optional: VAR[0..9] (10 values, 0-100)
323
+ vars?: number[] // Optional: VAR[0..9] (0-10 values, 0-100 range)
276
324
  });
277
325
  ```
278
326
 
@@ -305,23 +353,134 @@ if (!result.valid) {
305
353
 
306
354
  ### `getCapabilities()`
307
355
 
308
- Discover SDK capabilities.
356
+ Discover SDK capabilities for AI and tooling.
309
357
 
310
358
  ```typescript
311
359
  import { getCapabilities } from '@nexart/ui-renderer';
312
360
 
313
361
  const caps = getCapabilities();
314
362
  // {
315
- // version: '0.4.0',
363
+ // version: '0.6.0',
316
364
  // isCanonical: false,
317
365
  // isArchival: false,
318
366
  // renderer: '@nexart/ui-renderer',
319
- // delegatesTo: '@nexart/codemode-sdk',
320
- // protocolVersion: '1.0.0',
367
+ // primitivesMeta: { notice: '...', count: 30, isCanonical: false },
368
+ // primitives: [ { name, category, description, parameters } ],
321
369
  // ...
322
370
  // }
323
371
  ```
324
372
 
373
+ ### `getPrimitiveTypes()`
374
+
375
+ Get all 30 primitive names as array.
376
+
377
+ ```typescript
378
+ import { getPrimitiveTypes } from '@nexart/ui-renderer';
379
+
380
+ const names = getPrimitiveTypes();
381
+ // ['dots', 'lines', 'waves', 'stripes', ... ]
382
+ ```
383
+
384
+ ### `getPrimitivesByCategory()`
385
+
386
+ Get primitives organized by category.
387
+
388
+ ```typescript
389
+ import { getPrimitivesByCategory } from '@nexart/ui-renderer';
390
+
391
+ const byCategory = getPrimitivesByCategory();
392
+ // {
393
+ // basic: ['dots', 'lines', 'waves', 'stripes', 'circles', 'grid'],
394
+ // geometric: ['polygons', 'diamonds', 'hexgrid', 'stars', 'concentricSquares'],
395
+ // radial: ['spirals', 'rays', 'orbits', 'rings', 'arcs', 'radialLines', 'petals'],
396
+ // flow: ['flow', 'particles', 'bubbles'],
397
+ // patterns: ['crosshatch', 'chevrons', 'zigzag', 'weave', 'moire'],
398
+ // organic: ['curves', 'noise', 'mesh', 'branches']
399
+ // }
400
+ ```
401
+
402
+ ### `getPrimitiveInfo(name)`
403
+
404
+ Get full capability info for a single primitive.
405
+
406
+ ```typescript
407
+ import { getPrimitiveInfo } from '@nexart/ui-renderer';
408
+
409
+ const info = getPrimitiveInfo('spirals');
410
+ // {
411
+ // name: 'spirals',
412
+ // category: 'radial',
413
+ // description: 'Multiple expanding spirals from center',
414
+ // compilesTo: 'codemode',
415
+ // isCanonical: false,
416
+ // parameters: { count, color, opacity, strokeWeight, motion }
417
+ // }
418
+ ```
419
+
420
+ ### `isPrimitiveValid(name)`
421
+
422
+ Check if a primitive name is valid.
423
+
424
+ ```typescript
425
+ import { isPrimitiveValid } from '@nexart/ui-renderer';
426
+
427
+ isPrimitiveValid('spirals'); // true
428
+ isPrimitiveValid('invalid'); // false
429
+ ```
430
+
431
+ ---
432
+
433
+ ## AI Capabilities API
434
+
435
+ **Designed for AI agents to build valid systems without hallucination.**
436
+
437
+ ⚠️ **Primitives are helper generators that compile to Code Mode sketches.**
438
+ They are NOT canonical. The canonical output is always the compiled Code Mode source.
439
+
440
+ ### For AI Agents
441
+
442
+ ```typescript
443
+ import { getCapabilities, isPrimitiveValid, getPrimitiveInfo } from '@nexart/ui-renderer';
444
+
445
+ const caps = getCapabilities();
446
+
447
+ caps.primitivesMeta.notice; // "Primitives are helper generators..."
448
+ caps.primitivesMeta.count; // 30
449
+ caps.primitivesMeta.isCanonical; // false
450
+
451
+ for (const p of caps.primitives) {
452
+ console.log(p.name); // 'dots', 'spirals', etc.
453
+ console.log(p.category); // 'basic', 'radial', etc.
454
+ console.log(p.description); // Human-readable description
455
+ console.log(p.parameters.count.min); // 3
456
+ console.log(p.parameters.count.max); // 50
457
+ console.log(p.parameters.count.default); // 12
458
+ }
459
+ ```
460
+
461
+ ### Primitive Parameter Specification
462
+
463
+ All primitives share these parameters:
464
+
465
+ | Parameter | Type | Required | Range | Default |
466
+ |-----------|------|----------|-------|---------|
467
+ | `count` | number | No | 3-50 | 12 |
468
+ | `color` | string | No | CSS color | Palette foreground |
469
+ | `opacity` | number | No | 0.1-1 | 1 |
470
+ | `strokeWeight` | enum | No | 'auto', 'thin', 'medium', 'thick' | 'auto' |
471
+ | `motion` | enum | No | 'slow', 'medium', 'fast' | 'slow' |
472
+
473
+ ### Valid Primitive Categories
474
+
475
+ | Category | Primitives |
476
+ |----------|-----------|
477
+ | `basic` | dots, lines, waves, stripes, circles, grid |
478
+ | `geometric` | polygons, diamonds, hexgrid, stars, concentricSquares |
479
+ | `radial` | spirals, rays, orbits, rings, arcs, radialLines, petals |
480
+ | `flow` | flow, particles, bubbles |
481
+ | `patterns` | crosshatch, chevrons, zigzag, weave, moire |
482
+ | `organic` | curves, noise, mesh, branches |
483
+
325
484
  ---
326
485
 
327
486
  ## Delegation Logging
@@ -1,13 +1,27 @@
1
1
  /**
2
- * @nexart/ui-renderer v0.2.0 - Capabilities Discovery
2
+ * @nexart/ui-renderer v0.6.0 - Capabilities Discovery
3
3
  *
4
4
  * Exposes SDK capabilities for AI tools and builders.
5
5
  * Critical for preventing hallucination and SDK bypass.
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.
6
11
  */
7
12
  export interface PrimitiveCapability {
8
- type: string;
13
+ name: string;
14
+ category: 'basic' | 'geometric' | 'radial' | 'flow' | 'patterns' | 'organic';
9
15
  description: string;
10
- parameters: Record<string, ParameterSpec>;
16
+ compilesTo: 'codemode';
17
+ isCanonical: false;
18
+ parameters: {
19
+ count: ParameterSpec;
20
+ color: ParameterSpec;
21
+ opacity: ParameterSpec;
22
+ strokeWeight: ParameterSpec;
23
+ motion: ParameterSpec;
24
+ };
11
25
  }
12
26
  export interface ParameterSpec {
13
27
  type: 'number' | 'string' | 'enum' | 'tuple' | 'boolean';
@@ -24,6 +38,13 @@ export interface Capabilities {
24
38
  isCanonical: false;
25
39
  isArchival: false;
26
40
  renderer: '@nexart/ui-renderer';
41
+ primitivesMeta: {
42
+ notice: string;
43
+ count: number;
44
+ categories: string[];
45
+ compilesTo: 'codemode';
46
+ isCanonical: false;
47
+ };
27
48
  primitives: PrimitiveCapability[];
28
49
  background: {
29
50
  color: ParameterSpec;
@@ -40,15 +61,15 @@ export interface Capabilities {
40
61
  };
41
62
  limits: {
42
63
  maxElements: number;
43
- maxParticles: number;
44
- maxDots: number;
45
- maxLines: number;
46
- maxOrbits: number;
47
- maxGridSize: number;
64
+ maxCount: number;
65
+ maxPrimitives: number;
48
66
  };
49
67
  }
50
68
  export declare function getCapabilities(): Capabilities;
51
69
  export declare function getPrimitiveTypes(): string[];
70
+ export declare function getPrimitivesByCategory(): Record<string, string[]>;
71
+ export declare function getPrimitiveInfo(name: string): PrimitiveCapability | null;
52
72
  export declare function getMotionSources(): string[];
53
73
  export declare function getBackgroundTextures(): string[];
74
+ export declare function isPrimitiveValid(name: string): boolean;
54
75
  //# sourceMappingURL=capabilities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACzD,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,O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