@bytecodealliance/jco
Advanced tools
Comparing version 1.4.0 to 1.4.1
export namespace LocalWasmToolsTools { | ||
export function parse(wat: string): Uint8Array; | ||
export function print(binary: Uint8Array): string; | ||
export function componentNew(binary: Uint8Array, adapters: [string, Uint8Array][] | undefined): Uint8Array; | ||
export function componentNew(binary: Uint8Array, adapters: Array<[string, Uint8Array]> | undefined): Uint8Array; | ||
export function componentWit(binary: Uint8Array): string; | ||
export function componentEmbed(embedOpts: EmbedOpts): Uint8Array; | ||
export function metadataShow(binary: Uint8Array): ModuleMetadata[]; | ||
export function metadataShow(binary: Uint8Array): Array<ModuleMetadata>; | ||
export function metadataAdd(binary: Uint8Array, metadata: ProducersFields): Uint8Array; | ||
@@ -20,3 +20,11 @@ } | ||
export type StringEncoding = 'utf8' | 'utf16' | 'compact-utf16'; | ||
export type ProducersFields = [string, [string, string][]][]; | ||
export type ProducersFields = Array<[string, Array<[string, string]>]>; | ||
export type EnabledFeatureSet = EnabledFeatureSetList | EnabledFeatureSetAll; | ||
export interface EnabledFeatureSetList { | ||
tag: 'list', | ||
val: Array<string>, | ||
} | ||
export interface EnabledFeatureSetAll { | ||
tag: 'all', | ||
} | ||
export interface EmbedOpts { | ||
@@ -30,2 +38,3 @@ binary?: Uint8Array, | ||
metadata?: ProducersFields, | ||
features?: EnabledFeatureSet, | ||
} | ||
@@ -32,0 +41,0 @@ export type ModuleMetaType = ModuleMetaTypeModule | ModuleMetaTypeComponent; |
export namespace WasiCliEnvironment { | ||
export function getEnvironment(): [string, string][]; | ||
export function getEnvironment(): Array<[string, string]>; | ||
} |
export namespace WasiFilesystemPreopens { | ||
export function getDirectories(): [Descriptor, string][]; | ||
export function getDirectories(): Array<[Descriptor, string]>; | ||
} | ||
import type { Descriptor } from './wasi-filesystem-types.js'; | ||
export { Descriptor }; |
@@ -1,3 +0,3 @@ | ||
export type Files = [string, Uint8Array][]; | ||
export type Maps = [string, string][]; | ||
export type Files = Array<[string, Uint8Array]>; | ||
export type Maps = Array<[string, string]>; | ||
export type InstantiationMode = InstantiationModeAsync | InstantiationModeSync; | ||
@@ -51,2 +51,10 @@ export interface InstantiationModeAsync { | ||
} | ||
export type EnabledFeatureSet = EnabledFeatureSetList | EnabledFeatureSetAll; | ||
export interface EnabledFeatureSetList { | ||
tag: 'list', | ||
val: Array<string>, | ||
} | ||
export interface EnabledFeatureSetAll { | ||
tag: 'all', | ||
} | ||
export interface TypeGenerationOptions { | ||
@@ -58,2 +66,3 @@ wit: Wit, | ||
map?: Maps, | ||
features?: EnabledFeatureSet, | ||
} | ||
@@ -70,4 +79,4 @@ /** | ||
files: Files, | ||
imports: string[], | ||
exports: [string, ExportType][], | ||
imports: Array<string>, | ||
exports: Array<[string, ExportType]>, | ||
} | ||
@@ -74,0 +83,0 @@ import { WasiCliEnvironment } from './interfaces/wasi-cli-environment.js'; |
{ | ||
"name": "@bytecodealliance/jco", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "JavaScript tooling for working with WebAssembly Components", | ||
@@ -5,0 +5,0 @@ "author": "Guy Bedford", |
import { getTmpDir } from '../common.js'; | ||
import { transpile } from './transpile.js'; | ||
import { rm, stat, mkdir, writeFile, symlink } from 'node:fs/promises'; | ||
import { rm, mkdir, writeFile, symlink } from 'node:fs/promises'; | ||
import { basename, resolve, extname } from 'node:path'; | ||
@@ -88,17 +88,7 @@ import { spawn } from 'node:child_process'; | ||
let preview2ShimPath = fileURLToPath(new URL('../../node_modules/@bytecodealliance/preview2-shim', import.meta.url)); | ||
while (true) { | ||
try { | ||
if ((await stat(preview2ShimPath)).isDirectory()) { | ||
break; | ||
} | ||
} | ||
catch { | ||
// empty | ||
} | ||
let len = preview2ShimPath.length; | ||
preview2ShimPath = resolve(preview2ShimPath, '..', '..', '..', 'node_modules', '@bytecodealliance', 'preview2-shim'); | ||
if (preview2ShimPath.length === len) { | ||
throw c`Unable to locate the {bold @bytecodealliance/preview2-shim} package, make sure it is installed.`; | ||
} | ||
let preview2ShimPath | ||
try { | ||
preview2ShimPath = fileURLToPath(new URL('../..', import.meta.resolve('@bytecodealliance/preview2-shim'))); | ||
} catch { | ||
throw c`Unable to locate the {bold @bytecodealliance/preview2-shim} package, make sure it is installed.`; | ||
} | ||
@@ -105,0 +95,0 @@ |
@@ -10,2 +10,3 @@ export function types(witPath: any, opts: any): Promise<void>; | ||
* outDir?: string, | ||
* features?: string[] | 'all', | ||
* }} opts | ||
@@ -20,2 +21,3 @@ * @returns {Promise<{ [filename: string]: Uint8Array }>} | ||
outDir?: string; | ||
features?: string[] | "all"; | ||
}): Promise<{ | ||
@@ -22,0 +24,0 @@ [filename: string]: Uint8Array; |
@@ -30,2 +30,3 @@ import { $init, generate, generateTypes } from '../../obj/js-component-bindgen-component.js'; | ||
* outDir?: string, | ||
* features?: string[] | 'all', | ||
* }} opts | ||
@@ -46,2 +47,10 @@ * @returns {Promise<{ [filename: string]: Uint8Array }>} | ||
outDir += '/'; | ||
let features = null; | ||
if (opts.allFeatures) { | ||
features = { tag: 'all' }; | ||
} else if (Array.isArray(opts.feature)) { | ||
features = { tag: 'list', val: opts.feature }; | ||
} | ||
return Object.fromEntries(generateTypes(name, { | ||
@@ -51,3 +60,4 @@ wit: { tag: 'path', val: (isWindows ? '//?/' : '') + resolve(witPath) }, | ||
tlaCompat: opts.tlaCompat ?? false, | ||
world: opts.worldName | ||
world: opts.worldName, | ||
features, | ||
}).map(([name, file]) => [`${outDir}${name}`, file])); | ||
@@ -65,3 +75,3 @@ } | ||
{bold ${summaryTitle}:} | ||
${table(Object.entries(files).map(([name, source]) => [ | ||
@@ -68,0 +78,0 @@ c` - {italic ${name}} `, |
@@ -14,3 +14,3 @@ #!/usr/bin/env node | ||
.usage('<command> [options]') | ||
.version('1.4.0'); | ||
.version('1.4.1'); | ||
@@ -21,2 +21,12 @@ function myParseInt(value) { | ||
/** | ||
* Option parsing that allows for collecting repeated arguments | ||
* | ||
* @param {string} value - the new value that is added | ||
* @param {string[]} previous - the existing list of values | ||
*/ | ||
function collectOptions(value, previous) { | ||
return previous.concat([value]); | ||
} | ||
program.command('componentize') | ||
@@ -69,2 +79,4 @@ .description('Create a component from a JavaScript module') | ||
.option('-q, --quiet', 'disable output summary') | ||
.option('--feature <feature>', 'enable one specific WIT feature (repeatable)', collectOptions, []) | ||
.option('--all-features', 'enable all features') | ||
.action(asyncAction(types)); | ||
@@ -71,0 +83,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10222
4719385