@fossil-lang/wasm 0.3.0-alpha.1 → 0.3.0-alpha.3

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.
@@ -0,0 +1,141 @@
1
+ /**
2
+ * The wasm-bindgen-backed runtime surface (lexer, LSP worker, Workspace API) of
3
+ * @fossil-lang/wasm.
4
+ *
5
+ * Kept in its OWN module (NOT the package entry) so the wasm-bindgen glue
6
+ * (`../pkg/fossil_wasm.js`) is imported only from leaf modules — `load.ts` (for
7
+ * `init`) and here. Under a bundler with `"sideEffects": false`, importing the
8
+ * stateful glue from the entry chunk can duplicate it: `init()` then populates
9
+ * the `wasm` binding in one instance while these functions read `undefined` from
10
+ * another (→ `Cannot read properties of undefined (reading '__wbindgen_malloc…')`,
11
+ * seen when the codemirror tokenizer calls `tokenize` on the main thread).
12
+ * Mirrors `@fossil-lang/graph`'s `client.ts` split, the known-good shape.
13
+ */
14
+ import { FileHandle as RawFileHandle } from '../pkg/fossil_wasm.js';
15
+ import type { TokenRow, SemanticTokensLegend } from '@fossil-lang/types';
16
+ import type { CheckRow, StdlibClass, InferredDescriptorJson, SourceRefInfo, ProviderInfo } from './index.js';
17
+ /**
18
+ * Install the LSP-over-postMessage dispatcher on the current Worker scope.
19
+ *
20
+ * Per ADR-0024 (`fossil-wasm` IS the LSP server-side) + Phase 7 plan 07-03
21
+ * (the 16-route dispatch loop). The Rust function (re-exported from
22
+ * `crates/fossil-wasm/src/lsp_worker.rs`) installs `self.onmessage` on the
23
+ * Worker scope and owns LSP JSON-RPC dispatch from that point forward.
24
+ *
25
+ * MUST be called inside a Web Worker scope, AFTER {@link initFossilWasm} has
26
+ * resolved. Calling it on the main thread is a no-op (the dispatcher needs
27
+ * `DedicatedWorkerGlobalScope.onmessage`).
28
+ */
29
+ export declare function start_lsp_worker(): void;
30
+ /**
31
+ * Opaque file-handle returned by {@link FossilPlayground.openFile}. Pass it
32
+ * back into the matching `updateFile` / `closeFile` / `diagnosticsFor`
33
+ * calls. JS code cannot construct one directly (the wasm-bindgen class has a
34
+ * private constructor) — handles are minted only by `openFile` on the Rust
35
+ * side, where they index a `HashMap<FileHandle, SourceFile>` keyed by a `u32`.
36
+ */
37
+ export type FileHandle = RawFileHandle;
38
+ /**
39
+ * Tokenize a Fossil source string. Returns the byte-range tokens from the
40
+ * canonical Rust lexer (`fossil_syntax::lexer::raw_lex`) — single grammar
41
+ * source of truth per ADR-0030.
42
+ *
43
+ * MUST be called after {@link initFossilWasm} has resolved; otherwise the
44
+ * underlying wasm-bindgen function throws (the wasm module is not yet
45
+ * instantiated).
46
+ */
47
+ export declare function tokenize(text: string): TokenRow[];
48
+ /**
49
+ * Returns the LSP `SemanticTokensLegend` (token types + modifiers list) the
50
+ * editor uses to map LSP `semanticTokens/full` response indices to highlight
51
+ * categories. Re-export of `fossil_ide::semantic_legend` over the wasm-bindgen
52
+ * boundary — NO duplicate legend definition lives here.
53
+ *
54
+ * MUST be called after {@link initFossilWasm} has resolved.
55
+ */
56
+ export declare function semanticLegend(): SemanticTokensLegend;
57
+ /**
58
+ * Parse a Fossil program and return its external references — the typed lineage
59
+ * (every data URI + `schema =` argument, each tagged with its `@conn` alias and
60
+ * role). keasy's client-compute job runner reads this to derive a job's
61
+ * connections WITHOUT subprocessing `fossil` / a server round-trip. Identical
62
+ * shape to the native `fossil refs` (the SAME `fossil_run_status::SourceRefInfo`
63
+ * struct), so the browser and the CLI never diverge.
64
+ *
65
+ * MUST be called after {@link initFossilWasm} has resolved.
66
+ */
67
+ export declare function refs(program: string): SourceRefInfo[];
68
+ /**
69
+ * List the data-source providers fossil supports (`io.csv`, `io.rdf`, …) — the
70
+ * provider name, the extensions it reads, and how it can be used. Identical
71
+ * shape to the native `fossil providers`.
72
+ *
73
+ * MUST be called after {@link initFossilWasm} has resolved.
74
+ */
75
+ export declare function providers(): ProviderInfo[];
76
+ /**
77
+ * Workspace API class (ADR-0024). Thin TS wrapper around the wasm-bindgen
78
+ * `FossilPlayground` that exposes camelCase method names for JS idiom + better
79
+ * TS inference (the raw bindings use snake_case from the Rust impl block).
80
+ *
81
+ * One instance per browser tab / Node process — the instance owns the Salsa
82
+ * store + `Arc<OutputDescriptorKind>` for the schema slot.
83
+ *
84
+ * NOTE: {@link FileHandle} is opaque — JS cannot construct one. Callers receive
85
+ * a handle from `openFile` and pass it back to subsequent operations.
86
+ */
87
+ export declare class FossilPlayground {
88
+ private _inner;
89
+ constructor();
90
+ /**
91
+ * Free the underlying WASM-side Salsa store. Call when the playground is no
92
+ * longer needed (e.g. component unmount).
93
+ */
94
+ free(): void;
95
+ /**
96
+ * Return the stdlib classification manifest (STDL-07). The playground reads
97
+ * this once at startup to render `native_udf_only` functions as disabled.
98
+ */
99
+ classification(): StdlibClass[];
100
+ /**
101
+ * Open a file in the workspace. Returns the {@link FileHandle} subsequent
102
+ * `updateFile` / `closeFile` / `diagnosticsFor` calls key on.
103
+ */
104
+ openFile(path: string, contents: string): FileHandle;
105
+ /**
106
+ * Apply an edit to an open file. Mutates the SAME `SourceFile` via the Salsa
107
+ * `Setter` (`set_text`) — bumps the revision (ADR-0022) for incremental
108
+ * invalidation rather than a full recompute.
109
+ */
110
+ updateFile(handle: FileHandle, contents: string): void;
111
+ /**
112
+ * Close a file in the workspace. Strict: closing an unknown / already-closed
113
+ * handle throws so JS-side bugs surface loudly.
114
+ */
115
+ closeFile(handle: FileHandle): void;
116
+ /**
117
+ * Workspace-wide diagnostic drain. Runs `parse → def_map → typecheck_mapping`
118
+ * across every open file and returns a flat array of {@link CheckRow}.
119
+ */
120
+ check(): CheckRow[];
121
+ /**
122
+ * Per-file diagnostic drain — the accessor the LSP Worker uses for its
123
+ * per-file `publishDiagnostics` notifications.
124
+ */
125
+ diagnosticsFor(handle: FileHandle): CheckRow[];
126
+ /**
127
+ * Install a user-supplied ShEx schema as the active output descriptor. On
128
+ * parse failure the previously-installed descriptor is RETAINED.
129
+ */
130
+ setTargetShex(text: string): void;
131
+ /**
132
+ * Register an {@link InferredDescriptorJson} for a source binding name BEFORE
133
+ * invoking {@link check}. The Rust compiler reads from this during forward
134
+ * type propagation.
135
+ *
136
+ * @throws Error if the descriptor JSON fails to deserialise on the Rust side.
137
+ * @see ADR-0037
138
+ */
139
+ registerInferredDescriptor(descriptor: InferredDescriptorJson): void;
140
+ }
141
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAEL,UAAU,IAAI,aAAa,EAM5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,sBAAsB,EACtB,aAAa,EACb,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC;AAEvC;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAMjD;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CAErD;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,EAAE,CAErD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,IAAI,YAAY,EAAE,CAE1C;AAED;;;;;;;;;;GAUG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAsB;;IAMpC;;;OAGG;IACH,IAAI,IAAI,IAAI;IAIZ;;;OAGG;IACH,cAAc,IAAI,WAAW,EAAE;IAI/B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU;IAIpD;;;;OAIG;IACH,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAItD;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAInC;;;OAGG;IACH,KAAK,IAAI,QAAQ,EAAE;IAInB;;;OAGG;IACH,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,QAAQ,EAAE;IAI9C;;;OAGG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIjC;;;;;;;OAOG;IACH,0BAA0B,CAAC,UAAU,EAAE,sBAAsB,GAAG,IAAI;CAKrE"}
package/dist/client.js ADDED
@@ -0,0 +1,167 @@
1
+ /**
2
+ * The wasm-bindgen-backed runtime surface (lexer, LSP worker, Workspace API) of
3
+ * @fossil-lang/wasm.
4
+ *
5
+ * Kept in its OWN module (NOT the package entry) so the wasm-bindgen glue
6
+ * (`../pkg/fossil_wasm.js`) is imported only from leaf modules — `load.ts` (for
7
+ * `init`) and here. Under a bundler with `"sideEffects": false`, importing the
8
+ * stateful glue from the entry chunk can duplicate it: `init()` then populates
9
+ * the `wasm` binding in one instance while these functions read `undefined` from
10
+ * another (→ `Cannot read properties of undefined (reading '__wbindgen_malloc…')`,
11
+ * seen when the codemirror tokenizer calls `tokenize` on the main thread).
12
+ * Mirrors `@fossil-lang/graph`'s `client.ts` split, the known-good shape.
13
+ */
14
+ import { FossilPlayground as RawFossilPlayground, FileHandle as RawFileHandle, tokenize as rawTokenize, semantic_legend as rawSemanticLegend, start_lsp_worker as rawStartLspWorker, refs as rawRefs, providers as rawProviders, } from '../pkg/fossil_wasm.js';
15
+ /**
16
+ * Install the LSP-over-postMessage dispatcher on the current Worker scope.
17
+ *
18
+ * Per ADR-0024 (`fossil-wasm` IS the LSP server-side) + Phase 7 plan 07-03
19
+ * (the 16-route dispatch loop). The Rust function (re-exported from
20
+ * `crates/fossil-wasm/src/lsp_worker.rs`) installs `self.onmessage` on the
21
+ * Worker scope and owns LSP JSON-RPC dispatch from that point forward.
22
+ *
23
+ * MUST be called inside a Web Worker scope, AFTER {@link initFossilWasm} has
24
+ * resolved. Calling it on the main thread is a no-op (the dispatcher needs
25
+ * `DedicatedWorkerGlobalScope.onmessage`).
26
+ */
27
+ export function start_lsp_worker() {
28
+ rawStartLspWorker();
29
+ }
30
+ /**
31
+ * Tokenize a Fossil source string. Returns the byte-range tokens from the
32
+ * canonical Rust lexer (`fossil_syntax::lexer::raw_lex`) — single grammar
33
+ * source of truth per ADR-0030.
34
+ *
35
+ * MUST be called after {@link initFossilWasm} has resolved; otherwise the
36
+ * underlying wasm-bindgen function throws (the wasm module is not yet
37
+ * instantiated).
38
+ */
39
+ export function tokenize(text) {
40
+ // The wasm-bindgen wrapper returns a `JsValue` typed as `any`; the Rust side
41
+ // (crates/fossil-wasm/src/tokenize.rs) serializes `Vec<TokenRow>` via
42
+ // `serde_wasm_bindgen::to_value`, so the shape matches `{ kind, start, end }`
43
+ // exactly. Cast is safe because the Rust ↔ JS contract is enforced upstream.
44
+ return rawTokenize(text);
45
+ }
46
+ /**
47
+ * Returns the LSP `SemanticTokensLegend` (token types + modifiers list) the
48
+ * editor uses to map LSP `semanticTokens/full` response indices to highlight
49
+ * categories. Re-export of `fossil_ide::semantic_legend` over the wasm-bindgen
50
+ * boundary — NO duplicate legend definition lives here.
51
+ *
52
+ * MUST be called after {@link initFossilWasm} has resolved.
53
+ */
54
+ export function semanticLegend() {
55
+ return rawSemanticLegend();
56
+ }
57
+ /**
58
+ * Parse a Fossil program and return its external references — the typed lineage
59
+ * (every data URI + `schema =` argument, each tagged with its `@conn` alias and
60
+ * role). keasy's client-compute job runner reads this to derive a job's
61
+ * connections WITHOUT subprocessing `fossil` / a server round-trip. Identical
62
+ * shape to the native `fossil refs` (the SAME `fossil_run_status::SourceRefInfo`
63
+ * struct), so the browser and the CLI never diverge.
64
+ *
65
+ * MUST be called after {@link initFossilWasm} has resolved.
66
+ */
67
+ export function refs(program) {
68
+ return rawRefs(program);
69
+ }
70
+ /**
71
+ * List the data-source providers fossil supports (`io.csv`, `io.rdf`, …) — the
72
+ * provider name, the extensions it reads, and how it can be used. Identical
73
+ * shape to the native `fossil providers`.
74
+ *
75
+ * MUST be called after {@link initFossilWasm} has resolved.
76
+ */
77
+ export function providers() {
78
+ return rawProviders();
79
+ }
80
+ /**
81
+ * Workspace API class (ADR-0024). Thin TS wrapper around the wasm-bindgen
82
+ * `FossilPlayground` that exposes camelCase method names for JS idiom + better
83
+ * TS inference (the raw bindings use snake_case from the Rust impl block).
84
+ *
85
+ * One instance per browser tab / Node process — the instance owns the Salsa
86
+ * store + `Arc<OutputDescriptorKind>` for the schema slot.
87
+ *
88
+ * NOTE: {@link FileHandle} is opaque — JS cannot construct one. Callers receive
89
+ * a handle from `openFile` and pass it back to subsequent operations.
90
+ */
91
+ export class FossilPlayground {
92
+ _inner;
93
+ constructor() {
94
+ this._inner = new RawFossilPlayground();
95
+ }
96
+ /**
97
+ * Free the underlying WASM-side Salsa store. Call when the playground is no
98
+ * longer needed (e.g. component unmount).
99
+ */
100
+ free() {
101
+ this._inner.free();
102
+ }
103
+ /**
104
+ * Return the stdlib classification manifest (STDL-07). The playground reads
105
+ * this once at startup to render `native_udf_only` functions as disabled.
106
+ */
107
+ classification() {
108
+ return this._inner.classification();
109
+ }
110
+ /**
111
+ * Open a file in the workspace. Returns the {@link FileHandle} subsequent
112
+ * `updateFile` / `closeFile` / `diagnosticsFor` calls key on.
113
+ */
114
+ openFile(path, contents) {
115
+ return this._inner.open_file(path, contents);
116
+ }
117
+ /**
118
+ * Apply an edit to an open file. Mutates the SAME `SourceFile` via the Salsa
119
+ * `Setter` (`set_text`) — bumps the revision (ADR-0022) for incremental
120
+ * invalidation rather than a full recompute.
121
+ */
122
+ updateFile(handle, contents) {
123
+ this._inner.update_file(handle, contents);
124
+ }
125
+ /**
126
+ * Close a file in the workspace. Strict: closing an unknown / already-closed
127
+ * handle throws so JS-side bugs surface loudly.
128
+ */
129
+ closeFile(handle) {
130
+ this._inner.close_file(handle);
131
+ }
132
+ /**
133
+ * Workspace-wide diagnostic drain. Runs `parse → def_map → typecheck_mapping`
134
+ * across every open file and returns a flat array of {@link CheckRow}.
135
+ */
136
+ check() {
137
+ return this._inner.check();
138
+ }
139
+ /**
140
+ * Per-file diagnostic drain — the accessor the LSP Worker uses for its
141
+ * per-file `publishDiagnostics` notifications.
142
+ */
143
+ diagnosticsFor(handle) {
144
+ return this._inner.diagnostics_for(handle);
145
+ }
146
+ /**
147
+ * Install a user-supplied ShEx schema as the active output descriptor. On
148
+ * parse failure the previously-installed descriptor is RETAINED.
149
+ */
150
+ setTargetShex(text) {
151
+ this._inner.set_target_shex(text);
152
+ }
153
+ /**
154
+ * Register an {@link InferredDescriptorJson} for a source binding name BEFORE
155
+ * invoking {@link check}. The Rust compiler reads from this during forward
156
+ * type propagation.
157
+ *
158
+ * @throws Error if the descriptor JSON fails to deserialise on the Rust side.
159
+ * @see ADR-0037
160
+ */
161
+ registerInferredDescriptor(descriptor) {
162
+ // The wasm-bindgen wrapper accepts a JSON string; serialise here so callers
163
+ // pass a typed object.
164
+ this._inner.registerInferredDescriptor(JSON.stringify(descriptor));
165
+ }
166
+ }
167
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,gBAAgB,IAAI,mBAAmB,EACvC,UAAU,IAAI,aAAa,EAC3B,QAAQ,IAAI,WAAW,EACvB,eAAe,IAAI,iBAAiB,EACpC,gBAAgB,IAAI,iBAAiB,EACrC,IAAI,IAAI,OAAO,EACf,SAAS,IAAI,YAAY,GAC1B,MAAM,uBAAuB,CAAC;AAU/B;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB;IAC9B,iBAAiB,EAAE,CAAC;AACtB,CAAC;AAWD;;;;;;;;GAQG;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AC;IAED;;;OAGG;IACH,cAAc,CAAC,MAAkB;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAe,CAAC;IAC3D,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,IAAY;QACxB,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;;OAOG;IACH,0BAA0B,CAAC,UAAkC;QAC3D,4EAA4E;QAC5E,uBAAuB;QACvB,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IACrE,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -15,59 +15,28 @@
15
15
  * await initFossilWasm({ wasmUrl });
