@fossil-lang/wasm 0.3.0-alpha.18 → 0.3.0-alpha.19
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 +2 -1
- package/dist/index.d.ts +5 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -7
- package/dist/index.js.map +1 -1
- package/dist/load.d.ts +3 -1
- package/dist/load.d.ts.map +1 -1
- package/dist/load.js +11 -3
- package/dist/load.js.map +1 -1
- package/dist/program.d.ts +9 -3
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +28 -8
- package/dist/program.js.map +1 -1
- package/package.json +3 -3
- package/pkg/fossil_wasm.d.ts +4 -6
- package/pkg/fossil_wasm.js +4 -6
- package/pkg/fossil_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@ JS/TS wrapper around the `fossil-wasm` Rust crate's wasm-bindgen artefacts. Prov
|
|
|
4
4
|
|
|
5
5
|
- `openProgram(uri, { host, text })` — one program open for an editor, and the
|
|
6
6
|
call a host with an editor makes. See below.
|
|
7
|
-
- `initFossilWasm()` — boots the module
|
|
7
|
+
- `initFossilWasm()` — boots the module, within 60 s (`module/unreachable` when it
|
|
8
|
+
cannot be fetched); a boot that failed is forgotten, so the next call tries again. Its `.wasm` ships in this
|
|
8
9
|
package and the host's bundler emits it as an asset; the host copies nothing.
|
|
9
10
|
- `tokenize(text)` — calls the Rust lexer, returns `TokenRow[]`. The Rust lexer
|
|
10
11
|
is the only lexer: no host reimplements one and drifts from the grammar.
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public API (one of the @fossil-lang/* packages; `git ls-files packages` is
|
|
5
5
|
* the list):
|
|
6
|
-
* - {@link initFossilWasm} — boots the module; its `.wasm` is a bundler asset
|
|
6
|
+
* - {@link initFossilWasm} — boots the module; its `.wasm` is a bundler asset. A failed boot is
|
|
7
|
+
* forgotten, so the next call tries again.
|
|
7
8
|
* - {@link tokenize} — calls the Rust lexer, returns TokenRow[].
|
|
8
9
|
* - {@link tokenKinds} — the legend for TokenRow.kind: variant names by index.
|
|
9
10
|
* - {@link semanticLegend} — returns the LSP SemanticTokensLegend.
|
|
@@ -47,17 +48,9 @@ export interface ProviderInfo {
|
|
|
47
48
|
extensions: string[];
|
|
48
49
|
kind: 'schema' | 'data' | 'both';
|
|
49
50
|
}
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
|
|
53
|
-
* `fossil_ide::LineIndex` for UTF-16 ranges).
|
|
54
|
-
*/
|
|
55
|
-
export interface CheckRow {
|
|
56
|
-
uri: string;
|
|
57
|
-
range: LspRange;
|
|
58
|
-
severity: number;
|
|
59
|
-
message: string;
|
|
60
|
-
}
|
|
51
|
+
/** The rows {@link FossilWorkspace.check} and {@link FossilWorkspace.diagnosticsFor} return —
|
|
52
|
+
* defined in `@fossil-lang/types`, beside the `Code` and `ProblemData` that type them. */
|
|
53
|
+
export type { CheckRow, CheckRelated } from '@fossil-lang/types';
|
|
61
54
|
/** An LSP range: zero-based lines, `character` in UTF-16 code units — the units
|
|
62
55
|
* a JavaScript string is indexed in, so no byte arithmetic converts it. (The
|
|
63
56
|
* lexer's {@link TokenRow} offsets are the other thing: those ARE bytes.) */
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAUH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,EACL,QAAQ,EACR,UAAU,EACV,cAAc,EACd,eAAe,EACf,IAAI,EACJ,SAAS,GACV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,GACzB,QAAQ,GACR,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,WAAW,GACX,MAAM,GACN,QAAQ,GACR,SAAS,CAAC;AAEd,kDAAkD;AAClD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,iBAAiB,CAAC;CAC9B;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ,2EAA2E;IAC3E,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B;;;;;;OAMG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB;AAKD,YAAY,EACV,QAAQ,EACR,oBAAoB,EACpB,IAAI,EACJ,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,aAAa,GACd,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public API (one of the @fossil-lang/* packages; `git ls-files packages` is
|
|
5
5
|
* the list):
|
|
6
|
-
* - {@link initFossilWasm} — boots the module; its `.wasm` is a bundler asset
|
|
6
|
+
* - {@link initFossilWasm} — boots the module; its `.wasm` is a bundler asset. A failed boot is
|
|
7
|
+
* forgotten, so the next call tries again.
|
|
7
8
|
* - {@link tokenize} — calls the Rust lexer, returns TokenRow[].
|
|
8
9
|
* - {@link tokenKinds} — the legend for TokenRow.kind: variant names by index.
|
|
9
10
|
* - {@link semanticLegend} — returns the LSP SemanticTokensLegend.
|
|
@@ -24,12 +25,6 @@
|
|
|
24
25
|
* const program = await openProgram('job.fossil', { host, text });
|
|
25
26
|
* const extensions = fossil({ ...program, onNavigate });
|
|
26
27
|
*/
|
|
27
|
-
// The wasm-bindgen glue (`../pkg/fossil_wasm.js`) is imported ONLY from leaf
|
|
28
|
-
// modules — `load.ts` (init) and `client.ts` (the lexer / LSP / Workspace API) —
|
|
29
|
-
// never here in the entry. See `client.ts`: importing the stateful glue from the
|
|
30
|
-
// package entry lets a `sideEffects:false` bundler duplicate it, splitting
|
|
31
|
-
// `init()`'s wasm instance from the one the functions use (the crash the
|
|
32
|
-
// codemirror tokenizer hit on the main thread). This entry only re-exports.
|
|
33
28
|
export { initFossilWasm } from './load.js';
|
|
34
29
|
export { tokenize, tokenKinds, semanticLegend, FossilWorkspace, refs, providers, } from './client.js';
|
|
35
30
|
export { openProgram } from './program.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAUH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,EACL,QAAQ,EACR,UAAU,EACV,cAAc,EACd,eAAe,EACf,IAAI,EACJ,SAAS,GACV,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/load.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export type { InitInput };
|
|
|
3
3
|
/**
|
|
4
4
|
* Boot the fossil-wasm module. MUST be awaited before calling any of
|
|
5
5
|
* {@link tokenize}, {@link semanticLegend}, or instantiating
|
|
6
|
-
* {@link FossilWorkspace}.
|
|
6
|
+
* {@link FossilWorkspace}. A boot that succeeded is kept; one that failed is
|
|
7
|
+
* not, so the next call tries again — `module/unreachable` for a module that could not be
|
|
8
|
+
* fetched within 60 s, `internal/bug` for one that would not instantiate.
|
|
7
9
|
*
|
|
8
10
|
* **Called with nothing, the module finds its own `.wasm`.** The glue resolves
|
|
9
11
|
* `new URL('fossil_wasm_bg.wasm', import.meta.url)`, which is the pattern Vite,
|
package/dist/load.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,YAAY,EAAE,SAAS,EAAE,CAAC;AAI1B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAUjE;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,IAAI,CAEtC"}
|
package/dist/load.js
CHANGED
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
// It is gitignored (repo .gitignore `packages/wasm/pkg/`) but always present at build time and in
|
|
3
3
|
// the published tarball. Its `.d.ts` is consumed via the file's `/* @ts-self-types */` pragma.
|
|
4
4
|
import init from '../pkg/fossil_wasm.js';
|
|
5
|
+
import { boot } from '@fossil-lang/types';
|
|
5
6
|
let _initPromise = null;
|
|
6
7
|
/**
|
|
7
8
|
* Boot the fossil-wasm module. MUST be awaited before calling any of
|
|
8
9
|
* {@link tokenize}, {@link semanticLegend}, or instantiating
|
|
9
|
-
* {@link FossilWorkspace}.
|
|
10
|
+
* {@link FossilWorkspace}. A boot that succeeded is kept; one that failed is
|
|
11
|
+
* not, so the next call tries again — `module/unreachable` for a module that could not be
|
|
12
|
+
* fetched within 60 s, `internal/bug` for one that would not instantiate.
|
|
10
13
|
*
|
|
11
14
|
* **Called with nothing, the module finds its own `.wasm`.** The glue resolves
|
|
12
15
|
* `new URL('fossil_wasm_bg.wasm', import.meta.url)`, which is the pattern Vite,
|
|
@@ -17,9 +20,14 @@ let _initPromise = null;
|
|
|
17
20
|
* `file://`, hands the bytes (`BufferSource`) or a `Response`.
|
|
18
21
|
*/
|
|
19
22
|
export function initFossilWasm(wasm) {
|
|
20
|
-
if (
|
|
23
|
+
if (_initPromise === null) {
|
|
21
24
|
// The object form: the positional one still works but logs a deprecation warning.
|
|
22
|
-
|
|
25
|
+
const pending = boot('fossil_wasm_bg.wasm', () => init(wasm === undefined ? undefined : { module_or_path: wasm }));
|
|
26
|
+
_initPromise = pending;
|
|
27
|
+
pending.catch(() => {
|
|
28
|
+
if (_initPromise === pending)
|
|
29
|
+
_initPromise = null; // forgotten, so the next call boots again
|
|
30
|
+
});
|
|
23
31
|
}
|
|
24
32
|
return _initPromise;
|
|
25
33
|
}
|
package/dist/load.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,kGAAkG;AAClG,+FAA+F;AAC/F,OAAO,IAAI,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../src/load.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,kGAAkG;AAClG,+FAA+F;AAC/F,OAAO,IAAI,MAAM,uBAAuB,CAAC;AAGzC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAI1C,IAAI,YAAY,GAA4B,IAAI,CAAC;AAEjD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,cAAc,CAAC,IAAgB;IAC7C,IAAI,YAAY,KAAK,IAAI,EAAE,CAAC;QAC1B,kFAAkF;QAClF,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnH,YAAY,GAAG,OAAO,CAAC;QACvB,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE;YACjB,IAAI,YAAY,KAAK,OAAO;gBAAE,YAAY,GAAG,IAAI,CAAC,CAAC,0CAA0C;QAC/F,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,YAAY,GAAG,IAAI,CAAC;AACtB,CAAC"}
|
package/dist/program.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Host, type ProgramSource } from '@fossil-lang/types';
|
|
2
2
|
import { FossilWorkspace, tokenize, tokenKinds } from './client.js';
|
|
3
3
|
import type { CheckRow, CompletionRow, DefinitionRow, HoverRow, InferredDescriptorJson } from './index.js';
|
|
4
4
|
import { type InitInput } from './load.js';
|
|
@@ -10,6 +10,8 @@ export interface OpenProgramOptions {
|
|
|
10
10
|
text?: string;
|
|
11
11
|
/** The module's `.wasm`, for a host with no bundler — see {@link initFossilWasm}. */
|
|
12
12
|
wasm?: InitInput;
|
|
13
|
+
/** Stops the open — the boot and the first read of the documents — rejecting with its reason. */
|
|
14
|
+
signal?: AbortSignal;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
15
17
|
* A program open in its own workspace. Every member that answers about the program takes the
|
|
@@ -26,6 +28,10 @@ export interface FossilProgram {
|
|
|
26
28
|
* Push the text, read every document it names that the workspace lacks, and check. No debounce:
|
|
27
29
|
* `fossil()`'s linter waits out its own delay AND waits for this to return before it schedules
|
|
28
30
|
* again, which is what an LSP client does with `didChange`.
|
|
31
|
+
*
|
|
32
|
+
* A document that could not be read is a row of its own at the top of the program, under the code
|
|
33
|
+
* of its read — `storage/host-silent`, `storage/unreachable`, … — beside the checker's rows, which
|
|
34
|
+
* see it only as missing.
|
|
29
35
|
*/
|
|
30
36
|
check(text: string): Promise<CheckRow[]>;
|
|
31
37
|
/** The type under the cursor, and the type the target shape demands of it — or `null`. */
|
|
@@ -52,8 +58,8 @@ export interface FossilProgram {
|
|
|
52
58
|
/**
|
|
53
59
|
* Boot the module, open `uri` in a fresh workspace, and read the documents its text names.
|
|
54
60
|
*
|
|
55
|
-
* One call and the answer goes straight into `fossil()`.
|
|
56
|
-
* in the same tab costs a workspace and nothing else.
|
|
61
|
+
* One call and the answer goes straight into `fossil()`. A boot that succeeded is kept, so a second
|
|
62
|
+
* program in the same tab costs a workspace and nothing else.
|
|
57
63
|
*/
|
|
58
64
|
export declare function openProgram(uri: string, options: OpenProgramOptions): Promise<FossilProgram>;
|
|
59
65
|
//# sourceMappingURL=program.d.ts.map
|
package/dist/program.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAkCA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAS,KAAK,IAAI,EAAE,KAAK,aAAa,EAAuB,MAAM,oBAAoB,CAAC;AAE/F,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EACV,QAAQ,EACR,aAAa,EACb,aAAa,EACb,QAAQ,EACR,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3D,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,yFAAyF;IACzF,IAAI,EAAE,IAAI,CAAC;IACX,6FAA6F;IAC7F,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qFAAqF;IACrF,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,iGAAiG;IACjG,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,2FAA2F;IAC3F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,mGAAmG;IACnG,QAAQ,CAAC,QAAQ,EAAE,OAAO,QAAQ,CAAC;IACnC,uCAAuC;IACvC,QAAQ,CAAC,UAAU,EAAE,OAAO,UAAU,CAAC;IACvC;;;;;;;;OAQG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACzC,0FAA0F;IAC1F,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;IACtE,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IACzE,2FAA2F;IAC3F,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,EAAE,CAAC;IAC3E;;;OAGG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAChD;;;OAGG;IACH,kBAAkB,CAAC,UAAU,EAAE,sBAAsB,GAAG,IAAI,CAAC;IAC7D,iFAAiF;IACjF,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,uDAAuD;IACvD,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAyElG"}
|
package/dist/program.js
CHANGED
|
@@ -32,17 +32,18 @@
|
|
|
32
32
|
* check rather than poisoning it.
|
|
33
33
|
*/
|
|
34
34
|
import { resolveDocuments } from '@fossil-lang/storage';
|
|
35
|
+
import { until } from '@fossil-lang/types';
|
|
35
36
|
import { FossilWorkspace, tokenize, tokenKinds } from './client.js';
|
|
36
37
|
import { initFossilWasm } from './load.js';
|
|
37
38
|
/**
|
|
38
39
|
* Boot the module, open `uri` in a fresh workspace, and read the documents its text names.
|
|
39
40
|
*
|
|
40
|
-
* One call and the answer goes straight into `fossil()`.
|
|
41
|
-
* in the same tab costs a workspace and nothing else.
|
|
41
|
+
* One call and the answer goes straight into `fossil()`. A boot that succeeded is kept, so a second
|
|
42
|
+
* program in the same tab costs a workspace and nothing else.
|
|
42
43
|
*/
|
|
43
44
|
export async function openProgram(uri, options) {
|
|
44
|
-
const { host, text = '', wasm } = options;
|
|
45
|
-
await initFossilWasm(wasm);
|
|
45
|
+
const { host, text = '', wasm, signal } = options;
|
|
46
|
+
await until(initFossilWasm(wasm), signal);
|
|
46
47
|
const workspace = new FossilWorkspace();
|
|
47
48
|
const handle = workspace.openFile(uri, text);
|
|
48
49
|
let pushed = text;
|
|
@@ -52,18 +53,37 @@ export async function openProgram(uri, options) {
|
|
|
52
53
|
workspace.updateFile(handle, next);
|
|
53
54
|
pushed = next;
|
|
54
55
|
};
|
|
55
|
-
|
|
56
|
+
// What the last read of the documents could not read; every settle reads what is missing again.
|
|
57
|
+
let unread = [];
|
|
58
|
+
const settle = async (next, stop) => {
|
|
56
59
|
sync(next);
|
|
57
|
-
await resolveDocuments(workspace.workspace(handle), host);
|
|
60
|
+
({ unread } = await resolveDocuments(workspace.workspace(handle), host, { signal: stop }));
|
|
58
61
|
};
|
|
59
|
-
|
|
62
|
+
try {
|
|
63
|
+
await settle(text, signal);
|
|
64
|
+
}
|
|
65
|
+
catch (cause) {
|
|
66
|
+
workspace.free();
|
|
67
|
+
throw cause;
|
|
68
|
+
}
|
|
60
69
|
return {
|
|
61
70
|
uri,
|
|
62
71
|
tokenize,
|
|
63
72
|
tokenKinds,
|
|
64
73
|
async check(next) {
|
|
65
74
|
await settle(next);
|
|
66
|
-
|
|
75
|
+
const rows = workspace.check();
|
|
76
|
+
const failed = unread.map(({ key, problem }) => ({
|
|
77
|
+
uri,
|
|
78
|
+
range: { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } },
|
|
79
|
+
severity: 1,
|
|
80
|
+
code: problem.code,
|
|
81
|
+
data: problem.data,
|
|
82
|
+
title: problem.title,
|
|
83
|
+
message: `${key}: ${problem.detail}`,
|
|
84
|
+
...(problem.help === undefined ? {} : { help: problem.help }),
|
|
85
|
+
}));
|
|
86
|
+
return [...failed, ...rows];
|
|
67
87
|
},
|
|
68
88
|
hover(next, line, character) {
|
|
69
89
|
sync(next);
|
package/dist/program.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAsD,MAAM,oBAAoB,CAAC;AAE/F,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQpE,OAAO,EAAE,cAAc,EAAkB,MAAM,WAAW,CAAC;AAyD3D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAW,EAAE,OAA2B;IACxE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAClD,MAAM,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;IAE1C,MAAM,SAAS,GAAG,IAAI,eAAe,EAAE,CAAC;IACxC,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC7C,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,MAAM,IAAI,GAAG,CAAC,IAAY,EAAQ,EAAE;QA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
|
{
|
|
2
2
|
"name": "@fossil-lang/wasm",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.19",
|
|
4
4
|
"description": "JS/TS wrapper around the fossil-wasm wasm-bindgen artifacts (--target web). Exposes initFossilWasm + tokenize + semanticLegend + FossilWorkspace class for downstream @fossil-lang/* packages.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
],
|
|
34
34
|
"sideEffects": false,
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@fossil-lang/storage": "0.3.0-alpha.
|
|
37
|
-
"@fossil-lang/types": "0.3.0-alpha.
|
|
36
|
+
"@fossil-lang/storage": "0.3.0-alpha.19",
|
|
37
|
+
"@fossil-lang/types": "0.3.0-alpha.19"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"typescript": "^5.6.0",
|
package/pkg/fossil_wasm.d.ts
CHANGED
|
@@ -69,9 +69,8 @@ export class FossilWorkspace {
|
|
|
69
69
|
[Symbol.dispose](): void;
|
|
70
70
|
/**
|
|
71
71
|
* Every open **program**'s diagnostics as a flat JS array of
|
|
72
|
-
* `
|
|
73
|
-
*
|
|
74
|
-
* [`CheckRow`].
|
|
72
|
+
* [`CheckRow`]s keyed by file URI — the diagnostics panel's view. It is
|
|
73
|
+
* NOT the LSP wire's shape; see [`CheckRow`].
|
|
75
74
|
*
|
|
76
75
|
* A buffer the installed provider catalogue claims — a `.shex` being
|
|
77
76
|
* edited, a `.csv`, a `.parquet` — is an INPUT and is not parsed as fossil.
|
|
@@ -80,9 +79,8 @@ export class FossilWorkspace {
|
|
|
80
79
|
*
|
|
81
80
|
* `range` is the UTF-16 LSP range (via `fossil_ide::LineIndex` — the
|
|
82
81
|
* rust-analyzer model). `severity` is the LSP integer constant
|
|
83
|
-
* (1 = error, 2 = warning, 3 = info). `message`
|
|
84
|
-
* `
|
|
85
|
-
* [`fossil_ide::lsp_diagnostic`], the rendering an editor is shown.
|
|
82
|
+
* (1 = error, 2 = warning, 3 = info). `message` is the problem rendered
|
|
83
|
+
* and nothing else; `help` is its own field.
|
|
86
84
|
*
|
|
87
85
|
* # Errors
|
|
88
86
|
*
|
package/pkg/fossil_wasm.js
CHANGED
|
@@ -90,9 +90,8 @@ export class FossilWorkspace {
|
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Every open **program**'s diagnostics as a flat JS array of
|
|
93
|
-
* `
|
|
94
|
-
*
|
|
95
|
-
* [`CheckRow`].
|
|
93
|
+
* [`CheckRow`]s keyed by file URI — the diagnostics panel's view. It is
|
|
94
|
+
* NOT the LSP wire's shape; see [`CheckRow`].
|
|
96
95
|
*
|
|
97
96
|
* A buffer the installed provider catalogue claims — a `.shex` being
|
|
98
97
|
* edited, a `.csv`, a `.parquet` — is an INPUT and is not parsed as fossil.
|
|
@@ -101,9 +100,8 @@ export class FossilWorkspace {
|
|
|
101
100
|
*
|
|
102
101
|
* `range` is the UTF-16 LSP range (via `fossil_ide::LineIndex` — the
|
|
103
102
|
* rust-analyzer model). `severity` is the LSP integer constant
|
|
104
|
-
* (1 = error, 2 = warning, 3 = info). `message`
|
|
105
|
-
* `
|
|
106
|
-
* [`fossil_ide::lsp_diagnostic`], the rendering an editor is shown.
|
|
103
|
+
* (1 = error, 2 = warning, 3 = info). `message` is the problem rendered
|
|
104
|
+
* and nothing else; `help` is its own field.
|
|
107
105
|
*
|
|
108
106
|
* # Errors
|
|
109
107
|
*
|
package/pkg/fossil_wasm_bg.wasm
CHANGED
|
Binary file
|