@nexart/ui-renderer 0.1.0 → 0.2.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/README.md +204 -95
- package/dist/capabilities.d.ts +54 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +338 -0
- package/dist/compiler.d.ts +34 -0
- package/dist/compiler.d.ts.map +1 -0
- package/dist/compiler.js +80 -0
- package/dist/index.d.ts +21 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -5
- package/dist/preview/primitives/dots.d.ts +6 -0
- package/dist/preview/primitives/dots.d.ts.map +1 -0
- package/dist/preview/primitives/dots.js +53 -0
- package/dist/preview/primitives/flow.d.ts +6 -0
- package/dist/preview/primitives/flow.d.ts.map +1 -0
- package/dist/preview/primitives/flow.js +32 -0
- package/dist/preview/primitives/grid.d.ts +6 -0
- package/dist/preview/primitives/grid.d.ts.map +1 -0
- package/dist/preview/primitives/grid.js +38 -0
- package/dist/preview/primitives/lines.d.ts +6 -0
- package/dist/preview/primitives/lines.d.ts.map +1 -0
- package/dist/preview/primitives/lines.js +47 -0
- package/dist/preview/primitives/orbits.d.ts +6 -0
- package/dist/preview/primitives/orbits.d.ts.map +1 -0
- package/dist/preview/primitives/orbits.js +27 -0
- package/dist/preview/primitives/waves.d.ts +6 -0
- package/dist/preview/primitives/waves.d.ts.map +1 -0
- package/dist/preview/primitives/waves.js +44 -0
- package/dist/preview/renderer.d.ts +17 -0
- package/dist/preview/renderer.d.ts.map +1 -0
- package/dist/preview/renderer.js +167 -0
- package/dist/system.d.ts +9 -0
- package/dist/system.d.ts.map +1 -0
- package/dist/system.js +165 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/package.json +16 -7
- package/dist/renderer.d.ts +0 -31
- package/dist/renderer.d.ts.map +0 -1
- package/dist/renderer.js +0 -210
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/ui-renderer v0.2.0 - Capabilities Discovery
|
|
3
|
+
*
|
|
4
|
+
* Exposes SDK capabilities for AI tools and builders.
|
|
5
|
+
* Critical for preventing hallucination and SDK bypass.
|
|
6
|
+
*/
|
|
7
|
+
export function getCapabilities() {
|
|
8
|
+
return {
|
|
9
|
+
version: '0.2.0',
|
|
10
|
+
isCanonical: false,
|
|
11
|
+
isArchival: false,
|
|
12
|
+
renderer: '@nexart/ui-renderer',
|
|
13
|
+
primitives: [
|
|
14
|
+
{
|
|
15
|
+
type: 'dots',
|
|
16
|
+
description: 'Scattered dot patterns with various distributions',
|
|
17
|
+
parameters: {
|
|
18
|
+
distribution: {
|
|
19
|
+
type: 'enum',
|
|
20
|
+
required: true,
|
|
21
|
+
description: 'How dots are distributed across the canvas',
|
|
22
|
+
options: ['random', 'radial', 'grid', 'spiral'],
|
|
23
|
+
},
|
|
24
|
+
count: {
|
|
25
|
+
type: 'number',
|
|
26
|
+
required: true,
|
|
27
|
+
description: 'Number of dots to render',
|
|
28
|
+
min: 1,
|
|
29
|
+
max: 10000,
|
|
30
|
+
},
|
|
31
|
+
size: {
|
|
32
|
+
type: 'tuple',
|
|
33
|
+
required: true,
|
|
34
|
+
description: 'Size range [min, max] in pixels',
|
|
35
|
+
tupleLength: 2,
|
|
36
|
+
},
|
|
37
|
+
color: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
required: false,
|
|
40
|
+
description: 'CSS color or named color',
|
|
41
|
+
default: 'white',
|
|
42
|
+
},
|
|
43
|
+
opacity: {
|
|
44
|
+
type: 'number',
|
|
45
|
+
required: false,
|
|
46
|
+
description: 'Opacity from 0 to 1',
|
|
47
|
+
min: 0,
|
|
48
|
+
max: 1,
|
|
49
|
+
default: 1,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: 'lines',
|
|
55
|
+
description: 'Linear patterns in various directions',
|
|
56
|
+
parameters: {
|
|
57
|
+
direction: {
|
|
58
|
+
type: 'enum',
|
|
59
|
+
required: true,
|
|
60
|
+
description: 'Direction of lines',
|
|
61
|
+
options: ['horizontal', 'vertical', 'diagonal', 'radial'],
|
|
62
|
+
},
|
|
63
|
+
count: {
|
|
64
|
+
type: 'number',
|
|
65
|
+
required: true,
|
|
66
|
+
description: 'Number of lines',
|
|
67
|
+
min: 1,
|
|
68
|
+
max: 500,
|
|
69
|
+
},
|
|
70
|
+
thickness: {
|
|
71
|
+
type: 'tuple',
|
|
72
|
+
required: true,
|
|
73
|
+
description: 'Thickness range [min, max] in pixels',
|
|
74
|
+
tupleLength: 2,
|
|
75
|
+
},
|
|
76
|
+
color: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
required: false,
|
|
79
|
+
description: 'CSS color or named color',
|
|
80
|
+
default: 'white',
|
|
81
|
+
},
|
|
82
|
+
opacity: {
|
|
83
|
+
type: 'number',
|
|
84
|
+
required: false,
|
|
85
|
+
description: 'Opacity from 0 to 1',
|
|
86
|
+
min: 0,
|
|
87
|
+
max: 1,
|
|
88
|
+
default: 1,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
type: 'waves',
|
|
94
|
+
description: 'Sinusoidal wave patterns',
|
|
95
|
+
parameters: {
|
|
96
|
+
axis: {
|
|
97
|
+
type: 'enum',
|
|
98
|
+
required: true,
|
|
99
|
+
description: 'Primary axis of wave motion',
|
|
100
|
+
options: ['x', 'y'],
|
|
101
|
+
},
|
|
102
|
+
amplitude: {
|
|
103
|
+
type: 'number',
|
|
104
|
+
required: true,
|
|
105
|
+
description: 'Wave height as fraction of canvas (0-1)',
|
|
106
|
+
min: 0,
|
|
107
|
+
max: 1,
|
|
108
|
+
},
|
|
109
|
+
frequency: {
|
|
110
|
+
type: 'number',
|
|
111
|
+
required: true,
|
|
112
|
+
description: 'Number of wave cycles',
|
|
113
|
+
min: 0.1,
|
|
114
|
+
max: 10,
|
|
115
|
+
},
|
|
116
|
+
count: {
|
|
117
|
+
type: 'number',
|
|
118
|
+
required: false,
|
|
119
|
+
description: 'Number of parallel waves',
|
|
120
|
+
min: 1,
|
|
121
|
+
max: 50,
|
|
122
|
+
default: 8,
|
|
123
|
+
},
|
|
124
|
+
color: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
required: false,
|
|
127
|
+
description: 'CSS color or named color',
|
|
128
|
+
default: 'white',
|
|
129
|
+
},
|
|
130
|
+
opacity: {
|
|
131
|
+
type: 'number',
|
|
132
|
+
required: false,
|
|
133
|
+
description: 'Opacity from 0 to 1',
|
|
134
|
+
min: 0,
|
|
135
|
+
max: 1,
|
|
136
|
+
default: 1,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
type: 'grid',
|
|
142
|
+
description: 'Regular grid of shapes',
|
|
143
|
+
parameters: {
|
|
144
|
+
rows: {
|
|
145
|
+
type: 'number',
|
|
146
|
+
required: true,
|
|
147
|
+
description: 'Number of rows',
|
|
148
|
+
min: 1,
|
|
149
|
+
max: 100,
|
|
150
|
+
},
|
|
151
|
+
cols: {
|
|
152
|
+
type: 'number',
|
|
153
|
+
required: true,
|
|
154
|
+
description: 'Number of columns',
|
|
155
|
+
min: 1,
|
|
156
|
+
max: 100,
|
|
157
|
+
},
|
|
158
|
+
shape: {
|
|
159
|
+
type: 'enum',
|
|
160
|
+
required: true,
|
|
161
|
+
description: 'Shape at each grid point',
|
|
162
|
+
options: ['square', 'circle', 'diamond'],
|
|
163
|
+
},
|
|
164
|
+
cellSize: {
|
|
165
|
+
type: 'number',
|
|
166
|
+
required: false,
|
|
167
|
+
description: 'Size of each cell shape in pixels',
|
|
168
|
+
},
|
|
169
|
+
color: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
required: false,
|
|
172
|
+
description: 'CSS color or named color',
|
|
173
|
+
default: 'white',
|
|
174
|
+
},
|
|
175
|
+
opacity: {
|
|
176
|
+
type: 'number',
|
|
177
|
+
required: false,
|
|
178
|
+
description: 'Opacity from 0 to 1',
|
|
179
|
+
min: 0,
|
|
180
|
+
max: 1,
|
|
181
|
+
default: 1,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: 'flowField',
|
|
187
|
+
description: 'Particle traces following a noise-based vector field',
|
|
188
|
+
parameters: {
|
|
189
|
+
resolution: {
|
|
190
|
+
type: 'number',
|
|
191
|
+
required: true,
|
|
192
|
+
description: 'Grid resolution for noise sampling',
|
|
193
|
+
min: 5,
|
|
194
|
+
max: 100,
|
|
195
|
+
},
|
|
196
|
+
strength: {
|
|
197
|
+
type: 'number',
|
|
198
|
+
required: true,
|
|
199
|
+
description: 'Field influence strength (0-1)',
|
|
200
|
+
min: 0,
|
|
201
|
+
max: 1,
|
|
202
|
+
},
|
|
203
|
+
particles: {
|
|
204
|
+
type: 'number',
|
|
205
|
+
required: true,
|
|
206
|
+
description: 'Number of particles',
|
|
207
|
+
min: 10,
|
|
208
|
+
max: 5000,
|
|
209
|
+
},
|
|
210
|
+
color: {
|
|
211
|
+
type: 'string',
|
|
212
|
+
required: false,
|
|
213
|
+
description: 'CSS color or named color',
|
|
214
|
+
default: 'white',
|
|
215
|
+
},
|
|
216
|
+
opacity: {
|
|
217
|
+
type: 'number',
|
|
218
|
+
required: false,
|
|
219
|
+
description: 'Opacity from 0 to 1',
|
|
220
|
+
min: 0,
|
|
221
|
+
max: 1,
|
|
222
|
+
default: 1,
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
type: 'orbits',
|
|
228
|
+
description: 'Circular orbital patterns with dots',
|
|
229
|
+
parameters: {
|
|
230
|
+
count: {
|
|
231
|
+
type: 'number',
|
|
232
|
+
required: true,
|
|
233
|
+
description: 'Number of orbital rings',
|
|
234
|
+
min: 1,
|
|
235
|
+
max: 20,
|
|
236
|
+
},
|
|
237
|
+
radius: {
|
|
238
|
+
type: 'tuple',
|
|
239
|
+
required: true,
|
|
240
|
+
description: 'Radius range [min, max] in pixels',
|
|
241
|
+
tupleLength: 2,
|
|
242
|
+
},
|
|
243
|
+
dotCount: {
|
|
244
|
+
type: 'number',
|
|
245
|
+
required: true,
|
|
246
|
+
description: 'Dots per orbit',
|
|
247
|
+
min: 1,
|
|
248
|
+
max: 200,
|
|
249
|
+
},
|
|
250
|
+
speed: {
|
|
251
|
+
type: 'number',
|
|
252
|
+
required: false,
|
|
253
|
+
description: 'Rotation speed multiplier',
|
|
254
|
+
min: 0,
|
|
255
|
+
max: 5,
|
|
256
|
+
default: 1,
|
|
257
|
+
},
|
|
258
|
+
color: {
|
|
259
|
+
type: 'string',
|
|
260
|
+
required: false,
|
|
261
|
+
description: 'CSS color or named color',
|
|
262
|
+
default: 'white',
|
|
263
|
+
},
|
|
264
|
+
opacity: {
|
|
265
|
+
type: 'number',
|
|
266
|
+
required: false,
|
|
267
|
+
description: 'Opacity from 0 to 1',
|
|
268
|
+
min: 0,
|
|
269
|
+
max: 1,
|
|
270
|
+
default: 1,
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
background: {
|
|
276
|
+
color: {
|
|
277
|
+
type: 'string',
|
|
278
|
+
required: true,
|
|
279
|
+
description: 'Background color (CSS color or named color like "blue", "black", "#1a1a2e")',
|
|
280
|
+
},
|
|
281
|
+
texture: {
|
|
282
|
+
type: 'enum',
|
|
283
|
+
required: false,
|
|
284
|
+
description: 'Background texture overlay',
|
|
285
|
+
options: ['none', 'noise', 'grain'],
|
|
286
|
+
default: 'none',
|
|
287
|
+
},
|
|
288
|
+
gradient: {
|
|
289
|
+
type: {
|
|
290
|
+
type: 'enum',
|
|
291
|
+
required: true,
|
|
292
|
+
description: 'Gradient type',
|
|
293
|
+
options: ['linear', 'radial'],
|
|
294
|
+
},
|
|
295
|
+
colors: {
|
|
296
|
+
type: 'string',
|
|
297
|
+
required: true,
|
|
298
|
+
description: 'Array of CSS colors (minimum 2)',
|
|
299
|
+
},
|
|
300
|
+
angle: {
|
|
301
|
+
type: 'number',
|
|
302
|
+
required: false,
|
|
303
|
+
description: 'Gradient angle in degrees (linear only)',
|
|
304
|
+
min: 0,
|
|
305
|
+
max: 360,
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
motion: {
|
|
310
|
+
sources: ['none', 'time', 'seed'],
|
|
311
|
+
speed: {
|
|
312
|
+
type: 'number',
|
|
313
|
+
required: false,
|
|
314
|
+
description: 'Animation speed multiplier',
|
|
315
|
+
min: 0,
|
|
316
|
+
max: 5,
|
|
317
|
+
default: 1,
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
limits: {
|
|
321
|
+
maxElements: 20,
|
|
322
|
+
maxParticles: 5000,
|
|
323
|
+
maxDots: 10000,
|
|
324
|
+
maxLines: 500,
|
|
325
|
+
maxOrbits: 20,
|
|
326
|
+
maxGridSize: 100,
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
export function getPrimitiveTypes() {
|
|
331
|
+
return ['dots', 'lines', 'waves', 'grid', 'flowField', 'orbits'];
|
|
332
|
+
}
|
|
333
|
+
export function getMotionSources() {
|
|
334
|
+
return ['none', 'time', 'seed'];
|
|
335
|
+
}
|
|
336
|
+
export function getBackgroundTextures() {
|
|
337
|
+
return ['none', 'noise', 'grain'];
|
|
338
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/ui-renderer v0.2.0 - System Compiler
|
|
3
|
+
*
|
|
4
|
+
* Compiles validated systems into canonical protocol-compatible JSON.
|
|
5
|
+
*/
|
|
6
|
+
import type { NexArtSystem } from './types';
|
|
7
|
+
export interface CompiledSystem {
|
|
8
|
+
protocol: 'nexart';
|
|
9
|
+
systemVersion: string;
|
|
10
|
+
seed: number;
|
|
11
|
+
background: {
|
|
12
|
+
color: string;
|
|
13
|
+
texture: string;
|
|
14
|
+
gradient?: {
|
|
15
|
+
type: string;
|
|
16
|
+
colors: string[];
|
|
17
|
+
angle?: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
elements: Array<{
|
|
21
|
+
type: string;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}>;
|
|
24
|
+
motion: {
|
|
25
|
+
source: string;
|
|
26
|
+
speed?: number;
|
|
27
|
+
};
|
|
28
|
+
deterministic: boolean;
|
|
29
|
+
compiledAt: string;
|
|
30
|
+
compilerVersion: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function compileSystem(system: NexArtSystem): CompiledSystem;
|
|
33
|
+
export declare function serializeSystem(system: NexArtSystem): string;
|
|
34
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,SAAS,CAAC;AAG3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE;QACV,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE;YACT,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,EAAE,CAAC;YACjB,KAAK,CAAC,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;IACF,QAAQ,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC,CAAC;IACH,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AAID,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,CAyClE;AAuCD,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAG5D"}
|
package/dist/compiler.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/ui-renderer v0.2.0 - System Compiler
|
|
3
|
+
*
|
|
4
|
+
* Compiles validated systems into canonical protocol-compatible JSON.
|
|
5
|
+
*/
|
|
6
|
+
import { validateSystem } from './system';
|
|
7
|
+
const COMPILER_VERSION = '0.2.0';
|
|
8
|
+
export function compileSystem(system) {
|
|
9
|
+
const validation = validateSystem({
|
|
10
|
+
seed: system.seed,
|
|
11
|
+
background: system.background,
|
|
12
|
+
elements: system.elements,
|
|
13
|
+
motion: system.motion,
|
|
14
|
+
});
|
|
15
|
+
if (!validation.valid) {
|
|
16
|
+
throw new Error(`Cannot compile invalid system: ${validation.errors.join('; ')}`);
|
|
17
|
+
}
|
|
18
|
+
const compiled = {
|
|
19
|
+
protocol: 'nexart',
|
|
20
|
+
systemVersion: system.systemVersion,
|
|
21
|
+
seed: system.seed,
|
|
22
|
+
background: {
|
|
23
|
+
color: normalizeColor(system.background.color),
|
|
24
|
+
texture: system.background.texture || 'none',
|
|
25
|
+
},
|
|
26
|
+
elements: system.elements.map(normalizeElement),
|
|
27
|
+
motion: {
|
|
28
|
+
source: system.motion.source,
|
|
29
|
+
...(system.motion.speed !== undefined && { speed: system.motion.speed }),
|
|
30
|
+
},
|
|
31
|
+
deterministic: true,
|
|
32
|
+
compiledAt: new Date().toISOString(),
|
|
33
|
+
compilerVersion: COMPILER_VERSION,
|
|
34
|
+
};
|
|
35
|
+
if (system.background.gradient) {
|
|
36
|
+
compiled.background.gradient = {
|
|
37
|
+
type: system.background.gradient.type,
|
|
38
|
+
colors: system.background.gradient.colors.map(normalizeColor),
|
|
39
|
+
...(system.background.gradient.angle !== undefined && {
|
|
40
|
+
angle: system.background.gradient.angle,
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return compiled;
|
|
45
|
+
}
|
|
46
|
+
function normalizeColor(color) {
|
|
47
|
+
const colorMap = {
|
|
48
|
+
red: '#ff0000',
|
|
49
|
+
green: '#00ff00',
|
|
50
|
+
blue: '#0000ff',
|
|
51
|
+
black: '#000000',
|
|
52
|
+
white: '#ffffff',
|
|
53
|
+
yellow: '#ffff00',
|
|
54
|
+
cyan: '#00ffff',
|
|
55
|
+
magenta: '#ff00ff',
|
|
56
|
+
orange: '#ff8000',
|
|
57
|
+
purple: '#8000ff',
|
|
58
|
+
pink: '#ff0080',
|
|
59
|
+
gray: '#808080',
|
|
60
|
+
grey: '#808080',
|
|
61
|
+
};
|
|
62
|
+
const lower = color.toLowerCase();
|
|
63
|
+
return colorMap[lower] || color;
|
|
64
|
+
}
|
|
65
|
+
function normalizeElement(element) {
|
|
66
|
+
const normalized = { type: element.type };
|
|
67
|
+
for (const [key, value] of Object.entries(element)) {
|
|
68
|
+
if (value !== undefined && value !== null) {
|
|
69
|
+
normalized[key] = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (normalized.opacity === undefined) {
|
|
73
|
+
normalized.opacity = 1;
|
|
74
|
+
}
|
|
75
|
+
return normalized;
|
|
76
|
+
}
|
|
77
|
+
export function serializeSystem(system) {
|
|
78
|
+
const compiled = compileSystem(system);
|
|
79
|
+
return JSON.stringify(compiled, null, 2);
|
|
80
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @nexart/ui-renderer
|
|
3
|
-
* Version: 0.
|
|
3
|
+
* Version: 0.2.0
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Declarative System Authoring SDK for NexArt Protocol
|
|
6
6
|
*
|
|
7
|
-
* ⚠️
|
|
7
|
+
* ⚠️ IMPORTANT DISCLAIMER
|
|
8
|
+
*
|
|
9
|
+
* This SDK is for authoring and preview only.
|
|
8
10
|
* Canonical, archival output is produced exclusively by @nexart/codemode-sdk.
|
|
9
11
|
*
|
|
10
12
|
* This renderer is:
|
|
@@ -12,8 +14,21 @@
|
|
|
12
14
|
* - NOT archival
|
|
13
15
|
* - NOT protocol-authoritative
|
|
14
16
|
*
|
|
15
|
-
* Use it for
|
|
17
|
+
* Use it for:
|
|
18
|
+
* - Creating NexArt systems declaratively
|
|
19
|
+
* - Previewing systems in the browser
|
|
20
|
+
* - Compiling systems to protocol-compatible JSON
|
|
21
|
+
* - Building platforms, tools, and integrations
|
|
16
22
|
*/
|
|
17
|
-
export {
|
|
18
|
-
export
|
|
23
|
+
export { createSystem, validateSystem } from './system';
|
|
24
|
+
export { compileSystem, serializeSystem } from './compiler';
|
|
25
|
+
export { previewSystem } from './preview/renderer';
|
|
26
|
+
export { getCapabilities, getPrimitiveTypes, getMotionSources, getBackgroundTextures, } from './capabilities';
|
|
27
|
+
export type { NexArtSystemInput, NexArtSystem, SystemElement, DotsElement, LinesElement, WavesElement, GridElement, FlowFieldElement, OrbitsElement, BackgroundConfig, MotionConfig, PreviewOptions, ValidationResult, } from './types';
|
|
28
|
+
export type { Capabilities, PrimitiveCapability, ParameterSpec, } from './capabilities';
|
|
29
|
+
export declare const SDK_VERSION = "0.2.1";
|
|
30
|
+
export declare const PROTOCOL_VERSION = "0.2";
|
|
31
|
+
export declare const IS_CANONICAL = false;
|
|
32
|
+
export declare const IS_ARCHIVAL = false;
|
|
33
|
+
export declare const RENDERER = "@nexart/ui-renderer";
|
|
19
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,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"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @nexart/ui-renderer
|
|
3
|
-
* Version: 0.
|
|
3
|
+
* Version: 0.2.0
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Declarative System Authoring SDK for NexArt Protocol
|
|
6
6
|
*
|
|
7
|
-
* ⚠️
|
|
7
|
+
* ⚠️ IMPORTANT DISCLAIMER
|
|
8
|
+
*
|
|
9
|
+
* This SDK is for authoring and preview only.
|
|
8
10
|
* Canonical, archival output is produced exclusively by @nexart/codemode-sdk.
|
|
9
11
|
*
|
|
10
12
|
* This renderer is:
|
|
@@ -12,6 +14,18 @@
|
|
|
12
14
|
* - NOT archival
|
|
13
15
|
* - NOT protocol-authoritative
|
|
14
16
|
*
|
|
15
|
-
* Use it for
|
|
17
|
+
* Use it for:
|
|
18
|
+
* - Creating NexArt systems declaratively
|
|
19
|
+
* - Previewing systems in the browser
|
|
20
|
+
* - Compiling systems to protocol-compatible JSON
|
|
21
|
+
* - Building platforms, tools, and integrations
|
|
16
22
|
*/
|
|
17
|
-
export {
|
|
23
|
+
export { createSystem, validateSystem } from './system';
|
|
24
|
+
export { compileSystem, serializeSystem } from './compiler';
|
|
25
|
+
export { previewSystem } from './preview/renderer';
|
|
26
|
+
export { getCapabilities, getPrimitiveTypes, getMotionSources, getBackgroundTextures, } from './capabilities';
|
|
27
|
+
export const SDK_VERSION = '0.2.1';
|
|
28
|
+
export const PROTOCOL_VERSION = '0.2';
|
|
29
|
+
export const IS_CANONICAL = false;
|
|
30
|
+
export const IS_ARCHIVAL = false;
|
|
31
|
+
export const RENDERER = '@nexart/ui-renderer';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dots Primitive Renderer
|
|
3
|
+
*/
|
|
4
|
+
import type { DotsElement } from '../../types';
|
|
5
|
+
export declare function renderDots(ctx: CanvasRenderingContext2D, el: DotsElement, width: number, height: number, random: () => number, t: number): void;
|
|
6
|
+
//# sourceMappingURL=dots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dots.d.ts","sourceRoot":"","sources":["../../../src/preview/primitives/dots.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,wBAAgB,UAAU,CACxB,GAAG,EAAE,wBAAwB,EAC7B,EAAE,EAAE,WAAW,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,MAAM,EACpB,CAAC,EAAE,MAAM,GACR,IAAI,CA2DN"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dots Primitive Renderer
|
|
3
|
+
*/
|
|
4
|
+
export function renderDots(ctx, el, width, height, random, t) {
|
|
5
|
+
const color = el.color || 'white';
|
|
6
|
+
const opacity = el.opacity ?? 1;
|
|
7
|
+
ctx.fillStyle = color;
|
|
8
|
+
ctx.globalAlpha = opacity;
|
|
9
|
+
const cx = width / 2;
|
|
10
|
+
const cy = height / 2;
|
|
11
|
+
for (let i = 0; i < el.count; i++) {
|
|
12
|
+
let x, y;
|
|
13
|
+
const size = el.size[0] + random() * (el.size[1] - el.size[0]);
|
|
14
|
+
switch (el.distribution) {
|
|
15
|
+
case 'random':
|
|
16
|
+
x = random() * width;
|
|
17
|
+
y = random() * height;
|
|
18
|
+
break;
|
|
19
|
+
case 'radial': {
|
|
20
|
+
const angle = random() * Math.PI * 2;
|
|
21
|
+
const radius = random() * Math.min(width, height) * 0.45;
|
|
22
|
+
x = cx + Math.cos(angle + t * 0.5) * radius;
|
|
23
|
+
y = cy + Math.sin(angle + t * 0.5) * radius;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case 'grid': {
|
|
27
|
+
const cols = Math.ceil(Math.sqrt(el.count));
|
|
28
|
+
const rows = Math.ceil(el.count / cols);
|
|
29
|
+
const col = i % cols;
|
|
30
|
+
const row = Math.floor(i / cols);
|
|
31
|
+
const cellW = width / cols;
|
|
32
|
+
const cellH = height / rows;
|
|
33
|
+
x = cellW * (col + 0.5) + (random() - 0.5) * cellW * 0.3;
|
|
34
|
+
y = cellH * (row + 0.5) + (random() - 0.5) * cellH * 0.3;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case 'spiral': {
|
|
38
|
+
const spiralAngle = (i / el.count) * Math.PI * 8 + t;
|
|
39
|
+
const spiralRadius = (i / el.count) * Math.min(width, height) * 0.45;
|
|
40
|
+
x = cx + Math.cos(spiralAngle) * spiralRadius;
|
|
41
|
+
y = cy + Math.sin(spiralAngle) * spiralRadius;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
x = random() * width;
|
|
46
|
+
y = random() * height;
|
|
47
|
+
}
|
|
48
|
+
ctx.beginPath();
|
|
49
|
+
ctx.arc(x, y, size, 0, Math.PI * 2);
|
|
50
|
+
ctx.fill();
|
|
51
|
+
}
|
|
52
|
+
ctx.globalAlpha = 1;
|
|
53
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow Field Primitive Renderer
|
|
3
|
+
*/
|
|
4
|
+
import type { FlowFieldElement } from '../../types';
|
|
5
|
+
export declare function renderFlowField(ctx: CanvasRenderingContext2D, el: FlowFieldElement, width: number, height: number, random: () => number, seed: number, t: number): void;
|
|
6
|
+
//# sourceMappingURL=flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow.d.ts","sourceRoot":"","sources":["../../../src/preview/primitives/flow.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,eAAe,CAC7B,GAAG,EAAE,wBAAwB,EAC7B,EAAE,EAAE,gBAAgB,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,MAAM,EACpB,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,MAAM,GACR,IAAI,CAsCN"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow Field Primitive Renderer
|
|
3
|
+
*/
|
|
4
|
+
export function renderFlowField(ctx, el, width, height, random, seed, t) {
|
|
5
|
+
const color = el.color || 'white';
|
|
6
|
+
const opacity = el.opacity ?? 1;
|
|
7
|
+
ctx.strokeStyle = color;
|
|
8
|
+
ctx.globalAlpha = opacity * 0.6;
|
|
9
|
+
ctx.lineWidth = 1;
|
|
10
|
+
const noise2D = (x, y) => {
|
|
11
|
+
const n = Math.sin(x * 12.9898 + y * 78.233 + seed * 0.001) * 43758.5453;
|
|
12
|
+
return n - Math.floor(n);
|
|
13
|
+
};
|
|
14
|
+
for (let i = 0; i < el.particles; i++) {
|
|
15
|
+
let x = random() * width;
|
|
16
|
+
let y = random() * height;
|
|
17
|
+
ctx.beginPath();
|
|
18
|
+
ctx.moveTo(x, y);
|
|
19
|
+
const steps = 15 + Math.floor(random() * 20);
|
|
20
|
+
for (let s = 0; s < steps; s++) {
|
|
21
|
+
const noiseVal = noise2D(x / el.resolution, y / el.resolution + t * 0.3);
|
|
22
|
+
const angle = noiseVal * Math.PI * 4 * el.strength;
|
|
23
|
+
x += Math.cos(angle) * 3;
|
|
24
|
+
y += Math.sin(angle) * 3;
|
|
25
|
+
if (x < 0 || x > width || y < 0 || y > height)
|
|
26
|
+
break;
|
|
27
|
+
ctx.lineTo(x, y);
|
|
28
|
+
}
|
|
29
|
+
ctx.stroke();
|
|
30
|
+
}
|
|
31
|
+
ctx.globalAlpha = 1;
|
|
32
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grid Primitive Renderer
|
|
3
|
+
*/
|
|
4
|
+
import type { GridElement } from '../../types';
|
|
5
|
+
export declare function renderGrid(ctx: CanvasRenderingContext2D, el: GridElement, width: number, height: number, random: () => number, t: number): void;
|
|
6
|
+
//# sourceMappingURL=grid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grid.d.ts","sourceRoot":"","sources":["../../../src/preview/primitives/grid.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,wBAAgB,UAAU,CACxB,GAAG,EAAE,wBAAwB,EAC7B,EAAE,EAAE,WAAW,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,MAAM,EACpB,CAAC,EAAE,MAAM,GACR,IAAI,CA4CN"}
|