@bytecodealliance/jco 1.4.4 → 1.6.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 +0 -2
- package/obj/js-component-bindgen-component.core.wasm +0 -0
- package/obj/js-component-bindgen-component.core2.wasm +0 -0
- package/obj/js-component-bindgen-component.js +14 -14
- package/obj/wasm-tools.core.wasm +0 -0
- package/obj/wasm-tools.core2.wasm +0 -0
- package/obj/wasm-tools.js +20 -30
- package/package.json +6 -7
- package/src/cmd/componentize.d.ts.map +1 -1
- package/src/cmd/componentize.js +5 -7
- package/src/cmd/opt.d.ts.map +1 -1
- package/src/cmd/opt.js +4 -9
- package/src/cmd/run.js +3 -3
- package/src/cmd/transpile.d.ts.map +1 -1
- package/src/cmd/transpile.js +3 -8
- package/src/jco.js +4 -2
package/README.md
CHANGED
|
@@ -113,8 +113,6 @@ jco componentize app.js --wit wit -n world-name -o component.wasm
|
|
|
113
113
|
|
|
114
114
|
Creates a component from a JS module implementing a WIT world definition, via a Spidermonkey engine embedding.
|
|
115
115
|
|
|
116
|
-
Currently requires an explicit install of the componentize-js engine via `npm install @bytecodealliance/componentize-js`.
|
|
117
|
-
|
|
118
116
|
See [ComponentizeJS](https://github.com/bytecodealliance/componentize-js) for more details on this process.
|
|
119
117
|
|
|
120
118
|
## API
|
|
Binary file
|
|
Binary file
|
|
@@ -3992,24 +3992,24 @@ export const $init = (() => {
|
|
|
3992
3992
|
let gen = (function* init () {
|
|
3993
3993
|
const module0 = fetchCompile(new URL('./js-component-bindgen-component.core.wasm', import.meta.url));
|
|
3994
3994
|
const module1 = fetchCompile(new URL('./js-component-bindgen-component.core2.wasm', import.meta.url));
|
|
3995
|
-
const module2 = base64Compile('
|
|
3996
|
-
const module3 = base64Compile('AGFzbQEAAAABaw9gAX8AYAN/fn8AYAJ/fwBgBX9/f39/AGAHf39/f39/fwBgBH9/f38AYAJ+
|
|
3995
|
+
const module2 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBX9/f39/AGAEf39/fwBgBH9/f38Bf2AHf39/f39/fwBgAn5/AGAJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAX8Bf2ADf39/AX8DJiUBAwMAAAAABAcABAAAAwMABQUACAEBAQEGCQoLAgIGAgIMAg0BBAUBcAElJQe7ASYBMAAAATEAAQEyAAIBMwADATQABAE1AAUBNgAGATcABwE4AAgBOQAJAjEwAAoCMTEACwIxMgAMAjEzAA0CMTQADgIxNQAPAjE2ABACMTcAEQIxOAASAjE5ABMCMjAAFAIyMQAVAjIyABYCMjMAFwIyNAAYAjI1ABkCMjYAGgIyNwAbAjI4ABwCMjkAHQIzMAAeAjMxAB8CMzIAIAIzMwAhAjM0ACICMzUAIwIzNgAkCCRpbXBvcnRzAQAK+QMlCQAgAEEAEQEACw0AIAAgASACQQERAwALDQAgACABIAJBAhEDAAsLACAAIAFBAxEAAAsLACAAIAFBBBEAAAsLACAAIAFBBREAAAsLACAAIAFBBhEAAAsRACAAIAEgAiADIARBBxEEAAsVACAAIAEgAiADIAQgBSAGQQgRBwALCwAgACABQQkRAAALEQAgACABIAIgAyAEQQoRBAALCwAgACABQQsRAAALCwAgACABQQwRAAALDQAgACABIAJBDREDAAsNACAAIAEgAkEOEQMACwsAIAAgAUEPEQAACw8AIAAgASACIANBEBEFAAsPACAAIAEgAiADQRERBQALCwAgACABQRIRAAALCwAgACABQRMRCAALCQAgAEEUEQEACwkAIABBFREBAAsJACAAQRYRAQALCQAgAEEXEQEACw8AIAAgASACIANBGBEGAAsZACAAIAEgAiADIAQgBSAGIAcgCEEZEQkACxEAIAAgASACIAMgBEEaEQoACxEAIAAgASACIAMgBEEbEQsACwsAIAAgAUEcEQIACwsAIAAgAUEdEQIACw8AIAAgASACIANBHhEGAAsLACAAIAFBHxECAAsLACAAIAFBIBECAAsJACAAQSERDAALCwAgACABQSIRAgALDQAgACABIAJBIxENAAsJACAAQSQRAQALAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMTUuMA');
|
|
3996
|
+
const module3 = base64Compile('AGFzbQEAAAABaw9gAX8AYAN/fn8AYAJ/fwBgBX9/f39/AGAHf39/f39/fwBgBH9/f38AYAJ+fwBgBH9/f38Bf2AJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAn9/AX9gAX8Bf2ADf39/AX9gAX8AAuQBJgABMAAAAAExAAEAATIAAQABMwACAAE0AAIAATUAAgABNgACAAE3AAMAATgABAABOQACAAIxMAADAAIxMQACAAIxMgACAAIxMwABAAIxNAABAAIxNQACAAIxNgAFAAIxNwAFAAIxOAACAAIxOQAGAAIyMAAAAAIyMQAAAAIyMgAAAAIyMwAAAAIyNAAHAAIyNQAIAAIyNgAJAAIyNwAKAAIyOAALAAIyOQALAAIzMAAHAAIzMQALAAIzMgALAAIzMwAMAAIzNAALAAIzNQANAAIzNgAOAAgkaW1wb3J0cwFwASUlCSsBAEEACyUAAQIDBAUGBwgJCgsMDQ4PEBESExQVFhcYGRobHB0eHyAhIiMkAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMTUuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw');
|
|
3997
3997
|
({ exports: exports0 } = yield instantiateCore(yield module2));
|
|
3998
3998
|
({ exports: exports1 } = yield instantiateCore(yield module0, {
|
|
3999
3999
|
wasi_snapshot_preview1: {
|
|
4000
4000
|
environ_get: exports0['31'],
|
|
4001
4001
|
environ_sizes_get: exports0['32'],
|
|
4002
4002
|
fd_close: exports0['33'],
|
|
4003
|
-
fd_filestat_get: exports0['
|
|
4003
|
+
fd_filestat_get: exports0['29'],
|
|
4004
4004
|
fd_prestat_dir_name: exports0['35'],
|
|
4005
4005
|
fd_prestat_get: exports0['34'],
|
|
4006
|
-
fd_read: exports0['
|
|
4006
|
+
fd_read: exports0['30'],
|
|
4007
4007
|
fd_readdir: exports0['26'],
|
|
4008
|
-
fd_write: exports0['
|
|
4009
|
-
path_filestat_get: exports0['
|
|
4010
|
-
path_open: exports0['
|
|
4008
|
+
fd_write: exports0['24'],
|
|
4009
|
+
path_filestat_get: exports0['27'],
|
|
4010
|
+
path_open: exports0['25'],
|
|
4011
4011
|
proc_exit: exports0['36'],
|
|
4012
|
-
random_get: exports0['
|
|
4012
|
+
random_get: exports0['28'],
|
|
4013
4013
|
},
|
|
4014
4014
|
}));
|
|
4015
4015
|
({ exports: exports2 } = yield instantiateCore(yield module1, {
|
|
@@ -4107,14 +4107,14 @@ export const $init = (() => {
|
|
|
4107
4107
|
'21': trampoline32,
|
|
4108
4108
|
'22': trampoline33,
|
|
4109
4109
|
'23': trampoline34,
|
|
4110
|
-
'24': exports2.
|
|
4111
|
-
'25': exports2.
|
|
4110
|
+
'24': exports2.fd_write,
|
|
4111
|
+
'25': exports2.path_open,
|
|
4112
4112
|
'26': exports2.fd_readdir,
|
|
4113
|
-
'27': exports2.
|
|
4114
|
-
'28': exports2.
|
|
4115
|
-
'29': exports2.
|
|
4113
|
+
'27': exports2.path_filestat_get,
|
|
4114
|
+
'28': exports2.random_get,
|
|
4115
|
+
'29': exports2.fd_filestat_get,
|
|
4116
4116
|
'3': trampoline14,
|
|
4117
|
-
'30': exports2.
|
|
4117
|
+
'30': exports2.fd_read,
|
|
4118
4118
|
'31': exports2.environ_get,
|
|
4119
4119
|
'32': exports2.environ_sizes_get,
|
|
4120
4120
|
'33': exports2.fd_close,
|
package/obj/wasm-tools.core.wasm
CHANGED
|
Binary file
|
|
Binary file
|
package/obj/wasm-tools.js
CHANGED
|
@@ -3464,11 +3464,6 @@ let exports3;
|
|
|
3464
3464
|
let realloc1;
|
|
3465
3465
|
let postReturn0;
|
|
3466
3466
|
let postReturn1;
|
|
3467
|
-
let postReturn2;
|
|
3468
|
-
let postReturn3;
|
|
3469
|
-
let postReturn4;
|
|
3470
|
-
let postReturn5;
|
|
3471
|
-
let postReturn6;
|
|
3472
3467
|
function trampoline0(handle) {
|
|
3473
3468
|
const handleEntry = rscTableRemove(handleTable6, handle);
|
|
3474
3469
|
if (handleEntry.own) {
|
|
@@ -3635,7 +3630,7 @@ function print(arg0) {
|
|
|
3635
3630
|
}
|
|
3636
3631
|
}
|
|
3637
3632
|
const retVal = variant3;
|
|
3638
|
-
|
|
3633
|
+
postReturn0(ret);
|
|
3639
3634
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
3640
3635
|
throw new ComponentError(retVal.val);
|
|
3641
3636
|
}
|
|
@@ -3709,7 +3704,7 @@ function componentNew(arg0, arg1) {
|
|
|
3709
3704
|
}
|
|
3710
3705
|
}
|
|
3711
3706
|
const retVal = variant8;
|
|
3712
|
-
|
|
3707
|
+
postReturn0(ret);
|
|
3713
3708
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
3714
3709
|
throw new ComponentError(retVal.val);
|
|
3715
3710
|
}
|
|
@@ -3751,7 +3746,7 @@ function componentWit(arg0) {
|
|
|
3751
3746
|
}
|
|
3752
3747
|
}
|
|
3753
3748
|
const retVal = variant3;
|
|
3754
|
-
|
|
3749
|
+
postReturn0(ret);
|
|
3755
3750
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
3756
3751
|
throw new ComponentError(retVal.val);
|
|
3757
3752
|
}
|
|
@@ -3947,7 +3942,7 @@ function componentEmbed(arg0) {
|
|
|
3947
3942
|
}
|
|
3948
3943
|
}
|
|
3949
3944
|
const retVal = variant27;
|
|
3950
|
-
|
|
3945
|
+
postReturn0(ret);
|
|
3951
3946
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
3952
3947
|
throw new ComponentError(retVal.val);
|
|
3953
3948
|
}
|
|
@@ -4057,7 +4052,7 @@ function metadataShow(arg0) {
|
|
|
4057
4052
|
}
|
|
4058
4053
|
}
|
|
4059
4054
|
const retVal = variant11;
|
|
4060
|
-
|
|
4055
|
+
postReturn1(ret);
|
|
4061
4056
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
4062
4057
|
throw new ComponentError(retVal.val);
|
|
4063
4058
|
}
|
|
@@ -4127,7 +4122,7 @@ function metadataAdd(arg0, arg1) {
|
|
|
4127
4122
|
}
|
|
4128
4123
|
}
|
|
4129
4124
|
const retVal = variant10;
|
|
4130
|
-
|
|
4125
|
+
postReturn0(ret);
|
|
4131
4126
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
4132
4127
|
throw new ComponentError(retVal.val);
|
|
4133
4128
|
}
|
|
@@ -4139,22 +4134,22 @@ export const $init = (() => {
|
|
|
4139
4134
|
let gen = (function* init () {
|
|
4140
4135
|
const module0 = fetchCompile(new URL('./wasm-tools.core.wasm', import.meta.url));
|
|
4141
4136
|
const module1 = fetchCompile(new URL('./wasm-tools.core2.wasm', import.meta.url));
|
|
4142
|
-
const module2 = base64Compile('
|
|
4143
|
-
const module3 = base64Compile('
|
|
4137
|
+
const module2 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBX9/f39/AGAEf39/fwBgBH9/f38Bf2AHf39/f39/fwBgAn5/AGAJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAX8Bf2ADf39/AX8DJiUBAwMAAAAABAcABAAAAwMABQUACAEBAQEGCQoLAgYCAgIMAg0BBAUBcAElJQe7ASYBMAAAATEAAQEyAAIBMwADATQABAE1AAUBNgAGATcABwE4AAgBOQAJAjEwAAoCMTEACwIxMgAMAjEzAA0CMTQADgIxNQAPAjE2ABACMTcAEQIxOAASAjE5ABMCMjAAFAIyMQAVAjIyABYCMjMAFwIyNAAYAjI1ABkCMjYAGgIyNwAbAjI4ABwCMjkAHQIzMAAeAjMxAB8CMzIAIAIzMwAhAjM0ACICMzUAIwIzNgAkCCRpbXBvcnRzAQAK+QMlCQAgAEEAEQEACw0AIAAgASACQQERAwALDQAgACABIAJBAhEDAAsLACAAIAFBAxEAAAsLACAAIAFBBBEAAAsLACAAIAFBBREAAAsLACAAIAFBBhEAAAsRACAAIAEgAiADIARBBxEEAAsVACAAIAEgAiADIAQgBSAGQQgRBwALCwAgACABQQkRAAALEQAgACABIAIgAyAEQQoRBAALCwAgACABQQsRAAALCwAgACABQQwRAAALDQAgACABIAJBDREDAAsNACAAIAEgAkEOEQMACwsAIAAgAUEPEQAACw8AIAAgASACIANBEBEFAAsPACAAIAEgAiADQRERBQALCwAgACABQRIRAAALCwAgACABQRMRCAALCQAgAEEUEQEACwkAIABBFREBAAsJACAAQRYRAQALCQAgAEEXEQEACw8AIAAgASACIANBGBEGAAsZACAAIAEgAiADIAQgBSAGIAcgCEEZEQkACxEAIAAgASACIAMgBEEaEQoACxEAIAAgASACIAMgBEEbEQsACwsAIAAgAUEcEQIACw8AIAAgASACIANBHREGAAsLACAAIAFBHhECAAsLACAAIAFBHxECAAsLACAAIAFBIBECAAsJACAAQSERDAALCwAgACABQSIRAgALDQAgACABIAJBIxENAAsJACAAQSQRAQALAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMTUuMA');
|
|
4138
|
+
const module3 = base64Compile('AGFzbQEAAAABZw5gAn9/AGABfwBgAn9/AX9gA39+fwBgBX9/f39/AGAEf39/fwBgBH9/f38Bf2AHf39/f39/fwBgAn5/AGAJf39/f39+fn9/AX9gBX9/f35/AX9gBX9/f39/AX9gAX8Bf2ADf39/AX8C5AEmAAEwAAEAATEAAwABMgADAAEzAAAAATQAAAABNQAAAAE2AAAAATcABAABOAAHAAE5AAAAAjEwAAQAAjExAAAAAjEyAAAAAjEzAAMAAjE0AAMAAjE1AAAAAjE2AAUAAjE3AAUAAjE4AAAAAjE5AAgAAjIwAAEAAjIxAAEAAjIyAAEAAjIzAAEAAjI0AAYAAjI1AAkAAjI2AAoAAjI3AAsAAjI4AAIAAjI5AAYAAjMwAAIAAjMxAAIAAjMyAAIAAjMzAAwAAjM0AAIAAjM1AA0AAjM2AAEACCRpbXBvcnRzAXABJSUJKwEAQQALJQABAgMEBQYHCAkKCwwNDg8QERITFBUWFxgZGhscHR4fICEiIyQALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIxNS4w');
|
|
4144
4139
|
({ exports: exports0 } = yield instantiateCore(yield module2));
|
|
4145
4140
|
({ exports: exports1 } = yield instantiateCore(yield module0, {
|
|
4146
4141
|
wasi_snapshot_preview1: {
|
|
4147
4142
|
environ_get: exports0['31'],
|
|
4148
4143
|
environ_sizes_get: exports0['32'],
|
|
4149
4144
|
fd_close: exports0['33'],
|
|
4150
|
-
fd_filestat_get: exports0['
|
|
4145
|
+
fd_filestat_get: exports0['28'],
|
|
4151
4146
|
fd_prestat_dir_name: exports0['35'],
|
|
4152
4147
|
fd_prestat_get: exports0['34'],
|
|
4153
|
-
fd_read: exports0['
|
|
4148
|
+
fd_read: exports0['29'],
|
|
4154
4149
|
fd_readdir: exports0['26'],
|
|
4155
|
-
fd_write: exports0['
|
|
4156
|
-
path_filestat_get: exports0['
|
|
4157
|
-
path_open: exports0['
|
|
4150
|
+
fd_write: exports0['24'],
|
|
4151
|
+
path_filestat_get: exports0['27'],
|
|
4152
|
+
path_open: exports0['25'],
|
|
4158
4153
|
proc_exit: exports0['36'],
|
|
4159
4154
|
random_get: exports0['30'],
|
|
4160
4155
|
},
|
|
@@ -4254,12 +4249,12 @@ export const $init = (() => {
|
|
|
4254
4249
|
'21': trampoline32,
|
|
4255
4250
|
'22': trampoline33,
|
|
4256
4251
|
'23': trampoline34,
|
|
4257
|
-
'24': exports2.
|
|
4258
|
-
'25': exports2.
|
|
4252
|
+
'24': exports2.fd_write,
|
|
4253
|
+
'25': exports2.path_open,
|
|
4259
4254
|
'26': exports2.fd_readdir,
|
|
4260
|
-
'27': exports2.
|
|
4261
|
-
'28': exports2.
|
|
4262
|
-
'29': exports2.
|
|
4255
|
+
'27': exports2.path_filestat_get,
|
|
4256
|
+
'28': exports2.fd_filestat_get,
|
|
4257
|
+
'29': exports2.fd_read,
|
|
4263
4258
|
'3': trampoline14,
|
|
4264
4259
|
'30': exports2.random_get,
|
|
4265
4260
|
'31': exports2.environ_get,
|
|
@@ -4277,13 +4272,8 @@ export const $init = (() => {
|
|
|
4277
4272
|
},
|
|
4278
4273
|
}));
|
|
4279
4274
|
realloc1 = exports1.cabi_realloc;
|
|
4280
|
-
postReturn0 = exports1['cabi_post_local:wasm-tools/tools#
|
|
4281
|
-
postReturn1 = exports1['cabi_post_local:wasm-tools/tools#
|
|
4282
|
-
postReturn2 = exports1['cabi_post_local:wasm-tools/tools#component-new'];
|
|
4283
|
-
postReturn3 = exports1['cabi_post_local:wasm-tools/tools#component-wit'];
|
|
4284
|
-
postReturn4 = exports1['cabi_post_local:wasm-tools/tools#component-embed'];
|
|
4285
|
-
postReturn5 = exports1['cabi_post_local:wasm-tools/tools#metadata-show'];
|
|
4286
|
-
postReturn6 = exports1['cabi_post_local:wasm-tools/tools#metadata-add'];
|
|
4275
|
+
postReturn0 = exports1['cabi_post_local:wasm-tools/tools#component-embed'];
|
|
4276
|
+
postReturn1 = exports1['cabi_post_local:wasm-tools/tools#metadata-show'];
|
|
4287
4277
|
_initialized = true;
|
|
4288
4278
|
})();
|
|
4289
4279
|
let promise, resolve, reject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytecodealliance/jco",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "JavaScript tooling for working with WebAssembly Components",
|
|
5
5
|
"author": "Guy Bedford",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"type": "module",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@bytecodealliance/
|
|
27
|
+
"@bytecodealliance/componentize-js": "^0.12.0",
|
|
28
|
+
"@bytecodealliance/preview2-shim": "^0.16.7",
|
|
28
29
|
"binaryen": "^118.0.0",
|
|
29
30
|
"chalk-template": "^1",
|
|
30
31
|
"commander": "^12",
|
|
@@ -33,15 +34,13 @@
|
|
|
33
34
|
"terser": "^5"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@bytecodealliance/componentize-js": "^0.9.0",
|
|
37
37
|
"@types/node": "^20.14.12",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
39
|
-
"@typescript-eslint/parser": "^
|
|
40
|
-
"eslint": "^
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^8.2.0",
|
|
39
|
+
"@typescript-eslint/parser": "^8.2.0",
|
|
40
|
+
"eslint": "^9.9.0",
|
|
41
41
|
"mime": "^4.0.4",
|
|
42
42
|
"mocha": "^10.7.0",
|
|
43
43
|
"puppeteer": "^22.14.0",
|
|
44
|
-
"terser": "^5.16.1",
|
|
45
44
|
"typescript": "^5.5.4"
|
|
46
45
|
},
|
|
47
46
|
"repository": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"componentize.d.ts","sourceRoot":"","sources":["componentize.js"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"componentize.d.ts","sourceRoot":"","sources":["componentize.js"],"names":[],"mappings":"AAIA,sEAiBC"}
|
package/src/cmd/componentize.js
CHANGED
|
@@ -3,20 +3,18 @@ import { resolve, basename } from 'node:path';
|
|
|
3
3
|
import c from 'chalk-template';
|
|
4
4
|
|
|
5
5
|
export async function componentize (jsSource, opts) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} catch (e) {
|
|
10
|
-
if (e?.code === 'ERR_MODULE_NOT_FOUND' && e?.message?.includes('\'@bytecodealliance/componentize-js\''))
|
|
11
|
-
throw new Error(`componentize-js must first be installed separately via "npm install @bytecodealliance/componentize-js".`);
|
|
12
|
-
throw e;
|
|
6
|
+
const { componentize: componentizeFn } = await eval('import("@bytecodealliance/componentize-js")');
|
|
7
|
+
if (opts.disable?.includes('all')) {
|
|
8
|
+
opts.disable = ['stdio', 'random', 'clocks', 'http'];
|
|
13
9
|
}
|
|
14
10
|
const source = await readFile(jsSource, 'utf8');
|
|
15
11
|
const { component } = await componentizeFn(source, {
|
|
12
|
+
enableAot: opts.aot,
|
|
16
13
|
sourceName: basename(jsSource),
|
|
17
14
|
witPath: resolve(opts.wit),
|
|
18
15
|
worldName: opts.worldName,
|
|
19
16
|
disableFeatures: opts.disable,
|
|
17
|
+
enableFeatures: opts.enable,
|
|
20
18
|
preview2Adapter: opts.preview2Adapter,
|
|
21
19
|
});
|
|
22
20
|
await writeFile(opts.out, component);
|
package/src/cmd/opt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opt.d.ts","sourceRoot":"","sources":["opt.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"opt.d.ts","sourceRoot":"","sources":["opt.js"],"names":[],"mappings":"AAQA,gFAoCC;AAED;;;;;GAKG;AACH,kDAJW,UAAU,cAER,OAAO,CAAC;IAAE,SAAS,EAAE,UAAU,CAAC;IAAC,eAAe,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAA,CAAE,CA8E7G"}
|
package/src/cmd/opt.js
CHANGED
|
@@ -6,13 +6,6 @@ import c from 'chalk-template';
|
|
|
6
6
|
import { readFile, sizeStr, fixedDigitDisplay, table, spawnIOTmp, setShowSpinner, getShowSpinner } from '../common.js';
|
|
7
7
|
import ora from '#ora';
|
|
8
8
|
|
|
9
|
-
let WASM_OPT;
|
|
10
|
-
try {
|
|
11
|
-
WASM_OPT = fileURLToPath(new URL('../../node_modules/binaryen/bin/wasm-opt', import.meta.url));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
WASM_OPT = new URL('../../node_modules/binaryen/bin/wasm-opt', import.meta.url);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
export async function opt (componentPath, opts, program) {
|
|
17
10
|
await $init;
|
|
18
11
|
const varIdx = program.parent.rawArgs.indexOf('--');
|
|
@@ -139,9 +132,11 @@ export async function optimizeComponent (componentBytes, opts) {
|
|
|
139
132
|
* @param {Uint8Array} source
|
|
140
133
|
* @returns {Promise<Uint8Array>}
|
|
141
134
|
*/
|
|
142
|
-
async function wasmOpt
|
|
135
|
+
async function wasmOpt(source, args = ['-O1', '--low-memory-unused', '--enable-bulk-memory']) {
|
|
136
|
+
const wasmOptPath = fileURLToPath(import.meta.resolve('binaryen/bin/wasm-opt'));
|
|
137
|
+
|
|
143
138
|
try {
|
|
144
|
-
return await spawnIOTmp(
|
|
139
|
+
return await spawnIOTmp(wasmOptPath, source, [
|
|
145
140
|
...args, '-o'
|
|
146
141
|
]);
|
|
147
142
|
} catch (e) {
|
package/src/cmd/run.js
CHANGED
|
@@ -85,9 +85,9 @@ async function runComponent (componentPath, args, opts, executor) {
|
|
|
85
85
|
|
|
86
86
|
await writeFile(resolve(outDir, 'package.json'), JSON.stringify({ type: 'module' }));
|
|
87
87
|
|
|
88
|
-
let preview2ShimPath
|
|
88
|
+
let preview2ShimPath;
|
|
89
89
|
try {
|
|
90
|
-
preview2ShimPath = fileURLToPath(
|
|
90
|
+
preview2ShimPath = resolve(fileURLToPath(import.meta.resolve('@bytecodealliance/preview2-shim')), '../../../');
|
|
91
91
|
} catch {
|
|
92
92
|
throw c`Unable to locate the {bold @bytecodealliance/preview2-shim} package, make sure it is installed.`;
|
|
93
93
|
}
|
|
@@ -130,4 +130,4 @@ async function runComponent (componentPath, args, opts, executor) {
|
|
|
130
130
|
// empty
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
}
|
|
133
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["transpile.js"],"names":[],"mappings":"AAgBA,8DAGC;AAED;;;;;;;;;;;GAWG;AACH,wCAXW,MAAM,QACN;IACV,IAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACrC,SAAa,CAAC,EAAE,IAAI,CAAC;IACrB,MAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAY,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;CAC7B,GACS,OAAO,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC,CA6BvD;AAkBD,sFAwBC;
|
|
1
|
+
{"version":3,"file":"transpile.d.ts","sourceRoot":"","sources":["transpile.js"],"names":[],"mappings":"AAgBA,8DAGC;AAED;;;;;;;;;;;GAWG;AACH,wCAXW,MAAM,QACN;IACV,IAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACrC,SAAa,CAAC,EAAE,IAAI,CAAC;IACrB,MAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAY,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;CAC7B,GACS,OAAO,CAAC;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC,CA6BvD;AAkBD,sFAwBC;AAkBD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,8CAtBW,UAAU,SACV;IACV,IAAQ,EAAE,MAAM,CAAC;IACjB,aAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACrC,cAAkB,CAAC,EAAE,IAAI,GAAG,WAAW,GAAG,QAAQ,GAAG,kBAAkB,CAAC;IACxE,GAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,wBAA4B,CAAC,EAAE,IAAI,CAAC;IACpC,OAAW,CAAC,EAAE,IAAI,CAAC;IACnB,YAAgB,CAAC,EAAE,IAAI,CAAC;IACxB,SAAa,CAAC,EAAE,IAAI,CAAC;IACrB,YAAgB,CAAC,EAAE,IAAI,CAAC;IACxB,EAAM,CAAC,EAAE,IAAI,CAAC;IACd,MAAU,CAAC,EAAE,IAAI,CAAC;IAClB,QAAY,CAAC,EAAE,IAAI,CAAC;IACpB,iBAAqB,CAAC,EAAE,IAAI,CAAC;IAC7B,MAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAe,CAAC,EAAE,IAAI,CAAC;IACvB,sBAA0B,CAAC,EAAE,IAAI,CAAC;IAClC,OAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GACS,OAAO,CAAC;IAAE,KAAK,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC,EAAE,CAAA;CAAE,CAAC,CAoSnI"}
|
package/src/cmd/transpile.js
CHANGED
|
@@ -102,20 +102,15 @@ export async function transpile (componentPath, opts, program) {
|
|
|
102
102
|
await writeFiles(files, opts.quiet ? false : 'Transpiled JS Component Files');
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
let WASM_2_JS;
|
|
106
|
-
try {
|
|
107
|
-
WASM_2_JS = fileURLToPath(new URL('../../node_modules/binaryen/bin/wasm2js', import.meta.url));
|
|
108
|
-
} catch {
|
|
109
|
-
WASM_2_JS = new URL('../../node_modules/binaryen/bin/wasm2js', import.meta.url);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
105
|
/**
|
|
113
106
|
* @param {Uint8Array} source
|
|
114
107
|
* @returns {Promise<Uint8Array>}
|
|
115
108
|
*/
|
|
116
109
|
async function wasm2Js (source) {
|
|
110
|
+
const wasm2jsPath = fileURLToPath(import.meta.resolve('binaryen/bin/wasm2js'));
|
|
111
|
+
|
|
117
112
|
try {
|
|
118
|
-
return await spawnIOTmp(
|
|
113
|
+
return await spawnIOTmp(wasm2jsPath, source, ['-Oz', '-o']);
|
|
119
114
|
} catch (e) {
|
|
120
115
|
if (e.toString().includes('BasicBlock requested'))
|
|
121
116
|
return wasm2Js(source);
|
package/src/jco.js
CHANGED
|
@@ -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.
|
|
14
|
+
.version('1.6.0');
|
|
15
15
|
|
|
16
16
|
function myParseInt(value) {
|
|
17
17
|
return parseInt(value, 10);
|
|
@@ -33,7 +33,9 @@ program.command('componentize')
|
|
|
33
33
|
.argument('<js-source>', 'JS source file to build')
|
|
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
|
+
.addOption(new Option('-d, --disable <feature...>', 'disable WASI features').choices(['clocks', 'http', 'random', 'stdio', 'all']))
|
|
38
|
+
// .addOption(new Option('-e, --enable <feature...>', 'enable WASI features').choices(['http']))
|
|
37
39
|
.option('--preview2-adapter <adapter>', 'provide a custom preview2 adapter path')
|
|
38
40
|
.requiredOption('-o, --out <out>', 'output component file')
|
|
39
41
|
.action(asyncAction(componentize));
|