@openreplay/tracker 14.0.10-beta.2 → 14.0.11

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 (273) hide show
  1. package/{cjs → dist/cjs}/index.js +29 -49
  2. package/dist/cjs/index.js.map +1 -0
  3. package/{cjs → dist/cjs/main}/app/index.d.ts +17 -5
  4. package/{lib → dist/cjs/main}/app/logger.d.ts +1 -0
  5. package/{lib → dist/cjs/main}/app/messages.gen.d.ts +2 -2
  6. package/{lib/app/nodes.d.ts → dist/cjs/main/app/nodes/index.d.ts} +14 -7
  7. package/dist/cjs/main/app/nodes/maintainer.d.ts +28 -0
  8. package/{lib → dist/cjs/main}/app/observer/iframe_observer.d.ts +2 -0
  9. package/{lib → dist/cjs/main}/app/observer/iframe_offsets.d.ts +1 -1
  10. package/{lib → dist/cjs/main}/app/observer/observer.d.ts +3 -1
  11. package/{lib → dist/cjs/main}/app/observer/top_observer.d.ts +7 -1
  12. package/{cjs → dist/cjs/main}/app/sanitizer.d.ts +5 -2
  13. package/{cjs → dist/cjs/main}/app/session.d.ts +6 -3
  14. package/{cjs → dist/cjs/main}/index.d.ts +2 -2
  15. package/{cjs → dist/cjs/main}/modules/attributeSender.d.ts +5 -2
  16. package/{cjs → dist/cjs/main}/modules/conditionsManager.d.ts +1 -1
  17. package/{cjs → dist/cjs/main}/modules/tagWatcher.d.ts +8 -4
  18. package/{lib → dist/cjs/main}/modules/userTesting/SignalManager.d.ts +2 -2
  19. package/{lib → dist/cjs/main}/utils.d.ts +4 -3
  20. package/dist/lib/index.js +9358 -0
  21. package/dist/lib/index.js.map +1 -0
  22. package/{lib → dist/lib/main}/app/index.d.ts +17 -5
  23. package/{cjs → dist/lib/main}/app/logger.d.ts +1 -0
  24. package/{cjs → dist/lib/main}/app/messages.gen.d.ts +2 -2
  25. package/{cjs/app/nodes.d.ts → dist/lib/main/app/nodes/index.d.ts} +14 -7
  26. package/dist/lib/main/app/nodes/maintainer.d.ts +28 -0
  27. package/{cjs → dist/lib/main}/app/observer/iframe_observer.d.ts +2 -0
  28. package/{cjs → dist/lib/main}/app/observer/iframe_offsets.d.ts +1 -1
  29. package/{cjs → dist/lib/main}/app/observer/observer.d.ts +3 -1
  30. package/{cjs → dist/lib/main}/app/observer/top_observer.d.ts +7 -1
  31. package/{lib → dist/lib/main}/app/sanitizer.d.ts +5 -2
  32. package/{lib → dist/lib/main}/app/session.d.ts +6 -3
  33. package/{lib → dist/lib/main}/index.d.ts +2 -2
  34. package/{lib → dist/lib/main}/modules/attributeSender.d.ts +5 -2
  35. package/{lib → dist/lib/main}/modules/conditionsManager.d.ts +1 -1
  36. package/{lib → dist/lib/main}/modules/tagWatcher.d.ts +8 -4
  37. package/{cjs → dist/lib/main}/modules/userTesting/SignalManager.d.ts +2 -2
  38. package/{cjs → dist/lib/main}/utils.d.ts +4 -3
  39. package/package.json +31 -20
  40. package/.eslintignore +0 -11
  41. package/.nvmrc +0 -1
  42. package/.prettierignore +0 -1
  43. package/CHANGELOG.md +0 -297
  44. package/bun.lockb +0 -0
  45. package/cjs/app/canvas.js +0 -204
  46. package/cjs/app/guards.js +0 -37
  47. package/cjs/app/index.js +0 -1397
  48. package/cjs/app/logger.js +0 -37
  49. package/cjs/app/messages.gen.js +0 -702
  50. package/cjs/app/nodes.js +0 -111
  51. package/cjs/app/observer/iframe_observer.js +0 -35
  52. package/cjs/app/observer/iframe_offsets.js +0 -56
  53. package/cjs/app/observer/observer.js +0 -383
  54. package/cjs/app/observer/shadow_root_observer.js +0 -24
  55. package/cjs/app/observer/top_observer.js +0 -134
  56. package/cjs/app/sanitizer.js +0 -82
  57. package/cjs/app/session.js +0 -140
  58. package/cjs/app/ticker.js +0 -48
  59. package/cjs/common/interaction.js +0 -2
  60. package/cjs/common/messages.gen.js +0 -4
  61. package/cjs/modules/attributeSender.js +0 -51
  62. package/cjs/modules/axiosSpy.js +0 -122
  63. package/cjs/modules/conditionsManager.js +0 -343
  64. package/cjs/modules/connection.js +0 -15
  65. package/cjs/modules/console.js +0 -127
  66. package/cjs/modules/constructedStyleSheets.js +0 -138
  67. package/cjs/modules/cssrules.js +0 -99
  68. package/cjs/modules/exception.js +0 -85
  69. package/cjs/modules/featureFlags.js +0 -89
  70. package/cjs/modules/focus.js +0 -45
  71. package/cjs/modules/fonts.js +0 -57
  72. package/cjs/modules/img.js +0 -110
  73. package/cjs/modules/input.js +0 -203
  74. package/cjs/modules/mouse.js +0 -195
  75. package/cjs/modules/network.js +0 -244
  76. package/cjs/modules/performance.js +0 -53
  77. package/cjs/modules/scroll.js +0 -84
  78. package/cjs/modules/selection.js +0 -37
  79. package/cjs/modules/tabs.js +0 -13
  80. package/cjs/modules/tagWatcher.js +0 -76
  81. package/cjs/modules/timing.js +0 -173
  82. package/cjs/modules/userTesting/SignalManager.js +0 -83
  83. package/cjs/modules/userTesting/dnd.js +0 -40
  84. package/cjs/modules/userTesting/index.js +0 -464
  85. package/cjs/modules/userTesting/recorder.js +0 -101
  86. package/cjs/modules/userTesting/styles.js +0 -266
  87. package/cjs/modules/userTesting/utils.js +0 -87
  88. package/cjs/modules/viewport.js +0 -43
  89. package/cjs/package.json +0 -1
  90. package/cjs/utils.js +0 -249
  91. package/coverage/clover.xml +0 -4304
  92. package/coverage/coverage-final.json +0 -55
  93. package/coverage/lcov-report/base.css +0 -224
  94. package/coverage/lcov-report/block-navigation.js +0 -87
  95. package/coverage/lcov-report/favicon.png +0 -0
  96. package/coverage/lcov-report/index.html +0 -206
  97. package/coverage/lcov-report/main/app/canvas.ts.html +0 -712
  98. package/coverage/lcov-report/main/app/guards.ts.html +0 -232
  99. package/coverage/lcov-report/main/app/index.html +0 -236
  100. package/coverage/lcov-report/main/app/index.ts.html +0 -3955
  101. package/coverage/lcov-report/main/app/logger.ts.html +0 -211
  102. package/coverage/lcov-report/main/app/messages.gen.ts.html +0 -3034
  103. package/coverage/lcov-report/main/app/nodes.ts.html +0 -406
  104. package/coverage/lcov-report/main/app/observer/iframe_observer.ts.html +0 -148
  105. package/coverage/lcov-report/main/app/observer/iframe_offsets.ts.html +0 -289
  106. package/coverage/lcov-report/main/app/observer/index.html +0 -161
  107. package/coverage/lcov-report/main/app/observer/shadow_root_observer.ts.html +0 -142
  108. package/coverage/lcov-report/main/app/observer/top_observer.ts.html +0 -541
  109. package/coverage/lcov-report/main/app/sanitizer.ts.html +0 -403
  110. package/coverage/lcov-report/main/app/session.ts.html +0 -622
  111. package/coverage/lcov-report/main/app/ticker.ts.html +0 -250
  112. package/coverage/lcov-report/main/index.html +0 -131
  113. package/coverage/lcov-report/main/index.ts.html +0 -1597
  114. package/coverage/lcov-report/main/modules/Network/beaconProxy.ts.html +0 -400
  115. package/coverage/lcov-report/main/modules/Network/fetchProxy.ts.html +0 -1075
  116. package/coverage/lcov-report/main/modules/Network/index.html +0 -191
  117. package/coverage/lcov-report/main/modules/Network/index.ts.html +0 -244
  118. package/coverage/lcov-report/main/modules/Network/networkMessage.ts.html +0 -400
  119. package/coverage/lcov-report/main/modules/Network/utils.ts.html +0 -709
  120. package/coverage/lcov-report/main/modules/Network/xhrProxy.ts.html +0 -877
  121. package/coverage/lcov-report/main/modules/attributeSender.ts.html +0 -241
  122. package/coverage/lcov-report/main/modules/axiosSpy.ts.html +0 -709
  123. package/coverage/lcov-report/main/modules/conditionsManager.ts.html +0 -1381
  124. package/coverage/lcov-report/main/modules/connection.ts.html +0 -160
  125. package/coverage/lcov-report/main/modules/console.ts.html +0 -541
  126. package/coverage/lcov-report/main/modules/constructedStyleSheets.ts.html +0 -571
  127. package/coverage/lcov-report/main/modules/cssrules.ts.html +0 -418
  128. package/coverage/lcov-report/main/modules/exception.ts.html +0 -385
  129. package/coverage/lcov-report/main/modules/featureFlags.ts.html +0 -415
  130. package/coverage/lcov-report/main/modules/focus.ts.html +0 -220
  131. package/coverage/lcov-report/main/modules/fonts.ts.html +0 -289
  132. package/coverage/lcov-report/main/modules/img.ts.html +0 -436
  133. package/coverage/lcov-report/main/modules/index.html +0 -431
  134. package/coverage/lcov-report/main/modules/input.ts.html +0 -826
  135. package/coverage/lcov-report/main/modules/mouse.ts.html +0 -826
  136. package/coverage/lcov-report/main/modules/network.ts.html +0 -1123
  137. package/coverage/lcov-report/main/modules/performance.ts.html +0 -367
  138. package/coverage/lcov-report/main/modules/scroll.ts.html +0 -364
  139. package/coverage/lcov-report/main/modules/selection.ts.html +0 -202
  140. package/coverage/lcov-report/main/modules/tabs.ts.html +0 -124
  141. package/coverage/lcov-report/main/modules/tagWatcher.ts.html +0 -337
  142. package/coverage/lcov-report/main/modules/timing.ts.html +0 -877
  143. package/coverage/lcov-report/main/modules/userTesting/SignalManager.ts.html +0 -370
  144. package/coverage/lcov-report/main/modules/userTesting/dnd.ts.html +0 -220
  145. package/coverage/lcov-report/main/modules/userTesting/index.html +0 -191
  146. package/coverage/lcov-report/main/modules/userTesting/index.ts.html +0 -1909
  147. package/coverage/lcov-report/main/modules/userTesting/recorder.ts.html +0 -430
  148. package/coverage/lcov-report/main/modules/userTesting/styles.ts.html +0 -937
  149. package/coverage/lcov-report/main/modules/userTesting/utils.ts.html +0 -364
  150. package/coverage/lcov-report/main/modules/viewport.ts.html +0 -250
  151. package/coverage/lcov-report/main/utils.ts.html +0 -814
  152. package/coverage/lcov-report/prettify.css +0 -1
  153. package/coverage/lcov-report/prettify.js +0 -2
  154. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  155. package/coverage/lcov-report/sorter.js +0 -196
  156. package/coverage/lcov-report/webworker/BatchWriter.ts.html +0 -499
  157. package/coverage/lcov-report/webworker/MessageEncoder.gen.ts.html +0 -1021
  158. package/coverage/lcov-report/webworker/PrimitiveEncoder.ts.html +0 -436
  159. package/coverage/lcov-report/webworker/QueueSender.ts.html +0 -547
  160. package/coverage/lcov-report/webworker/index.html +0 -176
  161. package/coverage/lcov-report/webworker/index.ts.html +0 -667
  162. package/coverage/lcov.info +0 -8425
  163. package/jest.config.js +0 -13
  164. package/lib/app/canvas.js +0 -202
  165. package/lib/app/guards.js +0 -26
  166. package/lib/app/index.js +0 -1367
  167. package/lib/app/logger.js +0 -33
  168. package/lib/app/messages.gen.js +0 -622
  169. package/lib/app/nodes.js +0 -108
  170. package/lib/app/observer/iframe_observer.js +0 -29
  171. package/lib/app/observer/iframe_offsets.js +0 -53
  172. package/lib/app/observer/observer.js +0 -380
  173. package/lib/app/observer/shadow_root_observer.js +0 -18
  174. package/lib/app/observer/top_observer.js +0 -128
  175. package/lib/app/sanitizer.js +0 -77
  176. package/lib/app/session.js +0 -137
  177. package/lib/app/ticker.js +0 -45
  178. package/lib/common/interaction.js +0 -1
  179. package/lib/common/messages.gen.js +0 -3
  180. package/lib/common/tsconfig.tsbuildinfo +0 -1
  181. package/lib/index.js +0 -423
  182. package/lib/modules/attributeSender.js +0 -46
  183. package/lib/modules/axiosSpy.js +0 -119
  184. package/lib/modules/conditionsManager.js +0 -340
  185. package/lib/modules/connection.js +0 -12
  186. package/lib/modules/console.js +0 -124
  187. package/lib/modules/constructedStyleSheets.js +0 -133
  188. package/lib/modules/cssrules.js +0 -97
  189. package/lib/modules/exception.js +0 -76
  190. package/lib/modules/featureFlags.js +0 -86
  191. package/lib/modules/focus.js +0 -42
  192. package/lib/modules/fonts.js +0 -54
  193. package/lib/modules/img.js +0 -107
  194. package/lib/modules/input.js +0 -198
  195. package/lib/modules/mouse.js +0 -192
  196. package/lib/modules/network.js +0 -238
  197. package/lib/modules/performance.js +0 -49
  198. package/lib/modules/scroll.js +0 -81
  199. package/lib/modules/selection.js +0 -35
  200. package/lib/modules/tabs.js +0 -10
  201. package/lib/modules/tagWatcher.js +0 -73
  202. package/lib/modules/timing.js +0 -170
  203. package/lib/modules/userTesting/SignalManager.js +0 -80
  204. package/lib/modules/userTesting/dnd.js +0 -37
  205. package/lib/modules/userTesting/index.js +0 -435
  206. package/lib/modules/userTesting/recorder.js +0 -97
  207. package/lib/modules/userTesting/styles.js +0 -263
  208. package/lib/modules/userTesting/utils.js +0 -79
  209. package/lib/modules/viewport.js +0 -40
  210. package/lib/utils.js +0 -230
  211. package/rollup.config.js +0 -12
  212. package/scripts/checkver.cjs +0 -7
  213. package/tsconfig-base.json +0 -16
  214. /package/{cjs → dist/cjs}/common/interaction.d.ts +0 -0
  215. /package/{cjs → dist/cjs}/common/messages.gen.d.ts +0 -0
  216. /package/{cjs → dist/cjs/main}/app/canvas.d.ts +0 -0
  217. /package/{cjs → dist/cjs/main}/app/guards.d.ts +0 -0
  218. /package/{cjs → dist/cjs/main}/app/observer/shadow_root_observer.d.ts +0 -0
  219. /package/{cjs → dist/cjs/main}/app/ticker.d.ts +0 -0
  220. /package/{cjs → dist/cjs/main}/modules/axiosSpy.d.ts +0 -0
  221. /package/{cjs → dist/cjs/main}/modules/connection.d.ts +0 -0
  222. /package/{cjs → dist/cjs/main}/modules/console.d.ts +0 -0
  223. /package/{cjs → dist/cjs/main}/modules/constructedStyleSheets.d.ts +0 -0
  224. /package/{cjs → dist/cjs/main}/modules/cssrules.d.ts +0 -0
  225. /package/{cjs → dist/cjs/main}/modules/exception.d.ts +0 -0
  226. /package/{cjs → dist/cjs/main}/modules/featureFlags.d.ts +0 -0
  227. /package/{cjs → dist/cjs/main}/modules/focus.d.ts +0 -0
  228. /package/{cjs → dist/cjs/main}/modules/fonts.d.ts +0 -0
  229. /package/{cjs → dist/cjs/main}/modules/img.d.ts +0 -0
  230. /package/{cjs → dist/cjs/main}/modules/input.d.ts +0 -0
  231. /package/{cjs → dist/cjs/main}/modules/mouse.d.ts +0 -0
  232. /package/{cjs → dist/cjs/main}/modules/network.d.ts +0 -0
  233. /package/{cjs → dist/cjs/main}/modules/performance.d.ts +0 -0
  234. /package/{cjs → dist/cjs/main}/modules/scroll.d.ts +0 -0
  235. /package/{cjs → dist/cjs/main}/modules/selection.d.ts +0 -0
  236. /package/{cjs → dist/cjs/main}/modules/tabs.d.ts +0 -0
  237. /package/{cjs → dist/cjs/main}/modules/timing.d.ts +0 -0
  238. /package/{cjs → dist/cjs/main}/modules/userTesting/dnd.d.ts +0 -0
  239. /package/{cjs → dist/cjs/main}/modules/userTesting/index.d.ts +0 -0
  240. /package/{cjs → dist/cjs/main}/modules/userTesting/recorder.d.ts +0 -0
  241. /package/{cjs → dist/cjs/main}/modules/userTesting/styles.d.ts +0 -0
  242. /package/{cjs → dist/cjs/main}/modules/userTesting/utils.d.ts +0 -0
  243. /package/{cjs → dist/cjs/main}/modules/viewport.d.ts +0 -0
  244. /package/{lib → dist/lib}/common/interaction.d.ts +0 -0
  245. /package/{lib → dist/lib}/common/messages.gen.d.ts +0 -0
  246. /package/{lib → dist/lib/main}/app/canvas.d.ts +0 -0
  247. /package/{lib → dist/lib/main}/app/guards.d.ts +0 -0
  248. /package/{lib → dist/lib/main}/app/observer/shadow_root_observer.d.ts +0 -0
  249. /package/{lib → dist/lib/main}/app/ticker.d.ts +0 -0
  250. /package/{lib → dist/lib/main}/modules/axiosSpy.d.ts +0 -0
  251. /package/{lib → dist/lib/main}/modules/connection.d.ts +0 -0
  252. /package/{lib → dist/lib/main}/modules/console.d.ts +0 -0
  253. /package/{lib → dist/lib/main}/modules/constructedStyleSheets.d.ts +0 -0
  254. /package/{lib → dist/lib/main}/modules/cssrules.d.ts +0 -0
  255. /package/{lib → dist/lib/main}/modules/exception.d.ts +0 -0
  256. /package/{lib → dist/lib/main}/modules/featureFlags.d.ts +0 -0
  257. /package/{lib → dist/lib/main}/modules/focus.d.ts +0 -0
  258. /package/{lib → dist/lib/main}/modules/fonts.d.ts +0 -0
  259. /package/{lib → dist/lib/main}/modules/img.d.ts +0 -0
  260. /package/{lib → dist/lib/main}/modules/input.d.ts +0 -0
  261. /package/{lib → dist/lib/main}/modules/mouse.d.ts +0 -0
  262. /package/{lib → dist/lib/main}/modules/network.d.ts +0 -0
  263. /package/{lib → dist/lib/main}/modules/performance.d.ts +0 -0
  264. /package/{lib → dist/lib/main}/modules/scroll.d.ts +0 -0
  265. /package/{lib → dist/lib/main}/modules/selection.d.ts +0 -0
  266. /package/{lib → dist/lib/main}/modules/tabs.d.ts +0 -0
  267. /package/{lib → dist/lib/main}/modules/timing.d.ts +0 -0
  268. /package/{lib → dist/lib/main}/modules/userTesting/dnd.d.ts +0 -0
  269. /package/{lib → dist/lib/main}/modules/userTesting/index.d.ts +0 -0
  270. /package/{lib → dist/lib/main}/modules/userTesting/recorder.d.ts +0 -0
  271. /package/{lib → dist/lib/main}/modules/userTesting/styles.d.ts +0 -0
  272. /package/{lib → dist/lib/main}/modules/userTesting/utils.d.ts +0 -0
  273. /package/{lib → dist/lib/main}/modules/viewport.d.ts +0 -0
