@yuku-parser/wasm 0.5.21 → 0.5.25

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
@@ -1,4 +1,4 @@
1
- # yuku-parser-wasm
1
+ # @yuku-parser/wasm
2
2
 
3
3
  The [`yuku-parser`](https://www.npmjs.com/package/yuku-parser) JavaScript/TypeScript
4
4
  parser as a single WebAssembly module. Runs anywhere: browsers, bundlers, Deno,
@@ -7,13 +7,13 @@ Bun and Node. Same API and same AST as `yuku-parser`.
7
7
  ## Install
8
8
 
9
9
  ```sh
10
- npm install yuku-parser-wasm
10
+ npm install @yuku-parser/wasm
11
11
  ```
12
12
 
13
13
  ## Usage
14
14
 
15
15
  ```js
16
- import { parse } from "yuku-parser-wasm";
16
+ import { parse } from "@yuku-parser/wasm";
17
17
 
18
18
  const { program, comments, diagnostics } = parse("const x: number = 1", {
19
19
  lang: "ts",
package/index.d.ts CHANGED
@@ -149,15 +149,6 @@ interface ParseResult {
149
149
  * 1-based, columns are 0-based, matching ESTree's `loc` convention.
150
150
  */
151
151
  locOf(offset: number): SourceLocation;
152
- /**
153
- * Resolves an offset to a `{ line, column }` pair, starting the search at
154
- * `hintLine` and scanning toward the target line. For offsets resolved in
155
- * roughly source order, pass the previously returned `line` as `hintLine`
156
- * to keep lookups near-constant time, avoiding the binary search in
157
- * {@link locOf}. `hintLine` is 1-based, like the returned `line`. Lines are
158
- * 1-based, columns are 0-based, matching ESTree's `loc` convention.
159
- */
160
- locNear(offset: number, hintLine: number): SourceLocation;
161
152
  }
162
153
 
163
154
  /**
package/index.js CHANGED
@@ -32,12 +32,13 @@ function packFlags(o = {}) {
32
32
 
33
33
  export function parse(source, options) {
34
34
  const bytes = encoder.encode(source);
35
- const srcPtr = alloc(bytes.length);
35
+ const srcLen = bytes.length;
36
+ const srcPtr = alloc(srcLen || 1);
36
37
  // Growing wasm memory detaches memory.buffer, so re-view after every call.
37
- new Uint8Array(memory.buffer, srcPtr, bytes.length).set(bytes);
38
+ new Uint8Array(memory.buffer, srcPtr, srcLen).set(bytes);
38
39
 
39
- const ptr = wasmParse(srcPtr, bytes.length, packFlags(options));
40
- free(srcPtr, bytes.length);
40
+ const ptr = wasmParse(srcPtr, srcLen, packFlags(options));
41
+ free(srcPtr, srcLen || 1);
41
42
  if (ptr === 0) throw new Error("yuku-parser-wasm: failed to parse source");
42
43
 
43
44
  const len = new DataView(memory.buffer).getUint32(ptr, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuku-parser/wasm",
3
- "version": "0.5.21",
3
+ "version": "0.5.25",
4
4
  "description": "High-performance JavaScript/TypeScript parser, compiled to WebAssembly",
5
5
  "license": "MIT",
6
6
  "repository": {