16
16
  * const tokens = tokenize('prefix ex: <https://example.org/>');
17
17
  */
18
- import { FileHandle as RawFileHandle } from '../pkg/fossil_wasm.js';
19
- import type { TokenRow, SemanticTokensLegend } from '@fossil-lang/types';
20
18
  export { initFossilWasm } from './load.js';
21
19
  export type { InitFossilWasmOpts } from './load.js';
22
- /**
23
- * Install the LSP-over-postMessage dispatcher on the current Worker scope.
24
- *
25
- * Per ADR-0024 (`fossil-wasm` IS the LSP server-side) + Phase 7 plan 07-03
26
- * (the 16-route dispatch loop). The Rust function (re-exported from
27
- * `crates/fossil-wasm/src/lsp_worker.rs`) installs `self.onmessage` on the
28
- * Worker scope and owns LSP JSON-RPC dispatch from that point forward —
29
- * including per-file `textDocument/publishDiagnostics` drains (B3 fix from
30
- * 07-03), `textDocument/semanticTokens/full` (06-07), hover, completion,
31
- * definition, references, rename, formatting, code actions, document
32
- * symbols, signature help.
33
- *
34
- * MUST be called inside a Web Worker scope, AFTER {@link initFossilWasm} has
35
- * resolved. Calling it on the main thread is a no-op (the dispatcher needs
36
- * `DedicatedWorkerGlobalScope.onmessage`).
37
- *
38
- * Consumed by `@fossil-lang/playground`'s `src/workers/lsp.worker.ts` —
39
- * the React component's LSP Worker entry boots the WASM module then calls
40
- * this function once.
41
- */
42
- export declare function start_lsp_worker(): void;
43
- /**
44
- * Opaque file-handle returned by {@link FossilPlayground.openFile}. Pass it
45
- * back into the matching `updateFile` / `closeFile` / `diagnosticsFor`
46
- * calls. JS code cannot construct one directly (the wasm-bindgen
47
- * class has a private constructor) — that is intentional per ADR-0024:
48
- * handles are minted only by `openFile` on the Rust side, where they index a
49
- * `HashMap<FileHandle, SourceFile>` keyed by a `u32` newtype.
50
- */
51
- export type FileHandle = RawFileHandle;
52
- /**
53
- * Tokenize a Fossil source string. Returns the byte-range tokens from the
54
- * canonical Rust lexer (`fossil_syntax::lexer::raw_lex`) — single grammar
55
- * source of truth per ADR-0030.
56
- *
57
- * MUST be called after {@link initFossilWasm} has resolved; otherwise the
58
- * underlying wasm-bindgen function throws (the wasm module is not yet
59
- * instantiated).
60
- */
61
- export declare function tokenize(text: string): TokenRow[];
62
- /**
63
- * Returns the LSP `SemanticTokensLegend` (token types + modifiers list) the
64
- * editor uses to map LSP `semanticTokens/full` response indices to highlight
65
- * categories. Re-export of `fossil_ide::semantic_legend` (Phase-6 06-07) over
66
- * the wasm-bindgen boundary — NO duplicate legend definition lives here.
67
- *
68
- * MUST be called after {@link initFossilWasm} has resolved.
69
- */
70
- export declare function semanticLegend(): SemanticTokensLegend;
20
+ export { start_lsp_worker, tokenize, semanticLegend, FossilPlayground, refs, providers, } from './client.js';
21
+ export type { FileHandle } from './client.js';
22
+ /** One external reference a program makes — the typed lineage returned by
23
+ * {@link refs}. Mirrors `fossil_run_status::SourceRefInfo` (the SAME struct the
24
+ * native `fossil refs` emits). `connection` is the `@conn` alias the reference
25
+ * targets, or `null` for a direct URL/path; `role` is where it appears in the
26
+ * source constructor. The host resolves `@conn` → `{base}/path` itself. */
27
+ export interface SourceRefInfo {
28
+ connection: string | null;
29
+ path: string;
30
+ role: 'data' | 'schema';
31
+ }
32
+ /** One data-source provider returned by {@link providers}. Mirrors
33
+ * `fossil_run_status::ProviderInfo`: the short name (`csv`, `rdf`, …), the file
34
+ * extensions it reads (no leading dot), and how it can be used. */
35
+ export interface ProviderInfo {
36
+ name: string;
37
+ extensions: string[];
38
+ kind: 'schema' | 'data' | 'both';
39
+ }
71
40
  /** Diagnostic row returned by {@link FossilPlayground.check} and
72
41
  * {@link FossilPlayground.diagnosticsFor} — mirrors `fossil-wasm`'s
73
42
  * `CheckRow` JSON shape (the LSP `Diagnostic` projected through
@@ -136,111 +105,5 @@ export interface InferredDescriptorJson {
136
105
  */
