oxc-parser 0.2.0 → 0.3.0-alpha.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/README.md CHANGED
@@ -11,7 +11,8 @@ const oxc = require("oxc-parser");
11
11
  const assert = require('assert');
12
12
 
13
13
  function test(ret) {
14
- assert(ret.program.body.length == 1);
14
+ const program = JSON.parse(ret.program);
15
+ assert(program.body.length == 1);
15
16
  assert(ret.errors.length == 0);
16
17
  }
17
18
 
@@ -31,7 +32,8 @@ import oxc from 'oxc-parser';
31
32
  import assert from 'assert';
32
33
 
33
34
  function test(ret) {
34
- assert(ret.program.body.length == 1);
35
+ const program = JSON.parse(ret.program);
36
+ assert(program.body.length == 1);
35
37
  assert(ret.errors.length == 0);
36
38
  }
37
39
 
package/index.d.ts CHANGED
@@ -33,6 +33,15 @@ export function parseWithoutReturn(sourceText: string, options?: ParserOptions |
33
33
  * * Serde JSON serialization
34
34
  */
35
35
  export function parseSync(sourceText: string, options?: ParserOptions | undefined | null): ParseResult
36
+ /**
37
+ * Returns a binary AST in flexbuffers format.
38
+ * This is a POC API. Error handling is not done yet.
39
+ * # Panics
40
+ *
41
+ * * File extension is invalid
42
+ * * FlexbufferSerializer serialization error
43
+ */
44
+ export function parseSyncBuffer(sourceText: string, options?: ParserOptions | undefined | null): Buffer
36
45
  /**
37
46
  * # Panics
38
47
  *
package/index.js CHANGED
@@ -17,7 +17,7 @@ function isMusl() {
17
17
  // For Node 10
18
18
  if (!process.report || typeof process.report.getReport !== 'function') {
19
19
  try {
20
- const lddPath = require('child_process').execSync('which ldd').toString().trim();
20
+ const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
21
  return readFileSync(lddPath, 'utf8').includes('musl')
22
22
  } catch (e) {
23
23
  return true
@@ -237,6 +237,49 @@ switch (platform) {
237
237
  loadError = e
238
238
  }
239
239
  break
240
+ case 'riscv64':
241
+ if (isMusl()) {
242
+ localFileExisted = existsSync(
243
+ join(__dirname, 'parser.linux-riscv64-musl.node')
244
+ )
245
+ try {
246
+ if (localFileExisted) {
247
+ nativeBinding = require('./parser.linux-riscv64-musl.node')
248
+ } else {
249
+ nativeBinding = require('@oxc-parser/binding-linux-riscv64-musl')
250
+ }
251
+ } catch (e) {
252
+ loadError = e
253
+ }
254
+ } else {
255
+ localFileExisted = existsSync(
256
+ join(__dirname, 'parser.linux-riscv64-gnu.node')
257
+ )
258
+ try {
259
+ if (localFileExisted) {
260
+ nativeBinding = require('./parser.linux-riscv64-gnu.node')
261
+ } else {
262
+ nativeBinding = require('@oxc-parser/binding-linux-riscv64-gnu')
263
+ }
264
+ } catch (e) {
265
+ loadError = e
266
+ }
267
+ }
268
+ break
269
+ case 's390x':
270
+ localFileExisted = existsSync(
271
+ join(__dirname, 'parser.linux-s390x-gnu.node')
272
+ )
273
+ try {
274
+ if (localFileExisted) {
275
+ nativeBinding = require('./parser.linux-s390x-gnu.node')
276
+ } else {
277
+ nativeBinding = require('@oxc-parser/binding-linux-s390x-gnu')
278
+ }
279
+ } catch (e) {
280
+ loadError = e
281
+ }
282
+ break
240
283
  default:
241
284
  throw new Error(`Unsupported architecture on Linux: ${arch}`)
242
285
  }
@@ -252,8 +295,9 @@ if (!nativeBinding) {
252
295
  throw new Error(`Failed to load native binding`)
253
296
  }
254
297
 
255
- const { parseWithoutReturn, parseSync, parseAsync } = nativeBinding
298
+ const { parseWithoutReturn, parseSync, parseSyncBuffer, parseAsync } = nativeBinding
256
299
 
257
300
  module.exports.parseWithoutReturn = parseWithoutReturn
258
301
  module.exports.parseSync = parseSync
302
+ module.exports.parseSyncBuffer = parseSyncBuffer
259
303
  module.exports.parseAsync = parseAsync
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"oxc-parser","version":"0.2.0","description":"Oxc Parser Node API","main":"index.js","files":["index.d.ts","index.js"],"license":"MIT","repository":{"type":"git","url":"https://github.com/web-infra-dev/oxc.git","directory":"npm/oxc-parser"},"funding":{"url":"https://github.com/sponsors/Boshen"},"optionalDependencies":{"@oxc-parser/binding-win32-x64-msvc":"0.2.0","@oxc-parser/binding-win32-arm64-msvc":"0.2.0","@oxc-parser/binding-linux-x64-gnu":"0.2.0","@oxc-parser/binding-linux-arm64-gnu":"0.2.0","@oxc-parser/binding-darwin-x64":"0.2.0","@oxc-parser/binding-darwin-arm64":"0.2.0"}}
1
+ {"name":"oxc-parser","version":"0.3.0-alpha.0","description":"Oxc Parser Node API","keywords":["Parser"],"author":"Boshen and oxc contributors","license":"MIT","homepage":"https://oxc-project.github.io","bugs":"https://github.com/oxc-project/oxc/issues","repository":{"type":"git","url":"https://github.com/oxc-project/oxc.git","directory":"npm/oxc-parser"},"funding":{"url":"https://github.com/sponsors/Boshen"},"main":"index.js","files":["index.d.ts","index.js"],"optionalDependencies":{"@oxc-parser/binding-win32-x64-msvc":"0.3.0-alpha.0","@oxc-parser/binding-win32-arm64-msvc":"0.3.0-alpha.0","@oxc-parser/binding-linux-x64-gnu":"0.3.0-alpha.0","@oxc-parser/binding-linux-arm64-gnu":"0.3.0-alpha.0","@oxc-parser/binding-linux-x64-musl":"0.3.0-alpha.0","@oxc-parser/binding-linux-arm64-musl":"0.3.0-alpha.0","@oxc-parser/binding-darwin-x64":"0.3.0-alpha.0","@oxc-parser/binding-darwin-arm64":"0.3.0-alpha.0"}}