@bytecodealliance/jco 0.8.0 → 0.9.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 (36) hide show
  1. package/LICENSE +220 -0
  2. package/README.md +38 -14
  3. package/lib/console.js +7 -0
  4. package/obj/imports/environment.d.ts +3 -0
  5. package/obj/imports/exit.d.ts +4 -0
  6. package/obj/imports/filesystem.d.ts +152 -0
  7. package/obj/imports/preopens.d.ts +5 -0
  8. package/obj/imports/random.d.ts +3 -0
  9. package/obj/imports/stderr.d.ts +5 -0
  10. package/obj/imports/stdin.d.ts +5 -0
  11. package/obj/imports/stdout.d.ts +5 -0
  12. package/obj/imports/streams.d.ts +12 -0
  13. package/obj/imports/wall-clock.d.ts +6 -0
  14. package/{js-component-bindgen-component.core.wasm → obj/js-component-bindgen-component.core.wasm} +0 -0
  15. package/obj/js-component-bindgen-component.d.ts +60 -0
  16. package/obj/js-component-bindgen-component.js +2036 -0
  17. package/obj/wasm-tools.d.ts +53 -0
  18. package/obj/wasm-tools.js +2236 -0
  19. package/package.json +36 -6
  20. package/src/api.js +68 -0
  21. package/src/cmd/componentize.js +21 -0
  22. package/src/cmd/opt.js +151 -0
  23. package/src/cmd/transpile.js +366 -0
  24. package/src/cmd/wasm-tools.js +114 -0
  25. package/src/common.js +104 -0
  26. package/src/jco.js +129 -0
  27. package/api.d.ts +0 -109
  28. package/api.mjs +0 -46035
  29. package/cli.mjs +0 -49700
  30. package/wasm-opt +0 -2
  31. package/wasm2js +0 -2
  32. /package/{wasi_snapshot_preview1.command.wasm → lib/wasi_snapshot_preview1.command.wasm} +0 -0
  33. /package/{wasi_snapshot_preview1.reactor.wasm → lib/wasi_snapshot_preview1.reactor.wasm} +0 -0
  34. /package/{js-component-bindgen-component.core2.wasm → obj/js-component-bindgen-component.core2.wasm} +0 -0
  35. /package/{wasm-tools.core.wasm → obj/wasm-tools.core.wasm} +0 -0
  36. /package/{wasm-tools.core2.wasm → obj/wasm-tools.core2.wasm} +0 -0
package/LICENSE ADDED
@@ -0,0 +1,220 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+
205
+ --- LLVM Exceptions to the Apache 2.0 License ----
206
+
207
+ As an exception, if, as a result of your compiling your source code, portions
208
+ of this Software are embedded into an Object form of such source code, you
209
+ may redistribute such embedded portions in such Object form without complying
210
+ with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
211
+
212
+ In addition, if you combine or link compiled forms of this Software with
213
+ software that is licensed under the GPLv2 ("Combined Software") and if a
214
+ court of competent jurisdiction determines that the patent provision (Section
215
+ 3), the indemnity provision (Section 9) or other Section of the License
216
+ conflicts with the conditions of the GPLv2, you may retroactively and
217
+ prospectively choose to deem waived or otherwise exclude such Section(s) of
218
+ the License, but only in their entirety and only with respect to the Combined
219
+ Software.
220
+
package/README.md CHANGED
@@ -65,6 +65,44 @@ Commands:
65
65
  help [command] display help for command
