@srcmap/sourcemap-wasm 0.1.3 → 0.2.1

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
@@ -68,6 +68,8 @@ Parse a source map from a JSON string.
68
68
  |----------|------|-------------|
69
69
  | `lineCount` | `number` | Number of generated lines |
70
70
  | `mappingCount` | `number` | Total decoded mappings |
71
+ | `hasRangeMappings` | `boolean` | Whether any range mappings exist |
72
+ | `rangeMappingCount` | `number` | Number of range mappings |
71
73
  | `sources` | `string[]` | All source filenames |
72
74
  | `names` | `string[]` | All names |
73
75
 
package/package.json CHANGED
@@ -1,19 +1,30 @@
1
1
  {
2
2
  "name": "@srcmap/sourcemap-wasm",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
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
+ "browser": "web/srcmap_sourcemap_wasm.js",
9
+ "module": "web/srcmap_sourcemap_wasm.js",
10
+ "exports": {
11
+ ".": {
12
+ "node": "./pkg/srcmap_sourcemap_wasm.js",
13
+ "browser": "./web/srcmap_sourcemap_wasm.js",
14
+ "default": "./pkg/srcmap_sourcemap_wasm.js"
15
+ }
16
+ },
8
17
  "license": "MIT",
9
18
  "files": [
10
19
  "pkg/",
20
+ "web/",
11
21
  "README.md"
12
22
  ],
13
23
  "scripts": {
14
- "build": "wasm-pack build --target nodejs",
15
- "build:web": "wasm-pack build --target web",
16
- "build:bundler": "wasm-pack build --target bundler",
24
+ "build": "wasm-pack build --target nodejs --out-dir pkg",
25
+ "build:web": "wasm-pack build --target web --out-dir web",
26
+ "build:bundler": "wasm-pack build --target bundler --out-dir bundler",
27
+ "build:all": "npm run build && npm run build:web",
17
28
  "test": "node --test __tests__/sourcemap-wasm.test.mjs",
18
29
  "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"
19
30
  },
@@ -30,6 +41,7 @@
30
41
  "rust",
31
42
  "wasm",
32
43
  "webassembly",
33
- "performance"
44
+ "performance",
45
+ "browser"
34
46
  ]
35
47
  }
package/pkg/README.md CHANGED
@@ -68,6 +68,8 @@ Parse a source map from a JSON string.
68
68
  |----------|------|-------------|
69
69
  | `lineCount` | `number` | Number of generated lines |
70
70
  | `mappingCount` | `number` | Total decoded mappings |
71
+ | `hasRangeMappings` | `boolean` | Whether any range mappings exist |
72
+ | `rangeMappingCount` | `number` | Number of range mappings |
71
73
  | `sources` | `string[]` | All source filenames |
72
74
  | `names` | `string[]` | All names |
73
75
 
package/pkg/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "srcmap-sourcemap-wasm",
3
3
  "description": "WebAssembly bindings for srcmap-sourcemap",
4
- "version": "0.1.3",
4
+ "version": "0.2.1",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/bartwaardenburg/srcmap"
8
+ "url": "https://github.com/BartWaardenburg/srcmap"
9
9
  },
