@nexart/codemode-sdk 1.4.0 → 1.5.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 +289 -0
- package/CODE_MODE_PROTOCOL.md +471 -0
- package/README.md +237 -50
- package/dist/builder-manifest.d.ts +79 -0
- package/dist/builder-manifest.d.ts.map +1 -0
- package/dist/builder-manifest.js +97 -0
- package/dist/core-index.d.ts +21 -0
- package/dist/core-index.d.ts.map +1 -0
- package/dist/core-index.js +26 -0
- package/dist/engine.d.ts +1 -1
- package/dist/engine.js +1 -1
- package/dist/execute.d.ts +46 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +282 -0
- package/dist/index.d.ts +27 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -19
- package/dist/loop-engine.d.ts +5 -1
- package/dist/loop-engine.d.ts.map +1 -1
- package/dist/loop-engine.js +25 -14
- package/dist/noise-bridge.d.ts +44 -0
- package/dist/noise-bridge.d.ts.map +1 -0
- package/dist/noise-bridge.js +68 -0
- package/dist/noise-engine.d.ts +74 -0
- package/dist/noise-engine.d.ts.map +1 -0
- package/dist/noise-engine.js +132 -0
- package/dist/noise-sketches/fractalNoise.d.ts +11 -0
- package/dist/noise-sketches/fractalNoise.d.ts.map +1 -0
- package/dist/noise-sketches/fractalNoise.js +121 -0
- package/dist/noise-sketches/index.d.ts +21 -0
- package/dist/noise-sketches/index.d.ts.map +1 -0
- package/dist/noise-sketches/index.js +28 -0
- package/dist/p5-runtime.d.ts +56 -4
- package/dist/p5-runtime.d.ts.map +1 -1
- package/dist/p5-runtime.js +743 -32
- package/dist/sound-bridge.d.ts +89 -0
- package/dist/sound-bridge.d.ts.map +1 -0
- package/dist/sound-bridge.js +128 -0
- package/dist/soundart-engine.d.ts +87 -0
- package/dist/soundart-engine.d.ts.map +1 -0
- package/dist/soundart-engine.js +173 -0
- package/dist/soundart-sketches/chladniBloom.d.ts +3 -0
- package/dist/soundart-sketches/chladniBloom.d.ts.map +1 -0
- package/dist/soundart-sketches/chladniBloom.js +53 -0
- package/dist/soundart-sketches/dualVortex.d.ts +3 -0
- package/dist/soundart-sketches/dualVortex.d.ts.map +1 -0
- package/dist/soundart-sketches/dualVortex.js +67 -0
- package/dist/soundart-sketches/geometryIllusion.d.ts +3 -0
- package/dist/soundart-sketches/geometryIllusion.d.ts.map +1 -0
- package/dist/soundart-sketches/geometryIllusion.js +89 -0
- package/dist/soundart-sketches/index.d.ts +39 -0
- package/dist/soundart-sketches/index.d.ts.map +1 -0
- package/dist/soundart-sketches/index.js +72 -0
- package/dist/soundart-sketches/isoflow.d.ts +3 -0
- package/dist/soundart-sketches/isoflow.d.ts.map +1 -0
- package/dist/soundart-sketches/isoflow.js +60 -0
- package/dist/soundart-sketches/loomWeave.d.ts +3 -0
- package/dist/soundart-sketches/loomWeave.d.ts.map +1 -0
- package/dist/soundart-sketches/loomWeave.js +59 -0
- package/dist/soundart-sketches/noiseTerraces.d.ts +3 -0
- package/dist/soundart-sketches/noiseTerraces.d.ts.map +1 -0
- package/dist/soundart-sketches/noiseTerraces.js +53 -0
- package/dist/soundart-sketches/orb.d.ts +3 -0
- package/dist/soundart-sketches/orb.d.ts.map +1 -0
- package/dist/soundart-sketches/orb.js +50 -0
- package/dist/soundart-sketches/pixelGlyphs.d.ts +3 -0
- package/dist/soundart-sketches/pixelGlyphs.d.ts.map +1 -0
- package/dist/soundart-sketches/pixelGlyphs.js +72 -0
- package/dist/soundart-sketches/prismFlowFields.d.ts +3 -0
- package/dist/soundart-sketches/prismFlowFields.d.ts.map +1 -0
- package/dist/soundart-sketches/prismFlowFields.js +51 -0
- package/dist/soundart-sketches/radialBurst.d.ts +3 -0
- package/dist/soundart-sketches/radialBurst.d.ts.map +1 -0
- package/dist/soundart-sketches/radialBurst.js +60 -0
- package/dist/soundart-sketches/resonantSoundBodies.d.ts +3 -0
- package/dist/soundart-sketches/resonantSoundBodies.d.ts.map +1 -0
- package/dist/soundart-sketches/resonantSoundBodies.js +89 -0
- package/dist/soundart-sketches/rings.d.ts +11 -0
- package/dist/soundart-sketches/rings.d.ts.map +1 -0
- package/dist/soundart-sketches/rings.js +89 -0
- package/dist/soundart-sketches/squares.d.ts +3 -0
- package/dist/soundart-sketches/squares.d.ts.map +1 -0
- package/dist/soundart-sketches/squares.js +52 -0
- package/dist/soundart-sketches/waveStripes.d.ts +3 -0
- package/dist/soundart-sketches/waveStripes.d.ts.map +1 -0
- package/dist/soundart-sketches/waveStripes.js +44 -0
- package/dist/static-engine.d.ts +4 -1
- package/dist/static-engine.d.ts.map +1 -1
- package/dist/static-engine.js +13 -8
- package/dist/types.d.ts +43 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/package.json +24 -15
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# NexArt Code Mode Runtime SDK
|
|
2
2
|
|
|
3
|
-
**Version: 1.
|
|
3
|
+
**Version: 1.5.1 (Protocol v1.2.0)**
|
|
4
4
|
|
|
5
5
|
╔══════════════════════════════════════════════════════════════════════════════╗
|
|
6
6
|
║ @nexart/codemode-sdk — Canonical Code Mode Authority ║
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
║ ║
|
|
11
11
|
║ Protocol: nexart ║
|
|
12
12
|
║ Engine: codemode ║
|
|
13
|
-
║ SDK Version: 1.
|
|
13
|
+
║ SDK Version: 1.5.1 ║
|
|
14
14
|
║ Protocol Version: 1.2.0 ║
|
|
15
15
|
║ Phase: 3 ║
|
|
16
16
|
║ Enforcement: HARD ║
|
|
@@ -54,7 +54,35 @@ The answer is: "Whatever @nexart/codemode-sdk does — that is the protocol."
|
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
|
-
## What's New in v1.
|
|
57
|
+
## What's New in v1.5.1
|
|
58
|
+
|
|
59
|
+
**Builder Manifest — Passive Attribution (Write-Only)**
|
|
60
|
+
|
|
61
|
+
- `registerBuilderManifest(manifest?)` — Declare builder identity for future attribution
|
|
62
|
+
|
|
63
|
+
**The Builder Manifest is a declaration of intent, not a capability.**
|
|
64
|
+
|
|
65
|
+
The SDK does not expose any API to read or inspect manifests. This is:
|
|
66
|
+
- **Declarative** — Write-only, no read API exposed
|
|
67
|
+
- **Optional** — No errors if missing or invalid
|
|
68
|
+
- **Non-enforced** — No validation logic
|
|
69
|
+
- **Non-rewarding** — No incentives, no tracking
|
|
70
|
+
|
|
71
|
+
There is NO SDK API to read manifests, NO validation, NO attribution logic, and NO tracking. Execution behavior is identical with or without a manifest registered.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
import { registerBuilderManifest } from '@nexart/codemode-sdk';
|
|
75
|
+
|
|
76
|
+
registerBuilderManifest({
|
|
77
|
+
protocol: 'nexart',
|
|
78
|
+
manifestVersion: '0.1',
|
|
79
|
+
app: { name: 'My App', url: 'https://myapp.com' }
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## v1.4.0 (Protocol v1.2.0)
|
|
58
86
|
|
|
59
87
|
**Phase 3 — Pixel & Graphics**
|
|
60
88
|
|
|
@@ -119,7 +147,8 @@ The SDK enforces the **NexArt Code Mode Protocol v1.2.0** for reproducible, mint
|
|
|
119
147
|
## Installation
|
|
120
148
|
|
|
121
149
|
```bash
|
|
122
|
-
|
|
150
|
+
# Copy the sdk/codemode folder to your project
|
|
151
|
+
cp -r sdk/codemode your-project/lib/codemode
|
|
123
152
|
```
|
|
124
153
|
|
|
125
154
|
---
|
|
@@ -181,8 +210,8 @@ interface ExecuteCodeModeResult {
|
|
|
181
210
|
metadata: {
|
|
182
211
|
protocol: 'nexart';
|
|
183
212
|
engine: 'codemode';
|
|
184
|
-
protocolVersion: '1.
|
|
185
|
-
phase:
|
|
213
|
+
protocolVersion: '1.0.0';
|
|
214
|
+
phase: 1;
|
|
186
215
|
deterministic: true;
|
|
187
216
|
seed: number;
|
|
188
217
|
vars: number[];
|
|
@@ -196,11 +225,67 @@ interface ExecuteCodeModeResult {
|
|
|
196
225
|
|
|
197
226
|
---
|
|
198
227
|
|
|
199
|
-
##
|
|
228
|
+
## Legacy API
|
|
229
|
+
|
|
230
|
+
> ⚠️ **Note**: The `createEngine()` API is still supported but new implementations should use `executeCodeMode()`.
|
|
231
|
+
|
|
232
|
+
### `createEngine(config: EngineConfig): Engine`
|
|
233
|
+
|
|
234
|
+
Create a rendering engine instance.
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
import { createEngine } from './codemode';
|
|
238
|
+
|
|
239
|
+
const engine = createEngine({
|
|
240
|
+
mode: 'static', // 'static' | 'loop'
|
|
241
|
+
width: 1950, // Optional, default: 1950
|
|
242
|
+
height: 2400, // Optional, default: 2400
|
|
243
|
+
duration: 2, // Loop mode only, 1-4 seconds
|
|
244
|
+
fps: 30, // Loop mode only, default: 30
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### `engine.run(options: RunOptions): Promise<void>`
|
|
249
|
+
|
|
250
|
+
Execute code and produce output.
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
await engine.run({
|
|
254
|
+
code: `
|
|
255
|
+
function setup() {
|
|
256
|
+
background(255);
|
|
257
|
+
fill(0);
|
|
258
|
+
// Use VAR for external control
|
|
259
|
+
let size = map(VAR[0], 0, 100, 50, 200);
|
|
260
|
+
ellipse(width/2, height/2, size);
|
|
261
|
+
}
|
|
262
|
+
`,
|
|
263
|
+
seed: 12345, // Optional: seed for deterministic randomness
|
|
264
|
+
vars: [50, 75, 0, 0, 0, 0, 0, 0, 0, 0], // Optional: VAR[0..9] values (0-100)
|
|
265
|
+
onPreview: (canvas) => {
|
|
266
|
+
// Optional: called with canvas after first frame
|
|
267
|
+
},
|
|
268
|
+
onProgress: (info) => {
|
|
269
|
+
// Optional: progress updates
|
|
270
|
+
console.log(info.message, info.percent + '%');
|
|
271
|
+
},
|
|
272
|
+
onComplete: (result) => {
|
|
273
|
+
// Required: called with final result
|
|
274
|
+
console.log(result.type); // 'image' | 'video'
|
|
275
|
+
console.log(result.blob); // Blob
|
|
276
|
+
},
|
|
277
|
+
onError: (error) => {
|
|
278
|
+
// Optional: called on error
|
|
279
|
+
console.error(error);
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Protocol Variables (VAR[0..9]) — Protocol v1.0.0
|
|
200
285
|
|
|
201
286
|
Protocol variables are first-class inputs that control artwork parameters.
|
|
202
287
|
|
|
203
|
-
**VAR Specification:**
|
|
288
|
+
**VAR Specification (SDK v1.0.2):**
|
|
204
289
|
|
|
205
290
|
| Property | Value | Enforcement |
|
|
206
291
|
|----------|-------|-------------|
|
|
@@ -214,7 +299,20 @@ Protocol variables are first-class inputs that control artwork parameters.
|
|
|
214
299
|
| Default | All zeros | If not provided |
|
|
215
300
|
|
|
216
301
|
```typescript
|
|
217
|
-
//
|
|
302
|
+
// Pass values when running (0-10 elements)
|
|
303
|
+
await engine.run({
|
|
304
|
+
code: myCode,
|
|
305
|
+
vars: [80, 50, 25], // VAR[0]=80, VAR[1]=50, VAR[2]=25, VAR[3..9]=0
|
|
306
|
+
onComplete: (result) => { /* ... */ },
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// Or omit entirely (all zeros)
|
|
310
|
+
await engine.run({
|
|
311
|
+
code: myCode,
|
|
312
|
+
onComplete: (result) => { /* ... */ },
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
// Access in sketch code
|
|
218
316
|
function setup() {
|
|
219
317
|
let density = map(VAR[0], 0, 100, 10, 200);
|
|
220
318
|
let speed = map(VAR[1], 0, 100, 0.5, 5);
|
|
@@ -230,6 +328,14 @@ function setup() {
|
|
|
230
328
|
- Values MUST be in range 0-100 (throws if out of range)
|
|
231
329
|
- Same code + same seed + same VARs = identical output
|
|
232
330
|
|
|
331
|
+
### `engine.stop(): void`
|
|
332
|
+
|
|
333
|
+
Cancel a running render (Loop mode only).
|
|
334
|
+
|
|
335
|
+
### `engine.getConfig(): EngineConfig`
|
|
336
|
+
|
|
337
|
+
Get the resolved engine configuration.
|
|
338
|
+
|
|
233
339
|
---
|
|
234
340
|
|
|
235
341
|
## Execution Rules
|
|
@@ -257,7 +363,6 @@ function setup() {
|
|
|
257
363
|
| `t` | float | Normalized time [0.0, 1.0) |
|
|
258
364
|
| `time` | float | Elapsed seconds |
|
|
259
365
|
| `tGlobal` | float | Alias for `t` |
|
|
260
|
-
| `totalFrames` | int | Total frames in loop (v1.4.0+) |
|
|
261
366
|
|
|
262
367
|
---
|
|
263
368
|
|
|
@@ -286,6 +391,76 @@ Additionally in Loop Mode:
|
|
|
286
391
|
|
|
287
392
|
---
|
|
288
393
|
|
|
394
|
+
## Example: Static Mode
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
import { createEngine } from './codemode';
|
|
398
|
+
|
|
399
|
+
const engine = createEngine({ mode: 'static' });
|
|
400
|
+
|
|
401
|
+
await engine.run({
|
|
402
|
+
code: `
|
|
403
|
+
function setup() {
|
|
404
|
+
background(30);
|
|
405
|
+
noStroke();
|
|
406
|
+
for (let i = 0; i < 100; i++) {
|
|
407
|
+
fill(random(255), random(255), random(255));
|
|
408
|
+
ellipse(random(width), random(height), 50);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
`,
|
|
412
|
+
onComplete: (result) => {
|
|
413
|
+
// result.type === 'image'
|
|
414
|
+
// result.blob is a PNG Blob
|
|
415
|
+
const url = URL.createObjectURL(result.blob);
|
|
416
|
+
document.body.innerHTML = `<img src="${url}" />`;
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## Example: Loop Mode
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
import { createEngine } from './codemode';
|
|
427
|
+
|
|
428
|
+
const engine = createEngine({
|
|
429
|
+
mode: 'loop',
|
|
430
|
+
duration: 2, // 2 second loop
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
await engine.run({
|
|
434
|
+
code: `
|
|
435
|
+
function setup() {
|
|
436
|
+
// Called once
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
function draw() {
|
|
440
|
+
background(30);
|
|
441
|
+
|
|
442
|
+
// t goes from 0 to 1 over the loop duration
|
|
443
|
+
let x = width/2 + cos(t * TWO_PI) * 200;
|
|
444
|
+
let y = height/2 + sin(t * TWO_PI) * 200;
|
|
445
|
+
|
|
446
|
+
fill(255);
|
|
447
|
+
ellipse(x, y, 80);
|
|
448
|
+
}
|
|
449
|
+
`,
|
|
450
|
+
onProgress: (info) => {
|
|
451
|
+
console.log(info.message);
|
|
452
|
+
},
|
|
453
|
+
onComplete: (result) => {
|
|
454
|
+
// result.type === 'video'
|
|
455
|
+
// result.blob is an MP4 Blob
|
|
456
|
+
const url = URL.createObjectURL(result.blob);
|
|
457
|
+
document.body.innerHTML = `<video src="${url}" autoplay loop />`;
|
|
458
|
+
},
|
|
459
|
+
});
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
289
464
|
## Supported Functions
|
|
290
465
|
|
|
291
466
|
The SDK includes a comprehensive p5.js-like runtime with 130+ functions:
|
|
@@ -350,21 +525,41 @@ All of the following are accepted by `fill()`, `stroke()`, `background()`:
|
|
|
350
525
|
|
|
351
526
|
---
|
|
352
527
|
|
|
353
|
-
##
|
|
528
|
+
## Video Encoding
|
|
354
529
|
|
|
355
|
-
|
|
530
|
+
Loop Mode requires server-side video encoding. The SDK calls:
|
|
356
531
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
532
|
+
```
|
|
533
|
+
POST /api/encode-loop
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
Ensure your server has this endpoint available (NexArt provides this).
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## Files
|
|
541
|
+
|
|
542
|
+
```
|
|
543
|
+
sdk/codemode/
|
|
544
|
+
├── index.ts # Main export
|
|
545
|
+
├── execute.ts # executeCodeMode canonical entry point
|
|
546
|
+
├── engine.ts # createEngine entry point (legacy)
|
|
547
|
+
├── types.ts # TypeScript types
|
|
548
|
+
├── static-engine.ts # Static mode implementation
|
|
549
|
+
├── loop-engine.ts # Loop mode implementation
|
|
550
|
+
├── p5-runtime.ts # p5.js-like runtime
|
|
551
|
+
├── builder-manifest.ts # Builder manifest (write-only)
|
|
552
|
+
├── CHANGELOG.md # Version history
|
|
553
|
+
└── README.md # This file
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
## License
|
|
559
|
+
|
|
560
|
+
MIT License
|
|
561
|
+
|
|
562
|
+
Copyright (c) 2024-2026 NexArt
|
|
368
563
|
|
|
369
564
|
---
|
|
370
565
|
|
|
@@ -387,7 +582,7 @@ const result = await executeCodeMode({
|
|
|
387
582
|
width: 1950,
|
|
388
583
|
height: 2400,
|
|
389
584
|
seed: 12345,
|
|
390
|
-
vars: [50, 75, 25, 0, 0, 0, 0, 0, 0, 0],
|
|
585
|
+
vars: [50, 75, 25, 0, 0, 0, 0, 0, 0, 0], // Exactly 10 values
|
|
391
586
|
mode: 'static'
|
|
392
587
|
});
|
|
393
588
|
|
|
@@ -413,35 +608,27 @@ try {
|
|
|
413
608
|
|
|
414
609
|
---
|
|
415
610
|
|
|
416
|
-
##
|
|
417
|
-
|
|
418
|
-
Loop Mode requires server-side video encoding. The SDK calls:
|
|
419
|
-
|
|
420
|
-
```
|
|
421
|
-
POST /api/encode-loop
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
Ensure your server has this endpoint available (NexArt provides this).
|
|
425
|
-
|
|
426
|
-
---
|
|
611
|
+
## Frozen Execution Guarantees — v1.0.0
|
|
427
612
|
|
|
428
|
-
|
|
613
|
+
The following guarantees are LOCKED and will not change in v1.x:
|
|
429
614
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
615
|
+
| Guarantee | Description |
|
|
616
|
+
|-----------|-------------|
|
|
617
|
+
| Determinism | Same code + same seed + same VARs = identical output |
|
|
618
|
+
| Static Mode | `setup()` only, single PNG output |
|
|
619
|
+
| Loop Mode | Frame-authoritative, `draw()` per frame, MP4 output |
|
|
620
|
+
| Time Semantics | `t` ∈ [0,1), `frameCount` ∈ [0,totalFrames), `time` in seconds |
|
|
621
|
+
| Random | Seeded Mulberry32 PRNG via `random()` |
|
|
622
|
+
| Noise | Seeded Perlin noise via `noise()` |
|
|
623
|
+
| Canvas | Pre-initialized, no `createCanvas()` |
|
|
624
|
+
| VAR | Exactly 10 read-only protocol variables |
|
|
625
|
+
| Forbidden Patterns | 13 patterns rejected (see above) |
|
|
440
626
|
|
|
441
627
|
---
|
|
442
628
|
|
|
443
|
-
##
|
|
444
|
-
|
|
445
|
-
MIT License
|
|
629
|
+
## Future Work (Phase 4+)
|
|
446
630
|
|
|
447
|
-
|
|
631
|
+
- External asset loading (controlled)
|
|
632
|
+
- WebGL/3D rendering support
|
|
633
|
+
- GIF output option
|
|
634
|
+
- GSL v1 SDK (protocol layer) — separate package
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NexArt Code Mode SDK - Builder Manifest
|
|
3
|
+
* Version: 1.5.1 (Protocol v1.2.0)
|
|
4
|
+
*
|
|
5
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
6
|
+
* ║ BUILDER MANIFEST — PASSIVE ATTRIBUTION (WRITE-ONLY) ║
|
|
7
|
+
* ║ ║
|
|
8
|
+
* ║ The Builder Manifest is a declaration of intent, not a capability. ║
|
|
9
|
+
* ║ The SDK does not expose any API to read or inspect manifests. ║
|
|
10
|
+
* ║ ║
|
|
11
|
+
* ║ This is: ║
|
|
12
|
+
* ║ - Declarative (write-only, no read API exposed) ║
|
|
13
|
+
* ║ - Optional (no errors if missing or invalid) ║
|
|
14
|
+
* ║ - Non-enforced (no validation logic) ║
|
|
15
|
+
* ║ - Non-rewarding (no incentives, no tracking) ║
|
|
16
|
+
* ║ ║
|
|
17
|
+
* ║ There is: ║
|
|
18
|
+
* ║ - No SDK API to read manifests ║
|
|
19
|
+
* ║ - No validation ║
|
|
20
|
+
* ║ - No attribution logic ║
|
|
21
|
+
* ║ - No tracking, analytics, or network calls ║
|
|
22
|
+
* ║ ║
|
|
23
|
+
* ║ Execution behavior is identical with or without a manifest. ║
|
|
24
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
25
|
+
*/
|
|
26
|
+
import type { NexArtBuilderManifest } from './types';
|
|
27
|
+
/**
|
|
28
|
+
* Register a builder manifest for attribution.
|
|
29
|
+
*
|
|
30
|
+
* This is optional and does not affect execution behavior.
|
|
31
|
+
* The manifest is stored in-memory only and is not:
|
|
32
|
+
* - Serialized to disk
|
|
33
|
+
* - Sent over the network
|
|
34
|
+
* - Logged to console
|
|
35
|
+
* - Used for validation or enforcement
|
|
36
|
+
*
|
|
37
|
+
* @param manifest - Optional builder manifest. Pass undefined to clear.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { registerBuilderManifest } from "@nexart/codemode-sdk";
|
|
42
|
+
*
|
|
43
|
+
* registerBuilderManifest({
|
|
44
|
+
* protocol: "nexart",
|
|
45
|
+
* manifestVersion: "0.1",
|
|
46
|
+
* app: { name: "My App", url: "https://myapp.com" }
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function registerBuilderManifest(manifest?: NexArtBuilderManifest): void;
|
|
51
|
+
/**
|
|
52
|
+
* Get the currently registered builder manifest.
|
|
53
|
+
*
|
|
54
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
55
|
+
* ║ INTERNAL FUNCTION — NOT EXPORTED TO SDK CONSUMERS ║
|
|
56
|
+
* ║ ║
|
|
57
|
+
* ║ This function exists only for internal SDK execution context. ║
|
|
58
|
+
* ║ It is NOT part of the public API and must NOT be exported from index. ║
|
|
59
|
+
* ║ Runtime code and sketch code cannot access this function. ║
|
|
60
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export declare function getBuilderManifest(): NexArtBuilderManifest | null;
|
|
65
|
+
/**
|
|
66
|
+
* Clear the registered builder manifest.
|
|
67
|
+
*
|
|
68
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
69
|
+
* ║ INTERNAL FUNCTION — NOT EXPORTED TO SDK CONSUMERS ║
|
|
70
|
+
* ║ ║
|
|
71
|
+
* ║ This function exists only for internal SDK execution context. ║
|
|
72
|
+
* ║ It is NOT part of the public API and must NOT be exported from index. ║
|
|
73
|
+
* ║ Runtime code and sketch code cannot access this function. ║
|
|
74
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
75
|
+
*
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
export declare function clearBuilderManifest(): void;
|
|
79
|
+
//# sourceMappingURL=builder-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder-manifest.d.ts","sourceRoot":"","sources":["../builder-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAKrD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAiB9E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,IAAI,qBAAqB,GAAG,IAAI,CAEjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NexArt Code Mode SDK - Builder Manifest
|
|
3
|
+
* Version: 1.5.1 (Protocol v1.2.0)
|
|
4
|
+
*
|
|
5
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
6
|
+
* ║ BUILDER MANIFEST — PASSIVE ATTRIBUTION (WRITE-ONLY) ║
|
|
7
|
+
* ║ ║
|
|
8
|
+
* ║ The Builder Manifest is a declaration of intent, not a capability. ║
|
|
9
|
+
* ║ The SDK does not expose any API to read or inspect manifests. ║
|
|
10
|
+
* ║ ║
|
|
11
|
+
* ║ This is: ║
|
|
12
|
+
* ║ - Declarative (write-only, no read API exposed) ║
|
|
13
|
+
* ║ - Optional (no errors if missing or invalid) ║
|
|
14
|
+
* ║ - Non-enforced (no validation logic) ║
|
|
15
|
+
* ║ - Non-rewarding (no incentives, no tracking) ║
|
|
16
|
+
* ║ ║
|
|
17
|
+
* ║ There is: ║
|
|
18
|
+
* ║ - No SDK API to read manifests ║
|
|
19
|
+
* ║ - No validation ║
|
|
20
|
+
* ║ - No attribution logic ║
|
|
21
|
+
* ║ - No tracking, analytics, or network calls ║
|
|
22
|
+
* ║ ║
|
|
23
|
+
* ║ Execution behavior is identical with or without a manifest. ║
|
|
24
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
25
|
+
*/
|
|
26
|
+
/** Internal storage - not accessible to SDK consumers */
|
|
27
|
+
let currentManifest = null;
|
|
28
|
+
/**
|
|
29
|
+
* Register a builder manifest for attribution.
|
|
30
|
+
*
|
|
31
|
+
* This is optional and does not affect execution behavior.
|
|
32
|
+
* The manifest is stored in-memory only and is not:
|
|
33
|
+
* - Serialized to disk
|
|
34
|
+
* - Sent over the network
|
|
35
|
+
* - Logged to console
|
|
36
|
+
* - Used for validation or enforcement
|
|
37
|
+
*
|
|
38
|
+
* @param manifest - Optional builder manifest. Pass undefined to clear.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { registerBuilderManifest } from "@nexart/codemode-sdk";
|
|
43
|
+
*
|
|
44
|
+
* registerBuilderManifest({
|
|
45
|
+
* protocol: "nexart",
|
|
46
|
+
* manifestVersion: "0.1",
|
|
47
|
+
* app: { name: "My App", url: "https://myapp.com" }
|
|
48
|
+
* });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export function registerBuilderManifest(manifest) {
|
|
52
|
+
if (!manifest) {
|
|
53
|
+
currentManifest = null;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (manifest.protocol !== 'nexart') {
|
|
57
|
+
currentManifest = null;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (typeof manifest.manifestVersion !== 'string') {
|
|
61
|
+
currentManifest = null;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
currentManifest = manifest;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the currently registered builder manifest.
|
|
68
|
+
*
|
|
69
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
70
|
+
* ║ INTERNAL FUNCTION — NOT EXPORTED TO SDK CONSUMERS ║
|
|
71
|
+
* ║ ║
|
|
72
|
+
* ║ This function exists only for internal SDK execution context. ║
|
|
73
|
+
* ║ It is NOT part of the public API and must NOT be exported from index. ║
|
|
74
|
+
* ║ Runtime code and sketch code cannot access this function. ║
|
|
75
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
export function getBuilderManifest() {
|
|
80
|
+
return currentManifest;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Clear the registered builder manifest.
|
|
84
|
+
*
|
|
85
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
86
|
+
* ║ INTERNAL FUNCTION — NOT EXPORTED TO SDK CONSUMERS ║
|
|
87
|
+
* ║ ║
|
|
88
|
+
* ║ This function exists only for internal SDK execution context. ║
|
|
89
|
+
* ║ It is NOT part of the public API and must NOT be exported from index. ║
|
|
90
|
+
* ║ Runtime code and sketch code cannot access this function. ║
|
|
91
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export function clearBuilderManifest() {
|
|
96
|
+
currentManifest = null;
|
|
97
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/codemode-sdk v1.4.0 — Core Exports
|
|
3
|
+
*
|
|
4
|
+
* Canonical execution engine for NexArt Code Mode.
|
|
5
|
+
* This is the single source of truth for Code Mode semantics.
|
|
6
|
+
*
|
|
7
|
+
* Protocol: v1.2.0 (Phase 3)
|
|
8
|
+
* Enforcement: HARD
|
|
9
|
+
*/
|
|
10
|
+
export { executeCodeMode, validateCodeModeSource, } from './execute';
|
|
11
|
+
export { type RenderMode, type TimeVariables, type ProtocolMetadata, type EngineConfig, type RenderResult, type RunOptions, type ProgressInfo, type Engine, type ExecuteCodeModeInput, type ExecuteCodeModeResult, PROTOCOL_IDENTITY, DEFAULT_VARS, DEFAULT_CONFIG, } from './types';
|
|
12
|
+
export { createP5Runtime, injectTimeVariables, createProtocolVAR, VAR_COUNT, VAR_MIN, VAR_MAX, CODE_MODE_PROTOCOL_VERSION, CODE_MODE_PROTOCOL_PHASE, CODE_MODE_ENFORCEMENT, type P5Runtime, type P5RuntimeConfig, } from './p5-runtime';
|
|
13
|
+
export { runStaticMode, } from './static-engine';
|
|
14
|
+
export { runLoopMode, cancelLoopMode, } from './loop-engine';
|
|
15
|
+
export { createEngine, } from './engine';
|
|
16
|
+
/**
|
|
17
|
+
* SDK Identity
|
|
18
|
+
*/
|
|
19
|
+
export declare const SDK_VERSION = "1.1.1";
|
|
20
|
+
export declare const SDK_NAME = "@nexart/codemode-sdk";
|
|
21
|
+
//# sourceMappingURL=core-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-index.d.ts","sourceRoot":"","sources":["../core-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EACL,eAAe,EACf,sBAAsB,GACvB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,iBAAiB,EACjB,YAAY,EACZ,cAAc,GACf,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,OAAO,EACP,0BAA0B,EAC1B,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,WAAW,EACX,cAAc,GACf,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,YAAY,GACb,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,QAAQ,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @nexart/codemode-sdk v1.4.0 — Core Exports
|
|
3
|
+
*
|
|
4
|
+
* Canonical execution engine for NexArt Code Mode.
|
|
5
|
+
* This is the single source of truth for Code Mode semantics.
|
|
6
|
+
*
|
|
7
|
+
* Protocol: v1.2.0 (Phase 3)
|
|
8
|
+
* Enforcement: HARD
|
|
9
|
+
*/
|
|
10
|
+
// Core execution
|
|
11
|
+
export { executeCodeMode, validateCodeModeSource, } from './execute';
|
|
12
|
+
// Protocol types
|
|
13
|
+
export { PROTOCOL_IDENTITY, DEFAULT_VARS, DEFAULT_CONFIG, } from './types';
|
|
14
|
+
// Runtime
|
|
15
|
+
export { createP5Runtime, injectTimeVariables, createProtocolVAR, VAR_COUNT, VAR_MIN, VAR_MAX, CODE_MODE_PROTOCOL_VERSION, CODE_MODE_PROTOCOL_PHASE, CODE_MODE_ENFORCEMENT, } from './p5-runtime';
|
|
16
|
+
// Static engine
|
|
17
|
+
export { runStaticMode, } from './static-engine';
|
|
18
|
+
// Loop engine
|
|
19
|
+
export { runLoopMode, cancelLoopMode, } from './loop-engine';
|
|
20
|
+
// Engine utilities
|
|
21
|
+
export { createEngine, } from './engine';
|
|
22
|
+
/**
|
|
23
|
+
* SDK Identity
|
|
24
|
+
*/
|
|
25
|
+
export const SDK_VERSION = '1.1.1';
|
|
26
|
+
export const SDK_NAME = '@nexart/codemode-sdk';
|
package/dist/engine.d.ts
CHANGED
package/dist/engine.js
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NexArt Code Mode Runtime SDK - Canonical Execution Entry Point
|
|
3
|
+
*
|
|
4
|
+
* ╔══════════════════════════════════════════════════════════════════════════╗
|
|
5
|
+
* ║ CODE MODE PROTOCOL v1.2.0 (Phase 3) — CANONICAL ENTRY POINT ║
|
|
6
|
+
* ║ ║
|
|
7
|
+
* ║ This is the ONLY official way to execute Code Mode. ║
|
|
8
|
+
* ║ All implementations (NexArt, ByX, external) MUST use this function. ║
|
|
9
|
+
* ║ ║
|
|
10
|
+
* ║ Authority: @nexart/codemode-sdk ║
|
|
11
|
+
* ╚══════════════════════════════════════════════════════════════════════════╝
|
|
12
|
+
*/
|
|
13
|
+
import { ExecuteCodeModeInput, ExecuteCodeModeResult } from './types';
|
|
14
|
+
/**
|
|
15
|
+
* executeCodeMode — Canonical Code Mode Execution Entry Point
|
|
16
|
+
*
|
|
17
|
+
* This is the ONLY official way to execute Code Mode.
|
|
18
|
+
* All implementations MUST use this function.
|
|
19
|
+
*
|
|
20
|
+
* @param input - Execution parameters
|
|
21
|
+
* @returns Promise<ExecuteCodeModeResult> - Execution result with protocol metadata
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const result = await executeCodeMode({
|
|
26
|
+
* source: `function setup() { background(255); ellipse(width/2, height/2, 100); }`,
|
|
27
|
+
* width: 1950,
|
|
28
|
+
* height: 2400,
|
|
29
|
+
* seed: 12345,
|
|
30
|
+
* vars: [50, 75, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
31
|
+
* mode: 'static'
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* console.log(result.metadata.protocolVersion); // '1.2.0'
|
|
35
|
+
* console.log(result.image); // PNG Blob
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function executeCodeMode(input: ExecuteCodeModeInput): Promise<ExecuteCodeModeResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Validate code without executing
|
|
41
|
+
*/
|
|
42
|
+
export declare function validateCodeModeSource(source: string, mode: 'static' | 'loop'): {
|
|
43
|
+
valid: boolean;
|
|
44
|
+
errors: string[];
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=execute.d.ts.map
|