oxc-parser 0.56.4 → 0.57.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/deserialize-js.js CHANGED
@@ -1180,7 +1180,7 @@ function deserializeJSXNamespacedName(pos) {
1180
1180
  start: deserializeU32(pos),
1181
1181
  end: deserializeU32(pos + 4),
1182
1182
  namespace: deserializeJSXIdentifier(pos + 8),
1183
- property: deserializeJSXIdentifier(pos + 32),
1183
+ name: deserializeJSXIdentifier(pos + 32),
1184
1184
  };
1185
1185
  }
1186
1186
 
@@ -1771,11 +1771,11 @@ function deserializeTSImportType(pos) {
1771
1771
  type: 'TSImportType',
1772
1772
  start: deserializeU32(pos),
1773
1773
  end: deserializeU32(pos + 4),
1774
- isTypeOf: deserializeBool(pos + 8),
1775
- parameter: deserializeTSType(pos + 16),
1774
+ argument: deserializeTSType(pos + 8),
1775
+ options: deserializeOptionBoxTSImportAttributes(pos + 24),
1776
1776
  qualifier: deserializeOptionTSTypeName(pos + 32),
1777
- attributes: deserializeOptionBoxTSImportAttributes(pos + 48),
1778
- typeParameters: deserializeOptionBoxTSTypeParameterInstantiation(pos + 56),
1777
+ typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
1778
+ isTypeOf: deserializeBool(pos + 56),
1779
1779
  };
1780
1780
  }
1781
1781
 
@@ -5515,11 +5515,6 @@ function deserializeBoxTSTypeParameter(pos) {
5515
5515
  return deserializeTSTypeParameter(uint32[pos >> 2]);
5516
5516
  }
5517
5517
 
5518
- function deserializeOptionTSTypeName(pos) {
5519
- if (uint8[pos] === 2) return null;
5520
- return deserializeTSTypeName(pos);
5521
- }
5522
-
5523
5518
  function deserializeBoxTSImportAttributes(pos) {
5524
5519
  return deserializeTSImportAttributes(uint32[pos >> 2]);
5525
5520
  }
@@ -5529,6 +5524,11 @@ function deserializeOptionBoxTSImportAttributes(pos) {
5529
5524
  return deserializeBoxTSImportAttributes(pos);
5530
5525
  }
5531
5526
 
5527
+ function deserializeOptionTSTypeName(pos) {
5528
+ if (uint8[pos] === 2) return null;
5529
+ return deserializeTSTypeName(pos);
5530
+ }
5531
+
5532
5532
  function deserializeVecTSImportAttribute(pos) {
5533
5533
  const arr = [],
5534
5534
  pos32 = pos >> 2,
package/deserialize-ts.js CHANGED
@@ -1233,7 +1233,7 @@ function deserializeJSXNamespacedName(pos) {
1233
1233
  start: deserializeU32(pos),
1234
1234
  end: deserializeU32(pos + 4),
1235
1235
  namespace: deserializeJSXIdentifier(pos + 8),
1236
- property: deserializeJSXIdentifier(pos + 32),
1236
+ name: deserializeJSXIdentifier(pos + 32),
1237
1237
  };
1238
1238
  }
1239
1239
 
@@ -1824,11 +1824,11 @@ function deserializeTSImportType(pos) {
1824
1824
  type: 'TSImportType',
1825
1825
  start: deserializeU32(pos),
1826
1826
  end: deserializeU32(pos + 4),
1827
- isTypeOf: deserializeBool(pos + 8),
1828
- parameter: deserializeTSType(pos + 16),
1827
+ argument: deserializeTSType(pos + 8),
1828
+ options: deserializeOptionBoxTSImportAttributes(pos + 24),
1829
1829
  qualifier: deserializeOptionTSTypeName(pos + 32),
1830
- attributes: deserializeOptionBoxTSImportAttributes(pos + 48),
1831
- typeParameters: deserializeOptionBoxTSTypeParameterInstantiation(pos + 56),
1830
+ typeArguments: deserializeOptionBoxTSTypeParameterInstantiation(pos + 48),
1831
+ isTypeOf: deserializeBool(pos + 56),
1832
1832
  };
1833
1833
  }
1834
1834
 
