@bytecodealliance/jco 0.13.3 → 0.14.1

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.
Files changed (44) hide show
  1. package/README.md +23 -21
  2. package/lib/wasi_snapshot_preview1.command.wasm +0 -0
  3. package/lib/wasi_snapshot_preview1.reactor.wasm +0 -0
  4. package/obj/interfaces/wasi-filesystem-types.d.ts +1 -6
  5. package/obj/interfaces/wasi-io-error.d.ts +6 -0
  6. package/obj/interfaces/wasi-io-streams.d.ts +7 -9
  7. package/obj/js-component-bindgen-component.component.wasm +0 -0
  8. package/obj/js-component-bindgen-component.core.wasm +0 -0
  9. package/obj/js-component-bindgen-component.core2.wasm +0 -0
  10. package/obj/js-component-bindgen-component.d.ts +11 -2
  11. package/obj/js-component-bindgen-component.js +478 -453
  12. package/obj/wasm-tools.component.wasm +0 -0
  13. package/obj/wasm-tools.core.wasm +0 -0
  14. package/obj/wasm-tools.core2.wasm +0 -0
  15. package/obj/wasm-tools.d.ts +1 -0
  16. package/obj/wasm-tools.js +408 -420
  17. package/package.json +7 -5
  18. package/src/api.d.ts +42 -0
  19. package/src/api.d.ts.map +1 -0
  20. package/src/browser.d.ts +3 -0
  21. package/src/browser.d.ts.map +1 -0
  22. package/src/browser.js +11 -3
  23. package/src/cmd/componentize.d.ts +2 -0
  24. package/src/cmd/componentize.d.ts.map +1 -0
  25. package/src/cmd/componentize.js +1 -0
  26. package/src/cmd/opt.d.ts +15 -0
  27. package/src/cmd/opt.d.ts.map +1 -0
  28. package/src/cmd/run.d.ts +2 -0
  29. package/src/cmd/run.d.ts.map +1 -0
  30. package/src/cmd/run.js +22 -6
  31. package/src/cmd/transpile.d.ts +44 -0
  32. package/src/cmd/transpile.d.ts.map +1 -0
  33. package/src/cmd/transpile.js +206 -47
  34. package/src/cmd/wasm-tools.d.ts +8 -0
  35. package/src/cmd/wasm-tools.d.ts.map +1 -0
  36. package/src/cmd/wasm-tools.js +3 -2
  37. package/src/common.d.ts +16 -0
  38. package/src/common.d.ts.map +1 -0
  39. package/src/common.js +3 -0
  40. package/src/jco.d.ts +3 -0
  41. package/src/jco.d.ts.map +1 -0
  42. package/src/jco.js +9 -4
  43. package/src/ora-shim.d.ts +7 -0
  44. package/src/ora-shim.d.ts.map +1 -0
@@ -1,9 +1,10 @@
1
1
  import { writeFile } from "node:fs/promises";
2
- import { readFile } from '../common.js';
2
+ import { readFile, isWindows } from '../common.js';
3
3
  import { $init, tools } from "../../obj/wasm-tools.js";
4
4
  const { print: printFn, parse: parseFn, componentWit: componentWitFn, componentNew: componentNewFn, componentEmbed: componentEmbedFn, metadataAdd: metadataAddFn, metadataShow: metadataShowFn } = tools;
5
5
  import { resolve, basename, extname } from 'node:path';
6
6
  import c from 'chalk-template';
7
+ import { platform } from 'node:process';
7
8
 
8
9
  export async function parse(file, opts) {
9
10
  await $init;
@@ -68,7 +69,7 @@ export async function componentEmbed(file, opts) {
68
69
  });
69
70
  const source = file ? await readFile(file) : null;
70
71
  opts.binary = source;
71
- opts.witPath = resolve(opts.wit);
72
+ opts.witPath = (isWindows ? '//?/' : '') + resolve(opts.wit);
72
73
  const output = componentEmbedFn(opts);
73
74
  await writeFile(opts.output, output);
74
75
  }
