Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: upgrade rrweb
  • Loading branch information
daibhin committed Oct 22, 2024
commit b311956e1520c6eda1775323e6f387166ba214e5
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -127,7 +127,7 @@
],
"pnpm": {
"patchedDependencies": {
"[email protected].16": "patches/[email protected].16.patch"
"[email protected].17": "patches/[email protected].17.patch"
}
}
}
81 changes: 81 additions & 0 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -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]
47 changes: 24 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.