oxc-parser 0.87.0 → 0.88.0
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/{bindings.js → bindings.mjs} +15 -12
- package/generated/constants.mjs +9 -0
- package/generated/deserialize/{js.js → js.mjs} +1 -5
- package/generated/deserialize/{ts.js → ts.mjs} +1 -5
- package/generated/lazy/{constructors.js → constructors.mjs} +206 -415
- package/generated/lazy/{types.js → types.mjs} +3 -11
- package/generated/lazy/{walk.js → walk.mjs} +148 -150
- package/{index.js → index.mjs} +18 -22
- package/package.json +33 -34
- package/raw-transfer/{common.js → common.mjs} +8 -16
- package/raw-transfer/{eager.js → eager.mjs} +7 -8
- package/raw-transfer/{lazy-common.js → lazy-common.mjs} +2 -6
- package/raw-transfer/{lazy.js → lazy.mjs} +9 -12
- package/raw-transfer/{node-array.js → node-array.mjs} +2 -6
- package/raw-transfer/{supported.js → supported.mjs} +2 -6
- package/raw-transfer/{visitor.js → visitor.mjs} +5 -11
- package/generated/constants.js +0 -18
- package/wrap.cjs +0 -58
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { TOKEN, constructorError } = require('./lazy-common.js');
|
|
1
|
+
import { constructorError, TOKEN } from './lazy-common.mjs';
|
|
4
2
|
|
|
5
3
|
// Internal symbol to get `NodeArray` from a proxy wrapping a `NodeArray`.
|
|
6
4
|
//
|
|
@@ -23,7 +21,7 @@ let getInternalFromProxy, getLength, getElement;
|
|
|
23
21
|
* TODO: Other methods could maybe be more optimal, avoiding going via proxy multiple times
|
|
24
22
|
* e.g. `some`, `indexOf`.
|
|
25
23
|
*/
|
|
26
|
-
class NodeArray extends Array {
|
|
24
|
+
export class NodeArray extends Array {
|
|
27
25
|
#internal;
|
|
28
26
|
|
|
29
27
|
/**
|
|
@@ -153,8 +151,6 @@ class NodeArray extends Array {
|
|
|
153
151
|
|
|
154
152
|
NodeArray.prototype[Symbol.iterator] = NodeArray.prototype.values;
|
|
155
153
|
|
|
156
|
-
module.exports = NodeArray;
|
|
157
|
-
|
|
158
154
|
/**
|
|
159
155
|
* Iterator over values of a `NodeArray`.
|
|
160
156
|
* Returned by `values` method, and also used as iterator for `for (const node of nodeArray) {}`.
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const rawTransferSupportedBinding = require('../bindings.js').rawTransferSupported;
|
|
4
|
-
|
|
5
|
-
module.exports = rawTransferSupported;
|
|
1
|
+
import { rawTransferSupported as rawTransferSupportedBinding } from '../bindings.mjs';
|
|
6
2
|
|
|
7
3
|
let rawTransferIsSupported = null;
|
|
8
4
|
|
|
@@ -21,7 +17,7 @@ let rawTransferIsSupported = null;
|
|
|
21
17
|
*
|
|
22
18
|
* @returns {boolean} - `true` if raw transfer is supported on this platform
|
|
23
19
|
*/
|
|
24
|
-
function rawTransferSupported() {
|
|
20
|
+
export function rawTransferSupported() {
|
|
25
21
|
if (rawTransferIsSupported === null) {
|
|
26
22
|
rawTransferIsSupported = rawTransferRuntimeSupported() && rawTransferSupportedBinding();
|
|
27
23
|
}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
NODE_TYPE_IDS_MAP,
|
|
5
|
-
NODE_TYPES_COUNT,
|
|
6
|
-
LEAF_NODE_TYPES_COUNT,
|
|
7
|
-
} = require('../generated/lazy/types.js');
|
|
1
|
+
import { LEAF_NODE_TYPES_COUNT, NODE_TYPE_IDS_MAP, NODE_TYPES_COUNT } from '../generated/lazy/types.mjs';
|
|
8
2
|
|
|
9
3
|
// Getter for private `#visitorsArr` property of `Visitor` class. Initialized in class body below.
|
|
10
|
-
let
|
|
4
|
+
let getVisitorsArrTemp;
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Visitor class, used to visit an AST.
|
|
14
8
|
*/
|
|
15
|
-
class Visitor {
|
|
9
|
+
export class Visitor {
|
|
16
10
|
#visitorsArr;
|
|
17
11
|
|
|
18
12
|
/**
|
|
@@ -43,11 +37,11 @@ class Visitor {
|
|
|
43
37
|
}
|
|
44
38
|
|
|
45
39
|
static {
|
|
46
|
-
|
|
40
|
+
getVisitorsArrTemp = visitor => visitor.#visitorsArr;
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
|
|
44
|
+
export const getVisitorsArr = getVisitorsArrTemp;
|
|
51
45
|
|
|
52
46
|
/**
|
|
53
47
|
* Create array of visitors, keyed by node type ID.
|
package/generated/constants.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Auto-generated code, DO NOT EDIT DIRECTLY!
|
|
2
|
-
// To edit this generated file you have to edit `tasks/ast_tools/src/generators/raw_transfer.rs`.
|
|
3
|
-
|
|
4
|
-
const BUFFER_SIZE = 2147483616,
|
|
5
|
-
BUFFER_ALIGN = 4294967296,
|
|
6
|
-
DATA_POINTER_POS_32 = 536870902,
|
|
7
|
-
IS_TS_FLAG_POS = 2147483612,
|
|
8
|
-
PROGRAM_OFFSET = 0,
|
|
9
|
-
SOURCE_LEN_OFFSET = 16;
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
BUFFER_SIZE,
|
|
13
|
-
BUFFER_ALIGN,
|
|
14
|
-
DATA_POINTER_POS_32,
|
|
15
|
-
IS_TS_FLAG_POS,
|
|
16
|
-
PROGRAM_OFFSET,
|
|
17
|
-
SOURCE_LEN_OFFSET,
|
|
18
|
-
};
|
package/wrap.cjs
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// Note: This code is repeated in `wrap.mjs`.
|
|
2
|
-
// Any changes should be applied in that file too.
|
|
3
|
-
|
|
4
|
-
module.exports.wrap = function wrap(result) {
|
|
5
|
-
let program, module, comments, errors;
|
|
6
|
-
return {
|
|
7
|
-
get program() {
|
|
8
|
-
if (!program) program = jsonParseAst(result.program);
|
|
9
|
-
return program;
|
|
10
|
-
},
|
|
11
|
-
get module() {
|
|
12
|
-
if (!module) module = result.module;
|
|
13
|
-
return module;
|
|
14
|
-
},
|
|
15
|
-
get comments() {
|
|
16
|
-
if (!comments) comments = result.comments;
|
|
17
|
-
return comments;
|
|
18
|
-
},
|
|
19
|
-
get errors() {
|
|
20
|
-
if (!errors) errors = result.errors;
|
|
21
|
-
return errors;
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// Set `value` field of `Literal`s which are `BigInt`s or `RegExp`s.
|
|
27
|
-
//
|
|
28
|
-
// Returned JSON contains an array `fixes` with paths to these nodes
|
|
29
|
-
// e.g. for `123n; foo(/xyz/)`, `fixes` will be
|
|
30
|
-
// `[["body", 0, "expression"], ["body", 1, "expression", "arguments", 2]]`.
|
|
31
|
-
//
|
|
32
|
-
// Walk down the AST to these nodes and alter them.
|
|
33
|
-
// Compiling the list of fixes on Rust side avoids having to do a full AST traversal on JS side
|
|
34
|
-
// to locate the likely very few `Literal`s which need fixing.
|
|
35
|
-
function jsonParseAst(programJson) {
|
|
36
|
-
const { node: program, fixes } = JSON.parse(programJson);
|
|
37
|
-
for (const fixPath of fixes) {
|
|
38
|
-
applyFix(program, fixPath);
|
|
39
|
-
}
|
|
40
|
-
return program;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function applyFix(program, fixPath) {
|
|
44
|
-
let node = program;
|
|
45
|
-
for (const key of fixPath) {
|
|
46
|
-
node = node[key];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (node.bigint) {
|
|
50
|
-
node.value = BigInt(node.bigint);
|
|
51
|
-
} else {
|
|
52
|
-
try {
|
|
53
|
-
node.value = RegExp(node.regex.pattern, node.regex.flags);
|
|
54
|
-
} catch (_err) { // oxlint-disable-line no-unused-vars
|
|
55
|
-
// Invalid regexp, or valid regexp using syntax not supported by this version of NodeJS
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|