@srcmap/remapping-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-remapping-wasm",
|
|
3
|
+
"description": "WebAssembly bindings for srcmap-remapping",
|
|
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_remapping_wasm_bg.wasm",
|
|
12
|
+
"srcmap_remapping_wasm.js",
|
|
13
|
+
"srcmap_remapping_wasm.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"main": "srcmap_remapping_wasm.js",
|
|
16
|
+
"types": "srcmap_remapping_wasm.d.ts"
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class ConcatBuilder {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
/**
|
|
8
|
+
* Add a source map (as JSON string) at the given line offset.
|
|
9
|
+
*/
|
|
10
|
+
addMap(json: string, line_offset: number): void;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new concatenation builder.
|
|
13
|
+
*/
|
|
14
|
+
constructor(file?: string | null);
|
|
15
|
+
/**
|
|
16
|
+
* Finish and return the concatenated source map as a JSON string.
|
|
17
|
+
*/
|
|
18
|
+
toJSON(): string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Compose/remap source maps through a transform chain.
|
|
23
|
+
*
|
|
24
|
+
* `outer_json` is the final-stage source map as a JSON string.
|
|
25
|
+
* `loader` is a function that receives a source filename and should return
|
|
26
|
+
* the upstream source map JSON string, or null/undefined if none.
|
|
27
|
+
*
|
|
28
|
+
* Returns the remapped source map as a JSON string.
|
|
29
|
+
*/
|
|
30
|
+
export function remap(outer_json: string, loader: Function): string;
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/* @ts-self-types="./srcmap_remapping_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
class ConcatBuilder {
|
|
4
|
+
__destroy_into_raw() {
|
|
5
|
+
const ptr = this.__wbg_ptr;
|
|
6
|
+
this.__wbg_ptr = 0;
|
|
7
|
+
ConcatBuilderFinalization.unregister(this);
|
|
8
|
+
return ptr;
|
|
9
|
+
}
|
|
10
|
+
free() {
|
|
11
|
+
const ptr = this.__destroy_into_raw();
|
|
12
|
+
wasm.__wbg_concatbuilder_free(ptr, 0);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Add a source map (as JSON string) at the given line offset.
|
|
16
|
+
* @param {string} json
|
|
17
|
+
* @param {number} line_offset
|
|
18
|
+
*/
|
|
19
|
+
addMap(json, line_offset) {
|
|
20
|
+
try {
|
|
21
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
22
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
23
|
+
const len0 = WASM_VECTOR_LEN;
|
|
24
|
+
wasm.concatbuilder_addMap(retptr, this.__wbg_ptr, ptr0, len0, line_offset);
|
|
25
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
26
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
27
|
+
if (r1) {
|
|
28
|
+
throw takeObject(r0);
|
|
29
|
+
}
|
|
30
|
+
} finally {
|
|
31
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a new concatenation builder.
|
|
36
|
+
* @param {string | null} [file]
|
|
37
|
+
*/
|
|
38
|
+
constructor(file) {
|
|
39
|
+
var ptr0 = isLikeNone(file) ? 0 : passStringToWasm0(file, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
40
|
+
var len0 = WASM_VECTOR_LEN;
|
|
41
|
+
const ret = wasm.concatbuilder_new(ptr0, len0);
|
|
42
|
+
this.__wbg_ptr = ret >>> 0;
|
|
43
|
+
ConcatBuilderFinalization.register(this, this.__wbg_ptr, this);
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Finish and return the concatenated source map as a JSON string.
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
toJSON() {
|
|
51
|
+
let deferred1_0;
|
|
52
|
+
let deferred1_1;
|
|
53
|
+
try {
|
|
54
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
55
|
+
wasm.concatbuilder_toJSON(retptr, this.__wbg_ptr);
|
|
56
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
57
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
58
|
+
deferred1_0 = r0;
|
|
59
|
+
deferred1_1 = r1;
|
|
60
|
+
return getStringFromWasm0(r0, r1);
|
|
61
|
+
} finally {
|
|
62
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
63
|
+
wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (Symbol.dispose) ConcatBuilder.prototype[Symbol.dispose] = ConcatBuilder.prototype.free;
|
|
68
|
+
exports.ConcatBuilder = ConcatBuilder;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Compose/remap source maps through a transform chain.
|
|
72
|
+
*
|
|
73
|
+
* `outer_json` is the final-stage source map as a JSON string.
|
|
74
|
+
* `loader` is a function that receives a source filename and should return
|
|
75
|
+
* the upstream source map JSON string, or null/undefined if none.
|
|
76
|
+
*
|
|
77
|
+
* Returns the remapped source map as a JSON string.
|
|
78
|
+
* @param {string} outer_json
|
|
79
|
+
* @param {Function} loader
|
|
80
|
+
* @returns {string}
|
|
81
|
+
*/
|
|
82
|
+
function remap(outer_json, loader) {
|
|
83
|
+
let deferred3_0;
|
|
84
|
+
let deferred3_1;
|
|
85
|
+
try {
|
|
86
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
87
|
+
const ptr0 = passStringToWasm0(outer_json, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
88
|
+
const len0 = WASM_VECTOR_LEN;
|
|
89
|
+
wasm.remap(retptr, ptr0, len0, addBorrowedObject(loader));
|
|
90
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
91
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
92
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
93
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
94
|
+
var ptr2 = r0;
|
|
95
|
+
var len2 = r1;
|
|
96
|
+
if (r3) {
|
|
97
|
+
ptr2 = 0; len2 = 0;
|
|
98
|
+
throw takeObject(r2);
|
|
99
|
+
}
|
|
100
|
+
deferred3_0 = ptr2;
|
|
101
|
+
deferred3_1 = len2;
|
|
102
|
+
return getStringFromWasm0(ptr2, len2);
|
|
103
|
+
} finally {
|
|
104
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
105
|
+
heap[stack_pointer++] = undefined;
|
|
106
|
+
wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.remap = remap;
|
|
110
|
+
|
|
111
|
+
function __wbg_get_imports() {
|
|
112
|
+
const import0 = {
|
|
113
|
+
__proto__: null,
|
|
114
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
115
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
116
|
+
return addHeapObject(ret);
|
|
117
|
+
},
|
|
118
|
+
__wbg___wbindgen_is_null_0b605fc6b167c56f: function(arg0) {
|
|
119
|
+
const ret = getObject(arg0) === null;
|
|
120
|
+
return ret;
|
|
121
|
+
},
|
|
122
|
+
__wbg___wbindgen_is_undefined_52709e72fb9f179c: function(arg0) {
|
|
123
|
+
const ret = getObject(arg0) === undefined;
|
|
124
|
+
return ret;
|
|
125
|
+
},
|
|
126
|
+
__wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
|
|
127
|
+
const obj = getObject(arg1);
|
|
128
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
129
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
130
|
+
var len1 = WASM_VECTOR_LEN;
|
|
131
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
132
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
133
|
+
},
|
|
134
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
135
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
136
|
+
},
|
|
137
|
+
__wbg_call_2d781c1f4d5c0ef8: function() { return handleError(function (arg0, arg1, arg2) {
|
|
138
|
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
139
|
+
return addHeapObject(ret);
|
|
140
|
+
}, arguments); },
|
|
141
|
+
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
142
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
143
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
144
|
+
return addHeapObject(ret);
|
|
145
|
+
},
|
|
146
|
+
__wbindgen_object_drop_ref: function(arg0) {
|
|
147
|
+
takeObject(arg0);
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
__proto__: null,
|
|
152
|
+
"./srcmap_remapping_wasm_bg.js": import0,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const ConcatBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
157
|
+
? { register: () => {}, unregister: () => {} }
|
|
158
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_concatbuilder_free(ptr >>> 0, 1));
|
|
159
|
+
|
|
160
|
+
function addHeapObject(obj) {
|
|
161
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
162
|
+
const idx = heap_next;
|
|
163
|
+
heap_next = heap[idx];
|
|
164
|
+
|
|
165
|
+
heap[idx] = obj;
|
|
166
|
+
return idx;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function addBorrowedObject(obj) {
|
|
170
|
+
if (stack_pointer == 1) throw new Error('out of js stack');
|
|
171
|
+
heap[--stack_pointer] = obj;
|
|
172
|
+
return stack_pointer;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function dropObject(idx) {
|
|
176
|
+
if (idx < 1028) return;
|
|
177
|
+
heap[idx] = heap_next;
|
|
178
|
+
heap_next = idx;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let cachedDataViewMemory0 = null;
|
|
182
|
+
function getDataViewMemory0() {
|
|
183
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
184
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
185
|
+
}
|
|
186
|
+
return cachedDataViewMemory0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function getStringFromWasm0(ptr, len) {
|
|
190
|
+
ptr = ptr >>> 0;
|
|
191
|
+
return decodeText(ptr, len);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
let cachedUint8ArrayMemory0 = null;
|
|
195
|
+
function getUint8ArrayMemory0() {
|
|
196
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
197
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
198
|
+
}
|
|
199
|
+
return cachedUint8ArrayMemory0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function getObject(idx) { return heap[idx]; }
|
|
203
|
+
|
|
204
|
+
function handleError(f, args) {
|
|
205
|
+
try {
|
|
206
|
+
return f.apply(this, args);
|
|
207
|
+
} catch (e) {
|
|
208
|
+
wasm.__wbindgen_export3(addHeapObject(e));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
let heap = new Array(1024).fill(undefined);
|
|
213
|
+
heap.push(undefined, null, true, false);
|
|
214
|
+
|
|
215
|
+
let heap_next = heap.length;
|
|
216
|
+
|
|
217
|
+
function isLikeNone(x) {
|
|
218
|
+
return x === undefined || x === null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
222
|
+
if (realloc === undefined) {
|
|
223
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
224
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
225
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
226
|
+
WASM_VECTOR_LEN = buf.length;
|
|
227
|
+
return ptr;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
let len = arg.length;
|
|
231
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
232
|
+
|
|
233
|
+
const mem = getUint8ArrayMemory0();
|
|
234
|
+
|
|
235
|
+
let offset = 0;
|
|
236
|
+
|
|
237
|
+
for (; offset < len; offset++) {
|
|
238
|
+
const code = arg.charCodeAt(offset);
|
|
239
|
+
if (code > 0x7F) break;
|
|
240
|
+
mem[ptr + offset] = code;
|
|
241
|
+
}
|
|
242
|
+
if (offset !== len) {
|
|
243
|
+
if (offset !== 0) {
|
|
244
|
+
arg = arg.slice(offset);
|
|
245
|
+
}
|
|
246
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
247
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
248
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
249
|
+
|
|
250
|
+
offset += ret.written;
|
|
251
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
WASM_VECTOR_LEN = offset;
|
|
255
|
+
return ptr;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
let stack_pointer = 1024;
|
|
259
|
+
|
|
260
|
+
function takeObject(idx) {
|
|
261
|
+
const ret = getObject(idx);
|
|
262
|
+
dropObject(idx);
|
|
263
|
+
return ret;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
267
|
+
cachedTextDecoder.decode();
|
|
268
|
+
function decodeText(ptr, len) {
|
|
269
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const cachedTextEncoder = new TextEncoder();
|
|
273
|
+
|
|
274
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
275
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
276
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
277
|
+
view.set(buf);
|
|
278
|
+
return {
|
|
279
|
+
read: arg.length,
|
|
280
|
+
written: buf.length
|
|
281
|
+
};
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
let WASM_VECTOR_LEN = 0;
|
|
286
|
+
|
|
287
|
+
const wasmPath = `${__dirname}/srcmap_remapping_wasm_bg.wasm`;
|
|
288
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
289
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
290
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_concatbuilder_free: (a: number, b: number) => void;
|
|
5
|
+
export const concatbuilder_addMap: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
6
|
+
export const concatbuilder_new: (a: number, b: number) => number;
|
|
7
|
+
export const concatbuilder_toJSON: (a: number, b: number) => void;
|
|
8
|
+
export const remap: (a: number, b: number, c: number, d: number) => void;
|
|
9
|
+
export const __wbindgen_export: (a: number, b: number) => number;
|
|
10
|
+
export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
11
|
+
export const __wbindgen_export3: (a: number) => void;
|
|
12
|
+
export const __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
13
|
+
export const __wbindgen_export4: (a: number, b: number, c: number) => void;
|