@yodaos-pkg/aix 0.8.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -92,6 +92,29 @@ const optimized = await AIX.optimize(packed.data, { level: 3 });
92
92
 
93
93
  Both methods return the generated `Uint8Array` and a structured per-file report.
94
94
 
95
+ Use `packFromSource` when the input represents an unpacked application tree.
96
+ It applies the same path normalization and nested `.aixignore` behavior as the
97
+ native and npm CLIs, and can report structured progress:
98
+
99
+ ```ts
100
+ const packed = await AIX.packFromSource(
101
+ [
102
+ { path: ".aixignore", data: new TextEncoder().encode("*.tmp\n") },
103
+ { path: "app.json", data: new TextEncoder().encode('{"pages":[]}') },
104
+ { path: "scratch.tmp", data: new Uint8Array() },
105
+ ],
106
+ {
107
+ optimize: { level: 2 },
108
+ onProgress(event) {
109
+ console.log(event.type);
110
+ },
111
+ },
112
+ );
113
+ ```
114
+
115
+ Use `pack` only when the caller has already normalized and filtered its input
116
+ files and wants to invoke the low-level packer directly.
117
+
95
118
  ## API Reference
96
119
 
97
120
  ### `AIX` Class
@@ -147,6 +170,13 @@ const pages = aix.getPages();
147
170
  */
148
171
  ```
149
172
 
173
+ #### `getWidgets(): WidgetInfo[]`
174
+ Returns widget declarations after verifying that every path resolves to an `.ink` entry in the package. Throws when a declared entry is missing.
175
+ ```typescript
176
+ const widgets = aix.getWidgets();
177
+ // [{ path: "widgets/clock/index", family: "1x1", placement: "persistent" }]
178
+ ```
179
+
150
180
  #### `getTools(): Tool[]`
151
181
  Generates a list of OpenAI-compatible tool definitions based on the pages and their schemas.
152
182
  ```typescript
@@ -183,6 +213,14 @@ interface PageInfo {
183
213
  }
184
214
  ```
185
215
 
216
+ ### `WidgetInfo`
217
+ ```typescript
218
+ interface WidgetInfo {
219
+ path: string;
220
+ family: string;
221
+ }
222
+ ```
223
+
186
224
  ### `Tool`
187
225
  OpenAI compatible tool format.
188
226
  ```typescript
package/index.d.ts CHANGED
@@ -27,11 +27,28 @@ export interface PackResult {
27
27
  report: OptimizeReport;
28
28
  warnings: string[];
29
29
  }