137
106
  content_hash: string;
138
107
  }
139
- /**
140
- * Workspace API class (ADR-0024). Thin TS wrapper around the wasm-bindgen
141
- * `FossilPlayground` that exposes camelCase method names for JS idiom + better
142
- * TS inference (the raw bindings use snake_case from the Rust impl block).
143
- *
144
- * One instance per browser tab / Node process — the instance owns the Salsa
145
- * store + `Arc<OutputDescriptorKind>` for the schema slot. Subsequent
146
- * `openFile` calls intern fresh `SourceFile` inputs under the same Salsa
147
- * revision so `updateFile` benefits from incremental memoisation.
148
- *
149
- * The Phase 7 LSP Worker (07-03) drives this class via postMessage; the React
150
- * component in `@fossil-lang/playground` (08-09) does the same via the
151
- * WorkerTransport adapter.
152
- *
153
- * NOTE: {@link FileHandle} is opaque — JS cannot construct one. Callers receive
154
- * a handle from `openFile` and pass it back to subsequent operations. The Rust
155
- * side keeps a `HashMap<FileHandle, SourceFile>` indexed by a `u32` newtype;
156
- * the wasm-bindgen wrapper exposes that as a class with `private constructor()`.
157
- */
158
- export declare class FossilPlayground {
159
- private _inner;
160
- constructor();
161
- /**
162
- * Free the underlying WASM-side Salsa store. Call when the playground is no
163
- * longer needed (e.g. component unmount). Idempotent in spirit — subsequent
164
- * method calls on a freed playground throw.
165
- */
166
- free(): void;
167
- /**
168
- * Return the stdlib classification manifest (STDL-07). The playground reads
169
- * this once at startup to render `native_udf_only` functions as disabled
170
- * with a "native-only — unavailable in the browser" tooltip.
171
- */
172
- classification(): StdlibClass[];
173
- /**
174
- * Open a file in the workspace. Returns the {@link FileHandle} subsequent
175
- * `updateFile` / `closeFile` / `diagnosticsFor` calls key
176
- * on. `path` is the URI / virtual path diagnostics carry back to the LSP
177
- * client (e.g. `"file:///tmp/a.fossil"` or `"untitled:Untitled-1"`).
178
- *
179
- * Mirrors `ty_wasm::Workspace::open_file` (Astral). Interns a fresh
180
- * `fossil_base::SourceFile` under the current Salsa revision.
181
- */
182
- openFile(path: string, contents: string): FileHandle;
183
- /**
184
- * Apply an edit to an open file. Mutates the SAME `SourceFile` via the
185
- * Salsa `Setter` (`set_text`) — this BUMPS THE REVISION (ADR-0022), the
186
- * real cancellation trigger. NO new `SourceFile` is interned, so memoised
187
- * downstream queries (`def_map`, `typecheck_mapping`) invalidate
188
- * incrementally instead of falling off a cliff.
189
- */
190
- updateFile(handle: FileHandle, contents: string): void;
191
- /**
192
- * Close a file in the workspace. Strict in signal: closing an unknown /
193
- * already-closed handle throws so JS-side bugs surface loudly (mirrors
194
- * `ty_wasm`).
195
- */
196
- closeFile(handle: FileHandle): void;
197
- /**
198
- * Workspace-wide diagnostic drain. Runs `parse → def_map →
199
- * typecheck_mapping` across every open file and returns a flat array of
200
- * {@link CheckRow}. The LSP Worker (07-03) republishes these grouped by URI
201
- * as `textDocument/publishDiagnostics` notifications.
202
- */
203
- check(): CheckRow[];
204
- /**
205
- * Per-file diagnostic drain — the B3 follow-up accessor the LSP Worker uses
206
- * for its per-file `publishDiagnostics` notifications. `check()` returns
207
- * the workspace-wide flat array; `diagnosticsFor` returns just one file's
208
- * rows so 07-03 can dispatch one notification per affected URI without
209
- * partitioning the workspace array on the JS side.
210
- */
211
- diagnosticsFor(handle: FileHandle): CheckRow[];
212
- /**
213
- * Install a user-supplied ShEx schema as the active output descriptor. On
214
- * parse failure the previously-installed descriptor is RETAINED (no
215
- * half-applied state — same contract as `fossil-lsp::load_sibling_shex` in
216
- * 06-09). Future `fossil-ide` feature calls (hover, completion) reading
217
- * `HirDb::output_descriptor_kind` see the new schema atomically.
218
- */
219
- setTargetShex(text: string): void;
220
- /**
221
- * Register an {@link InferredDescriptorJson} for a source binding name
222
- * BEFORE invoking {@link check}. The Rust compiler reads from this
223
- * registration during forward type propagation (Phase 3 CORE-05 rewired in
224
- * plan 13-02).
225
- *
226
- * The browser-side orchestration runs DuckDB-WASM
227
- * `DESCRIBE read_csv_auto('<resolved-url>')` for each `io.csv("...")`
228
- * reference in the source, canonicalises the columns to the
229
- * {@link InferredPrimitive} catalog, and calls this method with the
230
- * resulting descriptor before {@link check}. See ADR-0037 for the full
231
- * architectural rationale.
232
- *
233
- * Keyed by source-binding name (e.g. `"users"` for
234
- * `users := io.csv("...")`), NOT by URL. Idempotent — re-registering with
235
- * the same `source_name` overwrites the previous entry.
236
- *
237
- * @throws Error if the descriptor JSON fails to deserialise on the Rust
238
- * side (e.g. missing required fields). The error message includes
239
- * the underlying serde_json diagnostic.
240
- *
241
- * @see ADR-0037 — drop user-facing CSVW; infer via DuckDB DESCRIBE
242
- */
243
- registerInferredDescriptor(descriptor: InferredDescriptorJson): void;
244
- }
245
108
  export type { TokenRow, SemanticTokensLegend } from '@fossil-lang/types';
