codecharta-visualization 2.4.0 → 2.5.1

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.
@@ -6,6 +6,9 @@ class CustomJSDOMEnvironment extends JSDOMEnvironment {
6
6
 
7
7
  // Expose Node.js structuredClone to jsdom global
8
8
  this.global.structuredClone = structuredClone
9
+
10
+ // jsdom's crypto has no subtle, so expose Node.js Web Crypto digests
11
+ Object.defineProperty(this.global.crypto, "subtle", { value: globalThis.crypto.subtle, writable: true, configurable: true })
9
12
  }
10
13
  }
11
14
 
@@ -28,9 +28,9 @@ if (typeof globalThis.fetch === "undefined") {
28
28
  ) as any
29
29
  }
30
30
 
31
- // JSDOM implements neither Blob.text() nor File.text(), which every browser the app runs in has had
32
- // for years, so reading an uploaded file would reject in tests alone. FileReader is implemented, so
33
- // it stands in.
31
+ // JSDOM implements neither Blob.text()/arrayBuffer() nor their File counterparts, which every browser
32
+ // the app runs in has had for years, so reading an uploaded file would reject in tests alone.
33
+ // FileReader is implemented, so it stands in.
34
34
  if (typeof Blob.prototype.text === "undefined") {
35
35
  Blob.prototype.text = function (this: Blob) {
36
36
  return new Promise<string>((resolve, reject) => {
@@ -42,6 +42,17 @@ if (typeof Blob.prototype.text === "undefined") {
42
42
  }
43
43
  }
44
44
 
45
+ if (typeof Blob.prototype.arrayBuffer === "undefined") {
46
+ Blob.prototype.arrayBuffer = function (this: Blob) {
47
+ return new Promise<ArrayBuffer>((resolve, reject) => {
48
+ const reader = new FileReader()
49
+ reader.onload = () => resolve(reader.result as ArrayBuffer)
50
+ reader.onerror = () => reject(reader.error)
51
+ reader.readAsArrayBuffer(this)
52
+ })
53
+ }
54
+ }
55
+
45
56
  // JSDOM (nwsapi) does not implement the native Popover API or the :popover-open selector.
46
57
  // Without zone.js swallowing the thrown error, components calling popover.matches(":popover-open")
47
58
  // would fail tests. Make the selector match nothing and stub the popover methods.