@opensip-cli/tree-sitter 0.1.6 → 0.1.8
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 -2
- package/dist/lifecycle.d.ts +7 -1
- package/dist/lifecycle.d.ts.map +1 -1
- package/dist/lifecycle.js +24 -2
- package/dist/lifecycle.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,8 +23,8 @@ This package is published for the CLI and advanced plugin authors; most users sh
|
|
|
23
23
|
## Documentation
|
|
24
24
|
|
|
25
25
|
- 📚 Project docs: https://opensip.ai/docs/opensip-cli/
|
|
26
|
-
- 🧭 Package catalog (what every package does): https://github.com/opensip-ai/opensip-cli/blob/v0.1.
|
|
27
|
-
- 📦 Source: https://github.com/opensip-ai/opensip-cli/tree/v0.1.
|
|
26
|
+
- 🧭 Package catalog (what every package does): https://github.com/opensip-ai/opensip-cli/blob/v0.1.8/docs/public/70-reference/02-package-catalog.md
|
|
27
|
+
- 📦 Source: https://github.com/opensip-ai/opensip-cli/tree/v0.1.8/packages/tree-sitter
|
|
28
28
|
|
|
29
29
|
## License
|
|
30
30
|
|
package/dist/lifecycle.d.ts
CHANGED
|
@@ -15,7 +15,13 @@
|
|
|
15
15
|
* adapter's own top-level `await loadGrammar(<wasm>)`.
|
|
16
16
|
*/
|
|
17
17
|
import { Parser, Language, type Tree } from 'web-tree-sitter';
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Load a tree-sitter grammar from a `.wasm` path (adapter module top level).
|
|
20
|
+
*
|
|
21
|
+
* @throws {Error} When the web-tree-sitter runtime failed to initialize (the
|
|
22
|
+
* contained `Parser.init()` above) — lang-* adapters catch this and degrade
|
|
23
|
+
* that language to "unavailable" rather than crashing the CLI.
|
|
24
|
+
*/
|
|
19
25
|
export declare function loadGrammar(wasmPath: string): Promise<Language>;
|
|
20
26
|
/**
|
|
21
27
|
* Create a parser bound to `grammar`. Adapters create one per grammar at
|
package/dist/lifecycle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAmB9D;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAIrE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,CAItD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAEvE"}
|
package/dist/lifecycle.js
CHANGED
|
@@ -18,9 +18,31 @@ import { Parser, Language } from 'web-tree-sitter';
|
|
|
18
18
|
// One-time WASM runtime init. Top-level await — every consumer statically
|
|
19
19
|
// imports this module — guarantees the runtime is ready before any adapter's
|
|
20
20
|
// `loadGrammar(<wasm>)` (which also runs at module top level).
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Contained: if the WASM runtime fails to initialize (a broken/incompatible
|
|
22
|
+
// web-tree-sitter build), this module still LOADS — `loadGrammar` then throws,
|
|
23
|
+
// and each lang-* adapter degrades its language to "unavailable" rather than
|
|
24
|
+
// crashing the whole CLI on import.
|
|
25
|
+
let runtimeReady = false;
|
|
26
|
+
/* v8 ignore start -- runtime-init failure is environment-dependent; not reproducible under the test runner */
|
|
27
|
+
try {
|
|
28
|
+
await Parser.init();
|
|
29
|
+
runtimeReady = true;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
/* @swallow-ok runtime init failed → loadGrammar throws → adapters degrade per-language */
|
|
33
|
+
}
|
|
34
|
+
/* v8 ignore stop */
|
|
35
|
+
/**
|
|
36
|
+
* Load a tree-sitter grammar from a `.wasm` path (adapter module top level).
|
|
37
|
+
*
|
|
38
|
+
* @throws {Error} When the web-tree-sitter runtime failed to initialize (the
|
|
39
|
+
* contained `Parser.init()` above) — lang-* adapters catch this and degrade
|
|
40
|
+
* that language to "unavailable" rather than crashing the CLI.
|
|
41
|
+
*/
|
|
23
42
|
export async function loadGrammar(wasmPath) {
|
|
43
|
+
/* v8 ignore next -- only reachable when Parser.init() failed above */
|
|
44
|
+
if (!runtimeReady)
|
|
45
|
+
throw new Error('web-tree-sitter runtime is not initialized');
|
|
24
46
|
return Language.load(wasmPath);
|
|
25
47
|
}
|
|
26
48
|
/**
|
package/dist/lifecycle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAE9D,0EAA0E;AAC1E,6EAA6E;AAC7E,+DAA+D;AAC/D,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../src/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAE9D,0EAA0E;AAC1E,6EAA6E;AAC7E,+DAA+D;AAC/D,4EAA4E;AAC5E,+EAA+E;AAC/E,6EAA6E;AAC7E,oCAAoC;AACpC,IAAI,YAAY,GAAG,KAAK,CAAC;AAC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