@yodaos-pkg/aix 0.8.2 → 0.9.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
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;
@@ -59,7 +76,15 @@ export declare class AIX {
59
76
  */
60
77
  static From(data: Uint8Array | File): Promise<AIX>;
61
78
  static pack(files: AixInputFile[], options?: PackOptions): Promise<PackResult>;
62
- static packFromFiles(files: File[], options?: PackOptions): Promise<PackResult>;
79
+ /**
80
+ * Packs an in-memory application source tree.
81
+ *
82
+ * Unlike {@link pack}, this applies source collection semantics before
83
+ * packing: paths are normalized, duplicate paths are rejected, nested
84
+ * `.aixignore` files are honored, and the rule files are omitted.
85
+ */
86
+ static packFromSource(files: AixInputFile[], options?: PackFromSourceOptions): Promise<PackResult>;
87
+ static packFromFiles(files: File[], options?: PackFromSourceOptions): Promise<PackResult>;
63
88
  static optimize(data: Uint8Array | File, options?: OptimizeOptions): Promise<PackResult>;
64
89
  /**
65
90
  * List all files in the AIX package.
@@ -88,4 +113,3 @@ export declare class AIX {
88
113
  */
89
114
  getTools(): Tool[];
90
115
  }
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();
@@ -119,3 +131,10 @@ function getPackFromSource() {
119
131
  }
120
132
  return packFromSource;
121
133
  }
134
+ function getPackFromSourceWithProgress() {
135
+ const packFromSourceWithProgress = wasmExports.pack_aix_from_source_with_progress;
136
+ if (!packFromSourceWithProgress) {
137
+ throw new Error('pack_aix_from_source_with_progress is not available in the current WASM bundle');
138
+ }
139
+ return packFromSourceWithProgress;
140
+ }
package/jsr.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@yodaos-pkg/aix",
3
- "version": "0.8.2",
3
+ "version": "0.9.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.9.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
package/pkg/aix_web.js CHANGED
@@ -463,7 +463,7 @@ function __wbg_get_imports() {
463
463
  const ret = arg0.value;
464
464
  return ret;
465
465
  },
466
- __wbg_warn_8bb2cd442b445478: function(arg0, arg1) {
466
+ __wbg_warn_fdc391c7c8dd5585: function(arg0, arg1) {
467
467
  console.warn(getStringFromWasm0(arg0, arg1));
468
468
  },
469
469
  __wbindgen_cast_0000000000000001: function(arg0) {
Binary file
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.9.0",
4
4
  "files": [
5
5
  "aix_web_bg.wasm",
6
6
  "aix_web.js",