oxc-parser 0.130.0 → 0.132.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/package.json +27 -27
- package/src-js/bindings.js +52 -52
- package/src-js/generated/deserialize/js.js +27 -13
- package/src-js/generated/deserialize/js_range.js +27 -13
- package/src-js/generated/deserialize/ts.js +27 -13
- package/src-js/generated/deserialize/ts_range.js +27 -13
- package/src-js/generated/lazy/constructors.js +4 -1
- package/src-js/raw-transfer/common.js +31 -13
- package/src-js/raw-transfer/eager.js +3 -2
- package/src-js/raw-transfer/lazy.js +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxc-parser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.132.0",
|
|
4
4
|
"description": "Oxc Parser Node API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ast",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"registry": "https://registry.npmjs.org/"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@oxc-project/types": "^0.
|
|
62
|
+
"@oxc-project/types": "^0.132.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@codspeed/vitest-plugin": "^5.0.0",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"@napi-rs/wasm-runtime": "1.1.4",
|
|
70
70
|
"@types/node": "24.1.0",
|
|
71
71
|
"@typescript-eslint/visitor-keys": "^8.54.0",
|
|
72
|
-
"@vitest/browser": "4.1.
|
|
73
|
-
"@vitest/browser-playwright": "4.1.
|
|
72
|
+
"@vitest/browser": "4.1.6",
|
|
73
|
+
"@vitest/browser-playwright": "4.1.6",
|
|
74
74
|
"playwright": "^1.51.0",
|
|
75
|
-
"publint": "0.3.
|
|
76
|
-
"rolldown": "1.0.
|
|
75
|
+
"publint": "0.3.21",
|
|
76
|
+
"rolldown": "1.0.1",
|
|
77
77
|
"tinypool": "^2.0.0",
|
|
78
|
-
"vitest": "4.1.
|
|
78
|
+
"vitest": "4.1.6"
|
|
79
79
|
},
|
|
80
80
|
"napi": {
|
|
81
81
|
"binaryName": "parser",
|
|
@@ -113,26 +113,26 @@
|
|
|
113
113
|
"node": "^20.19.0 || >=22.12.0"
|
|
114
114
|
},
|
|
115
115
|
"optionalDependencies": {
|
|
116
|
-
"@oxc-parser/binding-darwin-arm64": "0.
|
|
117
|
-
"@oxc-parser/binding-android-arm64": "0.
|
|
118
|
-
"@oxc-parser/binding-win32-arm64-msvc": "0.
|
|
119
|
-
"@oxc-parser/binding-linux-arm64-gnu": "0.
|
|
120
|
-
"@oxc-parser/binding-linux-arm64-musl": "0.
|
|
121
|
-
"@oxc-parser/binding-openharmony-arm64": "0.
|
|
122
|
-
"@oxc-parser/binding-android-arm-eabi": "0.
|
|
123
|
-
"@oxc-parser/binding-linux-arm-gnueabihf": "0.
|
|
124
|
-
"@oxc-parser/binding-linux-arm-musleabihf": "0.
|
|
125
|
-
"@oxc-parser/binding-win32-ia32-msvc": "0.
|
|
126
|
-
"@oxc-parser/binding-linux-ppc64-gnu": "0.
|
|
127
|
-
"@oxc-parser/binding-linux-riscv64-gnu": "0.
|
|
128
|
-
"@oxc-parser/binding-linux-riscv64-musl": "0.
|
|
129
|
-
"@oxc-parser/binding-linux-s390x-gnu": "0.
|
|
130
|
-
"@oxc-parser/binding-wasm32-wasi": "0.
|
|
131
|
-
"@oxc-parser/binding-darwin-x64": "0.
|
|
132
|
-
"@oxc-parser/binding-win32-x64-msvc": "0.
|
|
133
|
-
"@oxc-parser/binding-freebsd-x64": "0.
|
|
134
|
-
"@oxc-parser/binding-linux-x64-gnu": "0.
|
|
135
|
-
"@oxc-parser/binding-linux-x64-musl": "0.
|
|
116
|
+
"@oxc-parser/binding-darwin-arm64": "0.132.0",
|
|
117
|
+
"@oxc-parser/binding-android-arm64": "0.132.0",
|
|
118
|
+
"@oxc-parser/binding-win32-arm64-msvc": "0.132.0",
|
|
119
|
+
"@oxc-parser/binding-linux-arm64-gnu": "0.132.0",
|
|
120
|
+
"@oxc-parser/binding-linux-arm64-musl": "0.132.0",
|
|
121
|
+
"@oxc-parser/binding-openharmony-arm64": "0.132.0",
|
|
122
|
+
"@oxc-parser/binding-android-arm-eabi": "0.132.0",
|
|
123
|
+
"@oxc-parser/binding-linux-arm-gnueabihf": "0.132.0",
|
|
124
|
+
"@oxc-parser/binding-linux-arm-musleabihf": "0.132.0",
|
|
125
|
+
"@oxc-parser/binding-win32-ia32-msvc": "0.132.0",
|
|
126
|
+
"@oxc-parser/binding-linux-ppc64-gnu": "0.132.0",
|
|
127
|
+
"@oxc-parser/binding-linux-riscv64-gnu": "0.132.0",
|
|
128
|
+
"@oxc-parser/binding-linux-riscv64-musl": "0.132.0",
|
|
129
|
+
"@oxc-parser/binding-linux-s390x-gnu": "0.132.0",
|
|
130
|
+
"@oxc-parser/binding-wasm32-wasi": "0.132.0",
|
|
131
|
+
"@oxc-parser/binding-darwin-x64": "0.132.0",
|
|
132
|
+
"@oxc-parser/binding-win32-x64-msvc": "0.132.0",
|
|
133
|
+
"@oxc-parser/binding-freebsd-x64": "0.132.0",
|
|
134
|
+
"@oxc-parser/binding-linux-x64-gnu": "0.132.0",
|
|
135
|
+
"@oxc-parser/binding-linux-x64-musl": "0.132.0"
|
|
136
136
|
},
|
|
137
137
|
"scripts": {
|
|
138
138
|
"build-dev": "napi build --esm --platform --js bindings.js --dts index.d.ts --output-dir src-js",
|
package/src-js/bindings.js
CHANGED
|
@@ -81,8 +81,8 @@ function requireNative() {
|
|
|
81
81
|
try {
|
|
82
82
|
const binding = require('@oxc-parser/binding-android-arm64')
|
|
83
83
|
const bindingPackageVersion = require('@oxc-parser/binding-android-arm64/package.json').version
|
|
84
|
-
if (bindingPackageVersion !== '0.
|
|
85
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
84
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
85
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
86
86
|
}
|
|
87
87
|
return binding
|
|
88
88
|
} catch (e) {
|
|
@@ -97,8 +97,8 @@ function requireNative() {
|
|
|
97
97
|
try {
|
|
98
98
|
const binding = require('@oxc-parser/binding-android-arm-eabi')
|
|
99
99
|
const bindingPackageVersion = require('@oxc-parser/binding-android-arm-eabi/package.json').version
|
|
100
|
-
if (bindingPackageVersion !== '0.
|
|
101
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
100
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
101
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
102
102
|
}
|
|
103
103
|
return binding
|
|
104
104
|
} catch (e) {
|
|
@@ -118,8 +118,8 @@ function requireNative() {
|
|
|
118
118
|
try {
|
|
119
119
|
const binding = require('@oxc-parser/binding-win32-x64-gnu')
|
|
120
120
|
const bindingPackageVersion = require('@oxc-parser/binding-win32-x64-gnu/package.json').version
|
|
121
|
-
if (bindingPackageVersion !== '0.
|
|
122
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
121
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
122
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
123
123
|
}
|
|
124
124
|
return binding
|
|
125
125
|
} catch (e) {
|
|
@@ -134,8 +134,8 @@ function requireNative() {
|
|
|
134
134
|
try {
|
|
135
135
|
const binding = require('@oxc-parser/binding-win32-x64-msvc')
|
|
136
136
|
const bindingPackageVersion = require('@oxc-parser/binding-win32-x64-msvc/package.json').version
|
|
137
|
-
if (bindingPackageVersion !== '0.
|
|
138
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
137
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
138
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
139
139
|
}
|
|
140
140
|
return binding
|
|
141
141
|
} catch (e) {
|
|
@@ -151,8 +151,8 @@ function requireNative() {
|
|
|
151
151
|
try {
|
|
152
152
|
const binding = require('@oxc-parser/binding-win32-ia32-msvc')
|
|
153
153
|
const bindingPackageVersion = require('@oxc-parser/binding-win32-ia32-msvc/package.json').version
|
|
154
|
-
if (bindingPackageVersion !== '0.
|
|
155
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
154
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
155
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
156
156
|
}
|
|
157
157
|
return binding
|
|
158
158
|
} catch (e) {
|
|
@@ -167,8 +167,8 @@ function requireNative() {
|
|
|
167
167
|
try {
|
|
168
168
|
const binding = require('@oxc-parser/binding-win32-arm64-msvc')
|
|
169
169
|
const bindingPackageVersion = require('@oxc-parser/binding-win32-arm64-msvc/package.json').version
|
|
170
|
-
if (bindingPackageVersion !== '0.
|
|
171
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
170
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
171
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
172
172
|
}
|
|
173
173
|
return binding
|
|
174
174
|
} catch (e) {
|
|
@@ -186,8 +186,8 @@ function requireNative() {
|
|
|
186
186
|
try {
|
|
187
187
|
const binding = require('@oxc-parser/binding-darwin-universal')
|
|
188
188
|
const bindingPackageVersion = require('@oxc-parser/binding-darwin-universal/package.json').version
|
|
189
|
-
if (bindingPackageVersion !== '0.
|
|
190
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
189
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
190
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
191
191
|
}
|
|
192
192
|
return binding
|
|
193
193
|
} catch (e) {
|
|
@@ -202,8 +202,8 @@ function requireNative() {
|
|
|
202
202
|
try {
|
|
203
203
|
const binding = require('@oxc-parser/binding-darwin-x64')
|
|
204
204
|
const bindingPackageVersion = require('@oxc-parser/binding-darwin-x64/package.json').version
|
|
205
|
-
if (bindingPackageVersion !== '0.
|
|
206
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
205
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
206
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
207
207
|
}
|
|
208
208
|
return binding
|
|
209
209
|
} catch (e) {
|
|
@@ -218,8 +218,8 @@ function requireNative() {
|
|
|
218
218
|
try {
|
|
219
219
|
const binding = require('@oxc-parser/binding-darwin-arm64')
|
|
220
220
|
const bindingPackageVersion = require('@oxc-parser/binding-darwin-arm64/package.json').version
|
|
221
|
-
if (bindingPackageVersion !== '0.
|
|
222
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
221
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
222
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
223
223
|
}
|
|
224
224
|
return binding
|
|
225
225
|
} catch (e) {
|
|
@@ -238,8 +238,8 @@ function requireNative() {
|
|
|
238
238
|
try {
|
|
239
239
|
const binding = require('@oxc-parser/binding-freebsd-x64')
|
|
240
240
|
const bindingPackageVersion = require('@oxc-parser/binding-freebsd-x64/package.json').version
|
|
241
|
-
if (bindingPackageVersion !== '0.
|
|
242
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
241
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
242
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
243
243
|
}
|
|
244
244
|
return binding
|
|
245
245
|
} catch (e) {
|
|
@@ -254,8 +254,8 @@ function requireNative() {
|
|
|
254
254
|
try {
|
|
255
255
|
const binding = require('@oxc-parser/binding-freebsd-arm64')
|
|
256
256
|
const bindingPackageVersion = require('@oxc-parser/binding-freebsd-arm64/package.json').version
|
|
257
|
-
if (bindingPackageVersion !== '0.
|
|
258
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
257
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
258
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
259
259
|
}
|
|
260
260
|
return binding
|
|
261
261
|
} catch (e) {
|
|
@@ -275,8 +275,8 @@ function requireNative() {
|
|
|
275
275
|
try {
|
|
276
276
|
const binding = require('@oxc-parser/binding-linux-x64-musl')
|
|
277
277
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-x64-musl/package.json').version
|
|
278
|
-
if (bindingPackageVersion !== '0.
|
|
279
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
278
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
279
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
280
280
|
}
|
|
281
281
|
return binding
|
|
282
282
|
} catch (e) {
|
|
@@ -291,8 +291,8 @@ function requireNative() {
|
|
|
291
291
|
try {
|
|
292
292
|
const binding = require('@oxc-parser/binding-linux-x64-gnu')
|
|
293
293
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-x64-gnu/package.json').version
|
|
294
|
-
if (bindingPackageVersion !== '0.
|
|
295
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
294
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
295
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
296
296
|
}
|
|
297
297
|
return binding
|
|
298
298
|
} catch (e) {
|
|
@@ -309,8 +309,8 @@ function requireNative() {
|
|
|
309
309
|
try {
|
|
310
310
|
const binding = require('@oxc-parser/binding-linux-arm64-musl')
|
|
311
311
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm64-musl/package.json').version
|
|
312
|
-
if (bindingPackageVersion !== '0.
|
|
313
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
312
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
313
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
314
314
|
}
|
|
315
315
|
return binding
|
|
316
316
|
} catch (e) {
|
|
@@ -325,8 +325,8 @@ function requireNative() {
|
|
|
325
325
|
try {
|
|
326
326
|
const binding = require('@oxc-parser/binding-linux-arm64-gnu')
|
|
327
327
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm64-gnu/package.json').version
|
|
328
|
-
if (bindingPackageVersion !== '0.
|
|
329
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
328
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
329
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
330
330
|
}
|
|
331
331
|
return binding
|
|
332
332
|
} catch (e) {
|
|
@@ -343,8 +343,8 @@ function requireNative() {
|
|
|
343
343
|
try {
|
|
344
344
|
const binding = require('@oxc-parser/binding-linux-arm-musleabihf')
|
|
345
345
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm-musleabihf/package.json').version
|
|
346
|
-
if (bindingPackageVersion !== '0.
|
|
347
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
346
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
347
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
348
348
|
}
|
|
349
349
|
return binding
|
|
350
350
|
} catch (e) {
|
|
@@ -359,8 +359,8 @@ function requireNative() {
|
|
|
359
359
|
try {
|
|
360
360
|
const binding = require('@oxc-parser/binding-linux-arm-gnueabihf')
|
|
361
361
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-arm-gnueabihf/package.json').version
|
|
362
|
-
if (bindingPackageVersion !== '0.
|
|
363
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
362
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
363
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
364
364
|
}
|
|
365
365
|
return binding
|
|
366
366
|
} catch (e) {
|
|
@@ -377,8 +377,8 @@ function requireNative() {
|
|
|
377
377
|
try {
|
|
378
378
|
const binding = require('@oxc-parser/binding-linux-loong64-musl')
|
|
379
379
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-loong64-musl/package.json').version
|
|
380
|
-
if (bindingPackageVersion !== '0.
|
|
381
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
380
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
381
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
382
382
|
}
|
|
383
383
|
return binding
|
|
384
384
|
} catch (e) {
|
|
@@ -393,8 +393,8 @@ function requireNative() {
|
|
|
393
393
|
try {
|
|
394
394
|
const binding = require('@oxc-parser/binding-linux-loong64-gnu')
|
|
395
395
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-loong64-gnu/package.json').version
|
|
396
|
-
if (bindingPackageVersion !== '0.
|
|
397
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
396
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
397
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
398
398
|
}
|
|
399
399
|
return binding
|
|
400
400
|
} catch (e) {
|
|
@@ -411,8 +411,8 @@ function requireNative() {
|
|
|
411
411
|
try {
|
|
412
412
|
const binding = require('@oxc-parser/binding-linux-riscv64-musl')
|
|
413
413
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-riscv64-musl/package.json').version
|
|
414
|
-
if (bindingPackageVersion !== '0.
|
|
415
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
414
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
415
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
416
416
|
}
|
|
417
417
|
return binding
|
|
418
418
|
} catch (e) {
|
|
@@ -427,8 +427,8 @@ function requireNative() {
|
|
|
427
427
|
try {
|
|
428
428
|
const binding = require('@oxc-parser/binding-linux-riscv64-gnu')
|
|
429
429
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-riscv64-gnu/package.json').version
|
|
430
|
-
if (bindingPackageVersion !== '0.
|
|
431
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
430
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
431
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
432
432
|
}
|
|
433
433
|
return binding
|
|
434
434
|
} catch (e) {
|
|
@@ -444,8 +444,8 @@ function requireNative() {
|
|
|
444
444
|
try {
|
|
445
445
|
const binding = require('@oxc-parser/binding-linux-ppc64-gnu')
|
|
446
446
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-ppc64-gnu/package.json').version
|
|
447
|
-
if (bindingPackageVersion !== '0.
|
|
448
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
447
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
448
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
449
449
|
}
|
|
450
450
|
return binding
|
|
451
451
|
} catch (e) {
|
|
@@ -460,8 +460,8 @@ function requireNative() {
|
|
|
460
460
|
try {
|
|
461
461
|
const binding = require('@oxc-parser/binding-linux-s390x-gnu')
|
|
462
462
|
const bindingPackageVersion = require('@oxc-parser/binding-linux-s390x-gnu/package.json').version
|
|
463
|
-
if (bindingPackageVersion !== '0.
|
|
464
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
463
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
464
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
465
465
|
}
|
|
466
466
|
return binding
|
|
467
467
|
} catch (e) {
|
|
@@ -480,8 +480,8 @@ function requireNative() {
|
|
|
480
480
|
try {
|
|
481
481
|
const binding = require('@oxc-parser/binding-openharmony-arm64')
|
|
482
482
|
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-arm64/package.json').version
|
|
483
|
-
if (bindingPackageVersion !== '0.
|
|
484
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
483
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
484
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
485
485
|
}
|
|
486
486
|
return binding
|
|
487
487
|
} catch (e) {
|
|
@@ -496,8 +496,8 @@ function requireNative() {
|
|
|
496
496
|
try {
|
|
497
497
|
const binding = require('@oxc-parser/binding-openharmony-x64')
|
|
498
498
|
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-x64/package.json').version
|
|
499
|
-
if (bindingPackageVersion !== '0.
|
|
500
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
499
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
500
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
501
501
|
}
|
|
502
502
|
return binding
|
|
503
503
|
} catch (e) {
|
|
@@ -512,8 +512,8 @@ function requireNative() {
|
|
|
512
512
|
try {
|
|
513
513
|
const binding = require('@oxc-parser/binding-openharmony-arm')
|
|
514
514
|
const bindingPackageVersion = require('@oxc-parser/binding-openharmony-arm/package.json').version
|
|
515
|
-
if (bindingPackageVersion !== '0.
|
|
516
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
515
|
+
if (bindingPackageVersion !== '0.132.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
516
|
+
throw new Error(`Native binding package version mismatch, expected 0.132.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
517
517
|
}
|
|
518
518
|
return binding
|
|
519
519
|
} catch (e) {
|
|
@@ -6,7 +6,7 @@ let uint8,
|
|
|
6
6
|
float64,
|
|
7
7
|
sourceText,
|
|
8
8
|
sourceTextLatin,
|
|
9
|
-
|
|
9
|
+
sourceStartPos = 0,
|
|
10
10
|
firstNonAsciiPos = 0;
|
|
11
11
|
|
|
12
12
|
const { fromCharCode } = String,
|
|
@@ -14,24 +14,35 @@ const { fromCharCode } = String,
|
|
|
14
14
|
stringDecodeArrays = Array(65).fill(null);
|
|
15
15
|
for (let i = 0; i <= 64; i++) stringDecodeArrays[i] = Array(i).fill(0);
|
|
16
16
|
|
|
17
|
-
export function deserialize(buffer, sourceText, sourceByteLen) {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export function deserialize(buffer, sourceText, sourceStartPos, sourceByteLen) {
|
|
18
|
+
return deserializeWith(
|
|
19
|
+
buffer,
|
|
20
|
+
sourceText,
|
|
21
|
+
sourceStartPos,
|
|
22
|
+
sourceByteLen,
|
|
23
|
+
deserializeRawTransferData,
|
|
24
|
+
);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
function deserializeWith(buffer, sourceTextInput, sourceByteLen, deserialize) {
|
|
27
|
+
function deserializeWith(buffer, sourceTextInput, sourceStartPosInput, sourceByteLen, deserialize) {
|
|
23
28
|
uint8 = buffer;
|
|
24
29
|
int32 = buffer.int32;
|
|
25
30
|
float64 = buffer.float64;
|
|
26
31
|
sourceText = sourceTextInput;
|
|
32
|
+
sourceStartPos = sourceStartPosInput;
|
|
33
|
+
// Find first non-ASCII byte in source region.
|
|
34
|
+
// `sourceText.substr()` can be used for strings which are within source text and ending before
|
|
35
|
+
// this position, since byte offsets equal char offsets in the all-ASCII prefix.
|
|
36
|
+
// Also decode source text as Latin-1 (or reuse `sourceText` if it's all ASCII).
|
|
27
37
|
if (sourceText.length === sourceByteLen) {
|
|
28
|
-
firstNonAsciiPos = sourceByteLen;
|
|
38
|
+
firstNonAsciiPos = sourceStartPos + sourceByteLen;
|
|
29
39
|
sourceTextLatin = sourceText;
|
|
30
40
|
} else {
|
|
31
|
-
let i =
|
|
32
|
-
|
|
41
|
+
let i = sourceStartPos,
|
|
42
|
+
sourceEndPos = sourceStartPos + sourceByteLen;
|
|
43
|
+
for (; i < sourceEndPos && uint8[i] < 128; i++);
|
|
33
44
|
firstNonAsciiPos = i;
|
|
34
|
-
sourceTextLatin = latin1Slice.call(uint8,
|
|
45
|
+
sourceTextLatin = latin1Slice.call(uint8, sourceStartPos, sourceEndPos);
|
|
35
46
|
}
|
|
36
47
|
let data = deserialize(int32[536870890]);
|
|
37
48
|
resetBuffer();
|
|
@@ -4520,15 +4531,18 @@ function deserializeStr(pos) {
|
|
|
4520
4531
|
len = int32[pos32 + 2];
|
|
4521
4532
|
if (len === 0) return "";
|
|
4522
4533
|
pos = int32[pos32];
|
|
4523
|
-
let end = pos + len
|
|
4524
|
-
|
|
4534
|
+
let end = pos + len,
|
|
4535
|
+
isInSourceRegion = pos >= sourceStartPos;
|
|
4536
|
+
if (isInSourceRegion && end <= firstNonAsciiPos)
|
|
4537
|
+
return sourceTextLatin.substr(pos - sourceStartPos, len);
|
|
4525
4538
|
// Use `utf8Slice` for strings longer than 64 bytes
|
|
4526
4539
|
if (len > 64) return utf8Slice.call(uint8, pos, end);
|
|
4527
|
-
|
|
4540
|
+
// If string is in source region, use slice of `sourceTextLatin` if all ASCII
|
|
4541
|
+
if (isInSourceRegion) {
|
|
4528
4542
|
// Check if all bytes are ASCII, use `utf8Slice` if not
|
|
4529
4543
|
for (let i = pos; i < end; i++) if (uint8[i] >= 128) return utf8Slice.call(uint8, pos, end);
|
|
4530
4544
|
// String is all ASCII, so slice from `sourceTextLatin`
|
|
4531
|
-
return sourceTextLatin.substr(pos, len);
|
|
4545
|
+
return sourceTextLatin.substr(pos - sourceStartPos, len);
|
|
4532
4546
|
}
|
|
4533
4547
|
// String is not in source region - use `fromCharCode.apply` with a temp array of correct length.
|
|
4534
4548
|
// Copy bytes into temp array.
|
|
@@ -6,7 +6,7 @@ let uint8,
|
|
|
6
6
|
float64,
|
|
7
7
|
sourceText,
|
|
8
8
|
sourceTextLatin,
|
|
9
|
-
|
|
9
|
+
sourceStartPos = 0,
|
|
10
10
|
firstNonAsciiPos = 0;
|
|
11
11
|
|
|
12
12
|
const { fromCharCode } = String,
|
|
@@ -14,24 +14,35 @@ const { fromCharCode } = String,
|
|
|
14
14
|
stringDecodeArrays = Array(65).fill(null);
|
|
15
15
|
for (let i = 0; i <= 64; i++) stringDecodeArrays[i] = Array(i).fill(0);
|
|
16
16
|
|
|
17
|
-
export function deserialize(buffer, sourceText, sourceByteLen) {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export function deserialize(buffer, sourceText, sourceStartPos, sourceByteLen) {
|
|
18
|
+
return deserializeWith(
|
|
19
|
+
buffer,
|
|
20
|
+
sourceText,
|
|
21
|
+
sourceStartPos,
|
|
22
|
+
sourceByteLen,
|
|
23
|
+
deserializeRawTransferData,
|
|
24
|
+
);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
function deserializeWith(buffer, sourceTextInput, sourceByteLen, deserialize) {
|
|
27
|
+
function deserializeWith(buffer, sourceTextInput, sourceStartPosInput, sourceByteLen, deserialize) {
|
|
23
28
|
uint8 = buffer;
|
|
24
29
|
int32 = buffer.int32;
|
|
25
30
|
float64 = buffer.float64;
|
|
26
31
|
sourceText = sourceTextInput;
|
|
32
|
+
sourceStartPos = sourceStartPosInput;
|
|
33
|
+
// Find first non-ASCII byte in source region.
|
|
34
|
+
// `sourceText.substr()` can be used for strings which are within source text and ending before
|
|
35
|
+
// this position, since byte offsets equal char offsets in the all-ASCII prefix.
|
|
36
|
+
// Also decode source text as Latin-1 (or reuse `sourceText` if it's all ASCII).
|
|
27
37
|
if (sourceText.length === sourceByteLen) {
|
|
28
|
-
firstNonAsciiPos = sourceByteLen;
|
|
38
|
+
firstNonAsciiPos = sourceStartPos + sourceByteLen;
|
|
29
39
|
sourceTextLatin = sourceText;
|
|
30
40
|
} else {
|
|
31
|
-
let i =
|
|
32
|
-
|
|
41
|
+
let i = sourceStartPos,
|
|
42
|
+
sourceEndPos = sourceStartPos + sourceByteLen;
|
|
43
|
+
for (; i < sourceEndPos && uint8[i] < 128; i++);
|
|
33
44
|
firstNonAsciiPos = i;
|
|
34
|
-
sourceTextLatin = latin1Slice.call(uint8,
|
|
45
|
+
sourceTextLatin = latin1Slice.call(uint8, sourceStartPos, sourceEndPos);
|
|
35
46
|
}
|
|
36
47
|
let data = deserialize(int32[536870890]);
|
|
37
48
|
resetBuffer();
|
|
@@ -5061,15 +5072,18 @@ function deserializeStr(pos) {
|
|
|
5061
5072
|
len = int32[pos32 + 2];
|
|
5062
5073
|
if (len === 0) return "";
|
|
5063
5074
|
pos = int32[pos32];
|
|
5064
|
-
let end = pos + len
|
|
5065
|
-
|
|
5075
|
+
let end = pos + len,
|
|
5076
|
+
isInSourceRegion = pos >= sourceStartPos;
|
|
5077
|
+
if (isInSourceRegion && end <= firstNonAsciiPos)
|
|
5078
|
+
return sourceTextLatin.substr(pos - sourceStartPos, len);
|
|
5066
5079
|
// Use `utf8Slice` for strings longer than 64 bytes
|
|
5067
5080
|
if (len > 64) return utf8Slice.call(uint8, pos, end);
|
|
5068
|
-
|
|
5081
|
+
// If string is in source region, use slice of `sourceTextLatin` if all ASCII
|
|
5082
|
+
if (isInSourceRegion) {
|
|
5069
5083
|
// Check if all bytes are ASCII, use `utf8Slice` if not
|
|
5070
5084
|
for (let i = pos; i < end; i++) if (uint8[i] >= 128) return utf8Slice.call(uint8, pos, end);
|
|
5071
5085
|
// String is all ASCII, so slice from `sourceTextLatin`
|
|
5072
|
-
return sourceTextLatin.substr(pos, len);
|
|
5086
|
+
return sourceTextLatin.substr(pos - sourceStartPos, len);
|
|
5073
5087
|
}
|
|
5074
5088
|
// String is not in source region - use `fromCharCode.apply` with a temp array of correct length.
|
|
5075
5089
|
// Copy bytes into temp array.
|
|
@@ -6,7 +6,7 @@ let uint8,
|
|
|
6
6
|
float64,
|
|
7
7
|
sourceText,
|
|
8
8
|
sourceTextLatin,
|
|
9
|
-
|
|
9
|
+
sourceStartPos = 0,
|
|
10
10
|
firstNonAsciiPos = 0;
|
|
11
11
|
|
|
12
12
|
const { fromCharCode } = String,
|
|
@@ -14,24 +14,35 @@ const { fromCharCode } = String,
|
|
|
14
14
|
stringDecodeArrays = Array(65).fill(null);
|
|
15
15
|
for (let i = 0; i <= 64; i++) stringDecodeArrays[i] = Array(i).fill(0);
|
|
16
16
|
|
|
17
|
-
export function deserialize(buffer, sourceText, sourceByteLen) {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export function deserialize(buffer, sourceText, sourceStartPos, sourceByteLen) {
|
|
18
|
+
return deserializeWith(
|
|
19
|
+
buffer,
|
|
20
|
+
sourceText,
|
|
21
|
+
sourceStartPos,
|
|
22
|
+
sourceByteLen,
|
|
23
|
+
deserializeRawTransferData,
|
|
24
|
+
);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
function deserializeWith(buffer, sourceTextInput, sourceByteLen, deserialize) {
|
|
27
|
+
function deserializeWith(buffer, sourceTextInput, sourceStartPosInput, sourceByteLen, deserialize) {
|
|
23
28
|
uint8 = buffer;
|
|
24
29
|
int32 = buffer.int32;
|
|
25
30
|
float64 = buffer.float64;
|
|
26
31
|
sourceText = sourceTextInput;
|
|
32
|
+
sourceStartPos = sourceStartPosInput;
|
|
33
|
+
// Find first non-ASCII byte in source region.
|
|
34
|
+
// `sourceText.substr()` can be used for strings which are within source text and ending before
|
|
35
|
+
// this position, since byte offsets equal char offsets in the all-ASCII prefix.
|
|
36
|
+
// Also decode source text as Latin-1 (or reuse `sourceText` if it's all ASCII).
|
|
27
37
|
if (sourceText.length === sourceByteLen) {
|
|
28
|
-
firstNonAsciiPos = sourceByteLen;
|
|
38
|
+
firstNonAsciiPos = sourceStartPos + sourceByteLen;
|
|
29
39
|
sourceTextLatin = sourceText;
|
|
30
40
|
} else {
|
|
31
|
-
let i =
|
|
32
|
-
|
|
41
|
+
let i = sourceStartPos,
|
|
42
|
+
sourceEndPos = sourceStartPos + sourceByteLen;
|
|
43
|
+
for (; i < sourceEndPos && uint8[i] < 128; i++);
|
|
33
44
|
firstNonAsciiPos = i;
|
|
34
|
-
sourceTextLatin = latin1Slice.call(uint8,
|
|
45
|
+
sourceTextLatin = latin1Slice.call(uint8, sourceStartPos, sourceEndPos);
|
|
35
46
|
}
|
|
36
47
|
let data = deserialize(int32[536870890]);
|
|
37
48
|
resetBuffer();
|
|
@@ -4796,15 +4807,18 @@ function deserializeStr(pos) {
|
|
|
4796
4807
|
len = int32[pos32 + 2];
|
|
4797
4808
|
if (len === 0) return "";
|
|
4798
4809
|
pos = int32[pos32];
|
|
4799
|
-
let end = pos + len
|
|
4800
|
-
|
|
4810
|
+
let end = pos + len,
|
|
4811
|
+
isInSourceRegion = pos >= sourceStartPos;
|
|
4812
|
+
if (isInSourceRegion && end <= firstNonAsciiPos)
|
|
4813
|
+
return sourceTextLatin.substr(pos - sourceStartPos, len);
|
|
4801
4814
|
// Use `utf8Slice` for strings longer than 64 bytes
|
|
4802
4815
|
if (len > 64) return utf8Slice.call(uint8, pos, end);
|
|
4803
|
-
|
|
4816
|
+
// If string is in source region, use slice of `sourceTextLatin` if all ASCII
|
|
4817
|
+
if (isInSourceRegion) {
|
|
4804
4818
|
// Check if all bytes are ASCII, use `utf8Slice` if not
|
|
4805
4819
|
for (let i = pos; i < end; i++) if (uint8[i] >= 128) return utf8Slice.call(uint8, pos, end);
|
|
4806
4820
|
// String is all ASCII, so slice from `sourceTextLatin`
|
|
4807
|
-
return sourceTextLatin.substr(pos, len);
|
|
4821
|
+
return sourceTextLatin.substr(pos - sourceStartPos, len);
|
|
4808
4822
|
}
|
|
4809
4823
|
// String is not in source region - use `fromCharCode.apply` with a temp array of correct length.
|
|
4810
4824
|
// Copy bytes into temp array.
|
|
@@ -6,7 +6,7 @@ let uint8,
|
|
|
6
6
|
float64,
|
|
7
7
|
sourceText,
|
|
8
8
|
sourceTextLatin,
|
|
9
|
-
|
|
9
|
+
sourceStartPos = 0,
|
|
10
10
|
firstNonAsciiPos = 0;
|
|
11
11
|
|
|
12
12
|
const { fromCharCode } = String,
|
|
@@ -14,24 +14,35 @@ const { fromCharCode } = String,
|
|
|
14
14
|
stringDecodeArrays = Array(65).fill(null);
|
|
15
15
|
for (let i = 0; i <= 64; i++) stringDecodeArrays[i] = Array(i).fill(0);
|
|
16
16
|
|
|
17
|
-
export function deserialize(buffer, sourceText, sourceByteLen) {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export function deserialize(buffer, sourceText, sourceStartPos, sourceByteLen) {
|
|
18
|
+
return deserializeWith(
|
|
19
|
+
buffer,
|
|
20
|
+
sourceText,
|
|
21
|
+
sourceStartPos,
|
|
22
|
+
sourceByteLen,
|
|
23
|
+
deserializeRawTransferData,
|
|
24
|
+
);
|
|
20
25
|
}
|
|
21
26
|
|
|
22
|
-
function deserializeWith(buffer, sourceTextInput, sourceByteLen, deserialize) {
|
|
27
|
+
function deserializeWith(buffer, sourceTextInput, sourceStartPosInput, sourceByteLen, deserialize) {
|
|
23
28
|
uint8 = buffer;
|
|
24
29
|
int32 = buffer.int32;
|
|
25
30
|
float64 = buffer.float64;
|
|
26
31
|
sourceText = sourceTextInput;
|
|
32
|
+
sourceStartPos = sourceStartPosInput;
|
|
33
|
+
// Find first non-ASCII byte in source region.
|
|
34
|
+
// `sourceText.substr()` can be used for strings which are within source text and ending before
|
|
35
|
+
// this position, since byte offsets equal char offsets in the all-ASCII prefix.
|
|
36
|
+
// Also decode source text as Latin-1 (or reuse `sourceText` if it's all ASCII).
|
|
27
37
|
if (sourceText.length === sourceByteLen) {
|
|
28
|
-
firstNonAsciiPos = sourceByteLen;
|
|
38
|
+
firstNonAsciiPos = sourceStartPos + sourceByteLen;
|
|
29
39
|
sourceTextLatin = sourceText;
|
|
30
40
|
} else {
|
|
31
|
-
let i =
|
|
32
|
-
|
|
41
|
+
let i = sourceStartPos,
|
|
42
|
+
sourceEndPos = sourceStartPos + sourceByteLen;
|
|
43
|
+
for (; i < sourceEndPos && uint8[i] < 128; i++);
|
|
33
44
|
firstNonAsciiPos = i;
|
|
34
|
-
sourceTextLatin = latin1Slice.call(uint8,
|
|
45
|
+
sourceTextLatin = latin1Slice.call(uint8, sourceStartPos, sourceEndPos);
|
|
35
46
|
}
|
|
36
47
|
let data = deserialize(int32[536870890]);
|
|
37
48
|
resetBuffer();
|
|
@@ -5365,15 +5376,18 @@ function deserializeStr(pos) {
|
|
|
5365
5376
|
len = int32[pos32 + 2];
|
|
5366
5377
|
if (len === 0) return "";
|
|
5367
5378
|
pos = int32[pos32];
|
|
5368
|
-
let end = pos + len
|
|
5369
|
-
|
|
5379
|
+
let end = pos + len,
|
|
5380
|
+
isInSourceRegion = pos >= sourceStartPos;
|
|
5381
|
+
if (isInSourceRegion && end <= firstNonAsciiPos)
|
|
5382
|
+
return sourceTextLatin.substr(pos - sourceStartPos, len);
|
|
5370
5383
|
// Use `utf8Slice` for strings longer than 64 bytes
|
|
5371
5384
|
if (len > 64) return utf8Slice.call(uint8, pos, end);
|
|
5372
|
-
|
|
5385
|
+
// If string is in source region, use slice of `sourceTextLatin` if all ASCII
|
|
5386
|
+
if (isInSourceRegion) {
|
|
5373
5387
|
// Check if all bytes are ASCII, use `utf8Slice` if not
|
|
5374
5388
|
for (let i = pos; i < end; i++) if (uint8[i] >= 128) return utf8Slice.call(uint8, pos, end);
|
|
5375
5389
|
// String is all ASCII, so slice from `sourceTextLatin`
|
|
5376
|
-
return sourceTextLatin.substr(pos, len);
|
|
5390
|
+
return sourceTextLatin.substr(pos - sourceStartPos, len);
|
|
5377
5391
|
}
|
|
5378
5392
|
// String is not in source region - use `fromCharCode.apply` with a temp array of correct length.
|
|
5379
5393
|
// Copy bytes into temp array.
|
|
@@ -12638,7 +12638,10 @@ function constructStr(pos, ast) {
|
|
|
12638
12638
|
if (len === 0) return "";
|
|
12639
12639
|
|
|
12640
12640
|
pos = int32[pos32];
|
|
12641
|
-
if (ast.sourceIsAscii
|
|
12641
|
+
if (ast.sourceIsAscii) {
|
|
12642
|
+
const { sourceStartPos } = ast;
|
|
12643
|
+
if (pos >= sourceStartPos) return ast.sourceText.substr(pos - sourceStartPos, len);
|
|
12644
|
+
}
|
|
12642
12645
|
|
|
12643
12646
|
// Longer strings use `TextDecoder`
|
|
12644
12647
|
// TODO: Find best switch-over point
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BLOCK_SIZE,
|
|
4
|
+
BLOCK_ALIGN,
|
|
5
|
+
BUFFER_SIZE,
|
|
6
|
+
ACTIVE_SIZE,
|
|
7
|
+
IS_TS_FLAG_POS,
|
|
8
|
+
} from "../generated/constants.js";
|
|
3
9
|
import {
|
|
4
10
|
getBufferOffset,
|
|
5
11
|
parseRaw as parseRawBinding,
|
|
@@ -33,9 +39,9 @@ if (!rawTransferSupported()) {
|
|
|
33
39
|
* @returns {Object} - The return value of `convert`
|
|
34
40
|
*/
|
|
35
41
|
export function parseSyncRawImpl(filename, sourceText, options, convert) {
|
|
36
|
-
const { buffer, sourceByteLen } = prepareRaw(sourceText);
|
|
37
|
-
parseRawSyncBinding(filename, buffer.block, sourceByteLen, options);
|
|
38
|
-
return convert(buffer, sourceText, sourceByteLen, options);
|
|
42
|
+
const { buffer, sourceStartPos, sourceByteLen } = prepareRaw(sourceText);
|
|
43
|
+
parseRawSyncBinding(filename, buffer.block, sourceStartPos, sourceByteLen, options);
|
|
44
|
+
return convert(buffer, sourceText, sourceStartPos, sourceByteLen, options);
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
// User should not schedule more async tasks than there are available CPUs, as it hurts performance,
|
|
@@ -113,9 +119,9 @@ export async function parseAsyncRawImpl(filename, sourceText, options, convert)
|
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
// Parse
|
|
116
|
-
const { buffer, sourceByteLen } = prepareRaw(sourceText);
|
|
117
|
-
await parseRawBinding(filename, buffer.block, sourceByteLen, options);
|
|
118
|
-
const data = convert(buffer, sourceText, sourceByteLen, options);
|
|
122
|
+
const { buffer, sourceStartPos, sourceByteLen } = prepareRaw(sourceText);
|
|
123
|
+
await parseRawBinding(filename, buffer.block, sourceStartPos, sourceByteLen, options);
|
|
124
|
+
const data = convert(buffer, sourceText, sourceStartPos, sourceByteLen, options);
|
|
119
125
|
|
|
120
126
|
// Free the CPU core
|
|
121
127
|
if (queue.length > 0) {
|
|
@@ -174,8 +180,9 @@ const textEncoder = new TextEncoder();
|
|
|
174
180
|
* Get a buffer (from cache if possible), and copy source text into it.
|
|
175
181
|
*
|
|
176
182
|
* @param {string} sourceText - Source text of file
|
|
177
|
-
* @returns {Object} - Object of form `{ buffer, sourceByteLen }`.
|
|
183
|
+
* @returns {Object} - Object of form `{ buffer, sourceStartPos, sourceByteLen }`.
|
|
178
184
|
* - `buffer`: `Uint8Array` containing the AST in raw form.
|
|
185
|
+
* - `sourceStartPos`: Position of first byte of source text in buffer
|
|
179
186
|
* - `sourceByteLen`: Length of source text in UTF-8 bytes
|
|
180
187
|
* (which may not be equal to `sourceText.length` if source contains non-ASCII characters).
|
|
181
188
|
*/
|
|
@@ -200,14 +207,25 @@ export function prepareRaw(sourceText) {
|
|
|
200
207
|
// Reuse existing buffer, or create a new one
|
|
201
208
|
const buffer = buffers.length > 0 ? buffers.pop() : createBuffer();
|
|
202
209
|
|
|
203
|
-
// Write source into
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
|
|
210
|
+
// Write source into end of buffer.
|
|
211
|
+
// Maximum size of a string encoded in UTF-8 is 3 x the length of the string in UTF-16 characters
|
|
212
|
+
// (a source which consists entirely of 3-byte UTF-8 characters).
|
|
213
|
+
// We can't predict how many bytes will be needed exactly in advance of encoding, so we reserve
|
|
214
|
+
// the maximum theoretically possible number of bytes required.
|
|
215
|
+
// `TextEncoder` cannot write into a `Uint8Array` larger than 1 GiB, so size is capped at 1 GiB.
|
|
216
|
+
const maxSourceByteLen = sourceText.length * 3;
|
|
217
|
+
if (maxSourceByteLen > ONE_GIB) throw new Error("Source text is too long");
|
|
218
|
+
const sourceStartPos = ACTIVE_SIZE - maxSourceByteLen;
|
|
219
|
+
|
|
220
|
+
const sourceBuffer = new Uint8Array(
|
|
221
|
+
buffer.buffer,
|
|
222
|
+
buffer.byteOffset + sourceStartPos,
|
|
223
|
+
maxSourceByteLen,
|
|
224
|
+
);
|
|
207
225
|
const { read, written: sourceByteLen } = textEncoder.encodeInto(sourceText, sourceBuffer);
|
|
208
226
|
if (read !== sourceText.length) throw new Error("Failed to write source text into buffer");
|
|
209
227
|
|
|
210
|
-
return { buffer, sourceByteLen };
|
|
228
|
+
return { buffer, sourceStartPos, sourceByteLen };
|
|
211
229
|
}
|
|
212
230
|
|
|
213
231
|
/**
|
|
@@ -58,11 +58,12 @@ const deserializerNames = [
|
|
|
58
58
|
*
|
|
59
59
|
* @param {Uint8Array} buffer - Buffer containing AST in raw form
|
|
60
60
|
* @param {string} sourceText - Source for the file
|
|
61
|
+
* @param {number} sourceStartPos - Position of first byte of source text in buffer
|
|
61
62
|
* @param {number} sourceByteLen - Length of source text in UTF-8 bytes
|
|
62
63
|
* @param {Object} options - Parsing options
|
|
63
64
|
* @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`
|
|
64
65
|
*/
|
|
65
|
-
function deserialize(buffer, sourceText, sourceByteLen, options) {
|
|
66
|
+
function deserialize(buffer, sourceText, sourceStartPos, sourceByteLen, options) {
|
|
66
67
|
const isJs = isJsAst(buffer),
|
|
67
68
|
range = !!options.range,
|
|
68
69
|
parent = !!options.experimentalParent;
|
|
@@ -76,7 +77,7 @@ function deserialize(buffer, sourceText, sourceByteLen, options) {
|
|
|
76
77
|
).deserialize;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
const data = deserializeThis(buffer, sourceText, sourceByteLen);
|
|
80
|
+
const data = deserializeThis(buffer, sourceText, sourceStartPos, sourceByteLen);
|
|
80
81
|
|
|
81
82
|
// Add a line comment for hashbang if JS.
|
|
82
83
|
// Do not add comment if TS, to match `@typescript-eslint/parser`.
|
|
@@ -83,15 +83,24 @@ const bufferRecycleRegistry =
|
|
|
83
83
|
*
|
|
84
84
|
* @param {Uint8Array} buffer - Buffer containing AST in raw form
|
|
85
85
|
* @param {string} sourceText - Source for the file
|
|
86
|
+
* @param {number} sourceStartPos - Position of first byte of source text in buffer
|
|
86
87
|
* @param {number} sourceByteLen - Length of source text in UTF-8 bytes
|
|
87
88
|
* @param {Object} _options - Parsing options
|
|
88
89
|
* @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`,
|
|
89
90
|
* and `dispose` and `visit` methods
|
|
90
91
|
*/
|
|
91
|
-
function construct(buffer, sourceText, sourceByteLen, _options) {
|
|
92
|
+
function construct(buffer, sourceText, sourceStartPos, sourceByteLen, _options) {
|
|
92
93
|
// Create AST object
|
|
93
94
|
const sourceIsAscii = sourceText.length === sourceByteLen;
|
|
94
|
-
const ast = {
|
|
95
|
+
const ast = {
|
|
96
|
+
buffer,
|
|
97
|
+
sourceText,
|
|
98
|
+
sourceStartPos,
|
|
99
|
+
sourceByteLen,
|
|
100
|
+
sourceIsAscii,
|
|
101
|
+
nodes: new Map(),
|
|
102
|
+
token: TOKEN,
|
|
103
|
+
};
|
|
95
104
|
|
|
96
105
|
// Register `ast` with the recycle registry so buffer is returned to cache
|
|
97
106
|
// when `ast` is garbage collected
|