@highlight-run/rrweb 1.2.1 → 2.0.4

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 (191) hide show
  1. package/dist/plugins/console-record.js +454 -0
  2. package/dist/plugins/console-record.min.js +12 -15
  3. package/dist/plugins/console-record.min.js.map +1 -1
  4. package/dist/plugins/console-replay.js +164 -0
  5. package/dist/plugins/console-replay.min.js +5 -0
  6. package/dist/plugins/console-replay.min.js.map +1 -0
  7. package/dist/plugins/sequential-id-record.js +30 -0
  8. package/dist/plugins/sequential-id-record.min.js +2 -0
  9. package/dist/plugins/sequential-id-record.min.js.map +1 -0
  10. package/dist/plugins/sequential-id-replay.js +33 -0
  11. package/dist/plugins/sequential-id-replay.min.js +2 -0
  12. package/dist/plugins/sequential-id-replay.min.js.map +1 -0
  13. package/dist/record/rrweb-record-pack.js +664 -0
  14. package/dist/record/rrweb-record-pack.min.js +4 -0
  15. package/dist/record/rrweb-record-pack.min.js.map +1 -0
  16. package/dist/record/rrweb-record.js +3202 -0
  17. package/dist/record/rrweb-record.min.js +5 -0
  18. package/dist/record/rrweb-record.min.js.map +1 -0
  19. package/dist/replay/rrweb-replay-unpack.js +4926 -0
  20. package/dist/replay/rrweb-replay-unpack.min.js +18 -0
  21. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -0
  22. package/dist/replay/rrweb-replay.js +4518 -0
  23. package/dist/replay/rrweb-replay.min.js +18 -0
  24. package/dist/replay/rrweb-replay.min.js.map +1 -0
  25. package/dist/rrweb-all.js +8889 -0
  26. package/dist/rrweb-all.min.js +29 -0
  27. package/dist/rrweb-all.min.js.map +1 -0
  28. package/dist/rrweb.js +7558 -0
  29. package/dist/rrweb.min.js +6 -17
  30. package/dist/rrweb.min.js.map +1 -1
  31. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__createBase64WorkerFactory.js +12 -0
  32. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__auto__isNodeJS.js +7 -0
  33. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__browser__createBase64WorkerFactory.js +31 -0
  34. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__WorkerClass.js +11 -0
  35. package/es/rrweb/_virtual/_rollup-plugin-web-worker-loader__helper__node__createBase64WorkerFactory.js +18 -0
  36. package/es/rrweb/_virtual/image-bitmap-data-url-worker.js +6 -0
  37. package/es/rrweb/ext/@xstate/fsm/es/index.js +17 -0
  38. package/es/rrweb/ext/base64-arraybuffer/dist/base64-arraybuffer.es5.js +49 -0
  39. package/es/rrweb/ext/fflate/esm/browser.js +777 -0
  40. package/es/rrweb/ext/mitt/dist/mitt.es.js +63 -0
  41. package/es/rrweb/ext/tslib/tslib.es6.js +38 -0
  42. package/es/rrweb/packages/rrdom/es/virtual-dom.js +1099 -0
  43. package/es/rrweb/packages/rrweb/src/entries/all.js +13 -0
  44. package/es/rrweb/packages/rrweb/src/index.js +14 -0
  45. package/es/rrweb/packages/rrweb/src/packer/base.js +3 -0
  46. package/es/rrweb/packages/rrweb/src/packer/pack.js +9 -0
  47. package/es/rrweb/packages/rrweb/src/packer/unpack.js +29 -0
  48. package/es/rrweb/packages/rrweb/src/plugins/console/record/error-stack-parser.js +178 -0
  49. package/es/rrweb/packages/rrweb/src/plugins/console/record/index.js +115 -0
  50. package/es/rrweb/packages/rrweb/src/plugins/console/record/stringify.js +128 -0
  51. package/es/rrweb/packages/rrweb/src/plugins/console/replay/index.js +94 -0
  52. package/es/rrweb/packages/rrweb/src/plugins/sequential-id/record/index.js +22 -0
  53. package/es/rrweb/packages/rrweb/src/plugins/sequential-id/replay/index.js +28 -0
  54. package/es/rrweb/packages/rrweb/src/record/iframe-manager.js +31 -0
  55. package/es/rrweb/packages/rrweb/src/record/index.js +356 -0
  56. package/es/rrweb/packages/rrweb/src/record/mutation.js +491 -0
  57. package/es/rrweb/packages/rrweb/src/record/observer.js +590 -0
  58. package/es/rrweb/packages/rrweb/src/record/observers/canvas/2d.js +49 -0
  59. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas-manager.js +172 -0
  60. package/es/rrweb/packages/rrweb/src/record/observers/canvas/canvas.js +25 -0
  61. package/es/rrweb/packages/rrweb/src/record/observers/canvas/serialize-args.js +123 -0
  62. package/es/rrweb/packages/rrweb/src/record/observers/canvas/webgl.js +59 -0
  63. package/es/rrweb/packages/rrweb/src/record/shadow-dom-manager.js +43 -0
  64. package/es/rrweb/packages/rrweb/src/record/stylesheet-manager.js +31 -0
  65. package/es/rrweb/packages/rrweb/src/replay/canvas/2d.js +29 -0
  66. package/es/rrweb/packages/rrweb/src/replay/canvas/deserialize-args.js +67 -0
  67. package/es/rrweb/packages/rrweb/src/replay/canvas/index.js +43 -0
  68. package/es/rrweb/packages/rrweb/src/replay/canvas/webgl.js +62 -0
  69. package/es/rrweb/packages/rrweb/src/replay/index.js +1555 -0
  70. package/es/rrweb/packages/rrweb/src/replay/machine.js +281 -0
  71. package/es/rrweb/packages/rrweb/src/replay/smoothscroll.js +219 -0
  72. package/es/rrweb/packages/rrweb/src/replay/styles/inject-style.js +8 -0
  73. package/es/rrweb/packages/rrweb/src/replay/timer.js +92 -0
  74. package/es/rrweb/packages/rrweb/src/types.js +75 -0
  75. package/es/rrweb/packages/rrweb/src/utils.js +315 -0
  76. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1821 -0
  77. package/lib/plugins/console-record.js +492 -0
  78. package/lib/plugins/console-replay.js +218 -0
  79. package/lib/plugins/sequential-id-record.js +27 -0
  80. package/lib/plugins/sequential-id-replay.js +32 -0
  81. package/lib/record/rrweb-record-pack.js +787 -0
  82. package/lib/record/rrweb-record.js +3363 -0
  83. package/lib/replay/rrweb-replay-unpack.js +5075 -0
  84. package/lib/replay/rrweb-replay.js +4665 -0
  85. package/lib/rrweb-all.js +9181 -0
  86. package/lib/rrweb.js +7814 -0
  87. package/package.json +41 -42
  88. package/typings/entries/all.d.ts +6 -0
  89. package/{dist → typings}/entries/record-pack.d.ts +0 -0
  90. package/{dist → typings}/entries/replay-unpack.d.ts +0 -0
  91. package/{dist → typings}/index.d.ts +1 -2
  92. package/{dist → typings}/packer/base.d.ts +1 -1
  93. package/{dist → typings}/packer/index.d.ts +0 -0
  94. package/{dist → typings}/packer/pack.d.ts +0 -0
  95. package/{dist → typings}/packer/unpack.d.ts +0 -0
  96. package/{dist → typings}/plugins/console/record/error-stack-parser.d.ts +0 -0
  97. package/{dist → typings}/plugins/console/record/index.d.ts +4 -3
  98. package/{dist → typings}/plugins/console/record/stringify.d.ts +1 -1
  99. package/{dist → typings}/plugins/console/replay/index.d.ts +2 -2
  100. package/{dist → typings}/plugins/sequential-id/record/index.d.ts +1 -1
  101. package/{dist → typings}/plugins/sequential-id/replay/index.d.ts +1 -1
  102. package/{dist → typings}/record/iframe-manager.d.ts +3 -3
  103. package/{dist/plugins → typings}/record/index.d.ts +9 -9
  104. package/{dist → typings}/record/mutation.d.ts +6 -8
  105. package/typings/record/observer.d.ts +7 -0
  106. package/{dist/plugins → typings}/record/observers/canvas/2d.d.ts +3 -2
  107. package/{dist → typings}/record/observers/canvas/canvas-manager.d.ts +5 -2
  108. package/{dist/plugins → typings}/record/observers/canvas/canvas.d.ts +2 -2
  109. package/typings/record/observers/canvas/serialize-args.d.ts +6 -0
  110. package/{dist/plugins → typings}/record/observers/canvas/webgl.d.ts +3 -2
  111. package/typings/record/observers/canvas/webgl2.d.ts +2 -0
  112. package/typings/record/shadow-dom-manager.d.ts +22 -0
  113. package/typings/record/stylesheet-manager.d.ts +12 -0
  114. package/typings/record/workers/image-bitmap-data-url-worker.d.ts +5 -0
  115. package/{dist → typings}/replay/canvas/2d.d.ts +3 -3
  116. package/typings/replay/canvas/deserialize-args.d.ts +7 -0
  117. package/{dist/plugins → typings}/replay/canvas/index.d.ts +10 -9
  118. package/typings/replay/canvas/webgl.d.ts +9 -0
  119. package/{dist → typings}/replay/index.d.ts +7 -9
  120. package/{dist → typings}/replay/machine.d.ts +0 -0
  121. package/{dist → typings}/replay/smoothscroll.d.ts +0 -0
  122. package/{dist → typings}/replay/styles/inject-style.d.ts +0 -0
  123. package/{dist → typings}/replay/timer.d.ts +0 -0
  124. package/{dist → typings}/rrdom/index.d.ts +0 -0
  125. package/{dist → typings}/rrdom/tree-node.d.ts +0 -0
  126. package/{dist/plugins → typings}/types.d.ts +536 -509
  127. package/typings/utils.d.ts +43 -0
  128. package/CHANGELOG.md +0 -26
  129. package/README.md +0 -124
  130. package/README.zh_CN.md +0 -122
  131. package/dist/entries/all.d.ts +0 -4
  132. package/dist/index.css +0 -82
  133. package/dist/index.css.map +0 -1
  134. package/dist/index.js +0 -3
  135. package/dist/index.js.LICENSE.txt +0 -14
  136. package/dist/index.js.map +0 -1
  137. package/dist/plugins/entries/all.d.ts +0 -4
  138. package/dist/plugins/entries/record-pack.d.ts +0 -2
  139. package/dist/plugins/entries/replay-unpack.d.ts +0 -2
  140. package/dist/plugins/index.d.ts +0 -9
  141. package/dist/plugins/packer/base.d.ts +0 -7
  142. package/dist/plugins/packer/index.d.ts +0 -2
  143. package/dist/plugins/packer/pack.d.ts +0 -2
  144. package/dist/plugins/packer/unpack.d.ts +0 -2
  145. package/dist/plugins/plugins/console/record/error-stack-parser.d.ts +0 -37
  146. package/dist/plugins/plugins/console/record/index.d.ts +0 -41
  147. package/dist/plugins/plugins/console/record/stringify.d.ts +0 -2
  148. package/dist/plugins/plugins/console/replay/index.d.ts +0 -9
  149. package/dist/plugins/plugins/sequential-id/record/index.d.ts +0 -6
  150. package/dist/plugins/plugins/sequential-id/replay/index.d.ts +0 -7
  151. package/dist/plugins/record/iframe-manager.d.ts +0 -13
  152. package/dist/plugins/record/mutation.d.ts +0 -45
  153. package/dist/plugins/record/observer.d.ts +0 -11
  154. package/dist/plugins/record/observers/canvas/canvas-manager.d.ts +0 -32
  155. package/dist/plugins/record/observers/canvas/serialize-args.d.ts +0 -6
  156. package/dist/plugins/record/shadow-dom-manager.d.ts +0 -34
  157. package/dist/plugins/replay/canvas/2d.d.ts +0 -9
  158. package/dist/plugins/replay/canvas/webgl.d.ts +0 -11
  159. package/dist/plugins/replay/index.d.ts +0 -82
  160. package/dist/plugins/replay/machine.d.ts +0 -85
  161. package/dist/plugins/replay/smoothscroll.d.ts +0 -1
  162. package/dist/plugins/replay/styles/inject-style.d.ts +0 -2
  163. package/dist/plugins/replay/timer.d.ts +0 -19
  164. package/dist/plugins/replay/virtual-styles.d.ts +0 -43
  165. package/dist/plugins/rrdom/index.d.ts +0 -1
  166. package/dist/plugins/rrdom/tree-node.d.ts +0 -20
  167. package/dist/plugins/snapshot/css.d.ts +0 -92
  168. package/dist/plugins/snapshot/index.d.ts +0 -5
  169. package/dist/plugins/snapshot/rebuild.d.ts +0 -19
  170. package/dist/plugins/snapshot/snapshot.d.ts +0 -49
  171. package/dist/plugins/snapshot/types.d.ts +0 -99
  172. package/dist/plugins/snapshot/utils.d.ts +0 -11
  173. package/dist/plugins/utils.d.ts +0 -71
  174. package/dist/record/index.d.ts +0 -9
  175. package/dist/record/observer.d.ts +0 -11
  176. package/dist/record/observers/canvas/2d.d.ts +0 -2
  177. package/dist/record/observers/canvas/canvas.d.ts +0 -2
  178. package/dist/record/observers/canvas/serialize-args.d.ts +0 -6
  179. package/dist/record/observers/canvas/webgl.d.ts +0 -2
  180. package/dist/record/shadow-dom-manager.d.ts +0 -34
  181. package/dist/replay/canvas/index.d.ts +0 -9
  182. package/dist/replay/canvas/webgl.d.ts +0 -11
  183. package/dist/replay/virtual-styles.d.ts +0 -43
  184. package/dist/snapshot/css.d.ts +0 -92
  185. package/dist/snapshot/index.d.ts +0 -5
  186. package/dist/snapshot/rebuild.d.ts +0 -19
  187. package/dist/snapshot/snapshot.d.ts +0 -49
  188. package/dist/snapshot/types.d.ts +0 -99
  189. package/dist/snapshot/utils.d.ts +0 -11
  190. package/dist/types.d.ts +0 -509
  191. package/dist/utils.d.ts +0 -71