246
109
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,EAEL,UAAU,IAAI,aAAa,EAI5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,UAAU,GAAG,aAAa,CAAC;AAEvC;;;;;;;;GAQG;AACH,wBAAgB,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,GAAG,MAAM,GAAG,MAAM,CAAC;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;QAC3C,GAAG,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,CAAC;KAC1C,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,UAAU,GAAG,iBAAiB,CAAC;CAC5C;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GACzB,QAAQ,GACR,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,UAAU,GACV,MAAM,GACN,OAAO,GACP,QAAQ,CAAC;AAEb,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAKD,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -15,187 +15,12 @@
15
15
  * await initFossilWasm({ wasmUrl });
16
16
  * const tokens = tokenize('prefix ex: <https://example.org/>');
17
17
  */
18
- // '../pkg/fossil_wasm.js' is a wasm-bindgen --target web output emitted by `pnpm run build:wasm`.
19
- // Gitignored at the repo root (`packages/wasm/pkg/`) but always present at build time. The accompanying
20
- // .d.ts is consumed via the file's `/* @ts-self-types="./fossil_wasm.d.ts" */` pragma.
21
- import { FossilPlayground as RawFossilPlayground, FileHandle as RawFileHandle, tokenize as rawTokenize, semantic_legend as rawSemanticLegend, start_lsp_worker as rawStartLspWorker, } from '../pkg/fossil_wasm.js';
18
+ // The wasm-bindgen glue (`../pkg/fossil_wasm.js`) is imported ONLY from leaf
19
+ // modules — `load.ts` (init) and `client.ts` (the lexer / LSP / Workspace API) —
20
+ // never here in the entry. See `client.ts`: importing the stateful glue from the
21
+ // package entry lets a `sideEffects:false` bundler duplicate it, splitting
22
+ // `init()`'s wasm instance from the one the functions use (the crash the
23
+ // codemirror tokenizer hit on the main thread). This entry only re-exports.
22
24
  export { initFossilWasm } from './load.js';