66
66
  ```
67
67
 
68
+ For help with individual command options, use `jco <cmd> --help`.
69
+
70
+ ### Transpile
71
+
72
+ To transpile a component into JS:
73
+
74
+ ```
75
+ jco transpile component.wasm -o out-dir
76
+ ```
77
+
78
+ The resultant file can be imported providing the bindings of the component as if it were imported directly:
79
+
80
+ app.js
81
+ ```
82
+ import { fn } from './out-dir/component.js';
83
+
84
+ fn();
85
+ ```
86
+
87
+ Imports can be remapped using the `--map` flag, or to provide imports as an argument use the `--instantiation` option.
88
+
89
+ Components relying on WASI bindings will contain external WASI imports, which are automatically updated
90
+ to the `@bytecodealliance/preview-shim` package. This package can be installed from npm separately for
91
+ runtime usage. This shim layer supports both Node.js and browsers.
92
+
93
+ Options include:
94
+ * `--name`: Give a custom name for the component JS file in `out-dir/[name].js`
95
+ * `--minify`: Minify the component JS
96
+ * `--optimize`: Runs the internal core Wasm files through Binaryen for optimization. Optimization options can be passed with a `-- <binaryen options>` flag separator.
97
+ * `--tla-compat`: Instead of relying on top-level-await, requires an `$init` promise to be imported and awaited first.
98
+ * `--js`: Converts core Wasm files to JavaScript for environments that don't even support core Wasm.
99
+ * `--base64-cutoff=<number>`: Sets the maximum number of bytes for inlining Wasm files into the JS using base64 encoding. Set to zero to disable base64 inlining entirely.
100
+ * `--no-wasi-shim`: Disable the WASI shim mapping to `@bytecodealliance/preview2-shim`.
101
+ * `--map`: Provide custom mappings for world imports. Supports both wildcard mappings (`*` similarly as in the package.json "exports" field) as well as `#` mappings for targetting exported interfaces. For example, the WASI mappings are internally defined with mappings like `--map wasi:filesystem/*=@bytecodealliance/preview2-shim/filesystem#*` to map `import as * filesystem from 'wasi:filesystem/filesystem'` to `import { filesystem } from '@bytecodealliance/preview2-shim/filesystem`.
102
+ * `--no-nodejs-compat`: Disables Node.js compat in the output to load core Wasm with FS methods.
103
+ * `--instantiation`: Instead of a direct ES module, export an `instantiate` function which can take the imports as an argument instead of implicit imports.
104
+ * `--valid-lifting-optimization`: Internal validations are removed assuming that core Wasm binaries are valid components, providing a minor output size saving.
105
+
68
106
  ### Componentize
69
107
 
70
108
  To componentize a JS file run:
