@fossil-lang/wasm 0.3.0-alpha.2 → 0.3.0-alpha.5
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 +13 -11
- package/dist/client.d.ts +199 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +231 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +115 -204
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -188
- package/dist/index.js.map +1 -1
- package/dist/load.d.ts +1 -1
- package/dist/load.js +1 -1
- package/package.json +2 -2
- package/pkg/fossil_wasm.d.ts +194 -111
- package/pkg/fossil_wasm.js +252 -131
- package/pkg/fossil_wasm_bg.wasm +0 -0
- package/pkg/fossil_wasm_bg.wasm.d.ts +7 -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
|
|
53
|
+
*
|
|
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.
|
|
32
68
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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,27 @@ 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 — the `.shex` the
|
|
99
|
+
* playground had to open to give the compiler a document, a `.csv`, a
|
|
100
|
+
* `.parquet` — is an INPUT and is not parsed as fossil.
|
|
101
|
+
* [`fossil_ide::diagnostics()`] is where that is said and measured, for both
|
|
102
|
+
* hosts.
|
|
54
103
|
*
|
|
55
104
|
* `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
|
-
* `
|
|
105
|
+
* rust-analyzer model). `severity` is the LSP integer constant
|
|
106
|
+
* (1 = error, 2 = warning, 3 = info). `message` carries any
|
|
107
|
+
* `suggestion_source` as a `\nhelp: ...` suffix. All three come from
|
|
108
|
+
* [`fossil_ide::lsp_diagnostic`], the rendering an editor is shown.
|
|
60
109
|
*
|
|
61
110
|
* # Errors
|
|
62
111
|
*
|
|
63
|
-
* Returns a JS error
|
|
112
|
+
* Returns a JS error if the workspace is busy, or if the result fails to
|
|
113
|
+
* serialize to `JsValue`.
|
|
64
114
|
* @returns {any}
|
|
65
115
|
*/
|
|
66
116
|
check() {
|
|
@@ -71,68 +121,119 @@ export class FossilPlayground {
|
|
|
71
121
|
return takeFromExternrefTable0(ret[0]);
|
|
72
122
|
}
|
|
73
123
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
124
|
+
* Close a file in the workspace. Idempotent in spirit but strict in
|
|
125
|
+
* signal: closing an unknown / already-closed handle is an error so
|
|
126
|
+
* JS-side bugs surface loudly (mirrors `ty_wasm`).
|
|
127
|
+
*
|
|
128
|
+
* # Errors
|
|
76
129
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
130
|
+
* Returns a JS error if `handle` was never opened or was already closed,
|
|
131
|
+
* or if the workspace is busy.
|
|
132
|
+
* @param {FileHandle} handle
|
|
133
|
+
*/
|
|
134
|
+
close_file(handle) {
|
|
135
|
+
_assertClass(handle, FileHandle);
|
|
136
|
+
const ret = wasm.fossilplayground_close_file(this.__wbg_ptr, handle.__wbg_ptr);
|
|
137
|
+
if (ret[1]) {
|
|
138
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The completion candidates at a position: `{ label, kind, detail }` rows,
|
|
143
|
+
* already narrowed by the receiver — `str.` offers string members and no
|
|
144
|
+
* reader, a property key position offers the target shape's predicates and
|
|
145
|
+
* no catalogue row.
|
|
83
146
|
*
|
|
84
|
-
*
|
|
85
|
-
* `
|
|
86
|
-
*
|
|
147
|
+
* `kind` is the LSP `CompletionItemKind` **by name** (`"function"`,
|
|
148
|
+
* `"field"`). See [`ide::CompletionRow`] for why a number does not cross
|
|
149
|
+
* this boundary.
|
|
87
150
|
*
|
|
88
151
|
* # Errors
|
|
89
152
|
*
|
|
90
|
-
* Returns a JS error
|
|
153
|
+
* Returns a JS error if the workspace is busy, or if the result fails to
|
|
154
|
+
* serialize to `JsValue`. An unknown handle is an empty array.
|
|
155
|
+
* @param {FileHandle} handle
|
|
156
|
+
* @param {number} line
|
|
157
|
+
* @param {number} character
|
|
91
158
|
* @returns {any}
|
|
92
159
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
160
|
+
completions(handle, line, character) {
|
|
161
|
+
_assertClass(handle, FileHandle);
|
|
162
|
+
const ret = wasm.fossilplayground_completions(this.__wbg_ptr, handle.__wbg_ptr, line, character);
|
|
95
163
|
if (ret[2]) {
|
|
96
164
|
throw takeFromExternrefTable0(ret[1]);
|
|
97
165
|
}
|
|
98
166
|
return takeFromExternrefTable0(ret[0]);
|
|
99
167
|
}
|
|
100
168
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
169
|
+
* Per-file diagnostic drain: `check()` returns the workspace-wide flat
|
|
170
|
+
* array, this returns one file's rows, so a host can refresh one buffer's
|
|
171
|
+
* panel without partitioning the workspace array on the JS side. It is NOT
|
|
172
|
+
* what the LSP Worker publishes — that is
|
|
173
|
+
* [`fossil_ide::lsp_diagnostics`], through `lsp_worker::publish_diagnostics`.
|
|
104
174
|
*
|
|
105
175
|
* # Errors
|
|
106
176
|
*
|
|
107
|
-
* Returns a JS error if `handle`
|
|
177
|
+
* Returns a JS error if `handle` is unknown, if the workspace is busy, or
|
|
178
|
+
* if serialization fails.
|
|
108
179
|
* @param {FileHandle} handle
|
|
180
|
+
* @returns {any}
|
|
109
181
|
*/
|
|
110
|
-
|
|
182
|
+
diagnostics_for(handle) {
|
|
111
183
|
_assertClass(handle, FileHandle);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
184
|
+
const ret = wasm.fossilplayground_diagnostics_for(this.__wbg_ptr, handle.__wbg_ptr);
|
|
185
|
+
if (ret[2]) {
|
|
186
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
116
187
|
}
|
|
188
|
+
return takeFromExternrefTable0(ret[0]);
|
|
117
189
|
}
|
|
118
190
|
/**
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
191
|
+
* Where the name under the cursor is defined: `{ uri, range }` rows, empty
|
|
192
|
+
* when nothing there has a definition.
|
|
193
|
+
*
|
|
194
|
+
* `uri` is the key the host opened the buffer under, verbatim — and two of
|
|
195
|
+
* the three positions goto-def recognises resolve into the shape document,
|
|
196
|
+
* so a host with one pane has to read it before moving a cursor.
|
|
125
197
|
*
|
|
126
198
|
* # Errors
|
|
127
199
|
*
|
|
128
|
-
* Returns a JS error if
|
|
200
|
+
* Returns a JS error if the workspace is busy, or if the result fails to
|
|
201
|
+
* serialize to `JsValue`.
|
|
129
202
|
* @param {FileHandle} handle
|
|
203
|
+
* @param {number} line
|
|
204
|
+
* @param {number} character
|
|
130
205
|
* @returns {any}
|
|
131
206
|
*/
|
|
132
|
-
|
|
207
|
+
gotoDefinition(handle, line, character) {
|
|
133
208
|
_assertClass(handle, FileHandle);
|
|
134
|
-
|
|
135
|
-
|
|
209
|
+
const ret = wasm.fossilplayground_gotoDefinition(this.__wbg_ptr, handle.__wbg_ptr, line, character);
|
|
210
|
+
if (ret[2]) {
|
|
211
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
212
|
+
}
|
|
213
|
+
return takeFromExternrefTable0(ret[0]);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* What is under the cursor: `{ markdown, range }`, or `null` when the
|
|
217
|
+
* cursor is on whitespace, on an expression the checker inferred no type
|
|
218
|
+
* for, or outside any mapping.
|
|
219
|
+
*
|
|
220
|
+
* `line` / `character` are LSP — zero-based, and `character` in UTF-16
|
|
221
|
+
* code units, which is what a JS host counts in anyway. The `range` comes
|
|
222
|
+
* back in the same units.
|
|
223
|
+
*
|
|
224
|
+
* # Errors
|
|
225
|
+
*
|
|
226
|
+
* Returns a JS error if the workspace is busy, or if the result fails to
|
|
227
|
+
* serialize to `JsValue`. An unknown handle is `null`, not an error —
|
|
228
|
+
* see [`FossilPlayground::hover_row`].
|
|
229
|
+
* @param {FileHandle} handle
|
|
230
|
+
* @param {number} line
|
|
231
|
+
* @param {number} character
|
|
232
|
+
* @returns {any}
|
|
233
|
+
*/
|
|
234
|
+
hover(handle, line, character) {
|
|
235
|
+
_assertClass(handle, FileHandle);
|
|
236
|
+
const ret = wasm.fossilplayground_hover(this.__wbg_ptr, handle.__wbg_ptr, line, character);
|
|
136
237
|
if (ret[2]) {
|
|
137
238
|
throw takeFromExternrefTable0(ret[1]);
|
|
138
239
|
}
|
|
@@ -141,9 +242,9 @@ export class FossilPlayground {
|
|
|
141
242
|
/**
|
|
142
243
|
* Construct a new playground.
|
|
143
244
|
*
|
|
144
|
-
* Installs `console_error_panic_hook` (idempotent
|
|
145
|
-
*
|
|
146
|
-
*
|
|
245
|
+
* Installs `console_error_panic_hook` (idempotent) so any panic inside
|
|
246
|
+
* compiler-core surfaces as a `console.error` stack trace in the host
|
|
247
|
+
* (browser `DevTools` or Node).
|
|
147
248
|
*/
|
|
148
249
|
constructor() {
|
|
149
250
|
const ret = wasm.fossilplayground_new();
|
|
@@ -153,18 +254,16 @@ export class FossilPlayground {
|
|
|
153
254
|
}
|
|
154
255
|
/**
|
|
155
256
|
* Open a file in the workspace. Returns a [`FileHandle`] the JS side
|
|
156
|
-
* keys subsequent `update_file` / `close_file`
|
|
157
|
-
*
|
|
158
|
-
* the LSP client.
|
|
257
|
+
* keys subsequent `update_file` / `close_file` calls on. `path` is the
|
|
258
|
+
* URI / virtual path the diagnostics carry back to the LSP client.
|
|
159
259
|
*
|
|
160
260
|
* Mirrors `ty_wasm::Workspace::open_file` (Astral). Interns a fresh
|
|
161
261
|
* [`fossil_base::SourceFile`] under the current Salsa revision.
|
|
162
262
|
*
|
|
163
263
|
* # Errors
|
|
164
264
|
*
|
|
165
|
-
* Returns a JS error
|
|
166
|
-
*
|
|
167
|
-
* failure mode).
|
|
265
|
+
* Returns a JS error if the workspace is already inside another call —
|
|
266
|
+
* see the type-level note on [`WasmPlayground`].
|
|
168
267
|
* @param {string} path
|
|
169
268
|
* @param {string} contents
|
|
170
269
|
* @returns {FileHandle}
|
|
@@ -182,42 +281,19 @@ export class FossilPlayground {
|
|
|
182
281
|
}
|
|
183
282
|
/**
|
|
184
283
|
* Register an [`fossil_descriptors_input::InferredDescriptor`] for a
|
|
185
|
-
* source binding name BEFORE invoking
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* `descriptor_json` is the JSON serialisation of `InferredDescriptor`;
|
|
191
|
-
* the canonical shape is exposed in `packages/wasm/src/index.ts` as
|
|
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.
|
|
284
|
+
* source binding name BEFORE invoking `check`. The Rust compiler reads
|
|
285
|
+
* from this registration during forward type propagation — the browser has
|
|
286
|
+
* no filesystem to introspect a CSV from, so the column types must arrive
|
|
287
|
+
* from the host.
|
|
209
288
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* file content changes.
|
|
289
|
+
* Registering the same URI twice REPLACES the previous descriptor
|
|
290
|
+
* — intentional, since the host re-introspects when the source changes.
|
|
213
291
|
*
|
|
214
292
|
* # Errors
|
|
215
293
|
*
|
|
216
294
|
* - Malformed JSON / missing required fields → JS `Error` with the
|
|
217
295
|
* underlying `serde_json` message.
|
|
218
|
-
*
|
|
219
|
-
* Implementation: thin shim over the pure-Rust
|
|
220
|
-
* [`Self::register_inferred_descriptor_native`] helper.
|
|
296
|
+
* - The workspace is busy.
|
|
221
297
|
* @param {string} descriptor_json
|
|
222
298
|
*/
|
|
223
299
|
registerInferredDescriptor(descriptor_json) {
|
|
@@ -228,37 +304,10 @@ export class FossilPlayground {
|
|
|
228
304
|
throw takeFromExternrefTable0(ret[0]);
|
|
229
305
|
}
|
|
230
306
|
}
|
|
231
|
-
/**
|
|
232
|
-
* Install a user-supplied `ShEx` schema as the active output descriptor.
|
|
233
|
-
* On parse failure the previously-installed descriptor is RETAINED (no
|
|
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.
|
|
244
|
-
*
|
|
245
|
-
* # Errors
|
|
246
|
-
*
|
|
247
|
-
* Returns a JS error if the text is not a parseable `ShEx` schema.
|
|
248
|
-
* @param {string} text
|
|
249
|
-
*/
|
|
250
|
-
set_target_shex(text) {
|
|
251
|
-
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
252
|
-
const len0 = WASM_VECTOR_LEN;
|
|
253
|
-
const ret = wasm.fossilplayground_set_target_shex(this.__wbg_ptr, ptr0, len0);
|
|
254
|
-
if (ret[1]) {
|
|
255
|
-
throw takeFromExternrefTable0(ret[0]);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
307
|
/**
|
|
259
308
|
* Apply an edit to an open file. Mutates the SAME `SourceFile` via the
|
|
260
309
|
* Salsa [`salsa::Setter`] (`set_text`) — this BUMPS THE REVISION, the
|
|
261
|
-
* real cancellation trigger
|
|
310
|
+
* real cancellation trigger: any in-flight analysis from the
|
|
262
311
|
* previous keystroke observes the new revision at its next cooperative
|
|
263
312
|
* checkpoint. NO new `SourceFile` is interned — the Salsa input
|
|
264
313
|
* identity stays stable across the file's lifetime, so memoised
|
|
@@ -267,16 +316,18 @@ export class FossilPlayground {
|
|
|
267
316
|
*
|
|
268
317
|
* # Errors
|
|
269
318
|
*
|
|
270
|
-
* Returns a JS error if `handle` was never opened or was already closed
|
|
319
|
+
* Returns a JS error if `handle` was never opened or was already closed,
|
|
320
|
+
* or if the workspace is already inside another call — see the type-level
|
|
321
|
+
* note on [`WasmPlayground`]. **Neither leaves the workspace unusable**,
|
|
322
|
+
* which is the whole reason this method takes `&self`.
|
|
271
323
|
* @param {FileHandle} handle
|
|
272
324
|
* @param {string} contents
|
|
273
325
|
*/
|
|
274
326
|
update_file(handle, contents) {
|
|
275
327
|
_assertClass(handle, FileHandle);
|
|
276
|
-
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
const ret = wasm.fossilplayground_update_file(this.__wbg_ptr, ptr0, ptr1, len1);
|
|
328
|
+
const ptr0 = passStringToWasm0(contents, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
329
|
+
const len0 = WASM_VECTOR_LEN;
|
|
330
|
+
const ret = wasm.fossilplayground_update_file(this.__wbg_ptr, handle.__wbg_ptr, ptr0, len0);
|
|
280
331
|
if (ret[1]) {
|
|
281
332
|
throw takeFromExternrefTable0(ret[0]);
|
|
282
333
|
}
|
|
@@ -285,15 +336,54 @@ export class FossilPlayground {
|
|
|
285
336
|
if (Symbol.dispose) FossilPlayground.prototype[Symbol.dispose] = FossilPlayground.prototype.free;
|
|
286
337
|
|
|
287
338
|
/**
|
|
288
|
-
*
|
|
339
|
+
* The providers this host installs (`io.csv`, `io.rdf`, `io.shex`, …) as a JS
|
|
340
|
+
* array of `{ name, extensions, kind }`. Pure projection of the provider
|
|
341
|
+
* registry — no parsing, no db. `kind` is read off each row's capabilities, so
|
|
342
|
+
* the two shape-document rows come back as `Schema`.
|
|
343
|
+
*
|
|
344
|
+
* # Errors
|
|
345
|
+
* Returns a JS error only if the result fails to serialize to `JsValue`.
|
|
346
|
+
* @returns {any}
|
|
347
|
+
*/
|
|
348
|
+
export function providers() {
|
|
349
|
+
const ret = wasm.providers();
|
|
350
|
+
if (ret[2]) {
|
|
351
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
352
|
+
}
|
|
353
|
+
return takeFromExternrefTable0(ret[0]);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Parse `program` and return its external references — every data URI +
|
|
358
|
+
* `schema =` argument, each tagged with its `@conn` alias (`null` for a direct
|
|
359
|
+
* path) and role (`Data` / `Schema`) — as a JS array of
|
|
360
|
+
* `{ connection, path, role }`. Parse-only; the host resolves `@conn` →
|
|
361
|
+
* `{base}/path` itself (its data-plane job, kept out of fossil's semantics).
|
|
362
|
+
*
|
|
363
|
+
* # Errors
|
|
364
|
+
* Returns a JS error only if the result fails to serialize to `JsValue`.
|
|
365
|
+
* @param {string} program
|
|
366
|
+
* @returns {any}
|
|
367
|
+
*/
|
|
368
|
+
export function refs(program) {
|
|
369
|
+
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
|
|
370
|
+
const len0 = WASM_VECTOR_LEN;
|
|
371
|
+
const ret = wasm.refs(ptr0, len0);
|
|
372
|
+
if (ret[2]) {
|
|
373
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
374
|
+
}
|
|
375
|
+
return takeFromExternrefTable0(ret[0]);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* `JS`-facing re-export of the semantic-token legend.
|
|
289
380
|
*
|
|
290
381
|
* Returns `{ tokenTypes: string[], tokenModifiers: string[] }` — the exact
|
|
291
|
-
* LSP `SemanticTokensLegend` shape
|
|
292
|
-
* `
|
|
293
|
-
* LSP `semanticTokens/full` response indices into highlight tag names.
|
|
382
|
+
* LSP `SemanticTokensLegend` shape, which is what turns the indices in a
|
|
383
|
+
* `semanticTokens/full` response into names a host can style.
|
|
294
384
|
*
|
|
295
|
-
* Delegates to [`fossil_ide::semantic_legend`]
|
|
296
|
-
*
|
|
385
|
+
* Delegates to [`fossil_ide::semantic_legend`], the one definition — a second
|
|
386
|
+
* legend here would desynchronise the indices the native LSP already emits.
|
|
297
387
|
*
|
|
298
388
|
* # Errors
|
|
299
389
|
*
|
|
@@ -328,10 +418,38 @@ export function start_lsp_worker() {
|
|
|
328
418
|
}
|
|
329
419
|
}
|
|
330
420
|
|
|
421
|
+
/**
|
|
422
|
+
* The name of every [`TokenRow::kind`], indexed BY that kind.
|
|
423
|
+
*
|
|
424
|
+
* `token_kinds()[row.kind]` is the variant name — `"Comment"`, `"KwFrom"`,
|
|
425
|
+
* `"String"`. A host maps names to highlight categories and never writes a
|
|
426
|
+
* discriminant down, which is the only version of this contract that survives
|
|
427
|
+
* a reorder of the lexer.
|
|
428
|
+
*
|
|
429
|
+
* This is the same move [`semantic_legend`] makes for LSP semantic tokens: the
|
|
430
|
+
* indices are meaningless without the legend, so ship the legend.
|
|
431
|
+
*
|
|
432
|
+
* A kind past the end of the array is a variant appended by a newer compiler
|
|
433
|
+
* than the host was built against. That is BACKWARDS-COMPATIBLE by
|
|
434
|
+
* construction: the host sees `undefined` and styles the span as plain text.
|
|
435
|
+
*
|
|
436
|
+
* # Errors
|
|
437
|
+
*
|
|
438
|
+
* Returns a JS error only if `serde_wasm_bindgen` fails to serialise a
|
|
439
|
+
* `Vec<&str>` (impossible in practice).
|
|
440
|
+
* @returns {any}
|
|
441
|
+
*/
|
|
442
|
+
export function tokenKinds() {
|
|
443
|
+
const ret = wasm.tokenKinds();
|
|
444
|
+
if (ret[2]) {
|
|
445
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
446
|
+
}
|
|
447
|
+
return takeFromExternrefTable0(ret[0]);
|
|
448
|
+
}
|
|
449
|
+
|
|
331
450
|
/**
|
|
332
451
|
* `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).
|
|
452
|
+
* serialised via `serde_wasm_bindgen`.
|
|
335
453
|
*
|
|
336
454
|
* # Errors
|
|
337
455
|
*
|
|
@@ -460,6 +578,9 @@ function __wbg_get_imports() {
|
|
|
460
578
|
wasm.__wbindgen_free_command_export(deferred0_0, deferred0_1, 1);
|
|
461
579
|
}
|
|
462
580
|
},
|
|
581
|
+
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
582
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
583
|
+
}, arguments); },
|
|
463
584
|
__wbg_get_652f640b3b0b6e3e: function(arg0, arg1) {
|
|
464
585
|
const ret = arg0[arg1 >>> 0];
|
|
465
586
|
return ret;
|
|
@@ -611,8 +732,8 @@ function __wbg_get_imports() {
|
|
|
611
732
|
return ret;
|
|
612
733
|
},
|
|
613
734
|
__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,
|
|
735
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 6, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
736
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h900f85fb942a113b);
|
|
616
737
|
return ret;
|
|
617
738
|
},
|
|
618
739
|
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
@@ -651,8 +772,8 @@ function __wbg_get_imports() {
|
|
|
651
772
|
};
|
|
652
773
|
}
|
|
653
774
|
|
|
654
|
-
function
|
|
655
|
-
wasm.
|
|
775
|
+
function wasm_bindgen__convert__closures_____invoke__h900f85fb942a113b(arg0, arg1, arg2) {
|
|
776
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h900f85fb942a113b(arg0, arg1, arg2);
|
|
656
777
|
}
|
|
657
778
|
|
|
658
779
|
const FileHandleFinalization = (typeof FinalizationRegistry === 'undefined')
|
package/pkg/fossil_wasm_bg.wasm
CHANGED
|
Binary file
|
|
@@ -4,18 +4,22 @@ 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_hover: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
17
|
+
export const fossilplayground_completions: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
18
|
+
export const fossilplayground_gotoDefinition: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
17
19
|
export const fossilplayground_registerInferredDescriptor: (a: number, b: number, c: number) => [number, number];
|
|
18
|
-
export const
|
|
20
|
+
export const providers: () => [number, number, number];
|
|
21
|
+
export const refs: (a: number, b: number) => [number, number, number];
|
|
22
|
+
export const wasm_bindgen__convert__closures_____invoke__h900f85fb942a113b: (a: number, b: number, c: any) => void;
|
|
19
23
|
export const __wbindgen_malloc_command_export: (a: number, b: number) => number;
|
|
20
24
|
export const __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
|
|
21
25
|
export const __wbindgen_exn_store_command_export: (a: number) => void;
|