@bytecodealliance/jco 0.9.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/obj/imports/environment.d.ts +1 -1
  2. package/obj/imports/exit.d.ts +1 -1
  3. package/obj/imports/filesystem.d.ts +1 -1
  4. package/obj/imports/preopens.d.ts +1 -1
  5. package/obj/imports/random.d.ts +1 -1
  6. package/obj/imports/stderr.d.ts +1 -1
  7. package/obj/imports/stdin.d.ts +1 -1
  8. package/obj/imports/stdout.d.ts +1 -1
  9. package/obj/imports/streams.d.ts +1 -1
  10. package/obj/imports/wall-clock.d.ts +1 -1
  11. package/obj/js-component-bindgen-component.core.wasm +0 -0
  12. package/obj/js-component-bindgen-component.d.ts +56 -10
  13. package/obj/wasm-tools.d.ts +44 -10
  14. package/package.json +1 -1
  15. package/src/api.js +31 -8
  16. package/src/jco.js +1 -1
  17. package/obj/imports/cli-base-environment.d.ts +0 -3
  18. package/obj/imports/cli-base-exit.d.ts +0 -4
  19. package/obj/imports/cli-base-preopens.d.ts +0 -5
  20. package/obj/imports/cli-base-stderr.d.ts +0 -5
  21. package/obj/imports/cli-base-stdin.d.ts +0 -5
  22. package/obj/imports/cli-base-stdout.d.ts +0 -5
  23. package/obj/imports/clocks-wall-clock.d.ts +0 -6
  24. package/obj/imports/filesystem-filesystem.d.ts +0 -152
  25. package/obj/imports/io-streams.d.ts +0 -12
  26. package/obj/imports/random-random.d.ts +0 -3
  27. package/obj/imports/wasi:cli-base/environment.d.ts +0 -3
  28. package/obj/imports/wasi:cli-base/exit.d.ts +0 -4
  29. package/obj/imports/wasi:cli-base/preopens.d.ts +0 -5
  30. package/obj/imports/wasi:cli-base/stderr.d.ts +0 -5
  31. package/obj/imports/wasi:cli-base/stdin.d.ts +0 -5
  32. package/obj/imports/wasi:cli-base/stdout.d.ts +0 -5
  33. package/obj/imports/wasi:clocks/wall-clock.d.ts +0 -6
  34. package/obj/imports/wasi:filesystem/filesystem.d.ts +0 -152
  35. package/obj/imports/wasi:io/streams.d.ts +0 -12
  36. package/obj/imports/wasi:random/random.d.ts +0 -3
