@yuku-parser/wasm 0.5.41 → 0.5.43

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
@@ -20,8 +20,8 @@ const { program, comments, diagnostics } = parse("const x: number = 1", {
20
20
  });
21
21
  ```
22
22
 
23
- `parse(source, options?)` returns `{ program, comments, diagnostics, lineStarts,
24
- locOf, scan }`. Options:
23
+ `parse(source, options?)` returns `{ program, comments, diagnostics, scan }`.
24
+ Options:
25
25
 
26
26
  | Option | Default | Description |
27
27
  | ---------------------------- | ---------- | ----------------------------------------- |
package/decode.js CHANGED
@@ -245,15 +245,14 @@ function decode(buffer, source) {
245
245
  extraCount = _u32[1],
246
246
  spLen = _u32[2];
247
247
  const commentCount = _u32[4],
248
- lineStartsCount = _u32[6],
249
- diagCount = _u32[7],
250
- progIdx = _u32[8];
248
+ diagCount = _u32[6],
249
+ progIdx = _u32[7];
251
250
  const attachedCommentCount = _u32[5];
252
- const _flags = _u32[9];
251
+ const _flags = _u32[8];
253
252
  const _isTs = !!(_flags & 1);
254
253
  const _attached = !!(_flags & 2);
255
- const _firstNa = _u32[10];
256
- const _nodesOff = 44;
254
+ const _firstNa = _u32[9];
255
+ const _nodesOff = 40;
257
256
  const eOff = _nodesOff + nodeCount * 48;
258
257
  const _extraBase = eOff >> 2;
259
258
  const _spOff = eOff + extraCount * 4;
@@ -778,8 +777,7 @@ function decode(buffer, source) {
778
777
  }
779
778
  }
780
779
  const node = _attached ? nodeWithComments : _decode;
781
- const lsOff = _cOff + commentCount * 20;
782
- const dOff = lsOff + lineStartsCount * 4;
780
+ const dOff = _cOff + commentCount * 20;
783
781
  function _decodeComments() {
784
782
  const out = Array.from({ length: commentCount });
785
783
  for (let j = 0; j < commentCount; j++) {
@@ -798,20 +796,6 @@ function decode(buffer, source) {
798
796
  }
799
797
  return out;
800
798
  }
801
- function _decodeLineStarts() {
802
- const out = Array.from({ length: lineStartsCount });
803
- if (_firstNa >= _srcLen) {
804
- for (let j = 0; j < lineStartsCount; j++) {
805
- out[j] = dv.getUint32(lsOff + j * 4, true);
806
- }
807
- return out;
808
- }
809
- for (let j = 0; j < lineStartsCount; j++) {
810
- const v = dv.getUint32(lsOff + j * 4, true);
811
- out[j] = v < _firstNa ? v : (v >= _srcLen ? pm[pm.length - 1] : pm[v - _firstNa]);
812
- }
813
- return out;
814
- }
815
799
  function _decodeDiagnostics() {
816
800
  const out = Array.from({ length: diagCount });
817
801
  let dp = dOff;
@@ -844,11 +828,7 @@ function decode(buffer, source) {
844
828
  }
845
829
  return out;
846
830
  }
847
- let _program, _lineStarts, _diagnostics, _comments;
848
- function _getLineStarts() {
849
- if (_lineStarts === undefined) _lineStarts = _decodeLineStarts();
850
- return _lineStarts;
851
- }
831
+ let _program, _diagnostics, _comments;
852
832
  return {
853
833
  get program() {
854
834
  return _program !== undefined ? _program : (_program = node(progIdx));
@@ -863,16 +843,6 @@ function decode(buffer, source) {
863
843
  ? _diagnostics
864
844
  : (_diagnostics = _decodeDiagnostics());
865
845
  },
866
- get lineStarts() { return _getLineStarts(); },
867
- locOf(offset) {
868
- const ls = _getLineStarts();
869
- let lo = 0, hi = ls.length;
870
- while (lo < hi) {
871
- const mid = (lo + hi) >>> 1;
872
- if (ls[mid] <= offset) lo = mid + 1; else hi = mid;
873
- }
874
- return { line: lo, column: offset - ls[lo - 1] };
875
- },
876
846
  };
877
847
  }
878
848
  export { decode, CHILD_KEYS };
package/index.d.ts CHANGED
@@ -10,7 +10,6 @@ import type {
10
10
  NodeType,
11
11
  Program,
12
12
  SourceLang,
13
- SourceLocation,
14
13
  SourceType,
15
14
  WalkContext,
16
15
  } from "@yuku-toolchain/types";
@@ -70,17 +69,6 @@ interface ParseResult {
70
69
  comments: Comment[];
71
70
  /** Syntax diagnostics, and semantic diagnostics when {@link ParseOptions.semanticErrors} is enabled. */
72
71
  diagnostics: Diagnostic[];
73
- /**
74
- * Sorted UTF-16 offsets where each line begins. Index `i` is the start of
75
- * line `i + 1`. Used internally by {@link locOf}, and required by
76
- * `yuku-codegen` for source maps.
77
- */
78
- lineStarts: number[];
79
- /**
80
- * Resolves an offset to a `{ line, column }` pair. Lines are
81
- * 1-based, columns are 0-based, matching ESTree's `loc` convention.
82
- */
83
- locOf(offset: number): SourceLocation;
84
72
  }
85
73
 
86
74
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuku-parser/wasm",
3
- "version": "0.5.41",
3
+ "version": "0.5.43",
4
4
  "description": "High-performance JavaScript/TypeScript parser, compiled to WebAssembly",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  "yuku-parser.wasm"
19
19
  ],
20
20
  "dependencies": {
21
- "@yuku-toolchain/types": "0.5.37"
21
+ "@yuku-toolchain/types": "0.5.42"
22
22
  },
23
23
  "keywords": [
24
24
  "acorn",
package/yuku-parser.wasm CHANGED
Binary file