@bytecodealliance/jco 1.8.1 → 1.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/src/jco.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { program, Option } from 'commander';
3
3
  import { opt } from './cmd/opt.js';
4
- import { transpile, types } from './cmd/transpile.js';
4
+ import { transpile, types, guestTypes } from './cmd/transpile.js';
5
5
  import { run as runCmd, serve as serveCmd } from './cmd/run.js';
6
6
  import { parse, print, componentNew, componentEmbed, metadataAdd, metadataShow, componentWit } from './cmd/wasm-tools.js';
7
7
  import { componentize } from './cmd/componentize.js';
@@ -11,7 +11,7 @@ program
11
11
  .name('jco')
12
12
  .description(c`{bold jco - WebAssembly JS Component Tools}\n JS Component Transpilation Bindgen & Wasm Tools for JS`)
13
13
  .usage('<command> [options]')
14
- .version('1.8.1');
14
+ .version('1.9.1');
15
15
 
16
16
  function myParseInt(value) {
17
17
  return parseInt(value, 10);
@@ -34,6 +34,7 @@ program.command('componentize')
34
34
  .requiredOption('-w, --wit <path>', 'WIT path to build with')
35
35
  .option('-n, --world-name <name>', 'WIT world to build')
36
36
  .option('--aot', 'Enable Weval AOT compilation of JS')
37
+ .option('--weval-bin <path>', 'Specify a custom weval binary to use')
37
38
  .addOption(new Option('-d, --disable <feature...>', 'disable WASI features').choices(['clocks', 'http', 'random', 'stdio', 'all']))
38
39
  // .addOption(new Option('-e, --enable <feature...>', 'enable WASI features').choices(['http']))
39
40
  .option('--preview2-adapter <adapter>', 'provide a custom preview2 adapter path')
@@ -51,6 +52,11 @@ program.command('transpile')
51
52
  .option('--no-typescript', 'do not output TypeScript .d.ts types')
52
53
  .option('--valid-lifting-optimization', 'optimize component binary validations assuming all lifted values are valid')
53
54
  .addOption(new Option('--import-bindings [mode]', 'bindings mode for imports').choices(['js', 'optimized', 'hybrid', 'direct-optimized']).preset('js'))
55
+ .addOption(new Option('--async-mode [mode]', 'EXPERIMENTAL: use async imports and exports').choices(['sync', 'jspi']).preset('sync'))
56
+ .option('--async-wasi-imports', 'EXPERIMENTAL: async component imports from WASI interfaces')
57
+ .option('--async-wasi-exports', 'EXPERIMENTAL: async component exports from WASI interfaces')
58
+ .option('--async-imports <imports...>', 'EXPERIMENTAL: async component imports (examples: "wasi:io/poll@0.2.0#poll", "wasi:io/poll#[method]pollable.block")')
59
+ .option('--async-exports <exports...>', 'EXPERIMENTAL: async component exports (examples: "wasi:cli/run@#run", "handle")')
54
60
  .option('--tracing', 'emit `tracing` calls on function entry/exit')
55
61
  .option('-b, --base64-cutoff <bytes>', 'set the byte size under which core Wasm binaries will be inlined as base64', myParseInt)
56
62
  .option('--tla-compat', 'enables compatibility for JS environments without top-level await support via an async $init promise export')
@@ -75,11 +81,28 @@ program.command('types')
75
81
  .requiredOption('-o, --out-dir <out-dir>', 'output directory')
76
82
  .option('--tla-compat', 'generates types for the TLA compat output with an async $init promise export')
77
83
  .addOption(new Option('-I, --instantiation [mode]', 'type output for custom module instantiation').choices(['async', 'sync']).preset('async'))
84
+ .addOption(new Option('--async-mode [mode]', 'EXPERIMENTAL: use async imports and exports').choices(['sync', 'jspi']).preset('sync'))
85
+ .option('--async-wasi-imports', 'EXPERIMENTAL: async component imports from WASI interfaces')
86
+ .option('--async-wasi-exports', 'EXPERIMENTAL: async component exports from WASI interfaces')
87
+ .option('--async-imports <imports...>', 'EXPERIMENTAL: async component imports (examples: "wasi:io/poll@0.2.0#poll", "wasi:io/poll#[method]pollable.block")')
88
+ .option('--async-exports <exports...>', 'EXPERIMENTAL: async component exports (examples: "wasi:cli/run@#run", "handle")')
78
89
  .option('-q, --quiet', 'disable output summary')
79
90
  .option('--feature <feature>', 'enable one specific WIT feature (repeatable)', collectOptions, [])
80
91
  .option('--all-features', 'enable all features')
81
92
  .action(asyncAction(types));
82
93
 
94
+ program.command('guest-types')
95
+ .description('(experimental) Generate guest types for the given WIT')
96
+ .usage('<wit-path> -o <out-dir>')
97
+ .argument('<wit-path>', 'path to a WIT file or directory')
98
+ .option('--name <name>', 'custom output name')
99
+ .option('-n, --world-name <world>', 'WIT world to generate types for')
100
+ .requiredOption('-o, --out-dir <out-dir>', 'output directory')
101
+ .option('-q, --quiet', 'disable output summary')
102
+ .option('--feature <feature>', 'enable one specific WIT feature (repeatable)', collectOptions, [])
103
+ .option('--all-features', 'enable all features')
104
+ .action(asyncAction(guestTypes));
105
+
83
106
  program.command('run')
84
107
  .description('Run a WASI Command component')
85
108
  .usage('<command.wasm> <args...>')
@@ -131,6 +154,7 @@ program.command('opt')
131
154
  .usage('<component-file> -o <output-file>')
132
155
  .argument('<component-file>', 'Wasm component binary filepath')
133
156
  .requiredOption('-o, --output <output-file>', 'optimized component output filepath')
157
+ .option('--asyncify', 'runs Asyncify pass in wasm-opt')
134
158
  .option('-q, --quiet')
135
159
  .option('--', 'custom wasm-opt arguments (defaults to best size optimization)')
136
160
  .action(asyncAction(opt));