@fossil-lang/wasm 0.3.0-alpha.1 → 0.3.0-alpha.10
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 +94 -32
- package/dist/client.d.ts +223 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +269 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +128 -210
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -195
- package/dist/index.js.map +1 -1
- package/dist/load.d.ts +10 -18
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +12 -12
- package/dist/load.js.map +1 -1
- package/dist/program.d.ts +94 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +93 -0
- package/dist/program.js.map +1 -0
- package/package.json +2 -2
- package/pkg/fossil_wasm.d.ts +232 -107
- package/pkg/fossil_wasm.js +317 -123
- package/pkg/fossil_wasm_bg.wasm +0 -0
- package/pkg/fossil_wasm_bg.wasm.d.ts +11 -3
package/pkg/fossil_wasm.js
CHANGED
|
@@ -6,6 +6,24 @@
|
|
|
6
6
|
*
|
|
7
7
|
* `Copy + Clone + Eq + Hash` so it can be a `HashMap` key on the Rust
|
|
8
8
|
* side; `#[wasm_bindgen]` so JS can pass it back across the boundary.
|
|
9
|
+
*
|
|
10
|
+
* # Every exported method takes `&FileHandle`, and it has to
|
|
11
|
+
*
|
|
12
|
+
* wasm-bindgen CONSUMES an exported struct passed by value: the generated glue
|
|
13
|
+
* calls `__destroy_into_raw()` on the JS wrapper, which nulls its pointer. A
|
|
14
|
+
* handle passed by value is therefore good for exactly one call, and the second
|
|
15
|
+
* throws *"null pointer passed to rust"* — from inside a method that has nothing
|
|
16
|
+
* wrong with it, naming no handle and no file.
|
|
17
|
+
*
|
|
18
|
+
* `Copy` does not save it. The derive is a Rust-side property; nothing about it
|
|
19
|
+
* reaches the JS boundary, where this is a class holding a pointer like any
|
|
20
|
+
* other. The three methods a host calls repeatedly with one handle
|
|
21
|
+
* (`update_file`, `close_file`, `diagnostics_for`) take `&FileHandle` so
|
|
22
|
+
* wasm-bindgen borrows instead, and the handle stays live across the whole
|
|
23
|
+
* lifetime `open_file`'s doc comment promises.
|
|
24
|
+
*
|
|
25
|
+
* This was reachable from the FIRST loop an editor runs: `updateFile(h, text)` on
|
|
26
|
+
* every check, with the handle `openFile` returned once.
|
|
9
27
|
*/
|
|
10
28
|
export class FileHandle {
|
|
11
29
|
static __wrap(ptr) {
|
|
@@ -28,12 +46,37 @@ export class FileHandle {
|
|
|
28
46
|
if (Symbol.dispose) FileHandle.prototype[Symbol.dispose] = FileHandle.prototype.free;
|
|
29
47
|
|
|
30
48
|
/**
|
|
31
|
-
* JS-facing
|
|
49
|
+
* The JS-facing workspace — `FossilPlayground` on the JS side, and a
|
|
50
|
+
* `RefCell` around the Rust one.
|
|
51
|
+
*
|
|
52
|
+
* # Why the interior `RefCell`, and it is not a style choice
|
|
32
53
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
54
|
+
* `wasm-bindgen` wraps every exported struct in its own `WasmRefCell`. A
|
|
55
|
+
* method taking `&mut self` borrows that cell EXCLUSIVELY for the call, and a
|
|
56
|
+
* failed borrow does not return — it panics, with
|
|
57
|
+
* *"recursive use of an object detected which would lead to unsafe aliasing in
|
|
58
|
+
* rust"*. On `wasm32-unknown-unknown` a panic is an abort: the trap unwinds
|
|
59
|
+
* nothing, so the borrow flag it was holding is never cleared, and **every
|
|
60
|
+
* later call on that object fails the same way for the life of the module.**
|
|
61
|
+
* One bad call poisons the workspace permanently.
|
|
62
|
+
*
|
|
63
|
+
* That is a real defect and it was reachable from correct host code:
|
|
64
|
+
* `apps/playground` reproduced it by typing sixteen characters faster than its
|
|
65
|
+
* debounce, and the app carried a `busy` flag and a 120 ms coalesce to stay
|
|
66
|
+
* out of it. A mitigation a host has to remember is not a fix — and an editor
|
|
67
|
+
* is precisely the workload that forgets.
|
|
68
|
+
*
|
|
69
|
+
* So no exported method takes `&mut self`. Every one takes `&self`, which
|
|
70
|
+
* wasm-bindgen borrows SHARED — shared borrows nest, so re-entry cannot fail
|
|
71
|
+
* there — and the mutation goes through this `RefCell` with
|
|
72
|
+
* `try_borrow_mut`. Genuine re-entry (a JS callback that calls back in while a
|
|
73
|
+
* call is live) now returns a catchable `Error` naming what happened, and
|
|
74
|
+
* **the workspace is still usable afterwards**, because a returned `Err` drops
|
|
75
|
+
* its guard where a panic did not.
|
|
76
|
+
*
|
|
77
|
+
* The Rust-side [`FossilPlayground`] keeps its `&mut self` signatures
|
|
78
|
+
* untouched: `lsp_worker` already owns it inside an `Rc<RefCell<…>>`, and the
|
|
79
|
+
* native tests drive it directly. Only the JS boundary changed.
|
|
37
80
|
*/
|
|
38
81
|
export class FossilPlayground {
|
|
39
82
|
__destroy_into_raw() {
|
|
@@ -47,20 +90,26 @@ export class FossilPlayground {
|
|
|
47
90
|
wasm.__wbg_fossilplayground_free(ptr, 0);
|
|
48
91
|
}
|
|
49
92
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
93
|
+
* Every open **program**'s diagnostics as a flat JS array of
|
|
94
|
+
* `{ uri, range, severity, message }` rows keyed by file URI — the
|
|
95
|
+
* playground's panel view. It is NOT what the LSP Worker publishes; see
|
|
96
|
+
* [`CheckRow`], and `lsp_worker::publish_diagnostics` for the wire.
|
|
97
|
+
*
|
|
98
|
+
* A buffer the installed provider catalogue claims — a `.shex` being
|
|
99
|
+
* edited, a `.csv`, a `.parquet` — is an INPUT and is not parsed as fossil.
|
|
100
|
+
* [`fossil_ide::diagnostics()`] is where that is said and measured, for both
|
|
101
|
+
* hosts.
|
|
54
102
|
*
|
|
55
103
|
* `range` is the UTF-16 LSP range (via `fossil_ide::LineIndex` — the
|
|
56
|
-
* rust-analyzer model
|
|
57
|
-
*
|
|
58
|
-
* `suggestion_source` as a `\nhelp: ...` suffix
|
|
59
|
-
* `
|
|
104
|
+
* rust-analyzer model). `severity` is the LSP integer constant
|
|
105
|
+
* (1 = error, 2 = warning, 3 = info). `message` carries any
|
|
106
|
+
* `suggestion_source` as a `\nhelp: ...` suffix. All three come from
|
|
107
|
+
* [`fossil_ide::lsp_diagnostic`], the rendering an editor is shown.
|
|
60
108
|
*
|
|
61
109
|
* # Errors
|
|
62
110
|
*
|
|
63
|
-
* Returns a JS error
|
|
111
|
+
* Returns a JS error if the workspace is busy, or if the result fails to
|
|
112
|
+
* serialize to `JsValue`.
|
|
64
113
|
* @returns {any}
|
|
65
114
|
*/
|
|
66
115
|
check() {
|
|
@@ -71,68 +120,138 @@ export class FossilPlayground {
|
|
|
71
120
|
return takeFromExternrefTable0(ret[0]);
|
|
72
121
|
}
|
|
73
122
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
123
|
+
* Close a file in the workspace. Idempotent in spirit but strict in
|
|
124
|
+
* signal: closing an unknown / already-closed handle is an error so
|
|
125
|
+
* JS-side bugs surface loudly (mirrors `ty_wasm`).
|
|
126
|
+
*
|
|
127
|
+
* # Errors
|
|
76
128
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
129
|
+
* Returns a JS error if `handle` was never opened or was already closed,
|
|
130
|
+
* or if the workspace is busy.
|
|
131
|
+
* @param {FileHandle} handle
|
|
132
|
+
*/
|
|
133
|
+
close_file(handle) {
|
|
134
|
+
_assertClass(handle, FileHandle);
|
|
135
|
+
const ret = wasm.fossilplayground_close_file(this.__wbg_ptr, handle.__wbg_ptr);
|
|
136
|
+
if (ret[1]) {
|
|
137
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The completion candidates at a position: `{ label, kind, detail }` rows,
|
|
142
|
+
* already narrowed by the receiver — `str.` offers string members and no
|
|
143
|
+
* reader, a property key position offers the target shape's predicates and
|
|
144
|
+
* no catalogue row.
|
|
83
145
|
*
|
|
84
|
-
*
|
|
85
|
-
* `
|
|
86
|
-
*
|
|
146
|
+
* `kind` is the LSP `CompletionItemKind` **by name** (`"function"`,
|
|
147
|
+
* `"field"`). See [`ide::CompletionRow`] for why a number does not cross
|
|
148
|
+
* this boundary.
|
|
87
149
|
*
|
|
88
150
|
* # Errors
|
|
89
151
|
*
|
|
90
|
-
* Returns a JS error
|
|
152
|
+
* Returns a JS error if the workspace is busy, or if the result fails to
|
|
153
|
+
* serialize to `JsValue`. An unknown handle is an empty array.
|
|
154
|
+
* @param {FileHandle} handle
|
|
155
|
+
* @param {number} line
|
|
156
|
+
* @param {number} character
|
|
91
157
|
* @returns {any}
|
|
92
158
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
159
|
+
completions(handle, line, character) {
|
|
160
|
+
_assertClass(handle, FileHandle);
|
|
161
|
+
const ret = wasm.fossilplayground_completions(this.__wbg_ptr, handle.__wbg_ptr, line, character);
|
|
95
162
|
if (ret[2]) {
|
|
96
163
|
throw takeFromExternrefTable0(ret[1]);
|
|
97
164
|
}
|
|
98
165
|
return takeFromExternrefTable0(ret[0]);
|
|
99
166
|
}
|
|
100
167
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
168
|
+
* Per-file diagnostic drain: `check()` returns the workspace-wide flat
|
|
169
|
+
* array, this returns one file's rows, so a host can refresh one buffer's
|
|
170
|
+
* panel without partitioning the workspace array on the JS side. It is NOT
|
|
171
|
+
* what the LSP Worker publishes — that is
|
|
172
|
+
* [`fossil_ide::lsp_diagnostics`], through `lsp_worker::publish_diagnostics`.
|
|
104
173
|
*
|
|
105
174
|
* # Errors
|
|
106
175
|
*
|
|
107
|
-
* Returns a JS error if `handle`
|
|
176
|
+
* Returns a JS error if `handle` is unknown, if the workspace is busy, or
|
|
177
|
+
* if serialization fails.
|
|
108
178
|
* @param {FileHandle} handle
|
|
179
|
+
* @returns {any}
|
|
109
180
|
*/
|
|
110
|
-
|
|
181
|
+
diagnostics_for(handle) {
|
|
111
182
|
_assertClass(handle, FileHandle);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
183
|
+
const ret = wasm.fossilplayground_diagnostics_for(this.__wbg_ptr, handle.__wbg_ptr);
|
|
184
|
+
if (ret[2]) {
|
|
185
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
116
186
|
}
|
|
187
|
+
return takeFromExternrefTable0(ret[0]);
|
|
117
188
|
}
|
|
118
189
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
190
|
+
* Where the name under the cursor is defined: `{ uri, range }` rows, empty
|
|
191
|
+
* when nothing there has a definition.
|
|
192
|
+
*
|
|
193
|
+
* `uri` is the key the host opened the buffer under, verbatim — and two of
|
|
194
|
+
* the three positions goto-def recognises resolve into the shape document,
|
|
195
|
+
* so a host with one pane has to read it before moving a cursor.
|
|
125
196
|
*
|
|
126
197
|
* # Errors
|
|
127
198
|
*
|
|
128
|
-
* Returns a JS error if
|
|
199
|
+
* Returns a JS error if the workspace is busy, or if the result fails to
|
|
200
|
+
* serialize to `JsValue`.
|
|
129
201
|
* @param {FileHandle} handle
|
|
202
|
+
* @param {number} line
|
|
203
|
+
* @param {number} character
|
|
130
204
|
* @returns {any}
|
|
131
205
|
*/
|
|
132
|
-
|
|
206
|
+
gotoDefinition(handle, line, character) {
|
|
207
|
+
_assertClass(handle, FileHandle);
|
|
208
|
+
const ret = wasm.fossilplayground_gotoDefinition(this.__wbg_ptr, handle.__wbg_ptr, line, character);
|
|
209
|
+
if (ret[2]) {
|
|
210
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
211
|
+
}
|
|
212
|
+
return takeFromExternrefTable0(ret[0]);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* What is under the cursor: `{ markdown, range }`, or `null` when the
|
|
216
|
+
* cursor is on whitespace, on an expression the checker inferred no type
|
|
217
|
+
* for, or outside any mapping.
|
|
218
|
+
*
|
|
219
|
+
* `line` / `character` are LSP — zero-based, and `character` in UTF-16
|
|
220
|
+
* code units, which is what a JS host counts in anyway. The `range` comes
|
|
221
|
+
* back in the same units.
|
|
222
|
+
*
|
|
223
|
+
* # Errors
|
|
224
|
+
*
|
|
225
|
+
* Returns a JS error if the workspace is busy, or if the result fails to
|
|
226
|
+
* serialize to `JsValue`. An unknown handle is `null`, not an error —
|
|
227
|
+
* see [`FossilPlayground::hover_row`].
|
|
228
|
+
* @param {FileHandle} handle
|
|
229
|
+
* @param {number} line
|
|
230
|
+
* @param {number} character
|
|
231
|
+
* @returns {any}
|
|
232
|
+
*/
|
|
233
|
+
hover(handle, line, character) {
|
|
133
234
|
_assertClass(handle, FileHandle);
|
|
134
|
-
|
|
135
|
-
|
|
235
|
+
const ret = wasm.fossilplayground_hover(this.__wbg_ptr, handle.__wbg_ptr, line, character);
|
|
236
|
+
if (ret[2]) {
|
|
237
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
238
|
+
}
|
|
239
|
+
return takeFromExternrefTable0(ret[0]);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The documents the file at `handle` names that nothing has registered:
|
|
243
|
+
* `{ key, locator }` rows, the locator expanded through the connection map.
|
|
244
|
+
*
|
|
245
|
+
* # Errors
|
|
246
|
+
*
|
|
247
|
+
* Returns a JS error if `handle` is unknown, if the workspace is busy, or
|
|
248
|
+
* if serialization fails.
|
|
249
|
+
* @param {FileHandle} handle
|
|
250
|
+
* @returns {any}
|
|
251
|
+
*/
|
|
252
|
+
missingDocuments(handle) {
|
|
253
|
+
_assertClass(handle, FileHandle);
|
|
254
|
+
const ret = wasm.fossilplayground_missingDocuments(this.__wbg_ptr, handle.__wbg_ptr);
|
|
136
255
|
if (ret[2]) {
|
|
137
256
|
throw takeFromExternrefTable0(ret[1]);
|
|
138
257
|
}
|
|
@@ -141,9 +260,9 @@ export class FossilPlayground {
|
|
|
141
260
|
/**
|
|
142
261
|
* Construct a new playground.
|
|
143
262
|
*
|
|
144
|
-
* Installs `console_error_panic_hook` (idempotent
|
|
145
|
-
*
|
|
146
|
-
*
|
|
263
|
+
* Installs `console_error_panic_hook` (idempotent) so any panic inside
|
|
264
|
+
* compiler-core surfaces as a `console.error` stack trace in the host
|
|
265
|
+
* (browser `DevTools` or Node).
|
|
147
266
|
*/
|
|
148
267
|
constructor() {
|
|
149
268
|
const ret = wasm.fossilplayground_new();
|
|
@@ -153,18 +272,16 @@ export class FossilPlayground {
|
|
|
153
272
|
}
|
|
154
273
|
/**
|
|
155
274
|
* Open a file in the workspace. Returns a [`FileHandle`] the JS side
|
|
156
|
-
* keys subsequent `update_file` / `close_file`
|
|
157
|
-
*
|
|
158
|
-
* the LSP client.
|
|
275
|
+
* keys subsequent `update_file` / `close_file` calls on. `path` is the
|
|
276
|
+
* URI / virtual path the diagnostics carry back to the LSP client.
|
|
159
277
|
*
|
|
160
278
|
* Mirrors `ty_wasm::Workspace::open_file` (Astral). Interns a fresh
|
|
161
279
|
* [`fossil_base::SourceFile`] under the current Salsa revision.
|
|
162
280
|
*
|
|
163
281
|
* # Errors
|
|
164
282
|
*
|
|
165
|
-
* Returns a JS error
|
|
166
|
-
*
|
|
167
|
-
* failure mode).
|
|
283
|
+
* Returns a JS error if the workspace is already inside another call —
|
|
284
|
+
* see the type-level note on [`WasmPlayground`].
|
|
168
285
|
* @param {string} path
|
|
169
286
|
* @param {string} contents
|
|
170
287
|
* @returns {FileHandle}
|
|
@@ -180,44 +297,41 @@ export class FossilPlayground {
|
|
|
180
297
|
}
|
|
181
298
|
return FileHandle.__wrap(ret[0]);
|
|
182
299
|
}
|
|
300
|
+
/**
|
|
301
|
+
* Register a fetched document's `text` under the `key` `missingDocuments`
|
|
302
|
+
* reported.
|
|
303
|
+
*
|
|
304
|
+
* # Errors
|
|
305
|
+
*
|
|
306
|
+
* Returns a JS error if the workspace is busy.
|
|
307
|
+
* @param {string} key
|
|
308
|
+
* @param {string} text
|
|
309
|
+
*/
|
|
310
|
+
registerDocument(key, text) {
|
|
311
|
+
const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
312
|
+
const len0 = WASM_VECTOR_LEN;
|
|
313
|
+
const ptr1 = passStringToWasm0(text, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
314
|
+
const len1 = WASM_VECTOR_LEN;
|
|
315
|
+
const ret = wasm.fossilplayground_registerDocument(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
316
|
+
if (ret[1]) {
|
|
317
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
183
320
|
/**
|
|
184
321
|
* Register an [`fossil_descriptors_input::InferredDescriptor`] for a
|
|
185
|
-
* source binding name BEFORE invoking
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
* the
|
|
192
|
-
* `InferredDescriptorJson`:
|
|
193
|
-
*
|
|
194
|
-
* ```json
|
|
195
|
-
* {
|
|
196
|
-
* "source_name": "users",
|
|
197
|
-
* "columns": [
|
|
198
|
-
* { "name": "id", "primitive": "Integer" },
|
|
199
|
-
* { "name": "name", "primitive": "String" }
|
|
200
|
-
* ],
|
|
201
|
-
* "content_hash": ""
|
|
202
|
-
* }
|
|
203
|
-
* ```
|
|
204
|
-
*
|
|
205
|
-
* Called by the browser-side playground orchestration AFTER running
|
|
206
|
-
* DuckDB-WASM `DESCRIBE read_csv_auto('<resolved-url>')` and BEFORE
|
|
207
|
-
* invoking `compile()` / `compile_file()`. Keyed by source-binding
|
|
208
|
-
* name (`"users"` for `users := io.csv("...")`), NOT by URL.
|
|
209
|
-
*
|
|
210
|
-
* Idempotent: re-registering with the same `source_name` OVERWRITES the
|
|
211
|
-
* previous entry — intentional, since the host may re-introspect when
|
|
212
|
-
* file content changes.
|
|
322
|
+
* source binding name BEFORE invoking `check`. The Rust compiler reads
|
|
323
|
+
* from this registration during forward type propagation — the browser has
|
|
324
|
+
* no filesystem to introspect a CSV from, so the column types must arrive
|
|
325
|
+
* from the host.
|
|
326
|
+
*
|
|
327
|
+
* Registering the same URI twice REPLACES the previous descriptor
|
|
328
|
+
* — intentional, since the host re-introspects when the source changes.
|
|
213
329
|
*
|
|
214
330
|
* # Errors
|
|
215
331
|
*
|
|
216
332
|
* - Malformed JSON / missing required fields → JS `Error` with the
|
|
217
333
|
* underlying `serde_json` message.
|
|
218
|
-
*
|
|
219
|
-
* Implementation: thin shim over the pure-Rust
|
|
220
|
-
* [`Self::register_inferred_descriptor_native`] helper.
|
|
334
|
+
* - The workspace is busy.
|
|
221
335
|
* @param {string} descriptor_json
|
|
222
336
|
*/
|
|
223
337
|
registerInferredDescriptor(descriptor_json) {
|
|
@@ -229,36 +343,44 @@ export class FossilPlayground {
|
|
|
229
343
|
}
|
|
230
344
|
}
|
|
231
345
|
/**
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
* half-applied state — a broken schema must never wedge the editor;
|
|
235
|
-
* same contract as `fossil-lsp`'s `load_sibling_shex` in 06-09).
|
|
236
|
-
*
|
|
237
|
-
* The schema is parsed via
|
|
238
|
-
* [`fossil_descriptors_output::ShExDescriptor::from_reader`] (no
|
|
239
|
-
* network access — Pitfall 1) and wrapped in
|
|
240
|
-
* [`OutputDescriptorKind::ShEx`]. The resulting `Arc` is swapped into
|
|
241
|
-
* the [`WasmDb`]'s descriptor slot atomically; future `fossil-ide`
|
|
242
|
-
* feature calls (hover, completion) reading
|
|
243
|
-
* [`HirDb::output_descriptor_kind`] see the new schema.
|
|
346
|
+
* Replace the connection map `@name/…` expands against, as
|
|
347
|
+
* `SourceHost.connections()` answers it.
|
|
244
348
|
*
|
|
245
349
|
* # Errors
|
|
246
350
|
*
|
|
247
|
-
* Returns a JS error if
|
|
248
|
-
*
|
|
351
|
+
* Returns a JS error if `connections` is not a string-to-string record, or
|
|
352
|
+
* if the workspace is busy.
|
|
353
|
+
* @param {any} connections
|
|
249
354
|
*/
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
const len0 = WASM_VECTOR_LEN;
|
|
253
|
-
const ret = wasm.fossilplayground_set_target_shex(this.__wbg_ptr, ptr0, len0);
|
|
355
|
+
setConnections(connections) {
|
|
356
|
+
const ret = wasm.fossilplayground_setConnections(this.__wbg_ptr, connections);
|
|
254
357
|
if (ret[1]) {
|
|
255
358
|
throw takeFromExternrefTable0(ret[0]);
|
|
256
359
|
}
|
|
257
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* The data sources the file at `handle` reads — see
|
|
363
|
+
* [`fossil_lineage::program_sources`].
|
|
364
|
+
*
|
|
365
|
+
* # Errors
|
|
366
|
+
*
|
|
367
|
+
* Returns a JS error if `handle` is unknown, if the workspace is busy, or
|
|
368
|
+
* if serialization fails.
|
|
369
|
+
* @param {FileHandle} handle
|
|
370
|
+
* @returns {any}
|
|
371
|
+
*/
|
|
372
|
+
sources(handle) {
|
|
373
|
+
_assertClass(handle, FileHandle);
|
|
374
|
+
const ret = wasm.fossilplayground_sources(this.__wbg_ptr, handle.__wbg_ptr);
|
|
375
|
+
if (ret[2]) {
|
|
376
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
377
|
+
}
|
|
378
|
+
return takeFromExternrefTable0(ret[0]);
|
|
379
|
+
}
|
|
258
380
|
/**
|
|
259
381
|
* Apply an edit to an open file. Mutates the SAME `SourceFile` via the
|
|
260
382
|
* Salsa [`salsa::Setter`] (`set_text`) — this BUMPS THE REVISION, the
|
|
261
|
-
* real cancellation trigger
|
|
383
|
+
* real cancellation trigger: any in-flight analysis from the
|
|
262
384
|
* previous keystroke observes the new revision at its next cooperative
|
|
263
385
|
* checkpoint. NO new `SourceFile` is interned — the Salsa input
|
|
264
386
|
* identity stays stable across the file's lifetime, so memoised
|
|
@@ -267,16 +389,18 @@ export class FossilPlayground {
|
|
|
267
389
|
*
|
|
268
390
|
* # Errors
|
|
269
391
|
*
|
|
270
|
-
* Returns a JS error if `handle` was never opened or was already closed
|
|
392
|
+
* Returns a JS error if `handle` was never opened or was already closed,
|
|
393
|
+
* or if the workspace is already inside another call — see the type-level
|
|
394
|
+
* note on [`WasmPlayground`]. **Neither leaves the workspace unusable**,
|
|
395
|
+
* which is the whole reason this method takes `&self`.
|
|
271
396
|
* @param {FileHandle} handle
|
|
272
397
|
* @param {string} contents
|
|
273
398
|
*/
|
|
274
399
|
update_file(handle, contents) {
|
|
275
400
|
_assertClass(handle, FileHandle);
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
const ret = wasm.fossilplayground_update_file(this.__wbg_ptr, ptr0, ptr1, len1);
|
|
401
|
+
const ptr0 = passStringToWasm0(contents, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
402
|
+
const len0 = WASM_VECTOR_LEN;
|
|
403
|
+
const ret = wasm.fossilplayground_update_file(this.__wbg_ptr, handle.__wbg_ptr, ptr0, len0);
|
|
280
404
|
if (ret[1]) {
|
|
281
405
|
throw takeFromExternrefTable0(ret[0]);
|
|
282
406
|
}
|
|
@@ -285,15 +409,54 @@ export class FossilPlayground {
|
|
|
285
409
|
if (Symbol.dispose) FossilPlayground.prototype[Symbol.dispose] = FossilPlayground.prototype.free;
|
|
286
410
|
|
|
287
411
|
/**
|
|
288
|
-
*
|
|
412
|
+
* The providers this host installs (`io.csv`, `io.rdf`, `io.shex`, …) as a JS
|
|
413
|
+
* array of `{ name, extensions, kind }`. Pure projection of the provider
|
|
414
|
+
* registry — no parsing, no db. `kind` is read off each row's capabilities, so
|
|
415
|
+
* the two shape-document rows come back as `Schema`.
|
|
416
|
+
*
|
|
417
|
+
* # Errors
|
|
418
|
+
* Returns a JS error only if the result fails to serialize to `JsValue`.
|
|
419
|
+
* @returns {any}
|
|
420
|
+
*/
|
|
421
|
+
export function providers() {
|
|
422
|
+
const ret = wasm.providers();
|
|
423
|
+
if (ret[2]) {
|
|
424
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
425
|
+
}
|
|
426
|
+
return takeFromExternrefTable0(ret[0]);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Parse `program` and return its external references — every data URI +
|
|
431
|
+
* `schema =` argument, each tagged with its `@conn` alias (`null` for a direct
|
|
432
|
+
* path) and role (`Data` / `Schema`) — as a JS array of
|
|
433
|
+
* `{ connection, path, role }`. Parse-only; the host resolves `@conn` →
|
|
434
|
+
* `{base}/path` itself (its data-plane job, kept out of fossil's semantics).
|
|
435
|
+
*
|
|
436
|
+
* # Errors
|
|
437
|
+
* Returns a JS error only if the result fails to serialize to `JsValue`.
|
|
438
|
+
* @param {string} program
|
|
439
|
+
* @returns {any}
|
|
440
|
+
*/
|
|
441
|
+
export function refs(program) {
|
|
442
|
+
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
443
|
+
const len0 = WASM_VECTOR_LEN;
|
|
444
|
+
const ret = wasm.refs(ptr0, len0);
|
|
445
|
+
if (ret[2]) {
|
|
446
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
447
|
+
}
|
|
448
|
+
return takeFromExternrefTable0(ret[0]);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* `JS`-facing re-export of the semantic-token legend.
|
|
289
453
|
*
|
|
290
454
|
* Returns `{ tokenTypes: string[], tokenModifiers: string[] }` — the exact
|
|
291
|
-
* LSP `SemanticTokensLegend` shape
|
|
292
|
-
* `
|
|
293
|
-
* LSP `semanticTokens/full` response indices into highlight tag names.
|
|
455
|
+
* LSP `SemanticTokensLegend` shape, which is what turns the indices in a
|
|
456
|
+
* `semanticTokens/full` response into names a host can style.
|
|
294
457
|
*
|
|
295
|
-
* Delegates to [`fossil_ide::semantic_legend`]
|
|
296
|
-
*
|
|
458
|
+
* Delegates to [`fossil_ide::semantic_legend`], the one definition — a second
|
|
459
|
+
* legend here would desynchronise the indices the native LSP already emits.
|
|
297
460
|
*
|
|
298
461
|
* # Errors
|
|
299
462
|
*
|
|
@@ -328,10 +491,38 @@ export function start_lsp_worker() {
|
|
|
328
491
|
}
|
|
329
492
|
}
|
|
330
493
|
|
|
494
|
+
/**
|
|
495
|
+
* The name of every [`TokenRow::kind`], indexed BY that kind.
|
|
496
|
+
*
|
|
497
|
+
* `token_kinds()[row.kind]` is the variant name — `"Comment"`, `"KwFrom"`,
|
|
498
|
+
* `"String"`. A host maps names to highlight categories and never writes a
|
|
499
|
+
* discriminant down, which is the only version of this contract that survives
|
|
500
|
+
* a reorder of the lexer.
|
|
501
|
+
*
|
|
502
|
+
* This is the same move [`semantic_legend`] makes for LSP semantic tokens: the
|
|
503
|
+
* indices are meaningless without the legend, so ship the legend.
|
|
504
|
+
*
|
|
505
|
+
* A kind past the end of the array is a variant appended by a newer compiler
|
|
506
|
+
* than the host was built against. That is BACKWARDS-COMPATIBLE by
|
|
507
|
+
* construction: the host sees `undefined` and styles the span as plain text.
|
|
508
|
+
*
|
|
509
|
+
* # Errors
|
|
510
|
+
*
|
|
511
|
+
* Returns a JS error only if `serde_wasm_bindgen` fails to serialise a
|
|
512
|
+
* `Vec<&str>` (impossible in practice).
|
|
513
|
+
* @returns {any}
|
|
514
|
+
*/
|
|
515
|
+
export function tokenKinds() {
|
|
516
|
+
const ret = wasm.tokenKinds();
|
|
517
|
+
if (ret[2]) {
|
|
518
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
519
|
+
}
|
|
520
|
+
return takeFromExternrefTable0(ret[0]);
|
|
521
|
+
}
|
|
522
|
+
|
|
331
523
|
/**
|
|
332
524
|
* `JS`-facing tokenize. Returns the same row stream as [`tokenize_native`],
|
|
333
|
-
* serialised via `serde_wasm_bindgen`.
|
|
334
|
-
* `@fossil-lang/codemirror-fossil`'s `StreamParser` (plan 08-08).
|
|
525
|
+
* serialised via `serde_wasm_bindgen`.
|
|
335
526
|
*
|
|
336
527
|
* # Errors
|
|
337
528
|
*
|
|
@@ -460,6 +651,9 @@ function __wbg_get_imports() {
|
|
|
460
651
|
wasm.__wbindgen_free_command_export(deferred0_0, deferred0_1, 1);
|
|
461
652
|
}
|
|
462
653
|
},
|
|
654
|
+
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
655
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
656
|
+
}, arguments); },
|
|
463
657
|
__wbg_get_652f640b3b0b6e3e: function(arg0, arg1) {
|
|
464
658
|
const ret = arg0[arg1 >>> 0];
|
|
465
659
|
return ret;
|
|
@@ -611,8 +805,8 @@ function __wbg_get_imports() {
|
|
|
611
805
|
return ret;
|
|
612
806
|
},
|
|
613
807
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
614
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx:
|
|
615
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
808
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
809
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h6c9357f9f01d3cd7);
|
|
616
810
|
return ret;
|
|
617
811
|
},
|
|
618
812
|
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
@@ -651,8 +845,8 @@ function __wbg_get_imports() {
|
|
|
651
845
|
};
|
|
652
846
|
}
|
|
653
847
|
|
|
654
|
-
function
|
|
655
|
-
wasm.
|
|
848
|
+
function wasm_bindgen__convert__closures_____invoke__h6c9357f9f01d3cd7(arg0, arg1, arg2) {
|
|
849
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h6c9357f9f01d3cd7(arg0, arg1, arg2);
|
|
656
850
|
}
|
|
657
851
|
|
|
658
852
|
const FileHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
package/pkg/fossil_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -4,18 +4,26 @@ export const memory: WebAssembly.Memory;
|
|
|
4
4
|
export const start_lsp_worker: () => [number, number];
|
|
5
5
|
export const tokenize: (a: number, b: number) => [number, number, number];
|
|
6
6
|
export const semantic_legend: () => [number, number, number];
|
|
7
|
+
export const tokenKinds: () => [number, number, number];
|
|
7
8
|
export const __wbg_filehandle_free: (a: number, b: number) => void;
|
|
8
9
|
export const __wbg_fossilplayground_free: (a: number, b: number) => void;
|
|
9
10
|
export const fossilplayground_new: () => number;
|
|
10
|
-
export const fossilplayground_classification: (a: number) => [number, number, number];
|
|
11
11
|
export const fossilplayground_open_file: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
12
12
|
export const fossilplayground_update_file: (a: number, b: number, c: number, d: number) => [number, number];
|
|
13
13
|
export const fossilplayground_close_file: (a: number, b: number) => [number, number];
|
|
14
14
|
export const fossilplayground_check: (a: number) => [number, number, number];
|
|
15
15
|
export const fossilplayground_diagnostics_for: (a: number, b: number) => [number, number, number];
|
|
16
|
-
export const
|
|
16
|
+
export const fossilplayground_setConnections: (a: number, b: any) => [number, number];
|
|
17
|
+
export const fossilplayground_missingDocuments: (a: number, b: number) => [number, number, number];
|
|
18
|
+
export const fossilplayground_registerDocument: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
19
|
+
export const fossilplayground_sources: (a: number, b: number) => [number, number, number];
|
|
20
|
+
export const fossilplayground_hover: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
21
|
+
export const fossilplayground_completions: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
22
|
+
export const fossilplayground_gotoDefinition: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
17
23
|
export const fossilplayground_registerInferredDescriptor: (a: number, b: number, c: number) => [number, number];
|
|
18
|
-
export const
|
|
24
|
+
export const providers: () => [number, number, number];
|
|
25
|
+
export const refs: (a: number, b: number) => [number, number, number];
|
|
26
|
+
export const wasm_bindgen__convert__closures_____invoke__h6c9357f9f01d3cd7: (a: number, b: number, c: any) => void;
|
|
19
27
|
export const __wbindgen_malloc_command_export: (a: number, b: number) => number;
|
|
20
28
|
export const __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
|
|
21
29
|
export const __wbindgen_exn_store_command_export: (a: number) => void;
|