md-spreadsheet-parser 1.0.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.
Files changed (49) hide show
  1. package/README.md +158 -0
  2. package/dist/interfaces/example-spreadsheet-types.d.ts +50 -0
  3. package/dist/interfaces/exports.d.ts +100 -0
  4. package/dist/interfaces/wasi-cli-environment.d.ts +4 -0
  5. package/dist/interfaces/wasi-cli-exit.d.ts +3 -0
  6. package/dist/interfaces/wasi-cli-stderr.d.ts +3 -0
  7. package/dist/interfaces/wasi-cli-stdin.d.ts +3 -0
  8. package/dist/interfaces/wasi-cli-stdout.d.ts +3 -0
  9. package/dist/interfaces/wasi-cli-terminal-input.d.ts +8 -0
  10. package/dist/interfaces/wasi-cli-terminal-output.d.ts +8 -0
  11. package/dist/interfaces/wasi-cli-terminal-stderr.d.ts +3 -0
  12. package/dist/interfaces/wasi-cli-terminal-stdin.d.ts +3 -0
  13. package/dist/interfaces/wasi-cli-terminal-stdout.d.ts +3 -0
  14. package/dist/interfaces/wasi-clocks-monotonic-clock.d.ts +8 -0
  15. package/dist/interfaces/wasi-clocks-wall-clock.d.ts +7 -0
  16. package/dist/interfaces/wasi-filesystem-preopens.d.ts +3 -0
  17. package/dist/interfaces/wasi-filesystem-types.d.ts +208 -0
  18. package/dist/interfaces/wasi-io-error.d.ts +9 -0
  19. package/dist/interfaces/wasi-io-poll.d.ts +11 -0
  20. package/dist/interfaces/wasi-io-streams.d.ts +40 -0
  21. package/dist/interfaces/wasi-random-insecure-seed.d.ts +2 -0
  22. package/dist/interfaces/wasi-random-insecure.d.ts +3 -0
  23. package/dist/interfaces/wasi-random-random.d.ts +3 -0
  24. package/dist/interfaces/wasi-sockets-instance-network.d.ts +3 -0
  25. package/dist/interfaces/wasi-sockets-ip-name-lookup.d.ts +15 -0
  26. package/dist/interfaces/wasi-sockets-network.d.ts +92 -0
  27. package/dist/interfaces/wasi-sockets-tcp-create-socket.d.ts +5 -0
  28. package/dist/interfaces/wasi-sockets-tcp.d.ts +54 -0
  29. package/dist/interfaces/wasi-sockets-udp-create-socket.d.ts +5 -0
  30. package/dist/interfaces/wasi-sockets-udp.d.ts +53 -0
  31. package/dist/parser.core.wasm +0 -0
  32. package/dist/parser.core2.wasm +0 -0
  33. package/dist/parser.core3.wasm +0 -0
  34. package/dist/parser.core4.wasm +0 -0
  35. package/dist/parser.core5.wasm +0 -0
  36. package/dist/parser.core6.wasm +0 -0
  37. package/dist/parser.core7.wasm +0 -0
  38. package/dist/parser.core8.wasm +0 -0
  39. package/dist/parser.core9.wasm +0 -0
  40. package/dist/parser.d.ts +68 -0
  41. package/dist/parser.js +28872 -0
  42. package/dist/parser.wasm +0 -0
  43. package/package.json +36 -0
  44. package/src/__pycache__/app.cpython-314.pyc +0 -0
  45. package/src/__pycache__/generated_adapter.cpython-314.pyc +0 -0
  46. package/src/app.py +164 -0
  47. package/src/client-adapters.ts +40 -0
  48. package/src/generated_adapter.py +247 -0
  49. package/src/index.ts +317 -0
