@opensip-cli/lang-python 0.1.7 → 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/parse.d.ts.map +1 -1
- package/dist/parse.js +20 -2
- package/dist/parse.js.map +1 -1
- package/package.json +3 -3
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/languages/lang-python
|
|
28
28
|
|
|
29
29
|
## License
|
|
30
30
|
|
package/dist/parse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAA0C,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAqBnG,kFAAkF;AAClF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC;AAEpC,wFAAwF;AACxF,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,CAKjF"}
|
package/dist/parse.js
CHANGED
|
@@ -11,11 +11,29 @@
|
|
|
11
11
|
* tree (non-null) rather than throwing — callers can inspect `rootNode.hasError`.
|
|
12
12
|
*/
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { logger } from '@opensip-cli/core';
|
|
14
15
|
import { loadGrammar, createParser, parseToTree } from '@opensip-cli/tree-sitter';
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
// Load the grammar once at module top level (keeps parse() synchronous). A
|
|
17
|
+
// missing/corrupt/ABI-mismatched .wasm must NOT crash the whole CLI — contain
|
|
18
|
+
// the failure so Python analysis degrades to "unavailable" (parse returns null).
|
|
19
|
+
let parser;
|
|
20
|
+
/* v8 ignore start -- grammar-load failure is environment-dependent (bad/missing .wasm); not reproducible under the test runner */
|
|
21
|
+
try {
|
|
22
|
+
const grammar = await loadGrammar(fileURLToPath(new URL('../wasm/tree-sitter-python.wasm', import.meta.url)));
|
|
23
|
+
parser = createParser(grammar);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
logger.warn({
|
|
27
|
+
evt: 'lang.grammar.load_failed',
|
|
28
|
+
module: 'lang:python',
|
|
29
|
+
msg: `Python grammar failed to load — Python analysis is unavailable this run: ${error instanceof Error ? error.message : String(error)}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
17
32
|
/** Parses Python source into a {@link PythonTree}, or null when no tree is produced. */
|
|
18
33
|
export function parsePython(content, _filePath) {
|
|
34
|
+
/* v8 ignore next -- defensive: parser is undefined only when the grammar failed to load */
|
|
35
|
+
if (!parser)
|
|
36
|
+
return null;
|
|
19
37
|
const tree = parseToTree(parser, content);
|
|
20
38
|
return tree ? { tree, source: content } : null;
|
|
21
39
|
}
|
package/dist/parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,YAAY,E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OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACjD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensip-cli/lang-python",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Python language adapter for opensip-cli",
|
|
6
6
|
"keywords": [
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"NOTICE"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@opensip-cli/core": "0.1.
|
|
38
|
-
"@opensip-cli/tree-sitter": "0.1.
|
|
37
|
+
"@opensip-cli/core": "0.1.8",
|
|
38
|
+
"@opensip-cli/tree-sitter": "0.1.8"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^24.13.2",
|