23
- /**
24
- * Install the LSP-over-postMessage dispatcher on the current Worker scope.
25
- *
26
- * Per ADR-0024 (`fossil-wasm` IS the LSP server-side) + Phase 7 plan 07-03
27
- * (the 16-route dispatch loop). The Rust function (re-exported from
28
- * `crates/fossil-wasm/src/lsp_worker.rs`) installs `self.onmessage` on the
29
- * Worker scope and owns LSP JSON-RPC dispatch from that point forward —
30
- * including per-file `textDocument/publishDiagnostics` drains (B3 fix from
31
- * 07-03), `textDocument/semanticTokens/full` (06-07), hover, completion,
32
- * definition, references, rename, formatting, code actions, document
33
- * symbols, signature help.
34
- *
35
- * MUST be called inside a Web Worker scope, AFTER {@link initFossilWasm} has
36
- * resolved. Calling it on the main thread is a no-op (the dispatcher needs
37
- * `DedicatedWorkerGlobalScope.onmessage`).
38
- *
39
- * Consumed by `@fossil-lang/playground`'s `src/workers/lsp.worker.ts` —
40
- * the React component's LSP Worker entry boots the WASM module then calls
41
- * this function once.
42
- */
43
- export function start_lsp_worker() {
44
- rawStartLspWorker();
45
- }
46
- /**
47
- * Tokenize a Fossil source string. Returns the byte-range tokens from the
48
- * canonical Rust lexer (`fossil_syntax::lexer::raw_lex`) — single grammar
49
- * source of truth per ADR-0030.
50
- *
51
- * MUST be called after {@link initFossilWasm} has resolved; otherwise the
52
- * underlying wasm-bindgen function throws (the wasm module is not yet
53
- * instantiated).
54
- */
55
- export function tokenize(text) {
56
- // The wasm-bindgen wrapper returns a `JsValue` typed as `any`; the Rust side
57
- // (crates/fossil-wasm/src/tokenize.rs) serializes `Vec<TokenRow>` via
58
- // `serde_wasm_bindgen::to_value`, so the shape matches `{ kind, start, end }`
59
- // exactly. Cast is safe because the Rust ↔ JS contract is enforced upstream.
60
- return rawTokenize(text);
61
- }
62
- /**
63
- * Returns the LSP `SemanticTokensLegend` (token types + modifiers list) the
64
- * editor uses to map LSP `semanticTokens/full` response indices to highlight
65
- * categories. Re-export of `fossil_ide::semantic_legend` (Phase-6 06-07) over
66
- * the wasm-bindgen boundary — NO duplicate legend definition lives here.
67
- *
68
- * MUST be called after {@link initFossilWasm} has resolved.
69
- */
70
- export function semanticLegend() {
71
- return rawSemanticLegend();
72
- }
73
- /**
74
- * Workspace API class (ADR-0024). Thin TS wrapper around the wasm-bindgen
75
- * `FossilPlayground` that exposes camelCase method names for JS idiom + better
76
- * TS inference (the raw bindings use snake_case from the Rust impl block).
77
- *
78
- * One instance per browser tab / Node process — the instance owns the Salsa
79
- * store + `Arc<OutputDescriptorKind>` for the schema slot. Subsequent
80
- * `openFile` calls intern fresh `SourceFile` inputs under the same Salsa
81
- * revision so `updateFile` benefits from incremental memoisation.
82
- *
83
- * The Phase 7 LSP Worker (07-03) drives this class via postMessage; the React
84
- * component in `@fossil-lang/playground` (08-09) does the same via the
85
- * WorkerTransport adapter.
86
- *
87
- * NOTE: {@link FileHandle} is opaque — JS cannot construct one. Callers receive
88
- * a handle from `openFile` and pass it back to subsequent operations. The Rust
89
- * side keeps a `HashMap<FileHandle, SourceFile>` indexed by a `u32` newtype;
90
- * the wasm-bindgen wrapper exposes that as a class with `private constructor()`.
91
- */
92
- export class FossilPlayground {
93
- _inner;
94
- constructor() {
95
- this._inner = new RawFossilPlayground();
96
- }
97
- /**
98
- * Free the underlying WASM-side Salsa store. Call when the playground is no
99
- * longer needed (e.g. component unmount). Idempotent in spirit — subsequent
100
- * method calls on a freed playground throw.
101
- */
102
- free() {
103
- this._inner.free();
104
- }
105
- /**
106
- * Return the stdlib classification manifest (STDL-07). The playground reads
107
- * this once at startup to render `native_udf_only` functions as disabled
108
- * with a "native-only — unavailable in the browser" tooltip.
109
- */
110
- classification() {
111
- return this._inner.classification();
112
- }
113
- /**
114
- * Open a file in the workspace. Returns the {@link FileHandle} subsequent
115
- * `updateFile` / `closeFile` / `diagnosticsFor` calls key
116
- * on. `path` is the URI / virtual path diagnostics carry back to the LSP
117
- * client (e.g. `"file:///tmp/a.fossil"` or `"untitled:Untitled-1"`).
118
- *
119
- * Mirrors `ty_wasm::Workspace::open_file` (Astral). Interns a fresh
120
- * `fossil_base::SourceFile` under the current Salsa revision.
121
- */
122
- openFile(path, contents) {
123
- return this._inner.open_file(path, contents);
124
- }
125
- /**
126
- * Apply an edit to an open file. Mutates the SAME `SourceFile` via the
127
- * Salsa `Setter` (`set_text`) — this BUMPS THE REVISION (ADR-0022), the
128
- * real cancellation trigger. NO new `SourceFile` is interned, so memoised
129
- * downstream queries (`def_map`, `typecheck_mapping`) invalidate
130
- * incrementally instead of falling off a cliff.
131
- */
132
- updateFile(handle, contents) {
133
- this._inner.update_file(handle, contents);
134
- }
135
- /**
136
- * Close a file in the workspace. Strict in signal: closing an unknown /
137
- * already-closed handle throws so JS-side bugs surface loudly (mirrors
138
- * `ty_wasm`).
139
- */
140
- closeFile(handle) {
141
- this._inner.close_file(handle);
142
- }
143
- /**
144
- * Workspace-wide diagnostic drain. Runs `parse → def_map →
145
- * typecheck_mapping` across every open file and returns a flat array of
146
- * {@link CheckRow}. The LSP Worker (07-03) republishes these grouped by URI
147
- * as `textDocument/publishDiagnostics` notifications.
148
- */
149
- check() {
150
- return this._inner.check();
151
- }
152
- /**
153
- * Per-file diagnostic drain — the B3 follow-up accessor the LSP Worker uses
154
- * for its per-file `publishDiagnostics` notifications. `check()` returns
155
- * the workspace-wide flat array; `diagnosticsFor` returns just one file's
156
- * rows so 07-03 can dispatch one notification per affected URI without
157
- * partitioning the workspace array on the JS side.
158
- */
159
- diagnosticsFor(handle) {
160
- return this._inner.diagnostics_for(handle);
161
- }
162
- /**
163
- * Install a user-supplied ShEx schema as the active output descriptor. On
164
- * parse failure the previously-installed descriptor is RETAINED (no
165
- * half-applied state — same contract as `fossil-lsp::load_sibling_shex` in
166
- * 06-09). Future `fossil-ide` feature calls (hover, completion) reading
167
- * `HirDb::output_descriptor_kind` see the new schema atomically.
168
- */
169
- setTargetShex(text) {
170
- this._inner.set_target_shex(text);
171
- }
172
- /**
173
- * Register an {@link InferredDescriptorJson} for a source binding name
174
- * BEFORE invoking {@link check}. The Rust compiler reads from this
175
- * registration during forward type propagation (Phase 3 CORE-05 rewired in
176
- * plan 13-02).
177
- *
178
- * The browser-side orchestration runs DuckDB-WASM
179
- * `DESCRIBE read_csv_auto('<resolved-url>')` for each `io.csv("...")`
180
- * reference in the source, canonicalises the columns to the
181
- * {@link InferredPrimitive} catalog, and calls this method with the
182
- * resulting descriptor before {@link check}. See ADR-0037 for the full
183
- * architectural rationale.
184
- *
185
- * Keyed by source-binding name (e.g. `"users"` for
186
- * `users := io.csv("...")`), NOT by URL. Idempotent — re-registering with
187
- * the same `source_name` overwrites the previous entry.
188
- *
189
- * @throws Error if the descriptor JSON fails to deserialise on the Rust
190
- * side (e.g. missing required fields). The error message includes
191
- * the underlying serde_json diagnostic.
192
- *
193
- * @see ADR-0037 — drop user-facing CSVW; infer via DuckDB DESCRIBE
194
- */
195
- registerInferredDescriptor(descriptor) {
196
- // The wasm-bindgen wrapper exposes `registerInferredDescriptor(string)` —
197
- // it accepts a JSON string. Serialise here so callers pass a typed object.
198
- this._inner.registerInferredDescriptor(JSON.stringify(descriptor));
199
- }
200
- }
25
+ export { start_lsp_worker, tokenize, semanticLegend, FossilPlayground, refs, providers, } from './client.js';
201
26
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,kGAAkG;AAClG,wGAAwG;AACxG,uFAAuF;AACvF,OAAO,EACL,gBAAgB,IAAI,mBAAmB,EACvC,UAAU,IAAI,aAAa,EAC3B,QAAQ,IAAI,WAAW,EACvB,eAAe,IAAI,iBAAiB,EACpC,gBAAgB,IAAI,iBAAiB,GACtC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,iBAAiB,EAAE,CAAC;AACtB,CAAC;AAYD;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,6EAA6E;IAC7E,sEAAsE;IACtE,8EAA8E;IAC9E,6EAA6E;IAC7E,OAAO,WAAW,CAAC,IAAI,CAAe,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,iBAAiB,EAA0B,CAAC;AACrD,CAAC;AA8ED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAsB;IAEpC;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,EAAmB,CAAC;IACvD,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ,CAAC,IAAY,EAAE,QAAgB;QACrC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED;;;;;;OAMG;IACH,UAAU,CAAC,MAAkB,EAAE,QAAgB;QAC7C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,MAAkB;QAC1B,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED;;;;;OAKG;IACH,KAAK;QACH,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAgB,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACH,cAAc,CAAC,MAAkB;QAC/B,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAe,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACH,aAAa,CAAC,IAAY;QACxB,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,0BAA0B,CAAC,UAAkC;QAC3D,0EAA0E;QAC1E,2EAA2E;QAC3E,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IACrE,CAAC;CACF"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,6EAA6E;AAC7E,iFAAiF;AACjF,iFAAiF;AACjF,2EAA2E;AAC3E,yEAAyE;AACzE,4EAA4E;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,IAAI,EACJ,SAAS,GACV,MAAM,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fossil-lang/wasm",
3
- "version": "0.3.0-alpha.1",
3
+ "version": "0.3.0-alpha.3",
4
4
  "description": "JS/TS wrapper around the fossil-wasm wasm-bindgen artifacts (--target web). Exposes initFossilWasm + tokenize + semanticLegend + FossilPlayground class for downstream @fossil-lang/* packages.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -33,7 +33,7 @@
