Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade rrweb to alpha.16 #1276

Merged
merged 30 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4d55234
chore: upgrade rrweb to alpha.16
daibhin Jun 26, 2024
858c900
add patches
daibhin Jun 26, 2024
5a9c55c
await not yield
daibhin Jun 26, 2024
936a040
update imports
daibhin Jun 27, 2024
d8a367c
readd types
daibhin Jun 27, 2024
1c52fa2
add necessary package
daibhin Jun 27, 2024
bc298a5
fix import issues
daibhin Jun 27, 2024
9b953af
include tsc check
daibhin Jun 27, 2024
84acf2d
move to dev dependency
daibhin Jun 27, 2024
625b3db
fix patching
daibhin Jun 27, 2024
99e86e1
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Jun 28, 2024
9a48218
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Jul 2, 2024
869db07
fix typescript error on rrwebs end (https://rrweb.slack.com/archives/…
daibhin Jul 4, 2024
d690015
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Jul 4, 2024
c8244ea
add comment
daibhin Jul 4, 2024
2f31e1c
Merge branch 'main' into dn-chore/upgrade-rrweb
pauldambra Jul 8, 2024
7b07766
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Jul 9, 2024
e964112
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Jul 31, 2024
b0e022d
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Jul 31, 2024
d064109
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Oct 14, 2024
5dcf91a
remove dodgy function
daibhin Oct 14, 2024
4867257
remove old patch
daibhin Oct 14, 2024
c41a808
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Oct 14, 2024
59a3d08
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Oct 16, 2024
b6f2a18
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Oct 16, 2024
9245c9e
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Oct 17, 2024
40e0f7d
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Oct 17, 2024
0f7dc10
Merge branch 'main' into dn-chore/upgrade-rrweb
pauldambra Oct 18, 2024
1284fef
Merge branch 'main' into dn-chore/upgrade-rrweb
daibhin Oct 22, 2024
4facee8
fix variable names
daibhin Oct 22, 2024
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
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@rrweb/types": "2.0.0-alpha.13",
"@rrweb/types": "2.0.0-alpha.16",
"@sentry/types": "8.7.0",
"@testing-library/dom": "^9.3.0",
"@testing-library/jest-dom": "^6.4.5",
Expand Down Expand Up @@ -94,8 +94,8 @@
"rollup": "^4.9.6",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-visualizer": "^5.12.0",
"rrweb": "2.0.0-alpha.13",
"rrweb-snapshot": "2.0.0-alpha.13",
"rrweb": "2.0.0-alpha.16",
"rrweb-snapshot": "2.0.0-alpha.16",
"sinon": "9.0.2",
"testcafe": "1.19.0",
"testcafe-browser-provider-browserstack": "1.14.0",
Expand All @@ -116,7 +116,7 @@
],
"pnpm": {
"patchedDependencies": {
"[email protected].13": "patches/[email protected].13.patch"
"[email protected].16": "patches/[email protected].16.patch"
}
}
}
74 changes: 74 additions & 0 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
diff --git a/dist/rrweb.js b/dist/rrweb.js
index 1db2d08b2fe9a73521001c3aa88b1a64d1b3e71a..a9a473fca25eeec5c6794c4806baffe2d1bc1e15 100644
--- a/dist/rrweb.js
+++ b/dist/rrweb.js
@@ -661,9 +661,17 @@ function serializeElementNode(n2, options) {
}
}
if (tagName === "link" && inlineStylesheet) {
- const stylesheet = Array.from(doc.styleSheets).find((s2) => {
- return s2.href === n2.href;
- });
+ function findStylesheet(href) {
+ return Array.from(doc.styleSheets).find((s2) => {
+ return s2.href === href;
+ });
+ }
+ let stylesheet = findStylesheet(n2.href);
+ if (!stylesheet && href.includes('.css')) {
+ const stylesheetPath = href.replace(window.location.href, '');
+ const potentialStylesheetHref = window.location.origin + '/' + stylesheetPath;
+ stylesheet = findStylesheet(potentialStylesheetHref);
+ }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces

- const stylesheet = Array.from(doc.styleSheets).find((s) => {
- return s.href === n.href;
+ const href = n.href
+ let stylesheet = Array.from(doc.styleSheets).find((s) => {
+ return s.href === href;
});
+ if (!stylesheet && href.includes('.css')) {
+ const rootDomain = window.location.origin
+ const stylesheetPath = href.replace(window.location.href, '')
+ const potentialStylesheetHref = rootDomain + '/' + stylesheetPath
+ stylesheet = Array.from(doc.styleSheets).find((s) => {
+ return s.href === 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 = yield createImageBitmap(canvas, {
+ resizeWidth: width,
+ resizeHeight: height
+ });
worker.postMessage(
{
id,
bitmap,
- width: canvas.width,
- height: canvas.height,
+ width: width,
+ height: height,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaces

- const bitmap = yield 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 = yield createImageBitmap(canvas, {
+ resizeWidth: width,
+ resizeHeight: height
+ })
+
worker.postMessage({
id,
bitmap,
- width: canvas.width,
- height: canvas.height,
+ width: width,
+ height: height,

dataURLOptions: options.dataURLOptions
},
[bitmap]
46 changes: 23 additions & 23 deletions pnpm-lock.yaml

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

Loading