@srcmap/generator-wasm 0.1.3 → 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 +2 -2
- package/pkg/srcmap_generator_wasm_bg.wasm +0 -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
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srcmap-generator-wasm",
|
|
3
3
|
"description": "WebAssembly bindings for srcmap-generator",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/
|
|
8
|
+
"url": "https://github.com/BartWaardenburg/srcmap"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"srcmap_generator_wasm_bg.wasm",
|
|
Binary file
|