@@ -0,0 +1,16 @@
1
+ export function setShowSpinner(val: any): void;
2
+ export function getShowSpinner(): boolean;
3
+ export function sizeStr(num: any): string;
4
+ export function fixedDigitDisplay(num: any, maxChars: any): string;
5
+ export function table(data: any, align?: any[]): string;
6
+ /**
7
+ * Securely creates a temporary directory and returns its path.
8
+ *
9
+ * The new directory is created using `fsPromises.mkdtemp()`.
10
+ */
11
+ export function getTmpDir(): Promise<string>;
12
+ export function spawnIOTmp(cmd: any, input: any, args: any): Promise<Buffer>;
13
+ export const isWindows: boolean;
14
+ export { readFileCli as readFile };
15
+ declare function readFileCli(file: any, encoding: any): Promise<Buffer>;
16
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["common.js"],"names":[],"mappings":"AAWA,+CAEC;AACD,0CAIC;AAED,0CAOC;AAED,mEAaC;AAED,wDAcC;AAED;;;;GAIG;AACH,6CAEC;AAYD,6EA8BC;AArGD,gCAA8C;;AA6D9C,wEAOC"}
package/src/common.js CHANGED
@@ -4,6 +4,9 @@ import { readFile, writeFile, rm, mkdtemp } from 'node:fs/promises';
4
4
  import { spawn } from 'node:child_process';
5
5
  import { argv0 } from 'node:process';
6
6
  import c from 'chalk-template';
7
+ import { platform } from 'node:process';
8
+
9
+ export const isWindows = platform === 'win32';
7
10
 
8
11
  let _showSpinner = false;
9
12
  export function setShowSpinner (val) {
package/src/jco.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=jco.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jco.d.ts","sourceRoot":"","sources":["jco.js"],"names":[],"mappings":""}
package/src/jco.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { program } from 'commander';
2
+ import { program, Option } from 'commander';
3
3
  import { opt } from './cmd/opt.js';
4
4
  import { transpile } from './cmd/transpile.js';
5
5
  import { run } from './cmd/run.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('0.13.3');
14
+ .version('0.14.1');
15
15
 
16
16
  function myParseInt(value) {
17
17
  return parseInt(value, 10);
@@ -45,15 +45,20 @@ program.command('transpile')
45
45
  .option('-M, --map <mappings...>', 'specifier=./output custom mappings for the component imports')
46
46
  .option('--no-wasi-shim', 'disable automatic rewriting of WASI imports to use @bytecodealliance/preview2-shim')
47
47
  .option('--js', 'output JS instead of core WebAssembly')
48
- .option('-I, --instantiation', 'output for custom module instantiation')
48
+ .addOption(new Option('-I, --instantiation [mode]', 'output for custom module instantiation').choices(['async', 'sync']).preset('async'))
49
49
  .option('-q, --quiet', 'disable logging')
50
+ .option('--no-namespaced-exports', 'disable namespaced exports for typescript compatibility')
50
51
  .option('--', 'for --optimize, custom wasm-opt arguments (defaults to best size optimization)')
51
52
  .action(asyncAction(transpile));
52
53
 
53
- program.command('run')
54
+ program.command('run')
54
55
  .description('Run a WebAssembly Command component')
55
56
  .usage('<command.wasm> <args...>')
57
+ .helpOption(false)
56
58
  .argument('<command>', 'Wasm command binary to run')
59
+ .option('--jco-dir <dir>', 'Instead of using a temporary dir, set the output directory for the run command')
60
+ .option('--jco-trace', 'Enable call tracing')
61
+ .option('--jco-import <module>', 'Custom module to import before the run executes to support custom environment setup')
57
62
  .argument('[args...]', 'Any CLI arguments to provide to the command')
58
63
  .action(asyncAction(run));
59
64
 
@@ -0,0 +1,7 @@
1
+ export default function ora(): Ora;
2
+ declare class Ora {
3
+ start(): void;
4
+ stop(): void;
5
+ }
6
+ export {};
7
+ //# sourceMappingURL=ora-shim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ora-shim.d.ts","sourceRoot":"","sources":["ora-shim.js"],"names":[],"mappings":"AACA,mCAEC;AAED;IACE,cAAW;IACX,aAAU;CACX"}