From 98b4dbed6d33a25d85057344b2698cbd1a5d94b7 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Fri, 24 Jan 2025 21:25:34 +0000 Subject: [PATCH] fix: rrweb patch fix take 2 (#1691) --- patches/@rrweb__record@2.0.0-alpha.18.patch | 18 ++++++++++-------- pnpm-lock.yaml | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/patches/@rrweb__record@2.0.0-alpha.18.patch b/patches/@rrweb__record@2.0.0-alpha.18.patch index 3378d3598..7e1816662 100644 --- a/patches/@rrweb__record@2.0.0-alpha.18.patch +++ b/patches/@rrweb__record@2.0.0-alpha.18.patch @@ -1,5 +1,5 @@ diff --git a/dist/record.js b/dist/record.js -index d9c57625633fb87da27fc5948c1b15a7c4e4caa5..d43fabe4d92be3a17c4ee8012d8a9d91d30b09fd 100644 +index d9c57625633fb87da27fc5948c1b15a7c4e4caa5..30dbe05ea243ef79f6f7f2b6b5474cd7599dcb43 100644 --- a/dist/record.js +++ b/dist/record.js @@ -26,14 +26,33 @@ const testableMethods$1 = { @@ -110,13 +110,13 @@ index d9c57625633fb87da27fc5948c1b15a7c4e4caa5..d43fabe4d92be3a17c4ee8012d8a9d91 - const textContentNorm = normalizeCssString(childNodes2[i2].textContent); - for (let j = 3; j < textContentNorm.length; j++) { + let iterLimit = 0; ++ // cssText is mutated so we keep the original for when we cache the result ++ const og = cssText + if (childNodes.length > 1 && cssText && typeof cssText === 'string') { + if (splitCache.has(cssText)) { + // we know there's a result + return splitCache.get(cssText) + } -+ // cssText is mutated so we keep the original for when we cache the result -+ const og = cssText + let cssTextNorm = normalizeCssString(cssText); + const normFactor = cssTextNorm.length / cssText.length; + for (let i = 1; i < childNodes.length; i++) { @@ -7922,7 +7922,7 @@ index d9c57625633fb87da27fc5948c1b15a7c4e4caa5..d43fabe4d92be3a17c4ee8012d8a9d91 }, [bitmap] diff --git a/dist/record.umd.cjs b/dist/record.umd.cjs -index 902c5eca13b2c3e69af25afa682d2e7300372bfc..4246d630b0a1b5b3a5ab9b2986a955c846c69708 100644 +index 902c5eca13b2c3e69af25afa682d2e7300372bfc..5e09da575b4f192dfe03ca0de6e3c58b75d829f2 100644 --- a/dist/record.umd.cjs +++ b/dist/record.umd.cjs @@ -470,26 +470,98 @@ function absolutifyURLs(cssText, href) { @@ -7963,13 +7963,13 @@ index 902c5eca13b2c3e69af25afa682d2e7300372bfc..4246d630b0a1b5b3a5ab9b2986a955c8 - const textContentNorm = normalizeCssString(childNodes2[i2].textContent); - for (let j = 3; j < textContentNorm.length; j++) { + let iterLimit = 0; ++ // cssText is mutated so we keep the original for when we cache the result ++ const og = cssText + if (childNodes.length > 1 && cssText && typeof cssText === 'string') { + if (splitCache.has(cssText)) { + // we know there's a result + return splitCache.get(cssText) + } -+ // cssText is mutated so we keep the original for when we cache the result -+ const og = cssText + let cssTextNorm = normalizeCssString(cssText); + const normFactor = cssTextNorm.length / cssText.length; + for (let i = 1; i < childNodes.length; i++) { @@ -8038,13 +8038,15 @@ index 902c5eca13b2c3e69af25afa682d2e7300372bfc..4246d630b0a1b5b3a5ab9b2986a955c8 } } break; -@@ -498,7 +570,8 @@ function splitCssText(cssText, style) { +@@ -498,7 +570,10 @@ function splitCssText(cssText, style) { } } } - splits.push(cssText); + splits.push(cssText); // either the full thing if no splits were found, or the last split -+ splitCache.set(og, splits); ++ if (og) { ++ splitCache.set(og, splits); ++ } return splits; } function markCssSplits(cssText, style) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0e09d3cc9..d4a4370e0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: patchedDependencies: '@rrweb/record@2.0.0-alpha.18': - hash: h2mo2zvt7kxzabiw4jvsjdn42e + hash: s674fwxwhjljk2m6xsch5lk5hq path: patches/@rrweb__record@2.0.0-alpha.18.patch '@rrweb/rrweb-plugin-console-record@2.0.0-alpha.18': hash: xqev6zvgnatibyueo4tkcc7s5q @@ -74,7 +74,7 @@ devDependencies: version: 12.1.2(rollup@4.28.1)(tslib@2.5.0)(typescript@5.5.4) '@rrweb/record': specifier: 2.0.0-alpha.18 - version: 2.0.0-alpha.18(patch_hash=h2mo2zvt7kxzabiw4jvsjdn42e) + version: 2.0.0-alpha.18(patch_hash=s674fwxwhjljk2m6xsch5lk5hq) '@rrweb/rrweb-plugin-console-record': specifier: 2.0.0-alpha.18 version: 2.0.0-alpha.18(patch_hash=xqev6zvgnatibyueo4tkcc7s5q)(rrweb@2.0.0-alpha.18) @@ -2857,7 +2857,7 @@ packages: dev: true optional: true - /@rrweb/record@2.0.0-alpha.18(patch_hash=h2mo2zvt7kxzabiw4jvsjdn42e): + /@rrweb/record@2.0.0-alpha.18(patch_hash=s674fwxwhjljk2m6xsch5lk5hq): resolution: {integrity: sha512-WbzcybTEqT+cKkOnzYiyaAYvNzAIxTK9f8qNLNOG9lOqWsmi+qu/W7CEdxHmfjlfgXGw/f7bxGZggAWVaizKqg==} dependencies: '@rrweb/types': 2.0.0-alpha.18