@yodaos-pkg/aix 0.11.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 +110 -6
- package/index.d.ts +103 -2
- package/index.js +212 -5
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/pkg/README.md +110 -6
- package/pkg/aix_web.d.ts +35 -13
- package/pkg/aix_web.js +128 -2
- package/pkg/aix_web_bg.wasm +0 -0
- package/pkg/aix_web_bg.wasm.d.ts +20 -13
- package/pkg/package.json +1 -1
- package/pkg-reader/README.md +110 -6
- package/pkg-reader/aix_web.d.ts +2 -0
- package/pkg-reader/aix_web.js +11 -1
- package/pkg-reader/aix_web_bg.wasm +0 -0
- package/pkg-reader/aix_web_bg.wasm.d.ts +1 -0
- package/pkg-reader/package.json +1 -1
- package/workers/progressive-worker.d.ts +1 -0
- package/workers/progressive-worker.js +57 -0
package/pkg/README.md
CHANGED
|
@@ -32,8 +32,9 @@ async function fromFile(file: File) {
|
|
|
32
32
|
|
|
33
33
|
## WASM Loading
|
|
34
34
|
|
|
35
|
-
`AIX.From()` and all instance methods initialize a separate reader-only WASM.
|
|
35
|
+
By default, `AIX.From()` and all instance methods initialize a separate reader-only WASM.
|
|
36
36
|
They do not load image codecs, script minification, or source/schema checking.
|
|
37
|
+
The optional `AIX.From(data, limits, true)` check also loads the full tooling module.
|
|
37
38
|
The first pack, optimize, or source-check call lazily loads the full module;
|
|
38
39
|
concurrent tooling calls share initialization. Existing reader instances remain
|
|
39
40
|
valid after tooling loads, and tooling-only calls do not fetch reader WASM.
|
|
@@ -74,6 +75,35 @@ separate budgets. This policy applies to readers, not `AIX.optimize`.
|
|
|
74
75
|
Direct WASM consumers can call `AixReaderWasm.with_limits(data, limits)` using
|
|
75
76
|
the same fields. The existing `new AixReaderWasm(data)` constructor is unchanged.
|
|
76
77
|
|
|
78
|
+
## Open and Check
|
|
79
|
+
|
|
80
|
+
Pass `true` as the third `AIX.From` argument to run the source checker before
|
|
81
|
+
receiving the package. The second argument remains the optional read limits;
|
|
82
|
+
pass `undefined` there when no limits are needed.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { AIX, AixCheckError } from '@yodaos-pkg/aix';
|
|
86
|
+
|
|
87
|
+
async function openCheckedPackage(file: File) {
|
|
88
|
+
try {
|
|
89
|
+
return await AIX.From(file, undefined, true);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error instanceof AixCheckError) console.table(error.diagnostics);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Warnings alone pass. Error diagnostics reject with the exported `AixCheckError`
|
|
98
|
+
(`name: 'AixCheckError'`), an `Error` subclass with the complete `CheckReport` in
|
|
99
|
+
`report` and the same diagnostic array in `diagnostics`, including warnings.
|
|
100
|
+
The check uses `checkFromSource` on the package's source files without running
|
|
101
|
+
project code. It adds work and retains extracted check inputs; read limits still
|
|
102
|
+
apply but do not bound total checker memory. Archive, extraction, loading, and
|
|
103
|
+
collection failures retain their original operation errors rather than a check
|
|
104
|
+
report. Omitting the third argument or passing `false` preserves the existing
|
|
105
|
+
reader-only behavior.
|
|
106
|
+
|
|
77
107
|
## Check Source Files
|
|
78
108
|
|
|
79
109
|
The Web SDK and npm CLI use the same complete in-memory check engine:
|
|
@@ -218,8 +248,10 @@ files and wants to invoke the low-level packer directly.
|
|
|
218
248
|
|
|
219
249
|
The main class to interact with an AIX package.
|
|
220
250
|
|
|
221
|
-
#### `static async From(data: Uint8Array | File): Promise<AIX>`
|
|
251
|
+
#### `static async From(data: Uint8Array | File, limits?: AixReadLimits, check?: boolean): Promise<AIX>`
|
|
222
252
|
Initializes the WASM module and creates an AIX instance from the given `.aix` file content. It supports both `Uint8Array` and the standard Web `File` object.
|
|
253
|
+
`check` defaults to `false`. Set it to `true` to check before returning and reject
|
|
254
|
+
with `AixCheckError` when errors are reported; see [Open and Check](#open-and-check).
|
|
223
255
|
```typescript
|
|
224
256
|
// From Uint8Array
|
|
225
257
|
const aix = await AIX.From(new Uint8Array(buffer));
|
|
@@ -254,6 +286,17 @@ Extracts the navigation bar title from the `app.json`.
|
|
|
254
286
|
const title = aix.getTitle();
|
|
255
287
|
```
|
|
256
288
|
|
|
289
|
+
#### `getPermissions(): string[]`
|
|
290
|
+
Returns the permission names declared in `app.json.permissions`, preserving their
|
|
291
|
+
order, duplicates, and custom names. An omitted or empty list returns `[]`.
|
|
292
|
+
Throws if `app.json` is missing, unreadable, invalid, or `permissions` is not an
|
|
293
|
+
array of strings. This reads declarations without querying authorization or
|
|
294
|
+
prompting for access.
|
|
295
|
+
```typescript
|
|
296
|
+
const permissions = aix.getPermissions();
|
|
297
|
+
// e.g. ['GEOLOCATION', 'CAMERA']
|
|
298
|
+
```
|
|
299
|
+
|
|
257
300
|
#### `getPages(): PageInfo[]`
|
|
258
301
|
Returns information about all pages defined in the package, including their paths, titles, and data schemas.
|
|
259
302
|
```typescript
|
|
@@ -280,8 +323,8 @@ const widgets = aix.getWidgets('en-US');
|
|
|
280
323
|
|
|
281
324
|
Returns `{ pages, tools, diagnostics }` synchronously. Missing/unreadable resources,
|
|
282
325
|
UTF-8 errors, and malformed page metadata produce `{ path, message }` diagnostics,
|
|
283
|
-
one per failed page.
|
|
284
|
-
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;
|
|
285
328
|
invalid/unreadable `app.json.pages` produces an `app.json` diagnostic.
|
|
286
329
|
|
|
287
330
|
```typescript
|
|
@@ -309,7 +352,7 @@ Exported `MetadataResolution` has `pages: PageInfo[]`, `tools: Tool[]`, and
|
|
|
309
352
|
string fields.
|
|
310
353
|
|
|
311
354
|
#### `getTools(): Tool[]`
|
|
312
|
-
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`.
|
|
313
356
|
```typescript
|
|
314
357
|
const tools = aix.getTools();
|
|
315
358
|
/*
|
|
@@ -318,7 +361,7 @@ const tools = aix.getTools();
|
|
|
318
361
|
target: "_blank",
|
|
319
362
|
layout: { width: 480, height: 168 },
|
|
320
363
|
function: {
|
|
321
|
-
name: "
|
|
364
|
+
name: "pages/index/index",
|
|
322
365
|
description: "Home",
|
|
323
366
|
parameters: { ... }
|
|
324
367
|
}
|
|
@@ -410,3 +453,64 @@ The output will be generated in the `dist` directory, including WASM binaries an
|
|
|
410
453
|
## License
|
|
411
454
|
|
|
412
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
|
}
|
|
@@ -15,6 +16,7 @@ export class AixReaderWasm {
|
|
|
15
16
|
[Symbol.dispose](): void;
|
|
16
17
|
get_agent_id(): string | undefined;
|
|
17
18
|
get_pages(): any;
|
|
19
|
+
get_permissions(): any;
|
|
18
20
|
get_title(): string | undefined;
|
|
19
21
|
get_tools(): any;
|
|
20
22
|
get_version(): string | undefined;
|
|
@@ -44,6 +46,19 @@ export class AixSourcePackBuilderWasm {
|
|
|
44
46
|
pack_from_source_with_progress(build_id: string, engine: string | null | undefined, optimize_options: any, progress: Function, agent_id?: string | null): AixPackResultWasm;
|
|
45
47
|
}
|
|
46
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
|
+
|
|
47
62
|
/**
|
|
48
63
|
* Check source files using the same collection rules as the pack command.
|
|
49
64
|
*/
|
|
@@ -71,9 +86,25 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
71
86
|
|
|
72
87
|
export interface InitOutput {
|
|
73
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];
|
|
74
103
|
readonly __wbg_aixpackresultwasm_free: (a: number, b: number) => void;
|
|
75
104
|
readonly __wbg_aixsourcepackbuilderwasm_free: (a: number, b: number) => void;
|
|
105
|
+
readonly __wbg_progressivepackwasm_free: (a: number, b: number) => void;
|
|
76
106
|
readonly aixpackresultwasm_data: (a: number) => any;
|
|
107
|
+
readonly aixpackresultwasm_progressiveAssets: (a: number) => [number, number, number];
|
|
77
108
|
readonly aixpackresultwasm_report: (a: number) => [number, number, number];
|
|
78
109
|
readonly aixpackresultwasm_warnings: (a: number) => [number, number, number];
|
|
79
110
|
readonly aixsourcepackbuilderwasm_add_file: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
@@ -86,19 +117,10 @@ export interface InitOutput {
|
|
|
86
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];
|
|
87
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];
|
|
88
119
|
readonly prepare_aix_check: (a: any) => [number, number, number];
|
|
89
|
-
readonly
|
|
90
|
-
readonly
|
|
91
|
-
readonly
|
|
92
|
-
readonly
|
|
93
|
-
readonly aixreaderwasm_get_tools: (a: number) => [number, number, number];
|
|
94
|
-
readonly aixreaderwasm_get_version: (a: number) => [number, number];
|
|
95
|
-
readonly aixreaderwasm_get_widgets: (a: number, b: number, c: number) => [number, number, number];
|
|
96
|
-
readonly aixreaderwasm_list: (a: number) => [number, number, number];
|
|
97
|
-
readonly aixreaderwasm_new: (a: number, b: number) => [number, number, number];
|
|
98
|
-
readonly aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
|
|
99
|
-
readonly aixreaderwasm_resolve_metadata: (a: number) => [number, number, number];
|
|
100
|
-
readonly aixreaderwasm_supports_engine: (a: number, b: number, c: number) => [number, number, number];
|
|
101
|
-
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];
|
|
102
124
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
103
125
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
104
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
|
*/
|
|
@@ -89,6 +99,16 @@ export class AixReaderWasm {
|
|
|
89
99
|
}
|
|
90
100
|
return takeFromExternrefTable0(ret[0]);
|
|
91
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* @returns {any}
|
|
104
|
+
*/
|
|
105
|
+
get_permissions() {
|
|
106
|
+
const ret = wasm.aixreaderwasm_get_permissions(this.__wbg_ptr);
|
|
107
|
+
if (ret[2]) {
|
|
108
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
109
|
+
}
|
|
110
|
+
return takeFromExternrefTable0(ret[0]);
|
|
111
|
+
}
|
|
92
112
|
/**
|
|
93
113
|
* @returns {string | undefined}
|
|
94
114
|
*/
|
|
@@ -270,6 +290,82 @@ export class AixSourcePackBuilderWasm {
|
|
|
270
290
|
}
|
|
271
291
|
if (Symbol.dispose) AixSourcePackBuilderWasm.prototype[Symbol.dispose] = AixSourcePackBuilderWasm.prototype.free;
|
|
272
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
|
+
|
|
273
369
|
/**
|
|
274
370
|
* Check source files using the same collection rules as the pack command.
|
|
275
371
|
* @param {any} files
|
|
@@ -492,9 +588,21 @@ function __wbg_get_imports() {
|
|
|
492
588
|
const ret = arg0.done;
|
|
493
589
|
return ret;
|
|
494
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
|
+
},
|
|
495
599
|
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
496
600
|
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
497
601
|
}, arguments); },
|
|
602
|
+
__wbg_get_507a50627bffa49b: function(arg0, arg1) {
|
|
603
|
+
const ret = arg0[arg1 >>> 0];
|
|
604
|
+
return ret;
|
|
605
|
+
},
|
|
498
606
|
__wbg_get_c7eb1f358a7654df: function() { return handleError(function (arg0, arg1) {
|
|
499
607
|
const ret = Reflect.get(arg0, arg1);
|
|
500
608
|
return ret;
|
|
@@ -517,6 +625,16 @@ function __wbg_get_imports() {
|
|
|
517
625
|
const ret = result;
|
|
518
626
|
return ret;
|
|
519
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
|
+
},
|
|
520
638
|
__wbg_instanceof_Uint8Array_309b927aaf7a3fc7: function(arg0) {
|
|
521
639
|
let result;
|
|
522
640
|
try {
|
|
@@ -596,7 +714,7 @@ function __wbg_get_imports() {
|
|
|
596
714
|
const ret = arg0.value;
|
|
597
715
|
return ret;
|
|
598
716
|
},
|
|
599
|
-
|
|
717
|
+
__wbg_warn_c0128de590daf5c5: function(arg0, arg1) {
|
|
600
718
|
console.warn(getStringFromWasm0(arg0, arg1));
|
|
601
719
|
},
|
|
602
720
|
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
@@ -610,11 +728,16 @@ function __wbg_get_imports() {
|
|
|
610
728
|
return ret;
|
|
611
729
|
},
|
|
612
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) {
|
|
613
736
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
614
737
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
615
738
|
return ret;
|
|
616
739
|
},
|
|
617
|
-
|
|
740
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
618
741
|
// Cast intrinsic for `U64 -> Externref`.
|
|
619
742
|
const ret = BigInt.asUintN(64, arg0);
|
|
620
743
|
return ret;
|
|
@@ -644,6 +767,9 @@ const AixReaderWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
|
644
767
|
const AixSourcePackBuilderWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
645
768
|
? { register: () => {}, unregister: () => {} }
|
|
646
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));
|
|
647
773
|
|
|
648
774
|
function addToExternrefTable0(obj) {
|
|
649
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,19 +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_tools: (a: number) => [number, number, number];
|
|
24
|
-
export const aixreaderwasm_get_version: (a: number) => [number, number];
|
|
25
|
-
export const aixreaderwasm_get_widgets: (a: number, b: number, c: number) => [number, number, number];
|
|
26
|
-
export const aixreaderwasm_list: (a: number) => [number, number, number];
|
|
27
|
-
export const aixreaderwasm_new: (a: number, b: number) => [number, number, number];
|
|
28
|
-
export const aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
|
|
29
|
-
export const aixreaderwasm_resolve_metadata: (a: number) => [number, number, number];
|
|
30
|
-
export const aixreaderwasm_supports_engine: (a: number, b: number, c: number) => [number, number, number];
|
|
31
|
-
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];
|
|
32
39
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
33
40
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
41
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/pkg/package.json
CHANGED
package/pkg-reader/README.md
CHANGED
|
@@ -32,8 +32,9 @@ async function fromFile(file: File) {
|
|
|
32
32
|
|
|
33
33
|
## WASM Loading
|
|
34
34
|
|
|
35
|
-
`AIX.From()` and all instance methods initialize a separate reader-only WASM.
|
|
35
|
+
By default, `AIX.From()` and all instance methods initialize a separate reader-only WASM.
|
|
36
36
|
They do not load image codecs, script minification, or source/schema checking.
|
|
37
|
+
The optional `AIX.From(data, limits, true)` check also loads the full tooling module.
|
|
37
38
|
The first pack, optimize, or source-check call lazily loads the full module;
|
|
38
39
|
concurrent tooling calls share initialization. Existing reader instances remain
|
|
39
40
|
valid after tooling loads, and tooling-only calls do not fetch reader WASM.
|
|
@@ -74,6 +75,35 @@ separate budgets. This policy applies to readers, not `AIX.optimize`.
|
|
|
74
75
|
Direct WASM consumers can call `AixReaderWasm.with_limits(data, limits)` using
|
|
75
76
|
the same fields. The existing `new AixReaderWasm(data)` constructor is unchanged.
|
|
76
77
|
|
|
78
|
+
## Open and Check
|
|
79
|
+
|
|
80
|
+
Pass `true` as the third `AIX.From` argument to run the source checker before
|
|
81
|
+
receiving the package. The second argument remains the optional read limits;
|
|
82
|
+
pass `undefined` there when no limits are needed.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { AIX, AixCheckError } from '@yodaos-pkg/aix';
|
|
86
|
+
|
|
87
|
+
async function openCheckedPackage(file: File) {
|
|
88
|
+
try {
|
|
89
|
+
return await AIX.From(file, undefined, true);
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (error instanceof AixCheckError) console.table(error.diagnostics);
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Warnings alone pass. Error diagnostics reject with the exported `AixCheckError`
|
|
98
|
+
(`name: 'AixCheckError'`), an `Error` subclass with the complete `CheckReport` in
|
|
99
|
+
`report` and the same diagnostic array in `diagnostics`, including warnings.
|
|
100
|
+
The check uses `checkFromSource` on the package's source files without running
|
|
101
|
+
project code. It adds work and retains extracted check inputs; read limits still
|
|
102
|
+
apply but do not bound total checker memory. Archive, extraction, loading, and
|
|
103
|
+
collection failures retain their original operation errors rather than a check
|
|
104
|
+
report. Omitting the third argument or passing `false` preserves the existing
|
|
105
|
+
reader-only behavior.
|
|
106
|
+
|
|
77
107
|
## Check Source Files
|
|
78
108
|
|
|
79
109
|
The Web SDK and npm CLI use the same complete in-memory check engine:
|
|
@@ -218,8 +248,10 @@ files and wants to invoke the low-level packer directly.
|
|
|
218
248
|
|
|
219
249
|
The main class to interact with an AIX package.
|
|
220
250
|
|
|
221
|
-
#### `static async From(data: Uint8Array | File): Promise<AIX>`
|
|
251
|
+
#### `static async From(data: Uint8Array | File, limits?: AixReadLimits, check?: boolean): Promise<AIX>`
|
|
222
252
|
Initializes the WASM module and creates an AIX instance from the given `.aix` file content. It supports both `Uint8Array` and the standard Web `File` object.
|
|
253
|
+
`check` defaults to `false`. Set it to `true` to check before returning and reject
|
|
254
|
+
with `AixCheckError` when errors are reported; see [Open and Check](#open-and-check).
|
|
223
255
|
```typescript
|
|
224
256
|
// From Uint8Array
|
|
225
257
|
const aix = await AIX.From(new Uint8Array(buffer));
|
|
@@ -254,6 +286,17 @@ Extracts the navigation bar title from the `app.json`.
|
|
|
254
286
|
const title = aix.getTitle();
|
|
255
287
|
```
|
|
256
288
|
|
|
289
|
+
#### `getPermissions(): string[]`
|
|
290
|
+
Returns the permission names declared in `app.json.permissions`, preserving their
|
|
291
|
+
order, duplicates, and custom names. An omitted or empty list returns `[]`.
|
|
292
|
+
Throws if `app.json` is missing, unreadable, invalid, or `permissions` is not an
|
|
293
|
+
array of strings. This reads declarations without querying authorization or
|
|
294
|
+
prompting for access.
|
|
295
|
+
```typescript
|
|
296
|
+
const permissions = aix.getPermissions();
|
|
297
|
+
// e.g. ['GEOLOCATION', 'CAMERA']
|
|
298
|
+
```
|
|
299
|
+
|
|
257
300
|
#### `getPages(): PageInfo[]`
|
|
258
301
|
Returns information about all pages defined in the package, including their paths, titles, and data schemas.
|
|
259
302
|
```typescript
|
|
@@ -280,8 +323,8 @@ const widgets = aix.getWidgets('en-US');
|
|
|
280
323
|
|
|
281
324
|
Returns `{ pages, tools, diagnostics }` synchronously. Missing/unreadable resources,
|
|
282
325
|
UTF-8 errors, and malformed page metadata produce `{ path, message }` diagnostics,
|
|
283
|
-
one per failed page.
|
|
284
|
-
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;
|
|
285
328
|
invalid/unreadable `app.json.pages` produces an `app.json` diagnostic.
|
|
286
329
|
|
|
287
330
|
```typescript
|
|
@@ -309,7 +352,7 @@ Exported `MetadataResolution` has `pages: PageInfo[]`, `tools: Tool[]`, and
|
|
|
309
352
|
string fields.
|
|
310
353
|
|
|
311
354
|
#### `getTools(): Tool[]`
|
|
312
|
-
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`.
|
|
313
356
|
```typescript
|
|
314
357
|
const tools = aix.getTools();
|
|
315
358
|
/*
|
|
@@ -318,7 +361,7 @@ const tools = aix.getTools();
|
|
|
318
361
|
target: "_blank",
|
|
319
362
|
layout: { width: 480, height: 168 },
|
|
320
363
|
function: {
|
|
321
|
-
name: "
|
|
364
|
+
name: "pages/index/index",
|
|
322
365
|
description: "Home",
|
|
323
366
|
parameters: { ... }
|
|
324
367
|
}
|
|
@@ -410,3 +453,64 @@ The output will be generated in the `dist` directory, including WASM binaries an
|
|
|
410
453
|
## License
|
|
411
454
|
|
|
412
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
|
+
```
|