yuku-parser 0.5.9 → 0.5.11
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 +45 -16
- package/decode.js +41 -16
- package/index.d.ts +32 -2
- package/package.json +26 -26
package/README.md
CHANGED
|
@@ -51,10 +51,10 @@ Two small helpers are exported for resolving the `lang` and `sourceType` options
|
|
|
51
51
|
```ts
|
|
52
52
|
import { langFromPath, sourceTypeFromPath } from "yuku-parser";
|
|
53
53
|
|
|
54
|
-
langFromPath("foo.tsx");
|
|
55
|
-
langFromPath("types.d.ts");
|
|
56
|
-
sourceTypeFromPath("foo.cjs");
|
|
57
|
-
sourceTypeFromPath("foo.mjs");
|
|
54
|
+
langFromPath("foo.tsx"); // "tsx"
|
|
55
|
+
langFromPath("types.d.ts"); // "dts"
|
|
56
|
+
sourceTypeFromPath("foo.cjs"); // "script"
|
|
57
|
+
sourceTypeFromPath("foo.mjs"); // "module"
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
## Walking the AST
|
|
@@ -94,13 +94,13 @@ const result = parse(source, {
|
|
|
94
94
|
});
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
-
| Option
|
|
98
|
-
|
|
|
99
|
-
| `sourceType`
|
|
100
|
-
| `lang`
|
|
101
|
-
| `preserveParens`
|
|
102
|
-
| `allowReturnOutsideFunction` | `true`, `false`
|
|
103
|
-
| `semanticErrors`
|
|
97
|
+
| Option | Values | Default | Description |
|
|
98
|
+
| ---------------------------- | ----------------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
99
|
+
| `sourceType` | `"module"`, `"script"` | `"module"` | Module mode enables `import`/`export`, `import.meta`, top-level `await`, and strict mode. |
|
|
100
|
+
| `lang` | `"js"`, `"ts"`, `"jsx"`, `"tsx"`, `"dts"` | `"js"` | Language variant controls which syntax extensions are enabled. |
|
|
101
|
+
| `preserveParens` | `true`, `false` | `true` | Keep `ParenthesizedExpression` nodes in the AST. When false, parentheses are stripped and only the inner expression is kept. |
|
|
102
|
+
| `allowReturnOutsideFunction` | `true`, `false` | `false` | Allow `return` statements outside of functions, at the top level. |
|
|
103
|
+
| `semanticErrors` | `true`, `false` | `false` | Run semantic analysis and report semantic errors alongside syntax errors. |
|
|
104
104
|
|
|
105
105
|
## Result
|
|
106
106
|
|
|
@@ -110,11 +110,12 @@ const result = parse(source, {
|
|
|
110
110
|
interface ParseResult {
|
|
111
111
|
program: Program;
|
|
112
112
|
comments: Comment[];
|
|
113
|
+
lineStarts: number[];
|
|
113
114
|
diagnostics: Diagnostic[];
|
|
114
115
|
}
|
|
115
116
|
```
|
|
116
117
|
|
|
117
|
-
The parser is error-tolerant, an AST is always produced even when diagnostics are present.
|
|
118
|
+
The parser is error-tolerant, an AST is always produced even when diagnostics are present. `lineStarts` records the byte offset of every line in the source, useful for resolving spans to `(line, column)` pairs without rescanning.
|
|
118
119
|
|
|
119
120
|
### Diagnostics
|
|
120
121
|
|
|
@@ -141,11 +142,39 @@ This incurs a very small performance overhead. If your build pipeline already ha
|
|
|
141
142
|
|
|
142
143
|
### Comments
|
|
143
144
|
|
|
144
|
-
|
|
145
|
+
Every entry in `result.comments` is classified at parse time so consumers can route comments without rescanning the value:
|
|
145
146
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
```ts
|
|
148
|
+
interface Comment {
|
|
149
|
+
type: "Line" | "Block";
|
|
150
|
+
kind: CommentKind;
|
|
151
|
+
precededByNewline: boolean;
|
|
152
|
+
followedByNewline: boolean;
|
|
153
|
+
value: string; // text without the surrounding delimiters
|
|
154
|
+
start: number; // byte offset
|
|
155
|
+
end: number; // byte offset
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type CommentKind =
|
|
159
|
+
| "normal" // plain comment, no special meaning
|
|
160
|
+
| "legal" // /*! ... */ or contains @license / @preserve / @cc_on
|
|
161
|
+
| "jsdoc" // /** ... */ block
|
|
162
|
+
| "annotation" // /*# ... */ or /*@ ... */ other than tree-shaking
|
|
163
|
+
| "pure" // /*#__PURE__*/ or /*@__PURE__*/
|
|
164
|
+
| "no_side_effects"; // /*#__NO_SIDE_EFFECTS__*/ or /*@__NO_SIDE_EFFECTS__*/
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Common patterns:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
// Extract legal banners for a sidecar file.
|
|
171
|
+
const banners = result.comments.filter((c) => c.kind === "legal");
|
|
172
|
+
|
|
173
|
+
// Find tree-shaking annotations.
|
|
174
|
+
const pureMarkers = result.comments.filter((c) => c.kind === "pure");
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
`precededByNewline` and `followedByNewline` capture line layout, useful for tools that need to reconstruct source positioning.
|
|
149
178
|
|
|
150
179
|
## License
|
|
151
180
|
|
package/decode.js
CHANGED
|
@@ -12,6 +12,7 @@ const METHOD_KINDS = ["constructor", "method", "get", "set"];
|
|
|
12
12
|
const FUNCTION_TYPES = ["FunctionDeclaration", "FunctionExpression", "TSDeclareFunction", "TSEmptyBodyFunctionExpression"];
|
|
13
13
|
const CLASS_TYPES = ["ClassDeclaration", "ClassExpression"];
|
|
14
14
|
const COMMENT_TYPES = ["Line", "Block"];
|
|
15
|
+
const COMMENT_KINDS = ["normal", "legal", "jsdoc", "annotation", "pure", "no_side_effects"];
|
|
15
16
|
const SEVERITY = ["error", "warning", "hint", "info"];
|
|
16
17
|
const IMPORT_EXPORT_KINDS = ["value", "type"];
|
|
17
18
|
const ACCESSIBILITY = [null, "public", "private", "protected"];
|
|
@@ -56,10 +57,10 @@ function decode(buffer, source) {
|
|
|
56
57
|
const _src = source;
|
|
57
58
|
const _srcLen = _u32[3];
|
|
58
59
|
const nodeCount = _u32[0], extraCount = _u32[1], spLen = _u32[2];
|
|
59
|
-
const commentCount = _u32[4],
|
|
60
|
-
const _isTs = !!(_u32[
|
|
61
|
-
const _firstNa = _u32[
|
|
62
|
-
const _nodesOff =
|
|
60
|
+
const commentCount = _u32[4], lineStartsCount = _u32[5], diagCount = _u32[6], progIdx = _u32[7];
|
|
61
|
+
const _isTs = !!(_u32[8] & 1);
|
|
62
|
+
const _firstNa = _u32[9];
|
|
63
|
+
const _nodesOff = 40;
|
|
63
64
|
const eOff = _nodesOff + nodeCount * 48;
|
|
64
65
|
const _extraBase = eOff >> 2;
|
|
65
66
|
const _spOff = eOff + extraCount * 4;
|
|
@@ -130,8 +131,8 @@ function decode(buffer, source) {
|
|
|
130
131
|
case 1: return { type: "ParenthesizedExpression", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
131
132
|
case 2: { const r = { type: "ArrowFunctionExpression", start, end, id: null, generator: false, async: !!(flags & 2), params: f1 !== NULL ? fnParams(f1) : [], body: node(f2), expression: !!(flags & 1) }; if (_isTs) { r.typeParameters = f3 !== NULL ? node(f3) : null; r.returnType = f4 !== NULL ? node(f4) : null; } return r; }
|
|
132
133
|
case 3: { const ft = flags & 3; const r = { type: FUNCTION_TYPES[ft], start, end, id: f1 !== NULL ? node(f1) : null, generator: !!(flags & 4), async: !!(flags & 8), params: f2 !== NULL ? fnParams(f2) : [], body: f3 !== NULL ? node(f3) : null, expression: false }; if (_isTs) { r.typeParameters = f4 !== NULL ? node(f4) : null; r.returnType = f5 !== NULL ? node(f5) : null; r.declare = !!(flags & 16); } return r; }
|
|
133
|
-
case 4: return { type: "BlockStatement", start, end,
|
|
134
|
-
case 5: return { type: "BlockStatement", start, end,
|
|
134
|
+
case 4: return { type: "BlockStatement", start, end, body: nodeArr(f1, f0) };
|
|
135
|
+
case 5: return { type: "BlockStatement", start, end, body: nodeArr(f1, f0) };
|
|
135
136
|
case 6: return { params: fnParams(i) };
|
|
136
137
|
case 7: return node(f1);
|
|
137
138
|
case 8: return { type: "BinaryExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: BINARY_OPS[flags & 31] };
|
|
@@ -154,10 +155,10 @@ function decode(buffer, source) {
|
|
|
154
155
|
case 25: return { type: "MetaProperty", start, end, meta: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null };
|
|
155
156
|
case 26: return { type: "Decorator", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
156
157
|
case 27: { const r = { type: CLASS_TYPES[flags & 1], start, end, decorators: nodeArr(f1, f0), id: f2 !== NULL ? node(f2) : null, superClass: f3 !== NULL ? node(f3) : null, body: node(f4) }; if (_isTs) { r.typeParameters = f5 !== NULL ? node(f5) : null; r.superTypeArguments = f6 !== NULL ? node(f6) : null; r.implements = nodeArr(f7, f8); r.abstract = !!(flags & 2); r.declare = !!(flags & 4); } return r; }
|
|
157
|
-
case 28: return { type: "ClassBody", start, end,
|
|
158
|
+
case 28: return { type: "ClassBody", start, end, body: nodeArr(f1, f0) };
|
|
158
159
|
case 29: { const r = { type: "MethodDefinition", start, end, decorators: nodeArr(f1, f0), key: node(f2), value: node(f3), kind: METHOD_KINDS[flags & 3], computed: !!(flags & 4), static: !!(flags & 8) }; if (_isTs) { r.override = !!(flags & 16); r.optional = !!(flags & 32); const _abs = !!(flags & 64); r.accessibility = ACCESSIBILITY[(flags >> 7) & 3]; if (_abs) r.type = "TSAbstractMethodDefinition"; } return r; }
|
|
159
160
|
case 30: { const _acc = !!(flags & 4); const r = { type: _acc ? "AccessorProperty" : "PropertyDefinition", start, end, decorators: nodeArr(f1, f0), key: node(f2), value: f3 !== NULL ? node(f3) : null, computed: !!(flags & 1), static: !!(flags & 2) }; if (_isTs) { r.typeAnnotation = f4 !== NULL ? node(f4) : null; r.declare = !!(flags & 8); r.override = !!(flags & 16); r.optional = !!(flags & 32); r.definite = !!(flags & 64); r.readonly = !!(flags & 128); const _abs = !!(flags & 256); r.accessibility = ACCESSIBILITY[(flags >> 9) & 3]; if (_abs) r.type = _acc ? "TSAbstractAccessorProperty" : "TSAbstractPropertyDefinition"; } return r; }
|
|
160
|
-
case 31: return { type: "StaticBlock", start, end,
|
|
161
|
+
case 31: return { type: "StaticBlock", start, end, body: nodeArr(f1, f0) };
|
|
161
162
|
case 32: return { type: "Super", start, end };
|
|
162
163
|
case 33: return { type: "Literal", start, end, value: str(f1, f2), raw: _src.slice(start, end) };
|
|
163
164
|
case 34: { const r = _src.slice(start, end); const s = r.indexOf("_") === -1 ? r : r.replace(/_/g, ""); const v = (flags & 3) === 2 && s[1] !== "o" && s[1] !== "O" ? parseInt(s.slice(1), 8) : +s; return { type: "Literal", start, end, value: v === v && isFinite(v) ? v : null, raw: r }; }
|
|
@@ -200,7 +201,7 @@ function decode(buffer, source) {
|
|
|
200
201
|
case 71: { const el = nodeArrHoles(f1, f0); if (f2 !== NULL) el.push(node(f2)); const r = { type: "ArrayPattern", start, end, elements: el }; if (_isTs) { r.decorators = nodeArr(f3, f4); r.optional = !!(flags & 1); r.typeAnnotation = f5 !== NULL ? node(f5) : null; } return r; }
|
|
201
202
|
case 72: { const pr = nodeArr(f1, f0); if (f2 !== NULL) pr.push(node(f2)); const r = { type: "ObjectPattern", start, end, properties: pr }; if (_isTs) { r.decorators = nodeArr(f3, f4); r.optional = !!(flags & 1); r.typeAnnotation = f5 !== NULL ? node(f5) : null; } return r; }
|
|
202
203
|
case 73: { const r = { type: "Property", start, end, kind: "init", key: node(f1), value: node(f2), method: false, shorthand: !!(flags & 1), computed: !!(flags & 2) }; if (_isTs) { r.optional = false; } return r; }
|
|
203
|
-
case 74: return { type: "Program", start, end, sourceType: (flags & 1) ? "module" : "script", hashbang: (flags & 2) ? { type: "Hashbang", start: _p(f2 - 2), end: _p(f3), value: str(f2, f3) } : null,
|
|
204
|
+
case 74: return { type: "Program", start, end, sourceType: (flags & 1) ? "module" : "script", hashbang: (flags & 2) ? { type: "Hashbang", start: _p(f2 - 2), end: _p(f3), value: str(f2, f3) } : null, body: nodeArr(f1, f0) };
|
|
204
205
|
case 75: return { type: "ImportExpression", start, end, source: f1 !== NULL ? node(f1) : null, options: f2 !== NULL ? node(f2) : null, phase: (flags & 1) ? ["source", "defer"][(flags >> 1) & 1] : null };
|
|
205
206
|
case 76: { const r = { type: "ImportDeclaration", start, end, specifiers: nodeArr(f1, f0), source: f2 !== NULL ? node(f2) : null, attributes: nodeArr(f3, f4), phase: (flags & 1) ? ["source", "defer"][(flags >> 1) & 1] : null }; if (_isTs) { r.importKind = IMPORT_EXPORT_KINDS[(flags >> 2) & 1]; } return r; }
|
|
206
207
|
case 77: { const r = { type: "ImportSpecifier", start, end, imported: f1 !== NULL ? node(f1) : null, local: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.importKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
|
|
@@ -262,14 +263,14 @@ function decode(buffer, source) {
|
|
|
262
263
|
case 133: { const r = { type: "TSIndexSignature", start, end, parameters: nodeArr(f1, f0), typeAnnotation: f2 !== NULL ? node(f2) : null, readonly: !!(flags & 1) }; if (_isTs) { r.static = !!(flags & 2); r.accessibility = null; } return r; }
|
|
263
264
|
case 134: return { type: "TSTypeAliasDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, typeParameters: f2 !== NULL ? node(f2) : null, typeAnnotation: f3 !== NULL ? node(f3) : null, declare: !!(flags & 1) };
|
|
264
265
|
case 135: return { type: "TSInterfaceDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, typeParameters: f2 !== NULL ? node(f2) : null, extends: nodeArr(f3, f0), body: f4 !== NULL ? node(f4) : null, declare: !!(flags & 1) };
|
|
265
|
-
case 136: return { type: "TSInterfaceBody", start, end,
|
|
266
|
+
case 136: return { type: "TSInterfaceBody", start, end, body: nodeArr(f1, f0) };
|
|
266
267
|
case 137: return { type: "TSInterfaceHeritage", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
|
|
267
268
|
case 138: return { type: "TSClassImplements", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
|
|
268
269
|
case 139: return { type: "TSEnumDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null, const: !!(flags & 1), declare: !!(flags & 2) };
|
|
269
|
-
case 140: return { type: "TSEnumBody", start, end,
|
|
270
|
+
case 140: return { type: "TSEnumBody", start, end, members: nodeArr(f1, f0) };
|
|
270
271
|
case 141: return { type: "TSEnumMember", start, end, id: f1 !== NULL ? node(f1) : null, initializer: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1) };
|
|
271
272
|
case 142: { const r = { type: "TSModuleDeclaration", start, end, id: node(f1), kind: TS_MODULE_KINDS[(flags >> 0) & 1], declare: !!(flags & 2), global: false }; if (f2 !== NULL) r.body = node(f2); return r; }
|
|
272
|
-
case 143: return { type: "TSModuleBlock", start, end,
|
|
273
|
+
case 143: return { type: "TSModuleBlock", start, end, body: nodeArr(f1, f0) };
|
|
273
274
|
case 144: return { type: "TSModuleDeclaration", start, end, id: node(f1), body: node(f2), kind: "global", declare: !!(flags & 1), global: true };
|
|
274
275
|
case 145: { const r = { type: "TSParameterProperty", start, end, decorators: nodeArr(f1, f0), parameter: f2 !== NULL ? node(f2) : null, override: !!(flags & 1), readonly: !!(flags & 2), accessibility: ACCESSIBILITY[(flags >> 2) & 3] }; if (_isTs) { r.static = false; } return r; }
|
|
275
276
|
case 146: return { type: "Identifier", start, end, decorators: [], name: "this", optional: false, typeAnnotation: f1 !== NULL ? node(f1) : null };
|
|
@@ -299,13 +300,37 @@ function decode(buffer, source) {
|
|
|
299
300
|
case 170: return { type: "JSXSpreadChild", start, end, expression: f1 !== NULL ? node(f1) : null };
|
|
300
301
|
}
|
|
301
302
|
}
|
|
302
|
-
const cOff = _spOff + spLen
|
|
303
|
+
const cOff = _spOff + spLen;
|
|
304
|
+
const lsOff = cOff + commentCount * 20;
|
|
305
|
+
const dOff = lsOff + lineStartsCount * 4;
|
|
303
306
|
const dv = new DataView(buffer);
|
|
304
307
|
function _decodeComments() {
|
|
305
308
|
const out = new Array(commentCount);
|
|
306
309
|
for (let j = 0; j < commentCount; j++) {
|
|
307
310
|
const o = cOff + j * 20;
|
|
308
|
-
|
|
311
|
+
const flags = _u8[o + 2];
|
|
312
|
+
out[j] = {
|
|
313
|
+
type: COMMENT_TYPES[_u8[o + 0]],
|
|
314
|
+
kind: COMMENT_KINDS[_u8[o + 1]],
|
|
315
|
+
precededByNewline: (flags & 1) !== 0,
|
|
316
|
+
followedByNewline: (flags & 2) !== 0,
|
|
317
|
+
value: str(dv.getUint32(o + 12, true), dv.getUint32(o + 16, true)),
|
|
318
|
+
start: _p(dv.getUint32(o + 4, true)),
|
|
319
|
+
end: _p(dv.getUint32(o + 8, true)),
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
return out;
|
|
323
|
+
}
|
|
324
|
+
function _decodeLineStarts() {
|
|
325
|
+
const out = new Array(lineStartsCount);
|
|
326
|
+
if (_firstNa >= _srcLen) {
|
|
327
|
+
for (let j = 0; j < lineStartsCount; j++) out[j] = dv.getUint32(lsOff + j * 4, true);
|
|
328
|
+
return out;
|
|
329
|
+
}
|
|
330
|
+
if (pm === null) pm = buildPosMap(_src, _srcLen, _firstNa);
|
|
331
|
+
for (let j = 0; j < lineStartsCount; j++) {
|
|
332
|
+
const v = dv.getUint32(lsOff + j * 4, true);
|
|
333
|
+
out[j] = v < _firstNa ? v : (v >= _srcLen ? pm[pm.length - 1] : pm[v - _firstNa]);
|
|
309
334
|
}
|
|
310
335
|
return out;
|
|
311
336
|
}
|
|
@@ -333,11 +358,11 @@ function decode(buffer, source) {
|
|
|
333
358
|
}
|
|
334
359
|
return out;
|
|
335
360
|
}
|
|
336
|
-
|
|
337
|
-
let _program, _comments, _diagnostics;
|
|
361
|
+
let _program, _comments, _lineStarts, _diagnostics;
|
|
338
362
|
return {
|
|
339
363
|
get program() { return _program !== undefined ? _program : (_program = node(progIdx)); },
|
|
340
364
|
get comments() { return _comments !== undefined ? _comments : (_comments = _decodeComments()); },
|
|
365
|
+
get lineStarts() { return _lineStarts !== undefined ? _lineStarts : (_lineStarts = _decodeLineStarts()); },
|
|
341
366
|
get diagnostics() { return _diagnostics !== undefined ? _diagnostics : (_diagnostics = _decodeDiagnostics()); },
|
|
342
367
|
};
|
|
343
368
|
}
|
package/index.d.ts
CHANGED
|
@@ -45,9 +45,27 @@ interface ParseOptions {
|
|
|
45
45
|
/** Whether a {@link Comment} came from a line or block source comment. */
|
|
46
46
|
type CommentType = "Line" | "Block";
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Semantic classification of a {@link Comment}, computed at parse time so
|
|
50
|
+
* consumers can route comments without rescanning their value.
|
|
51
|
+
*
|
|
52
|
+
* - `"normal"`: plain comment with no special meaning.
|
|
53
|
+
* - `"legal"`: `/*! ... *\/` or contains `@license`, `@preserve`, or `@cc_on`.
|
|
54
|
+
* - `"jsdoc"`: `/** ... *\/` block.
|
|
55
|
+
* - `"annotation"`: `/*# ... *\/` or `/*@ ... *\/` other than tree-shaking.
|
|
56
|
+
* - `"pure"`: `/*#__PURE__*\/` or `/*@__PURE__*\/`.
|
|
57
|
+
* - `"no_side_effects"`: `/*#__NO_SIDE_EFFECTS__*\/` or `/*@__NO_SIDE_EFFECTS__*\/`.
|
|
58
|
+
*/
|
|
59
|
+
type CommentKind = "normal" | "legal" | "jsdoc" | "annotation" | "pure" | "no_side_effects";
|
|
60
|
+
|
|
48
61
|
/** A source code comment. */
|
|
49
62
|
interface Comment {
|
|
50
63
|
type: CommentType;
|
|
64
|
+
kind: CommentKind;
|
|
65
|
+
/** True when a line terminator immediately precedes this comment. */
|
|
66
|
+
precededByNewline: boolean;
|
|
67
|
+
/** True when a line terminator immediately follows this comment. */
|
|
68
|
+
followedByNewline: boolean;
|
|
51
69
|
/** Comment text without the delimiters. */
|
|
52
70
|
value: string;
|
|
53
71
|
/** Byte offset. */
|
|
@@ -91,6 +109,8 @@ interface ParseResult {
|
|
|
91
109
|
program: Program;
|
|
92
110
|
/** All comments in source order. */
|
|
93
111
|
comments: Comment[];
|
|
112
|
+
/** Byte offset where each source line begins. Index 0 is always 0. */
|
|
113
|
+
lineStarts: number[];
|
|
94
114
|
/** Syntax diagnostics, and semantic diagnostics when {@link ParseOptions.semanticErrors} is enabled. */
|
|
95
115
|
diagnostics: Diagnostic[];
|
|
96
116
|
}
|
|
@@ -912,7 +932,10 @@ interface ImportDeclaration extends BaseNode {
|
|
|
912
932
|
importKind?: ImportOrExportKind;
|
|
913
933
|
}
|
|
914
934
|
|
|
915
|
-
type ImportDeclarationSpecifier =
|
|
935
|
+
type ImportDeclarationSpecifier =
|
|
936
|
+
| ImportSpecifier
|
|
937
|
+
| ImportDefaultSpecifier
|
|
938
|
+
| ImportNamespaceSpecifier;
|
|
916
939
|
|
|
917
940
|
interface ImportSpecifier extends BaseNode {
|
|
918
941
|
type: "ImportSpecifier";
|
|
@@ -1189,7 +1212,13 @@ interface TSTypeParameterInstantiation extends BaseNode {
|
|
|
1189
1212
|
|
|
1190
1213
|
interface TSLiteralType extends BaseNode {
|
|
1191
1214
|
type: "TSLiteralType";
|
|
1192
|
-
literal:
|
|
1215
|
+
literal:
|
|
1216
|
+
| StringLiteral
|
|
1217
|
+
| NumericLiteral
|
|
1218
|
+
| BigIntLiteral
|
|
1219
|
+
| BooleanLiteral
|
|
1220
|
+
| TemplateLiteral
|
|
1221
|
+
| UnaryExpression;
|
|
1193
1222
|
}
|
|
1194
1223
|
|
|
1195
1224
|
interface TSTemplateLiteralType extends BaseNode {
|
|
@@ -1709,6 +1738,7 @@ export type {
|
|
|
1709
1738
|
ParseResult,
|
|
1710
1739
|
Comment,
|
|
1711
1740
|
CommentType,
|
|
1741
|
+
CommentKind,
|
|
1712
1742
|
Diagnostic,
|
|
1713
1743
|
DiagnosticLabel,
|
|
1714
1744
|
DiagnosticSeverity,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuku-parser",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.11",
|
|
4
4
|
"description": "High-performance JavaScript/TypeScript parser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,38 +17,38 @@
|
|
|
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.11",
|
|
21
|
+
"@yuku-parser/binding-linux-arm64-gnu": "0.5.11",
|
|
22
|
+
"@yuku-parser/binding-linux-arm-gnu": "0.5.11",
|
|
23
|
+
"@yuku-parser/binding-linux-x64-musl": "0.5.11",
|
|
24
|
+
"@yuku-parser/binding-linux-arm64-musl": "0.5.11",
|
|
25
|
+
"@yuku-parser/binding-linux-arm-musl": "0.5.11",
|
|
26
|
+
"@yuku-parser/binding-darwin-x64": "0.5.11",
|
|
27
|
+
"@yuku-parser/binding-darwin-arm64": "0.5.11",
|
|
28
|
+
"@yuku-parser/binding-win32-x64": "0.5.11",
|
|
29
|
+
"@yuku-parser/binding-win32-arm64": "0.5.11",
|
|
30
|
+
"@yuku-parser/binding-freebsd-x64": "0.5.11"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
|
-
"
|
|
34
|
-
"javascript",
|
|
35
|
-
"typescript",
|
|
36
|
-
"js",
|
|
37
|
-
"ts",
|
|
33
|
+
"acorn",
|
|
38
34
|
"ast",
|
|
35
|
+
"babel",
|
|
36
|
+
"compiler",
|
|
39
37
|
"ecmascript",
|
|
38
|
+
"espree",
|
|
39
|
+
"fast",
|
|
40
|
+
"javascript",
|
|
41
|
+
"js",
|
|
40
42
|
"jsx",
|
|
41
|
-
"tsx",
|
|
42
|
-
"tokenizer",
|
|
43
43
|
"lexer",
|
|
44
|
-
"compiler",
|
|
45
|
-
"rust",
|
|
46
44
|
"napi",
|
|
47
|
-
"fast",
|
|
48
|
-
"swc",
|
|
49
|
-
"acorn",
|
|
50
|
-
"babel",
|
|
51
45
|
"oxc",
|
|
52
|
-
"
|
|
46
|
+
"parser",
|
|
47
|
+
"rust",
|
|
48
|
+
"swc",
|
|
49
|
+
"tokenizer",
|
|
50
|
+
"ts",
|
|
51
|
+
"tsx",
|
|
52
|
+
"typescript"
|
|
53
53
|
]
|
|
54
54
|
}
|