@yuku-parser/wasm 0.6.7 → 0.6.9
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/index.d.ts +7 -11
- package/index.js +19 -0
- package/package.json +3 -2
package/index.d.ts
CHANGED
|
@@ -70,22 +70,19 @@ interface ParseResult {
|
|
|
70
70
|
*/
|
|
71
71
|
export function parse(source: string, options?: ParseOptions): ParseResult;
|
|
72
72
|
|
|
73
|
-
// Walking
|
|
73
|
+
// Deprecated walking surface. Walking moved to the yuku-ast package,
|
|
74
|
+
// these delegate there and will be removed in the next major version.
|
|
74
75
|
|
|
75
|
-
/**
|
|
76
|
+
/** @deprecated Import `WalkHandler` from the yuku-ast package instead. */
|
|
76
77
|
type WalkHandler<T extends Node = Node, S = unknown> = (node: T, ctx: WalkContext<T, S>) => void;
|
|
77
78
|
|
|
78
|
-
/**
|
|
79
|
+
/** @deprecated Import `WalkHooks` from the yuku-ast package instead. */
|
|
79
80
|
interface WalkHooks<T extends Node = Node, S = unknown> {
|
|
80
81
|
enter?: WalkHandler<T, S>;
|
|
81
82
|
leave?: WalkHandler<T, S>;
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
/**
|
|
85
|
-
* Handlers keyed by node `type`, or the universal `enter`/`leave`. A bare
|
|
86
|
-
* function is an enter handler; per node `enter` runs before children and
|
|
87
|
-
* `leave` after.
|
|
88
|
-
*/
|
|
85
|
+
/** @deprecated Import `Visitors` from the yuku-ast package instead. */
|
|
89
86
|
type Visitors<S = unknown> = {
|
|
90
87
|
[K in NodeType]?: WalkHandler<NodeOfType<K>, S> | WalkHooks<NodeOfType<K>, S>;
|
|
91
88
|
} & {
|
|
@@ -94,9 +91,8 @@ type Visitors<S = unknown> = {
|
|
|
94
91
|
};
|
|
95
92
|
|
|
96
93
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* parser's AST definition, so it can never drift. Returns the root.
|
|
94
|
+
* @deprecated Walking moved to the yuku-ast package. Install yuku-ast
|
|
95
|
+
* and import `walk` from there. Removed in the next major version.
|
|
100
96
|
*/
|
|
101
97
|
export function walk<T extends Node, S = unknown>(root: T, visitors: Visitors<S>, state?: S): T;
|
|
102
98
|
|
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { walk as astWalk } from "yuku-ast";
|
|
1
2
|
import { decode } from "./decode.js";
|
|
2
3
|
|
|
3
4
|
const wasmUrl = new URL("./yuku-parser.wasm", import.meta.url);
|
|
@@ -59,3 +60,21 @@ export function langFromPath(path) {
|
|
|
59
60
|
export function sourceTypeFromPath(path) {
|
|
60
61
|
return path.endsWith(".cjs") || path.endsWith(".cts") ? "script" : "module";
|
|
61
62
|
}
|
|
63
|
+
|
|
64
|
+
export { WalkContext } from "yuku-ast";
|
|
65
|
+
|
|
66
|
+
let deprecationWarned = false;
|
|
67
|
+
function warnWalkMoved(name) {
|
|
68
|
+
if (deprecationWarned) return;
|
|
69
|
+
deprecationWarned = true;
|
|
70
|
+
console.warn(
|
|
71
|
+
`[yuku-parser] ${name}() has moved to the yuku-ast package. ` +
|
|
72
|
+
`Install yuku-ast and update the import to: import { ${name} } from "yuku-ast". ` +
|
|
73
|
+
`This re-export will be removed in the next major version.`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function walk(root, visitors, state) {
|
|
78
|
+
warnWalkMoved("walk");
|
|
79
|
+
return astWalk(root, visitors, state);
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuku-parser/wasm",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.9",
|
|
4
4
|
"description": "High-performance JavaScript/TypeScript parser, compiled to WebAssembly",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"yuku-parser.wasm"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@yuku-toolchain/types": "0.6.
|
|
20
|
+
"@yuku-toolchain/types": "0.6.8",
|
|
21
|
+
"yuku-ast": "0.6.8"
|
|
21
22
|
},
|
|
22
23
|
"keywords": [
|
|
23
24
|
"acorn",
|