@sentry/wasm 6.19.7 → 7.0.0-beta.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/{dist → cjs}/index.d.ts +0 -0
- package/{dist → cjs}/index.d.ts.map +1 -1
- package/{dist → cjs}/index.js +21 -26
- package/cjs/index.js.map +1 -0
- package/{dist → cjs}/patchWebAssembly.d.ts +0 -0
- package/{dist → cjs}/patchWebAssembly.d.ts.map +0 -0
- package/{dist → cjs}/patchWebAssembly.js +7 -7
- package/cjs/patchWebAssembly.js.map +1 -0
- package/{dist → cjs}/registry.d.ts +0 -0
- package/{dist → cjs}/registry.d.ts.map +0 -0
- package/{dist → cjs}/registry.js +13 -13
- package/{dist → cjs}/registry.js.map +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +19 -25
- package/esm/index.js.map +1 -1
- package/esm/patchWebAssembly.js +6 -6
- package/esm/patchWebAssembly.js.map +1 -1
- package/esm/registry.js +14 -14
- package/esm/registry.js.map +1 -1
- package/package.json +5 -5
- package/types/index.d.ts.map +1 -1
- package/dist/index.js.map +0 -1
- package/dist/patchWebAssembly.js.map +0 -1
package/{dist → cjs}/index.d.ts
RENAMED
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAc,MAAM,eAAe,CAAC;AA2BpF;;;;;GAKG;AACH,qBAAa,IAAK,YAAW,WAAW;IACtC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAU;IAElC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAW;IAE9B;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAc,MAAM,eAAe,CAAC;AA2BpF;;;;;GAKG;AACH,qBAAa,IAAK,YAAW,WAAW;IACtC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAU;IAElC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAW;IAE9B;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,GAAG,IAAI;CAsB/G"}
|
package/{dist → cjs}/index.js
RENAMED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
const patchWebAssembly_1 = require("./patchWebAssembly");
|
|
3
|
+
const registry_1 = require("./registry");
|
|
4
4
|
/** plz don't */
|
|
5
5
|
function patchFrames(frames) {
|
|
6
|
-
|
|
7
|
-
frames.forEach(
|
|
6
|
+
let haveWasm = false;
|
|
7
|
+
frames.forEach(frame => {
|
|
8
8
|
if (!frame.filename) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
const match = frame.filename.match(/^(.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/);
|
|
12
12
|
if (match !== null) {
|
|
13
|
-
|
|
13
|
+
const index = registry_1.getImage(match[1]);
|
|
14
14
|
if (index >= 0) {
|
|
15
15
|
frame.instruction_addr = match[2];
|
|
16
|
-
frame.addr_mode =
|
|
16
|
+
frame.addr_mode = `rel:${index}`;
|
|
17
17
|
frame.filename = match[1];
|
|
18
18
|
frame.platform = 'native';
|
|
19
19
|
haveWasm = true;
|
|
@@ -28,8 +28,8 @@ function patchFrames(frames) {
|
|
|
28
28
|
* This also hooks the WebAssembly loading browser API so that module
|
|
29
29
|
* registraitons are intercepted.
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
class Wasm {
|
|
32
|
+
constructor() {
|
|
33
33
|
/**
|
|
34
34
|
* @inheritDoc
|
|
35
35
|
*/
|
|
@@ -38,34 +38,29 @@ var Wasm = /** @class */ (function () {
|
|
|
38
38
|
/**
|
|
39
39
|
* @inheritDoc
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
setupOnce(addGlobalEventProcessor, _getCurrentHub) {
|
|
42
42
|
patchWebAssembly_1.patchWebAssembly();
|
|
43
|
-
addGlobalEventProcessor(
|
|
44
|
-
|
|
45
|
-
var haveWasm = false;
|
|
43
|
+
addGlobalEventProcessor((event) => {
|
|
44
|
+
let haveWasm = false;
|
|
46
45
|
if (event.exception && event.exception.values) {
|
|
47
|
-
event.exception.values.forEach(
|
|
48
|
-
var _a
|
|
49
|
-
if ((
|
|
46
|
+
event.exception.values.forEach(exception => {
|
|
47
|
+
var _a;
|
|
48
|
+
if ((_a = exception === null || exception === void 0 ? void 0 : exception.stacktrace) === null || _a === void 0 ? void 0 : _a.frames) {
|
|
50
49
|
haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);
|
|
51
50
|
}
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
|
-
if ((_a = event.stacktrace) === null || _a === void 0 ? void 0 : _a.frames) {
|
|
55
|
-
haveWasm = haveWasm || patchFrames(event.stacktrace.frames);
|
|
56
|
-
}
|
|
57
53
|
if (haveWasm) {
|
|
58
54
|
event.debug_meta = event.debug_meta || {};
|
|
59
55
|
event.debug_meta.images = registry_1.getImages();
|
|
60
56
|
}
|
|
61
57
|
return event;
|
|
62
58
|
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
* @inheritDoc
|
|
66
|
-
*/
|
|
67
|
-
Wasm.id = 'Wasm';
|
|
68
|
-
return Wasm;
|
|
69
|
-
}());
|
|
59
|
+
}
|
|
60
|
+
}
|
|
70
61
|
exports.Wasm = Wasm;
|
|
62
|
+
/**
|
|
63
|
+
* @inheritDoc
|
|
64
|
+
*/
|
|
65
|
+
Wasm.id = 'Wasm';
|
|
71
66
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAEA,yDAAsD;AACtD,yCAAiD;AAEjD,gBAAgB;AAChB,SAAS,WAAW,CAAC,MAAyB;IAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnB,OAAO;SACR;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACpF,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,MAAM,KAAK,GAAG,mBAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,KAAK,IAAI,CAAC,EAAE;gBACd,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAClC,KAAK,CAAC,SAAS,GAAG,OAAO,KAAK,EAAE,CAAC;gBACjC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC1B,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;gBAC1B,QAAQ,GAAG,IAAI,CAAC;aACjB;SACF;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAa,IAAI;IAAjB;QAME;;WAEG;QACI,SAAI,GAAW,IAAI,CAAC,EAAE,CAAC;IA2BhC,CAAC;IAzBC;;OAEG;IACI,SAAS,CAAC,uBAA2D,EAAE,cAAyB;QACrG,mCAAgB,EAAE,CAAC;QAEnB,uBAAuB,CAAC,CAAC,KAAY,EAAE,EAAE;YACvC,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE;gBAC7C,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;;oBACzC,UAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,UAAU,0CAAE,MAAM,EAAE;wBACjC,QAAQ,GAAG,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;qBACjE;gBACH,CAAC,CAAC,CAAC;aACJ;YAED,IAAI,QAAQ,EAAE;gBACZ,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;gBAC1C,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,oBAAS,EAAE,CAAC;aACvC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;;AAnCH,oBAoCC;AAnCC;;GAEG;AACW,OAAE,GAAW,MAAM,CAAC","sourcesContent":["import { Event, EventProcessor, Hub, Integration, StackFrame } from '@sentry/types';\n\nimport { patchWebAssembly } from './patchWebAssembly';\nimport { getImage, getImages } from './registry';\n\n/** plz don't */\nfunction patchFrames(frames: Array<StackFrame>): boolean {\n let haveWasm = false;\n frames.forEach(frame => {\n if (!frame.filename) {\n return;\n }\n const match = frame.filename.match(/^(.*?):wasm-function\\[\\d+\\]:(0x[a-fA-F0-9]+)$/);\n if (match !== null) {\n const index = getImage(match[1]);\n if (index >= 0) {\n frame.instruction_addr = match[2];\n frame.addr_mode = `rel:${index}`;\n frame.filename = match[1];\n frame.platform = 'native';\n haveWasm = true;\n }\n }\n });\n return haveWasm;\n}\n\n/**\n * Process WASM stack traces to support server-side symbolication.\n *\n * This also hooks the WebAssembly loading browser API so that module\n * registraitons are intercepted.\n */\nexport class Wasm implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Wasm';\n\n /**\n * @inheritDoc\n */\n public name: string = Wasm.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, _getCurrentHub: () => Hub): void {\n patchWebAssembly();\n\n addGlobalEventProcessor((event: Event) => {\n let haveWasm = false;\n\n if (event.exception && event.exception.values) {\n event.exception.values.forEach(exception => {\n if (exception?.stacktrace?.frames) {\n haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);\n }\n });\n }\n\n if (haveWasm) {\n event.debug_meta = event.debug_meta || {};\n event.debug_meta.images = getImages();\n }\n\n return event;\n });\n }\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
|
|
2
|
+
const registry_1 = require("./registry");
|
|
3
3
|
/**
|
|
4
4
|
* Patches the web assembly runtime.
|
|
5
5
|
*/
|
|
6
6
|
function patchWebAssembly() {
|
|
7
7
|
if ('instantiateStreaming' in WebAssembly) {
|
|
8
|
-
|
|
8
|
+
const origInstantiateStreaming = WebAssembly.instantiateStreaming;
|
|
9
9
|
WebAssembly.instantiateStreaming = function instantiateStreaming(response, importObject) {
|
|
10
|
-
return Promise.resolve(response).then(
|
|
11
|
-
return
|
|
10
|
+
return Promise.resolve(response).then(response => {
|
|
11
|
+
return origInstantiateStreaming(response, importObject).then(rv => {
|
|
12
12
|
if (response.url) {
|
|
13
13
|
registry_1.registerModule(rv.module, response.url);
|
|
14
14
|
}
|
|
@@ -18,10 +18,10 @@ function patchWebAssembly() {
|
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
20
|
if ('compileStreaming' in WebAssembly) {
|
|
21
|
-
|
|
21
|
+
const origCompileStreaming = WebAssembly.compileStreaming;
|
|
22
22
|
WebAssembly.compileStreaming = function compileStreaming(source) {
|
|
23
|
-
return Promise.resolve(source).then(
|
|
24
|
-
return
|
|
23
|
+
return Promise.resolve(source).then(response => {
|
|
24
|
+
return origCompileStreaming(response).then(module => {
|
|
25
25
|
if (response.url) {
|
|
26
26
|
registry_1.registerModule(module, response.url);
|
|
27
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patchWebAssembly.js","sourceRoot":"","sources":["../../../src/patchWebAssembly.ts"],"names":[],"mappings":";AAAA,yCAA4C;AAE5C;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,IAAI,sBAAsB,IAAI,WAAW,EAAE;QACzC,MAAM,wBAAwB,GAAG,WAAW,CAAC,oBAAoB,CAAC;QAClE,WAAW,CAAC,oBAAoB,GAAG,SAAS,oBAAoB,CAC9D,QAA0C,EAC1C,YAAiC;YAEjC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAC/C,OAAO,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;oBAChE,IAAI,QAAQ,CAAC,GAAG,EAAE;wBAChB,yBAAc,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACzC;oBACD,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAA4C,CAAC;KAC9C;IAED,IAAI,kBAAkB,IAAI,WAAW,EAAE;QACrC,MAAM,oBAAoB,GAAG,WAAW,CAAC,gBAAgB,CAAC;QAC1D,WAAW,CAAC,gBAAgB,GAAG,SAAS,gBAAgB,CACtD,MAAoC;YAEpC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAC7C,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;oBAClD,IAAI,QAAQ,CAAC,GAAG,EAAE;wBAChB,yBAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACtC;oBACD,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAwC,CAAC;KAC1C;AACH,CAAC;AAjCD,4CAiCC","sourcesContent":["import { registerModule } from './registry';\n\n/**\n * Patches the web assembly runtime.\n */\nexport function patchWebAssembly(): void {\n if ('instantiateStreaming' in WebAssembly) {\n const origInstantiateStreaming = WebAssembly.instantiateStreaming;\n WebAssembly.instantiateStreaming = function instantiateStreaming(\n response: Response | PromiseLike<Response>,\n importObject: WebAssembly.Imports,\n ): Promise<WebAssembly.Module> {\n return Promise.resolve(response).then(response => {\n return origInstantiateStreaming(response, importObject).then(rv => {\n if (response.url) {\n registerModule(rv.module, response.url);\n }\n return rv;\n });\n });\n } as typeof WebAssembly.instantiateStreaming;\n }\n\n if ('compileStreaming' in WebAssembly) {\n const origCompileStreaming = WebAssembly.compileStreaming;\n WebAssembly.compileStreaming = function compileStreaming(\n source: Response | Promise<Response>,\n ): Promise<WebAssembly.Module> {\n return Promise.resolve(source).then(response => {\n return origCompileStreaming(response).then(module => {\n if (response.url) {\n registerModule(module, response.url);\n }\n return module;\n });\n });\n } as typeof WebAssembly.compileStreaming;\n }\n}\n"]}
|
|
File without changes
|
|
File without changes
|
package/{dist → cjs}/registry.js
RENAMED
|
@@ -7,31 +7,31 @@ exports.IMAGES = [];
|
|
|
7
7
|
* @param module
|
|
8
8
|
*/
|
|
9
9
|
function getModuleInfo(module) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const buildIds = WebAssembly.Module.customSections(module, 'build_id');
|
|
11
|
+
let buildId = null;
|
|
12
|
+
let debugFile = null;
|
|
13
13
|
if (buildIds.length > 0) {
|
|
14
|
-
|
|
15
|
-
buildId = Array.from(firstBuildId).reduce(
|
|
14
|
+
const firstBuildId = new Uint8Array(buildIds[0]);
|
|
15
|
+
buildId = Array.from(firstBuildId).reduce((acc, x) => {
|
|
16
16
|
return acc + x.toString(16).padStart(2, '0');
|
|
17
17
|
}, '');
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
const externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info');
|
|
20
20
|
if (externalDebugInfo.length > 0) {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const firstExternalDebugInfo = new Uint8Array(externalDebugInfo[0]);
|
|
22
|
+
const decoder = new TextDecoder('utf-8');
|
|
23
23
|
debugFile = decoder.decode(firstExternalDebugInfo);
|
|
24
24
|
}
|
|
25
|
-
return { buildId
|
|
25
|
+
return { buildId, debugFile };
|
|
26
26
|
}
|
|
27
27
|
exports.getModuleInfo = getModuleInfo;
|
|
28
28
|
/**
|
|
29
29
|
* Records a module
|
|
30
30
|
*/
|
|
31
31
|
function registerModule(module, url) {
|
|
32
|
-
|
|
32
|
+
const { buildId, debugFile } = getModuleInfo(module);
|
|
33
33
|
if (buildId) {
|
|
34
|
-
|
|
34
|
+
const oldIdx = exports.IMAGES.findIndex(img => img.code_file === url);
|
|
35
35
|
if (oldIdx >= 0) {
|
|
36
36
|
exports.IMAGES.splice(oldIdx, 1);
|
|
37
37
|
}
|
|
@@ -40,7 +40,7 @@ function registerModule(module, url) {
|
|
|
40
40
|
code_id: buildId,
|
|
41
41
|
code_file: url,
|
|
42
42
|
debug_file: debugFile ? new URL(debugFile, url).href : null,
|
|
43
|
-
debug_id: buildId.padEnd(32, '0').substr(0, 32)
|
|
43
|
+
debug_id: `${buildId.padEnd(32, '0').substr(0, 32)}0`,
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -58,7 +58,7 @@ exports.getImages = getImages;
|
|
|
58
58
|
* @param url the URL of the WebAssembly module.
|
|
59
59
|
*/
|
|
60
60
|
function getImage(url) {
|
|
61
|
-
return exports.IMAGES.findIndex(
|
|
61
|
+
return exports.IMAGES.findIndex(img => img.code_file === url);
|
|
62
62
|
}
|
|
63
63
|
exports.getImage = getImage;
|
|
64
64
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/registry.ts"],"names":[],"mappings":";AAEa,QAAA,MAAM,GAAsB,EAAE,CAAC;AAO5C;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,MAA0B;IACtD,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/registry.ts"],"names":[],"mappings":";AAEa,QAAA,MAAM,GAAsB,EAAE,CAAC;AAO5C;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,MAA0B;IACtD,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvE,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACnD,OAAO,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;IAED,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC3F,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;QAChC,MAAM,sBAAsB,GAAG,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;KACpD;IAED,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC;AApBD,sCAoBC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,MAA0B,EAAE,GAAW;IACpE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,OAAO,EAAE;QACX,MAAM,MAAM,GAAG,cAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC;QAC9D,IAAI,MAAM,IAAI,CAAC,EAAE;YACf,cAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;SAC1B;QACD,cAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,GAAG;YACd,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;YAC3D,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG;SACtD,CAAC,CAAC;KACJ;AACH,CAAC;AAfD,wCAeC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,cAAM,CAAC;AAChB,CAAC;AAFD,8BAEC;AAED;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,GAAW;IAClC,OAAO,cAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC;AACxD,CAAC;AAFD,4BAEC","sourcesContent":["import { DebugImage } from '@sentry/types';\n\nexport const IMAGES: Array<DebugImage> = [];\n\nexport interface ModuleInfo {\n buildId: string | null;\n debugFile: string | null;\n}\n\n/**\n * Returns the extracted meta information from a web assembly module that\n * Sentry uses to identify debug images.\n *\n * @param module\n */\nexport function getModuleInfo(module: WebAssembly.Module): ModuleInfo {\n const buildIds = WebAssembly.Module.customSections(module, 'build_id');\n let buildId = null;\n let debugFile = null;\n\n if (buildIds.length > 0) {\n const firstBuildId = new Uint8Array(buildIds[0]);\n buildId = Array.from(firstBuildId).reduce((acc, x) => {\n return acc + x.toString(16).padStart(2, '0');\n }, '');\n }\n\n const externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info');\n if (externalDebugInfo.length > 0) {\n const firstExternalDebugInfo = new Uint8Array(externalDebugInfo[0]);\n const decoder = new TextDecoder('utf-8');\n debugFile = decoder.decode(firstExternalDebugInfo);\n }\n\n return { buildId, debugFile };\n}\n\n/**\n * Records a module\n */\nexport function registerModule(module: WebAssembly.Module, url: string): void {\n const { buildId, debugFile } = getModuleInfo(module);\n if (buildId) {\n const oldIdx = IMAGES.findIndex(img => img.code_file === url);\n if (oldIdx >= 0) {\n IMAGES.splice(oldIdx, 1);\n }\n IMAGES.push({\n type: 'wasm',\n code_id: buildId,\n code_file: url,\n debug_file: debugFile ? new URL(debugFile, url).href : null,\n debug_id: `${buildId.padEnd(32, '0').substr(0, 32)}0`,\n });\n }\n}\n\n/**\n * Returns all known images.\n */\nexport function getImages(): Array<DebugImage> {\n return IMAGES;\n}\n\n/**\n * Looks up an image by URL.\n *\n * @param url the URL of the WebAssembly module.\n */\nexport function getImage(url: string): number {\n return IMAGES.findIndex(img => img.code_file === url);\n}\n"]}
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAc,MAAM,eAAe,CAAC;AA2BpF;;;;;GAKG;AACH,qBAAa,IAAK,YAAW,WAAW;IACtC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAU;IAElC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAW;IAE9B;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAc,MAAM,eAAe,CAAC;AA2BpF;;;;;GAKG;AACH,qBAAa,IAAK,YAAW,WAAW;IACtC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAU;IAElC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAW;IAE9B;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,GAAG,IAAI;CAsB/G"}
|
package/esm/index.js
CHANGED
|
@@ -2,17 +2,17 @@ import { patchWebAssembly } from './patchWebAssembly';
|
|
|
2
2
|
import { getImage, getImages } from './registry';
|
|
3
3
|
/** plz don't */
|
|
4
4
|
function patchFrames(frames) {
|
|
5
|
-
|
|
6
|
-
frames.forEach(
|
|
5
|
+
let haveWasm = false;
|
|
6
|
+
frames.forEach(frame => {
|
|
7
7
|
if (!frame.filename) {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
const match = frame.filename.match(/^(.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/);
|
|
11
11
|
if (match !== null) {
|
|
12
|
-
|
|
12
|
+
const index = getImage(match[1]);
|
|
13
13
|
if (index >= 0) {
|
|
14
14
|
frame.instruction_addr = match[2];
|
|
15
|
-
frame.addr_mode =
|
|
15
|
+
frame.addr_mode = `rel:${index}`;
|
|
16
16
|
frame.filename = match[1];
|
|
17
17
|
frame.platform = 'native';
|
|
18
18
|
haveWasm = true;
|
|
@@ -27,8 +27,8 @@ function patchFrames(frames) {
|
|
|
27
27
|
* This also hooks the WebAssembly loading browser API so that module
|
|
28
28
|
* registraitons are intercepted.
|
|
29
29
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
export class Wasm {
|
|
31
|
+
constructor() {
|
|
32
32
|
/**
|
|
33
33
|
* @inheritDoc
|
|
34
34
|
*/
|
|
@@ -37,34 +37,28 @@ var Wasm = /** @class */ (function () {
|
|
|
37
37
|
/**
|
|
38
38
|
* @inheritDoc
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
setupOnce(addGlobalEventProcessor, _getCurrentHub) {
|
|
41
41
|
patchWebAssembly();
|
|
42
|
-
addGlobalEventProcessor(
|
|
43
|
-
|
|
44
|
-
var haveWasm = false;
|
|
42
|
+
addGlobalEventProcessor((event) => {
|
|
43
|
+
let haveWasm = false;
|
|
45
44
|
if (event.exception && event.exception.values) {
|
|
46
|
-
event.exception.values.forEach(
|
|
47
|
-
var _a
|
|
48
|
-
if ((
|
|
45
|
+
event.exception.values.forEach(exception => {
|
|
46
|
+
var _a;
|
|
47
|
+
if ((_a = exception === null || exception === void 0 ? void 0 : exception.stacktrace) === null || _a === void 0 ? void 0 : _a.frames) {
|
|
49
48
|
haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);
|
|
50
49
|
}
|
|
51
50
|
});
|
|
52
51
|
}
|
|
53
|
-
if ((_a = event.stacktrace) === null || _a === void 0 ? void 0 : _a.frames) {
|
|
54
|
-
haveWasm = haveWasm || patchFrames(event.stacktrace.frames);
|
|
55
|
-
}
|
|
56
52
|
if (haveWasm) {
|
|
57
53
|
event.debug_meta = event.debug_meta || {};
|
|
58
54
|
event.debug_meta.images = getImages();
|
|
59
55
|
}
|
|
60
56
|
return event;
|
|
61
57
|
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}());
|
|
69
|
-
export { Wasm };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @inheritDoc
|
|
62
|
+
*/
|
|
63
|
+
Wasm.id = 'Wasm';
|
|
70
64
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjD,gBAAgB;AAChB,SAAS,WAAW,CAAC,MAAyB;IAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjD,gBAAgB;AAChB,SAAS,WAAW,CAAC,MAAyB;IAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACrB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnB,OAAO;SACR;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACpF,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,KAAK,IAAI,CAAC,EAAE;gBACd,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAClC,KAAK,CAAC,SAAS,GAAG,OAAO,KAAK,EAAE,CAAC;gBACjC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC1B,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;gBAC1B,QAAQ,GAAG,IAAI,CAAC;aACjB;SACF;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,IAAI;IAAjB;QAME;;WAEG;QACI,SAAI,GAAW,IAAI,CAAC,EAAE,CAAC;IA2BhC,CAAC;IAzBC;;OAEG;IACI,SAAS,CAAC,uBAA2D,EAAE,cAAyB;QACrG,gBAAgB,EAAE,CAAC;QAEnB,uBAAuB,CAAC,CAAC,KAAY,EAAE,EAAE;YACvC,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE;gBAC7C,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;;oBACzC,UAAI,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,UAAU,0CAAE,MAAM,EAAE;wBACjC,QAAQ,GAAG,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;qBACjE;gBACH,CAAC,CAAC,CAAC;aACJ;YAED,IAAI,QAAQ,EAAE;gBACZ,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;gBAC1C,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;aACvC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;;AAlCD;;GAEG;AACW,OAAE,GAAW,MAAM,CAAC","sourcesContent":["import { Event, EventProcessor, Hub, Integration, StackFrame } from '@sentry/types';\n\nimport { patchWebAssembly } from './patchWebAssembly';\nimport { getImage, getImages } from './registry';\n\n/** plz don't */\nfunction patchFrames(frames: Array<StackFrame>): boolean {\n let haveWasm = false;\n frames.forEach(frame => {\n if (!frame.filename) {\n return;\n }\n const match = frame.filename.match(/^(.*?):wasm-function\\[\\d+\\]:(0x[a-fA-F0-9]+)$/);\n if (match !== null) {\n const index = getImage(match[1]);\n if (index >= 0) {\n frame.instruction_addr = match[2];\n frame.addr_mode = `rel:${index}`;\n frame.filename = match[1];\n frame.platform = 'native';\n haveWasm = true;\n }\n }\n });\n return haveWasm;\n}\n\n/**\n * Process WASM stack traces to support server-side symbolication.\n *\n * This also hooks the WebAssembly loading browser API so that module\n * registraitons are intercepted.\n */\nexport class Wasm implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Wasm';\n\n /**\n * @inheritDoc\n */\n public name: string = Wasm.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, _getCurrentHub: () => Hub): void {\n patchWebAssembly();\n\n addGlobalEventProcessor((event: Event) => {\n let haveWasm = false;\n\n if (event.exception && event.exception.values) {\n event.exception.values.forEach(exception => {\n if (exception?.stacktrace?.frames) {\n haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);\n }\n });\n }\n\n if (haveWasm) {\n event.debug_meta = event.debug_meta || {};\n event.debug_meta.images = getImages();\n }\n\n return event;\n });\n }\n}\n"]}
|
package/esm/patchWebAssembly.js
CHANGED
|
@@ -4,10 +4,10 @@ import { registerModule } from './registry';
|
|
|
4
4
|
*/
|
|
5
5
|
export function patchWebAssembly() {
|
|
6
6
|
if ('instantiateStreaming' in WebAssembly) {
|
|
7
|
-
|
|
7
|
+
const origInstantiateStreaming = WebAssembly.instantiateStreaming;
|
|
8
8
|
WebAssembly.instantiateStreaming = function instantiateStreaming(response, importObject) {
|
|
9
|
-
return Promise.resolve(response).then(
|
|
10
|
-
return
|
|
9
|
+
return Promise.resolve(response).then(response => {
|
|
10
|
+
return origInstantiateStreaming(response, importObject).then(rv => {
|
|
11
11
|
if (response.url) {
|
|
12
12
|
registerModule(rv.module, response.url);
|
|
13
13
|
}
|
|
@@ -17,10 +17,10 @@ export function patchWebAssembly() {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
if ('compileStreaming' in WebAssembly) {
|
|
20
|
-
|
|
20
|
+
const origCompileStreaming = WebAssembly.compileStreaming;
|
|
21
21
|
WebAssembly.compileStreaming = function compileStreaming(source) {
|
|
22
|
-
return Promise.resolve(source).then(
|
|
23
|
-
return
|
|
22
|
+
return Promise.resolve(source).then(response => {
|
|
23
|
+
return origCompileStreaming(response).then(module => {
|
|
24
24
|
if (response.url) {
|
|
25
25
|
registerModule(module, response.url);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patchWebAssembly.js","sourceRoot":"","sources":["../../../src/patchWebAssembly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,sBAAsB,IAAI,WAAW,EAAE;QACzC,
|
|
1
|
+
{"version":3,"file":"patchWebAssembly.js","sourceRoot":"","sources":["../../../src/patchWebAssembly.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,IAAI,sBAAsB,IAAI,WAAW,EAAE;QACzC,MAAM,wBAAwB,GAAG,WAAW,CAAC,oBAAoB,CAAC;QAClE,WAAW,CAAC,oBAAoB,GAAG,SAAS,oBAAoB,CAC9D,QAA0C,EAC1C,YAAiC;YAEjC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAC/C,OAAO,wBAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;oBAChE,IAAI,QAAQ,CAAC,GAAG,EAAE;wBAChB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACzC;oBACD,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAA4C,CAAC;KAC9C;IAED,IAAI,kBAAkB,IAAI,WAAW,EAAE;QACrC,MAAM,oBAAoB,GAAG,WAAW,CAAC,gBAAgB,CAAC;QAC1D,WAAW,CAAC,gBAAgB,GAAG,SAAS,gBAAgB,CACtD,MAAoC;YAEpC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAC7C,OAAO,oBAAoB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;oBAClD,IAAI,QAAQ,CAAC,GAAG,EAAE;wBAChB,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACtC;oBACD,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAwC,CAAC;KAC1C;AACH,CAAC","sourcesContent":["import { registerModule } from './registry';\n\n/**\n * Patches the web assembly runtime.\n */\nexport function patchWebAssembly(): void {\n if ('instantiateStreaming' in WebAssembly) {\n const origInstantiateStreaming = WebAssembly.instantiateStreaming;\n WebAssembly.instantiateStreaming = function instantiateStreaming(\n response: Response | PromiseLike<Response>,\n importObject: WebAssembly.Imports,\n ): Promise<WebAssembly.Module> {\n return Promise.resolve(response).then(response => {\n return origInstantiateStreaming(response, importObject).then(rv => {\n if (response.url) {\n registerModule(rv.module, response.url);\n }\n return rv;\n });\n });\n } as typeof WebAssembly.instantiateStreaming;\n }\n\n if ('compileStreaming' in WebAssembly) {\n const origCompileStreaming = WebAssembly.compileStreaming;\n WebAssembly.compileStreaming = function compileStreaming(\n source: Response | Promise<Response>,\n ): Promise<WebAssembly.Module> {\n return Promise.resolve(source).then(response => {\n return origCompileStreaming(response).then(module => {\n if (response.url) {\n registerModule(module, response.url);\n }\n return module;\n });\n });\n } as typeof WebAssembly.compileStreaming;\n }\n}\n"]}
|
package/esm/registry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const IMAGES = [];
|
|
2
2
|
/**
|
|
3
3
|
* Returns the extracted meta information from a web assembly module that
|
|
4
4
|
* Sentry uses to identify debug images.
|
|
@@ -6,30 +6,30 @@ export var IMAGES = [];
|
|
|
6
6
|
* @param module
|
|
7
7
|
*/
|
|
8
8
|
export function getModuleInfo(module) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const buildIds = WebAssembly.Module.customSections(module, 'build_id');
|
|
10
|
+
let buildId = null;
|
|
11
|
+
let debugFile = null;
|
|
12
12
|
if (buildIds.length > 0) {
|
|
13
|
-
|
|
14
|
-
buildId = Array.from(firstBuildId).reduce(
|
|
13
|
+
const firstBuildId = new Uint8Array(buildIds[0]);
|
|
14
|
+
buildId = Array.from(firstBuildId).reduce((acc, x) => {
|
|
15
15
|
return acc + x.toString(16).padStart(2, '0');
|
|
16
16
|
}, '');
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
const externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info');
|
|
19
19
|
if (externalDebugInfo.length > 0) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const firstExternalDebugInfo = new Uint8Array(externalDebugInfo[0]);
|
|
21
|
+
const decoder = new TextDecoder('utf-8');
|
|
22
22
|
debugFile = decoder.decode(firstExternalDebugInfo);
|
|
23
23
|
}
|
|
24
|
-
return { buildId
|
|
24
|
+
return { buildId, debugFile };
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Records a module
|
|
28
28
|
*/
|
|
29
29
|
export function registerModule(module, url) {
|
|
30
|
-
|
|
30
|
+
const { buildId, debugFile } = getModuleInfo(module);
|
|
31
31
|
if (buildId) {
|
|
32
|
-
|
|
32
|
+
const oldIdx = IMAGES.findIndex(img => img.code_file === url);
|
|
33
33
|
if (oldIdx >= 0) {
|
|
34
34
|
IMAGES.splice(oldIdx, 1);
|
|
35
35
|
}
|
|
@@ -38,7 +38,7 @@ export function registerModule(module, url) {
|
|
|
38
38
|
code_id: buildId,
|
|
39
39
|
code_file: url,
|
|
40
40
|
debug_file: debugFile ? new URL(debugFile, url).href : null,
|
|
41
|
-
debug_id: buildId.padEnd(32, '0').substr(0, 32)
|
|
41
|
+
debug_id: `${buildId.padEnd(32, '0').substr(0, 32)}0`,
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -54,6 +54,6 @@ export function getImages() {
|
|
|
54
54
|
* @param url the URL of the WebAssembly module.
|
|
55
55
|
*/
|
|
56
56
|
export function getImage(url) {
|
|
57
|
-
return IMAGES.findIndex(
|
|
57
|
+
return IMAGES.findIndex(img => img.code_file === url);
|
|
58
58
|
}
|
|
59
59
|
//# sourceMappingURL=registry.js.map
|
package/esm/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/registry.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/registry.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAsB,EAAE,CAAC;AAO5C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,MAA0B;IACtD,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvE,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,IAAI,SAAS,GAAG,IAAI,CAAC;IAErB,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,MAAM,YAAY,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;YACnD,OAAO,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC,EAAE,EAAE,CAAC,CAAC;KACR;IAED,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC3F,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;QAChC,MAAM,sBAAsB,GAAG,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC;QACzC,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;KACpD;IAED,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAA0B,EAAE,GAAW;IACpE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,OAAO,EAAE;QACX,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC;QAC9D,IAAI,MAAM,IAAI,CAAC,EAAE;YACf,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;SAC1B;QACD,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE,OAAO;YAChB,SAAS,EAAE,GAAG;YACd,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;YAC3D,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG;SACtD,CAAC,CAAC;KACJ;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { DebugImage } from '@sentry/types';\n\nexport const IMAGES: Array<DebugImage> = [];\n\nexport interface ModuleInfo {\n buildId: string | null;\n debugFile: string | null;\n}\n\n/**\n * Returns the extracted meta information from a web assembly module that\n * Sentry uses to identify debug images.\n *\n * @param module\n */\nexport function getModuleInfo(module: WebAssembly.Module): ModuleInfo {\n const buildIds = WebAssembly.Module.customSections(module, 'build_id');\n let buildId = null;\n let debugFile = null;\n\n if (buildIds.length > 0) {\n const firstBuildId = new Uint8Array(buildIds[0]);\n buildId = Array.from(firstBuildId).reduce((acc, x) => {\n return acc + x.toString(16).padStart(2, '0');\n }, '');\n }\n\n const externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info');\n if (externalDebugInfo.length > 0) {\n const firstExternalDebugInfo = new Uint8Array(externalDebugInfo[0]);\n const decoder = new TextDecoder('utf-8');\n debugFile = decoder.decode(firstExternalDebugInfo);\n }\n\n return { buildId, debugFile };\n}\n\n/**\n * Records a module\n */\nexport function registerModule(module: WebAssembly.Module, url: string): void {\n const { buildId, debugFile } = getModuleInfo(module);\n if (buildId) {\n const oldIdx = IMAGES.findIndex(img => img.code_file === url);\n if (oldIdx >= 0) {\n IMAGES.splice(oldIdx, 1);\n }\n IMAGES.push({\n type: 'wasm',\n code_id: buildId,\n code_file: url,\n debug_file: debugFile ? new URL(debugFile, url).href : null,\n debug_id: `${buildId.padEnd(32, '0').substr(0, 32)}0`,\n });\n }\n}\n\n/**\n * Returns all known images.\n */\nexport function getImages(): Array<DebugImage> {\n return IMAGES;\n}\n\n/**\n * Looks up an image by URL.\n *\n * @param url the URL of the WebAssembly module.\n */\nexport function getImage(url: string): number {\n return IMAGES.findIndex(img => img.code_file === url);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/wasm",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-beta.0",
|
|
4
4
|
"description": "Support for WASM.",
|
|
5
5
|
"repository": "git://github.com/getsentry/sentry-javascript.git",
|
|
6
6
|
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/wasm",
|
|
7
7
|
"author": "Sentry",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">=8"
|
|
11
11
|
},
|
|
12
|
-
"main": "
|
|
12
|
+
"main": "cjs/index.js",
|
|
13
13
|
"module": "esm/index.js",
|
|
14
14
|
"types": "types/index.d.ts",
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@sentry/browser": "
|
|
20
|
-
"@sentry/types": "
|
|
19
|
+
"@sentry/browser": "7.0.0-beta.0",
|
|
20
|
+
"@sentry/types": "7.0.0-beta.0",
|
|
21
21
|
"tslib": "^1.9.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAc,MAAM,eAAe,CAAC;AA2BpF;;;;;GAKG;AACH,qBAAa,IAAK,YAAW,WAAW;IACtC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAU;IAElC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAW;IAE9B;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,cAAc,EAAE,GAAG,EAAE,WAAW,EAAc,MAAM,eAAe,CAAC;AA2BpF;;;;;GAKG;AACH,qBAAa,IAAK,YAAW,WAAW;IACtC;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAAU;IAElC;;OAEG;IACI,IAAI,EAAE,MAAM,CAAW;IAE9B;;OAEG;IACI,SAAS,CAAC,uBAAuB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,GAAG,IAAI;CAsB/G"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";AAEA,uDAAsD;AACtD,uCAAiD;AAEjD,gBAAgB;AAChB,SAAS,WAAW,CAAC,MAAyB;IAC5C,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,OAAO,CAAC,UAAA,KAAK;QAClB,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YACnB,OAAO;SACR;QACD,IAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,+CAA+C,CAAC,CAAC;QACpF,IAAI,KAAK,KAAK,IAAI,EAAE;YAClB,IAAM,KAAK,GAAG,mBAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACjC,IAAI,KAAK,IAAI,CAAC,EAAE;gBACd,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAClC,KAAK,CAAC,SAAS,GAAG,SAAO,KAAO,CAAC;gBACjC,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC1B,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;gBAC1B,QAAQ,GAAG,IAAI,CAAC;aACjB;SACF;IACH,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;GAKG;AACH;IAAA;QAME;;WAEG;QACI,SAAI,GAAW,IAAI,CAAC,EAAE,CAAC;IA8BhC,CAAC;IA5BC;;OAEG;IACI,wBAAS,GAAhB,UAAiB,uBAA2D,EAAE,cAAyB;QACrG,mCAAgB,EAAE,CAAC;QAEnB,uBAAuB,CAAC,UAAC,KAAY;;YACnC,IAAI,QAAQ,GAAG,KAAK,CAAC;YAErB,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE;gBAC7C,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,UAAA,SAAS;;oBACtC,gBAAI,SAAS,0CAAE,UAAU,0CAAE,MAAM,EAAE;wBACjC,QAAQ,GAAG,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;qBACjE;gBACH,CAAC,CAAC,CAAC;aACJ;YACD,UAAI,KAAK,CAAC,UAAU,0CAAE,MAAM,EAAE;gBAC5B,QAAQ,GAAG,QAAQ,IAAI,WAAW,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;aAC7D;YAED,IAAI,QAAQ,EAAE;gBACZ,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;gBAC1C,KAAK,CAAC,UAAU,CAAC,MAAM,GAAG,oBAAS,EAAE,CAAC;aACvC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IArCD;;OAEG;IACW,OAAE,GAAW,MAAM,CAAC;IAmCpC,WAAC;CAAA,AAvCD,IAuCC;AAvCY,oBAAI","sourcesContent":["import { Event, EventProcessor, Hub, Integration, StackFrame } from '@sentry/types';\n\nimport { patchWebAssembly } from './patchWebAssembly';\nimport { getImage, getImages } from './registry';\n\n/** plz don't */\nfunction patchFrames(frames: Array<StackFrame>): boolean {\n let haveWasm = false;\n frames.forEach(frame => {\n if (!frame.filename) {\n return;\n }\n const match = frame.filename.match(/^(.*?):wasm-function\\[\\d+\\]:(0x[a-fA-F0-9]+)$/);\n if (match !== null) {\n const index = getImage(match[1]);\n if (index >= 0) {\n frame.instruction_addr = match[2];\n frame.addr_mode = `rel:${index}`;\n frame.filename = match[1];\n frame.platform = 'native';\n haveWasm = true;\n }\n }\n });\n return haveWasm;\n}\n\n/**\n * Process WASM stack traces to support server-side symbolication.\n *\n * This also hooks the WebAssembly loading browser API so that module\n * registraitons are intercepted.\n */\nexport class Wasm implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'Wasm';\n\n /**\n * @inheritDoc\n */\n public name: string = Wasm.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, _getCurrentHub: () => Hub): void {\n patchWebAssembly();\n\n addGlobalEventProcessor((event: Event) => {\n let haveWasm = false;\n\n if (event.exception && event.exception.values) {\n event.exception.values.forEach(exception => {\n if (exception?.stacktrace?.frames) {\n haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);\n }\n });\n }\n if (event.stacktrace?.frames) {\n haveWasm = haveWasm || patchFrames(event.stacktrace.frames);\n }\n\n if (haveWasm) {\n event.debug_meta = event.debug_meta || {};\n event.debug_meta.images = getImages();\n }\n\n return event;\n });\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchWebAssembly.js","sourceRoot":"","sources":["../../../src/patchWebAssembly.ts"],"names":[],"mappings":";AAAA,uCAA4C;AAE5C;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,IAAI,sBAAsB,IAAI,WAAW,EAAE;QACzC,IAAM,0BAAwB,GAAG,WAAW,CAAC,oBAAoB,CAAC;QAClE,WAAW,CAAC,oBAAoB,GAAG,SAAS,oBAAoB,CAC9D,QAA0C,EAC1C,YAAiC;YAEjC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAA,QAAQ;gBAC5C,OAAO,0BAAwB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,UAAA,EAAE;oBAC7D,IAAI,QAAQ,CAAC,GAAG,EAAE;wBAChB,yBAAc,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACzC;oBACD,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAA4C,CAAC;KAC9C;IAED,IAAI,kBAAkB,IAAI,WAAW,EAAE;QACrC,IAAM,sBAAoB,GAAG,WAAW,CAAC,gBAAgB,CAAC;QAC1D,WAAW,CAAC,gBAAgB,GAAG,SAAS,gBAAgB,CACtD,MAAoC;YAEpC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAA,QAAQ;gBAC1C,OAAO,sBAAoB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAA,MAAM;oBAC/C,IAAI,QAAQ,CAAC,GAAG,EAAE;wBAChB,yBAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;qBACtC;oBACD,OAAO,MAAM,CAAC;gBAChB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAwC,CAAC;KAC1C;AACH,CAAC;AAjCD,4CAiCC","sourcesContent":["import { registerModule } from './registry';\n\n/**\n * Patches the web assembly runtime.\n */\nexport function patchWebAssembly(): void {\n if ('instantiateStreaming' in WebAssembly) {\n const origInstantiateStreaming = WebAssembly.instantiateStreaming;\n WebAssembly.instantiateStreaming = function instantiateStreaming(\n response: Response | PromiseLike<Response>,\n importObject: WebAssembly.Imports,\n ): Promise<WebAssembly.Module> {\n return Promise.resolve(response).then(response => {\n return origInstantiateStreaming(response, importObject).then(rv => {\n if (response.url) {\n registerModule(rv.module, response.url);\n }\n return rv;\n });\n });\n } as typeof WebAssembly.instantiateStreaming;\n }\n\n if ('compileStreaming' in WebAssembly) {\n const origCompileStreaming = WebAssembly.compileStreaming;\n WebAssembly.compileStreaming = function compileStreaming(\n source: Response | Promise<Response>,\n ): Promise<WebAssembly.Module> {\n return Promise.resolve(source).then(response => {\n return origCompileStreaming(response).then(module => {\n if (response.url) {\n registerModule(module, response.url);\n }\n return module;\n });\n });\n } as typeof WebAssembly.compileStreaming;\n }\n}\n"]}
|