From b311956e1520c6eda1775323e6f387166ba214e5 Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 22 Oct 2024 17:33:03 +0100 Subject: [PATCH 1/4] chore: upgrade rrweb --- package.json | 10 ++-- patches/rrweb@2.0.0-alpha.17.patch | 81 ++++++++++++++++++++++++++++++ pnpm-lock.yaml | 47 ++++++++--------- 3 files changed, 110 insertions(+), 28 deletions(-) create mode 100644 patches/rrweb@2.0.0-alpha.17.patch diff --git a/package.json b/package.json index 17e2980c1..6351d2c61 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,8 @@ "@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^12.1.1", - "@rrweb/types": "2.0.0-alpha.16", + "@rrweb/rrweb-plugin-console-record": "2.0.0-alpha.15", + "@rrweb/types": "2.0.0-alpha.17", "@sentry/types": "8.7.0", "@testing-library/dom": "^9.3.0", "@testing-library/jest-dom": "^6.5.0", @@ -103,9 +104,8 @@ "rollup": "^4.24.0", "rollup-plugin-dts": "^6.1.1", "rollup-plugin-visualizer": "^5.12.0", - "rrweb": "2.0.0-alpha.16", - "@rrweb/rrweb-plugin-console-record": "2.0.0-alpha.15", - "rrweb-snapshot": "2.0.0-alpha.16", + "rrweb": "2.0.0-alpha.17", + "rrweb-snapshot": "2.0.0-alpha.17", "sinon": "9.0.2", "testcafe": "1.19.0", "testcafe-browser-provider-browserstack": "1.14.0", @@ -127,7 +127,7 @@ ], "pnpm": { "patchedDependencies": { - "rrweb@2.0.0-alpha.16": "patches/rrweb@2.0.0-alpha.16.patch" + "rrweb@2.0.0-alpha.17": "patches/rrweb@2.0.0-alpha.17.patch" } } } diff --git a/patches/rrweb@2.0.0-alpha.17.patch b/patches/rrweb@2.0.0-alpha.17.patch new file mode 100644 index 000000000..7caa5db40 --- /dev/null +++ b/patches/rrweb@2.0.0-alpha.17.patch @@ -0,0 +1,81 @@ +diff --git a/dist/rrweb.js b/dist/rrweb.js +index 12f4ad3c7f897fe8a9ee2f4595dcf37f302d17c5..43f6bd95676c456e187b7bd68ba7af56e7b09f29 100644 +--- a/dist/rrweb.js ++++ b/dist/rrweb.js +@@ -246,6 +246,9 @@ function isCSSImportRule(rule2) { + function isCSSStyleRule(rule2) { + return "selectorText" in rule2; + } ++function findStylesheet(doc, href) { ++ return Array.from(doc.styleSheets).find((s) => s.href === href); ++} + class Mirror { + constructor() { + __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map()); +@@ -821,9 +824,14 @@ function serializeElementNode(n2, options) { + } + } + if (tagName === "link" && inlineStylesheet) { +- const stylesheet = Array.from(doc.styleSheets).find((s2) => { +- return s2.href === n2.href; +- }); ++ const href = n2.href; ++ let stylesheet = findStylesheet(doc, href); ++ if (!stylesheet && href.includes('.css')) { ++ const rootDomain = window.location.origin; ++ const stylesheetPath = href.replace(window.location.href, ''); ++ const potentialStylesheetHref = rootDomain + '/' + stylesheetPath; ++ stylesheet = findStylesheet(doc, potentialStylesheetHref); ++ } + let cssText = null; + if (stylesheet) { + cssText = stringifyStylesheet(stylesheet); +@@ -13276,11 +13284,19 @@ class CanvasManager { + let rafId; + const getCanvas = () => { + const matchedCanvas = []; +- win.document.querySelectorAll("canvas").forEach((canvas) => { +- if (!isBlocked(canvas, blockClass, blockSelector, true)) { +- matchedCanvas.push(canvas); +- } +- }); ++ const searchCanvas = (root) => { ++ root.querySelectorAll("canvas").forEach((canvas) => { ++ if (!isBlocked(canvas, blockClass, blockSelector, true)) { ++ matchedCanvas.push(canvas); ++ } ++ }); ++ root.querySelectorAll("*").forEach((elem) => { ++ if (elem.shadowRoot) { ++ searchCanvas(elem.shadowRoot); ++ } ++ }); ++ }; ++ searchCanvas(win.document); + return matchedCanvas; + }; + const takeCanvasSnapshots = (timestamp) => { +@@ -13301,13 +13317,20 @@ class CanvasManager { + context.clear(context.COLOR_BUFFER_BIT); + } + } +- const bitmap = await createImageBitmap(canvas); ++ // createImageBitmap throws if resizing to 0 ++ // Fallback to intrinsic size if canvas has not yet rendered ++ const width = canvas.clientWidth || canvas.width; ++ const height = canvas.clientHeight || canvas.height; ++ const bitmap = await createImageBitmap(canvas, { ++ resizeWidth: width, ++ resizeHeight: height ++ }); + worker.postMessage( + { + id, + bitmap, +- width: canvas.width, +- height: canvas.height, ++ width: width, ++ height: height, + dataURLOptions: options.dataURLOptions + }, + [bitmap] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bdee9346f..79ae50e62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,9 +5,9 @@ settings: excludeLinksFromLockfile: false patchedDependencies: - rrweb@2.0.0-alpha.16: - hash: x52pllmg6k5suqkcoa7bdybazq - path: patches/rrweb@2.0.0-alpha.16.patch + rrweb@2.0.0-alpha.17: + hash: xlkuvshzdprjlpxe7nzsj3spyi + path: patches/rrweb@2.0.0-alpha.17.patch dependencies: core-js: @@ -68,10 +68,10 @@ devDependencies: version: 12.1.1(rollup@4.24.0)(tslib@2.5.0)(typescript@5.5.4) '@rrweb/rrweb-plugin-console-record': specifier: 2.0.0-alpha.15 - version: 2.0.0-alpha.15(rrweb@2.0.0-alpha.16) + version: 2.0.0-alpha.15(rrweb@2.0.0-alpha.17) '@rrweb/types': - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 + specifier: 2.0.0-alpha.17 + version: 2.0.0-alpha.17 '@sentry/types': specifier: 8.7.0 version: 8.7.0 @@ -205,11 +205,11 @@ devDependencies: specifier: ^5.12.0 version: 5.12.0(rollup@4.24.0) rrweb: - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16(patch_hash=x52pllmg6k5suqkcoa7bdybazq) + specifier: 2.0.0-alpha.17 + version: 2.0.0-alpha.17(patch_hash=xlkuvshzdprjlpxe7nzsj3spyi) rrweb-snapshot: - specifier: 2.0.0-alpha.16 - version: 2.0.0-alpha.16 + specifier: 2.0.0-alpha.17 + version: 2.0.0-alpha.17 sinon: specifier: 9.0.2 version: 9.0.2 @@ -2802,18 +2802,22 @@ packages: dev: true optional: true - /@rrweb/rrweb-plugin-console-record@2.0.0-alpha.15(rrweb@2.0.0-alpha.16): + /@rrweb/rrweb-plugin-console-record@2.0.0-alpha.15(rrweb@2.0.0-alpha.17): resolution: {integrity: sha512-66iOkD99AS8WqQNAnDtkJsQnSD8E+tZx3tWMJltpRDovXs4GoBE9eYxQeTWSigz6iaqbrxYPIqQIRck+zqnheg==} peerDependencies: rrweb: ^2.0.0-alpha.15 dependencies: - rrweb: 2.0.0-alpha.16(patch_hash=x52pllmg6k5suqkcoa7bdybazq) + rrweb: 2.0.0-alpha.17(patch_hash=xlkuvshzdprjlpxe7nzsj3spyi) dev: true - /@rrweb/types@2.0.0-alpha.16: - resolution: {integrity: sha512-E6cACNVsm+NUhn7dzocQoKyXI7BHrHRRm5Ab23yrAzEQ2caWocCEYJhqDlc4KRVJBkQfXZfyWm8+2d0uggFuZg==} + /@rrweb/types@2.0.0-alpha.17: + resolution: {integrity: sha512-AfDTVUuCyCaIG0lTSqYtrZqJX39ZEYzs4fYKnexhQ+id+kbZIpIJtaut5cto6dWZbB3SEe4fW0o90Po3LvTmfg==} dependencies: - rrweb-snapshot: 2.0.0-alpha.16 + rrweb-snapshot: 2.0.0-alpha.17 + dev: true + + /@rrweb/utils@2.0.0-alpha.17: + resolution: {integrity: sha512-HCsasPERBwOS9/LQeOytO2ETKTCqRj1wORBuxiy3t41hKhmi225DdrUPiWnyDdTQm1GdVbOymMRknJVPnZaSXw==} dev: true /@sentry/types@8.7.0: @@ -9402,26 +9406,23 @@ packages: rrweb-snapshot: 2.0.0-alpha.17 dev: true - /rrweb-snapshot@2.0.0-alpha.16: - resolution: {integrity: sha512-p81OrzUiCmUMZzJu4fGHeLB00PIbVIqsV/zhqzr2pitHTUXpMYcyOvDWt0vHdla0vnowEPaHq3Wsu6cUc732/w==} - dev: true - /rrweb-snapshot@2.0.0-alpha.17: resolution: {integrity: sha512-GBg5pV8LHOTbeVmH2VHLEFR0mc2QpQMzAvcoxEGfPNWgWHc8UvKCyq7pqN1vA+fDZ+yXXbixeO0kB2pzVvFCBw==} dependencies: postcss: 8.4.47 dev: true - /rrweb@2.0.0-alpha.16(patch_hash=x52pllmg6k5suqkcoa7bdybazq): - resolution: {integrity: sha512-Uxl7quZc8gm9RqrUR+10prZBoAfKWvM5lqlWDe7zd2wAkMiBQawDHUrmt8dByx96aiLonvm4oLsbBK14A0A0Tg==} + /rrweb@2.0.0-alpha.17(patch_hash=xlkuvshzdprjlpxe7nzsj3spyi): + resolution: {integrity: sha512-GQxBkCC4r9XL2bwSdv7iIS49M3cEA8OtObVq0rrQ4GUT4+h7omucGQ4x7m5YN5Vq1oalStBaBlYqF7yRnfG3JA==} dependencies: - '@rrweb/types': 2.0.0-alpha.16 + '@rrweb/types': 2.0.0-alpha.17 + '@rrweb/utils': 2.0.0-alpha.17 '@types/css-font-loading-module': 0.0.7 '@xstate/fsm': 1.5.2 base64-arraybuffer: 1.0.2 mitt: 3.0.0 rrdom: 2.0.0-alpha.17 - rrweb-snapshot: 2.0.0-alpha.16 + rrweb-snapshot: 2.0.0-alpha.17 dev: true patched: true From c1ae66bb4afa8bcd665c5dc483b046263dfaa779 Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 22 Oct 2024 17:33:21 +0100 Subject: [PATCH 2/4] remove old patch --- patches/rrweb@2.0.0-alpha.16.patch | 98 ------------------------------ 1 file changed, 98 deletions(-) delete mode 100644 patches/rrweb@2.0.0-alpha.16.patch diff --git a/patches/rrweb@2.0.0-alpha.16.patch b/patches/rrweb@2.0.0-alpha.16.patch deleted file mode 100644 index 5a76bf4d6..000000000 --- a/patches/rrweb@2.0.0-alpha.16.patch +++ /dev/null @@ -1,98 +0,0 @@ -diff --git a/dist/rrweb.js b/dist/rrweb.js -index 1db2d08b2fe9a73521001c3aa88b1a64d1b3e71a..5a3ea8410b0f1dfa7248b9cb9752c04eea7b3ad3 100644 ---- a/dist/rrweb.js -+++ b/dist/rrweb.js -@@ -85,6 +85,9 @@ function isCSSImportRule(rule) { - function isCSSStyleRule(rule) { - return "selectorText" in rule; - } -+function findStylesheet(doc, href) { -+ return Array.from(doc.styleSheets).find((s) => s.href === href); -+} - class Mirror { - constructor() { - __publicField$1(this, "idNodeMap", /* @__PURE__ */ new Map()); -@@ -661,9 +664,14 @@ function serializeElementNode(n2, options) { - } - } - if (tagName === "link" && inlineStylesheet) { -- const stylesheet = Array.from(doc.styleSheets).find((s2) => { -- return s2.href === n2.href; -- }); -+ const href = n2.href; -+ let stylesheet = findStylesheet(doc, href); -+ if (!stylesheet && href.includes('.css')) { -+ const rootDomain = window.location.origin -+ const stylesheetPath = href.replace(window.location.href, '') -+ const potentialStylesheetHref = rootDomain + '/' + stylesheetPath -+ stylesheet = findStylesheet(doc, potentialStylesheetHref); -+ } - let cssText = null; - if (stylesheet) { - cssText = stringifyStylesheet(stylesheet); -@@ -5016,11 +5024,19 @@ class CanvasManager { - let rafId; - const getCanvas = () => { - const matchedCanvas = []; -- win.document.querySelectorAll("canvas").forEach((canvas) => { -- if (!isBlocked(canvas, blockClass, blockSelector, true)) { -- matchedCanvas.push(canvas); -- } -- }); -+ const searchCanvas = (root) => { -+ root.querySelectorAll("canvas").forEach((canvas) => { -+ if (!isBlocked(canvas, blockClass, blockSelector, true)) { -+ matchedCanvas.push(canvas); -+ } -+ }); -+ root.querySelectorAll("*").forEach((elem) => { -+ if (elem.shadowRoot) { -+ searchCanvas(elem.shadowRoot); -+ } -+ }); -+ }; -+ searchCanvas(win.document); - return matchedCanvas; - }; - const takeCanvasSnapshots = (timestamp) => { -@@ -5041,13 +5057,20 @@ class CanvasManager { - context.clear(context.COLOR_BUFFER_BIT); - } - } -- const bitmap = await createImageBitmap(canvas); -+ // createImageBitmap throws if resizing to 0 -+ // Fallback to intrinsic size if canvas has not yet rendered -+ const width = canvas.clientWidth || canvas.width; -+ const height = canvas.clientHeight || canvas.height; -+ const bitmap = await createImageBitmap(canvas, { -+ resizeWidth: width, -+ resizeHeight: height -+ }); - worker.postMessage( - { - id, - bitmap, -- width: canvas.width, -- height: canvas.height, -+ width: width, -+ height: height, - dataURLOptions: options.dataURLOptions - }, - [bitmap] -@@ -9805,6 +9828,7 @@ class Replayer { - } - const { addCustomEvent } = record; - const { freezePage } = record; -+const version = "2.0.0-alpha.16" - export { - EventType, - IncrementalSource, -@@ -9816,6 +9840,7 @@ export { - freezePage, - _mirror as mirror, - record, -- utils -+ utils, -+ version, - }; - //# sourceMappingURL=rrweb.js.map From df01b84cee502ea5577e5861f4b5e87951523321 Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 22 Oct 2024 18:30:10 +0100 Subject: [PATCH 3/4] fix wrong import --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 6351d2c61..589235fae 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "@rollup/plugin-node-resolve": "^15.3.0", "@rollup/plugin-terser": "^0.4.4", "@rollup/plugin-typescript": "^12.1.1", - "@rrweb/rrweb-plugin-console-record": "2.0.0-alpha.15", + "@rrweb/rrweb-plugin-console-record": "2.0.0-alpha.17", "@rrweb/types": "2.0.0-alpha.17", "@sentry/types": "8.7.0", "@testing-library/dom": "^9.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 79ae50e62..bc8d2dcea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,8 +67,8 @@ devDependencies: specifier: ^12.1.1 version: 12.1.1(rollup@4.24.0)(tslib@2.5.0)(typescript@5.5.4) '@rrweb/rrweb-plugin-console-record': - specifier: 2.0.0-alpha.15 - version: 2.0.0-alpha.15(rrweb@2.0.0-alpha.17) + specifier: 2.0.0-alpha.17 + version: 2.0.0-alpha.17(rrweb@2.0.0-alpha.17) '@rrweb/types': specifier: 2.0.0-alpha.17 version: 2.0.0-alpha.17 @@ -2802,10 +2802,10 @@ packages: dev: true optional: true - /@rrweb/rrweb-plugin-console-record@2.0.0-alpha.15(rrweb@2.0.0-alpha.17): - resolution: {integrity: sha512-66iOkD99AS8WqQNAnDtkJsQnSD8E+tZx3tWMJltpRDovXs4GoBE9eYxQeTWSigz6iaqbrxYPIqQIRck+zqnheg==} + /@rrweb/rrweb-plugin-console-record@2.0.0-alpha.17(rrweb@2.0.0-alpha.17): + resolution: {integrity: sha512-tjNJ3wWUDMMf275xr4Rb5tVYF2UR+wXvSxnyS9tRKnRa574PQQvx7sGbqM/O9AytYjnbiTrAMqNR7OFysGCMwQ==} peerDependencies: - rrweb: ^2.0.0-alpha.15 + rrweb: ^2.0.0-alpha.17 dependencies: rrweb: 2.0.0-alpha.17(patch_hash=xlkuvshzdprjlpxe7nzsj3spyi) dev: true From e0b8b402cb3126f0def399b4bf50d09e956d1a73 Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 22 Oct 2024 18:34:03 +0100 Subject: [PATCH 4/4] add version back --- patches/rrweb@2.0.0-alpha.17.patch | 19 ++++++++++++++++++- pnpm-lock.yaml | 8 ++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/patches/rrweb@2.0.0-alpha.17.patch b/patches/rrweb@2.0.0-alpha.17.patch index 7caa5db40..1101b681e 100644 --- a/patches/rrweb@2.0.0-alpha.17.patch +++ b/patches/rrweb@2.0.0-alpha.17.patch @@ -1,5 +1,5 @@ diff --git a/dist/rrweb.js b/dist/rrweb.js -index 12f4ad3c7f897fe8a9ee2f4595dcf37f302d17c5..43f6bd95676c456e187b7bd68ba7af56e7b09f29 100644 +index 12f4ad3c7f897fe8a9ee2f4595dcf37f302d17c5..2fb78e052ab4daf9f8d2435d74035564b8f1ef13 100644 --- a/dist/rrweb.js +++ b/dist/rrweb.js @@ -246,6 +246,9 @@ function isCSSImportRule(rule2) { @@ -79,3 +79,20 @@ index 12f4ad3c7f897fe8a9ee2f4595dcf37f302d17c5..43f6bd95676c456e187b7bd68ba7af56 dataURLOptions: options.dataURLOptions }, [bitmap] +@@ -16841,6 +16864,7 @@ class Replayer { + const { addCustomEvent } = record; + const { freezePage } = record; + const { takeFullSnapshot } = record; ++const version = "2.0.0-alpha.17"; + export { + EventType, + IncrementalSource, +@@ -16853,6 +16877,7 @@ export { + _mirror as mirror, + record, + takeFullSnapshot, +- utils ++ utils, ++ version + }; + //# sourceMappingURL=rrweb.js.map diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bc8d2dcea..3520100a8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: patchedDependencies: rrweb@2.0.0-alpha.17: - hash: xlkuvshzdprjlpxe7nzsj3spyi + hash: ovqfbi26faqgvd4dbhm6fm7hwm path: patches/rrweb@2.0.0-alpha.17.patch dependencies: @@ -206,7 +206,7 @@ devDependencies: version: 5.12.0(rollup@4.24.0) rrweb: specifier: 2.0.0-alpha.17 - version: 2.0.0-alpha.17(patch_hash=xlkuvshzdprjlpxe7nzsj3spyi) + version: 2.0.0-alpha.17(patch_hash=ovqfbi26faqgvd4dbhm6fm7hwm) rrweb-snapshot: specifier: 2.0.0-alpha.17 version: 2.0.0-alpha.17 @@ -2807,7 +2807,7 @@ packages: peerDependencies: rrweb: ^2.0.0-alpha.17 dependencies: - rrweb: 2.0.0-alpha.17(patch_hash=xlkuvshzdprjlpxe7nzsj3spyi) + rrweb: 2.0.0-alpha.17(patch_hash=ovqfbi26faqgvd4dbhm6fm7hwm) dev: true /@rrweb/types@2.0.0-alpha.17: @@ -9412,7 +9412,7 @@ packages: postcss: 8.4.47 dev: true - /rrweb@2.0.0-alpha.17(patch_hash=xlkuvshzdprjlpxe7nzsj3spyi): + /rrweb@2.0.0-alpha.17(patch_hash=ovqfbi26faqgvd4dbhm6fm7hwm): resolution: {integrity: sha512-GQxBkCC4r9XL2bwSdv7iIS49M3cEA8OtObVq0rrQ4GUT4+h7omucGQ4x7m5YN5Vq1oalStBaBlYqF7yRnfG3JA==} dependencies: '@rrweb/types': 2.0.0-alpha.17