@cloudcare/browser-rum 3.3.12 → 3.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/recorderApi.js +22 -2
  4. package/cjs/boot/recorderApi.js.map +1 -1
  5. package/cjs/boot/startRecording.js +54 -1
  6. package/cjs/boot/startRecording.js.map +1 -1
  7. package/cjs/domain/assembly.js +15 -2
  8. package/cjs/domain/assembly.js.map +1 -1
  9. package/cjs/domain/configuration.js +1 -0
  10. package/cjs/domain/configuration.js.map +1 -1
  11. package/cjs/domain/deflate/deflateWorker.js +1 -1
  12. package/cjs/domain/privacy.js +278 -0
  13. package/cjs/domain/privacy.js.map +1 -0
  14. package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
  15. package/cjs/domain/replay/record/mutationObserver.js +16 -6
  16. package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
  17. package/cjs/domain/replay/record/privacy.js +11 -272
  18. package/cjs/domain/replay/record/privacy.js.map +1 -1
  19. package/cjs/domain/replay/record/record.js +94 -8
  20. package/cjs/domain/replay/record/record.js.map +1 -1
  21. package/cjs/domain/replay/segmentCollection/segmentCollection.js +45 -17
  22. package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  23. package/cjs/domain/replay/timeAnchor.js +27 -0
  24. package/cjs/domain/replay/timeAnchor.js.map +1 -0
  25. package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +81 -19
  26. package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
  27. package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +11 -4
  28. package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
  29. package/cjs/domain/rumEventsCollection/view/trackViews.js +45 -7
  30. package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  31. package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
  32. package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  33. package/cjs/domain/rumSessionManager.js +2 -2
  34. package/cjs/domain/rumSessionManager.js.map +1 -1
  35. package/esm/boot/buildEnv.js +1 -1
  36. package/esm/boot/recorderApi.js +23 -3
  37. package/esm/boot/recorderApi.js.map +1 -1
  38. package/esm/boot/startRecording.js +54 -1
  39. package/esm/boot/startRecording.js.map +1 -1
  40. package/esm/domain/assembly.js +16 -3
  41. package/esm/domain/assembly.js.map +1 -1
  42. package/esm/domain/configuration.js +1 -0
  43. package/esm/domain/configuration.js.map +1 -1
  44. package/esm/domain/deflate/deflateWorker.js +1 -1
  45. package/esm/domain/privacy.js +266 -0
  46. package/esm/domain/privacy.js.map +1 -0
  47. package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
  48. package/esm/domain/replay/record/mutationObserver.js +16 -6
  49. package/esm/domain/replay/record/mutationObserver.js.map +1 -1
  50. package/esm/domain/replay/record/privacy.js +1 -266
  51. package/esm/domain/replay/record/privacy.js.map +1 -1
  52. package/esm/domain/replay/record/record.js +78 -9
  53. package/esm/domain/replay/record/record.js.map +1 -1
  54. package/esm/domain/replay/segmentCollection/segmentCollection.js +45 -17
  55. package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
  56. package/esm/domain/replay/timeAnchor.js +20 -0
  57. package/esm/domain/replay/timeAnchor.js.map +1 -0
  58. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +80 -18
  59. package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
  60. package/esm/domain/rumEventsCollection/actions/trackClickActions.js +11 -4
  61. package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
  62. package/esm/domain/rumEventsCollection/view/trackViews.js +46 -8
  63. package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
  64. package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
  65. package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
  66. package/esm/domain/rumSessionManager.js +2 -2
  67. package/esm/domain/rumSessionManager.js.map +1 -1
  68. package/package.json +4 -4
  69. package/src/boot/recorderApi.js +25 -3
  70. package/src/boot/startRecording.js +61 -1
  71. package/src/domain/assembly.js +18 -4
  72. package/src/domain/configuration.js +4 -0
  73. package/src/domain/privacy.js +356 -0
  74. package/src/domain/replay/record/mutationObserver.js +21 -11
  75. package/src/domain/replay/record/privacy.js +1 -356
  76. package/src/domain/replay/record/record.js +129 -8
  77. package/src/domain/replay/segmentCollection/segmentCollection.js +83 -18
  78. package/src/domain/replay/timeAnchor.js +33 -0
  79. package/src/domain/rumEventsCollection/actions/getActionNameFromElement.js +148 -21
  80. package/src/domain/rumEventsCollection/actions/trackClickActions.js +19 -5
  81. package/src/domain/rumEventsCollection/view/trackViews.js +83 -12
  82. package/src/domain/rumEventsCollection/view/viewCollection.js +2 -1
  83. package/src/domain/rumSessionManager.js +2 -2
