@sentry/wasm 7.0.0-alpha.1 → 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/cjs/index.js CHANGED
@@ -1,19 +1,19 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- var patchWebAssembly_1 = require("./patchWebAssembly");
3
- var registry_1 = require("./registry");
2
+ const patchWebAssembly_1 = require("./patchWebAssembly");
3
+ const registry_1 = require("./registry");
4
4
  /** plz don't */
5
5
  function patchFrames(frames) {
6
- var haveWasm = false;
7
- frames.forEach(function (frame) {
6
+ let haveWasm = false;
7
+ frames.forEach(frame => {
8
8
  if (!frame.filename) {
9
9
  return;
10
10
  }
11
- var match = frame.filename.match(/^(.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/);
11
+ const match = frame.filename.match(/^(.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/);
12
12
  if (match !== null) {
13
- var index = registry_1.getImage(match[1]);
13
+ const index = registry_1.getImage(match[1]);
14
14
  if (index >= 0) {
15
15
  frame.instruction_addr = match[2];
16
- frame.addr_mode = "rel:" + index;
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
- var Wasm = /** @class */ (function () {
32
- function Wasm() {
31
+ class Wasm {
32
+ constructor() {
33
33
  /**
34
34
  * @inheritDoc
35
35
  */
@@ -38,12 +38,12 @@ var Wasm = /** @class */ (function () {
38
38
  /**
39
39
  * @inheritDoc
40
40
  */
41
- Wasm.prototype.setupOnce = function (addGlobalEventProcessor, _getCurrentHub) {
41
+ setupOnce(addGlobalEventProcessor, _getCurrentHub) {
42
42
  patchWebAssembly_1.patchWebAssembly();
43
- addGlobalEventProcessor(function (event) {
44
- var haveWasm = false;
43
+ addGlobalEventProcessor((event) => {
44
+ let haveWasm = false;
45
45
  if (event.exception && event.exception.values) {
46
- event.exception.values.forEach(function (exception) {
46
+ event.exception.values.forEach(exception => {
47
47
  var _a;
48
48
  if ((_a = exception === null || exception === void 0 ? void 0 : exception.stacktrace) === null || _a === void 0 ? void 0 : _a.frames) {
49
49
  haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);
@@ -56,12 +56,11 @@ var Wasm = /** @class */ (function () {
56
56
  }
57
57
  return event;
58
58
  });
59
- };
60
- /**
61
- * @inheritDoc
62
- */
63
- Wasm.id = 'Wasm';
64
- return Wasm;
65
- }());
59
+ }
60
+ }
66
61
  exports.Wasm = Wasm;
62
+ /**
63
+ * @inheritDoc
64
+ */
65
+ Wasm.id = 'Wasm';
67
66
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
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;IA2BhC,CAAC;IAzBC;;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,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;IAlCD;;OAEG;IACW,OAAE,GAAW,MAAM,CAAC;IAgCpC,WAAC;CAAA,AApCD,IAoCC;AApCY,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\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
+ {"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,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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"]}
@@ -1,14 +1,14 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
- var registry_1 = require("./registry");
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
- var origInstantiateStreaming_1 = WebAssembly.instantiateStreaming;
8
+ const origInstantiateStreaming = WebAssembly.instantiateStreaming;
9
9
  WebAssembly.instantiateStreaming = function instantiateStreaming(response, importObject) {
10
- return Promise.resolve(response).then(function (response) {
11
- return origInstantiateStreaming_1(response, importObject).then(function (rv) {
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
- var origCompileStreaming_1 = WebAssembly.compileStreaming;
21
+ const origCompileStreaming = WebAssembly.compileStreaming;
22
22
  WebAssembly.compileStreaming = function compileStreaming(source) {
23
- return Promise.resolve(source).then(function (response) {
24
- return origCompileStreaming_1(response).then(function (module) {
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
  }
@@ -1 +1 @@
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"]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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"]}
package/cjs/registry.js CHANGED
@@ -7,31 +7,31 @@ exports.IMAGES = [];
7
7
  * @param module
8
8
  */
9
9
  function getModuleInfo(module) {
10
- var buildIds = WebAssembly.Module.customSections(module, 'build_id');
11
- var buildId = null;
12
- var debugFile = null;
10
+ const buildIds = WebAssembly.Module.customSections(module, 'build_id');
11
+ let buildId = null;
12
+ let debugFile = null;
13
13
  if (buildIds.length > 0) {
14
- var firstBuildId = new Uint8Array(buildIds[0]);
15
- buildId = Array.from(firstBuildId).reduce(function (acc, x) {
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
- var externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info');
19
+ const externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info');
20
20
  if (externalDebugInfo.length > 0) {
21
- var firstExternalDebugInfo = new Uint8Array(externalDebugInfo[0]);
22
- var decoder = new TextDecoder('utf-8');
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: buildId, debugFile: debugFile };
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
- var _a = getModuleInfo(module), buildId = _a.buildId, debugFile = _a.debugFile;
32
+ const { buildId, debugFile } = getModuleInfo(module);
33
33
  if (buildId) {
34
- var oldIdx = exports.IMAGES.findIndex(function (img) { return img.code_file === url; });
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) + "0",
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(function (img) { return img.code_file === url; });
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,IAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM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AC,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,EAAK,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,MAAG;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,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,SAAS,KAAK,GAAG,EAArB,CAAqB,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"]}
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,CAA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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.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
- var haveWasm = false;
6
- frames.forEach(function (frame) {
5
+ let haveWasm = false;
6
+ frames.forEach(frame => {
7
7
  if (!frame.filename) {
8
8
  return;
9
9
  }
10
- var match = frame.filename.match(/^(.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/);
10
+ const match = frame.filename.match(/^(.*?):wasm-function\[\d+\]:(0x[a-fA-F0-9]+)$/);
11
11
  if (match !== null) {
12
- var index = getImage(match[1]);
12
+ const index = getImage(match[1]);
13
13
  if (index >= 0) {
14
14
  frame.instruction_addr = match[2];
15
- frame.addr_mode = "rel:" + index;
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
- var Wasm = /** @class */ (function () {
31
- function Wasm() {
30
+ export class Wasm {
31
+ constructor() {
32
32
  /**
33
33
  * @inheritDoc
34
34
  */
@@ -37,12 +37,12 @@ var Wasm = /** @class */ (function () {
37
37
  /**
38
38
  * @inheritDoc
39
39
  */
40
- Wasm.prototype.setupOnce = function (addGlobalEventProcessor, _getCurrentHub) {
40
+ setupOnce(addGlobalEventProcessor, _getCurrentHub) {
41
41
  patchWebAssembly();
42
- addGlobalEventProcessor(function (event) {
43
- var haveWasm = false;
42
+ addGlobalEventProcessor((event) => {
43
+ let haveWasm = false;
44
44
  if (event.exception && event.exception.values) {
45
- event.exception.values.forEach(function (exception) {
45
+ event.exception.values.forEach(exception => {
46
46
  var _a;
47
47
  if ((_a = exception === null || exception === void 0 ? void 0 : exception.stacktrace) === null || _a === void 0 ? void 0 : _a.frames) {
48
48
  haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);
@@ -55,12 +55,10 @@ var Wasm = /** @class */ (function () {
55
55
  }
56
56
  return event;
57
57
  });
58
- };
59
- /**
60
- * @inheritDoc
61
- */
62
- Wasm.id = 'Wasm';
63
- return Wasm;
64
- }());
65
- export { Wasm };
58
+ }
59
+ }
60
+ /**
61
+ * @inheritDoc
62
+ */
63
+ Wasm.id = 'Wasm';
66
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,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,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,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;IA2BhC,CAAC;IAzBC;;OAEG;IACI,wBAAS,GAAhB,UAAiB,uBAA2D,EAAE,cAAyB;QACrG,gBAAgB,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,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;IAlCD;;OAEG;IACW,OAAE,GAAW,MAAM,CAAC;IAgCpC,WAAC;CAAA,AApCD,IAoCC;SApCY,IAAI","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"]}
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,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M,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"]}
@@ -4,10 +4,10 @@ import { registerModule } from './registry';
4
4
  */
5
5
  export function patchWebAssembly() {
6
6
  if ('instantiateStreaming' in WebAssembly) {
7
- var origInstantiateStreaming_1 = WebAssembly.instantiateStreaming;
7
+ const origInstantiateStreaming = WebAssembly.instantiateStreaming;
8
8
  WebAssembly.instantiateStreaming = function instantiateStreaming(response, importObject) {
9
- return Promise.resolve(response).then(function (response) {
10
- return origInstantiateStreaming_1(response, importObject).then(function (rv) {
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
- var origCompileStreaming_1 = WebAssembly.compileStreaming;
20
+ const origCompileStreaming = WebAssembly.compileStreaming;
21
21
  WebAssembly.compileStreaming = function compileStreaming(source) {
22
- return Promise.resolve(source).then(function (response) {
23
- return origCompileStreaming_1(response).then(function (module) {
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,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,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,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,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"]}
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 var IMAGES = [];
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
- var buildIds = WebAssembly.Module.customSections(module, 'build_id');
10
- var buildId = null;
11
- var debugFile = null;
9
+ const buildIds = WebAssembly.Module.customSections(module, 'build_id');
10
+ let buildId = null;
11
+ let debugFile = null;
12
12
  if (buildIds.length > 0) {
13
- var firstBuildId = new Uint8Array(buildIds[0]);
14
- buildId = Array.from(firstBuildId).reduce(function (acc, x) {
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
- var externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info');
18
+ const externalDebugInfo = WebAssembly.Module.customSections(module, 'external_debug_info');
19
19
  if (externalDebugInfo.length > 0) {
20
- var firstExternalDebugInfo = new Uint8Array(externalDebugInfo[0]);
21
- var decoder = new TextDecoder('utf-8');
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: buildId, debugFile: debugFile };
24
+ return { buildId, debugFile };
25
25
  }
26
26
  /**
27
27
  * Records a module
28
28
  */
29
29
  export function registerModule(module, url) {
30
- var _a = getModuleInfo(module), buildId = _a.buildId, debugFile = _a.debugFile;
30
+ const { buildId, debugFile } = getModuleInfo(module);
31
31
  if (buildId) {
32
- var oldIdx = IMAGES.findIndex(function (img) { return img.code_file === url; });
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) + "0",
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(function (img) { return img.code_file === url; });
57
+ return IMAGES.findIndex(img => img.code_file === url);
58
58
  }
59
59
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/registry.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,IAAM,MAAM,GAAsB,EAAE,CAAC;AAO5C;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,MAA0B;IACtD,IAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvE,IA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C;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,EAAK,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,MAAG;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,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,SAAS,KAAK,GAAG,EAArB,CAAqB,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"]}
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,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AAQ,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,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/wasm",
3
- "version": "7.0.0-alpha.1",
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",
@@ -16,8 +16,8 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@sentry/browser": "7.0.0-alpha.1",
20
- "@sentry/types": "7.0.0-alpha.1",
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": {