oxc-parser 0.97.0 → 0.99.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/src-js/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'node:module';
2
- import { parseAsync as parseAsyncBinding, parseSync as parseSyncBinding } from './bindings.js';
2
+ import { parse as parseBinding, parseSync as parseSyncBinding } from './bindings.js';
3
3
  import { wrap } from './wrap.js';
4
4
 
5
5
  export { default as visitorKeys } from '../generated/visit/keys.js';
@@ -19,9 +19,9 @@ const require = createRequire(import.meta.url);
19
19
 
20
20
  // Lazily loaded as needed
21
21
  let parseSyncRaw = null,
22
- parseAsyncRaw,
22
+ parseRaw,
23
23
  parseSyncLazy = null,
24
- parseAsyncLazy,
24
+ parseLazy,
25
25
  LazyVisitor;
26
26
 
27
27
  /**
@@ -30,7 +30,7 @@ let parseSyncRaw = null,
30
30
  */
31
31
  function loadRawTransfer() {
32
32
  if (parseSyncRaw === null) {
33
- ({ parseSyncRaw, parseAsyncRaw } = require('./raw-transfer/eager.js'));
33
+ ({ parseSyncRaw, parse: parseRaw } = require('./raw-transfer/eager.js'));
34
34
  }
35
35
  }
36
36
 
@@ -40,7 +40,7 @@ function loadRawTransfer() {
40
40
  */
41
41
  function loadRawTransferLazy() {
42
42
  if (parseSyncLazy === null) {
43
- ({ parseSyncLazy, parseAsyncLazy, Visitor: LazyVisitor } = require('./raw-transfer/lazy.js'));
43
+ ({ parseSyncLazy, parse: parseLazy, Visitor: LazyVisitor } = require('./raw-transfer/lazy.js'));
44
44
  }
45
45
  }
46
46
 
@@ -86,16 +86,16 @@ export function parseSync(filename, sourceText, options) {
86
86
  * @throws {Error} - If `experimentalRawTransfer` or `experimentalLazy` option is enabled,
87
87
  * and raw transfer is not supported on this platform
88
88
  */
89
- export async function parseAsync(filename, sourceText, options) {
89
+ export async function parse(filename, sourceText, options) {
90
90
  if (options?.experimentalRawTransfer) {
91
91
  loadRawTransfer();
92
- return await parseAsyncRaw(filename, sourceText, options);
92
+ return await parseRaw(filename, sourceText, options);
93
93
  }
94
94
  if (options?.experimentalLazy) {
95
95
  loadRawTransferLazy();
96
- return await parseAsyncLazy(filename, sourceText, options);
96
+ return await parseLazy(filename, sourceText, options);
97
97
  }
98
- return wrap(await parseAsyncBinding(filename, sourceText, options));
98
+ return wrap(await parseBinding(filename, sourceText, options));
99
99
  }
100
100
 
101
101
  /**
@@ -1,10 +1,6 @@
1
1
  import os from 'node:os';
2
2
  import { BUFFER_ALIGN, BUFFER_SIZE, IS_TS_FLAG_POS } from '../../generated/constants.js';
3
- import {
4
- getBufferOffset,
5
- parseAsyncRaw as parseAsyncRawBinding,
6
- parseSyncRaw as parseSyncRawBinding,
7
- } from '../bindings.js';
3
+ import { getBufferOffset, parseRaw as parseRawBinding, parseRawSync as parseRawSyncBinding } from '../bindings.js';
8
4
  import { rawTransferSupported } from './supported.js';
9
5
 
10
6
  // Throw an error if running on a platform which raw transfer doesn't support.
@@ -34,7 +30,7 @@ if (!rawTransferSupported()) {
34
30
  */
35
31
  export function parseSyncRawImpl(filename, sourceText, options, convert) {
36
32
  const { buffer, sourceByteLen } = prepareRaw(sourceText);
37
- parseSyncRawBinding(filename, buffer, sourceByteLen, options);
33
+ parseRawSyncBinding(filename, buffer, sourceByteLen, options);
38
34
  return convert(buffer, sourceText, sourceByteLen, options);
39
35
  }
40
36
 
@@ -114,7 +110,7 @@ export async function parseAsyncRawImpl(filename, sourceText, options, convert)
114
110
 
115
111
  // Parse
116
112
  const { buffer, sourceByteLen } = prepareRaw(sourceText);
117
- await parseAsyncRawBinding(filename, buffer, sourceByteLen, options);
113
+ await parseRawBinding(filename, buffer, sourceByteLen, options);
118
114
  const data = convert(buffer, sourceText, sourceByteLen, options);
119
115
 
120
116
  // Free the CPU core
@@ -35,7 +35,7 @@ export function parseSyncRaw(filename, sourceText, options) {
35
35
  * @param {Object} options - Parsing options
36
36
  * @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`
37
37
  */
38
- export function parseAsyncRaw(filename, sourceText, options) {
38
+ export function parse(filename, sourceText, options) {
39
39
  let _;
40
40
  ({ experimentalRawTransfer: _, ...options } = options);
41
41
  return parseAsyncRawImpl(filename, sourceText, options, deserialize);
@@ -44,7 +44,7 @@ export function parseSyncLazy(filename, sourceText, options) {
44
44
  * e.g. `program` in returned object is an instance of `Program` class, with getters for `start`, `end`,
45
45
  * `body` etc.
46
46
  *
47
- * Because this function does not deserialize the AST, unlike `parseAsyncRaw`, very little work happens
47
+ * Because this function does not deserialize the AST, unlike `parse`, very little work happens
48
48
  * on current thread in this function. Deserialization work only occurs when properties of the objects
49
49
  * are accessed.
50
50
  *
@@ -62,7 +62,7 @@ export function parseSyncLazy(filename, sourceText, options) {
62
62
  * @returns {Object} - Object with property getters for `program`, `module`, `comments`, and `errors`,
63
63
  * and `dispose` and `visit` methods
64
64
  */
65
- export function parseAsyncLazy(filename, sourceText, options) {
65
+ export function parse(filename, sourceText, options) {
66
66
  let _;
67
67
  ({ experimentalLazy: _, ...options } = options);
68
68
  return parseAsyncRawImpl(filename, sourceText, options, construct);
package/src-js/wasm.js CHANGED
@@ -2,8 +2,8 @@ export * from '@oxc-parser/binding-wasm32-wasi';
2
2
  import * as bindings from '@oxc-parser/binding-wasm32-wasi';
3
3
  import { wrap } from './wrap.js';
4
4
 
5
- export async function parseAsync(...args) {
6
- return wrap(await bindings.parseAsync(...args));
5
+ export async function parse(...args) {
6
+ return wrap(await bindings.parse(...args));
7
7
  }
8
8
 
9
9
  export function parseSync(filename, sourceText, options) {