@@ -87,20 +125,6 @@ See [ComponentizeJS](https://github.com/bytecodealliance/componentize-js) for mo
87
125
 
88
126
  Transpile a Component to JS.
89
127
 
90
- **Transpilation options:**
91
-
92
- * `name?: string` - name for the generated JS file.
93
- * `instantiation?: bool` - instead of a direct ES module, output the raw instantiation function for custom virtualization.
94
- * `map?: Record<string, string>` - remap component imports
95
- * `validLiftingOptimization?: bool` - optimization to reduce code size
96
- * `noNodejsCompat?: bool` - disables Node.js compatible output
97
- * `tlaCompat?: bool` - enable compat in JS runtimes without TLA support
98
- * `base64Cutoff?: number` - size in bytes, under which Wasm modules get inlined as base64.
99
- * `js?: bool` - convert Wasm into JS instead for execution compatibility in JS environments without Wasm support.
100
- * `minify?: bool` - minify the output JS.
101
- * `optimize?: bool` - optimize the component with Binaryen wasm-opt first.
102
- * `optArgs?: string[]` - if using optimize, custom optimization options (defaults to best optimization, but this is very slow)
103
-
104
128
  #### `opt(component: Uint8Array, opts?): Promise<{ component: Uint8Array }>`
105
129
 
106
130
  Optimize a Component with the [Binaryen Wasm-opt](https://www.npmjs.com/package/binaryen) project.
package/lib/console.js ADDED
@@ -0,0 +1,7 @@
1
+ export function log(msg) {
2
+ console.log(msg);
3
+ }
4
+
5
+ export function error(msg) {
6
+ console.error(msg);
7
+ }
@@ -0,0 +1,3 @@
1
+ export namespace ImportsEnvironment {
2
+ export function getEnvironment(): [string, string][];
3
+ }
@@ -0,0 +1,4 @@
1
+ export namespace ImportsExit {
2
+ export function exit(status: Result<void, void>): void;
3
+ }
4
+ export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -0,0 +1,152 @@
1
+ export namespace ImportsFilesystem {
2
+ export function readViaStream(this: Descriptor, offset: Filesize): InputStream;
3
+ export function writeViaStream(this: Descriptor, offset: Filesize): OutputStream;
4
+ export function appendViaStream(this: Descriptor): OutputStream;
5
+ export function getType(this: Descriptor): DescriptorType;
6
+ export function stat(this: Descriptor): DescriptorStat;
7
+ export function openAt(this: Descriptor, pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags, modes: Modes): Descriptor;
8
+ export function dropDescriptor(this: Descriptor): void;
9
+ export function dropDirectoryEntryStream(this: DirectoryEntryStream): void;
10
+ }
11
+ export type Descriptor = number;
12
+ export type Filesize = bigint;
13
+ import type { InputStream } from '../imports/streams';
14
+ export { InputStream };
15
+ /**
16
+ * # Variants
17
+ *
18
+ * ## `"access"`
19
+ *
20
+ * ## `"would-block"`
21
+ *
22
+ * ## `"already"`
23
+ *
24
+ * ## `"bad-descriptor"`
25
+ *
26
+ * ## `"busy"`
27
+ *
28
+ * ## `"deadlock"`
29
+ *
30
+ * ## `"quota"`
31
+ *
32
+ * ## `"exist"`
33
+ *
34
+ * ## `"file-too-large"`
35
+ *
36
+ * ## `"illegal-byte-sequence"`
37
+ *
38
+ * ## `"in-progress"`
39
+ *
40
+ * ## `"interrupted"`
41
+ *
42
+ * ## `"invalid"`
43
+ *
44
+ * ## `"io"`
45
+ *
46
+ * ## `"is-directory"`
47
+ *
48
+ * ## `"loop"`
49
+ *
50
+ * ## `"too-many-links"`
51
+ *
52
+ * ## `"message-size"`
53
+ *
54
+ * ## `"name-too-long"`
55
+ *
56
+ * ## `"no-device"`
57
+ *
58
+ * ## `"no-entry"`
59
+ *
60
+ * ## `"no-lock"`
61
+ *
62
+ * ## `"insufficient-memory"`
63
+ *
64
+ * ## `"insufficient-space"`
65
+ *
66
+ * ## `"not-directory"`
67
+ *
68
+ * ## `"not-empty"`
69
+ *
70
+ * ## `"not-recoverable"`
71
+ *
72
+ * ## `"unsupported"`
73
+ *
74
+ * ## `"no-tty"`
75
+ *
76
+ * ## `"no-such-device"`
77
+ *
78
+ * ## `"overflow"`
79
+ *
80
+ * ## `"not-permitted"`
81
+ *
82
+ * ## `"pipe"`
83
+ *
84
+ * ## `"read-only"`
85
+ *
86
+ * ## `"invalid-seek"`
87
+ *
88
+ * ## `"text-file-busy"`
89
+ *
90
+ * ## `"cross-device"`
91
+ */
92
+ export type ErrorCode = 'access' | 'would-block' | 'already' | 'bad-descriptor' | 'busy' | 'deadlock' | 'quota' | 'exist' | 'file-too-large' | 'illegal-byte-sequence' | 'in-progress' | 'interrupted' | 'invalid' | 'io' | 'is-directory' | 'loop' | 'too-many-links' | 'message-size' | 'name-too-long' | 'no-device' | 'no-entry' | 'no-lock' | 'insufficient-memory' | 'insufficient-space' | 'not-directory' | 'not-empty' | 'not-recoverable' | 'unsupported' | 'no-tty' | 'no-such-device' | 'overflow' | 'not-permitted' | 'pipe' | 'read-only' | 'invalid-seek' | 'text-file-busy' | 'cross-device';
93
+ import type { OutputStream } from '../imports/streams';
94
+ export { OutputStream };
95
+ /**
96
+ * # Variants
97
+ *
98
+ * ## `"unknown"`
99
+ *
100
+ * ## `"block-device"`
101
+ *
102
+ * ## `"character-device"`
103
+ *
104
+ * ## `"directory"`
105
+ *
106
+ * ## `"fifo"`
107
+ *
108
+ * ## `"symbolic-link"`
109
+ *
110
+ * ## `"regular-file"`
111
+ *
112
+ * ## `"socket"`
113
+ */
114
+ export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
115
+ export type Device = bigint;
116
+ export type Inode = bigint;
117
+ export type LinkCount = bigint;
118
+ import type { Datetime } from '../imports/wall-clock';
119
+ export { Datetime };
120
+ export interface DescriptorStat {
121
+ device: Device,
122
+ inode: Inode,
123
+ type: DescriptorType,
124
+ linkCount: LinkCount,
125
+ size: Filesize,
126
+ dataAccessTimestamp: Datetime,
127
+ dataModificationTimestamp: Datetime,
128
+ statusChangeTimestamp: Datetime,
129
+ }
130
+ export interface PathFlags {
131
+ symlinkFollow?: boolean,
132
+ }
133
+ export interface OpenFlags {
134
+ create?: boolean,
135
+ directory?: boolean,
136
+ exclusive?: boolean,
137
+ truncate?: boolean,
138
+ }
139
+ export interface DescriptorFlags {
140
+ read?: boolean,
141
+ write?: boolean,
142
+ fileIntegritySync?: boolean,
143
+ dataIntegritySync?: boolean,
144
+ requestedWriteSync?: boolean,
145
+ mutateDirectory?: boolean,
146
+ }
147
+ export interface Modes {
148
+ readable?: boolean,
149
+ writable?: boolean,
150
+ executable?: boolean,
151
+ }
152
+ export type DirectoryEntryStream = number;
@@ -0,0 +1,5 @@
1
+ export namespace ImportsPreopens {
2
+ export function getDirectories(): [Descriptor, string][];
3
+ }
4
+ import type { Descriptor } from '../imports/filesystem';
5
+ export { Descriptor };
@@ -0,0 +1,3 @@
1
+ export namespace ImportsRandom {
2
+ export function getRandomBytes(len: bigint): Uint8Array | ArrayBuffer;
3
+ }
@@ -0,0 +1,5 @@
1
+ export namespace ImportsStderr {
2
+ export function getStderr(): OutputStream;
3
+ }
4
+ import type { OutputStream } from '../imports/streams';
5
+ export { OutputStream };
@@ -0,0 +1,5 @@
1
+ export namespace ImportsStdin {
2
+ export function getStdin(): InputStream;
3
+ }
4
+ import type { InputStream } from '../imports/streams';
5
+ export { InputStream };
@@ -0,0 +1,5 @@
1
+ export namespace ImportsStdout {
2
+ export function getStdout(): OutputStream;
3
+ }
4
+ import type { OutputStream } from '../imports/streams';
5
+ export { OutputStream };
@@ -0,0 +1,12 @@
1
+ export namespace ImportsStreams {
2
+ export function read(this: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
3
+ export function blockingRead(this: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
4
+ export function dropInputStream(this: InputStream): void;
5
+ export function write(this: OutputStream, buf: Uint8Array): bigint;
6
+ export function blockingWrite(this: OutputStream, buf: Uint8Array): bigint;
7
+ export function dropOutputStream(this: OutputStream): void;
8
+ }
9
+ export type InputStream = number;
10
+ export interface StreamError {
11
+ }
12
+ export type OutputStream = number;
@@ -0,0 +1,6 @@
1
+ export namespace ImportsWallClock {
2
+ }
3
+ export interface Datetime {
4
+ seconds: bigint,
5
+ nanoseconds: number,
6
+ }
@@ -0,0 +1,60 @@
1
+ export type Wit = WitSource | WitBinary | WitPath;
2
+ export interface WitSource {
3
+ tag: 'source',
4
+ val: string,
5
+ }
6
+ export interface WitBinary {
7
+ tag: 'binary',
8
+ val: Uint8Array,
9
+ }
10
+ export interface WitPath {
11
+ tag: 'path',
12
+ val: string,
13
+ }
14
+ export type Maps = [string, string][];
15
+ export interface TypeGenerationOptions {
16
+ wit: Wit,
17
+ world?: string,
18
+ tlaCompat?: boolean,
19
+ instantiation?: boolean,
20
+ map?: Maps,
21
+ }
22
+ export interface GenerateOptions {
23
+ name: string,
24
+ noTypescript?: boolean,
25
+ instantiation?: boolean,
26
+ map?: Maps,
27
+ compat?: boolean,
28
+ noNodejsCompat?: boolean,
29
+ base64Cutoff?: number,
30
+ tlaCompat?: boolean,
31
+ validLiftingOptimization?: boolean,
32
+ }
33
+ export type Files = [string, Uint8Array][];
34
+ /**
35
+ * # Variants
36
+ *
37
+ * ## `"function"`
38
+ *
39
+ * ## `"instance"`
40
+ */
41
+ export type ExportType = 'function' | 'instance';
42
+ export interface Transpiled {
43
+ files: Files,
44
+ imports: string[],
45
+ exports: [string, ExportType][],
46
+ }
47
+ import { ImportsEnvironment } from './imports/environment';
48
+ import { ImportsExit } from './imports/exit';
49
+ import { ImportsPreopens } from './imports/preopens';
50
+ import { ImportsStderr } from './imports/stderr';
51
+ import { ImportsStdin } from './imports/stdin';
52
+ import { ImportsStdout } from './imports/stdout';
53
+ import { ImportsWallClock } from './imports/wall-clock';
54
+ import { ImportsFilesystem } from './imports/filesystem';
55
+ import { ImportsStreams } from './imports/streams';
56
+ import { ImportsRandom } from './imports/random';
57
+ export function generate(component: Uint8Array | ArrayBuffer, options: GenerateOptions): Transpiled;
58
+ export function generateTypes(name: string, options: TypeGenerationOptions): Files;
59
+
60
+ export const $init: Promise<void>;