@yodaos-pkg/aix 0.12.0 → 0.13.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 +65 -4
- package/index.d.ts +86 -0
- package/index.js +171 -3
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/pkg/README.md +65 -4
- package/pkg/aix_web.d.ts +34 -14
- package/pkg/aix_web.js +118 -2
- package/pkg/aix_web_bg.wasm +0 -0
- package/pkg/aix_web_bg.wasm.d.ts +20 -14
- package/pkg/package.json +1 -1
- package/pkg-reader/README.md +65 -4
- package/pkg-reader/aix_web.js +1 -1
- package/pkg-reader/aix_web_bg.wasm +0 -0
- package/pkg-reader/package.json +1 -1
- package/workers/progressive-worker.d.ts +1 -0
- package/workers/progressive-worker.js +57 -0
package/README.md
CHANGED
|
@@ -323,8 +323,8 @@ const widgets = aix.getWidgets('en-US');
|
|
|
323
323
|
|
|
324
324
|
Returns `{ pages, tools, diagnostics }` synchronously. Missing/unreadable resources,
|
|
325
325
|
UTF-8 errors, and malformed page metadata produce `{ path, message }` diagnostics,
|
|
326
|
-
one per failed page.
|
|
327
|
-
pages
|
|
326
|
+
one per failed page. Both result lists put the default page first when it resolves
|
|
327
|
+
and keep the other pages in declaration order. A valid empty page list has no diagnostics;
|
|
328
328
|
invalid/unreadable `app.json.pages` produces an `app.json` diagnostic.
|
|
329
329
|
|
|
330
330
|
```typescript
|
|
@@ -352,7 +352,7 @@ Exported `MetadataResolution` has `pages: PageInfo[]`, `tools: Tool[]`, and
|
|
|
352
352
|
string fields.
|
|
353
353
|
|
|
354
354
|
#### `getTools(): Tool[]`
|
|
355
|
-
Generates
|
|
355
|
+
Generates OpenAI-compatible tools with `_blank` or `_current`. Pages can declare `target` in page JSON or `<script def>` and use `_inline` as an alias for `_current`. A valid `entryPagePath` or an explicit page target places the default page first with `_blank`. When both fields are omitted, only a first page without parameters is inferred as `_blank`.
|
|
356
356
|
```typescript
|
|
357
357
|
const tools = aix.getTools();
|
|
358
358
|
/*
|
|
@@ -361,7 +361,7 @@ const tools = aix.getTools();
|
|
|
361
361
|
target: "_blank",
|
|
362
362
|
layout: { width: 480, height: 168 },
|
|
363
363
|
function: {
|
|
364
|
-
name: "
|
|
364
|
+
name: "pages/index/index",
|
|
365
365
|
description: "Home",
|
|
366
366
|
parameters: { ... }
|
|
367
367
|
}
|
|
@@ -453,3 +453,64 @@ The output will be generated in the `dist` directory, including WASM binaries an
|
|
|
453
453
|
## License
|
|
454
454
|
|
|
455
455
|
MIT
|
|
456
|
+
|
|
457
|
+
## Progressive Assets
|
|
458
|
+
|
|
459
|
+
Declare the asset in an ESM module or Ink script.
|
|
460
|
+
|
|
461
|
+
```js
|
|
462
|
+
import video from './assets/clip.mp4' with {
|
|
463
|
+
type: 'video',
|
|
464
|
+
progressive: 'prefer',
|
|
465
|
+
};
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
The imported value is an opaque `AssetRef`. Pass it to Ink's video or audio consumer. The CLI and Web SDK embed complete assets by default. A Web
|
|
469
|
+
pack caller can choose remote delivery after it stores all prepared objects.
|
|
470
|
+
|
|
471
|
+
```ts
|
|
472
|
+
const packed = await AIX.packFromSource(files, {
|
|
473
|
+
signal: controller.signal,
|
|
474
|
+
async onProgressiveAsset(candidate, context) {
|
|
475
|
+
if (!candidate.progressiveSupport.supported || !shouldUpload(candidate)) {
|
|
476
|
+
return { delivery: 'embedded' };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const plan = await context.prepare();
|
|
480
|
+
const receipt = await uploadVerifiedObjects(plan.remoteObjects, {
|
|
481
|
+
assetVersion: plan.assetVersion,
|
|
482
|
+
signal: context.signal,
|
|
483
|
+
});
|
|
484
|
+
return { delivery: 'progressive', planId: plan.id, receipt };
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
The caller owns upload policy, credentials, and cleanup of uploads left
|
|
490
|
+
unreferenced by a failed pack. Return a receipt only after durable storage has
|
|
491
|
+
verified every object. Receipt URLs must be final, immutable HTTPS locators
|
|
492
|
+
without credentials, query strings, or fragments. A rejected callback, invalid
|
|
493
|
+
receipt, or abort fails the pack. `packed.progressiveAssets` reports the
|
|
494
|
+
selected delivery mode and any source bytes retained for ordinary imports.
|
|
495
|
+
|
|
496
|
+
The media profile accepts ordinary MP4/M4A and prepared fMP4 with
|
|
497
|
+
finite H.264 video, AAC-LC audio, or both. The packer copies encoded samples
|
|
498
|
+
into keyframe-aligned fragments and preserves a single continuous rate-one
|
|
499
|
+
edit per track. Incompatible codecs or timelines can be converted upstream
|
|
500
|
+
or embedded. The Ink runtime must support the selected profile.
|
|
501
|
+
|
|
502
|
+
The browser integration test runs a local HTTPS Studio stand-in. It receives
|
|
503
|
+
object bytes over HTTP PUT, verifies length and SHA-256 on disk, and issues
|
|
504
|
+
receipts only after the entire inventory is present. Set `INK_WEB_DIST` to a
|
|
505
|
+
built Ink Web SDK to also test browser playback and offline reopening through the same object server.
|
|
506
|
+
|
|
507
|
+
In [Play's Build view](https://yodaos-project.github.io/aix/play?mode=build),
|
|
508
|
+
select a project directory and choose **Build and download**. Play calls
|
|
509
|
+
`onProgressiveAsset` for each declared asset and simulates the upload for
|
|
510
|
+
supported media. The downloaded package contains placeholder URLs you can
|
|
511
|
+
view in Inspect.
|
|
512
|
+
|
|
513
|
+
```sh
|
|
514
|
+
npm run build
|
|
515
|
+
AIX_TEST_BROWSER_CHANNEL=chrome node scripts/test-progressive.js
|
|
516
|
+
```
|
package/index.d.ts
CHANGED
|
@@ -35,8 +35,90 @@ export interface PackResult {
|
|
|
35
35
|
data: Uint8Array;
|
|
36
36
|
report: OptimizeReport;
|
|
37
37
|
warnings: string[];
|
|
38
|
+
progressiveAssets: ProgressiveAssetReport[];
|
|
39
|
+
}
|
|
40
|
+
export type AssetRef = `aix-asset:${string}`;
|
|
41
|
+
export type ProgressiveAssetKind = 'audio' | 'video';
|
|
42
|
+
export interface ProgressiveAssetCandidate {
|
|
43
|
+
id: string;
|
|
44
|
+
kind: ProgressiveAssetKind;
|
|
45
|
+
sourcePath: string;
|
|
46
|
+
sourceSha256: string;
|
|
47
|
+
sourceSize: number;
|
|
48
|
+
references: {
|
|
49
|
+
path: string;
|
|
50
|
+
line: number;
|
|
51
|
+
column: number;
|
|
52
|
+
}[];
|
|
53
|
+
format: string;
|
|
54
|
+
dependencies: string[];
|
|
55
|
+
progressiveSupport: {
|
|
56
|
+
supported: boolean;
|
|
57
|
+
profile?: string;
|
|
58
|
+
requiredCapabilities: string[];
|
|
59
|
+
features: string[];
|
|
60
|
+
reason?: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface ProgressiveAssetObject {
|
|
64
|
+
id: string;
|
|
65
|
+
size: number;
|
|
66
|
+
sha256: string;
|
|
67
|
+
}
|
|
68
|
+
export interface ProgressiveAssetPlan {
|
|
69
|
+
id: string;
|
|
70
|
+
assetVersion: string;
|
|
71
|
+
profile: string;
|
|
72
|
+
localMetadata: Record<string, Omit<ProgressiveAssetObject, 'id'>>;
|
|
73
|
+
layout: {
|
|
74
|
+
init: string;
|
|
75
|
+
tracks: Record<string, {
|
|
76
|
+
kind: ProgressiveAssetKind;
|
|
77
|
+
timescale: number;
|
|
78
|
+
}>;
|
|
79
|
+
fragments: {
|
|
80
|
+
object: string;
|
|
81
|
+
ranges: Record<string, {
|
|
82
|
+
start: number;
|
|
83
|
+
end: number;
|
|
84
|
+
presentation_start: number;
|
|
85
|
+
presentation_end: number;
|
|
86
|
+
}>;
|
|
87
|
+
}[];
|
|
88
|
+
};
|
|
89
|
+
remoteObjects: (ProgressiveAssetObject & {
|
|
90
|
+
bytes: Uint8Array;
|
|
91
|
+
})[];
|
|
92
|
+
}
|
|
93
|
+
export interface ProgressiveAssetUploadReceipt {
|
|
94
|
+
uploadId: string;
|
|
95
|
+
assetVersion: string;
|
|
96
|
+
objects: (ProgressiveAssetObject & {
|
|
97
|
+
url: string;
|
|
98
|
+
})[];
|
|
99
|
+
}
|
|
100
|
+
export type ProgressiveAssetDecision = {
|
|
101
|
+
delivery: 'embedded';
|
|
102
|
+
} | {
|
|
103
|
+
delivery: 'progressive';
|
|
104
|
+
planId: string;
|
|
105
|
+
receipt: ProgressiveAssetUploadReceipt;
|
|
106
|
+
};
|
|
107
|
+
export interface ProgressiveAssetPackContext {
|
|
108
|
+
signal: AbortSignal;
|
|
109
|
+
prepare(): Promise<ProgressiveAssetPlan>;
|
|
110
|
+
}
|
|
111
|
+
export interface ProgressiveAssetReport {
|
|
112
|
+
id: string;
|
|
113
|
+
kind: ProgressiveAssetKind;
|
|
114
|
+
sourcePath: string;
|
|
115
|
+
delivery: 'embedded' | 'progressive';
|
|
116
|
+
assetVersion?: string;
|
|
117
|
+
retainedSourceBytes: number;
|
|
38
118
|
}
|
|
39
119
|
export interface PackOptions {
|
|
120
|
+
onProgressiveAsset?: (candidate: ProgressiveAssetCandidate, context: ProgressiveAssetPackContext) => ProgressiveAssetDecision | Promise<ProgressiveAssetDecision>;
|
|
121
|
+
signal?: AbortSignal;
|
|
40
122
|
buildId?: string;
|
|
41
123
|
/** Stable normalized project ID; reuse across builds. */
|
|
42
124
|
agentId?: string;
|
|
@@ -143,6 +225,10 @@ export declare class AIX {
|
|
|
143
225
|
* Error diagnostics reject with AixCheckError; warnings alone are accepted.
|
|
144
226
|
*/
|
|
145
227
|
static From(data: Uint8Array | File, limits?: AixReadLimits, check?: boolean): Promise<AIX>;
|
|
228
|
+
/** Lists the Progressive Assets declared in the same normalized inputs as {@link pack}. */
|
|
229
|
+
static listProgressiveAssets(files: AixInputFile[], options?: {
|
|
230
|
+
signal?: AbortSignal;
|
|
231
|
+
}): Promise<ProgressiveAssetCandidate[]>;
|
|
146
232
|
static pack(files: AixInputFile[], options?: PackOptions): Promise<PackResult>;
|
|
147
233
|
/**
|
|
148
234
|
* Packs an in-memory application source tree.
|
package/index.js
CHANGED
|
@@ -115,12 +115,28 @@ export class AIX {
|
|
|
115
115
|
throw error;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
/** Lists the Progressive Assets declared in the same normalized inputs as {@link pack}. */
|
|
119
|
+
static async listProgressiveAssets(files, options) {
|
|
120
|
+
const signal = options?.signal ?? new AbortController().signal;
|
|
121
|
+
signal.throwIfAborted();
|
|
122
|
+
const session = await openPackSession(snapshotFiles(files), false, signal, () => { });
|
|
123
|
+
try {
|
|
124
|
+
signal.throwIfAborted();
|
|
125
|
+
return session.candidates;
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
session.close();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
118
131
|
static async pack(files, options) {
|
|
132
|
+
if (options?.onProgressiveAsset || options?.signal) {
|
|
133
|
+
return stagedPack(files, options, false);
|
|
134
|
+
}
|
|
119
135
|
const tooling = await loadTooling();
|
|
120
136
|
const buildId = options?.buildId ?? generateBuildId();
|
|
121
137
|
const optimize = options?.optimize === false ? undefined : options?.optimize;
|
|
122
138
|
const result = tooling.pack_aix(files, buildId, options?.engine, optimize, options?.agentId);
|
|
123
|
-
return
|
|
139
|
+
return packResult(result);
|
|
124
140
|
}
|
|
125
141
|
/**
|
|
126
142
|
* Packs an in-memory application source tree.
|
|
@@ -130,13 +146,16 @@ export class AIX {
|
|
|
130
146
|
* `.aixignore` files are honored, and the rule files are omitted.
|
|
131
147
|
*/
|
|
132
148
|
static async packFromSource(files, options) {
|
|
149
|
+
if (options?.onProgressiveAsset || options?.signal) {
|
|
150
|
+
return stagedPack(files, options, true);
|
|
151
|
+
}
|
|
133
152
|
const tooling = await loadTooling();
|
|
134
153
|
const buildId = options?.buildId ?? generateBuildId();
|
|
135
154
|
const optimize = options?.optimize === false ? undefined : options?.optimize;
|
|
136
155
|
const result = options?.onProgress
|
|
137
156
|
? getPackFromSourceWithProgress(tooling)(files, buildId, options.engine, optimize, options.onProgress, options.agentId)
|
|
138
157
|
: getPackFromSource(tooling)(files, buildId, options?.engine, optimize, options?.agentId);
|
|
139
|
-
return
|
|
158
|
+
return packResult(result);
|
|
140
159
|
}
|
|
141
160
|
static async packFromFiles(files, options) {
|
|
142
161
|
const sourceFiles = await Promise.all(files.map(async (file) => ({
|
|
@@ -151,7 +170,7 @@ export class AIX {
|
|
|
151
170
|
? data
|
|
152
171
|
: new Uint8Array(await data.arrayBuffer());
|
|
153
172
|
const result = tooling.optimize_aix(buffer, options);
|
|
154
|
-
return
|
|
173
|
+
return packResult(result);
|
|
155
174
|
}
|
|
156
175
|
/**
|
|
157
176
|
* List all files in the AIX package.
|
|
@@ -239,3 +258,152 @@ function getPackFromSourceWithProgress(tooling) {
|
|
|
239
258
|
}
|
|
240
259
|
return packFromSourceWithProgress;
|
|
241
260
|
}
|
|
261
|
+
function packResult(result) {
|
|
262
|
+
try {
|
|
263
|
+
return {
|
|
264
|
+
data: result.data,
|
|
265
|
+
report: result.report,
|
|
266
|
+
warnings: result.warnings ?? [],
|
|
267
|
+
progressiveAssets: result.progressiveAssets ?? [],
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
result.free?.();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async function openPackSession(files, fromSource, signal, progress) {
|
|
275
|
+
let worker;
|
|
276
|
+
if (typeof Worker !== 'undefined' && typeof document !== 'undefined') {
|
|
277
|
+
try {
|
|
278
|
+
worker = new Worker(new URL('./workers/progressive-worker.js', import.meta.url), { type: 'module' });
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// A host can forbid workers. Use its existing WASM event loop.
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (!worker) {
|
|
285
|
+
const tooling = await loadTooling();
|
|
286
|
+
signal.throwIfAborted();
|
|
287
|
+
const session = new tooling.ProgressivePackWasm(files, fromSource);
|
|
288
|
+
try {
|
|
289
|
+
return {
|
|
290
|
+
candidates: session.candidates(),
|
|
291
|
+
prepare: async (id) => session.prepare(id),
|
|
292
|
+
finalize: async (decisions, buildId, engine, optimize, agentId) => packResult(session.finalize(decisions, buildId, engine, optimize, agentId, progress)),
|
|
293
|
+
close: () => session.free(),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
session.free();
|
|
298
|
+
throw error;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const port = worker;
|
|
302
|
+
const call = (request, transfer = []) => untilAborted(signal, () => new Promise((resolve, reject) => {
|
|
303
|
+
port.onmessage = ({ data }) => {
|
|
304
|
+
if (data.progress) {
|
|
305
|
+
try {
|
|
306
|
+
progress(data.progress);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
reject(error);
|
|
310
|
+
port.terminate();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else if (data.error !== undefined) {
|
|
314
|
+
reject(new Error(data.error));
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
resolve(data.result);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
port.onerror = (event) => reject(new Error(event.message || 'Progressive Asset worker failed'));
|
|
321
|
+
port.onmessageerror = () => reject(new Error('Invalid Progressive Asset worker reply'));
|
|
322
|
+
port.postMessage(request, transfer);
|
|
323
|
+
}));
|
|
324
|
+
try {
|
|
325
|
+
const candidates = await call({ type: 'open', files, fromSource }, files.map((file) => file.data.buffer));
|
|
326
|
+
return {
|
|
327
|
+
candidates,
|
|
328
|
+
prepare: (id) => call({ type: 'prepare', id }),
|
|
329
|
+
finalize: (decisions, buildId, engine, optimize, agentId) => call({ type: 'finalize', decisions, buildId, engine, optimize, agentId }),
|
|
330
|
+
close: () => port.terminate(),
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
catch (error) {
|
|
334
|
+
port.terminate();
|
|
335
|
+
throw error;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function snapshotFiles(files) {
|
|
339
|
+
return files.map(({ path, data }) => ({ path, data: Uint8Array.from(data) }));
|
|
340
|
+
}
|
|
341
|
+
async function stagedPack(files, options, fromSource) {
|
|
342
|
+
const { onProgress, onProgressiveAsset, engine, agentId } = options;
|
|
343
|
+
const buildId = options.buildId ?? generateBuildId();
|
|
344
|
+
const optimize = options.optimize ? { ...options.optimize } : undefined;
|
|
345
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
346
|
+
signal.throwIfAborted();
|
|
347
|
+
const snapshot = snapshotFiles(files);
|
|
348
|
+
const progress = (event) => {
|
|
349
|
+
signal.throwIfAborted();
|
|
350
|
+
onProgress?.(event);
|
|
351
|
+
signal.throwIfAborted();
|
|
352
|
+
};
|
|
353
|
+
progress({ type: 'transferring_files_to_wasm' });
|
|
354
|
+
if (fromSource)
|
|
355
|
+
progress({ type: 'collecting_source_inputs' });
|
|
356
|
+
const session = await openPackSession(snapshot, fromSource, signal, progress);
|
|
357
|
+
try {
|
|
358
|
+
const decisions = Object.create(null);
|
|
359
|
+
if (onProgressiveAsset) {
|
|
360
|
+
for (const candidate of session.candidates) {
|
|
361
|
+
signal.throwIfAborted();
|
|
362
|
+
const id = candidate.id;
|
|
363
|
+
let active = true;
|
|
364
|
+
let plan;
|
|
365
|
+
const prepare = async () => {
|
|
366
|
+
signal.throwIfAborted();
|
|
367
|
+
if (!active)
|
|
368
|
+
throw new Error('Progressive Asset callback has finished');
|
|
369
|
+
plan ?? (plan = session.prepare(id));
|
|
370
|
+
void plan.catch(() => { });
|
|
371
|
+
// The upload may mutate or transfer the caller's copy. The pack
|
|
372
|
+
// session and subsequent prepare calls keep the original bytes.
|
|
373
|
+
return structuredClone(await plan);
|
|
374
|
+
};
|
|
375
|
+
try {
|
|
376
|
+
const decision = await untilAborted(signal, () => onProgressiveAsset(candidate, { signal, prepare }));
|
|
377
|
+
if (!decision || !['embedded', 'progressive'].includes(decision.delivery)) {
|
|
378
|
+
throw new Error('Invalid Progressive Asset delivery decision');
|
|
379
|
+
}
|
|
380
|
+
if (plan)
|
|
381
|
+
await plan;
|
|
382
|
+
decisions[id] = structuredClone(decision);
|
|
383
|
+
}
|
|
384
|
+
finally {
|
|
385
|
+
active = false;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
signal.throwIfAborted();
|
|
390
|
+
return await session.finalize(decisions, buildId, engine, optimize, agentId);
|
|
391
|
+
}
|
|
392
|
+
finally {
|
|
393
|
+
session.close();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function untilAborted(signal, work) {
|
|
397
|
+
return new Promise((resolve, reject) => {
|
|
398
|
+
if (signal.aborted) {
|
|
399
|
+
reject(signal.reason);
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
const onAbort = () => reject(signal.reason);
|
|
403
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
404
|
+
Promise.resolve().then(() => {
|
|
405
|
+
signal.throwIfAborted();
|
|
406
|
+
return work();
|
|
407
|
+
}).then(resolve, reject).finally(() => signal.removeEventListener('abort', onAbort));
|
|
408
|
+
});
|
|
409
|
+
}
|
package/jsr.json
CHANGED
package/package.json
CHANGED
package/pkg/README.md
CHANGED
|
@@ -323,8 +323,8 @@ const widgets = aix.getWidgets('en-US');
|
|
|
323
323
|
|
|
324
324
|
Returns `{ pages, tools, diagnostics }` synchronously. Missing/unreadable resources,
|
|
325
325
|
UTF-8 errors, and malformed page metadata produce `{ path, message }` diagnostics,
|
|
326
|
-
one per failed page.
|
|
327
|
-
pages
|
|
326
|
+
one per failed page. Both result lists put the default page first when it resolves
|
|
327
|
+
and keep the other pages in declaration order. A valid empty page list has no diagnostics;
|
|
328
328
|
invalid/unreadable `app.json.pages` produces an `app.json` diagnostic.
|
|
329
329
|
|
|
330
330
|
```typescript
|
|
@@ -352,7 +352,7 @@ Exported `MetadataResolution` has `pages: PageInfo[]`, `tools: Tool[]`, and
|
|
|
352
352
|
string fields.
|
|
353
353
|
|
|
354
354
|
#### `getTools(): Tool[]`
|
|
355
|
-
Generates
|
|
355
|
+
Generates OpenAI-compatible tools with `_blank` or `_current`. Pages can declare `target` in page JSON or `<script def>` and use `_inline` as an alias for `_current`. A valid `entryPagePath` or an explicit page target places the default page first with `_blank`. When both fields are omitted, only a first page without parameters is inferred as `_blank`.
|
|
356
356
|
```typescript
|
|
357
357
|
const tools = aix.getTools();
|
|
358
358
|
/*
|
|
@@ -361,7 +361,7 @@ const tools = aix.getTools();
|
|
|
361
361
|
target: "_blank",
|
|
362
362
|
layout: { width: 480, height: 168 },
|
|
363
363
|
function: {
|
|
364
|
-
name: "
|
|
364
|
+
name: "pages/index/index",
|
|
365
365
|
description: "Home",
|
|
366
366
|
parameters: { ... }
|
|
367
367
|
}
|
|
@@ -453,3 +453,64 @@ The output will be generated in the `dist` directory, including WASM binaries an
|
|
|
453
453
|
## License
|
|
454
454
|
|
|
455
455
|
MIT
|
|
456
|
+
|
|
457
|
+
## Progressive Assets
|
|
458
|
+
|
|
459
|
+
Declare the asset in an ESM module or Ink script.
|
|
460
|
+
|
|
461
|
+
```js
|
|
462
|
+
import video from './assets/clip.mp4' with {
|
|
463
|
+
type: 'video',
|
|
464
|
+
progressive: 'prefer',
|
|
465
|
+
};
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
The imported value is an opaque `AssetRef`. Pass it to Ink's video or audio consumer. The CLI and Web SDK embed complete assets by default. A Web
|
|
469
|
+
pack caller can choose remote delivery after it stores all prepared objects.
|
|
470
|
+
|
|
471
|
+
```ts
|
|
472
|
+
const packed = await AIX.packFromSource(files, {
|
|
473
|
+
signal: controller.signal,
|
|
474
|
+
async onProgressiveAsset(candidate, context) {
|
|
475
|
+
if (!candidate.progressiveSupport.supported || !shouldUpload(candidate)) {
|
|
476
|
+
return { delivery: 'embedded' };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const plan = await context.prepare();
|
|
480
|
+
const receipt = await uploadVerifiedObjects(plan.remoteObjects, {
|
|
481
|
+
assetVersion: plan.assetVersion,
|
|
482
|
+
signal: context.signal,
|
|
483
|
+
});
|
|
484
|
+
return { delivery: 'progressive', planId: plan.id, receipt };
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
The caller owns upload policy, credentials, and cleanup of uploads left
|
|
490
|
+
unreferenced by a failed pack. Return a receipt only after durable storage has
|
|
491
|
+
verified every object. Receipt URLs must be final, immutable HTTPS locators
|
|
492
|
+
without credentials, query strings, or fragments. A rejected callback, invalid
|
|
493
|
+
receipt, or abort fails the pack. `packed.progressiveAssets` reports the
|
|
494
|
+
selected delivery mode and any source bytes retained for ordinary imports.
|
|
495
|
+
|
|
496
|
+
The media profile accepts ordinary MP4/M4A and prepared fMP4 with
|
|
497
|
+
finite H.264 video, AAC-LC audio, or both. The packer copies encoded samples
|
|
498
|
+
into keyframe-aligned fragments and preserves a single continuous rate-one
|
|
499
|
+
edit per track. Incompatible codecs or timelines can be converted upstream
|
|
500
|
+
or embedded. The Ink runtime must support the selected profile.
|
|
501
|
+
|
|
502
|
+
The browser integration test runs a local HTTPS Studio stand-in. It receives
|
|
503
|
+
object bytes over HTTP PUT, verifies length and SHA-256 on disk, and issues
|
|
504
|
+
receipts only after the entire inventory is present. Set `INK_WEB_DIST` to a
|
|
505
|
+
built Ink Web SDK to also test browser playback and offline reopening through the same object server.
|
|
506
|
+
|
|
507
|
+
In [Play's Build view](https://yodaos-project.github.io/aix/play?mode=build),
|
|
508
|
+
select a project directory and choose **Build and download**. Play calls
|
|
509
|
+
`onProgressiveAsset` for each declared asset and simulates the upload for
|
|
510
|
+
supported media. The downloaded package contains placeholder URLs you can
|
|
511
|
+
view in Inspect.
|
|
512
|
+
|
|
513
|
+
```sh
|
|
514
|
+
npm run build
|
|
515
|
+
AIX_TEST_BROWSER_CHANNEL=chrome node scripts/test-progressive.js
|
|
516
|
+
```
|
package/pkg/aix_web.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export class AixPackResultWasm {
|
|
|
6
6
|
free(): void;
|
|
7
7
|
[Symbol.dispose](): void;
|
|
8
8
|
readonly data: Uint8Array;
|
|
9
|
+
readonly progressiveAssets: any;
|
|
9
10
|
readonly report: any;
|
|
10
11
|
readonly warnings: any;
|
|
11
12
|
}
|
|
@@ -45,6 +46,19 @@ export class AixSourcePackBuilderWasm {
|
|
|
45
46
|
pack_from_source_with_progress(build_id: string, engine: string | null | undefined, optimize_options: any, progress: Function, agent_id?: string | null): AixPackResultWasm;
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Uploads are performed outside this session. Only validated receipts and
|
|
51
|
+
* choices cross back into the Rust packer.
|
|
52
|
+
*/
|
|
53
|
+
export class ProgressivePackWasm {
|
|
54
|
+
free(): void;
|
|
55
|
+
[Symbol.dispose](): void;
|
|
56
|
+
candidates(): any;
|
|
57
|
+
finalize(decisions: any, build_id: string, engine: string | null | undefined, optimize_options: any, agent_id?: string | null, progress?: Function | null): AixPackResultWasm;
|
|
58
|
+
constructor(files: any, from_source: boolean);
|
|
59
|
+
prepare(id: string): any;
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
/**
|
|
49
63
|
* Check source files using the same collection rules as the pack command.
|
|
50
64
|
*/
|
|
@@ -72,9 +86,25 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
72
86
|
|
|
73
87
|
export interface InitOutput {
|
|
74
88
|
readonly memory: WebAssembly.Memory;
|
|
89
|
+
readonly __wbg_aixreaderwasm_free: (a: number, b: number) => void;
|
|
90
|
+
readonly aixreaderwasm_get_agent_id: (a: number) => [number, number, number, number];
|
|
91
|
+
readonly aixreaderwasm_get_pages: (a: number) => [number, number, number];
|
|
92
|
+
readonly aixreaderwasm_get_permissions: (a: number) => [number, number, number];
|
|
93
|
+
readonly aixreaderwasm_get_title: (a: number) => [number, number];
|
|
94
|
+
readonly aixreaderwasm_get_tools: (a: number) => [number, number, number];
|
|
95
|
+
readonly aixreaderwasm_get_version: (a: number) => [number, number];
|
|
96
|
+
readonly aixreaderwasm_get_widgets: (a: number, b: number, c: number) => [number, number, number];
|
|
97
|
+
readonly aixreaderwasm_list: (a: number) => [number, number, number];
|
|
98
|
+
readonly aixreaderwasm_new: (a: number, b: number) => [number, number, number];
|
|
99
|
+
readonly aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
|
|
100
|
+
readonly aixreaderwasm_resolve_metadata: (a: number) => [number, number, number];
|
|
101
|
+
readonly aixreaderwasm_supports_engine: (a: number, b: number, c: number) => [number, number, number];
|
|
102
|
+
readonly aixreaderwasm_with_limits: (a: number, b: number, c: any) => [number, number, number];
|
|
75
103
|
readonly __wbg_aixpackresultwasm_free: (a: number, b: number) => void;
|
|
76
104
|
readonly __wbg_aixsourcepackbuilderwasm_free: (a: number, b: number) => void;
|
|
105
|
+
readonly __wbg_progressivepackwasm_free: (a: number, b: number) => void;
|
|
77
106
|
readonly aixpackresultwasm_data: (a: number) => any;
|
|
107
|
+
readonly aixpackresultwasm_progressiveAssets: (a: number) => [number, number, number];
|
|
78
108
|
readonly aixpackresultwasm_report: (a: number) => [number, number, number];
|
|
79
109
|
readonly aixpackresultwasm_warnings: (a: number) => [number, number, number];
|
|
80
110
|
readonly aixsourcepackbuilderwasm_add_file: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
@@ -87,20 +117,10 @@ export interface InitOutput {
|
|
|
87
117
|
readonly pack_aix_from_source: (a: any, b: number, c: number, d: number, e: number, f: any, g: number, h: number) => [number, number, number];
|
|
88
118
|
readonly pack_aix_from_source_with_progress: (a: any, b: number, c: number, d: number, e: number, f: any, g: any, h: number, i: number) => [number, number, number];
|
|
89
119
|
readonly prepare_aix_check: (a: any) => [number, number, number];
|
|
90
|
-
readonly
|
|
91
|
-
readonly
|
|
92
|
-
readonly
|
|
93
|
-
readonly
|
|
94
|
-
readonly aixreaderwasm_get_title: (a: number) => [number, number];
|
|
95
|
-
readonly aixreaderwasm_get_tools: (a: number) => [number, number, number];
|
|
96
|
-
readonly aixreaderwasm_get_version: (a: number) => [number, number];
|
|
97
|
-
readonly aixreaderwasm_get_widgets: (a: number, b: number, c: number) => [number, number, number];
|
|
98
|
-
readonly aixreaderwasm_list: (a: number) => [number, number, number];
|
|
99
|
-
readonly aixreaderwasm_new: (a: number, b: number) => [number, number, number];
|
|
100
|
-
readonly aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
|
|
101
|
-
readonly aixreaderwasm_resolve_metadata: (a: number) => [number, number, number];
|
|
102
|
-
readonly aixreaderwasm_supports_engine: (a: number, b: number, c: number) => [number, number, number];
|
|
103
|
-
readonly aixreaderwasm_with_limits: (a: number, b: number, c: any) => [number, number, number];
|
|
120
|
+
readonly progressivepackwasm_candidates: (a: number) => [number, number, number];
|
|
121
|
+
readonly progressivepackwasm_finalize: (a: number, b: any, c: number, d: number, e: number, f: number, g: any, h: number, i: number, j: number) => [number, number, number];
|
|
122
|
+
readonly progressivepackwasm_new: (a: any, b: number) => [number, number, number];
|
|
123
|
+
readonly progressivepackwasm_prepare: (a: number, b: number, c: number) => [number, number, number];
|
|
104
124
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
105
125
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
106
126
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/pkg/aix_web.js
CHANGED
|
@@ -24,6 +24,16 @@ export class AixPackResultWasm {
|
|
|
24
24
|
const ret = wasm.aixpackresultwasm_data(this.__wbg_ptr);
|
|
25
25
|
return ret;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* @returns {any}
|
|
29
|
+
*/
|
|
30
|
+
get progressiveAssets() {
|
|
31
|
+
const ret = wasm.aixpackresultwasm_progressiveAssets(this.__wbg_ptr);
|
|
32
|
+
if (ret[2]) {
|
|
33
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
34
|
+
}
|
|
35
|
+
return takeFromExternrefTable0(ret[0]);
|
|
36
|
+
}
|
|
27
37
|
/**
|
|
28
38
|
* @returns {any}
|
|
29
39
|
*/
|
|
@@ -280,6 +290,82 @@ export class AixSourcePackBuilderWasm {
|
|
|
280
290
|
}
|
|
281
291
|
if (Symbol.dispose) AixSourcePackBuilderWasm.prototype[Symbol.dispose] = AixSourcePackBuilderWasm.prototype.free;
|
|
282
292
|
|
|
293
|
+
/**
|
|
294
|
+
* Uploads are performed outside this session. Only validated receipts and
|
|
295
|
+
* choices cross back into the Rust packer.
|
|
296
|
+
*/
|
|
297
|
+
export class ProgressivePackWasm {
|
|
298
|
+
__destroy_into_raw() {
|
|
299
|
+
const ptr = this.__wbg_ptr;
|
|
300
|
+
this.__wbg_ptr = 0;
|
|
301
|
+
ProgressivePackWasmFinalization.unregister(this);
|
|
302
|
+
return ptr;
|
|
303
|
+
}
|
|
304
|
+
free() {
|
|
305
|
+
const ptr = this.__destroy_into_raw();
|
|
306
|
+
wasm.__wbg_progressivepackwasm_free(ptr, 0);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* @returns {any}
|
|
310
|
+
*/
|
|
311
|
+
candidates() {
|
|
312
|
+
const ret = wasm.progressivepackwasm_candidates(this.__wbg_ptr);
|
|
313
|
+
if (ret[2]) {
|
|
314
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
315
|
+
}
|
|
316
|
+
return takeFromExternrefTable0(ret[0]);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @param {any} decisions
|
|
320
|
+
* @param {string} build_id
|
|
321
|
+
* @param {string | null | undefined} engine
|
|
322
|
+
* @param {any} optimize_options
|
|
323
|
+
* @param {string | null} [agent_id]
|
|
324
|
+
* @param {Function | null} [progress]
|
|
325
|
+
* @returns {AixPackResultWasm}
|
|
326
|
+
*/
|
|
327
|
+
finalize(decisions, build_id, engine, optimize_options, agent_id, progress) {
|
|
328
|
+
const ptr0 = passStringToWasm0(build_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
329
|
+
const len0 = WASM_VECTOR_LEN;
|
|
330
|
+
var ptr1 = isLikeNone(engine) ? 0 : passStringToWasm0(engine, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
331
|
+
var len1 = WASM_VECTOR_LEN;
|
|
332
|
+
var ptr2 = isLikeNone(agent_id) ? 0 : passStringToWasm0(agent_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
333
|
+
var len2 = WASM_VECTOR_LEN;
|
|
334
|
+
const ret = wasm.progressivepackwasm_finalize(this.__wbg_ptr, decisions, ptr0, len0, ptr1, len1, optimize_options, ptr2, len2, isLikeNone(progress) ? 0 : addToExternrefTable0(progress));
|
|
335
|
+
if (ret[2]) {
|
|
336
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
337
|
+
}
|
|
338
|
+
return AixPackResultWasm.__wrap(ret[0]);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* @param {any} files
|
|
342
|
+
* @param {boolean} from_source
|
|
343
|
+
*/
|
|
344
|
+
constructor(files, from_source) {
|
|
345
|
+
const ret = wasm.progressivepackwasm_new(files, from_source);
|
|
346
|
+
if (ret[2]) {
|
|
347
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
348
|
+
}
|
|
349
|
+
this.__wbg_ptr = ret[0];
|
|
350
|
+
ProgressivePackWasmFinalization.register(this, this.__wbg_ptr, this);
|
|
351
|
+
return this;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* @param {string} id
|
|
355
|
+
* @returns {any}
|
|
356
|
+
*/
|
|
357
|
+
prepare(id) {
|
|
358
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
359
|
+
const len0 = WASM_VECTOR_LEN;
|
|
360
|
+
const ret = wasm.progressivepackwasm_prepare(this.__wbg_ptr, ptr0, len0);
|
|
361
|
+
if (ret[2]) {
|
|
362
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
363
|
+
}
|
|
364
|
+
return takeFromExternrefTable0(ret[0]);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (Symbol.dispose) ProgressivePackWasm.prototype[Symbol.dispose] = ProgressivePackWasm.prototype.free;
|
|
368
|
+
|
|
283
369
|
/**
|
|
284
370
|
* Check source files using the same collection rules as the pack command.
|
|
285
371
|
* @param {any} files
|
|
@@ -502,9 +588,21 @@ function __wbg_get_imports() {
|
|
|
502
588
|
const ret = arg0.done;
|
|
503
589
|
return ret;
|
|
504
590
|
},
|
|
591
|
+
__wbg_entries_015dc610cd81ede0: function(arg0) {
|
|
592
|
+
const ret = Object.entries(arg0);
|
|
593
|
+
return ret;
|
|
594
|
+
},
|
|
595
|
+
__wbg_from_13e323c65fc8f464: function(arg0) {
|
|
596
|
+
const ret = Array.from(arg0);
|
|
597
|
+
return ret;
|
|
598
|
+
},
|
|
505
599
|
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
506
600
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
507
601
|
}, arguments); },
|
|
602
|
+
__wbg_get_507a50627bffa49b: function(arg0, arg1) {
|
|
603
|
+
const ret = arg0[arg1 >>> 0];
|
|
604
|
+
return ret;
|
|
605
|
+
},
|
|
508
606
|
__wbg_get_c7eb1f358a7654df: function() { return handleError(function (arg0, arg1) {
|
|
509
607
|
const ret = Reflect.get(arg0, arg1);
|
|
510
608
|
return ret;
|
|
@@ -527,6 +625,16 @@ function __wbg_get_imports() {
|
|
|
527
625
|
const ret = result;
|
|
528
626
|
return ret;
|
|
529
627
|
},
|
|
628
|
+
__wbg_instanceof_Map_e5b5e3db98422fcc: function(arg0) {
|
|
629
|
+
let result;
|
|
630
|
+
try {
|
|
631
|
+
result = arg0 instanceof Map;
|
|
632
|
+
} catch (_) {
|
|
633
|
+
result = false;
|
|
634
|
+
}
|
|
635
|
+
const ret = result;
|
|
636
|
+
return ret;
|
|
637
|
+
},
|
|
530
638
|
__wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
|
|
531
639
|
let result;
|
|
532
640
|
try {
|
|
@@ -606,7 +714,7 @@ function __wbg_get_imports() {
|
|
|
606
714
|
const ret = arg0.value;
|
|
607
715
|
return ret;
|
|
608
716
|
},
|
|
609
|
-
|
|
717
|
+
__wbg_warn_c0128de590daf5c5: function(arg0, arg1) {
|
|
610
718
|
console.warn(getStringFromWasm0(arg0, arg1));
|
|
611
719
|
},
|
|
612
720
|
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
@@ -620,11 +728,16 @@ function __wbg_get_imports() {
|
|
|
620
728
|
return ret;
|
|
621
729
|
},
|
|
622
730
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
731
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
732
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
733
|
+
return ret;
|
|
734
|
+
},
|
|
735
|
+
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
623
736
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
624
737
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
625
738
|
return ret;
|
|
626
739
|
},
|
|
627
|
-
|
|
740
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
628
741
|
// Cast intrinsic for `U64 -> Externref`.
|
|
629
742
|
const ret = BigInt.asUintN(64, arg0);
|
|
630
743
|
return ret;
|
|
@@ -654,6 +767,9 @@ const AixReaderWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
654
767
|
const AixSourcePackBuilderWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
655
768
|
? { register: () => {}, unregister: () => {} }
|
|
656
769
|
: new FinalizationRegistry(ptr => wasm.__wbg_aixsourcepackbuilderwasm_free(ptr, 1));
|
|
770
|
+
const ProgressivePackWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
771
|
+
? { register: () => {}, unregister: () => {} }
|
|
772
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_progressivepackwasm_free(ptr, 1));
|
|
657
773
|
|
|
658
774
|
function addToExternrefTable0(obj) {
|
|
659
775
|
const idx = wasm.__externref_table_alloc();
|
package/pkg/aix_web_bg.wasm
CHANGED
|
Binary file
|
package/pkg/aix_web_bg.wasm.d.ts
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_aixreaderwasm_free: (a: number, b: number) => void;
|
|
5
|
+
export const aixreaderwasm_get_agent_id: (a: number) => [number, number, number, number];
|
|
6
|
+
export const aixreaderwasm_get_pages: (a: number) => [number, number, number];
|
|
7
|
+
export const aixreaderwasm_get_permissions: (a: number) => [number, number, number];
|
|
8
|
+
export const aixreaderwasm_get_title: (a: number) => [number, number];
|
|
9
|
+
export const aixreaderwasm_get_tools: (a: number) => [number, number, number];
|
|
10
|
+
export const aixreaderwasm_get_version: (a: number) => [number, number];
|
|
11
|
+
export const aixreaderwasm_get_widgets: (a: number, b: number, c: number) => [number, number, number];
|
|
12
|
+
export const aixreaderwasm_list: (a: number) => [number, number, number];
|
|
13
|
+
export const aixreaderwasm_new: (a: number, b: number) => [number, number, number];
|
|
14
|
+
export const aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
|
|
15
|
+
export const aixreaderwasm_resolve_metadata: (a: number) => [number, number, number];
|
|
16
|
+
export const aixreaderwasm_supports_engine: (a: number, b: number, c: number) => [number, number, number];
|
|
17
|
+
export const aixreaderwasm_with_limits: (a: number, b: number, c: any) => [number, number, number];
|
|
4
18
|
export const __wbg_aixpackresultwasm_free: (a: number, b: number) => void;
|
|
5
19
|
export const __wbg_aixsourcepackbuilderwasm_free: (a: number, b: number) => void;
|
|
20
|
+
export const __wbg_progressivepackwasm_free: (a: number, b: number) => void;
|
|
6
21
|
export const aixpackresultwasm_data: (a: number) => any;
|
|
22
|
+
export const aixpackresultwasm_progressiveAssets: (a: number) => [number, number, number];
|
|
7
23
|
export const aixpackresultwasm_report: (a: number) => [number, number, number];
|
|
8
24
|
export const aixpackresultwasm_warnings: (a: number) => [number, number, number];
|
|
9
25
|
export const aixsourcepackbuilderwasm_add_file: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
@@ -16,20 +32,10 @@ export const pack_aix: (a: any, b: number, c: number, d: number, e: number, f: a
|
|
|
16
32
|
export const pack_aix_from_source: (a: any, b: number, c: number, d: number, e: number, f: any, g: number, h: number) => [number, number, number];
|
|
17
33
|
export const pack_aix_from_source_with_progress: (a: any, b: number, c: number, d: number, e: number, f: any, g: any, h: number, i: number) => [number, number, number];
|
|
18
34
|
export const prepare_aix_check: (a: any) => [number, number, number];
|
|
19
|
-
export const
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
22
|
-
export const
|
|
23
|
-
export const aixreaderwasm_get_title: (a: number) => [number, number];
|
|
24
|
-
export const aixreaderwasm_get_tools: (a: number) => [number, number, number];
|
|
25
|
-
export const aixreaderwasm_get_version: (a: number) => [number, number];
|
|
26
|
-
export const aixreaderwasm_get_widgets: (a: number, b: number, c: number) => [number, number, number];
|
|
27
|
-
export const aixreaderwasm_list: (a: number) => [number, number, number];
|
|
28
|
-
export const aixreaderwasm_new: (a: number, b: number) => [number, number, number];
|
|
29
|
-
export const aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
|
|
30
|
-
export const aixreaderwasm_resolve_metadata: (a: number) => [number, number, number];
|
|
31
|
-
export const aixreaderwasm_supports_engine: (a: number, b: number, c: number) => [number, number, number];
|
|
32
|
-
export const aixreaderwasm_with_limits: (a: number, b: number, c: any) => [number, number, number];
|
|
35
|
+
export const progressivepackwasm_candidates: (a: number) => [number, number, number];
|
|
36
|
+
export const progressivepackwasm_finalize: (a: number, b: any, c: number, d: number, e: number, f: number, g: any, h: number, i: number, j: number) => [number, number, number];
|
|
37
|
+
export const progressivepackwasm_new: (a: any, b: number) => [number, number, number];
|
|
38
|
+
export const progressivepackwasm_prepare: (a: number, b: number, c: number) => [number, number, number];
|
|
33
39
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
34
40
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
35
41
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/pkg/package.json
CHANGED
package/pkg-reader/README.md
CHANGED
|
@@ -323,8 +323,8 @@ const widgets = aix.getWidgets('en-US');
|
|
|
323
323
|
|
|
324
324
|
Returns `{ pages, tools, diagnostics }` synchronously. Missing/unreadable resources,
|
|
325
325
|
UTF-8 errors, and malformed page metadata produce `{ path, message }` diagnostics,
|
|
326
|
-
one per failed page.
|
|
327
|
-
pages
|
|
326
|
+
one per failed page. Both result lists put the default page first when it resolves
|
|
327
|
+
and keep the other pages in declaration order. A valid empty page list has no diagnostics;
|
|
328
328
|
invalid/unreadable `app.json.pages` produces an `app.json` diagnostic.
|
|
329
329
|
|
|
330
330
|
```typescript
|
|
@@ -352,7 +352,7 @@ Exported `MetadataResolution` has `pages: PageInfo[]`, `tools: Tool[]`, and
|
|
|
352
352
|
string fields.
|
|
353
353
|
|
|
354
354
|
#### `getTools(): Tool[]`
|
|
355
|
-
Generates
|
|
355
|
+
Generates OpenAI-compatible tools with `_blank` or `_current`. Pages can declare `target` in page JSON or `<script def>` and use `_inline` as an alias for `_current`. A valid `entryPagePath` or an explicit page target places the default page first with `_blank`. When both fields are omitted, only a first page without parameters is inferred as `_blank`.
|
|
356
356
|
```typescript
|
|
357
357
|
const tools = aix.getTools();
|
|
358
358
|
/*
|
|
@@ -361,7 +361,7 @@ const tools = aix.getTools();
|
|
|
361
361
|
target: "_blank",
|
|
362
362
|
layout: { width: 480, height: 168 },
|
|
363
363
|
function: {
|
|
364
|
-
name: "
|
|
364
|
+
name: "pages/index/index",
|
|
365
365
|
description: "Home",
|
|
366
366
|
parameters: { ... }
|
|
367
367
|
}
|
|
@@ -453,3 +453,64 @@ The output will be generated in the `dist` directory, including WASM binaries an
|
|
|
453
453
|
## License
|
|
454
454
|
|
|
455
455
|
MIT
|
|
456
|
+
|
|
457
|
+
## Progressive Assets
|
|
458
|
+
|
|
459
|
+
Declare the asset in an ESM module or Ink script.
|
|
460
|
+
|
|
461
|
+
```js
|
|
462
|
+
import video from './assets/clip.mp4' with {
|
|
463
|
+
type: 'video',
|
|
464
|
+
progressive: 'prefer',
|
|
465
|
+
};
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
The imported value is an opaque `AssetRef`. Pass it to Ink's video or audio consumer. The CLI and Web SDK embed complete assets by default. A Web
|
|
469
|
+
pack caller can choose remote delivery after it stores all prepared objects.
|
|
470
|
+
|
|
471
|
+
```ts
|
|
472
|
+
const packed = await AIX.packFromSource(files, {
|
|
473
|
+
signal: controller.signal,
|
|
474
|
+
async onProgressiveAsset(candidate, context) {
|
|
475
|
+
if (!candidate.progressiveSupport.supported || !shouldUpload(candidate)) {
|
|
476
|
+
return { delivery: 'embedded' };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const plan = await context.prepare();
|
|
480
|
+
const receipt = await uploadVerifiedObjects(plan.remoteObjects, {
|
|
481
|
+
assetVersion: plan.assetVersion,
|
|
482
|
+
signal: context.signal,
|
|
483
|
+
});
|
|
484
|
+
return { delivery: 'progressive', planId: plan.id, receipt };
|
|
485
|
+
},
|
|
486
|
+
});
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
The caller owns upload policy, credentials, and cleanup of uploads left
|
|
490
|
+
unreferenced by a failed pack. Return a receipt only after durable storage has
|
|
491
|
+
verified every object. Receipt URLs must be final, immutable HTTPS locators
|
|
492
|
+
without credentials, query strings, or fragments. A rejected callback, invalid
|
|
493
|
+
receipt, or abort fails the pack. `packed.progressiveAssets` reports the
|
|
494
|
+
selected delivery mode and any source bytes retained for ordinary imports.
|
|
495
|
+
|
|
496
|
+
The media profile accepts ordinary MP4/M4A and prepared fMP4 with
|
|
497
|
+
finite H.264 video, AAC-LC audio, or both. The packer copies encoded samples
|
|
498
|
+
into keyframe-aligned fragments and preserves a single continuous rate-one
|
|
499
|
+
edit per track. Incompatible codecs or timelines can be converted upstream
|
|
500
|
+
or embedded. The Ink runtime must support the selected profile.
|
|
501
|
+
|
|
502
|
+
The browser integration test runs a local HTTPS Studio stand-in. It receives
|
|
503
|
+
object bytes over HTTP PUT, verifies length and SHA-256 on disk, and issues
|
|
504
|
+
receipts only after the entire inventory is present. Set `INK_WEB_DIST` to a
|
|
505
|
+
built Ink Web SDK to also test browser playback and offline reopening through the same object server.
|
|
506
|
+
|
|
507
|
+
In [Play's Build view](https://yodaos-project.github.io/aix/play?mode=build),
|
|
508
|
+
select a project directory and choose **Build and download**. Play calls
|
|
509
|
+
`onProgressiveAsset` for each declared asset and simulates the upload for
|
|
510
|
+
supported media. The downloaded package contains placeholder URLs you can
|
|
511
|
+
view in Inspect.
|
|
512
|
+
|
|
513
|
+
```sh
|
|
514
|
+
npm run build
|
|
515
|
+
AIX_TEST_BROWSER_CHANNEL=chrome node scripts/test-progressive.js
|
|
516
|
+
```
|
package/pkg-reader/aix_web.js
CHANGED
|
@@ -343,7 +343,7 @@ function __wbg_get_imports() {
|
|
|
343
343
|
__wbg_set_8a16b38e4805b298: function(arg0, arg1, arg2) {
|
|
344
344
|
arg0[arg1 >>> 0] = arg2;
|
|
345
345
|
},
|
|
346
|
-
|
|
346
|
+
__wbg_warn_c0128de590daf5c5: function(arg0, arg1) {
|
|
347
347
|
console.warn(getStringFromWasm0(arg0, arg1));
|
|
348
348
|
},
|
|
349
349
|
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
Binary file
|
package/pkg-reader/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs one staged AIX pack session in a browser worker. Moving scanning,
|
|
3
|
+
* media remuxing, and packaging off the main thread keeps the page responsive.
|
|
4
|
+
*
|
|
5
|
+
* `open` starts the WASM session and reports candidates. `prepare` returns the
|
|
6
|
+
* upload plan and transfers its media fragments to the SDK. The caller's
|
|
7
|
+
* `onProgressiveAsset` callback handles uploads and returns a delivery decision
|
|
8
|
+
* with a receipt for remote assets. `finalize` passes those decisions to WASM
|
|
9
|
+
* to validate receipts and build the .aix archive.
|
|
10
|
+
*/
|
|
11
|
+
import init, { ProgressivePackWasm } from '../pkg/aix_web.js';
|
|
12
|
+
const port = globalThis;
|
|
13
|
+
let session;
|
|
14
|
+
port.onmessage = async ({ data }) => {
|
|
15
|
+
try {
|
|
16
|
+
switch (data.type) {
|
|
17
|
+
case 'open': {
|
|
18
|
+
await init();
|
|
19
|
+
session = new ProgressivePackWasm(data.files, data.fromSource);
|
|
20
|
+
port.postMessage({ result: session.candidates() });
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
case 'prepare': {
|
|
24
|
+
if (!session)
|
|
25
|
+
throw new Error('Progressive Asset session is closed');
|
|
26
|
+
const plan = session.prepare(data.id);
|
|
27
|
+
port.postMessage({ result: plan }, plan.remoteObjects.map((object) => object.bytes.buffer));
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case 'finalize': {
|
|
31
|
+
if (!session)
|
|
32
|
+
throw new Error('Progressive Asset session is closed');
|
|
33
|
+
const packed = session.finalize(data.decisions, data.buildId, data.engine, data.optimize, data.agentId, (progress) => port.postMessage({ progress }));
|
|
34
|
+
try {
|
|
35
|
+
const bytes = packed.data;
|
|
36
|
+
port.postMessage({
|
|
37
|
+
result: {
|
|
38
|
+
data: bytes,
|
|
39
|
+
report: packed.report,
|
|
40
|
+
warnings: packed.warnings,
|
|
41
|
+
progressiveAssets: packed.progressiveAssets,
|
|
42
|
+
},
|
|
43
|
+
}, [bytes.buffer]);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
packed.free();
|
|
47
|
+
session.free();
|
|
48
|
+
session = undefined;
|
|
49
|
+
}
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
port.postMessage({ error: String(error) });
|
|
56
|
+
}
|
|
57
|
+
};
|