@bytecodealliance/jco 1.15.3 → 1.16.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytecodealliance/jco",
3
- "version": "1.15.3",
3
+ "version": "1.16.0",
4
4
  "description": "JavaScript tooling for working with WebAssembly Components",
5
5
  "homepage": "https://github.com/bytecodealliance/jco#readme",
6
6
  "author": "Guy Bedford",
@@ -63,6 +63,7 @@
63
63
  "build": "cargo xtask build debug",
64
64
  "build:release": "cargo xtask build release",
65
65
  "build:types:preview2-shim": "npm run build:types:preview2-shim --include-workspace-root",
66
+ "build:test:components": "cargo xtask build-test-components",
66
67
  "fmt": "npm run lint:fix",
67
68
  "lint": "eslint -c ../../eslint.config.mjs --ext .js src test",
68
69
  "lint:fix": "npm run lint -- --fix",
@@ -86,12 +87,13 @@
86
87
  "@typescript-eslint/parser": "^8.39.1",
87
88
  "commitlint": "^19.8.1",
88
89
  "conventional-changelog-conventionalcommits": "^9.1.0",
89
- "eslint": "^9.33.0",
90
+ "eslint": "^9.39.1",
90
91
  "mime": "^4.0.7",
91
92
  "puppeteer": "^24.16.2",
92
93
  "semver": "^7.7.1",
93
94
  "smol-toml": "^1.4.2",
94
95
  "typescript": "^5.9.2",
96
+ "vite": "^7.1.5",
95
97
  "vitest": "^3.2.4",
96
98
  "which": "^2.0.2"
97
99
  }
package/src/cmd/opt.js CHANGED
@@ -2,7 +2,7 @@ import { writeFile } from 'node:fs/promises';
2
2
 
3
3
  import { $init, tools } from '../../obj/wasm-tools.js';
4
4
  const { metadataShow, print } = tools;
5
- import { fileURLToPath } from 'url';
5
+ import { fileURLToPath } from 'node:url';
6
6
  import {
7
7
  readFile,
8
8
  sizeStr,
@@ -1,5 +1,9 @@
1
+ import type { Command } from 'commander';
2
+
1
3
  export function types(witPath: any, opts: any): Promise<void>;
4
+
2
5
  export function guestTypes(witPath: any, opts: any): Promise<void>;
6
+
3
7
  /**
4
8
  * @param {string} witPath
5
9
  * @param {{
@@ -30,7 +34,45 @@ export function typesComponent(witPath: string, opts: {
30
34
  }): Promise<{
31
35
  [filename: string]: Uint8Array;
32
36
  }>;
33
- export function transpile(componentPath: any, opts: any, program: any): Promise<void>;
37
+
38
+
39
+ export function transpile(
40
+ componentPath: string,
41
+ opts: TranspilationOptions,
42
+ program: Command,
43
+ ): Promise<TranspilationResult>;
44
+
45
+ type TranspilationOptions = {
46
+ name: string;
47
+ instantiation?: 'async' | 'sync';
48
+ importBindings?: 'js' | 'optimized' | 'hybrid' | 'direct-optimized';
49
+ map?: Record<string, string>;
50
+ asyncMode?: string;
51
+ asyncImports?: string[];
52
+ asyncExports?: string[];
53
+ asyncWasiImports?: string[];
54
+ asyncWasiExports?: string[];
55
+ validLiftingOptimization?: boolean;
56
+ tracing?: boolean;
57
+ nodejsCompat?: boolean;
58
+ tlaCompat?: boolean;
59
+ base64Cutoff?: boolean;
60
+ js?: boolean;
61
+ minify?: boolean;
62
+ optimize?: boolean;
63
+ namespacedExports?: boolean;
64
+ outDir?: string;
65
+ multiMemory?: boolean;
66
+ experimentalIdlImports?: boolean;
67
+ optArgs?: string[];
68
+ };
69
+
70
+ type TranspilationResult = {
71
+ files: FileBytes;
72
+ imports: string[];
73
+ exports: [string, 'function' | 'instance'][];
74
+ };
75
+
34
76
  /**
35
77
  *
36
78
  * @param {Uint8Array} component
@@ -3,7 +3,7 @@
3
3
  import { extname, basename, resolve } from 'node:path';
4
4
 
5
5
  import { minify } from 'terser';
6
- import { fileURLToPath } from 'url';
6
+ import { fileURLToPath } from 'node:url';
7
7
 
8
8
  import { optimizeComponent } from './opt.js';
9
9
 
@@ -179,6 +179,11 @@ export async function transpileComponent(component, opts = {}) {
179
179
  'async exports cannot be specified in sync mode (consider adding --async-mode=jspi)'
180
180
  );
181
181
  }
182
+ if (asyncMode === 'sync' && asyncImports.size > 0) {
183
+ throw new Error(
184
+ 'async imports cannot be specified in sync mode (consider adding --async-mode=jspi)'
185
+ );
186
+ }
182
187
  let asyncModeObj;
183
188
  if (asyncMode === 'sync') {
184
189
  asyncModeObj = null;
package/src/common.js CHANGED
@@ -240,7 +240,7 @@ export async function resolveDefaultWITPath(witPath) {
240
240
  }
241
241
 
242
242
  /**
243
- * Partial polyfill for 'node:utils' `styleText()`
243
+ * Partial polyfill for 'node:util' `styleText()`
244
244
  *
245
245
  * @param {string | string[]} styles - styles to apply to the given text
246
246
  * @param {string} text - text that should be styled
package/src/jco.js CHANGED
@@ -25,7 +25,7 @@ program
25
25
  )
26
26
  .usage('<command> [options]')
27
27
  .enablePositionalOptions()
28
- .version('1.15.3');
28
+ .version('1.16.0');
29
29
 
30
30
  function myParseInt(value) {
31
31
  return parseInt(value, 10);
package/types/common.d.ts CHANGED
@@ -55,7 +55,7 @@ export function writeFiles(files: Record<string, string>, summaryTitle: boolean)
55
55
  */
56
56
  export function resolveDefaultWITPath(witPath?: string | undefined): Promise<string>;
57
57
  /**
58
- * Partial polyfill for 'node:utils' `styleText()`
58
+ * Partial polyfill for 'node:util' `styleText()`
59
59
  *
60
60
  * @param {string | string[]} styles - styles to apply to the given text
61
61
  * @param {string} text - text that should be styled