From 87a5c0b1dc695cae6dc48f46a0b59dcb99b2b2f8 Mon Sep 17 00:00:00 2001 From: David Newell Date: Tue, 30 Apr 2024 14:24:09 +0100 Subject: [PATCH] remove clashing method name and update post patch import --- patches/rrweb@2.0.0-alpha.13.patch | 463 +++++++++++++++++++++++++++-- pnpm-lock.yaml | 6 +- 2 files changed, 442 insertions(+), 27 deletions(-) diff --git a/patches/rrweb@2.0.0-alpha.13.patch b/patches/rrweb@2.0.0-alpha.13.patch index 493b783ab4f772..c23f683c22ad47 100644 --- a/patches/rrweb@2.0.0-alpha.13.patch +++ b/patches/rrweb@2.0.0-alpha.13.patch @@ -530,11 +530,11 @@ index 22fee601e786c1d8dfb5c01d2e359c8bcbac7c42..20c3e14adfde860563e8dd902041bd14 playbackRate = mediaAttributes.rr_mediaPlaybackRate; diff --git a/es/rrweb/packages/rrweb-snapshot/es/css.js b/es/rrweb/packages/rrweb-snapshot/es/css.js new file mode 100644 -index 0000000000000000000000000000000000000000..9e417600a9cb267ceb071ea9ffdd91cc9ddb779e +index 0000000000000000000000000000000000000000..34917db18e053a94d5c44ac857069ebb6133c8c1 --- /dev/null +++ b/es/rrweb/packages/rrweb-snapshot/es/css.js @@ -0,0 +1,87 @@ -+import postcss from '../../../../../../postcss/lib/postcss.js' ++import postcss from '../../../../../../../../../postcss/lib/postcss.js' + +const MEDIA_SELECTOR = /(max|min)-device-(width|height)/ +const MEDIA_SELECTOR_GLOBAL = new RegExp(MEDIA_SELECTOR.source, 'g') @@ -622,7 +622,7 @@ index 0000000000000000000000000000000000000000..9e417600a9cb267ceb071ea9ffdd91cc + }, +} diff --git a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js -index 38a23aaae8d683fa584329eced277dd8de55d1ff..3bee75fa4a64e72b01e388afdf2433e00ae1156a 100644 +index 38a23aaae8d683fa584329eced277dd8de55d1ff..afe2cfc4e7da3e3a5ec9ebb92c55f4f7f9dbe86f 100644 --- a/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +++ b/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js @@ -1,3 +1,5 @@ @@ -631,10 +631,131 @@ index 38a23aaae8d683fa584329eced277dd8de55d1ff..3bee75fa4a64e72b01e388afdf2433e0 var NodeType; (function (NodeType) { NodeType[NodeType["Document"] = 0] = "Document"; -@@ -1255,54 +1257,19 @@ function parse(css, options = {}) { - }); - } - function selector() { +@@ -1134,477 +1136,6 @@ function snapshot(n, options) { + }); + } + +-const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; +-function parse(css, options = {}) { +- let lineno = 1; +- let column = 1; +- function updatePosition(str) { +- const lines = str.match(/\n/g); +- if (lines) { +- lineno += lines.length; +- } +- const i = str.lastIndexOf('\n'); +- column = i === -1 ? column + str.length : str.length - i; +- } +- function position() { +- const start = { line: lineno, column }; +- return (node) => { +- node.position = new Position(start); +- whitespace(); +- return node; +- }; +- } +- class Position { +- constructor(start) { +- this.start = start; +- this.end = { line: lineno, column }; +- this.source = options.source; +- } +- } +- Position.prototype.content = css; +- const errorsList = []; +- function error(msg) { +- const err = new Error(`${options.source || ''}:${lineno}:${column}: ${msg}`); +- err.reason = msg; +- err.filename = options.source; +- err.line = lineno; +- err.column = column; +- err.source = css; +- if (options.silent) { +- errorsList.push(err); +- } +- else { +- throw err; +- } +- } +- function stylesheet() { +- const rulesList = rules(); +- return { +- type: 'stylesheet', +- stylesheet: { +- source: options.source, +- rules: rulesList, +- parsingErrors: errorsList, +- }, +- }; +- } +- function open() { +- return match(/^{\s*/); +- } +- function close() { +- return match(/^}/); +- } +- function rules() { +- let node; +- const rules = []; +- whitespace(); +- comments(rules); +- while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) { +- if (node) { +- rules.push(node); +- comments(rules); +- } +- } +- return rules; +- } +- function match(re) { +- const m = re.exec(css); +- if (!m) { +- return; +- } +- const str = m[0]; +- updatePosition(str); +- css = css.slice(str.length); +- return m; +- } +- function whitespace() { +- match(/^\s*/); +- } +- function comments(rules = []) { +- let c; +- while ((c = comment())) { +- if (c) { +- rules.push(c); +- } +- c = comment(); +- } +- return rules; +- } +- function comment() { +- const pos = position(); +- if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) { +- return; +- } +- let i = 2; +- while ('' !== css.charAt(i) && +- ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) { +- ++i; +- } +- i += 2; +- if ('' === css.charAt(i - 1)) { +- return error('End of comment missing'); +- } +- const str = css.slice(2, i - 2); +- column += 2; +- updatePosition(str); +- css = css.slice(i); +- column += 2; +- return pos({ +- type: 'comment', +- comment: str, +- }); +- } +- function selector() { - whitespace(); - while (css[0] == '}') { - error('extra closing bracket'); @@ -642,15 +763,13 @@ index 38a23aaae8d683fa584329eced277dd8de55d1ff..3bee75fa4a64e72b01e388afdf2433e0 - whitespace(); - } - const m = match(/^(("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^{])+)/); -+ const m = match(/^([^{]+)/); - if (!m) { - return; - } +- if (!m) { +- return; +- } - const cleanedInput = m[0] - .trim() -+ return trim(m[0]) - .replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '') - .replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, (m) => { +- .replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '') +- .replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, (m) => { - return m.replace(/,/g, '\u200C'); - }); - return customSplit(cleanedInput).map((s) => s.replace(/\u200C/g, ',').trim()); @@ -685,16 +804,312 @@ index 38a23aaae8d683fa584329eced277dd8de55d1ff..3bee75fa4a64e72b01e388afdf2433e0 - result.push(currentSegment); - } - return result; -+ return m.replace(/,/g, '\u200C'); -+ }) -+ .split(/\s*(?![^(]*\)),\s*/) -+ .map((s) => { -+ return s.replace(/\u200C/g, ','); -+ }); - } - function declaration() { - const pos = position(); -@@ -1651,67 +1618,11 @@ function getTagName(n) { +- } +- function declaration() { +- const pos = position(); +- const propMatch = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); +- if (!propMatch) { +- return; +- } +- const prop = trim(propMatch[0]); +- if (!match(/^:\s*/)) { +- return error(`property missing ':'`); +- } +- const val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); +- const ret = pos({ +- type: 'declaration', +- property: prop.replace(commentre, ''), +- value: val ? trim(val[0]).replace(commentre, '') : '', +- }); +- match(/^[;\s]*/); +- return ret; +- } +- function declarations() { +- const decls = []; +- if (!open()) { +- return error(`missing '{'`); +- } +- comments(decls); +- let decl; +- while ((decl = declaration())) { +- if (decl !== false) { +- decls.push(decl); +- comments(decls); +- } +- decl = declaration(); +- } +- if (!close()) { +- return error(`missing '}'`); +- } +- return decls; +- } +- function keyframe() { +- let m; +- const vals = []; +- const pos = position(); +- while ((m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/))) { +- vals.push(m[1]); +- match(/^,\s*/); +- } +- if (!vals.length) { +- return; +- } +- return pos({ +- type: 'keyframe', +- values: vals, +- declarations: declarations(), +- }); +- } +- function atkeyframes() { +- const pos = position(); +- let m = match(/^@([-\w]+)?keyframes\s*/); +- if (!m) { +- return; +- } +- const vendor = m[1]; +- m = match(/^([-\w]+)\s*/); +- if (!m) { +- return error('@keyframes missing name'); +- } +- const name = m[1]; +- if (!open()) { +- return error(`@keyframes missing '{'`); +- } +- let frame; +- let frames = comments(); +- while ((frame = keyframe())) { +- frames.push(frame); +- frames = frames.concat(comments()); +- } +- if (!close()) { +- return error(`@keyframes missing '}'`); +- } +- return pos({ +- type: 'keyframes', +- name, +- vendor, +- keyframes: frames, +- }); +- } +- function atsupports() { +- const pos = position(); +- const m = match(/^@supports *([^{]+)/); +- if (!m) { +- return; +- } +- const supports = trim(m[1]); +- if (!open()) { +- return error(`@supports missing '{'`); +- } +- const style = comments().concat(rules()); +- if (!close()) { +- return error(`@supports missing '}'`); +- } +- return pos({ +- type: 'supports', +- supports, +- rules: style, +- }); +- } +- function athost() { +- const pos = position(); +- const m = match(/^@host\s*/); +- if (!m) { +- return; +- } +- if (!open()) { +- return error(`@host missing '{'`); +- } +- const style = comments().concat(rules()); +- if (!close()) { +- return error(`@host missing '}'`); +- } +- return pos({ +- type: 'host', +- rules: style, +- }); +- } +- function atmedia() { +- const pos = position(); +- const m = match(/^@media *([^{]+)/); +- if (!m) { +- return; +- } +- const media = trim(m[1]); +- if (!open()) { +- return error(`@media missing '{'`); +- } +- const style = comments().concat(rules()); +- if (!close()) { +- return error(`@media missing '}'`); +- } +- return pos({ +- type: 'media', +- media, +- rules: style, +- }); +- } +- function atcustommedia() { +- const pos = position(); +- const m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); +- if (!m) { +- return; +- } +- return pos({ +- type: 'custom-media', +- name: trim(m[1]), +- media: trim(m[2]), +- }); +- } +- function atpage() { +- const pos = position(); +- const m = match(/^@page */); +- if (!m) { +- return; +- } +- const sel = selector() || []; +- if (!open()) { +- return error(`@page missing '{'`); +- } +- let decls = comments(); +- let decl; +- while ((decl = declaration())) { +- decls.push(decl); +- decls = decls.concat(comments()); +- } +- if (!close()) { +- return error(`@page missing '}'`); +- } +- return pos({ +- type: 'page', +- selectors: sel, +- declarations: decls, +- }); +- } +- function atdocument() { +- const pos = position(); +- const m = match(/^@([-\w]+)?document *([^{]+)/); +- if (!m) { +- return; +- } +- const vendor = trim(m[1]); +- const doc = trim(m[2]); +- if (!open()) { +- return error(`@document missing '{'`); +- } +- const style = comments().concat(rules()); +- if (!close()) { +- return error(`@document missing '}'`); +- } +- return pos({ +- type: 'document', +- document: doc, +- vendor, +- rules: style, +- }); +- } +- function atfontface() { +- const pos = position(); +- const m = match(/^@font-face\s*/); +- if (!m) { +- return; +- } +- if (!open()) { +- return error(`@font-face missing '{'`); +- } +- let decls = comments(); +- let decl; +- while ((decl = declaration())) { +- decls.push(decl); +- decls = decls.concat(comments()); +- } +- if (!close()) { +- return error(`@font-face missing '}'`); +- } +- return pos({ +- type: 'font-face', +- declarations: decls, +- }); +- } +- const atimport = _compileAtrule('import'); +- const atcharset = _compileAtrule('charset'); +- const atnamespace = _compileAtrule('namespace'); +- function _compileAtrule(name) { +- const re = new RegExp('^@' + name + '\\s*([^;]+);'); +- return () => { +- const pos = position(); +- const m = match(re); +- if (!m) { +- return; +- } +- const ret = { type: name }; +- ret[name] = m[1].trim(); +- return pos(ret); +- }; +- } +- function atrule() { +- if (css[0] !== '@') { +- return; +- } +- return (atkeyframes() || +- atmedia() || +- atcustommedia() || +- atsupports() || +- atimport() || +- atcharset() || +- atnamespace() || +- atdocument() || +- atpage() || +- athost() || +- atfontface()); +- } +- function rule() { +- const pos = position(); +- const sel = selector(); +- if (!sel) { +- return error('selector missing'); +- } +- comments(); +- return pos({ +- type: 'rule', +- selectors: sel, +- declarations: declarations(), +- }); +- } +- return addParent(stylesheet()); +-} +-function trim(str) { +- return str ? str.replace(/^\s+|\s+$/g, '') : ''; +-} +-function addParent(obj, parent) { +- const isNode = obj && typeof obj.type === 'string'; +- const childParent = isNode ? obj : parent; +- for (const k of Object.keys(obj)) { +- const value = obj[k]; +- if (Array.isArray(value)) { +- value.forEach((v) => { +- addParent(v, childParent); +- }); +- } +- else if (value && typeof value === 'object') { +- addParent(value, childParent); +- } +- } +- if (isNode) { +- Object.defineProperty(obj, 'parent', { +- configurable: true, +- writable: true, +- enumerable: false, +- value: parent || null, +- }); +- } +- return obj; +-} +- + const tagMap = { + script: 'noscript', + altglyph: 'altGlyph', +@@ -1651,67 +1182,11 @@ function getTagName(n) { } return tagName; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 41d88f85486686..25066727e9b52f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,7 +12,7 @@ patchedDependencies: hash: gydrxrztd4ruyhouu6tu7zh43e path: patches/heatmap.js@2.0.5.patch rrweb@2.0.0-alpha.13: - hash: ppwwvd5inagbkghbte76s24nnq + hash: 6bgnomayryopibyfydha2z5wbi path: patches/rrweb@2.0.0-alpha.13.patch dependencies: @@ -333,7 +333,7 @@ dependencies: version: 1.5.1 rrweb: specifier: 2.0.0-alpha.13 - version: 2.0.0-alpha.13(patch_hash=ppwwvd5inagbkghbte76s24nnq) + version: 2.0.0-alpha.13(patch_hash=6bgnomayryopibyfydha2z5wbi) sass: specifier: ^1.26.2 version: 1.56.0 @@ -19277,7 +19277,7 @@ packages: resolution: {integrity: sha512-slbhNBCYjxLGCeH95a67ECCy5a22nloXp1F5wF7DCzUNw80FN7tF9Lef1sRGLNo32g3mNqTc2sWLATlKejMxYw==} dev: false - /rrweb@2.0.0-alpha.13(patch_hash=ppwwvd5inagbkghbte76s24nnq): + /rrweb@2.0.0-alpha.13(patch_hash=6bgnomayryopibyfydha2z5wbi): resolution: {integrity: sha512-a8GXOCnzWHNaVZPa7hsrLZtNZ3CGjiL+YrkpLo0TfmxGLhjNZbWY2r7pE06p+FcjFNlgUVTmFrSJbK3kO7yxvw==} dependencies: '@rrweb/types': 2.0.0-alpha.13