@srcmap/sourcemap-wasm 0.1.0 → 0.1.3
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 +116 -0
- package/package.json +7 -4
- package/pkg/README.md +116 -0
- package/pkg/package.json +17 -0
- package/pkg/srcmap_sourcemap_wasm.d.ts +57 -0
- package/pkg/srcmap_sourcemap_wasm.js +400 -0
- package/pkg/srcmap_sourcemap_wasm_bg.wasm +0 -0
- package/pkg/srcmap_sourcemap_wasm_bg.wasm.d.ts +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# @srcmap/sourcemap-wasm
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@srcmap/sourcemap-wasm)
|
|
4
|
+
[](https://github.com/BartWaardenburg/srcmap/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/BartWaardenburg/srcmap/actions/workflows/coverage.yml)
|
|
6
|
+
|
|
7
|
+
High-performance source map parser and consumer powered by Rust via WebAssembly.
|
|
8
|
+
|
|
9
|
+
Parses source map JSON and provides position lookups. Implements [ECMA-426](https://tc39.es/ecma426/) (Source Map v3). The batch API is **faster than [`@jridgewell/trace-mapping`](https://github.com/jridgewell/trace-mapping)** for bulk lookups.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @srcmap/sourcemap-wasm
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Works in Node.js, browsers, and any WebAssembly-capable runtime. No native compilation required.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { SourceMap } from '@srcmap/sourcemap-wasm';
|
|
23
|
+
|
|
24
|
+
const sm = new SourceMap(jsonString);
|
|
25
|
+
|
|
26
|
+
// Single lookup (0-based lines and columns)
|
|
27
|
+
const loc = sm.originalPositionFor(42, 10);
|
|
28
|
+
// { source: 'src/app.ts', line: 10, column: 4, name: 'handleClick' }
|
|
29
|
+
|
|
30
|
+
// Batch lookup — recommended for bulk operations
|
|
31
|
+
const positions = new Int32Array([42, 10, 43, 0, 44, 5]);
|
|
32
|
+
const results = sm.originalPositionsFor(positions);
|
|
33
|
+
// Int32Array [srcIdx, line, col, nameIdx, srcIdx, line, col, nameIdx, ...]
|
|
34
|
+
// -1 = no mapping / no name
|
|
35
|
+
|
|
36
|
+
// Resolve indices to strings
|
|
37
|
+
const source = sm.source(results[0]);
|
|
38
|
+
const name = results[3] >= 0 ? sm.name(results[3]) : null;
|
|
39
|
+
|
|
40
|
+
// Reverse lookup
|
|
41
|
+
const pos = sm.generatedPositionFor('src/app.ts', 10, 4);
|
|
42
|
+
// { line: 42, column: 10 }
|
|
43
|
+
|
|
44
|
+
// Cleanup (or use `using sm = new SourceMap(json)` with Symbol.dispose)
|
|
45
|
+
sm.free();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### `new SourceMap(json: string)`
|
|
51
|
+
|
|
52
|
+
Parse a source map from a JSON string.
|
|
53
|
+
|
|
54
|
+
### Instance methods
|
|
55
|
+
|
|
56
|
+
| Method | Returns | Description |
|
|
57
|
+
|--------|---------|-------------|
|
|
58
|
+
| `originalPositionFor(line, column)` | `{ source, line, column, name } \| null` | Forward lookup (0-based) |
|
|
59
|
+
| `generatedPositionFor(source, line, column)` | `{ line, column } \| null` | Reverse lookup (0-based) |
|
|
60
|
+
| `originalPositionsFor(positions: Int32Array)` | `Int32Array` | Batch forward lookup |
|
|
61
|
+
| `source(index)` | `string` | Resolve source index to filename |
|
|
62
|
+
| `name(index)` | `string` | Resolve name index to string |
|
|
63
|
+
| `free()` | `void` | Release WASM memory (also via `Symbol.dispose`) |
|
|
64
|
+
|
|
65
|
+
### Instance properties
|
|
66
|
+
|
|
67
|
+
| Property | Type | Description |
|
|
68
|
+
|----------|------|-------------|
|
|
69
|
+
| `lineCount` | `number` | Number of generated lines |
|
|
70
|
+
| `mappingCount` | `number` | Total decoded mappings |
|
|
71
|
+
| `sources` | `string[]` | All source filenames |
|
|
72
|
+
| `names` | `string[]` | All names |
|
|
73
|
+
|
|
74
|
+
## Performance
|
|
75
|
+
|
|
76
|
+
### Batch API vs trace-mapping
|
|
77
|
+
|
|
78
|
+
The batch API (`originalPositionsFor`) returns a flat `Int32Array`, avoiding per-lookup object allocation. This makes it **faster than pure JS** for bulk operations.
|
|
79
|
+
|
|
80
|
+
| Operation | @srcmap/sourcemap-wasm | @jridgewell/trace-mapping | Speedup |
|
|
81
|
+
|-----------|----------------------|---------------------------|---------|
|
|
82
|
+
| 1000x lookup (medium map) | 12.9 us | 14.9 us | **1.15x faster** |
|
|
83
|
+
| 1000x lookup (large map) | 14.8 us | 22.0 us | **1.49x faster** |
|
|
84
|
+
| Per lookup (amortized) | 13-15 ns | 15-22 ns | **~1.3x faster** |
|
|
85
|
+
|
|
86
|
+
### When to use which
|
|
87
|
+
|
|
88
|
+
| Use case | Recommended package |
|
|
89
|
+
|----------|-------------------|
|
|
90
|
+
| Batch lookups (error stacks, coverage) | **@srcmap/sourcemap-wasm** (batch API) |
|
|
91
|
+
| Few individual lookups | `@jridgewell/trace-mapping` (lower per-call overhead) |
|
|
92
|
+
| Native Node.js addons | `@srcmap/sourcemap` (NAPI) |
|
|
93
|
+
| Browser environments | **@srcmap/sourcemap-wasm** |
|
|
94
|
+
|
|
95
|
+
## Build targets
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Node.js (default)
|
|
99
|
+
npm run build
|
|
100
|
+
|
|
101
|
+
# Browser (ES module + .wasm)
|
|
102
|
+
npm run build:web
|
|
103
|
+
|
|
104
|
+
# Bundler (e.g. webpack, vite)
|
|
105
|
+
npm run build:bundler
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Part of [srcmap](https://github.com/BartWaardenburg/srcmap)
|
|
109
|
+
|
|
110
|
+
High-performance source map tooling written in Rust. See also:
|
|
111
|
+
- [`@srcmap/codec`](https://www.npmjs.com/package/@srcmap/codec) - VLQ codec (NAPI)
|
|
112
|
+
- [`@srcmap/sourcemap`](https://www.npmjs.com/package/@srcmap/sourcemap) - Source map parser (NAPI)
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srcmap/sourcemap-wasm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "High-performance source map parser and consumer powered by Rust (WebAssembly)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "pkg/srcmap_sourcemap_wasm.js",
|
|
7
7
|
"types": "pkg/srcmap_sourcemap_wasm.d.ts",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"files": [
|
|
10
|
-
"pkg/"
|
|
10
|
+
"pkg/",
|
|
11
|
+
"README.md"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
14
|
"build": "wasm-pack build --target nodejs",
|
|
14
15
|
"build:web": "wasm-pack build --target web",
|
|
15
|
-
"build:bundler": "wasm-pack build --target bundler"
|
|
16
|
+
"build:bundler": "wasm-pack build --target bundler",
|
|
17
|
+
"test": "node --test __tests__/sourcemap-wasm.test.mjs",
|
|
18
|
+
"test:coverage": "mkdir -p coverage && node --test --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test-reporter=spec --test-reporter-destination=stdout __tests__/sourcemap-wasm.test.mjs"
|
|
16
19
|
},
|
|
17
20
|
"repository": {
|
|
18
21
|
"type": "git",
|
|
19
|
-
"url": "https://github.com/
|
|
22
|
+
"url": "git+https://github.com/BartWaardenburg/srcmap.git"
|
|
20
23
|
},
|
|
21
24
|
"keywords": [
|
|
22
25
|
"sourcemap",
|
package/pkg/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# @srcmap/sourcemap-wasm
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@srcmap/sourcemap-wasm)
|
|
4
|
+
[](https://github.com/BartWaardenburg/srcmap/actions/workflows/ci.yml)
|
|
5
|
+
[](https://github.com/BartWaardenburg/srcmap/actions/workflows/coverage.yml)
|
|
6
|
+
|
|
7
|
+
High-performance source map parser and consumer powered by Rust via WebAssembly.
|
|
8
|
+
|
|
9
|
+
Parses source map JSON and provides position lookups. Implements [ECMA-426](https://tc39.es/ecma426/) (Source Map v3). The batch API is **faster than [`@jridgewell/trace-mapping`](https://github.com/jridgewell/trace-mapping)** for bulk lookups.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @srcmap/sourcemap-wasm
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Works in Node.js, browsers, and any WebAssembly-capable runtime. No native compilation required.
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { SourceMap } from '@srcmap/sourcemap-wasm';
|
|
23
|
+
|
|
24
|
+
const sm = new SourceMap(jsonString);
|
|
25
|
+
|
|
26
|
+
// Single lookup (0-based lines and columns)
|
|
27
|
+
const loc = sm.originalPositionFor(42, 10);
|
|
28
|
+
// { source: 'src/app.ts', line: 10, column: 4, name: 'handleClick' }
|
|
29
|
+
|
|
30
|
+
// Batch lookup — recommended for bulk operations
|
|
31
|
+
const positions = new Int32Array([42, 10, 43, 0, 44, 5]);
|
|
32
|
+
const results = sm.originalPositionsFor(positions);
|
|
33
|
+
// Int32Array [srcIdx, line, col, nameIdx, srcIdx, line, col, nameIdx, ...]
|
|
34
|
+
// -1 = no mapping / no name
|
|
35
|
+
|
|
36
|
+
// Resolve indices to strings
|
|
37
|
+
const source = sm.source(results[0]);
|
|
38
|
+
const name = results[3] >= 0 ? sm.name(results[3]) : null;
|
|
39
|
+
|
|
40
|
+
// Reverse lookup
|
|
41
|
+
const pos = sm.generatedPositionFor('src/app.ts', 10, 4);
|
|
42
|
+
// { line: 42, column: 10 }
|
|
43
|
+
|
|
44
|
+
// Cleanup (or use `using sm = new SourceMap(json)` with Symbol.dispose)
|
|
45
|
+
sm.free();
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### `new SourceMap(json: string)`
|
|
51
|
+
|
|
52
|
+
Parse a source map from a JSON string.
|
|
53
|
+
|
|
54
|
+
### Instance methods
|
|
55
|
+
|
|
56
|
+
| Method | Returns | Description |
|
|
57
|
+
|--------|---------|-------------|
|
|
58
|
+
| `originalPositionFor(line, column)` | `{ source, line, column, name } \| null` | Forward lookup (0-based) |
|
|
59
|
+
| `generatedPositionFor(source, line, column)` | `{ line, column } \| null` | Reverse lookup (0-based) |
|
|
60
|
+
| `originalPositionsFor(positions: Int32Array)` | `Int32Array` | Batch forward lookup |
|
|
61
|
+
| `source(index)` | `string` | Resolve source index to filename |
|
|
62
|
+
| `name(index)` | `string` | Resolve name index to string |
|
|
63
|
+
| `free()` | `void` | Release WASM memory (also via `Symbol.dispose`) |
|
|
64
|
+
|
|
65
|
+
### Instance properties
|
|
66
|
+
|
|
67
|
+
| Property | Type | Description |
|
|
68
|
+
|----------|------|-------------|
|
|
69
|
+
| `lineCount` | `number` | Number of generated lines |
|
|
70
|
+
| `mappingCount` | `number` | Total decoded mappings |
|
|
71
|
+
| `sources` | `string[]` | All source filenames |
|
|
72
|
+
| `names` | `string[]` | All names |
|
|
73
|
+
|
|
74
|
+
## Performance
|
|
75
|
+
|
|
76
|
+
### Batch API vs trace-mapping
|
|
77
|
+
|
|
78
|
+
The batch API (`originalPositionsFor`) returns a flat `Int32Array`, avoiding per-lookup object allocation. This makes it **faster than pure JS** for bulk operations.
|
|
79
|
+
|
|
80
|
+
| Operation | @srcmap/sourcemap-wasm | @jridgewell/trace-mapping | Speedup |
|
|
81
|
+
|-----------|----------------------|---------------------------|---------|
|
|
82
|
+
| 1000x lookup (medium map) | 12.9 us | 14.9 us | **1.15x faster** |
|
|
83
|
+
| 1000x lookup (large map) | 14.8 us | 22.0 us | **1.49x faster** |
|
|
84
|
+
| Per lookup (amortized) | 13-15 ns | 15-22 ns | **~1.3x faster** |
|
|
85
|
+
|
|
86
|
+
### When to use which
|
|
87
|
+
|
|
88
|
+
| Use case | Recommended package |
|
|
89
|
+
|----------|-------------------|
|
|
90
|
+
| Batch lookups (error stacks, coverage) | **@srcmap/sourcemap-wasm** (batch API) |
|
|
91
|
+
| Few individual lookups | `@jridgewell/trace-mapping` (lower per-call overhead) |
|
|
92
|
+
| Native Node.js addons | `@srcmap/sourcemap` (NAPI) |
|
|
93
|
+
| Browser environments | **@srcmap/sourcemap-wasm** |
|
|
94
|
+
|
|
95
|
+
## Build targets
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Node.js (default)
|
|
99
|
+
npm run build
|
|
100
|
+
|
|
101
|
+
# Browser (ES module + .wasm)
|
|
102
|
+
npm run build:web
|
|
103
|
+
|
|
104
|
+
# Bundler (e.g. webpack, vite)
|
|
105
|
+
npm run build:bundler
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Part of [srcmap](https://github.com/BartWaardenburg/srcmap)
|
|
109
|
+
|
|
110
|
+
High-performance source map tooling written in Rust. See also:
|
|
111
|
+
- [`@srcmap/codec`](https://www.npmjs.com/package/@srcmap/codec) - VLQ codec (NAPI)
|
|
112
|
+
- [`@srcmap/sourcemap`](https://www.npmjs.com/package/@srcmap/sourcemap) - Source map parser (NAPI)
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "srcmap-sourcemap-wasm",
|
|
3
|
+
"description": "WebAssembly bindings for srcmap-sourcemap",
|
|
4
|
+
"version": "0.1.3",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/bartwaardenburg/srcmap"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"srcmap_sourcemap_wasm_bg.wasm",
|
|
12
|
+
"srcmap_sourcemap_wasm.js",
|
|
13
|
+
"srcmap_sourcemap_wasm.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "srcmap_sourcemap_wasm.js",
|
|
16
|
+
"types": "srcmap_sourcemap_wasm.d.ts"
|
|
17
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class SourceMap {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
/**
|
|
8
|
+
* Look up the generated position for an original source position.
|
|
9
|
+
* Returns null if no mapping exists, or an object {line, column}.
|
|
10
|
+
*/
|
|
11
|
+
generatedPositionFor(source: string, line: number, column: number): any;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a name index to its string.
|
|
14
|
+
*/
|
|
15
|
+
name(index: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* Parse a source map from a JSON string.
|
|
18
|
+
*/
|
|
19
|
+
constructor(json: string);
|
|
20
|
+
/**
|
|
21
|
+
* Look up the original source position for a generated position.
|
|
22
|
+
* Both line and column are 0-based.
|
|
23
|
+
* Returns null if no mapping exists, or an object {source, line, column, name}.
|
|
24
|
+
*/
|
|
25
|
+
originalPositionFor(line: number, column: number): any;
|
|
26
|
+
/**
|
|
27
|
+
* Batch lookup: find original positions for multiple generated positions.
|
|
28
|
+
* Takes a flat array [line0, col0, line1, col1, ...].
|
|
29
|
+
* Returns a flat array [srcIdx0, line0, col0, nameIdx0, srcIdx1, ...].
|
|
30
|
+
* -1 means no mapping found / no name.
|
|
31
|
+
*/
|
|
32
|
+
originalPositionsFor(positions: Int32Array): Int32Array;
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a source index to its filename.
|
|
35
|
+
*/
|
|
36
|
+
source(index: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get the debug ID (UUID) if present.
|
|
39
|
+
*/
|
|
40
|
+
readonly debugId: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Number of generated lines.
|
|
43
|
+
*/
|
|
44
|
+
readonly lineCount: number;
|
|
45
|
+
/**
|
|
46
|
+
* Total number of decoded mappings.
|
|
47
|
+
*/
|
|
48
|
+
readonly mappingCount: number;
|
|
49
|
+
/**
|
|
50
|
+
* Get all names.
|
|
51
|
+
*/
|
|
52
|
+
readonly names: any[];
|
|
53
|
+
/**
|
|
54
|
+
* Get all source filenames.
|
|
55
|
+
*/
|
|
56
|
+
readonly sources: any[];
|
|
57
|
+
}
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
/* @ts-self-types="./srcmap_sourcemap_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
class SourceMap {
|
|
4
|
+
__destroy_into_raw() {
|
|
5
|
+
const ptr = this.__wbg_ptr;
|
|
6
|
+
this.__wbg_ptr = 0;
|
|
7
|
+
SourceMapFinalization.unregister(this);
|
|
8
|
+
return ptr;
|
|
9
|
+
}
|
|
10
|
+
free() {
|
|
11
|
+
const ptr = this.__destroy_into_raw();
|
|
12
|
+
wasm.__wbg_sourcemap_free(ptr, 0);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get the debug ID (UUID) if present.
|
|
16
|
+
* @returns {string | undefined}
|
|
17
|
+
*/
|
|
18
|
+
get debugId() {
|
|
19
|
+
try {
|
|
20
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
21
|
+
wasm.sourcemap_debugId(retptr, this.__wbg_ptr);
|
|
22
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
23
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
24
|
+
let v1;
|
|
25
|
+
if (r0 !== 0) {
|
|
26
|
+
v1 = getStringFromWasm0(r0, r1).slice();
|
|
27
|
+
wasm.__wbindgen_export2(r0, r1 * 1, 1);
|
|
28
|
+
}
|
|
29
|
+
return v1;
|
|
30
|
+
} finally {
|
|
31
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Look up the generated position for an original source position.
|
|
36
|
+
* Returns null if no mapping exists, or an object {line, column}.
|
|
37
|
+
* @param {string} source
|
|
38
|
+
* @param {number} line
|
|
39
|
+
* @param {number} column
|
|
40
|
+
* @returns {any}
|
|
41
|
+
*/
|
|
42
|
+
generatedPositionFor(source, line, column) {
|
|
43
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
44
|
+
const len0 = WASM_VECTOR_LEN;
|
|
45
|
+
const ret = wasm.sourcemap_generatedPositionFor(this.__wbg_ptr, ptr0, len0, line, column);
|
|
46
|
+
return takeObject(ret);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Number of generated lines.
|
|
50
|
+
* @returns {number}
|
|
51
|
+
*/
|
|
52
|
+
get lineCount() {
|
|
53
|
+
const ret = wasm.sourcemap_lineCount(this.__wbg_ptr);
|
|
54
|
+
return ret >>> 0;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Total number of decoded mappings.
|
|
58
|
+
* @returns {number}
|
|
59
|
+
*/
|
|
60
|
+
get mappingCount() {
|
|
61
|
+
const ret = wasm.sourcemap_mappingCount(this.__wbg_ptr);
|
|
62
|
+
return ret >>> 0;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolve a name index to its string.
|
|
66
|
+
* @param {number} index
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
name(index) {
|
|
70
|
+
let deferred1_0;
|
|
71
|
+
let deferred1_1;
|
|
72
|
+
try {
|
|
73
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
74
|
+
wasm.sourcemap_name(retptr, this.__wbg_ptr, index);
|
|
75
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
76
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
77
|
+
deferred1_0 = r0;
|
|
78
|
+
deferred1_1 = r1;
|
|
79
|
+
return getStringFromWasm0(r0, r1);
|
|
80
|
+
} finally {
|
|
81
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
82
|
+
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Get all names.
|
|
87
|
+
* @returns {any[]}
|
|
88
|
+
*/
|
|
89
|
+
get names() {
|
|
90
|
+
try {
|
|
91
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
92
|
+
wasm.sourcemap_names(retptr, this.__wbg_ptr);
|
|
93
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
94
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
95
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
96
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
97
|
+
return v1;
|
|
98
|
+
} finally {
|
|
99
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Parse a source map from a JSON string.
|
|
104
|
+
* @param {string} json
|
|
105
|
+
*/
|
|
106
|
+
constructor(json) {
|
|
107
|
+
try {
|
|
108
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
109
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
|
|
110
|
+
const len0 = WASM_VECTOR_LEN;
|
|
111
|
+
wasm.sourcemap_new(retptr, ptr0, len0);
|
|
112
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
113
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
114
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
115
|
+
if (r2) {
|
|
116
|
+
throw takeObject(r1);
|
|
117
|
+
}
|
|
118
|
+
this.__wbg_ptr = r0 >>> 0;
|
|
119
|
+
SourceMapFinalization.register(this, this.__wbg_ptr, this);
|
|
120
|
+
return this;
|
|
121
|
+
} finally {
|
|
122
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Look up the original source position for a generated position.
|
|
127
|
+
* Both line and column are 0-based.
|
|
128
|
+
* Returns null if no mapping exists, or an object {source, line, column, name}.
|
|
129
|
+
* @param {number} line
|
|
130
|
+
* @param {number} column
|
|
131
|
+
* @returns {any}
|
|
132
|
+
*/
|
|
133
|
+
originalPositionFor(line, column) {
|
|
134
|
+
const ret = wasm.sourcemap_originalPositionFor(this.__wbg_ptr, line, column);
|
|
135
|
+
return takeObject(ret);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Batch lookup: find original positions for multiple generated positions.
|
|
139
|
+
* Takes a flat array [line0, col0, line1, col1, ...].
|
|
140
|
+
* Returns a flat array [srcIdx0, line0, col0, nameIdx0, srcIdx1, ...].
|
|
141
|
+
* -1 means no mapping found / no name.
|
|
142
|
+
* @param {Int32Array} positions
|
|
143
|
+
* @returns {Int32Array}
|
|
144
|
+
*/
|
|
145
|
+
originalPositionsFor(positions) {
|
|
146
|
+
try {
|
|
147
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
148
|
+
const ptr0 = passArray32ToWasm0(positions, wasm.__wbindgen_export3);
|
|
149
|
+
const len0 = WASM_VECTOR_LEN;
|
|
150
|
+
wasm.sourcemap_originalPositionsFor(retptr, this.__wbg_ptr, ptr0, len0);
|
|
151
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
152
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
153
|
+
var v2 = getArrayI32FromWasm0(r0, r1).slice();
|
|
154
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
155
|
+
return v2;
|
|
156
|
+
} finally {
|
|
157
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Resolve a source index to its filename.
|
|
162
|
+
* @param {number} index
|
|
163
|
+
* @returns {string}
|
|
164
|
+
*/
|
|
165
|
+
source(index) {
|
|
166
|
+
let deferred1_0;
|
|
167
|
+
let deferred1_1;
|
|
168
|
+
try {
|
|
169
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
170
|
+
wasm.sourcemap_source(retptr, this.__wbg_ptr, index);
|
|
171
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
172
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
173
|
+
deferred1_0 = r0;
|
|
174
|
+
deferred1_1 = r1;
|
|
175
|
+
return getStringFromWasm0(r0, r1);
|
|
176
|
+
} finally {
|
|
177
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
178
|
+
wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Get all source filenames.
|
|
183
|
+
* @returns {any[]}
|
|
184
|
+
*/
|
|
185
|
+
get sources() {
|
|
186
|
+
try {
|
|
187
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
188
|
+
wasm.sourcemap_sources(retptr, this.__wbg_ptr);
|
|
189
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
190
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
191
|
+
var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
|
|
192
|
+
wasm.__wbindgen_export2(r0, r1 * 4, 4);
|
|
193
|
+
return v1;
|
|
194
|
+
} finally {
|
|
195
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (Symbol.dispose) SourceMap.prototype[Symbol.dispose] = SourceMap.prototype.free;
|
|
200
|
+
exports.SourceMap = SourceMap;
|
|
201
|
+
|
|
202
|
+
function __wbg_get_imports() {
|
|
203
|
+
const import0 = {
|
|
204
|
+
__proto__: null,
|
|
205
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
206
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
207
|
+
return addHeapObject(ret);
|
|
208
|
+
},
|
|
209
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
210
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
211
|
+
},
|
|
212
|
+
__wbg_new_ab79df5bd7c26067: function() {
|
|
213
|
+
const ret = new Object();
|
|
214
|
+
return addHeapObject(ret);
|
|
215
|
+
},
|
|
216
|
+
__wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
|
|
217
|
+
const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
|
|
218
|
+
return ret;
|
|
219
|
+
}, arguments); },
|
|
220
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
221
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
222
|
+
const ret = arg0;
|
|
223
|
+
return addHeapObject(ret);
|
|
224
|
+
},
|
|
225
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
226
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
227
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
228
|
+
return addHeapObject(ret);
|
|
229
|
+
},
|
|
230
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
231
|
+
takeObject(arg0);
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
return {
|
|
235
|
+
__proto__: null,
|
|
236
|
+
"./srcmap_sourcemap_wasm_bg.js": import0,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const SourceMapFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
241
|
+
? { register: () => {}, unregister: () => {} }
|
|
242
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sourcemap_free(ptr >>> 0, 1));
|
|
243
|
+
|
|
244
|
+
function addHeapObject(obj) {
|
|
245
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
246
|
+
const idx = heap_next;
|
|
247
|
+
heap_next = heap[idx];
|
|
248
|
+
|
|
249
|
+
heap[idx] = obj;
|
|
250
|
+
return idx;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function dropObject(idx) {
|
|
254
|
+
if (idx < 1028) return;
|
|
255
|
+
heap[idx] = heap_next;
|
|
256
|
+
heap_next = idx;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
function getArrayI32FromWasm0(ptr, len) {
|
|
260
|
+
ptr = ptr >>> 0;
|
|
261
|
+
return getInt32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function getArrayJsValueFromWasm0(ptr, len) {
|
|
265
|
+
ptr = ptr >>> 0;
|
|
266
|
+
const mem = getDataViewMemory0();
|
|
267
|
+
const result = [];
|
|
268
|
+
for (let i = ptr; i < ptr + 4 * len; i += 4) {
|
|
269
|
+
result.push(takeObject(mem.getUint32(i, true)));
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
let cachedDataViewMemory0 = null;
|
|
275
|
+
function getDataViewMemory0() {
|
|
276
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
277
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
278
|
+
}
|
|
279
|
+
return cachedDataViewMemory0;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
let cachedInt32ArrayMemory0 = null;
|
|
283
|
+
function getInt32ArrayMemory0() {
|
|
284
|
+
if (cachedInt32ArrayMemory0 === null || cachedInt32ArrayMemory0.byteLength === 0) {
|
|
285
|
+
cachedInt32ArrayMemory0 = new Int32Array(wasm.memory.buffer);
|
|
286
|
+
}
|
|
287
|
+
return cachedInt32ArrayMemory0;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function getStringFromWasm0(ptr, len) {
|
|
291
|
+
ptr = ptr >>> 0;
|
|
292
|
+
return decodeText(ptr, len);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
let cachedUint32ArrayMemory0 = null;
|
|
296
|
+
function getUint32ArrayMemory0() {
|
|
297
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
298
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
299
|
+
}
|
|
300
|
+
return cachedUint32ArrayMemory0;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
let cachedUint8ArrayMemory0 = null;
|
|
304
|
+
function getUint8ArrayMemory0() {
|
|
305
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
306
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
307
|
+
}
|
|
308
|
+
return cachedUint8ArrayMemory0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function getObject(idx) { return heap[idx]; }
|
|
312
|
+
|
|
313
|
+
function handleError(f, args) {
|
|
314
|
+
try {
|
|
315
|
+
return f.apply(this, args);
|
|
316
|
+
} catch (e) {
|
|
317
|
+
wasm.__wbindgen_export(addHeapObject(e));
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
let heap = new Array(1024).fill(undefined);
|
|
322
|
+
heap.push(undefined, null, true, false);
|
|
323
|
+
|
|
324
|
+
let heap_next = heap.length;
|
|
325
|
+
|
|
326
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
327
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
328
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
329
|
+
WASM_VECTOR_LEN = arg.length;
|
|
330
|
+
return ptr;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
334
|
+
if (realloc === undefined) {
|
|
335
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
336
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
337
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
338
|
+
WASM_VECTOR_LEN = buf.length;
|
|
339
|
+
return ptr;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
let len = arg.length;
|
|
343
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
344
|
+
|
|
345
|
+
const mem = getUint8ArrayMemory0();
|
|
346
|
+
|
|
347
|
+
let offset = 0;
|
|
348
|
+
|
|
349
|
+
for (; offset < len; offset++) {
|
|
350
|
+
const code = arg.charCodeAt(offset);
|
|
351
|
+
if (code > 0x7F) break;
|
|
352
|
+
mem[ptr + offset] = code;
|
|
353
|
+
}
|
|
354
|
+
if (offset !== len) {
|
|
355
|
+
if (offset !== 0) {
|
|
356
|
+
arg = arg.slice(offset);
|
|
357
|
+
}
|
|
358
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
359
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
360
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
361
|
+
|
|
362
|
+
offset += ret.written;
|
|
363
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
WASM_VECTOR_LEN = offset;
|
|
367
|
+
return ptr;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function takeObject(idx) {
|
|
371
|
+
const ret = getObject(idx);
|
|
372
|
+
dropObject(idx);
|
|
373
|
+
return ret;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
377
|
+
cachedTextDecoder.decode();
|
|
378
|
+
function decodeText(ptr, len) {
|
|
379
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const cachedTextEncoder = new TextEncoder();
|
|
383
|
+
|
|
384
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
385
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
386
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
387
|
+
view.set(buf);
|
|
388
|
+
return {
|
|
389
|
+
read: arg.length,
|
|
390
|
+
written: buf.length
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
let WASM_VECTOR_LEN = 0;
|
|
396
|
+
|
|
397
|
+
const wasmPath = `${__dirname}/srcmap_sourcemap_wasm_bg.wasm`;
|
|
398
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
399
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
400
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_sourcemap_free: (a: number, b: number) => void;
|
|
5
|
+
export const sourcemap_debugId: (a: number, b: number) => void;
|
|
6
|
+
export const sourcemap_generatedPositionFor: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
7
|
+
export const sourcemap_lineCount: (a: number) => number;
|
|
8
|
+
export const sourcemap_mappingCount: (a: number) => number;
|
|
9
|
+
export const sourcemap_name: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const sourcemap_names: (a: number, b: number) => void;
|
|
11
|
+
export const sourcemap_new: (a: number, b: number, c: number) => void;
|
|
12
|
+
export const sourcemap_originalPositionFor: (a: number, b: number, c: number) => number;
|
|
13
|
+
export const sourcemap_originalPositionsFor: (a: number, b: number, c: number, d: number) => void;
|
|
14
|
+
export const sourcemap_source: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const sourcemap_sources: (a: number, b: number) => void;
|
|
16
|
+
export const __wbindgen_export: (a: number) => void;
|
|
17
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
18
|
+
export const __wbindgen_export2: (a: number, b: number, c: number) => void;
|
|
19
|
+
export const __wbindgen_export3: (a: number, b: number) => number;
|
|
20
|
+
export const __wbindgen_export4: (a: number, b: number, c: number, d: number) => number;
|