@srcmap/generator-wasm 0.1.2 → 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/package.json
CHANGED
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.1.2",
|
|
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;
|