yuku-parser 0.5.18 → 0.5.20
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 +1 -4
- package/decode.js +5 -5
- package/index.d.ts +0 -20
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -25,10 +25,7 @@ For JavaScript and JSX, the AST is fully conformant with the [ESTree](https://gi
|
|
|
25
25
|
|
|
26
26
|
For TypeScript, the AST conforms to the [TypeScript-ESTree](https://www.npmjs.com/package/@typescript-eslint/typescript-estree) format used by `@typescript-eslint`.
|
|
27
27
|
|
|
28
|
-
Yuku
|
|
29
|
-
|
|
30
|
-
- **Comments are attached to the AST nodes they belong to** rather than exposed as a separate offset-indexed array. See [Comments](#comments) for why.
|
|
31
|
-
- **`Identifier` carries a `kind` field** (`"reference" | "binding" | "name" | "label" | "this"`) naming its role in the tree. ESTree collapses these distinct roles onto one `Identifier` type, so consumers normally have to walk the parent context to tell them apart. The parser already knows which is which, so it surfaces the answer as a free field.
|
|
28
|
+
Yuku produces exactly the AST that [Oxc](https://oxc.rs) produces, for both JS and TS.
|
|
32
29
|
|
|
33
30
|
On top of the base specs, the AST also carries:
|
|
34
31
|
|
package/decode.js
CHANGED
|
@@ -377,11 +377,11 @@ function decode(buffer, source) {
|
|
|
377
377
|
tail: tl,
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
-
case 42: { const r = { type: "Identifier", start, end, name: str(f1, f2)
|
|
380
|
+
case 42: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
|
|
381
381
|
case 43: return { type: "PrivateIdentifier", start, end, name: str(f1, f2) };
|
|
382
|
-
case 44: { const r = { type: "Identifier", start, end, name: str(f1, f2)
|
|
383
|
-
case 45: { const r = { type: "Identifier", start, end, name: str(f1, f2)
|
|
384
|
-
case 46: { const r = { type: "Identifier", start, end, name: str(f1, f2)
|
|
382
|
+
case 44: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = nodeArr(f3, f0); r.typeAnnotation = f4 !== NULL ? node(f4) : null; r.optional = !!(flags & 1); } return r; }
|
|
383
|
+
case 45: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
|
|
384
|
+
case 46: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
|
|
385
385
|
case 47: { const r = { type: "ExpressionStatement", start, end, expression: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.directive = null; } return r; }
|
|
386
386
|
case 48: return { type: "IfStatement", start, end, test: f1 !== NULL ? node(f1) : null, consequent: f2 !== NULL ? node(f2) : null, alternate: f3 !== NULL ? node(f3) : null };
|
|
387
387
|
case 49: return { type: "SwitchStatement", start, end, discriminant: f1 !== NULL ? node(f1) : null, cases: nodeArr(f2, f0) };
|
|
@@ -579,7 +579,7 @@ function decode(buffer, source) {
|
|
|
579
579
|
case 146: return {
|
|
580
580
|
type: "Identifier", start, end,
|
|
581
581
|
decorators: [],
|
|
582
|
-
name: "this",
|
|
582
|
+
name: "this", optional: false,
|
|
583
583
|
typeAnnotation: f1 !== NULL ? node(f1) : null,
|
|
584
584
|
};
|
|
585
585
|
case 147: return { type: "TSAsExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null };
|
package/index.d.ts
CHANGED
|
@@ -271,28 +271,9 @@ type PropertyDefinitionType = "PropertyDefinition" | "TSAbstractPropertyDefiniti
|
|
|
271
271
|
|
|
272
272
|
type AccessorPropertyType = "AccessorProperty" | "TSAbstractAccessorProperty";
|
|
273
273
|
|
|
274
|
-
/**
|
|
275
|
-
* Role of an `Identifier` within the AST. Yuku exposes the four ESTree-collapsed
|
|
276
|
-
* identifier flavors as a discriminator, plus `"this"` for a TS `this`-parameter
|
|
277
|
-
* (which TS-ESTree also encodes as an `Identifier` with `name: "this"`).
|
|
278
|
-
*
|
|
279
|
-
* - `"reference"`: identifier read as a value (`x` in `x + 1`, `console`).
|
|
280
|
-
* - `"binding"`: identifier being declared (parameters, `let x`, function/class names).
|
|
281
|
-
* - `"name"`: identifier in a non-binding name slot (property/method names like `log` in `console.log`).
|
|
282
|
-
* - `"label"`: loop label (`outer` in `outer: for (...) {}`).
|
|
283
|
-
* - `"this"`: the TS `this`-parameter (`function f(this: T)`).
|
|
284
|
-
*/
|
|
285
|
-
type IdentifierKind = "reference" | "binding" | "name" | "label" | "this";
|
|
286
|
-
|
|
287
274
|
interface Identifier extends BaseNode {
|
|
288
275
|
type: "Identifier";
|
|
289
276
|
name: string;
|
|
290
|
-
/**
|
|
291
|
-
* ESTree collapses several distinct identifier
|
|
292
|
-
* roles onto one `Identifier` node, `kind` lets you tell them apart without
|
|
293
|
-
* walking the parent context. See {@link IdentifierKind}.
|
|
294
|
-
*/
|
|
295
|
-
kind: IdentifierKind;
|
|
296
277
|
decorators?: Decorator[];
|
|
297
278
|
optional?: boolean;
|
|
298
279
|
typeAnnotation?: TSTypeAnnotation | null;
|
|
@@ -1821,7 +1802,6 @@ export type {
|
|
|
1821
1802
|
ModuleExportName,
|
|
1822
1803
|
PropertyKey,
|
|
1823
1804
|
Identifier,
|
|
1824
|
-
IdentifierKind,
|
|
1825
1805
|
IdentifierName,
|
|
1826
1806
|
IdentifierReference,
|
|
1827
1807
|
BindingIdentifier,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuku-parser",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.20",
|
|
4
4
|
"description": "High-performance JavaScript/TypeScript parser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"decode.js"
|
|
18
18
|
],
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"@yuku-parser/binding-linux-x64-gnu": "0.5.
|
|
21
|
-
"@yuku-parser/binding-linux-arm64-gnu": "0.5.
|
|
22
|
-
"@yuku-parser/binding-linux-arm-gnu": "0.5.
|
|
23
|
-
"@yuku-parser/binding-linux-x64-musl": "0.5.
|
|
24
|
-
"@yuku-parser/binding-linux-arm64-musl": "0.5.
|
|
25
|
-
"@yuku-parser/binding-linux-arm-musl": "0.5.
|
|
26
|
-
"@yuku-parser/binding-darwin-x64": "0.5.
|
|
27
|
-
"@yuku-parser/binding-darwin-arm64": "0.5.
|
|
28
|
-
"@yuku-parser/binding-win32-x64": "0.5.
|
|
29
|
-
"@yuku-parser/binding-win32-arm64": "0.5.
|
|
30
|
-
"@yuku-parser/binding-freebsd-x64": "0.5.
|
|
20
|
+
"@yuku-parser/binding-linux-x64-gnu": "0.5.20",
|
|
21
|
+
"@yuku-parser/binding-linux-arm64-gnu": "0.5.20",
|
|
22
|
+
"@yuku-parser/binding-linux-arm-gnu": "0.5.20",
|
|
23
|
+
"@yuku-parser/binding-linux-x64-musl": "0.5.20",
|
|
24
|
+
"@yuku-parser/binding-linux-arm64-musl": "0.5.20",
|
|
25
|
+
"@yuku-parser/binding-linux-arm-musl": "0.5.20",
|
|
26
|
+
"@yuku-parser/binding-darwin-x64": "0.5.20",
|
|
27
|
+
"@yuku-parser/binding-darwin-arm64": "0.5.20",
|
|
28
|
+
"@yuku-parser/binding-win32-x64": "0.5.20",
|
|
29
|
+
"@yuku-parser/binding-win32-arm64": "0.5.20",
|
|
30
|
+
"@yuku-parser/binding-freebsd-x64": "0.5.20"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
33
|
"acorn",
|