30
- type PackOptions = {
30
+ export interface PackOptions {
31
31
  buildId?: string;
32
32
  engine?: string;
33
33
  optimize?: false | OptimizeOptions;
34
+ }
35
+ export type PackProgressEvent = {
36
+ type: 'transferring_files_to_wasm';
37
+ } | {
38
+ type: 'collecting_source_inputs';
39
+ } | {
40
+ type: 'resolving_engine';
41
+ } | {
42
+ type: 'preparing_files';
43
+ } | {
44
+ type: 'file_finished';
45
+ report: FileOptimizeReport;
46
+ } | {
47
+ type: 'finalizing_archive';
34
48
  };
49
+ export interface PackFromSourceOptions extends PackOptions {
50
+ onProgress?: (event: PackProgressEvent) => void;
51
+ }
35
52
  export interface AixEntry {
36
53
  name: string;
37
54
  size: number;
@@ -42,6 +59,11 @@ export interface PageInfo {
42
59
  title?: string;
43
60
  data_schema: any;
44
61
  }
62
+ export interface WidgetInfo {
63
+ path: string;
64
+ family: string;
65
+ placement: 'persistent' | 'overlay';
66
+ }
45
67
  export interface Tool {
46
68
  type: string;
47
69
  function: {
@@ -59,7 +81,15 @@ export declare class AIX {
59
81
  */
60
82
  static From(data: Uint8Array | File): Promise<AIX>;
61
83
  static pack(files: AixInputFile[], options?: PackOptions): Promise<PackResult>;
62
- static packFromFiles(files: File[], options?: PackOptions): Promise<PackResult>;
84
+ /**
85
+ * Packs an in-memory application source tree.
86
+ *
87
+ * Unlike {@link pack}, this applies source collection semantics before
88
+ * packing: paths are normalized, duplicate paths are rejected, nested
89
+ * `.aixignore` files are honored, and the rule files are omitted.
90
+ */
91
+ static packFromSource(files: AixInputFile[], options?: PackFromSourceOptions): Promise<PackResult>;
92
+ static packFromFiles(files: File[], options?: PackFromSourceOptions): Promise<PackResult>;
63
93
  static optimize(data: Uint8Array | File, options?: OptimizeOptions): Promise<PackResult>;
64
94
  /**
65
95
  * List all files in the AIX package.
@@ -83,9 +113,12 @@ export declare class AIX {
83
113
  * Get all pages from app.json and pages/*.json.
84
114
  */
85
115
  getPages(): PageInfo[];
116
+ /**
117
+ * Get all widgets from app.json after validating that each .ink entry exists.
118
+ */
119
+ getWidgets(): WidgetInfo[];
86
120
  /**
87
121
  * Get all tools from app.json and pages/*.json in OpenAI format.
88
122
  */
89
123
  getTools(): Tool[];
90
124
  }
91
- export {};
package/index.js CHANGED
@@ -48,16 +48,28 @@ export class AIX {
48
48
  const result = pack_aix(files, buildId, options?.engine, optimize);
49
49
  return { data: result.data, report: result.report, warnings: result.warnings ?? [] };
50
50
  }
51
- static async packFromFiles(files, options) {
51
+ /**
52
+ * Packs an in-memory application source tree.
53
+ *
54
+ * Unlike {@link pack}, this applies source collection semantics before
55
+ * packing: paths are normalized, duplicate paths are rejected, nested
56
+ * `.aixignore` files are honored, and the rule files are omitted.
57
+ */
58
+ static async packFromSource(files, options) {
52
59
  await init();
53
60
  const buildId = options?.buildId ?? generateBuildId();
54
61
  const optimize = options?.optimize === false ? undefined : options?.optimize;
62
+ const result = options?.onProgress
63
+ ? getPackFromSourceWithProgress()(files, buildId, options.engine, optimize, options.onProgress)
64
+ : getPackFromSource()(files, buildId, options?.engine, optimize);
65
+ return { data: result.data, report: result.report, warnings: result.warnings ?? [] };
66
+ }
67
+ static async packFromFiles(files, options) {
55
68
  const sourceFiles = await Promise.all(files.map(async (file) => ({
56
69
  path: resolveWebFilePath(file),
57
70
  data: new Uint8Array(await file.arrayBuffer()),
58
71
  })));
59
- const result = getPackFromSource()(sourceFiles, buildId, options?.engine, optimize);
60
- return { data: result.data, report: result.report, warnings: result.warnings ?? [] };
72
+ return AIX.packFromSource(sourceFiles, options);
61
73
  }
62
74
  static async optimize(data, options) {
63
75
  await init();
@@ -101,6 +113,12 @@ export class AIX {
101
113
  getPages() {
102
114
  return this.reader.get_pages();
103
115
  }
116
+ /**
117
+ * Get all widgets from app.json after validating that each .ink entry exists.
118
+ */
119
+ getWidgets() {
120
+ return this.reader.get_widgets();
121
+ }
104
122
  /**
105
123
  * Get all tools from app.json and pages/*.json in OpenAI format.
106
124
  */
@@ -119,3 +137,10 @@ function getPackFromSource() {
119
137
  }
120
138
  return packFromSource;
121
139
  }
140
+ function getPackFromSourceWithProgress() {
141
+ const packFromSourceWithProgress = wasmExports.pack_aix_from_source_with_progress;
142
+ if (!packFromSourceWithProgress) {
143
+ throw new Error('pack_aix_from_source_with_progress is not available in the current WASM bundle');
144
+ }
145
+ return packFromSourceWithProgress;
146
+ }
package/jsr.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@yodaos-pkg/aix",
3
- "version": "0.8.2",
3
+ "version": "0.10.0",
4
4
  "exports": "./index.js"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yodaos-pkg/aix",
3
- "version": "0.8.2",
3
+ "version": "0.10.0",
4
4
  "description": "Ink AIX Package Reader",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/pkg/README.md CHANGED
@@ -92,6 +92,29 @@ const optimized = await AIX.optimize(packed.data, { level: 3 });
92
92
 
93
93
  Both methods return the generated `Uint8Array` and a structured per-file report.
94
94
 
95
+ Use `packFromSource` when the input represents an unpacked application tree.
96
+ It applies the same path normalization and nested `.aixignore` behavior as the
97
+ native and npm CLIs, and can report structured progress:
98
+
99
+ ```ts
100
+ const packed = await AIX.packFromSource(
101
+ [
102
+ { path: ".aixignore", data: new TextEncoder().encode("*.tmp\n") },
103
+ { path: "app.json", data: new TextEncoder().encode('{"pages":[]}') },
104
+ { path: "scratch.tmp", data: new Uint8Array() },
105
+ ],
106
+ {
107
+ optimize: { level: 2 },
108
+ onProgress(event) {
109
+ console.log(event.type);
110
+ },
111
+ },
112
+ );
113
+ ```
114
+
115
+ Use `pack` only when the caller has already normalized and filtered its input
116
+ files and wants to invoke the low-level packer directly.
117
+
95
118
  ## API Reference
96
119
 
97
120
  ### `AIX` Class
@@ -147,6 +170,13 @@ const pages = aix.getPages();
147
170
  */
148
171
  ```
149
172
 
173
+ #### `getWidgets(): WidgetInfo[]`
174
+ Returns widget declarations after verifying that every path resolves to an `.ink` entry in the package. Throws when a declared entry is missing.
175
+ ```typescript
176
+ const widgets = aix.getWidgets();
177
+ // [{ path: "widgets/clock/index", family: "1x1", placement: "persistent" }]
178
+ ```
179
+
150
180
  #### `getTools(): Tool[]`
151
181
  Generates a list of OpenAI-compatible tool definitions based on the pages and their schemas.
152
182
  ```typescript
@@ -183,6 +213,14 @@ interface PageInfo {
183
213
  }
184
214
  ```
185
215
 
216
+ ### `WidgetInfo`
217
+ ```typescript
218
+ interface WidgetInfo {
219
+ path: string;
220
+ family: string;
221
+ }
222
+ ```
223
+
186
224
  ### `Tool`
187
225
  OpenAI compatible tool format.
188
226
  ```typescript
package/pkg/aix_web.d.ts CHANGED
@@ -17,6 +17,7 @@ export class AixReaderWasm {
17
17
  get_title(): string | undefined;
18
18
  get_tools(): any;
19
19
  get_version(): string | undefined;
20
+ get_widgets(): any;
20
21
  list(): any;
21
22
  constructor(data: Uint8Array);
22
23
  read_file(name: string): Uint8Array;
@@ -53,6 +54,7 @@ export interface InitOutput {
53
54
  readonly aixreaderwasm_get_title: (a: number) => [number, number];
54
55
  readonly aixreaderwasm_get_tools: (a: number) => [number, number, number];
55
56
  readonly aixreaderwasm_get_version: (a: number) => [number, number];
57
+ readonly aixreaderwasm_get_widgets: (a: number) => [number, number, number];
56
58
  readonly aixreaderwasm_list: (a: number) => [number, number, number];
57
59
  readonly aixreaderwasm_new: (a: number, b: number) => [number, number, number];
58
60
  readonly aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
package/pkg/aix_web.js CHANGED
@@ -102,6 +102,16 @@ export class AixReaderWasm {
102
102
  }
103
103
  return v1;
104
104
  }
105
+ /**
106
+ * @returns {any}
107
+ */
108
+ get_widgets() {
109
+ const ret = wasm.aixreaderwasm_get_widgets(this.__wbg_ptr);
110
+ if (ret[2]) {
111
+ throw takeFromExternrefTable0(ret[1]);
112
+ }
113
+ return takeFromExternrefTable0(ret[0]);
114
+ }
105
115
  /**
106
116
  * @returns {any}
107
117
  */
@@ -463,7 +473,7 @@ function __wbg_get_imports() {
463
473
  const ret = arg0.value;
464
474
  return ret;
465
475
  },
466
- __wbg_warn_8bb2cd442b445478: function(arg0, arg1) {
476
+ __wbg_warn_eb943974f65fe1d7: function(arg0, arg1) {
467
477
  console.warn(getStringFromWasm0(arg0, arg1));
468
478
  },
469
479
  __wbindgen_cast_0000000000000001: function(arg0) {
Binary file
@@ -11,6 +11,7 @@ export const aixreaderwasm_get_pages: (a: number) => [number, number, number];
11
11
  export const aixreaderwasm_get_title: (a: number) => [number, number];
12
12
  export const aixreaderwasm_get_tools: (a: number) => [number, number, number];
13
13
  export const aixreaderwasm_get_version: (a: number) => [number, number];
14
+ export const aixreaderwasm_get_widgets: (a: number) => [number, number, number];
14
15
  export const aixreaderwasm_list: (a: number) => [number, number, number];
15
16
  export const aixreaderwasm_new: (a: number, b: number) => [number, number, number];
16
17
  export const aixreaderwasm_read_file: (a: number, b: number, c: number) => [number, number, number, number];
package/pkg/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiui-aix-web",
3
- "version": "0.8.2",
3
+ "version": "0.10.0",
4
4
  "files": [
5
5
  "aix_web_bg.wasm",
6
6
  "aix_web.js",