@@ -1,3 +1,3 @@
1
- export namespace Environment {
1
+ export namespace ImportsEnvironment {
2
2
  export function getEnvironment(): [string, string][];
3
3
  }
@@ -1,4 +1,4 @@
1
- export namespace Exit {
1
+ export namespace ImportsExit {
2
2
  export function exit(status: Result<void, void>): void;
3
3
  }
4
4
  export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -1,4 +1,4 @@
1
- export namespace Filesystem {
1
+ export namespace ImportsFilesystem {
2
2
  export function readViaStream(this: Descriptor, offset: Filesize): InputStream;
3
3
  export function writeViaStream(this: Descriptor, offset: Filesize): OutputStream;
4
4
  export function appendViaStream(this: Descriptor): OutputStream;
@@ -1,4 +1,4 @@
1
- export namespace Preopens {
1
+ export namespace ImportsPreopens {
2
2
  export function getDirectories(): [Descriptor, string][];
3
3
  }
4
4
  import type { Descriptor } from '../imports/filesystem';
@@ -1,3 +1,3 @@
1
- export namespace Random {
1
+ export namespace ImportsRandom {
2
2
  export function getRandomBytes(len: bigint): Uint8Array | ArrayBuffer;
3
3
  }
@@ -1,4 +1,4 @@
1
- export namespace Stderr {
1
+ export namespace ImportsStderr {
2
2
  export function getStderr(): OutputStream;
3
3
  }
4
4
  import type { OutputStream } from '../imports/streams';
@@ -1,4 +1,4 @@
1
- export namespace Stdin {
1
+ export namespace ImportsStdin {
2
2
  export function getStdin(): InputStream;
3
3
  }
4
4
  import type { InputStream } from '../imports/streams';
@@ -1,4 +1,4 @@
1
- export namespace Stdout {
1
+ export namespace ImportsStdout {
2
2
  export function getStdout(): OutputStream;
3
3
  }
4
4
  import type { OutputStream } from '../imports/streams';
@@ -1,4 +1,4 @@
1
- export namespace Streams {
1
+ export namespace ImportsStreams {
2
2
  export function read(this: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
3
3
  export function blockingRead(this: InputStream, len: bigint): [Uint8Array | ArrayBuffer, boolean];
4
4
  export function dropInputStream(this: InputStream): void;
@@ -1,4 +1,4 @@
1
- export namespace WallClock {
1
+ export namespace ImportsWallClock {
2
2
  }
3
3
  export interface Datetime {
4
4
  seconds: bigint,
@@ -1,13 +1,59 @@
1
- import { Environment as EnvironmentImports } from './imports/environment';
2
- import { Exit as ExitImports } from './imports/exit';
3
- import { Preopens as PreopensImports } from './imports/preopens';
4
- import { Stderr as StderrImports } from './imports/stderr';
5
- import { Stdin as StdinImports } from './imports/stdin';
6
- import { Stdout as StdoutImports } from './imports/stdout';
7
- import { WallClock as WallClockImports } from './imports/wall-clock';
8
- import { Filesystem as FilesystemImports } from './imports/filesystem';
9
- import { Streams as StreamsImports } from './imports/streams';
10
- import { Random as RandomImports } from './imports/random';
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';
11
57
  export function generate(component: Uint8Array | ArrayBuffer, options: GenerateOptions): Transpiled;
12
58
  export function generateTypes(name: string, options: TypeGenerationOptions): Files;
13
59
 
@@ -1,13 +1,47 @@
1
- import { Environment as EnvironmentImports } from './imports/environment';
2
- import { Exit as ExitImports } from './imports/exit';
3
- import { Preopens as PreopensImports } from './imports/preopens';
4
- import { Stderr as StderrImports } from './imports/stderr';
5
- import { Stdin as StdinImports } from './imports/stdin';
6
- import { Stdout as StdoutImports } from './imports/stdout';
7
- import { WallClock as WallClockImports } from './imports/wall-clock';
8
- import { Filesystem as FilesystemImports } from './imports/filesystem';
9
- import { Streams as StreamsImports } from './imports/streams';
10
- import { Random as RandomImports } from './imports/random';
1
+ /**
2
+ * # Variants
3
+ *
4
+ * ## `"utf8"`
5
+ *
6
+ * ## `"utf16"`
7
+ *
8
+ * ## `"compact-utf16"`
9
+ */
10
+ export type StringEncoding = 'utf8' | 'utf16' | 'compact-utf16';
11
+ export type ProducersFields = [string, [string, string][]][];
12
+ export type ModuleMetaType = ModuleMetaTypeModule | ModuleMetaTypeComponent;
13
+ export interface ModuleMetaTypeModule {
14
+ tag: 'module',
15
+ }
16
+ export interface ModuleMetaTypeComponent {
17
+ tag: 'component',
18
+ val: number,
19
+ }
20
+ export interface ModuleMetadata {
21
+ name?: string,
22
+ metaType: ModuleMetaType,
23
+ range: [number, number],
24
+ producers: ProducersFields,
25
+ }
26
+ export interface EmbedOpts {
27
+ binary?: Uint8Array,
28
+ witSource?: string,
29
+ witPath?: string,
30
+ stringEncoding?: StringEncoding,
31
+ dummy?: boolean,
32
+ world?: string,
33
+ metadata?: ProducersFields,
34
+ }
35
+ import { ImportsEnvironment } from './imports/environment';
36
+ import { ImportsExit } from './imports/exit';
37
+ import { ImportsPreopens } from './imports/preopens';
38
+ import { ImportsStderr } from './imports/stderr';
39
+ import { ImportsStdin } from './imports/stdin';
40
+ import { ImportsStdout } from './imports/stdout';
41
+ import { ImportsWallClock } from './imports/wall-clock';
42
+ import { ImportsFilesystem } from './imports/filesystem';
43
+ import { ImportsStreams } from './imports/streams';
44
+ import { ImportsRandom } from './imports/random';
11
45
  export function parse(wat: string): Uint8Array;
12
46
  export function print(binary: Uint8Array | ArrayBuffer): string;
13
47
  export function componentNew(binary: Uint8Array | ArrayBuffer, adapters: [string, Uint8Array | ArrayBuffer][] | null): Uint8Array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytecodealliance/jco",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "JavaScript tooling for working with WebAssembly Components",
5
5
  "author": "Guy Bedford",
6
6
  "bin": {
package/src/api.js CHANGED
@@ -2,37 +2,60 @@ export { optimizeComponent as opt } from './cmd/opt.js';
2
2
  export { transpileComponent as transpile } from './cmd/transpile.js';
3
3
  import { $init, print as printFn, parse as parseFn, componentWit as componentWitFn, componentNew as componentNewFn, componentEmbed as componentEmbedFn, metadataAdd as metadataAddFn, metadataShow as metadataShowFn } from "../obj/wasm-tools.js";
4
4
 
5
- /** @type {import('../obj/wasm-tools.js').print} */
5
+ /**
6
+ * @param {Parameters<import('../obj/wasm-tools.js').print>[0]} binary
7
+ * @return {Promise<ReturnType<import('../obj/wasm-tools.js').print>>}
8
+ */
6
9
  export async function print (binary) {
7
10
  await $init;
8
11
  return printFn(binary);
9
12
  }
10
- /** @type {import('../obj/wasm-tools.js').parse} */
13
+ /**
14
+ * @param {Parameters<import('../obj/wasm-tools.js').parse>[0]} wat
15
+ * @return {Promise<ReturnType<import('../obj/wasm-tools.js').parse>>}
16
+ */
11
17
  export async function parse (wat) {
12
18
  await $init;
13
19
  return parseFn(wat);
14
20
  }
15
- /** @type {import('../obj/wasm-tools.js').componentWit} */
21
+ /**
22
+ * @param {Parameters<import('../obj/wasm-tools.js').componentWit>[0]} binary
23
+ * @return {Promise<ReturnType<import('../obj/wasm-tools.js').componentWit>>}
24
+ */
16
25
  export async function componentWit (binary) {
17
26
  await $init;
18
27
  return componentWitFn(binary);
19
28
  }
20
- /** @type {import('../obj/wasm-tools.js').componentNew} */
29
+ /**
30
+ * @param {Parameters<import('../obj/wasm-tools.js').componentNew>[0]} binary
31
+ * @param {Parameters<import('../obj/wasm-tools.js').componentNew>[1]} adapters
32
+ * @return {Promise<ReturnType<import('../obj/wasm-tools.js').componentNew>>}
33
+ */
21
34
  export async function componentNew (binary, adapters) {
22
35
  await $init;
23
36
  return componentNewFn(binary, adapters);
24
37
  }
25
- /** @type {import('../obj/wasm-tools.js').componentEmbed} */
38
+ /**
39
+ * @param {Parameters<import('../obj/wasm-tools.js').componentEmbed>[0]} embedOpts
40
+ * @return {Promise<ReturnType<import('../obj/wasm-tools.js').componentEmbed>>}
41
+ */
26
42
  export async function componentEmbed (embedOpts) {
27
43
  await $init;
28
44
  return componentEmbedFn(embedOpts);
29
45
  }
30
- /** @type {import('../obj/wasm-tools.js').metadataAdd} */
31
- export async function metadataAdd () {
46
+ /**
47
+ * @param {Parameters<import('../obj/wasm-tools.js').metadataAdd>[0]} binary
48
+ * @param {Parameters<import('../obj/wasm-tools.js').metadataAdd>[1]} metadata
49
+ * @return {Promise<ReturnType<import('../obj/wasm-tools.js').metadataAdd>>}
50
+ */
51
+ export async function metadataAdd (binary, metadata) {
32
52
  await $init;
33
53
  return metadataAddFn(binary, metadata);
34
54
  }
35
- /** @type {import('../obj/wasm-tools.js').metadataShow} */
55
+ /**
56
+ * @param {Parameters<import('../obj/wasm-tools.js').metadataShow>[0]} binary
57
+ * @return {Promise<ReturnType<import('../obj/wasm-tools.js').metadataShow>>}
58
+ */
36
59
  export async function metadataShow (binary) {
37
60
  await $init;
38
61
  return metadataShowFn(binary);
package/src/jco.js CHANGED
@@ -10,7 +10,7 @@ program
10
10
  .name('jco')
11
11
  .description(c`{bold jco - WebAssembly JS Component Tools}\n JS Component Transpilation Bindgen & Wasm Tools for JS`)
12
12
  .usage('<command> [options]')
13
- .version('0.8.0');
13
+ .version('0.9.1');
14
14
 
15
15
  function myParseInt(value) {
16
16
  return parseInt(value, 10);
@@ -1,3 +0,0 @@
1
- export namespace CliBaseEnvironment {
2
- export function getEnvironment(): [string, string][];
3
- }
@@ -1,4 +0,0 @@
1
- export namespace CliBaseExit {
2
- export function exit(status: Result<void, void>): void;
3
- }
4
- export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -1,5 +0,0 @@
1
- export namespace CliBasePreopens {
2
- export function getDirectories(): [Descriptor, string][];
3
- }
4
- import type { Descriptor } from '../imports/filesystem';
5
- export { Descriptor };
@@ -1,5 +0,0 @@
1
- export namespace CliBaseStderr {
2
- export function getStderr(): OutputStream;
3
- }
4
- import type { OutputStream } from '../imports/streams';
5
- export { OutputStream };
@@ -1,5 +0,0 @@
1
- export namespace CliBaseStdin {
2
- export function getStdin(): InputStream;
3
- }
4
- import type { InputStream } from '../imports/streams';
5
- export { InputStream };
@@ -1,5 +0,0 @@
1
- export namespace CliBaseStdout {
2
- export function getStdout(): OutputStream;
3
- }
4
- import type { OutputStream } from '../imports/streams';
5
- export { OutputStream };
@@ -1,6 +0,0 @@
1
- export namespace ClocksWallClock {
2
- }
3
- export interface Datetime {
4
- seconds: bigint,
5
- nanoseconds: number,
6
- }
@@ -1,152 +0,0 @@
1
- export namespace FilesystemFilesystem {
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;
@@ -1,12 +0,0 @@
1
- export namespace IoStreams {
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;
@@ -1,3 +0,0 @@
1
- export namespace RandomRandom {
2
- export function getRandomBytes(len: bigint): Uint8Array | ArrayBuffer;
3
- }
@@ -1,3 +0,0 @@
1
- export namespace Wasi:cliBaseEnvironment {
2
- export function getEnvironment(): [string, string][];
3
- }
@@ -1,4 +0,0 @@
1
- export namespace Wasi:cliBaseExit {
2
- export function exit(status: Result<void, void>): void;
3
- }
4
- export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -1,5 +0,0 @@
1
- export namespace Wasi:cliBasePreopens {
2
- export function getDirectories(): [Descriptor, string][];
3
- }
4
- import type { Descriptor } from '../imports/filesystem';
5
- export { Descriptor };
@@ -1,5 +0,0 @@
1
- export namespace Wasi:cliBaseStderr {
2
- export function getStderr(): OutputStream;
3
- }
4
- import type { OutputStream } from '../imports/streams';
5
- export { OutputStream };
@@ -1,5 +0,0 @@
1
- export namespace Wasi:cliBaseStdin {
2
- export function getStdin(): InputStream;
3
- }
4
- import type { InputStream } from '../imports/streams';
5
- export { InputStream };
@@ -1,5 +0,0 @@
1
- export namespace Wasi:cliBaseStdout {
2
- export function getStdout(): OutputStream;
3
- }
4
- import type { OutputStream } from '../imports/streams';
5
- export { OutputStream };
@@ -1,6 +0,0 @@
1
- export namespace Wasi:clocksWallClock {
2
- }
3
- export interface Datetime {
4
- seconds: bigint,
5
- nanoseconds: number,
6
- }
@@ -1,152 +0,0 @@
1
- export namespace Wasi:filesystemFilesystem {
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;
@@ -1,12 +0,0 @@
1
- export namespace Wasi:ioStreams {
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;
@@ -1,3 +0,0 @@
1
- export namespace Wasi:randomRandom {
2
- export function getRandomBytes(len: bigint): Uint8Array | ArrayBuffer;
3
- }