@@ -5568,11 +5568,6 @@ function deserializeBoxTSTypeParameter(pos) {
5568
5568
  return deserializeTSTypeParameter(uint32[pos >> 2]);
5569
5569
  }
5570
5570
 
5571
- function deserializeOptionTSTypeName(pos) {
5572
- if (uint8[pos] === 2) return null;
5573
- return deserializeTSTypeName(pos);
5574
- }
5575
-
5576
5571
  function deserializeBoxTSImportAttributes(pos) {
5577
5572
  return deserializeTSImportAttributes(uint32[pos >> 2]);
5578
5573
  }
@@ -5582,6 +5577,11 @@ function deserializeOptionBoxTSImportAttributes(pos) {
5582
5577
  return deserializeBoxTSImportAttributes(pos);
5583
5578
  }
5584
5579
 
5580
+ function deserializeOptionTSTypeName(pos) {
5581
+ if (uint8[pos] === 2) return null;
5582
+ return deserializeTSTypeName(pos);
5583
+ }
5584
+
5585
5585
  function deserializeVecTSImportAttribute(pos) {
5586
5586
  const arr = [],
5587
5587
  pos32 = pos >> 2,
package/index.d.ts CHANGED
@@ -151,11 +151,11 @@ export interface ParserOptions {
151
151
  */
152
152
  astType?: 'js' | 'ts'
153
153
  /**
154
- * Emit `ParenthesizedExpression` in AST.
154
+ * Emit `ParenthesizedExpression` and `TSParenthesizedType` in AST.
155
155
  *
156
156
  * If this option is true, parenthesized expressions are represented by
157
- * (non-standard) `ParenthesizedExpression` nodes that have a single `expression` property
158
- * containing the expression inside parentheses.
157
+ * (non-standard) `ParenthesizedExpression` and `TSParenthesizedType` nodes that
158
+ * have a single `expression` property containing the expression inside parentheses.
159
159
  *
160
160
  * @default true
161
161
  */
package/index.js CHANGED
@@ -69,7 +69,10 @@ let buffer, encoder;
69
69
 
70
70
  function parseSyncRaw(filename, sourceText, options) {
71
71
  if (!rawTransferSupported()) {
72
- throw new Error('`experimentalRawTransfer` option is not supported on 32-bit or big-endian systems');
72
+ throw new Error(
73
+ '`experimentalRawTransfer` option is not supported on 32-bit or big-endian systems, ' +
74
+ 'versions of NodeJS prior to v22.0.0, versions of Deno prior to v2.0.0, and other runtimes',
75
+ );
73
76
  }
74
77
 
75
78
  // Delete `experimentalRawTransfer` option
@@ -146,10 +149,45 @@ function createBuffer() {
146
149
  let rawTransferIsSupported = null;
147
150
 
148
151
  // Returns `true` if `experimentalRawTransfer` is option is supported.
149
- // Raw transfer is only available on 64-bit little-endian systems.
152
+ //
153
+ // Raw transfer is only supported on 64-bit little-endian systems,
154
+ // and NodeJS >= v22.0.0 or Deno >= v2.0.0.
155
+ //
156
+ // Versions of NodeJS prior to v22.0.0 do not support creating an `ArrayBuffer` larger than 4 GiB.
157
+ // Bun (as at v1.2.4) also does not support creating an `ArrayBuffer` larger than 4 GiB.
158
+ // Support on Deno v1 is unknown and it's EOL, so treating Deno before v2.0.0 as unsupported.
150
159
  function rawTransferSupported() {
151
- if (rawTransferIsSupported === null) rawTransferIsSupported = bindings.rawTransferSupported();
160
+ if (rawTransferIsSupported === null) {
161
+ rawTransferIsSupported = rawTransferRuntimeSupported() && bindings.rawTransferSupported();
162
+ }
152
163
  return rawTransferIsSupported;
153
164
  }
154
165
 
155
166
  module.exports.rawTransferSupported = rawTransferSupported;
167
+
168
+ // Checks copied from:
169
+ // https://github.com/unjs/std-env/blob/ab15595debec9e9115a9c1d31bc7597a8e71dbfd/src/runtimes.ts
170
+ // MIT license: https://github.com/unjs/std-env/blob/ab15595debec9e9115a9c1d31bc7597a8e71dbfd/LICENCE
171
+ function rawTransferRuntimeSupported() {
172
+ let global;
173
+ try {
174
+ global = globalThis;
175
+ } catch (e) {
176
+ return false;
177
+ }
178
+
179
+ const isBun = !!global.Bun || !!global.process?.versions?.bun;
180
+ if (isBun) return false;
181
+
182
+ const isDeno = !!global.Deno;
183
+ if (isDeno) {
184
+ const match = Deno.version?.deno?.match(/^(\d+)\./);
185
+ return !!match && match[1] * 1 >= 2;
186
+ }
187
+
188
+ const isNode = global.process?.release?.name === 'node';
189
+ if (!isNode) return false;
190
+
191
+ const match = process.version?.match(/^v(\d+)\./);
192
+ return !!match && match[1] * 1 >= 22;
193
+ }
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "oxc-parser",
3
- "version": "0.56.4",
3
+ "version": "0.57.0",
4
4
  "main": "index.js",
5
5
  "browser": "browser.js",
6
+ "engines": {
7
+ "node": ">=14.0.0"
8
+ },
6
9
  "description": "Oxc Parser Node API",
7
10
  "keywords": [
8
11
  "oxc",
@@ -15,7 +18,7 @@
15
18
  "repository": {
16
19
  "type": "git",
17
20
  "url": "https://github.com/oxc-project/oxc.git",
18
- "directory": "npm/oxc-parser"
21
+ "directory": "napi/parser"
19
22
  },
20
23
  "funding": {
21
24
  "url": "https://github.com/sponsors/Boshen"
@@ -33,10 +36,11 @@
33
36
  "access": "public"
34
37
  },
35
38
  "dependencies": {
36
- "@oxc-project/types": "^0.56.4"
39
+ "@oxc-project/types": "^0.57.0"
37
40
  },
38
- "engines": {
39
- "node": ">=14.0.0"
41
+ "devDependencies": {
42
+ "@codspeed/vitest-plugin": "^4.0.0",
43
+ "vitest": "3.0.7"
40
44
  },
41
45
  "napi": {
42
46
  "binaryName": "parser",
@@ -61,15 +65,21 @@
61
65
  "dtsHeaderFile": "header.js"
62
66
  },
63
67
  "optionalDependencies": {
64
- "@oxc-parser/binding-win32-x64-msvc": "0.56.4",
65
- "@oxc-parser/binding-win32-arm64-msvc": "0.56.4",
66
- "@oxc-parser/binding-linux-x64-gnu": "0.56.4",
67
- "@oxc-parser/binding-linux-x64-musl": "0.56.4",
68
- "@oxc-parser/binding-linux-arm64-gnu": "0.56.4",
69
- "@oxc-parser/binding-linux-arm64-musl": "0.56.4",
70
- "@oxc-parser/binding-linux-arm-gnueabihf": "0.56.4",
71
- "@oxc-parser/binding-darwin-x64": "0.56.4",
72
- "@oxc-parser/binding-darwin-arm64": "0.56.4",
73
- "@oxc-parser/binding-wasm32-wasi": "0.56.4"
68
+ "@oxc-parser/binding-win32-x64-msvc": "0.57.0",
69
+ "@oxc-parser/binding-win32-arm64-msvc": "0.57.0",
70
+ "@oxc-parser/binding-linux-x64-gnu": "0.57.0",
71
+ "@oxc-parser/binding-linux-x64-musl": "0.57.0",
72
+ "@oxc-parser/binding-linux-arm64-gnu": "0.57.0",
73
+ "@oxc-parser/binding-linux-arm64-musl": "0.57.0",
74
+ "@oxc-parser/binding-linux-arm-gnueabihf": "0.57.0",
75
+ "@oxc-parser/binding-darwin-x64": "0.57.0",
76
+ "@oxc-parser/binding-darwin-arm64": "0.57.0",
77
+ "@oxc-parser/binding-wasm32-wasi": "0.57.0"
78
+ },
79
+ "scripts": {
80
+ "build-dev": "napi build --no-dts-cache --platform --js bindings.js",
81
+ "build": "pnpm run build-dev --release",
82
+ "test": "vitest --typecheck run ./test && tsc",
83
+ "bench": "vitest bench --run ./bench.bench.mjs"
74
84
  }
75
85
  }