@openreplay/tracker 14.0.10-beta.1 → 14.0.10

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