package/README.md ADDED
@@ -0,0 +1,158 @@
1
+ # md-spreadsheet-parser (NPM)
2
+
3
+ <p align="center">
4
+ <img src="https://img.shields.io/badge/wasm-powered-purple.svg" alt="WASM Powered" />
5
+ <a href="https://github.com/f-y/md-spreadsheet-parser/blob/main/LICENSE">
6
+ <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License" />
7
+ </a>
8
+ </p>
9
+
10
+ **md-spreadsheet-parser** is a robust, zero-dependency Markdown table parser and manipulator for Node.js.
11
+ It is powered by the [Python Core](https://github.com/f-y/md-spreadsheet-parser) compiled to WebAssembly, ensuring 100% logic parity with the Python version while running natively in Node.js.
12
+
13
+ ## Features
14
+
15
+ - **🚀 High Performance**: Pre-compiled WASM binary (initialized in ~160ms).
16
+ - **💪 Robust Parsing**: Handles GFM tables, missing columns, and escaped pipes correctly.
17
+ - **🛠️ Spreadsheet Operations**: Edit cells, add/remove rows, and re-generate Markdown programmatically.
18
+ - **🛡️ Type-Safe Validation**: Validate table data against schemas (Plain Object or Zod).
19
+ - **📂 File System Support**: Direct file reading capabilities.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install md-spreadsheet-parser
25
+ ```
26
+
27
+ ## Usage Guide
28
+
29
+ ### 1. Basic Parsing (String)
30
+
31
+ Parse a Markdown table string into a structured `Table` object.
32
+
33
+ ```javascript
34
+ import { parseTable } from 'md-spreadsheet-parser';
35
+
36
+ const markdown = `
37
+ | Name | Age |
38
+ | --- | --- |
39
+ | Alice | 30 |
40
+ `;
41
+
42
+ const table = parseTable(markdown);
43
+ console.log(table.rows); // [ [ 'Alice', '30' ] ]
44
+ ```
45
+
46
+ ### 2. File System Usage
47
+
48
+ You can parse files directly without reading them into a string first.
49
+
50
+ ```javascript
51
+ import { parseWorkbookFromFile, scanTablesFromFile } from 'md-spreadsheet-parser';
52
+
53
+ // Parse entire workbook (multiple sheets)
54
+ const workbook = parseWorkbookFromFile('./data.md');
55
+ console.log(`Parsed ${workbook.sheets.length} sheets`);
56
+
57
+ // Validating contents using Lookup API
58
+ const sheet = workbook.getSheet('Sheet1');
59
+ if (sheet) {
60
+ const table = sheet.getTable(0); // Get first table
61
+ console.log(table.headers);
62
+ }
63
+
64
+ // Or just scan for all tables in a file
65
+ const tables = scanTablesFromFile('./readme.md');
66
+ console.log(`Found ${tables.length} tables`);
67
+ ```
68
+
69
+ ### 3. Programmatic Editing
70
+
71
+ Table objects are mutable (CoW-like behavior internally). You can modify them and export back to Markdown.
72
+
73
+ ```javascript
74
+ import { parseTable } from 'md-spreadsheet-parser';
75
+
76
+ const table = parseTable("| Item | Price |\n|---|---|\n| Apple | 100 |");
77
+
78
+ // Update Cell (Row 0, Col 1)
79
+ table.updateCell(0, 1, "150");
80
+
81
+ // Convert back to Markdown
82
+ console.log(table.toMarkdown());
83
+ // | Item | Price |
84
+ // | --- | --- |
85
+ // | Apple | 150 |
86
+ ```
87
+
88
+ ### 4. Type-Safe Validation (toModels)
89
+
90
+ You can convert string-based table data into typed objects.
91
+
92
+ #### Basic Usage (Plain Object Schema)
93
+ You can provide a simple schema object with converter functions.
94
+
95
+ ```javascript
96
+ const markdown = `
97
+ | id | active |
98
+ | -- | ------ |
99
+ | 1 | yes |
100
+ `;
101
+ const table = parseTable(markdown);
102
+
103
+ // Define Schema
104
+ const UserSchema = {
105
+ id: (val) => Number(val),
106
+ active: (val) => val === 'yes'
107
+ };
108
+
109
+ const users = table.toModels(UserSchema);
110
+ console.log(users);
111
+ // [ { id: 1, active: true } ]
112
+ ```
113
+
114
+ #### Advanced Usage (Zod)
115
+ For robust validation, use [Zod](https://zod.dev/).
116
+
117
+ ```javascript
118
+ import { z } from 'zod';
119
+
120
+ const UserZodSchema = z.object({
121
+ id: z.coerce.number(),
122
+ active: z.string().transform(v => v === 'yes')
123
+ });
124
+
125
+ const users = table.toModels(UserZodSchema);
126
+ // [ { id: 1, active: true } ]
127
+ ```
128
+
129
+ ## API Documentation
130
+
131
+ Since this package is a direct wrapper around the Python core, the fundamental concepts are identical. The API naming conventions are adapted for JavaScript (camelCase instead of snake_case).
132
+
133
+ - **Core Documentation**: [Python User Guide](https://github.com/f-y/md-spreadsheet-parser#usage)
134
+ - **Cookbook**: [Common Recipes](https://github.com/f-y/md-spreadsheet-parser/blob/main/COOKBOOK.md)
135
+
136
+ ### Key Function Mappings
137
+
138
+ | Python (Core) | JavaScript (NPM) | Description |
139
+ |---|---|---|
140
+ | `parse_table(md)` | `parseTable(md)` | Parse a single table string |
141
+ | `parse_workbook(md)` | `parseWorkbook(md)` | Parse entire workbook string |
142
+ | `scan_tables(md)` | `scanTables(md)` | Extract all tables from string |
143
+ | `parse_workbook_from_file(path)` | `parseWorkbookFromFile(path)` | Parse file to Workbook |
144
+ | `scan_tables_from_file(path)` | `scanTablesFromFile(path)` | Extract tables from file |
145
+ | `Table.to_markdown()` | `Table.toMarkdown()` | Generate Markdown |
146
+ | `Table.update_cell(r, c, v)` | `Table.updateCell(r, c, v)` | Update specific cell |
147
+ | `Table.to_models(schema)` | `Table.toModels(schema)` | Convert to typed objects |
148
+ | `Workbook.get_sheet(name)` | `Workbook.getSheet(name)` | Get sheet by name |
149
+ | `Sheet.get_table(index)` | `Sheet.getTable(index)` | Get table by index |
150
+
151
+ ## Architecture
152
+
153
+ This package uses `componentize-py` to bundle the Python library as a WASM Component.
154
+ For more details, see [ARCHITECTURE.md](./ARCHITECTURE.md).
155
+
156
+ ## License
157
+
158
+ MIT
@@ -0,0 +1,50 @@
1
+ /** @module Interface example:spreadsheet/types **/
2
+ export type AlignmentType = string;
3
+ export interface ConversionSchema {
4
+ booleanPairs?: string,
5
+ customConverters?: string,
6
+ fieldConverters?: string,
7
+ }
8
+ export interface ExcelParsingSchema {
9
+ headerRows?: number,
10
+ fillMergedHeaders?: boolean,
11
+ delimiter?: string,
12
+ headerSeparator?: string,
13
+ }
14
+ export interface MultiTableParsingSchema {
15
+ columnSeparator?: string,
16
+ headerSeparatorChar?: string,
17
+ requireOuterPipes?: boolean,
18
+ stripWhitespace?: boolean,
19
+ convertBrToNewline?: boolean,
20
+ rootMarker?: string,
21
+ sheetHeaderLevel?: number,
22
+ tableHeaderLevel?: number,
23
+ captureDescription?: boolean,
24
+ }
25
+ export interface ParsingSchema {
26
+ columnSeparator?: string,
27
+ headerSeparatorChar?: string,
28
+ requireOuterPipes?: boolean,
29
+ stripWhitespace?: boolean,
30
+ convertBrToNewline?: boolean,
31
+ }
32
+ export interface Table {
33
+ headers?: Array<string>,
34
+ rows: Array<Array<string>>,
35
+ alignments?: Array<AlignmentType>,
36
+ name?: string,
37
+ description?: string,
38
+ metadata?: string,
39
+ startLine?: number,
40
+ endLine?: number,
41
+ }
42
+ export interface Sheet {
43
+ name: string,
44
+ tables: Array<Table>,
45
+ metadata?: string,
46
+ }
47
+ export interface Workbook {
48
+ sheets: Array<Sheet>,
49
+ metadata?: string,
50
+ }
@@ -0,0 +1,100 @@
1
+ /** @module Interface exports **/
2
+ export function init(appName: string, symbols: Symbols, stubWasi: boolean): void;
3
+ export interface Function {
4
+ protocol: string,
5
+ name: string,
6
+ }
7
+ export interface Constructor {
8
+ module: string,
9
+ protocol: string,
10
+ }
11
+ export interface Static {
12
+ module: string,
13
+ protocol: string,
14
+ name: string,
15
+ }
16
+ export type FunctionExportKind = FunctionExportKindFreestanding | FunctionExportKindConstructor | FunctionExportKindMethod | FunctionExportKindStatic;
17
+ export interface FunctionExportKindFreestanding {
18
+ tag: 'freestanding',
19
+ val: Function,
20
+ }
21
+ export interface FunctionExportKindConstructor {
22
+ tag: 'constructor',
23
+ val: Constructor,
24
+ }
25
+ export interface FunctionExportKindMethod {
26
+ tag: 'method',
27
+ val: string,
28
+ }
29
+ export interface FunctionExportKindStatic {
30
+ tag: 'static',
31
+ val: Static,
32
+ }
33
+ export type ReturnStyle = ReturnStyleNone | ReturnStyleNormal | ReturnStyleResult;
34
+ export interface ReturnStyleNone {
35
+ tag: 'none',
36
+ }
37
+ export interface ReturnStyleNormal {
38
+ tag: 'normal',
39
+ }
40
+ export interface ReturnStyleResult {
41
+ tag: 'result',
42
+ }
43
+ export interface FunctionExport {
44
+ kind: FunctionExportKind,
45
+ returnStyle: ReturnStyle,
46
+ }
47
+ export interface Resource {
48
+ 'package': string,
49
+ name: string,
50
+ }
51
+ export interface Record {
52
+ 'package': string,
53
+ name: string,
54
+ fields: Array<string>,
55
+ }
56
+ export interface Flags {
57
+ 'package': string,
58
+ name: string,
59
+ u32Count: number,
60
+ }
61
+ export interface Tuple {
62
+ count: number,
63
+ }
64
+ export interface Case {
65
+ name: string,
66
+ hasPayload: boolean,
67
+ }
68
+ export interface Variant {
69
+ 'package': string,
70
+ name: string,
71
+ cases: Array<Case>,
72
+ }
73
+ export interface Enum {
74
+ 'package': string,
75
+ name: string,
76
+ count: number,
77
+ }
78
+ /**
79
+ * # Variants
80
+ *
81
+ * ## `"non-nesting"`
82
+ *
83
+ * ## `"nesting"`
84
+ */
85
+ export type OptionKind = 'non-nesting' | 'nesting';
86
+ export interface ResultRecord {
87
+ hasOk: boolean,
88
+ hasErr: boolean,
89
+ }
90
+ export interface Symbols {
91
+ exports: Array<FunctionExport>,
92
+ resources: Array<Resource>,
93
+ records: Array<Record>,
94
+ flags: Array<Flags>,
95
+ tuples: Array<Tuple>,
96
+ variants: Array<Variant>,
97
+ enums: Array<Enum>,
98
+ options: Array<OptionKind>,
99
+ results: Array<ResultRecord>,
100
+ }
@@ -0,0 +1,4 @@
1
+ /** @module Interface wasi:cli/environment@0.2.0 **/
2
+ export function getEnvironment(): Array<[string, string]>;
3
+ export function getArguments(): Array<string>;
4
+ export function initialCwd(): string | undefined;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/exit@0.2.0 **/
2
+ export function exit(status: Result<void, void>): void;
3
+ export type Result<T, E> = { tag: 'ok', val: T } | { tag: 'err', val: E };
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/stderr@0.2.0 **/
2
+ export function getStderr(): OutputStream;
3
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/stdin@0.2.0 **/
2
+ export function getStdin(): InputStream;
3
+ export type InputStream = import('./wasi-io-streams.js').InputStream;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/stdout@0.2.0 **/
2
+ export function getStdout(): OutputStream;
3
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
@@ -0,0 +1,8 @@
1
+ /** @module Interface wasi:cli/terminal-input@0.2.0 **/
2
+
3
+ export class TerminalInput {
4
+ /**
5
+ * This type does not have a public constructor.
6
+ */
7
+ private constructor();
8
+ }
@@ -0,0 +1,8 @@
1
+ /** @module Interface wasi:cli/terminal-output@0.2.0 **/
2
+
3
+ export class TerminalOutput {
4
+ /**
5
+ * This type does not have a public constructor.
6
+ */
7
+ private constructor();
8
+ }
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/terminal-stderr@0.2.0 **/
2
+ export function getTerminalStderr(): TerminalOutput | undefined;
3
+ export type TerminalOutput = import('./wasi-cli-terminal-output.js').TerminalOutput;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/terminal-stdin@0.2.0 **/
2
+ export function getTerminalStdin(): TerminalInput | undefined;
3
+ export type TerminalInput = import('./wasi-cli-terminal-input.js').TerminalInput;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:cli/terminal-stdout@0.2.0 **/
2
+ export function getTerminalStdout(): TerminalOutput | undefined;
3
+ export type TerminalOutput = import('./wasi-cli-terminal-output.js').TerminalOutput;
@@ -0,0 +1,8 @@
1
+ /** @module Interface wasi:clocks/monotonic-clock@0.2.0 **/
2
+ export function now(): Instant;
3
+ export function resolution(): Duration;
4
+ export function subscribeInstant(when: Instant): Pollable;
5
+ export function subscribeDuration(when: Duration): Pollable;
6
+ export type Duration = bigint;
7
+ export type Instant = bigint;
8
+ export type Pollable = import('./wasi-io-poll.js').Pollable;
@@ -0,0 +1,7 @@
1
+ /** @module Interface wasi:clocks/wall-clock@0.2.0 **/
2
+ export function now(): Datetime;
3
+ export function resolution(): Datetime;
4
+ export interface Datetime {
5
+ seconds: bigint,
6
+ nanoseconds: number,
7
+ }
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:filesystem/preopens@0.2.0 **/
2
+ export function getDirectories(): Array<[Descriptor, string]>;
3
+ export type Descriptor = import('./wasi-filesystem-types.js').Descriptor;
@@ -0,0 +1,208 @@
1
+ /** @module Interface wasi:filesystem/types@0.2.0 **/
2
+ export function filesystemErrorCode(err: Error): ErrorCode | undefined;
3
+ export type Filesize = bigint;
4
+ /**
5
+ * # Variants
6
+ *
7
+ * ## `"normal"`
8
+ *
9
+ * ## `"sequential"`
10
+ *
11
+ * ## `"random"`
12
+ *
13
+ * ## `"will-need"`
14
+ *
15
+ * ## `"dont-need"`
16
+ *
17
+ * ## `"no-reuse"`
18
+ */
19
+ export type Advice = 'normal' | 'sequential' | 'random' | 'will-need' | 'dont-need' | 'no-reuse';
20
+ /**
21
+ * # Variants
22
+ *
23
+ * ## `"access"`
24
+ *
25
+ * ## `"would-block"`
26
+ *
27
+ * ## `"already"`
28
+ *
29
+ * ## `"bad-descriptor"`
30
+ *
31
+ * ## `"busy"`
32
+ *
33
+ * ## `"deadlock"`
34
+ *
35
+ * ## `"quota"`
36
+ *
37
+ * ## `"exist"`
38
+ *
39
+ * ## `"file-too-large"`
40
+ *
41
+ * ## `"illegal-byte-sequence"`
42
+ *
43
+ * ## `"in-progress"`
44
+ *
45
+ * ## `"interrupted"`
46
+ *
47
+ * ## `"invalid"`
48
+ *
49
+ * ## `"io"`
50
+ *
51
+ * ## `"is-directory"`
52
+ *
53
+ * ## `"loop"`
54
+ *
55
+ * ## `"too-many-links"`
56
+ *
57
+ * ## `"message-size"`
58
+ *
59
+ * ## `"name-too-long"`
60
+ *
61
+ * ## `"no-device"`
62
+ *
63
+ * ## `"no-entry"`
64
+ *
65
+ * ## `"no-lock"`
66
+ *
67
+ * ## `"insufficient-memory"`
68
+ *
69
+ * ## `"insufficient-space"`
70
+ *
71
+ * ## `"not-directory"`
72
+ *
73
+ * ## `"not-empty"`
74
+ *
75
+ * ## `"not-recoverable"`
76
+ *
77
+ * ## `"unsupported"`
78
+ *
79
+ * ## `"no-tty"`
80
+ *
81
+ * ## `"no-such-device"`
82
+ *
83
+ * ## `"overflow"`
84
+ *
85
+ * ## `"not-permitted"`
86
+ *
87
+ * ## `"pipe"`
88
+ *
89
+ * ## `"read-only"`
90
+ *
91
+ * ## `"invalid-seek"`
92
+ *
93
+ * ## `"text-file-busy"`
94
+ *
95
+ * ## `"cross-device"`
96
+ */
97
+ 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';
98
+ /**
99
+ * # Variants
100
+ *
101
+ * ## `"unknown"`
102
+ *
103
+ * ## `"block-device"`
104
+ *
105
+ * ## `"character-device"`
106
+ *
107
+ * ## `"directory"`
108
+ *
109
+ * ## `"fifo"`
110
+ *
111
+ * ## `"symbolic-link"`
112
+ *
113
+ * ## `"regular-file"`
114
+ *
115
+ * ## `"socket"`
116
+ */
117
+ export type DescriptorType = 'unknown' | 'block-device' | 'character-device' | 'directory' | 'fifo' | 'symbolic-link' | 'regular-file' | 'socket';
118
+ export type Error = import('./wasi-io-streams.js').Error;
119
+ export type InputStream = import('./wasi-io-streams.js').InputStream;
120
+ export type OutputStream = import('./wasi-io-streams.js').OutputStream;
121
+ export interface DescriptorFlags {
122
+ read?: boolean,
123
+ write?: boolean,
124
+ fileIntegritySync?: boolean,
125
+ dataIntegritySync?: boolean,
126
+ requestedWriteSync?: boolean,
127
+ mutateDirectory?: boolean,
128
+ }
129
+ export type Datetime = import('./wasi-clocks-wall-clock.js').Datetime;
130
+ export type NewTimestamp = NewTimestampNoChange | NewTimestampNow | NewTimestampTimestamp;
131
+ export interface NewTimestampNoChange {
132
+ tag: 'no-change',
133
+ }
134
+ export interface NewTimestampNow {
135
+ tag: 'now',
136
+ }
137
+ export interface NewTimestampTimestamp {
138
+ tag: 'timestamp',
139
+ val: Datetime,
140
+ }
141
+ export type LinkCount = bigint;
142
+ export interface DescriptorStat {
143
+ type: DescriptorType,
144
+ linkCount: LinkCount,
145
+ size: Filesize,
146
+ dataAccessTimestamp?: Datetime,
147
+ dataModificationTimestamp?: Datetime,
148
+ statusChangeTimestamp?: Datetime,
149
+ }
150
+ export interface PathFlags {
151
+ symlinkFollow?: boolean,
152
+ }
153
+ export interface OpenFlags {
154
+ create?: boolean,
155
+ directory?: boolean,
156
+ exclusive?: boolean,
157
+ truncate?: boolean,
158
+ }
159
+ export interface MetadataHashValue {
160
+ lower: bigint,
161
+ upper: bigint,
162
+ }
163
+ export interface DirectoryEntry {
164
+ type: DescriptorType,
165
+ name: string,
166
+ }
167
+
168
+ export class Descriptor {
169
+ /**
170
+ * This type does not have a public constructor.
171
+ */
172
+ private constructor();
173
+ readViaStream(offset: Filesize): InputStream;
174
+ writeViaStream(offset: Filesize): OutputStream;
175
+ appendViaStream(): OutputStream;
176
+ advise(offset: Filesize, length: Filesize, advice: Advice): void;
177
+ syncData(): void;
178
+ getFlags(): DescriptorFlags;
179
+ getType(): DescriptorType;
180
+ setSize(size: Filesize): void;
181
+ setTimes(dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
182
+ read(length: Filesize, offset: Filesize): [Uint8Array, boolean];
183
+ write(buffer: Uint8Array, offset: Filesize): Filesize;
184
+ readDirectory(): DirectoryEntryStream;
185
+ sync(): void;
186
+ createDirectoryAt(path: string): void;
187
+ stat(): DescriptorStat;
188
+ statAt(pathFlags: PathFlags, path: string): DescriptorStat;
189
+ setTimesAt(pathFlags: PathFlags, path: string, dataAccessTimestamp: NewTimestamp, dataModificationTimestamp: NewTimestamp): void;
190
+ linkAt(oldPathFlags: PathFlags, oldPath: string, newDescriptor: Descriptor, newPath: string): void;
191
+ openAt(pathFlags: PathFlags, path: string, openFlags: OpenFlags, flags: DescriptorFlags): Descriptor;
192
+ readlinkAt(path: string): string;
193
+ removeDirectoryAt(path: string): void;
194
+ renameAt(oldPath: string, newDescriptor: Descriptor, newPath: string): void;
195
+ symlinkAt(oldPath: string, newPath: string): void;
196
+ unlinkFileAt(path: string): void;
197
+ isSameObject(other: Descriptor): boolean;
198
+ metadataHash(): MetadataHashValue;
199
+ metadataHashAt(pathFlags: PathFlags, path: string): MetadataHashValue;
200
+ }
201
+
202
+ export class DirectoryEntryStream {
203
+ /**
204
+ * This type does not have a public constructor.
205
+ */
206
+ private constructor();
207
+ readDirectoryEntry(): DirectoryEntry | undefined;
208
+ }
@@ -0,0 +1,9 @@
1
+ /** @module Interface wasi:io/error@0.2.0 **/
2
+
3
+ export class Error {
4
+ /**
5
+ * This type does not have a public constructor.
6
+ */
7
+ private constructor();
8
+ toDebugString(): string;
9
+ }
@@ -0,0 +1,11 @@
1
+ /** @module Interface wasi:io/poll@0.2.0 **/
2
+ export function poll(in_: Array<Pollable>): Uint32Array;
3
+
4
+ export class Pollable {
5
+ /**
6
+ * This type does not have a public constructor.
7
+ */
8
+ private constructor();
9
+ ready(): boolean;
10
+ block(): void;
11
+ }
@@ -0,0 +1,40 @@
1
+ /** @module Interface wasi:io/streams@0.2.0 **/
2
+ export type Error = import('./wasi-io-error.js').Error;
3
+ export type Pollable = import('./wasi-io-poll.js').Pollable;
4
+ export type StreamError = StreamErrorLastOperationFailed | StreamErrorClosed;
5
+ export interface StreamErrorLastOperationFailed {
6
+ tag: 'last-operation-failed',
7
+ val: Error,
8
+ }
9
+ export interface StreamErrorClosed {
10
+ tag: 'closed',
11
+ }
12
+
13
+ export class InputStream {
14
+ /**
15
+ * This type does not have a public constructor.
16
+ */
17
+ private constructor();
18
+ read(len: bigint): Uint8Array;
19
+ blockingRead(len: bigint): Uint8Array;
20
+ skip(len: bigint): bigint;
21
+ blockingSkip(len: bigint): bigint;
22
+ subscribe(): Pollable;
23
+ }
24
+
25
+ export class OutputStream {
26
+ /**
27
+ * This type does not have a public constructor.
28
+ */
29
+ private constructor();
30
+ checkWrite(): bigint;
31
+ write(contents: Uint8Array): void;
32
+ blockingWriteAndFlush(contents: Uint8Array): void;
33
+ flush(): void;
34
+ blockingFlush(): void;
35
+ subscribe(): Pollable;
36
+ writeZeroes(len: bigint): void;
37
+ blockingWriteZeroesAndFlush(len: bigint): void;
38
+ splice(src: InputStream, len: bigint): bigint;
39
+ blockingSplice(src: InputStream, len: bigint): bigint;
40
+ }
@@ -0,0 +1,2 @@
1
+ /** @module Interface wasi:random/insecure-seed@0.2.0 **/
2
+ export function insecureSeed(): [bigint, bigint];
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:random/insecure@0.2.0 **/
2
+ export function getInsecureRandomBytes(len: bigint): Uint8Array;
3
+ export function getInsecureRandomU64(): bigint;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:random/random@0.2.0 **/
2
+ export function getRandomBytes(len: bigint): Uint8Array;
3
+ export function getRandomU64(): bigint;
@@ -0,0 +1,3 @@
1
+ /** @module Interface wasi:sockets/instance-network@0.2.0 **/
2
+ export function instanceNetwork(): Network;
3
+ export type Network = import('./wasi-sockets-network.js').Network;