@@ -0,0 +1,266 @@
1
+ import { isElementNode, getParentNode, isTextNode } from '@cloudcare/browser-core';
2
+ import { NodePrivacyLevel, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_ALLOW, PRIVACY_ATTR_VALUE_MASK, PRIVACY_ATTR_VALUE_MASK_USER_INPUT, PRIVACY_ATTR_VALUE_HIDDEN, PRIVACY_CLASS_ALLOW, PRIVACY_CLASS_MASK, PRIVACY_CLASS_MASK_USER_INPUT, PRIVACY_CLASS_HIDDEN, FORM_PRIVATE_TAG_NAMES, CENSORED_STRING_MARK } from '../constants';
3
+ export var MAX_ATTRIBUTE_VALUE_CHAR_LENGTH = 100000;
4
+ var TEXT_MASKING_CHAR = 'x';
5
+ export var MAX_PRIVACY_ANCESTOR_DEPTH = 1000;
6
+
7
+ /**
8
+ * Get node privacy level by iterating over its ancestors. When the direct parent privacy level is
9
+ * know, it is best to use something like:
10
+ *
11
+ * derivePrivacyLevelGivenParent(getNodeSelfPrivacyLevel(node), parentNodePrivacyLevel)
12
+ */
13
+ export function getNodePrivacyLevel(node, defaultPrivacyLevel, cache) {
14
+ if (cache && cache.has(node)) {
15
+ return cache.get(node);
16
+ }
17
+
18
+ // Resolve ancestors iteratively so an adversarially deep DOM cannot grow the
19
+ // JavaScript stack. If the watermark is crossed, fail closed: hiding the
20
+ // branch is safer than spending unbounded time resolving its privacy chain.
21
+ var unresolvedNodes = [];
22
+ var currentNode = node;
23
+ var inheritedPrivacyLevel;
24
+ while (currentNode) {
25
+ if (cache && cache.has(currentNode)) {
26
+ inheritedPrivacyLevel = cache.get(currentNode);
27
+ break;
28
+ }
29
+ if (unresolvedNodes.length >= MAX_PRIVACY_ANCESTOR_DEPTH) {
30
+ inheritedPrivacyLevel = NodePrivacyLevel.HIDDEN;
31
+ break;
32
+ }
33
+ unresolvedNodes.push(currentNode);
34
+ currentNode = getParentNode(currentNode);
35
+ }
36
+ if (inheritedPrivacyLevel === undefined) {
37
+ inheritedPrivacyLevel = defaultPrivacyLevel;
38
+ }
39
+ while (unresolvedNodes.length) {
40
+ var unresolvedNode = unresolvedNodes.pop();
41
+ inheritedPrivacyLevel = reducePrivacyLevel(getNodeSelfPrivacyLevel(unresolvedNode), inheritedPrivacyLevel);
42
+ if (cache) {
43
+ cache.set(unresolvedNode, inheritedPrivacyLevel);
44
+ }
45
+ }
46
+ return inheritedPrivacyLevel;
47
+ }
48
+
49
+ /**
50
+ * Reduces the next privacy level based on self + parent privacy levels
51
+ */
52
+ export function reducePrivacyLevel(childPrivacyLevel, parentNodePrivacyLevel) {
53
+ switch (parentNodePrivacyLevel) {
54
+ // These values cannot be overridden
55
+ case NodePrivacyLevel.HIDDEN:
56
+ case NodePrivacyLevel.IGNORE:
57
+ return parentNodePrivacyLevel;
58
+ }
59
+ switch (childPrivacyLevel) {
60
+ case NodePrivacyLevel.ALLOW:
61
+ case NodePrivacyLevel.MASK:
62
+ case NodePrivacyLevel.MASK_USER_INPUT:
63
+ case NodePrivacyLevel.HIDDEN:
64
+ case NodePrivacyLevel.IGNORE:
65
+ return childPrivacyLevel;
66
+ default:
67
+ return parentNodePrivacyLevel;
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Determines the node's own privacy level without checking for ancestors.
73
+ */
74
+ export function getNodeSelfPrivacyLevel(node) {
75
+ // Only Element types can have a privacy level set
76
+ if (!isElementNode(node)) {
77
+ return;
78
+ }
79
+ var privAttr = node.getAttribute(PRIVACY_ATTR_NAME);
80
+
81
+ // Overrules for replay purpose
82
+ if (node.tagName === 'BASE') {
83
+ return NodePrivacyLevel.ALLOW;
84
+ }
85
+
86
+ // Overrules to enforce end-user protection
87
+ if (node.tagName === 'INPUT') {
88
+ var inputElement = node;
89
+ if (inputElement.type === 'password' || inputElement.type === 'email' || inputElement.type === 'tel') {
90
+ return NodePrivacyLevel.MASK;
91
+ }
92
+ if (inputElement.type === 'hidden') {
93
+ return NodePrivacyLevel.MASK;
94
+ }
95
+ var autocomplete = inputElement.getAttribute('autocomplete');
96
+ // Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year]
97
+ if (autocomplete && autocomplete.indexOf('cc-') === 0) {
98
+ return NodePrivacyLevel.MASK;
99
+ }
100
+ }
101
+
102
+ // Check HTML privacy attributes and classes
103
+ if (privAttr === PRIVACY_ATTR_VALUE_HIDDEN || node.classList.contains(PRIVACY_CLASS_HIDDEN)) {
104
+ return NodePrivacyLevel.HIDDEN;
105
+ }
106
+ if (privAttr === PRIVACY_ATTR_VALUE_MASK || node.classList.contains(PRIVACY_CLASS_MASK)) {
107
+ return NodePrivacyLevel.MASK;
108
+ }
109
+ if (privAttr === PRIVACY_ATTR_VALUE_MASK_USER_INPUT || node.classList.contains(PRIVACY_CLASS_MASK_USER_INPUT)) {
110
+ return NodePrivacyLevel.MASK_USER_INPUT;
111
+ }
112
+ if (privAttr === PRIVACY_ATTR_VALUE_ALLOW || node.classList.contains(PRIVACY_CLASS_ALLOW)) {
113
+ return NodePrivacyLevel.ALLOW;
114
+ }
115
+ if (shouldIgnoreElement(node)) {
116
+ return NodePrivacyLevel.IGNORE;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Helper aiming to unify `mask` and `mask-user-input` privacy levels:
122
+ *
123
+ * In the `mask` case, it is trivial: we should mask the element.
124
+ *
125
+ * In the `mask-user-input` case, we should mask the element only if it is a "form" element or the
126
+ * direct parent is a form element for text nodes).
127
+ *
128
+ * Other `shouldMaskNode` cases are edge cases that should not matter too much (ex: should we mask a
129
+ * node if it is ignored or hidden? it doesn't matter since it won't be serialized).
130
+ */
131
+ export function shouldMaskNode(configuration, node, privacyLevel) {
132
+ if (configuration.shouldMaskNode && configuration.shouldMaskNode(node, privacyLevel) === true) return true;
133
+ switch (privacyLevel) {
134
+ case NodePrivacyLevel.MASK:
135
+ case NodePrivacyLevel.HIDDEN:
136
+ case NodePrivacyLevel.IGNORE:
137
+ return true;
138
+ case NodePrivacyLevel.MASK_USER_INPUT:
139
+ return isTextNode(node) ? isFormElement(node.parentNode) : isFormElement(node);
140
+ default:
141
+ return false;
142
+ }
143
+ }
144
+ function isFormElement(node) {
145
+ if (!node || node.nodeType !== node.ELEMENT_NODE) {
146
+ return false;
147
+ }
148
+ var element = node;
149
+ if (element.tagName === 'INPUT') {
150
+ switch (element.type) {
151
+ case 'button':
152
+ case 'color':
153
+ case 'reset':
154
+ case 'submit':
155
+ return false;
156
+ }
157
+ }
158
+ return !!FORM_PRIVATE_TAG_NAMES[element.tagName];
159
+ }
160
+
161
+ /**
162
+ * Text censoring non-destructively maintains whitespace characters in order to preserve text shape
163
+ * during replay.
164
+ */
165
+ export var censorText = function censorText(text) {
166
+ return text.replace(/\S/g, TEXT_MASKING_CHAR);
167
+ };
168
+ export function getTextContent(configuration, textNode, ignoreWhiteSpace, parentNodePrivacyLevel) {
169
+ // The parent node may not be a html element which has a tagName attribute.
170
+ // So just let it be undefined which is ok in this use case.
171
+ var parentTagName = textNode.parentElement && textNode.parentElement.tagName;
172
+ var textContent = textNode.textContent || '';
173
+ if (ignoreWhiteSpace && !textContent.trim()) {
174
+ return;
175
+ }
176
+ var nodePrivacyLevel = parentNodePrivacyLevel;
177
+
178
+ // var isStyle = parentTagName === 'STYLE' ? true : undefined
179
+ var isScript = parentTagName === 'SCRIPT';
180
+ if (isScript) {
181
+ // For perf reasons, we don't record script (heuristic)
182
+ textContent = CENSORED_STRING_MARK;
183
+ } else if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
184
+ // Should never occur, but just in case, we set to CENSORED_MARK.
185
+ textContent = CENSORED_STRING_MARK;
186
+ } else if (shouldMaskNode(configuration, textNode, nodePrivacyLevel)) {
187
+ if (
188
+ // Scrambling the child list breaks text nodes for DATALIST/SELECT/OPTGROUP
189
+ parentTagName === 'DATALIST' || parentTagName === 'SELECT' || parentTagName === 'OPTGROUP') {
190
+ if (!textContent.trim()) {
191
+ return;
192
+ }
193
+ } else if (parentTagName === 'OPTION') {
194
+ // <Option> has low entropy in charset + text length, so use `CENSORED_STRING_MARK` when masked
195
+ textContent = CENSORED_STRING_MARK;
196
+ } else {
197
+ textContent = censorText(textContent);
198
+ }
199
+ }
200
+ // else if (isStyle && textContent) {
201
+ // try {
202
+ // // try to read style sheet
203
+ // if (textNode.nextSibling || textNode.previousSibling) {
204
+ // // This is not the only child of the stylesheet.
205
+ // // We can't read all of the sheet's .cssRules and expect them
206
+ // // to _only_ include the current rule(s) added by the text node.
207
+ // // So we'll be conservative and keep textContent as-is.
208
+ // } else if (
209
+ // textNode.parentNode &&
210
+ // textNode.parentNode.sheet &&
211
+ // textNode.parentNode.sheet.cssRules
212
+ // ) {
213
+ // textContent = getCssRulesString(textNode.parentNode.sheet)
214
+ // }
215
+ // } catch (err) {}
216
+ // textContent = switchToAbsoluteUrl(textContent, getHref())
217
+ // }
218
+ return textContent;
219
+ }
220
+
221
+ /**
222
+ * We don't need this logic on the recorder side.
223
+ * For security related meta's, customer can mask themmanually given they
224
+ * are easy to identify in the HEAD tag.
225
+ */
226
+ export function shouldIgnoreElement(element) {
227
+ if (element.nodeName === 'SCRIPT') {
228
+ return true;
229
+ }
230
+ if (element.nodeName === 'LINK') {
231
+ var relAttribute = getLowerCaseAttribute('rel');
232
+ return (
233
+ // Link as script - Ignore only when rel=preload, modulepreload or prefetch
234
+ /preload|prefetch/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script' ||
235
+ // Favicons
236
+ relAttribute === 'shortcut icon' || relAttribute === 'icon'
237
+ );
238
+ }
239
+ if (element.nodeName === 'META') {
240
+ var nameAttribute = getLowerCaseAttribute('name');
241
+ var relAttribute = getLowerCaseAttribute('rel');
242
+ var propertyAttribute = getLowerCaseAttribute('property');
243
+ return (
244
+ // Favicons
245
+ /^msapplication-tile(image|color)$/.test(nameAttribute) || nameAttribute === 'application-name' || relAttribute === 'icon' || relAttribute === 'apple-touch-icon' || relAttribute === 'shortcut icon' ||
246
+ // Description
247
+ nameAttribute === 'keywords' || nameAttribute === 'description' ||
248
+ // Social
249
+ /^(og|twitter|fb):/.test(propertyAttribute) || /^(og|twitter):/.test(nameAttribute) || nameAttribute === 'pinterest' ||
250
+ // Robots
251
+ nameAttribute === 'robots' || nameAttribute === 'googlebot' || nameAttribute === 'bingbot' ||
252
+ // Http headers. Ex: X-UA-Compatible, Content-Type, Content-Language, cache-control,
253
+ // X-Translated-By
254
+ element.hasAttribute('http-equiv') ||
255
+ // Authorship
256
+ nameAttribute === 'author' || nameAttribute === 'generator' || nameAttribute === 'framework' || nameAttribute === 'publisher' || nameAttribute === 'progid' || /^article:/.test(propertyAttribute) || /^product:/.test(propertyAttribute) ||
257
+ // Verification
258
+ nameAttribute === 'google-site-verification' || nameAttribute === 'yandex-verification' || nameAttribute === 'csrf-token' || nameAttribute === 'p:domain_verify' || nameAttribute === 'verify-v1' || nameAttribute === 'verification' || nameAttribute === 'shopify-checkout-api-token'
259
+ );
260
+ }
261
+ function getLowerCaseAttribute(name) {
262
+ return (element.getAttribute(name) || '').toLowerCase();
263
+ }
264
+ return false;
265
+ }
266
+ //# sourceMappingURL=privacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.js","names":["isElementNode","getParentNode","isTextNode","NodePrivacyLevel","PRIVACY_ATTR_NAME","PRIVACY_ATTR_VALUE_ALLOW","PRIVACY_ATTR_VALUE_MASK","PRIVACY_ATTR_VALUE_MASK_USER_INPUT","PRIVACY_ATTR_VALUE_HIDDEN","PRIVACY_CLASS_ALLOW","PRIVACY_CLASS_MASK","PRIVACY_CLASS_MASK_USER_INPUT","PRIVACY_CLASS_HIDDEN","FORM_PRIVATE_TAG_NAMES","CENSORED_STRING_MARK","MAX_ATTRIBUTE_VALUE_CHAR_LENGTH","TEXT_MASKING_CHAR","MAX_PRIVACY_ANCESTOR_DEPTH","getNodePrivacyLevel","node","defaultPrivacyLevel","cache","has","get","unresolvedNodes","currentNode","inheritedPrivacyLevel","length","HIDDEN","push","undefined","unresolvedNode","pop","reducePrivacyLevel","getNodeSelfPrivacyLevel","set","childPrivacyLevel","parentNodePrivacyLevel","IGNORE","ALLOW","MASK","MASK_USER_INPUT","privAttr","getAttribute","tagName","inputElement","type","autocomplete","indexOf","classList","contains","shouldIgnoreElement","shouldMaskNode","configuration","privacyLevel","isFormElement","parentNode","nodeType","ELEMENT_NODE","element","censorText","text","replace","getTextContent","textNode","ignoreWhiteSpace","parentTagName","parentElement","textContent","trim","nodePrivacyLevel","isScript","nodeName","relAttribute","getLowerCaseAttribute","test","nameAttribute","propertyAttribute","hasAttribute","name","toLowerCase"],"sources":["../../src/domain/privacy.js"],"mappings":"AAAA,SACEA,aAAa,EACbC,aAAa,EACbC,UAAU,QACL,yBAAyB;AAEhC,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,wBAAwB,EACxBC,uBAAuB,EACvBC,kCAAkC,EAClCC,yBAAyB,EACzBC,mBAAmB,EACnBC,kBAAkB,EAClBC,6BAA6B,EAC7BC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,QACf,cAAc;AAErB,OAAO,IAAIC,+BAA+B,GA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CAAC,IACvDA,aAAa,KAAK,kBAAkB,IACpCH,YAAY,KAAK,MAAM,IACvBA,YAAY,KAAK,kBAAkB,IACnCA,YAAY,KAAK,eAAe;MAChC;MACAG,aAAa,KAAK,UAAU,IAC5BA,aAAa,KAAK,aAAa;MAC/B;MACA,mBAAmB,CAACD,IAAI,CAACE,iBAAiB,CAAC,IAC3C,gBAAgB,CAACF,IAAI,CAACC,aAAa,CAAC,IACpCA,aAAa,KAAK,WAAW;MAC7B;MACAA,aAAa,KAAK,QAAQ,IAC1BA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,SAAS;MAC3B;MACA;MACAjB,OAAO,CAACmB,YAAY,CAAC,YAAY,CAAC;MAClC;MACAF,aAAa,KAAK,QAAQ,IAC1BA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,QAAQ,IAC1B,WAAW,CAACD,IAAI,CAACE,iBAAiB,CAAC,IACnC,WAAW,CAACF,IAAI,CAACE,iBAAiB,CAAC;MACnC;MACAD,aAAa,KAAK,0BAA0B,IAC5CA,aAAa,KAAK,qBAAqB,IACvCA,aAAa,KAAK,YAAY,IAC9BA,aAAa,KAAK,iBAAiB,IACnCA,aAAa,KAAK,WAAW,IAC7BA,aAAa,KAAK,cAAc,IAChCA,aAAa,KAAK;IAA4B;EAElD;EAEA,SAASF,qBAAqBA,CAACK,IAAI,EAAE;IACnC,OAAO,CAACpB,OAAO,CAAChB,YAAY,CAACoC,IAAI,CAAC,IAAI,EAAE,EAAEC,WAAW,CAAC,CAAC;EACzD;EAEA,OAAO,KAAK;AACd","ignoreList":[]}
@@ -11,7 +11,7 @@ export function createCanvasEncodeWorker(configuration, workerCtor, urlObject) {
11
11
  var workerUrl = configuration.replayCanvasWorkerUrl;
12
12
  var usesExternalUrl = !!workerUrl;
13
13
  if (!workerUrl) {
14
- workerUrl = urlObject.createObjectURL(new Blob(["!function(){\"use strict\";function n(n){for(var t=new Uint8Array(n),r=[],i=0;i<t.length;i+=8192){for(var e=t.subarray(i,i+8192),o=\"\",f=0;f<e.length;f+=1)o+=String.fromCharCode(e[f]);r.push(o)}return btoa(r.join(\"\"))}function t(n,t){try{n.postMessage(t)}catch(r){n.postMessage({action:\"errored\",id:t&&t.id,error:String(r&&r.message?r.message:r)})}}var r=16777216;function i(n){var t=Number(n&&n.width),r=Number(n&&n.height);if(!isFinite(t)||!isFinite(r)||t<0||r<0)return 1/0;var i=t*r*4;return isFinite(i)?i:1/0}function e(n){if(n)try{n.width=0,n.height=0}catch(n){}}!function(o){void 0===o&&(o=self);var f=[],c=0;o.addEventListener(\"message\",(function(a){var u=a.data;if(u)if(\"init\"!==u.action){if(\"encode\"===u.action){var d,h=!1;Promise.resolve().then((function(){var t=function(n,t,r){if(!n||!t||!r)return{width:n,height:t};if(n<=r&&t<=r)return{width:n,height:t};var i=n>t?r/n:r/t;return{width:Math.max(1,Math.round(n*i)),height:Math.max(1,Math.round(t*i))}}(u.width,u.height,u.maxSize),r=(d=function(n,t){var r=f.pop();return r?c=Math.max(0,c-i(r)):r=new OffscreenCanvas(n,t),r.width!==n&&(r.width=n),r.height!==t&&(r.height=t),r}(t.width,t.height)).getContext(\"2d\");if(!r)throw new Error(\"Cannot create offscreen canvas 2d context for encoding\");if(function(n,t,r,i){var e=\"function\"==typeof n.save&&\"function\"==typeof n.restore;e&&n.save();try{\"function\"==typeof n.resetTransform?n.resetTransform():\"function\"==typeof n.setTransform&&n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,r,i),n.drawImage(t,0,0,r,i)}finally{e&&n.restore()}}(r,u.bitmap,t.width,t.height),\"function\"!=typeof d.convertToBlob)throw new Error(\"OffscreenCanvas convertToBlob is not supported\");return d.convertToBlob({type:u.mimeType,quality:u.quality}).then((function(r){return\"number\"==typeof u.maxEncodedBytes&&r.size>u.maxEncodedBytes?{action:\"dropped\",id:u.id,reason:\"encode_too_large\",encodedBytesCount:r.size,width:t.width,height:t.height}:r.arrayBuffer().then((function(i){var e=r.type||u.mimeType;return{action:\"encoded\",id:u.id,dataUrl:\"data:\"+e+\";base64,\"+n(i),width:t.width,height:t.height}}))})).then((function(n){return h=!0,n}))})).finally((function(){!function(n){if(n&&\"function\"==typeof n.close)try{n.close()}catch(n){}}(u.bitmap),h?function(n){var t=i(n);f.length>=4||!t||t>r||c>r-t?e(n):(f.push(n),c+=t)}(d):e(d)})).then((function(n){t(o,n)})).catch((function(n){t(o,{action:\"errored\",id:u.id,error:String(n&&n.message?n.message:n)})}))}}else t(o,{action:\"initialized\",version:\"3.3.12\"})}))}()}();"]));
14
+ workerUrl = urlObject.createObjectURL(new Blob(["!function(){\"use strict\";function n(n){for(var t=new Uint8Array(n),r=[],i=0;i<t.length;i+=8192){for(var e=t.subarray(i,i+8192),o=\"\",f=0;f<e.length;f+=1)o+=String.fromCharCode(e[f]);r.push(o)}return btoa(r.join(\"\"))}function t(n,t){try{n.postMessage(t)}catch(r){n.postMessage({action:\"errored\",id:t&&t.id,error:String(r&&r.message?r.message:r)})}}var r=16777216;function i(n){var t=Number(n&&n.width),r=Number(n&&n.height);if(!isFinite(t)||!isFinite(r)||t<0||r<0)return 1/0;var i=t*r*4;return isFinite(i)?i:1/0}function e(n){if(n)try{n.width=0,n.height=0}catch(n){}}!function(o){void 0===o&&(o=self);var f=[],c=0;o.addEventListener(\"message\",(function(a){var u=a.data;if(u)if(\"init\"!==u.action){if(\"encode\"===u.action){var d,h=!1;Promise.resolve().then((function(){var t=function(n,t,r){if(!n||!t||!r)return{width:n,height:t};if(n<=r&&t<=r)return{width:n,height:t};var i=n>t?r/n:r/t;return{width:Math.max(1,Math.round(n*i)),height:Math.max(1,Math.round(t*i))}}(u.width,u.height,u.maxSize),r=(d=function(n,t){var r=f.pop();return r?c=Math.max(0,c-i(r)):r=new OffscreenCanvas(n,t),r.width!==n&&(r.width=n),r.height!==t&&(r.height=t),r}(t.width,t.height)).getContext(\"2d\");if(!r)throw new Error(\"Cannot create offscreen canvas 2d context for encoding\");if(function(n,t,r,i){var e=\"function\"==typeof n.save&&\"function\"==typeof n.restore;e&&n.save();try{\"function\"==typeof n.resetTransform?n.resetTransform():\"function\"==typeof n.setTransform&&n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,r,i),n.drawImage(t,0,0,r,i)}finally{e&&n.restore()}}(r,u.bitmap,t.width,t.height),\"function\"!=typeof d.convertToBlob)throw new Error(\"OffscreenCanvas convertToBlob is not supported\");return d.convertToBlob({type:u.mimeType,quality:u.quality}).then((function(r){return\"number\"==typeof u.maxEncodedBytes&&r.size>u.maxEncodedBytes?{action:\"dropped\",id:u.id,reason:\"encode_too_large\",encodedBytesCount:r.size,width:t.width,height:t.height}:r.arrayBuffer().then((function(i){var e=r.type||u.mimeType;return{action:\"encoded\",id:u.id,dataUrl:\"data:\"+e+\";base64,\"+n(i),width:t.width,height:t.height}}))})).then((function(n){return h=!0,n}))})).finally((function(){!function(n){if(n&&\"function\"==typeof n.close)try{n.close()}catch(n){}}(u.bitmap),h?function(n){var t=i(n);f.length>=4||!t||t>r||c>r-t?e(n):(f.push(n),c+=t)}(d):e(d)})).then((function(n){t(o,n)})).catch((function(n){t(o,{action:\"errored\",id:u.id,error:String(n&&n.message?n.message:n)})}))}}else t(o,{action:\"initialized\",version:\"3.3.14\"})}))}()}();"]));
15
15
  }
16
16
  try {
17
17
  return {
@@ -854,20 +854,30 @@ function processChildListMutations(mutations, configuration, shadowRootsControll
854
854
  // subtree followed by an ineffective remove.
855
855
  var pendingRootTask = mutationTasksController.findPendingRootTask(node, parent);
856
856
  if (pendingRootTask) {
857
- if (isNodePublished(node)) {
857
+ var pendingRootNodeWasPublished = isNodePublished(node);
858
+ if (pendingRootNodeWasPublished) {
858
859
  mutationTasksController.markPendingRootTaskPublishedDependency(pendingRootTask);
859
860
  }
860
861
  if (node !== pendingRootTask.rootNode && pendingRootTask.rootNode.isConnected) {
861
862
  // Several descendants can be removed in one batch. Rebuild the
862
863
  // unpublished root once after normalization instead of once per node.
863
864
  pendingRootTasksToRefresh.add(pendingRootTask);
865
+ if (!pendingRootNodeWasPublished) {
866
+ continue;
867
+ }
868
+ // A published descendant can also be serialized under a newly added
869
+ // ancestor in its current destination. It still needs a remove for
870
+ // the old replay-tree parent; otherwise the player builds a duplicate
871
+ // same-id node and later Canvas mutations have an ambiguous target.
872
+ // Refresh the destination add above, then fall through and emit the
873
+ // paired published removal below.
874
+ } else {
875
+ pendingRootTasksToRefresh["delete"](pendingRootTask);
876
+ if (!mutationTasksController.handlePendingRootRemoval(pendingRootTask, node)) {
877
+ pendingRootRemovalOverflowed = true;
878
+ }
864
879
  continue;
865
880
  }
866
- pendingRootTasksToRefresh["delete"](pendingRootTask);
867
- if (!mutationTasksController.handlePendingRootRemoval(pendingRootTask, node)) {
868
- pendingRootRemovalOverflowed = true;
869
- }
870
- continue;
871
881
  }
872
882
  if (hasSerializedNode(node) && isNodePublished(node)) {
873
883
  var removeMutation = {