@srcmap/generator-wasm 0.1.2 → 0.2.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/README.md +91 -0
- package/package.json +18 -6
- package/pkg/README.md +91 -0
- package/pkg/package.json +17 -0
- package/pkg/srcmap_generator_wasm.d.ts +60 -0
- package/pkg/srcmap_generator_wasm.js +263 -0
- package/pkg/srcmap_generator_wasm_bg.wasm +0 -0
- package/pkg/srcmap_generator_wasm_bg.wasm.d.ts +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @srcmap/generator-wasm
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@srcmap/generator-wasm)
|
|
4
|
+
[](https://github.com/BartWaardenburg/srcmap/actions/workflows/ci.yml)
|
|
5
|
+
|
|
6
|
+
High-performance source map generator powered by Rust via WebAssembly.
|
|
7
|
+
|
|
8
|
+
Builds source maps incrementally by registering sources, names, and mappings. Outputs standard source map v3 JSON (ECMA-426). Alternative to [`source-map`](https://github.com/nicolo-ribaudo/source-map-js)'s `SourceMapGenerator`.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @srcmap/generator-wasm
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Works in Node.js, browsers, and any WebAssembly-capable runtime. No native compilation required.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import { SourceMapGenerator } from '@srcmap/generator-wasm'
|
|
22
|
+
|
|
23
|
+
const gen = new SourceMapGenerator('bundle.js')
|
|
24
|
+
|
|
25
|
+
// Register sources and names (returns indices for use in mappings)
|
|
26
|
+
const src = gen.addSource('src/app.ts')
|
|
27
|
+
gen.setSourceContent(src, 'const x = 1;')
|
|
28
|
+
|
|
29
|
+
const name = gen.addName('x')
|
|
30
|
+
|
|
31
|
+
// Add mappings (all positions are 0-based)
|
|
32
|
+
gen.addNamedMapping(0, 0, src, 0, 6, name) // generated(0:0) -> original(0:6) name:"x"
|
|
33
|
+
gen.addMapping(1, 0, src, 1, 0) // generated(1:0) -> original(1:0)
|
|
34
|
+
|
|
35
|
+
// Deduplicated mapping: only adds if different from previous on same line
|
|
36
|
+
gen.maybeAddMapping(1, 4, src, 1, 4)
|
|
37
|
+
|
|
38
|
+
const json = gen.toJSON()
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API
|
|
42
|
+
|
|
43
|
+
### `new SourceMapGenerator(file?: string)`
|
|
44
|
+
|
|
45
|
+
Create a new source map generator. `file` is the optional output filename.
|
|
46
|
+
|
|
47
|
+
### Instance methods
|
|
48
|
+
|
|
49
|
+
| Method | Returns | Description |
|
|
50
|
+
|--------|---------|-------------|
|
|
51
|
+
| `addSource(source)` | `number` | Register a source file, returns its index |
|
|
52
|
+
| `addName(name)` | `number` | Register a name, returns its index |
|
|
53
|
+
| `setSourceRoot(root)` | `void` | Set the `sourceRoot` prefix |
|
|
54
|
+
| `setDebugId(id)` | `void` | Set the debug ID (ECMA-426) |
|
|
55
|
+
| `setSourceContent(sourceIdx, content)` | `void` | Attach source content to a source |
|
|
56
|
+
| `addToIgnoreList(sourceIdx)` | `void` | Add a source to the `ignoreList` |
|
|
57
|
+
| `addGeneratedMapping(genLine, genCol)` | `void` | Add a mapping with no source info |
|
|
58
|
+
| `addMapping(genLine, genCol, src, origLine, origCol)` | `void` | Add a mapping |
|
|
59
|
+
| `addNamedMapping(genLine, genCol, src, origLine, origCol, name)` | `void` | Add a mapping with a name |
|
|
60
|
+
| `maybeAddMapping(genLine, genCol, src, origLine, origCol)` | `boolean` | Add only if different from previous |
|
|
61
|
+
| `toJSON()` | `string` | Generate the source map JSON string |
|
|
62
|
+
|
|
63
|
+
### Instance properties
|
|
64
|
+
|
|
65
|
+
| Property | Type | Description |
|
|
66
|
+
|----------|------|-------------|
|
|
67
|
+
| `mappingCount` | `number` | Total number of mappings added |
|
|
68
|
+
|
|
69
|
+
## Build targets
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Node.js (default)
|
|
73
|
+
npm run build
|
|
74
|
+
|
|
75
|
+
# Browser (ES module + .wasm)
|
|
76
|
+
npm run build:web
|
|
77
|
+
|
|
78
|
+
# Bundler (e.g. webpack, vite)
|
|
79
|
+
npm run build:bundler
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Part of [srcmap](https://github.com/BartWaardenburg/srcmap)
|
|
83
|
+
|
|
84
|
+
High-performance source map tooling written in Rust. See also:
|
|
85
|
+
- [`@srcmap/sourcemap-wasm`](https://www.npmjs.com/package/@srcmap/sourcemap-wasm) - Source map parser (WASM)
|
|
86
|
+
- [`@srcmap/remapping-wasm`](https://www.npmjs.com/package/@srcmap/remapping-wasm) - Concatenation + composition (WASM)
|
|
87
|
+
- [`@srcmap/symbolicate-wasm`](https://www.npmjs.com/package/@srcmap/symbolicate-wasm) - Stack trace symbolication (WASM)
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@srcmap/generator-wasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "High-performance source map generator powered by Rust (WebAssembly)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "pkg/srcmap_generator_wasm.js",
|
|
7
7
|
"types": "pkg/srcmap_generator_wasm.d.ts",
|
|
8
|
+
"browser": "web/srcmap_generator_wasm.js",
|
|
9
|
+
"module": "web/srcmap_generator_wasm.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"node": "./pkg/srcmap_generator_wasm.js",
|
|
13
|
+
"browser": "./web/srcmap_generator_wasm.js",
|
|
14
|
+
"default": "./pkg/srcmap_generator_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__/generator-wasm.test.mjs"
|
|
18
29
|
},
|
|
19
30
|
"repository": {
|
|
20
31
|
"type": "git",
|
|
21
|
-
"url": "https://github.com/BartWaardenburg/srcmap"
|
|
32
|
+
"url": "git+https://github.com/BartWaardenburg/srcmap.git"
|
|
22
33
|
},
|
|
23
34
|
"keywords": [
|
|
24
35
|
"sourcemap",
|
|
@@ -28,6 +39,7 @@
|
|
|
28
39
|
"rust",
|
|
29
40
|
"wasm",
|
|
30
41
|
"webassembly",
|
|
31
|
-
"performance"
|
|
42
|
+
"performance",
|
|
43
|
+
"browser"
|
|
32
44
|
]
|
|
33
45
|
}
|
package/pkg/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# @srcmap/generator-wasm
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@srcmap/generator-wasm)
|
|
4
|
+
[](https://github.com/BartWaardenburg/srcmap/actions/workflows/ci.yml)
|
|
5
|
+
|
|
6
|
+
High-performance source map generator powered by Rust via WebAssembly.
|
|
7
|
+
|
|
8
|
+
Builds source maps incrementally by registering sources, names, and mappings. Outputs standard source map v3 JSON (ECMA-426). Alternative to [`source-map`](https://github.com/nicolo-ribaudo/source-map-js)'s `SourceMapGenerator`.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @srcmap/generator-wasm
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Works in Node.js, browsers, and any WebAssembly-capable runtime. No native compilation required.
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import { SourceMapGenerator } from '@srcmap/generator-wasm'
|
|
22
|
+
|
|
23
|
+
const gen = new SourceMapGenerator('bundle.js')
|
|
24
|
+
|
|
25
|
+
// Register sources and names (returns indices for use in mappings)
|
|
26
|
+
const src = gen.addSource('src/app.ts')
|
|
27
|
+
gen.setSourceContent(src, 'const x = 1;')
|
|
28
|
+
|
|
29
|
+
const name = gen.addName('x')
|
|
30
|
+
|
|
31
|
+
// Add mappings (all positions are 0-based)
|
|
32
|
+
gen.addNamedMapping(0, 0, src, 0, 6, name) // generated(0:0) -> original(0:6) name:"x"
|
|
33
|
+
gen.addMapping(1, 0, src, 1, 0) // generated(1:0) -> original(1:0)
|
|
34
|
+
|
|
35
|
+
// Deduplicated mapping: only adds if different from previous on same line
|
|
36
|
+
gen.maybeAddMapping(1, 4, src, 1, 4)
|
|
37
|
+
|
|
38
|
+
const json = gen.toJSON()
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API
|
|
42
|
+
|
|
43
|
+
### `new SourceMapGenerator(file?: string)`
|
|
44
|
+
|
|
45
|
+
Create a new source map generator. `file` is the optional output filename.
|
|
46
|
+
|
|
47
|
+
### Instance methods
|
|
48
|
+
|
|
49
|
+
| Method | Returns | Description |
|
|
50
|
+
|--------|---------|-------------|
|
|
51
|
+
| `addSource(source)` | `number` | Register a source file, returns its index |
|
|
52
|
+
| `addName(name)` | `number` | Register a name, returns its index |
|
|
53
|
+
| `setSourceRoot(root)` | `void` | Set the `sourceRoot` prefix |
|
|
54
|
+
| `setDebugId(id)` | `void` | Set the debug ID (ECMA-426) |
|
|
55
|
+
| `setSourceContent(sourceIdx, content)` | `void` | Attach source content to a source |
|
|
56
|
+
| `addToIgnoreList(sourceIdx)` | `void` | Add a source to the `ignoreList` |
|
|
57
|
+
| `addGeneratedMapping(genLine, genCol)` | `void` | Add a mapping with no source info |
|
|
58
|
+
| `addMapping(genLine, genCol, src, origLine, origCol)` | `void` | Add a mapping |
|
|
59
|
+
| `addNamedMapping(genLine, genCol, src, origLine, origCol, name)` | `void` | Add a mapping with a name |
|
|
60
|
+
| `maybeAddMapping(genLine, genCol, src, origLine, origCol)` | `boolean` | Add only if different from previous |
|
|
61
|
+
| `toJSON()` | `string` | Generate the source map JSON string |
|
|
62
|
+
|
|
63
|
+
### Instance properties
|
|
64
|
+
|
|
65
|
+
| Property | Type | Description |
|
|
66
|
+
|----------|------|-------------|
|
|
67
|
+
| `mappingCount` | `number` | Total number of mappings added |
|
|
68
|
+
|
|
69
|
+
## Build targets
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
# Node.js (default)
|
|
73
|
+
npm run build
|
|
74
|
+
|
|
75
|
+
# Browser (ES module + .wasm)
|
|
76
|
+
npm run build:web
|
|
77
|
+
|
|
78
|
+
# Bundler (e.g. webpack, vite)
|
|
79
|
+
npm run build:bundler
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Part of [srcmap](https://github.com/BartWaardenburg/srcmap)
|
|
83
|
+
|
|
84
|
+
High-performance source map tooling written in Rust. See also:
|
|
85
|
+
- [`@srcmap/sourcemap-wasm`](https://www.npmjs.com/package/@srcmap/sourcemap-wasm) - Source map parser (WASM)
|
|
86
|
+
- [`@srcmap/remapping-wasm`](https://www.npmjs.com/package/@srcmap/remapping-wasm) - Concatenation + composition (WASM)
|
|
87
|
+
- [`@srcmap/symbolicate-wasm`](https://www.npmjs.com/package/@srcmap/symbolicate-wasm) - Stack trace symbolication (WASM)
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
package/pkg/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "srcmap-generator-wasm",
|
|
3
|
+
"description": "WebAssembly bindings for srcmap-generator",
|
|
4
|
+
"version": "0.2.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/BartWaardenburg/srcmap"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"srcmap_generator_wasm_bg.wasm",
|
|
12
|
+
"srcmap_generator_wasm.js",
|
|
13
|
+
"srcmap_generator_wasm.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "srcmap_generator_wasm.js",
|
|
16
|
+
"types": "srcmap_generator_wasm.d.ts"
|
|
17
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class SourceMapGenerator {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
/**
|
|
8
|
+
* Add a mapping with no source information (generated-only).
|
|
9
|
+
*/
|
|
10
|
+
addGeneratedMapping(generated_line: number, generated_column: number): void;
|
|
11
|
+
/**
|
|
12
|
+
* Add a mapping from generated position to original position.
|
|
13
|
+
*/
|
|
14
|
+
addMapping(generated_line: number, generated_column: number, source: number, original_line: number, original_column: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* Register a name and return its index.
|
|
17
|
+
*/
|
|
18
|
+
addName(name: string): number;
|
|
19
|
+
/**
|
|
20
|
+
* Add a mapping with a name.
|
|
21
|
+
*/
|
|
22
|
+
addNamedMapping(generated_line: number, generated_column: number, source: number, original_line: number, original_column: number, name: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Register a source file and return its index.
|
|
25
|
+
*/
|
|
26
|
+
addSource(source: string): number;
|
|
27
|
+
/**
|
|
28
|
+
* Add a source index to the ignore list.
|
|
29
|
+
*/
|
|
30
|
+
addToIgnoreList(source_idx: number): void;
|
|
31
|
+
/**
|
|
32
|
+
* Add a mapping only if it differs from the previous mapping on the same line.
|
|
33
|
+
* Returns true if the mapping was added, false if skipped.
|
|
34
|
+
*/
|
|
35
|
+
maybeAddMapping(generated_line: number, generated_column: number, source: number, original_line: number, original_column: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Create a new source map generator.
|
|
38
|
+
*/
|
|
39
|
+
constructor(file?: string | null);
|
|
40
|
+
/**
|
|
41
|
+
* Set the debug ID (UUID) for this source map (ECMA-426).
|
|
42
|
+
*/
|
|
43
|
+
setDebugId(id: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Set the content for a source file by index.
|
|
46
|
+
*/
|
|
47
|
+
setSourceContent(source_idx: number, content: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Set the source root prefix.
|
|
50
|
+
*/
|
|
51
|
+
setSourceRoot(root: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Generate the source map as a JSON string.
|
|
54
|
+
*/
|
|
55
|
+
toJSON(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Get the number of mappings.
|
|
58
|
+
*/
|
|
59
|
+
readonly mappingCount: number;
|
|
60
|
+
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/* @ts-self-types="./srcmap_generator_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
class SourceMapGenerator {
|
|
4
|
+
__destroy_into_raw() {
|
|
5
|
+
const ptr = this.__wbg_ptr;
|
|
6
|
+
this.__wbg_ptr = 0;
|
|
7
|
+
SourceMapGeneratorFinalization.unregister(this);
|
|
8
|
+
return ptr;
|
|
9
|
+
}
|
|
10
|
+
free() {
|
|
11
|
+
const ptr = this.__destroy_into_raw();
|
|
12
|
+
wasm.__wbg_sourcemapgenerator_free(ptr, 0);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Add a mapping with no source information (generated-only).
|
|
16
|
+
* @param {number} generated_line
|
|
17
|
+
* @param {number} generated_column
|
|
18
|
+
*/
|
|
19
|
+
addGeneratedMapping(generated_line, generated_column) {
|
|
20
|
+
wasm.sourcemapgenerator_addGeneratedMapping(this.__wbg_ptr, generated_line, generated_column);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Add a mapping from generated position to original position.
|
|
24
|
+
* @param {number} generated_line
|
|
25
|
+
* @param {number} generated_column
|
|
26
|
+
* @param {number} source
|
|
27
|
+
* @param {number} original_line
|
|
28
|
+
* @param {number} original_column
|
|
29
|
+
*/
|
|
30
|
+
addMapping(generated_line, generated_column, source, original_line, original_column) {
|
|
31
|
+
wasm.sourcemapgenerator_addMapping(this.__wbg_ptr, generated_line, generated_column, source, original_line, original_column);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register a name and return its index.
|
|
35
|
+
* @param {string} name
|
|
36
|
+
* @returns {number}
|
|
37
|
+
*/
|
|
38
|
+
addName(name) {
|
|
39
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
40
|
+
const len0 = WASM_VECTOR_LEN;
|
|
41
|
+
const ret = wasm.sourcemapgenerator_addName(this.__wbg_ptr, ptr0, len0);
|
|
42
|
+
return ret >>> 0;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Add a mapping with a name.
|
|
46
|
+
* @param {number} generated_line
|
|
47
|
+
* @param {number} generated_column
|
|
48
|
+
* @param {number} source
|
|
49
|
+
* @param {number} original_line
|
|
50
|
+
* @param {number} original_column
|
|
51
|
+
* @param {number} name
|
|
52
|
+
*/
|
|
53
|
+
addNamedMapping(generated_line, generated_column, source, original_line, original_column, name) {
|
|
54
|
+
wasm.sourcemapgenerator_addNamedMapping(this.__wbg_ptr, generated_line, generated_column, source, original_line, original_column, name);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Register a source file and return its index.
|
|
58
|
+
* @param {string} source
|
|
59
|
+
* @returns {number}
|
|
60
|
+
*/
|
|
61
|
+
addSource(source) {
|
|
62
|
+
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
63
|
+
const len0 = WASM_VECTOR_LEN;
|
|
64
|
+
const ret = wasm.sourcemapgenerator_addSource(this.__wbg_ptr, ptr0, len0);
|
|
65
|
+
return ret >>> 0;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Add a source index to the ignore list.
|
|
69
|
+
* @param {number} source_idx
|
|
70
|
+
*/
|
|
71
|
+
addToIgnoreList(source_idx) {
|
|
72
|
+
wasm.sourcemapgenerator_addToIgnoreList(this.__wbg_ptr, source_idx);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the number of mappings.
|
|
76
|
+
* @returns {number}
|
|
77
|
+
*/
|
|
78
|
+
get mappingCount() {
|
|
79
|
+
const ret = wasm.sourcemapgenerator_mappingCount(this.__wbg_ptr);
|
|
80
|
+
return ret >>> 0;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Add a mapping only if it differs from the previous mapping on the same line.
|
|
84
|
+
* Returns true if the mapping was added, false if skipped.
|
|
85
|
+
* @param {number} generated_line
|
|
86
|
+
* @param {number} generated_column
|
|
87
|
+
* @param {number} source
|
|
88
|
+
* @param {number} original_line
|
|
89
|
+
* @param {number} original_column
|
|
90
|
+
* @returns {boolean}
|
|
91
|
+
*/
|
|
92
|
+
maybeAddMapping(generated_line, generated_column, source, original_line, original_column) {
|
|
93
|
+
const ret = wasm.sourcemapgenerator_maybeAddMapping(this.__wbg_ptr, generated_line, generated_column, source, original_line, original_column);
|
|
94
|
+
return ret !== 0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create a new source map generator.
|
|
98
|
+
* @param {string | null} [file]
|
|
99
|
+
*/
|
|
100
|
+
constructor(file) {
|
|
101
|
+
var ptr0 = isLikeNone(file) ? 0 : passStringToWasm0(file, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
102
|
+
var len0 = WASM_VECTOR_LEN;
|
|
103
|
+
const ret = wasm.sourcemapgenerator_new(ptr0, len0);
|
|
104
|
+
this.__wbg_ptr = ret >>> 0;
|
|
105
|
+
SourceMapGeneratorFinalization.register(this, this.__wbg_ptr, this);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Set the debug ID (UUID) for this source map (ECMA-426).
|
|
110
|
+
* @param {string} id
|
|
111
|
+
*/
|
|
112
|
+
setDebugId(id) {
|
|
113
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
114
|
+
const len0 = WASM_VECTOR_LEN;
|
|
115
|
+
wasm.sourcemapgenerator_setDebugId(this.__wbg_ptr, ptr0, len0);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Set the content for a source file by index.
|
|
119
|
+
* @param {number} source_idx
|
|
120
|
+
* @param {string} content
|
|
121
|
+
*/
|
|
122
|
+
setSourceContent(source_idx, content) {
|
|
123
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
125
|
+
wasm.sourcemapgenerator_setSourceContent(this.__wbg_ptr, source_idx, ptr0, len0);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Set the source root prefix.
|
|
129
|
+
* @param {string} root
|
|
130
|
+
*/
|
|
131
|
+
setSourceRoot(root) {
|
|
132
|
+
const ptr0 = passStringToWasm0(root, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
133
|
+
const len0 = WASM_VECTOR_LEN;
|
|
134
|
+
wasm.sourcemapgenerator_setSourceRoot(this.__wbg_ptr, ptr0, len0);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Generate the source map as a JSON string.
|
|
138
|
+
* @returns {string}
|
|
139
|
+
*/
|
|
140
|
+
toJSON() {
|
|
141
|
+
let deferred1_0;
|
|
142
|
+
let deferred1_1;
|
|
143
|
+
try {
|
|
144
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
145
|
+
wasm.sourcemapgenerator_toJSON(retptr, this.__wbg_ptr);
|
|
146
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
147
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
148
|
+
deferred1_0 = r0;
|
|
149
|
+
deferred1_1 = r1;
|
|
150
|
+
return getStringFromWasm0(r0, r1);
|
|
151
|
+
} finally {
|
|
152
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
153
|
+
wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (Symbol.dispose) SourceMapGenerator.prototype[Symbol.dispose] = SourceMapGenerator.prototype.free;
|
|
158
|
+
exports.SourceMapGenerator = SourceMapGenerator;
|
|
159
|
+
|
|
160
|
+
function __wbg_get_imports() {
|
|
161
|
+
const import0 = {
|
|
162
|
+
__proto__: null,
|
|
163
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
164
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
return {
|
|
168
|
+
__proto__: null,
|
|
169
|
+
"./srcmap_generator_wasm_bg.js": import0,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const SourceMapGeneratorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
174
|
+
? { register: () => {}, unregister: () => {} }
|
|
175
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_sourcemapgenerator_free(ptr >>> 0, 1));
|
|
176
|
+
|
|
177
|
+
let cachedDataViewMemory0 = null;
|
|
178
|
+
function getDataViewMemory0() {
|
|
179
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
180
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
181
|
+
}
|
|
182
|
+
return cachedDataViewMemory0;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function getStringFromWasm0(ptr, len) {
|
|
186
|
+
ptr = ptr >>> 0;
|
|
187
|
+
return decodeText(ptr, len);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let cachedUint8ArrayMemory0 = null;
|
|
191
|
+
function getUint8ArrayMemory0() {
|
|
192
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
193
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
194
|
+
}
|
|
195
|
+
return cachedUint8ArrayMemory0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function isLikeNone(x) {
|
|
199
|
+
return x === undefined || x === null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
203
|
+
if (realloc === undefined) {
|
|
204
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
205
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
206
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
207
|
+
WASM_VECTOR_LEN = buf.length;
|
|
208
|
+
return ptr;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let len = arg.length;
|
|
212
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
213
|
+
|
|
214
|
+
const mem = getUint8ArrayMemory0();
|
|
215
|
+
|
|
216
|
+
let offset = 0;
|
|
217
|
+
|
|
218
|
+
for (; offset < len; offset++) {
|
|
219
|
+
const code = arg.charCodeAt(offset);
|
|
220
|
+
if (code > 0x7F) break;
|
|
221
|
+
mem[ptr + offset] = code;
|
|
222
|
+
}
|
|
223
|
+
if (offset !== len) {
|
|
224
|
+
if (offset !== 0) {
|
|
225
|
+
arg = arg.slice(offset);
|
|
226
|
+
}
|
|
227
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
228
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
229
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
230
|
+
|
|
231
|
+
offset += ret.written;
|
|
232
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
WASM_VECTOR_LEN = offset;
|
|
236
|
+
return ptr;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
240
|
+
cachedTextDecoder.decode();
|
|
241
|
+
function decodeText(ptr, len) {
|
|
242
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const cachedTextEncoder = new TextEncoder();
|
|
246
|
+
|
|
247
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
248
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
249
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
250
|
+
view.set(buf);
|
|
251
|
+
return {
|
|
252
|
+
read: arg.length,
|
|
253
|
+
written: buf.length
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let WASM_VECTOR_LEN = 0;
|
|
259
|
+
|
|
260
|
+
const wasmPath = `${__dirname}/srcmap_generator_wasm_bg.wasm`;
|
|
261
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
262
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
263
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_sourcemapgenerator_free: (a: number, b: number) => void;
|
|
5
|
+
export const sourcemapgenerator_addGeneratedMapping: (a: number, b: number, c: number) => void;
|
|
6
|
+
export const sourcemapgenerator_addMapping: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
7
|
+
export const sourcemapgenerator_addName: (a: number, b: number, c: number) => number;
|
|
8
|
+
export const sourcemapgenerator_addNamedMapping: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
9
|
+
export const sourcemapgenerator_addSource: (a: number, b: number, c: number) => number;
|
|
10
|
+
export const sourcemapgenerator_addToIgnoreList: (a: number, b: number) => void;
|
|
11
|
+
export const sourcemapgenerator_mappingCount: (a: number) => number;
|
|
12
|
+
export const sourcemapgenerator_maybeAddMapping: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
13
|
+
export const sourcemapgenerator_new: (a: number, b: number) => number;
|
|
14
|
+
export const sourcemapgenerator_setDebugId: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const sourcemapgenerator_setSourceContent: (a: number, b: number, c: number, d: number) => void;
|
|
16
|
+
export const sourcemapgenerator_setSourceRoot: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const sourcemapgenerator_toJSON: (a: number, b: number) => void;
|
|
18
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
19
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
20
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
21
|
+
export const __wbindgen_export3: (a: number, b: number, c: number) => void;
|