package/cjs/app/nodes.js DELETED
@@ -1,111 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_js_1 = require("../utils.js");
4
- class Nodes {
5
- constructor(node_id, angularMode) {
6
- this.node_id = node_id;
7
- this.angularMode = angularMode;
8
- this.nodes = [];
9
- this.totalNodeAmount = 0;
10
- this.nodeCallbacks = [];
11
- this.elementListeners = new Map();
12
- this.nextNodeId = 0;
13
- this.scanTree = (cb) => {
14
- this.nodes.forEach((node) => cb(node));
15
- };
16
- this.attachNodeListener = (node, type, listener, useCapture = true) => {
17
- const id = this.getID(node);
18
- if (id === undefined) {
19
- return;
20
- }
21
- (0, utils_js_1.createEventListener)(node, type, listener, useCapture, this.angularMode);
22
- let listeners = this.elementListeners.get(id);
23
- if (listeners === undefined) {
24
- listeners = [];
25
- this.elementListeners.set(id, listeners);
26
- }
27
- listeners.push([type, listener, useCapture]);
28
- };
29
- }
30
- syntheticMode(frameOrder) {
31
- const maxSafeNumber = Number.MAX_SAFE_INTEGER;
32
- const placeholderSize = 99999999;
33
- const nextFrameId = placeholderSize * frameOrder;
34
- // I highly doubt that this will ever happen,
35
- // but it will be easier to debug if it does
36
- if (nextFrameId > maxSafeNumber) {
37
- throw new Error('Placeholder id overflow');
38
- }
39
- this.nextNodeId = nextFrameId;
40
- }
41
- // Attached once per Tracker instance
42
- attachNodeCallback(nodeCallback) {
43
- this.nodeCallbacks.push(nodeCallback);
44
- }
45
- registerNode(node) {
46
- let id = node[this.node_id];
47
- const isNew = id === undefined;
48
- if (isNew) {
49
- id = this.nextNodeId;
50
- this.totalNodeAmount++;
51
- this.nextNodeId++;
52
- this.nodes[id] = node;
53
- node[this.node_id] = id;
54
- }
55
- return [id, isNew];
56
- }
57
- unregisterNode(node) {
58
- const id = node[this.node_id];
59
- if (id !== undefined) {
60
- ;
61
- node[this.node_id] = undefined;
62
- delete node[this.node_id];
63
- delete this.nodes[id];
64
- const listeners = this.elementListeners.get(id);
65
- if (listeners !== undefined) {
66
- this.elementListeners.delete(id);
67
- listeners.forEach((listener) => (0, utils_js_1.deleteEventListener)(node, listener[0], listener[1], listener[2], this.angularMode));
68
- }
69
- this.totalNodeAmount--;
70
- }
71
- return id;
72
- }
73
- cleanTree() {
74
- // sadly we keep empty items in array here resulting in some memory still being used
75
- // but its still better than keeping dead nodes or undef elements
76
- // plus we keep our index positions for new/alive nodes
77
- // performance test: 3ms for 30k nodes with 17k dead ones
78
- for (let i = 0; i < this.nodes.length; i++) {
79
- const node = this.nodes[i];
80
- if (node && !document.contains(node)) {
81
- this.unregisterNode(node);
82
- }
83
- }
84
- }
85
- callNodeCallbacks(node, isStart) {
86
- this.nodeCallbacks.forEach((cb) => cb(node, isStart));
87
- }
88
- getID(node) {
89
- if (!node)
90
- return undefined;
91
- return node[this.node_id];
92
- }
93
- getNode(id) {
94
- return this.nodes[id];
95
- }
96
- getNodeCount() {
97
- return this.totalNodeAmount;
98
- }
99
- clear() {
100
- for (let id = 0; id < this.nodes.length; id++) {
101
- const node = this.nodes[id];
102
- if (!node) {
103
- continue;
104
- }
105
- this.unregisterNode(node);
106
- }
107
- this.nextNodeId = 0;
108
- this.nodes.length = 0;
109
- }
110
- }
111
- exports.default = Nodes;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const observer_js_1 = __importDefault(require("./observer.js"));
7
- const messages_gen_js_1 = require("../messages.gen.js");
8
- class IFrameObserver extends observer_js_1.default {
9
- observe(iframe) {
10
- const doc = iframe.contentDocument;
11
- const hostID = this.app.nodes.getID(iframe);
12
- if (!doc || hostID === undefined) {
13
- return;
14
- } //log TODO common app.logger
15
- // Have to observe document, because the inner <html> might be changed
16
- this.observeRoot(doc, (docID) => {
17
- //MBTODO: do not send if empty (send on load? it might be in-place iframe, like our replayer, which does not get loaded)
18
- if (docID === undefined) {
19
- this.app.debug.log('OpenReplay: Iframe document not bound');
20
- return;
21
- }
22
- this.app.send((0, messages_gen_js_1.CreateIFrameDocument)(hostID, docID));
23
- });
24
- }
25
- syntheticObserve(rootNodeId, doc) {
26
- this.observeRoot(doc, (docID) => {
27
- if (docID === undefined) {
28
- this.app.debug.log('OpenReplay: Iframe document not bound');
29
- return;
30
- }
31
- this.app.send((0, messages_gen_js_1.CreateIFrameDocument)(rootNodeId, docID));
32
- });
33
- }
34
- }
35
- exports.default = IFrameObserver;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class IFrameOffsets {
4
- constructor() {
5
- this.states = new Map();
6
- }
7
- calcOffset(state) {
8
- let parLeft = 0, parTop = 0;
9
- if (state.parent) {
10
- ;
11
- [parLeft, parTop] = this.calcOffset(state.parent);
12
- }
13
- if (!state.offset) {
14
- const { left, top } = state.iFrame.getBoundingClientRect();
15
- state.offset = [left, top];
16
- }
17
- const [left, top] = state.offset;
18
- return [parLeft + left, parTop + top]; // TODO: store absolute sum, invalidate whole subtree. Otherwise it is summated on each mousemove
19
- }
20
- getDocumentOffset(doc) {
21
- const state = this.states.get(doc);
22
- if (!state) {
23
- return [0, 0];
24
- } // topmost doc
25
- return this.calcOffset(state);
26
- }
27
- observe(iFrame) {
28
- const doc = iFrame.contentDocument;
29
- if (!doc) {
30
- return;
31
- }
32
- const parentDoc = iFrame.ownerDocument;
33
- const parentState = this.states.get(parentDoc);
34
- const state = {
35
- offset: null,
36
- iFrame,
37
- parent: parentState || null,
38
- clear: () => {
39
- parentDoc.removeEventListener('scroll', invalidateOffset);
40
- parentDoc.defaultView?.removeEventListener('resize', invalidateOffset);
41
- },
42
- };
43
- const invalidateOffset = () => {
44
- state.offset = null;
45
- };
46
- // anything more reliable? This does not cover all cases (layout changes are ignored, for ex.)
47
- parentDoc.addEventListener('scroll', invalidateOffset);
48
- parentDoc.defaultView?.addEventListener('resize', invalidateOffset);
49
- this.states.set(doc, state);
50
- }
51
- clear() {
52
- this.states.forEach((s) => s.clear());
53
- this.states.clear();
54
- }
55
- }
56
- exports.default = IFrameOffsets;
@@ -1,383 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_js_1 = require("../../utils.js");
4
- const messages_gen_js_1 = require("../messages.gen.js");
5
- const guards_js_1 = require("../guards.js");
6
- function isIgnored(node) {
7
- if ((0, guards_js_1.isCommentNode)(node)) {
8
- return true;
9
- }
10
- if ((0, guards_js_1.isTextNode)(node)) {
11
- return false;
12
- }
13
- if (!(0, guards_js_1.isElementNode)(node)) {
14
- return true;
15
- }
16
- const tag = node.tagName.toUpperCase();
17
- if (tag === 'LINK') {
18
- const rel = node.getAttribute('rel');
19
- const as = node.getAttribute('as');
20
- return !(rel?.includes('stylesheet') || as === 'style' || as === 'font');
21
- }
22
- return (tag === 'SCRIPT' || tag === 'NOSCRIPT' || tag === 'META' || tag === 'TITLE' || tag === 'BASE');
23
- }
24
- function isObservable(node) {
25
- if ((0, guards_js_1.isRootNode)(node)) {
26
- return true;
27
- }
28
- return !isIgnored(node);
29
- }
30
- /*
31
- TODO:
32
- - fix unbinding logic + send all removals first (ensure sequence is correct)
33
- - use document as a 0-node in the upper context (should be updated in player at first)
34
- */
35
- var RecentsType;
36
- (function (RecentsType) {
37
- RecentsType[RecentsType["New"] = 0] = "New";
38
- RecentsType[RecentsType["Removed"] = 1] = "Removed";
39
- RecentsType[RecentsType["Changed"] = 2] = "Changed";
40
- })(RecentsType || (RecentsType = {}));
41
- class Observer {
42
- constructor(app, isTopContext = false) {
43
- this.app = app;
44
- this.isTopContext = isTopContext;
45
- this.commited = [];
46
- this.recents = new Map();
47
- this.indexes = [];
48
- this.attributesMap = new Map();
49
- this.textSet = new Set();
50
- this.observer = (0, utils_js_1.createMutationObserver)(this.app.safe((mutations) => {
51
- for (const mutation of mutations) {
52
- // mutations order is sequential
53
- const target = mutation.target;
54
- const type = mutation.type;
55
- if (!isObservable(target)) {
56
- continue;
57
- }
58
- if (type === 'childList') {
59
- for (let i = 0; i < mutation.removedNodes.length; i++) {
60
- if (isObservable(mutation.removedNodes[i])) {
61
- this.bindNode(mutation.removedNodes[i]);
62
- }
63
- }
64
- for (let i = 0; i < mutation.addedNodes.length; i++) {
65
- this.bindTree(mutation.addedNodes[i]);
66
- }
67
- continue;
68
- }
69
- const id = this.app.nodes.getID(target);
70
- if (id === undefined) {
71
- continue;
72
- }
73
- if (!this.recents.has(id)) {
74
- this.recents.set(id, RecentsType.Changed); // TODO only when altered
75
- }
76
- if (type === 'attributes') {
77
- const name = mutation.attributeName;
78
- if (name === null) {
79
- continue;
80
- }
81
- if (target instanceof HTMLIFrameElement && name === 'src') {
82
- this.handleIframeSrcChange(target);
83
- }
84
- let attr = this.attributesMap.get(id);
85
- if (attr === undefined) {
86
- this.attributesMap.set(id, (attr = new Set()));
87
- }
88
- attr.add(name);
89
- continue;
90
- }
91
- if (type === 'characterData') {
92
- this.textSet.add(id);
93
- }
94
- }
95
- this.commitNodes();
96
- }), this.app.options.angularMode);
97
- }
98
- clear() {
99
- this.commited.length = 0;
100
- this.recents.clear();
101
- this.indexes.length = 1;
102
- this.attributesMap.clear();
103
- this.textSet.clear();
104
- }
105
- /**
106
- * Unbinds the removed nodes in case of iframe src change.
107
- */
108
- handleIframeSrcChange(iframe) {
109
- const oldContentDocument = iframe.contentDocument;
110
- if (oldContentDocument) {
111
- const id = this.app.nodes.getID(oldContentDocument);
112
- if (id !== undefined) {
113
- const walker = document.createTreeWalker(oldContentDocument, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, {
114
- acceptNode: (node) => isIgnored(node) || this.app.nodes.getID(node) === undefined
115
- ? NodeFilter.FILTER_REJECT
116
- : NodeFilter.FILTER_ACCEPT,
117
- },
118
- // @ts-ignore
119
- false);
120
- let removed = 0;
121
- const totalBeforeRemove = this.app.nodes.getNodeCount();
122
- while (walker.nextNode()) {
123
- if (!iframe.contentDocument.contains(walker.currentNode)) {
124
- removed += 1;
125
- this.app.nodes.unregisterNode(walker.currentNode);
126
- }
127
- }
128
- const removedPercent = Math.floor((removed / totalBeforeRemove) * 100);
129
- if (removedPercent > 30) {
130
- this.app.send((0, messages_gen_js_1.UnbindNodes)(removedPercent));
131
- }
132
- }
133
- }
134
- }
135
- sendNodeAttribute(id, node, name, value) {
136
- if ((0, guards_js_1.isSVGElement)(node)) {
137
- if (name.substring(0, 6) === 'xlink:') {
138
- name = name.substring(6);
139
- }
140
- if (value === null) {
141
- this.app.send((0, messages_gen_js_1.RemoveNodeAttribute)(id, name));
142
- }
143
- else if (name === 'href') {
144
- if (value.length > 1e5) {
145
- value = '';
146
- }
147
- this.app.send((0, messages_gen_js_1.SetNodeAttributeURLBased)(id, name, value, this.app.getBaseHref()));
148
- }
149
- else {
150
- this.app.attributeSender.sendSetAttribute(id, name, value);
151
- }
152
- return;
153
- }
154
- if (name === 'src' ||
155
- name === 'srcset' ||
156
- name === 'integrity' ||
157
- name === 'crossorigin' ||
158
- name === 'autocomplete' ||
159
- name.substring(0, 2) === 'on') {
160
- return;
161
- }
162
- if (name === 'value' &&
163
- (0, guards_js_1.hasTag)(node, 'input') &&
164
- node.type !== 'button' &&
165
- node.type !== 'reset' &&
166
- node.type !== 'submit') {
167
- return;
168
- }
169
- if (value === null) {
170
- this.app.send((0, messages_gen_js_1.RemoveNodeAttribute)(id, name));
171
- return;
172
- }
173
- if (name === 'style' || (name === 'href' && (0, guards_js_1.hasTag)(node, 'link'))) {
174
- this.app.send((0, messages_gen_js_1.SetNodeAttributeURLBased)(id, name, value, this.app.getBaseHref()));
175
- return;
176
- }
177
- if (name === 'href' || value.length > 1e5) {
178
- value = '';
179
- }
180
- this.app.attributeSender.sendSetAttribute(id, name, value);
181
- }
182
- sendNodeData(id, parentElement, data) {
183
- if ((0, guards_js_1.hasTag)(parentElement, 'style')) {
184
- this.app.send((0, messages_gen_js_1.SetCSSDataURLBased)(id, data, this.app.getBaseHref()));
185
- return;
186
- }
187
- data = this.app.sanitizer.sanitize(id, data);
188
- this.app.send((0, messages_gen_js_1.SetNodeData)(id, data));
189
- }
190
- bindNode(node) {
191
- const [id, isNew] = this.app.nodes.registerNode(node);
192
- if (isNew) {
193
- this.recents.set(id, RecentsType.New);
194
- }
195
- else if (this.recents.get(id) !== RecentsType.New) {
196
- this.recents.set(id, RecentsType.Removed);
197
- }
198
- }
199
- bindTree(node) {
200
- if (!isObservable(node)) {
201
- return;
202
- }
203
- this.bindNode(node);
204
- const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, {
205
- acceptNode: (node) => {
206
- if (this.app.nodes.getID(node) !== undefined) {
207
- this.app.debug.error('! Node is already bound', node);
208
- }
209
- return isIgnored(node) || this.app.nodes.getID(node) !== undefined
210
- ? NodeFilter.FILTER_REJECT
211
- : NodeFilter.FILTER_ACCEPT;
212
- },
213
- },
214
- // @ts-ignore
215
- false);
216
- while (walker.nextNode()) {
217
- this.bindNode(walker.currentNode);
218
- }
219
- }
220
- unbindTree(node) {
221
- const id = this.app.nodes.unregisterNode(node);
222
- if (id !== undefined && this.recents.get(id) === RecentsType.Removed) {
223
- // Sending RemoveNode only for parent to maintain
224
- this.app.send((0, messages_gen_js_1.RemoveNode)(id));
225
- // Unregistering all the children in order to clear the memory
226
- const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT + NodeFilter.SHOW_TEXT, {
227
- acceptNode: (node) => isIgnored(node) || this.app.nodes.getID(node) === undefined
228
- ? NodeFilter.FILTER_REJECT
229
- : NodeFilter.FILTER_ACCEPT,
230
- },
231
- // @ts-ignore
232
- false);
233
- let removed = 0;
234
- const totalBeforeRemove = this.app.nodes.getNodeCount();
235
- while (walker.nextNode()) {
236
- removed += 1;
237
- this.app.nodes.unregisterNode(walker.currentNode);
238
- }
239
- const removedPercent = Math.floor((removed / totalBeforeRemove) * 100);
240
- if (removedPercent > 30) {
241
- this.app.send((0, messages_gen_js_1.UnbindNodes)(removedPercent));
242
- }
243
- }
244
- }
245
- // A top-consumption function on the infinite lists test. (~1% of performance resources)
246
- _commitNode(id, node) {
247
- if ((0, guards_js_1.isRootNode)(node)) {
248
- return true;
249
- }
250
- const parent = node.parentNode;
251
- let parentID;
252
- // Disable parent check for the upper context HTMLHtmlElement, because it is root there... (before)
253
- // TODO: get rid of "special" cases (there is an issue with CreateDocument altered behaviour though)
254
- // TODO: Clean the logic (though now it workd fine)
255
- if (!(0, guards_js_1.hasTag)(node, 'html') || !this.isTopContext) {
256
- if (parent === null) {
257
- // Sometimes one observation contains attribute mutations for the removimg node, which gets ignored here.
258
- // That shouldn't affect the visual rendering ( should it? maybe when transition applied? )
259
- this.unbindTree(node);
260
- return false;
261
- }
262
- parentID = this.app.nodes.getID(parent);
263
- if (parentID === undefined) {
264
- this.unbindTree(node);
265
- return false;
266
- }
267
- if (!this.commitNode(parentID)) {
268
- this.unbindTree(node);
269
- return false;
270
- }
271
- this.app.sanitizer.handleNode(id, parentID, node);
272
- if (this.app.sanitizer.isHidden(parentID)) {
273
- return false;
274
- }
275
- }
276
- // From here parentID === undefined if node is top context HTML node
277
- let sibling = node.previousSibling;
278
- while (sibling !== null) {
279
- const siblingID = this.app.nodes.getID(sibling);
280
- if (siblingID !== undefined) {
281
- this.commitNode(siblingID);
282
- this.indexes[id] = this.indexes[siblingID] + 1;
283
- break;
284
- }
285
- sibling = sibling.previousSibling;
286
- }
287
- if (sibling === null) {
288
- this.indexes[id] = 0;
289
- }
290
- const recentsType = this.recents.get(id);
291
- const isNew = recentsType === RecentsType.New;
292
- const index = this.indexes[id];
293
- if (index === undefined) {
294
- throw 'commitNode: missing node index';
295
- }
296
- if (isNew) {
297
- if ((0, guards_js_1.isElementNode)(node)) {
298
- let el = node;
299
- if (parentID !== undefined) {
300
- if (this.app.sanitizer.isHidden(id)) {
301
- const width = el.clientWidth;
302
- const height = el.clientHeight;
303
- el = node.cloneNode();
304
- el.style.width = `${width}px`;
305
- el.style.height = `${height}px`;
306
- }
307
- this.app.send((0, messages_gen_js_1.CreateElementNode)(id, parentID, index, el.tagName, (0, guards_js_1.isSVGElement)(node)));
308
- }
309
- for (let i = 0; i < el.attributes.length; i++) {
310
- const attr = el.attributes[i];
311
- this.sendNodeAttribute(id, el, attr.nodeName, attr.value);
312
- }
313
- }
314
- else if ((0, guards_js_1.isTextNode)(node)) {
315
- // for text node id != 0, hence parentID !== undefined and parent is Element
316
- this.app.send((0, messages_gen_js_1.CreateTextNode)(id, parentID, index));
317
- this.sendNodeData(id, parent, node.data);
318
- }
319
- return true;
320
- }
321
- if (recentsType === RecentsType.Removed && parentID !== undefined) {
322
- this.app.send((0, messages_gen_js_1.MoveNode)(id, parentID, index));
323
- }
324
- const attr = this.attributesMap.get(id);
325
- if (attr !== undefined) {
326
- if (!(0, guards_js_1.isElementNode)(node)) {
327
- throw 'commitNode: node is not an element';
328
- }
329
- for (const name of attr) {
330
- this.sendNodeAttribute(id, node, name, node.getAttribute(name));
331
- }
332
- }
333
- if (this.textSet.has(id)) {
334
- if (!(0, guards_js_1.isTextNode)(node)) {
335
- throw 'commitNode: node is not a text';
336
- }
337
- // for text node id != 0, hence parent is Element
338
- this.sendNodeData(id, parent, node.data);
339
- }
340
- return true;
341
- }
342
- commitNode(id) {
343
- const node = this.app.nodes.getNode(id);
344
- if (node === undefined) {
345
- return false;
346
- }
347
- const cmt = this.commited[id];
348
- if (cmt !== undefined) {
349
- return cmt;
350
- }
351
- return (this.commited[id] = this._commitNode(id, node));
352
- }
353
- commitNodes(isStart = false) {
354
- let node;
355
- this.recents.forEach((type, id) => {
356
- this.commitNode(id);
357
- if (type === RecentsType.New && (node = this.app.nodes.getNode(id))) {
358
- this.app.nodes.callNodeCallbacks(node, isStart);
359
- }
360
- });
361
- this.clear();
362
- }
363
- // ISSSUE (nodeToBinde should be the same as node in all cases. Look at the comment about 0-node at the beginning of the file.)
364
- // TODO: use one observer instance for all iframes/shadowRoots (composition instiad of inheritance)
365
- observeRoot(node, beforeCommit, nodeToBind = node) {
366
- this.observer.observe(node, {
367
- childList: true,
368
- attributes: true,
369
- characterData: true,
370
- subtree: true,
371
- attributeOldValue: false,
372
- characterDataOldValue: false,
373
- });
374
- this.bindTree(nodeToBind);
375
- beforeCommit(this.app.nodes.getID(node));
376
- this.commitNodes(true);
377
- }
378
- disconnect() {
379
- this.observer.disconnect();
380
- this.clear();
381
- }
382
- }
383
- exports.default = Observer;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const observer_js_1 = __importDefault(require("./observer.js"));
7
- const messages_gen_js_1 = require("../messages.gen.js");
8
- class ShadowRootObserver extends observer_js_1.default {
9
- observe(el) {
10
- const shRoot = el.shadowRoot;
11
- const hostID = this.app.nodes.getID(el);
12
- if (!shRoot || hostID === undefined) {
13
- return;
14
- } // log
15
- this.observeRoot(shRoot, (rootID) => {
16
- if (rootID === undefined) {
17
- this.app.debug.error('OpenReplay: Shadow Root was not bound');
18
- return;
19
- }
20
- this.app.send((0, messages_gen_js_1.CreateIFrameDocument)(hostID, rootID));
21
- });
22
- }
23
- }
24
- exports.default = ShadowRootObserver;