@@ -0,0 +1,356 @@
1
+ import { createMirror, snapshot } from '../../../rrweb-snapshot/es/rrweb-snapshot.js';
2
+ import { initObservers, mutationBuffers } from './observer.js';
3
+ import { polyfill, on, getWindowWidth, getWindowHeight, isSerializedIframe, hasShadowRoot } from '../utils.js';
4
+ import { EventType, IncrementalSource } from '../types.js';
5
+ import { IframeManager } from './iframe-manager.js';
6
+ import { ShadowDomManager } from './shadow-dom-manager.js';
7
+ import { CanvasManager } from './observers/canvas/canvas-manager.js';
8
+ import { StylesheetManager } from './stylesheet-manager.js';
9
+
10
+ function wrapEvent(e) {
11
+ return Object.assign(Object.assign({}, e), { timestamp: Date.now() });
12
+ }
13
+ let wrappedEmit;
14
+ let takeFullSnapshot;
15
+ const mirror = createMirror();
16
+ function record(options = {}) {
17
+ const { emit, checkoutEveryNms, checkoutEveryNth, blockClass = 'highlight-block', blockSelector = null, ignoreClass = 'highlight-ignore', maskTextClass = 'highlight-mask', maskTextSelector = null, inlineStylesheet = true, maskAllInputs, maskInputOptions: _maskInputOptions, slimDOMOptions: _slimDOMOptions, maskInputFn, maskTextFn, hooks, packFn, sampling = {}, mousemoveWait, recordCanvas = false, userTriggeredOnInput = false, collectFonts = false, inlineImages = false, plugins, keepIframeSrcFn = () => false, enableStrictPrivacy = false, } = options;
18
+ if (!emit) {
19
+ throw new Error('emit function is required');
20
+ }
21
+ if (mousemoveWait !== undefined && sampling.mousemove === undefined) {
22
+ sampling.mousemove = mousemoveWait;
23
+ }
24
+ mirror.reset();
25
+ const maskInputOptions = maskAllInputs === true
26
+ ? {
27
+ color: true,
28
+ date: true,
29
+ 'datetime-local': true,
30
+ email: true,
31
+ month: true,
32
+ number: true,
33
+ range: true,
34
+ search: true,
35
+ tel: true,
36
+ text: true,
37
+ time: true,
38
+ url: true,
39
+ week: true,
40
+ textarea: true,
41
+ select: true,
42
+ password: true,
43
+ }
44
+ : _maskInputOptions !== undefined
45
+ ? _maskInputOptions
46
+ : { password: true };
47
+ const slimDOMOptions = _slimDOMOptions === true || _slimDOMOptions === 'all'
48
+ ? {
49
+ script: true,
50
+ comment: true,
51
+ headFavicon: true,
52
+ headWhitespace: true,
53
+ headMetaSocial: true,
54
+ headMetaRobots: true,
55
+ headMetaHttpEquiv: true,
56
+ headMetaVerification: true,
57
+ headMetaAuthorship: _slimDOMOptions === 'all',
58
+ headMetaDescKeywords: _slimDOMOptions === 'all',
59
+ }
60
+ : _slimDOMOptions
61
+ ? _slimDOMOptions
62
+ : {};
63
+ polyfill();
64
+ let lastFullSnapshotEvent;
65
+ let incrementalSnapshotCount = 0;
66
+ const eventProcessor = (e) => {
67
+ for (const plugin of plugins || []) {
68
+ if (plugin.eventProcessor) {
69
+ e = plugin.eventProcessor(e);
70
+ }
71
+ }
72
+ if (packFn) {
73
+ e = packFn(e);
74
+ }
75
+ return e;
76
+ };
77
+ wrappedEmit = (e, isCheckout) => {
78
+ var _a;
79
+ if (((_a = mutationBuffers[0]) === null || _a === void 0 ? void 0 : _a.isFrozen()) &&
80
+ e.type !== EventType.FullSnapshot &&
81
+ !(e.type === EventType.IncrementalSnapshot &&
82
+ e.data.source === IncrementalSource.Mutation)) {
83
+ mutationBuffers.forEach((buf) => buf.unfreeze());
84
+ }
85
+ emit(eventProcessor(e), isCheckout);
86
+ if (e.type === EventType.FullSnapshot) {
87
+ lastFullSnapshotEvent = e;
88
+ incrementalSnapshotCount = 0;
89
+ }
90
+ else if (e.type === EventType.IncrementalSnapshot) {
91
+ if (e.data.source === IncrementalSource.Mutation &&
92
+ e.data.isAttachIframe) {
93
+ return;
94
+ }
95
+ incrementalSnapshotCount++;
96
+ const exceedCount = checkoutEveryNth && incrementalSnapshotCount >= checkoutEveryNth;
97
+ const exceedTime = checkoutEveryNms &&
98
+ e.timestamp - lastFullSnapshotEvent.timestamp > checkoutEveryNms;
99
+ if (exceedCount || exceedTime) {
100
+ takeFullSnapshot(true);
101
+ }
102
+ }
103
+ };
104
+ const wrappedMutationEmit = (m) => {
105
+ wrappedEmit(wrapEvent({
106
+ type: EventType.IncrementalSnapshot,
107
+ data: Object.assign({ source: IncrementalSource.Mutation }, m),
108
+ }));
109
+ };
110
+ const wrappedScrollEmit = (p) => wrappedEmit(wrapEvent({
111
+ type: EventType.IncrementalSnapshot,
112
+ data: Object.assign({ source: IncrementalSource.Scroll }, p),
113
+ }));
114
+ const wrappedCanvasMutationEmit = (p) => wrappedEmit(wrapEvent({
115
+ type: EventType.IncrementalSnapshot,
116
+ data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
117
+ }));
118
+ const iframeManager = new IframeManager({
119
+ mutationCb: wrappedMutationEmit,
120
+ });
121
+ const stylesheetManager = new StylesheetManager({
122
+ mutationCb: wrappedMutationEmit,
123
+ });
124
+ const canvasManager = new CanvasManager({
125
+ recordCanvas,
126
+ mutationCb: wrappedCanvasMutationEmit,
127
+ win: window,
128
+ blockClass,
129
+ mirror,
130
+ sampling: sampling.canvas,
131
+ });
132
+ const shadowDomManager = new ShadowDomManager({
133
+ mutationCb: wrappedMutationEmit,
134
+ scrollCb: wrappedScrollEmit,
135
+ bypassOptions: {
136
+ blockClass,
137
+ blockSelector,
138
+ maskTextClass,
139
+ maskTextSelector,
140
+ inlineStylesheet,
141
+ maskInputOptions,
142
+ maskTextFn,
143
+ maskInputFn,
144
+ recordCanvas,
145
+ inlineImages,
146
+ sampling,
147
+ slimDOMOptions,
148
+ iframeManager,
149
+ stylesheetManager,
150
+ canvasManager,
151
+ enableStrictPrivacy
152
+ },
153
+ mirror,
154
+ });
155
+ takeFullSnapshot = (isCheckout = false) => {
156
+ var _a, _b, _c, _d;
157
+ wrappedEmit(wrapEvent({
158
+ type: EventType.Meta,
159
+ data: {
160
+ href: window.location.href,
161
+ width: getWindowWidth(),
162
+ height: getWindowHeight(),
163
+ },
164
+ }), isCheckout);
165
+ mutationBuffers.forEach((buf) => buf.lock());
166
+ const node = snapshot(document, {
167
+ mirror,
168
+ blockClass,
169
+ blockSelector,
170
+ maskTextClass,
171
+ maskTextSelector,
172
+ inlineStylesheet,
173
+ maskAllInputs: maskInputOptions,
174
+ maskTextFn,
175
+ slimDOM: slimDOMOptions,
176
+ recordCanvas,
177
+ inlineImages,
178
+ enableStrictPrivacy,
179
+ onSerialize: (n) => {
180
+ if (isSerializedIframe(n, mirror)) {
181
+ iframeManager.addIframe(n);
182
+ }
183
+ if (hasShadowRoot(n)) {
184
+ shadowDomManager.addShadowRoot(n.shadowRoot, document);
185
+ }
186
+ },
187
+ onIframeLoad: (iframe, childSn) => {
188
+ iframeManager.attachIframe(iframe, childSn, mirror);
189
+ shadowDomManager.observeAttachShadow(iframe);
190
+ },
191
+ onStylesheetLoad: (linkEl, childSn) => {
192
+ this.stylesheetManager.attachStylesheet(linkEl, childSn, this.mirror);
193
+ },
194
+ keepIframeSrcFn,
195
+ });
196
+ if (!node) {
197
+ return console.warn('Failed to snapshot the document');
198
+ }
199
+ wrappedEmit(wrapEvent({
200
+ type: EventType.FullSnapshot,
201
+ data: {
202
+ node,
203
+ initialOffset: {
204
+ left: window.pageXOffset !== undefined
205
+ ? window.pageXOffset
206
+ : (document === null || document === void 0 ? void 0 : document.documentElement.scrollLeft) ||
207
+ ((_b = (_a = document === null || document === void 0 ? void 0 : document.body) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.scrollLeft) ||
208
+ (document === null || document === void 0 ? void 0 : document.body.scrollLeft) ||
209
+ 0,
210
+ top: window.pageYOffset !== undefined
211
+ ? window.pageYOffset
212
+ : (document === null || document === void 0 ? void 0 : document.documentElement.scrollTop) ||
213
+ ((_d = (_c = document === null || document === void 0 ? void 0 : document.body) === null || _c === void 0 ? void 0 : _c.parentElement) === null || _d === void 0 ? void 0 : _d.scrollTop) ||
214
+ (document === null || document === void 0 ? void 0 : document.body.scrollTop) ||
215
+ 0,
216
+ },
217
+ },
218
+ }));
219
+ mutationBuffers.forEach((buf) => buf.unlock());
220
+ };
221
+ try {
222
+ const handlers = [];
223
+ handlers.push(on('DOMContentLoaded', () => {
224
+ wrappedEmit(wrapEvent({
225
+ type: EventType.DomContentLoaded,
226
+ data: {},
227
+ }));
228
+ }));
229
+ const observe = (doc) => {
230
+ var _a;
231
+ return initObservers({
232
+ mutationCb: wrappedMutationEmit,
233
+ mousemoveCb: (positions, source) => wrappedEmit(wrapEvent({
234
+ type: EventType.IncrementalSnapshot,
235
+ data: {
236
+ source,
237
+ positions,
238
+ },
239
+ })),
240
+ mouseInteractionCb: (d) => wrappedEmit(wrapEvent({
241
+ type: EventType.IncrementalSnapshot,
242
+ data: Object.assign({ source: IncrementalSource.MouseInteraction }, d),
243
+ })),
244
+ scrollCb: wrappedScrollEmit,
245
+ viewportResizeCb: (d) => wrappedEmit(wrapEvent({
246
+ type: EventType.IncrementalSnapshot,
247
+ data: Object.assign({ source: IncrementalSource.ViewportResize }, d),
248
+ })),
249
+ inputCb: (v) => wrappedEmit(wrapEvent({
250
+ type: EventType.IncrementalSnapshot,
251
+ data: Object.assign({ source: IncrementalSource.Input }, v),
252
+ })),
253
+ mediaInteractionCb: (p) => wrappedEmit(wrapEvent({
254
+ type: EventType.IncrementalSnapshot,
255
+ data: Object.assign({ source: IncrementalSource.MediaInteraction }, p),
256
+ })),
257
+ styleSheetRuleCb: (r) => wrappedEmit(wrapEvent({
258
+ type: EventType.IncrementalSnapshot,
259
+ data: Object.assign({ source: IncrementalSource.StyleSheetRule }, r),
260
+ })),
261
+ styleDeclarationCb: (r) => wrappedEmit(wrapEvent({
262
+ type: EventType.IncrementalSnapshot,
263
+ data: Object.assign({ source: IncrementalSource.StyleDeclaration }, r),
264
+ })),
265
+ canvasMutationCb: wrappedCanvasMutationEmit,
266
+ fontCb: (p) => wrappedEmit(wrapEvent({
267
+ type: EventType.IncrementalSnapshot,
268
+ data: Object.assign({ source: IncrementalSource.Font }, p),
269
+ })),
270
+ blockClass,
271
+ ignoreClass,
272
+ maskTextClass,
273
+ maskTextSelector,
274
+ maskInputOptions,
275
+ inlineStylesheet,
276
+ sampling,
277
+ recordCanvas,
278
+ inlineImages,
279
+ userTriggeredOnInput,
280
+ collectFonts,
281
+ doc,
282
+ maskInputFn,
283
+ maskTextFn,
284
+ blockSelector,
285
+ slimDOMOptions,
286
+ mirror,
287
+ iframeManager,
288
+ stylesheetManager,
289
+ shadowDomManager,
290
+ canvasManager,
291
+ enableStrictPrivacy,
292
+ plugins: ((_a = plugins === null || plugins === void 0 ? void 0 : plugins.filter((p) => p.observer)) === null || _a === void 0 ? void 0 : _a.map((p) => ({
293
+ observer: p.observer,
294
+ options: p.options,
295
+ callback: (payload) => wrappedEmit(wrapEvent({
296
+ type: EventType.Plugin,
297
+ data: {
298
+ plugin: p.name,
299
+ payload,
300
+ },
301
+ })),
302
+ }))) || [],
303
+ }, hooks);
304
+ };
305
+ iframeManager.addLoadListener((iframeEl) => {
306
+ handlers.push(observe(iframeEl.contentDocument));
307
+ });
308
+ const init = () => {
309
+ takeFullSnapshot();
310
+ handlers.push(observe(document));
311
+ };
312
+ if (document.readyState === 'interactive' ||
313
+ document.readyState === 'complete') {
314
+ init();
315
+ }
316
+ else {
317
+ handlers.push(on('load', () => {
318
+ wrappedEmit(wrapEvent({
319
+ type: EventType.Load,
320
+ data: {},
321
+ }));
322
+ init();
323
+ }, window));
324
+ }
325
+ return () => {
326
+ handlers.forEach((h) => h());
327
+ };
328
+ }
329
+ catch (error) {
330
+ console.warn(error);
331
+ }
332
+ }
333
+ record.addCustomEvent = (tag, payload) => {
334
+ if (!wrappedEmit) {
335
+ return;
336
+ }
337
+ wrappedEmit(wrapEvent({
338
+ type: EventType.Custom,
339
+ data: {
340
+ tag,
341
+ payload,
342
+ },
343
+ }));
344
+ };
345
+ record.freezePage = () => {
346
+ mutationBuffers.forEach((buf) => buf.freeze());
347
+ };
348
+ record.takeFullSnapshot = (isCheckout) => {
349
+ if (!takeFullSnapshot) {
350
+ throw new Error('please take full snapshot after start recording');
351
+ }
352
+ takeFullSnapshot(isCheckout);
353
+ };
354
+ record.mirror = mirror;
355
+
356
+ export { record as default };