33
33
  ],
34
34
  "sideEffects": false,
35
35
  "dependencies": {
36
- "@fossil-lang/types": "0.3.0-alpha.1"
36
+ "@fossil-lang/types": "0.3.0-alpha.3"
37
37
  },
38
38
  "devDependencies": {
39
39
  "typescript": "^5.6.0",
@@ -185,6 +185,28 @@ export class FossilPlayground {
185
185
  update_file(handle: FileHandle, contents: string): void;
186
186
  }
187
187
 
188
+ /**
189
+ * The data-source providers fossil supports (`io.csv`, `io.rdf`, …) as a JS
190
+ * array of `{ name, extensions, kind }`. Pure projection of the stdlib source
191
+ * registry — no parsing, no db.
192
+ *
193
+ * # Errors
194
+ * Returns a JS error only if the result fails to serialize to `JsValue`.
195
+ */
196
+ export function providers(): any;
197
+
198
+ /**
199
+ * Parse `program` and return its external references — every data URI +
200
+ * `schema =` argument, each tagged with its `@conn` alias (`null` for a direct
201
+ * path) and role (`Data` / `Schema`) — as a JS array of
202
+ * `{ connection, path, role }`. Parse-only; the host resolves `@conn` →
203
+ * `{base}/path` itself (its data-plane job, kept out of fossil's semantics).
204
+ *
205
+ * # Errors
206
+ * Returns a JS error only if the result fails to serialize to `JsValue`.
207
+ */
208
+ export function refs(program: string): any;
209
+
188
210
  /**
189
211
  * `JS`-facing re-export of the Phase-6 06-07 semantic-token legend.
190
212
  *
@@ -249,7 +271,9 @@ export interface InitOutput {
249
271
  readonly fossilplayground_diagnostics_for: (a: number, b: number) => [number, number, number];
250
272
  readonly fossilplayground_set_target_shex: (a: number, b: number, c: number) => [number, number];
251
273
  readonly fossilplayground_registerInferredDescriptor: (a: number, b: number, c: number) => [number, number];
252
- readonly wasm_bindgen__convert__closures_____invoke__h4393dedb0066ad40: (a: number, b: number, c: any) => void;
274
+ readonly providers: () => [number, number, number];
275
+ readonly refs: (a: number, b: number) => [number, number, number];
276
+ readonly wasm_bindgen__convert__closures_____invoke__h6bdcc41945596778: (a: number, b: number, c: any) => void;
253
277
  readonly __wbindgen_malloc_command_export: (a: number, b: number) => number;
254
278
  readonly __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
255
279
  readonly __wbindgen_exn_store_command_export: (a: number) => void;
@@ -284,6 +284,45 @@ export class FossilPlayground {
284
284
  }
285
285
  if (Symbol.dispose) FossilPlayground.prototype[Symbol.dispose] = FossilPlayground.prototype.free;
286
286
 
287
+ /**
288
+ * The data-source providers fossil supports (`io.csv`, `io.rdf`, …) as a JS
289
+ * array of `{ name, extensions, kind }`. Pure projection of the stdlib source
290
+ * registry — no parsing, no db.
291
+ *
292
+ * # Errors
293
+ * Returns a JS error only if the result fails to serialize to `JsValue`.
294
+ * @returns {any}
295
+ */
296
+ export function providers() {
297
+ const ret = wasm.providers();
298
+ if (ret[2]) {
299
+ throw takeFromExternrefTable0(ret[1]);
300
+ }
301
+ return takeFromExternrefTable0(ret[0]);
302
+ }
303
+
304
+ /**
305
+ * Parse `program` and return its external references — every data URI +
306
+ * `schema =` argument, each tagged with its `@conn` alias (`null` for a direct
307
+ * path) and role (`Data` / `Schema`) — as a JS array of
308
+ * `{ connection, path, role }`. Parse-only; the host resolves `@conn` →
309
+ * `{base}/path` itself (its data-plane job, kept out of fossil's semantics).
310
+ *
311
+ * # Errors
312
+ * Returns a JS error only if the result fails to serialize to `JsValue`.
313
+ * @param {string} program
314
+ * @returns {any}
315
+ */
316
+ export function refs(program) {
317
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc_command_export, wasm.__wbindgen_realloc_command_export);
318
+ const len0 = WASM_VECTOR_LEN;
319
+ const ret = wasm.refs(ptr0, len0);
320
+ if (ret[2]) {
321
+ throw takeFromExternrefTable0(ret[1]);
322
+ }
323
+ return takeFromExternrefTable0(ret[0]);
324
+ }
325
+
287
326
  /**
288
327
  * `JS`-facing re-export of the Phase-6 06-07 semantic-token legend.
289
328
  *
@@ -612,7 +651,7 @@ function __wbg_get_imports() {
612
651
  },
613
652
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
614
653
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 9, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
615
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h4393dedb0066ad40);
654
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h6bdcc41945596778);
616
655
  return ret;
617
656
  },
618
657
  __wbindgen_cast_0000000000000002: function(arg0) {
@@ -651,8 +690,8 @@ function __wbg_get_imports() {
651
690
  };
652
691
  }
653
692
 
654
- function wasm_bindgen__convert__closures_____invoke__h4393dedb0066ad40(arg0, arg1, arg2) {
655
- wasm.wasm_bindgen__convert__closures_____invoke__h4393dedb0066ad40(arg0, arg1, arg2);
693
+ function wasm_bindgen__convert__closures_____invoke__h6bdcc41945596778(arg0, arg1, arg2) {
694
+ wasm.wasm_bindgen__convert__closures_____invoke__h6bdcc41945596778(arg0, arg1, arg2);
656
695
  }
657
696
 
658
697
  const FileHandleFinalization = (typeof FinalizationRegistry === 'undefined')
Binary file
@@ -15,7 +15,9 @@ export const fossilplayground_check: (a: number) => [number, number, number];
15
15
  export const fossilplayground_diagnostics_for: (a: number, b: number) => [number, number, number];
16
16
  export const fossilplayground_set_target_shex: (a: number, b: number, c: number) => [number, number];
17
17
  export const fossilplayground_registerInferredDescriptor: (a: number, b: number, c: number) => [number, number];
18
- export const wasm_bindgen__convert__closures_____invoke__h4393dedb0066ad40: (a: number, b: number, c: any) => void;
18
+ export const providers: () => [number, number, number];
19
+ export const refs: (a: number, b: number) => [number, number, number];
20
+ export const wasm_bindgen__convert__closures_____invoke__h6bdcc41945596778: (a: number, b: number, c: any) => void;
19
21
  export const __wbindgen_malloc_command_export: (a: number, b: number) => number;
20
22
  export const __wbindgen_realloc_command_export: (a: number, b: number, c: number, d: number) => number;
21
23
  export const __wbindgen_exn_store_command_export: (a: number) => void;