10
10
  "files": [
11
11
  "srcmap_sourcemap_wasm_bg.wasm",
@@ -4,11 +4,52 @@
4
4
  export class SourceMap {
5
5
  free(): void;
6
6
  [Symbol.dispose](): void;
7
+ /**
8
+ * Find all generated positions for an original source position.
9
+ * Returns an array of {line, column} objects.
10
+ */
11
+ allGeneratedPositionsFor(source: string, line: number, column: number): any[];
12
+ /**
13
+ * Get all mappings as a flat Int32Array.
14
+ * Format: [genLine, genCol, source, origLine, origCol, name, isRange, ...] per mapping.
15
+ * source = -1 means unmapped, name = -1 means no name, isRange = 1 if range mapping.
16
+ */
17
+ allMappingsFlat(): Int32Array;
18
+ /**
19
+ * Encode all mappings back to a VLQ mappings string.
20
+ */
21
+ encodedMappings(): string;
22
+ /**
23
+ * Encode the range mappings back to a VLQ string, or null if none exist.
24
+ */
25
+ encodedRangeMappings(): any;
26
+ /**
27
+ * Build a source map from pre-parsed components.
28
+ *
29
+ * This is the fast path: JS does JSON.parse() (V8-native speed),
30
+ * then only the VLQ mappings string is sent to WASM for decoding.
31
+ * Avoids copying large sourcesContent into WASM linear memory.
32
+ */
33
+ static fromVlq(mappings: string, sources: any[], names: any[], file: string | null | undefined, source_root: string | null | undefined, sources_content: any[], ignore_list: Uint32Array, debug_id?: string | null): SourceMap;
7
34
  /**
8
35
  * Look up the generated position for an original source position.
9
36
  * Returns null if no mapping exists, or an object {line, column}.
10
37
  */
11
38
  generatedPositionFor(source: string, line: number, column: number): any;
39
+ /**
40
+ * Look up the generated position with a bias.
41
+ * bias: 0 = default, -1 = LEAST_UPPER_BOUND, 1 = GREATEST_LOWER_BOUND
42
+ */
43
+ generatedPositionForWithBias(source: string, line: number, column: number, bias: number): any;
44
+ /**
45
+ * Check if a source index is in the ignore list.
46
+ */
47
+ isIgnoredIndex(index: number): boolean;
48
+ /**
49
+ * Map a generated range to its original range.
50
+ * Returns null if either endpoint has no mapping or endpoints map to different sources.
51
+ */
52
+ mapRange(start_line: number, start_column: number, end_line: number, end_column: number): any;
12
53
  /**
13
54
  * Resolve a name index to its string.
14
55
  */
@@ -17,12 +58,29 @@ export class SourceMap {
17
58
  * Parse a source map from a JSON string.
18
59
  */
19
60
  constructor(json: string);
61
+ /**
62
+ * Zero-allocation single lookup. Writes result to the static WASM buffer.
63
+ * Returns true if a mapping was found, false otherwise.
64
+ * Read results via an Int32Array view at resultPtr(): [sourceIdx, line, column, nameIdx].
65
+ */
66
+ originalPositionBuf(line: number, column: number): boolean;
67
+ /**
68
+ * Fast single lookup returning flat array [sourceIdx, line, column, nameIdx].
69
+ * Returns [-1, -1, -1, -1] for unmapped positions.
70
+ * Use source(idx) and name(idx) to resolve strings.
71
+ */
72
+ originalPositionFlat(line: number, column: number): Int32Array;
20
73
  /**
21
74
  * Look up the original source position for a generated position.
22
75
  * Both line and column are 0-based.
23
76
  * Returns null if no mapping exists, or an object {source, line, column, name}.
24
77
  */
25
78
  originalPositionFor(line: number, column: number): any;
79
+ /**
80
+ * Look up the original source position with a bias.
81
+ * bias: 0 = GREATEST_LOWER_BOUND (default), -1 = LEAST_UPPER_BOUND
82
+ */
83
+ originalPositionForWithBias(line: number, column: number, bias: number): any;
26
84
  /**
27
85
  * Batch lookup: find original positions for multiple generated positions.
28
86
  * Takes a flat array [line0, col0, line1, col1, ...].
@@ -34,10 +92,26 @@ export class SourceMap {
34
92
  * Resolve a source index to its filename.
35
93
  */
36
94
  source(index: number): string;
95
+ /**
96
+ * Get source content for a given source index.
97
+ */
98
+ sourceContentFor(index: number): any;
37
99
  /**
38
100
  * Get the debug ID (UUID) if present.
39
101
  */
40
102
  readonly debugId: string | undefined;
103
+ /**
104
+ * Get the file property.
105
+ */
106
+ readonly file: string | undefined;
107
+ /**
108
+ * Whether the source map has any range mappings (ECMA-426).
109
+ */
110
+ readonly hasRangeMappings: boolean;
111
+ /**
112
+ * Get the ignore list (array of source indices).
113
+ */
114
+ readonly ignoreList: Uint32Array;
41
115
  /**
42
116
  * Number of generated lines.
43
117
  */
@@ -50,8 +124,32 @@ export class SourceMap {
50
124
  * Get all names.
51
125
  */
52
126
  readonly names: any[];
127
+ /**
128
+ * Number of range mappings in the source map.
129
+ */
130
+ readonly rangeMappingCount: number;
131
+ /**
132
+ * Get the sourceRoot property.
133
+ */
134
+ readonly sourceRoot: string | undefined;
53
135
  /**
54
136
  * Get all source filenames.
55
137
  */
56
138
  readonly sources: any[];
139
+ /**
140
+ * Get all sources content (array of string|null).
141
+ */
142
+ readonly sourcesContent: any[];
57
143
  }
144
+
145
+ /**
146
+ * Get the pointer to the static result buffer in WASM linear memory.
147
+ * JS side creates an Int32Array view at this offset to read lookup results
148
+ * without any allocation or copying.
149
+ */
150
+ export function resultPtr(): number;
151
+
152
+ /**
153
+ * Expose WASM linear memory for direct buffer access from JS.
154
+ */
155
+ export function wasmMemory(): any;
@@ -1,6 +1,13 @@
1
1
  /* @ts-self-types="./srcmap_sourcemap_wasm.d.ts" */
2
2
 
3
3
  class SourceMap {
4
+ static __wrap(ptr) {
5
+ ptr = ptr >>> 0;
6
+ const obj = Object.create(SourceMap.prototype);
7
+ obj.__wbg_ptr = ptr;
8
+ SourceMapFinalization.register(obj, obj.__wbg_ptr, obj);
9
+ return obj;
10
+ }
4
11
  __destroy_into_raw() {
5
12
  const ptr = this.__wbg_ptr;
6
13
  this.__wbg_ptr = 0;
@@ -11,6 +18,48 @@ class SourceMap {
11
18
  const ptr = this.__destroy_into_raw();
12
19
  wasm.__wbg_sourcemap_free(ptr, 0);
13
20
  }
21
+ /**
22
+ * Find all generated positions for an original source position.
23
+ * Returns an array of {line, column} objects.
24
+ * @param {string} source
25
+ * @param {number} line
26
+ * @param {number} column
27
+ * @returns {any[]}
28
+ */
29
+ allGeneratedPositionsFor(source, line, column) {
30
+ try {
31
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
32
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
33
+ const len0 = WASM_VECTOR_LEN;
34
+ wasm.sourcemap_allGeneratedPositionsFor(retptr, this.__wbg_ptr, ptr0, len0, line, column);
35
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
36
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
37
+ var v2 = getArrayJsValueFromWasm0(r0, r1).slice();
38
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
39
+ return v2;
40
+ } finally {
41
+ wasm.__wbindgen_add_to_stack_pointer(16);
42
+ }
43
+ }
44
+ /**
45
+ * Get all mappings as a flat Int32Array.
46
+ * Format: [genLine, genCol, source, origLine, origCol, name, isRange, ...] per mapping.
47
+ * source = -1 means unmapped, name = -1 means no name, isRange = 1 if range mapping.
48
+ * @returns {Int32Array}
49
+ */
50
+ allMappingsFlat() {
51
+ try {
52
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
53
+ wasm.sourcemap_allMappingsFlat(retptr, this.__wbg_ptr);
54
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
55
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
56
+ var v1 = getArrayI32FromWasm0(r0, r1).slice();
57
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
58
+ return v1;
59
+ } finally {
60
+ wasm.__wbindgen_add_to_stack_pointer(16);
61
+ }
62
+ }
14
63
  /**
15
64
  * Get the debug ID (UUID) if present.
16
65
  * @returns {string | undefined}
@@ -24,13 +73,108 @@ class SourceMap {
24
73
  let v1;
25
74
  if (r0 !== 0) {
26
75
  v1 = getStringFromWasm0(r0, r1).slice();
27
- wasm.__wbindgen_export2(r0, r1 * 1, 1);
76
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
77
+ }
78
+ return v1;
79
+ } finally {
80
+ wasm.__wbindgen_add_to_stack_pointer(16);
81
+ }
82
+ }
83
+ /**
84
+ * Encode all mappings back to a VLQ mappings string.
85
+ * @returns {string}
86
+ */
87
+ encodedMappings() {
88
+ let deferred1_0;
89
+ let deferred1_1;
90
+ try {
91
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
92
+ wasm.sourcemap_encodedMappings(retptr, this.__wbg_ptr);
93
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
94
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
95
+ deferred1_0 = r0;
96
+ deferred1_1 = r1;
97
+ return getStringFromWasm0(r0, r1);
98
+ } finally {
99
+ wasm.__wbindgen_add_to_stack_pointer(16);
100
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
101
+ }
102
+ }
103
+ /**
104
+ * Encode the range mappings back to a VLQ string, or null if none exist.
105
+ * @returns {any}
106
+ */
107
+ encodedRangeMappings() {
108
+ const ret = wasm.sourcemap_encodedRangeMappings(this.__wbg_ptr);
109
+ return takeObject(ret);
110
+ }
111
+ /**
112
+ * Get the file property.
113
+ * @returns {string | undefined}
114
+ */
115
+ get file() {
116
+ try {
117
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
118
+ wasm.sourcemap_file(retptr, this.__wbg_ptr);
119
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
120
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
121
+ let v1;
122
+ if (r0 !== 0) {
123
+ v1 = getStringFromWasm0(r0, r1).slice();
124
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
28
125
  }
29
126
  return v1;
30
127
  } finally {
31
128
  wasm.__wbindgen_add_to_stack_pointer(16);
32
129
  }
33
130
  }
131
+ /**
132
+ * Build a source map from pre-parsed components.
133
+ *
134
+ * This is the fast path: JS does JSON.parse() (V8-native speed),
135
+ * then only the VLQ mappings string is sent to WASM for decoding.
136
+ * Avoids copying large sourcesContent into WASM linear memory.
137
+ * @param {string} mappings
138
+ * @param {any[]} sources
139
+ * @param {any[]} names
140
+ * @param {string | null | undefined} file
141
+ * @param {string | null | undefined} source_root
142
+ * @param {any[]} sources_content
143
+ * @param {Uint32Array} ignore_list
144
+ * @param {string | null} [debug_id]
145
+ * @returns {SourceMap}
146
+ */
147
+ static fromVlq(mappings, sources, names, file, source_root, sources_content, ignore_list, debug_id) {
148
+ try {
149
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
150
+ const ptr0 = passStringToWasm0(mappings, wasm.__wbindgen_export, wasm.__wbindgen_export2);
151
+ const len0 = WASM_VECTOR_LEN;
152
+ const ptr1 = passArrayJsValueToWasm0(sources, wasm.__wbindgen_export);
153
+ const len1 = WASM_VECTOR_LEN;
154
+ const ptr2 = passArrayJsValueToWasm0(names, wasm.__wbindgen_export);
155
+ const len2 = WASM_VECTOR_LEN;
156
+ var ptr3 = isLikeNone(file) ? 0 : passStringToWasm0(file, wasm.__wbindgen_export, wasm.__wbindgen_export2);
157
+ var len3 = WASM_VECTOR_LEN;
158
+ var ptr4 = isLikeNone(source_root) ? 0 : passStringToWasm0(source_root, wasm.__wbindgen_export, wasm.__wbindgen_export2);
159
+ var len4 = WASM_VECTOR_LEN;
160
+ const ptr5 = passArrayJsValueToWasm0(sources_content, wasm.__wbindgen_export);
161
+ const len5 = WASM_VECTOR_LEN;
162
+ const ptr6 = passArray32ToWasm0(ignore_list, wasm.__wbindgen_export);
163
+ const len6 = WASM_VECTOR_LEN;
164
+ var ptr7 = isLikeNone(debug_id) ? 0 : passStringToWasm0(debug_id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
165
+ var len7 = WASM_VECTOR_LEN;
166
+ wasm.sourcemap_fromVlq(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4, ptr5, len5, ptr6, len6, ptr7, len7);
167
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
168
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
169
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
170
+ if (r2) {
171
+ throw takeObject(r1);
172
+ }
173
+ return SourceMap.__wrap(r0);
174
+ } finally {
175
+ wasm.__wbindgen_add_to_stack_pointer(16);
176
+ }
177
+ }
34
178
  /**
35
179
  * Look up the generated position for an original source position.
36
180
  * Returns null if no mapping exists, or an object {line, column}.
@@ -40,11 +184,60 @@ class SourceMap {
40
184
  * @returns {any}
41
185
  */
42
186
  generatedPositionFor(source, line, column) {
43
- const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
187
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
44
188
  const len0 = WASM_VECTOR_LEN;
45
189
  const ret = wasm.sourcemap_generatedPositionFor(this.__wbg_ptr, ptr0, len0, line, column);
46
190
  return takeObject(ret);
47
191
  }
192
+ /**
193
+ * Look up the generated position with a bias.
194
+ * bias: 0 = default, -1 = LEAST_UPPER_BOUND, 1 = GREATEST_LOWER_BOUND
195
+ * @param {string} source
196
+ * @param {number} line
197
+ * @param {number} column
198
+ * @param {number} bias
199
+ * @returns {any}
200
+ */
201
+ generatedPositionForWithBias(source, line, column, bias) {
202
+ const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
203
+ const len0 = WASM_VECTOR_LEN;
204
+ const ret = wasm.sourcemap_generatedPositionForWithBias(this.__wbg_ptr, ptr0, len0, line, column, bias);
205
+ return takeObject(ret);
206
+ }
207
+ /**
208
+ * Whether the source map has any range mappings (ECMA-426).
209
+ * @returns {boolean}
210
+ */
211
+ get hasRangeMappings() {
212
+ const ret = wasm.sourcemap_hasRangeMappings(this.__wbg_ptr);
213
+ return ret !== 0;
214
+ }
215
+ /**
216
+ * Get the ignore list (array of source indices).
217
+ * @returns {Uint32Array}
218
+ */
219
+ get ignoreList() {
220
+ try {
221
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
222
+ wasm.sourcemap_ignoreList(retptr, this.__wbg_ptr);
223
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
224
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
225
+ var v1 = getArrayU32FromWasm0(r0, r1).slice();
226
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
227
+ return v1;
228
+ } finally {
229
+ wasm.__wbindgen_add_to_stack_pointer(16);
230
+ }
231
+ }
232
+ /**
233
+ * Check if a source index is in the ignore list.
234
+ * @param {number} index
235
+ * @returns {boolean}
236
+ */
237
+ isIgnoredIndex(index) {
238
+ const ret = wasm.sourcemap_isIgnoredIndex(this.__wbg_ptr, index);
239
+ return ret !== 0;
240
+ }
48
241
  /**
49
242
  * Number of generated lines.
50
243
  * @returns {number}
@@ -53,6 +246,19 @@ class SourceMap {
53
246
  const ret = wasm.sourcemap_lineCount(this.__wbg_ptr);
54
247
  return ret >>> 0;
55
248
  }
249
+ /**
250
+ * Map a generated range to its original range.
251
+ * Returns null if either endpoint has no mapping or endpoints map to different sources.
252
+ * @param {number} start_line
253
+ * @param {number} start_column
254
+ * @param {number} end_line
255
+ * @param {number} end_column
256
+ * @returns {any}
257
+ */
258
+ mapRange(start_line, start_column, end_line, end_column) {
259
+ const ret = wasm.sourcemap_mapRange(this.__wbg_ptr, start_line, start_column, end_line, end_column);
260
+ return takeObject(ret);
261
+ }
56
262
  /**
57
263
  * Total number of decoded mappings.
58
264
  * @returns {number}
@@ -79,7 +285,7 @@ class SourceMap {
79
285
  return getStringFromWasm0(r0, r1);
80
286
  } finally {
81
287
  wasm.__wbindgen_add_to_stack_pointer(16);
82
- wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
288
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
83
289
  }
84
290
  }
85
291
  /**
@@ -93,7 +299,7 @@ class SourceMap {
93
299
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
94
300
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
95
301
  var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
96
- wasm.__wbindgen_export2(r0, r1 * 4, 4);
302
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
97
303
  return v1;
98
304
  } finally {
99
305
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -106,7 +312,7 @@ class SourceMap {
106
312
  constructor(json) {
107
313
  try {
108
314
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
109
- const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export3, wasm.__wbindgen_export4);
315
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
110
316
  const len0 = WASM_VECTOR_LEN;
111
317
  wasm.sourcemap_new(retptr, ptr0, len0);
112
318
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
@@ -122,6 +328,39 @@ class SourceMap {
122
328
  wasm.__wbindgen_add_to_stack_pointer(16);
123
329
  }
124
330
  }
331
+ /**
332
+ * Zero-allocation single lookup. Writes result to the static WASM buffer.
333
+ * Returns true if a mapping was found, false otherwise.
334
+ * Read results via an Int32Array view at resultPtr(): [sourceIdx, line, column, nameIdx].
335
+ * @param {number} line
336
+ * @param {number} column
337
+ * @returns {boolean}
338
+ */
339
+ originalPositionBuf(line, column) {
340
+ const ret = wasm.sourcemap_originalPositionBuf(this.__wbg_ptr, line, column);
341
+ return ret !== 0;
342
+ }
343
+ /**
344
+ * Fast single lookup returning flat array [sourceIdx, line, column, nameIdx].
345
+ * Returns [-1, -1, -1, -1] for unmapped positions.
346
+ * Use source(idx) and name(idx) to resolve strings.
347
+ * @param {number} line
348
+ * @param {number} column
349
+ * @returns {Int32Array}
350
+ */
351
+ originalPositionFlat(line, column) {
352
+ try {
353
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
354
+ wasm.sourcemap_originalPositionFlat(retptr, this.__wbg_ptr, line, column);
355
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
356
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
357
+ var v1 = getArrayI32FromWasm0(r0, r1).slice();
358
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
359
+ return v1;
360
+ } finally {
361
+ wasm.__wbindgen_add_to_stack_pointer(16);
362
+ }
363
+ }
125
364
  /**
126
365
  * Look up the original source position for a generated position.
127
366
  * Both line and column are 0-based.
@@ -134,6 +373,18 @@ class SourceMap {
134
373
  const ret = wasm.sourcemap_originalPositionFor(this.__wbg_ptr, line, column);
135
374
  return takeObject(ret);
136
375
  }
376
+ /**
377
+ * Look up the original source position with a bias.
378
+ * bias: 0 = GREATEST_LOWER_BOUND (default), -1 = LEAST_UPPER_BOUND
379
+ * @param {number} line
380
+ * @param {number} column
381
+ * @param {number} bias
382
+ * @returns {any}
383
+ */
384
+ originalPositionForWithBias(line, column, bias) {
385
+ const ret = wasm.sourcemap_originalPositionForWithBias(this.__wbg_ptr, line, column, bias);
386
+ return takeObject(ret);
387
+ }
137
388
  /**
138
389
  * Batch lookup: find original positions for multiple generated positions.
139
390
  * Takes a flat array [line0, col0, line1, col1, ...].
@@ -145,18 +396,26 @@ class SourceMap {
145
396
  originalPositionsFor(positions) {
146
397
  try {
147
398
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
148
- const ptr0 = passArray32ToWasm0(positions, wasm.__wbindgen_export3);
399
+ const ptr0 = passArray32ToWasm0(positions, wasm.__wbindgen_export);
149
400
  const len0 = WASM_VECTOR_LEN;
150
401
  wasm.sourcemap_originalPositionsFor(retptr, this.__wbg_ptr, ptr0, len0);
151
402
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
152
403
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
153
404
  var v2 = getArrayI32FromWasm0(r0, r1).slice();
154
- wasm.__wbindgen_export2(r0, r1 * 4, 4);
405
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
155
406
  return v2;
156
407
  } finally {
157
408
  wasm.__wbindgen_add_to_stack_pointer(16);
158
409
  }
159
410
  }
411
+ /**
412
+ * Number of range mappings in the source map.
413
+ * @returns {number}
414
+ */
415
+ get rangeMappingCount() {
416
+ const ret = wasm.sourcemap_rangeMappingCount(this.__wbg_ptr);
417
+ return ret >>> 0;
418
+ }
160
419
  /**
161
420
  * Resolve a source index to its filename.
162
421
  * @param {number} index
@@ -175,7 +434,36 @@ class SourceMap {
175
434
  return getStringFromWasm0(r0, r1);
176
435
  } finally {
177
436
  wasm.__wbindgen_add_to_stack_pointer(16);
178
- wasm.__wbindgen_export2(deferred1_0, deferred1_1, 1);
437
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
438
+ }
439
+ }
440
+ /**
441
+ * Get source content for a given source index.
442
+ * @param {number} index
443
+ * @returns {any}
444
+ */
445
+ sourceContentFor(index) {
446
+ const ret = wasm.sourcemap_sourceContentFor(this.__wbg_ptr, index);
447
+ return takeObject(ret);
448
+ }
449
+ /**
450
+ * Get the sourceRoot property.
451
+ * @returns {string | undefined}
452
+ */
453
+ get sourceRoot() {
454
+ try {
455
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
456
+ wasm.sourcemap_sourceRoot(retptr, this.__wbg_ptr);
457
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
458
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
459
+ let v1;
460
+ if (r0 !== 0) {
461
+ v1 = getStringFromWasm0(r0, r1).slice();
462
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
463
+ }
464
+ return v1;
465
+ } finally {
466
+ wasm.__wbindgen_add_to_stack_pointer(16);
179
467
  }
180
468
  }
181
469
  /**
@@ -189,7 +477,24 @@ class SourceMap {
189
477
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
190
478
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
191
479
  var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
192
- wasm.__wbindgen_export2(r0, r1 * 4, 4);
480
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
481
+ return v1;
482
+ } finally {
483
+ wasm.__wbindgen_add_to_stack_pointer(16);
484
+ }
485
+ }
486
+ /**
487
+ * Get all sources content (array of string|null).
488
+ * @returns {any[]}
489
+ */
490
+ get sourcesContent() {
491
+ try {
492
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
493
+ wasm.sourcemap_sourcesContent(retptr, this.__wbg_ptr);
494
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
495
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
496
+ var v1 = getArrayJsValueFromWasm0(r0, r1).slice();
497
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
193
498
  return v1;
194
499
  } finally {
195
500
  wasm.__wbindgen_add_to_stack_pointer(16);
@@ -199,6 +504,28 @@ class SourceMap {
199
504
  if (Symbol.dispose) SourceMap.prototype[Symbol.dispose] = SourceMap.prototype.free;
200
505
  exports.SourceMap = SourceMap;
201
506
 
507
+ /**
508
+ * Get the pointer to the static result buffer in WASM linear memory.
509
+ * JS side creates an Int32Array view at this offset to read lookup results
510
+ * without any allocation or copying.
511
+ * @returns {number}
512
+ */
513
+ function resultPtr() {
514
+ const ret = wasm.resultPtr();
515
+ return ret >>> 0;
516
+ }
517
+ exports.resultPtr = resultPtr;
518
+
519
+ /**
520
+ * Expose WASM linear memory for direct buffer access from JS.
521
+ * @returns {any}
522
+ */
523
+ function wasmMemory() {
524
+ const ret = wasm.wasmMemory();
525
+ return takeObject(ret);
526
+ }
527
+ exports.wasmMemory = wasmMemory;
528
+
202
529
  function __wbg_get_imports() {
203
530
  const import0 = {
204
531
  __proto__: null,
@@ -206,6 +533,18 @@ function __wbg_get_imports() {
206
533
  const ret = Error(getStringFromWasm0(arg0, arg1));
207
534
  return addHeapObject(ret);
208
535
  },
536
+ __wbg___wbindgen_memory_edb3f01e3930bbf6: function() {
537
+ const ret = wasm.memory;
538
+ return addHeapObject(ret);
539
+ },
540
+ __wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
541
+ const obj = getObject(arg1);
542
+ const ret = typeof(obj) === 'string' ? obj : undefined;
543
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
544
+ var len1 = WASM_VECTOR_LEN;
545
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
546
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
547
+ },
209
548
  __wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
210
549
  throw new Error(getStringFromWasm0(arg0, arg1));
211
550
  },
@@ -271,6 +610,11 @@ function getArrayJsValueFromWasm0(ptr, len) {
271
610
  return result;
272
611
  }
273
612
 
613
+ function getArrayU32FromWasm0(ptr, len) {
614
+ ptr = ptr >>> 0;
615
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
616
+ }
617
+
274
618
  let cachedDataViewMemory0 = null;
275
619
  function getDataViewMemory0() {
276
620
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -314,7 +658,7 @@ function handleError(f, args) {
314
658
  try {
315
659
  return f.apply(this, args);
316
660
  } catch (e) {
317
- wasm.__wbindgen_export(addHeapObject(e));
661
+ wasm.__wbindgen_export3(addHeapObject(e));
318
662
  }
319
663
  }
320
664
 
@@ -323,6 +667,10 @@ heap.push(undefined, null, true, false);
323
667
 
324
668
  let heap_next = heap.length;
325
669
 
670
+ function isLikeNone(x) {
671
+ return x === undefined || x === null;
672
+ }
673
+
326
674
  function passArray32ToWasm0(arg, malloc) {
327
675
  const ptr = malloc(arg.length * 4, 4) >>> 0;
328
676
  getUint32ArrayMemory0().set(arg, ptr / 4);
@@ -330,6 +678,16 @@ function passArray32ToWasm0(arg, malloc) {
330
678
  return ptr;
331
679
  }
332
680
 
681
+ function passArrayJsValueToWasm0(array, malloc) {
682
+ const ptr = malloc(array.length * 4, 4) >>> 0;
683
+ const mem = getDataViewMemory0();
684
+ for (let i = 0; i < array.length; i++) {
685
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
686
+ }
687
+ WASM_VECTOR_LEN = array.length;
688
+ return ptr;
689
+ }
690
+
333
691
  function passStringToWasm0(arg, malloc, realloc) {
334
692
  if (realloc === undefined) {
335
693
  const buf = cachedTextEncoder.encode(arg);
Binary file
@@ -2,19 +2,39 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_sourcemap_free: (a: number, b: number) => void;
5
+ export const resultPtr: () => number;
6
+ export const sourcemap_allGeneratedPositionsFor: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
7
+ export const sourcemap_allMappingsFlat: (a: number, b: number) => void;
5
8
  export const sourcemap_debugId: (a: number, b: number) => void;
9
+ export const sourcemap_encodedMappings: (a: number, b: number) => void;
10
+ export const sourcemap_encodedRangeMappings: (a: number) => number;
11
+ export const sourcemap_file: (a: number, b: number) => void;
12
+ export const sourcemap_fromVlq: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number) => void;
6
13
  export const sourcemap_generatedPositionFor: (a: number, b: number, c: number, d: number, e: number) => number;
14
+ export const sourcemap_generatedPositionForWithBias: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
15
+ export const sourcemap_hasRangeMappings: (a: number) => number;
16
+ export const sourcemap_ignoreList: (a: number, b: number) => void;
17
+ export const sourcemap_isIgnoredIndex: (a: number, b: number) => number;
7
18
  export const sourcemap_lineCount: (a: number) => number;
19
+ export const sourcemap_mapRange: (a: number, b: number, c: number, d: number, e: number) => number;
8
20
  export const sourcemap_mappingCount: (a: number) => number;
9
21
  export const sourcemap_name: (a: number, b: number, c: number) => void;
10
22
  export const sourcemap_names: (a: number, b: number) => void;
11
23
  export const sourcemap_new: (a: number, b: number, c: number) => void;
24
+ export const sourcemap_originalPositionBuf: (a: number, b: number, c: number) => number;
25
+ export const sourcemap_originalPositionFlat: (a: number, b: number, c: number, d: number) => void;
12
26
  export const sourcemap_originalPositionFor: (a: number, b: number, c: number) => number;
27
+ export const sourcemap_originalPositionForWithBias: (a: number, b: number, c: number, d: number) => number;
13
28
  export const sourcemap_originalPositionsFor: (a: number, b: number, c: number, d: number) => void;
29
+ export const sourcemap_rangeMappingCount: (a: number) => number;
14
30
  export const sourcemap_source: (a: number, b: number, c: number) => void;
31
+ export const sourcemap_sourceContentFor: (a: number, b: number) => number;
32
+ export const sourcemap_sourceRoot: (a: number, b: number) => void;
15
33
  export const sourcemap_sources: (a: number, b: number) => void;
16
- export const __wbindgen_export: (a: number) => void;
34
+ export const sourcemap_sourcesContent: (a: number, b: number) => void;
35
+ export const wasmMemory: () => number;
36
+ export const __wbindgen_export: (a: number, b: number) => number;
37
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
38
+ export const __wbindgen_export3: (a: number) => void;
17
39
  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;
40
+ export const __wbindgen_export4: (a: number, b: number, c: number) => void;