@sitelint/webrewind 0.0.0-stage → 0.0.1
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.
- package/README.md +65 -2
- package/dist/.test-helpers/setup.d.ts +2 -0
- package/dist/.test-helpers/setup.d.ts.map +1 -0
- package/dist/.test-helpers/setup.js +86 -0
- package/dist/.test-helpers/setup.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/record.d.ts +5 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +232 -0
- package/dist/record.js.map +1 -0
- package/dist/record.test.d.ts +2 -0
- package/dist/record.test.d.ts.map +1 -0
- package/dist/record.test.js +88 -0
- package/dist/record.test.js.map +1 -0
- package/dist/replay.d.ts +22 -0
- package/dist/replay.d.ts.map +1 -0
- package/dist/replay.js +202 -0
- package/dist/replay.js.map +1 -0
- package/dist/replay.test.d.ts +2 -0
- package/dist/replay.test.d.ts.map +1 -0
- package/dist/replay.test.js +128 -0
- package/dist/replay.test.js.map +1 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +32 -0
- package/dist/types.js.map +1 -0
- package/dist/types.test.d.ts +2 -0
- package/dist/types.test.d.ts.map +1 -0
- package/dist/types.test.js +46 -0
- package/dist/types.test.js.map +1 -0
- package/package.json +67 -4
package/README.md
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sitelint/webrewind
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Independent record-and-replay library for the web. Captures DOM mutations and user interactions into a compact JSON event stream, then replays them in a viewer for session replay and bug reproduction.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @sitelint/webrewind
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Record (in the page being audited)
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { record } from '@sitelint/webrewind';
|
|
17
|
+
|
|
18
|
+
const stop = record({
|
|
19
|
+
emit: (event) => {
|
|
20
|
+
// send event to your ring buffer / issue store
|
|
21
|
+
console.log(event.type, event.timestamp, event.data);
|
|
22
|
+
},
|
|
23
|
+
recordDOM: true,
|
|
24
|
+
sampling: { mousemove: 100, scroll: 150, input: 'last' }
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// later: stop recording
|
|
28
|
+
stop();
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Replay (in the issue detail viewer)
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { Replayer } from '@sitelint/webrewind';
|
|
35
|
+
|
|
36
|
+
const replayer = new Replayer(events, {
|
|
37
|
+
root: document.querySelector('#replayContainer'),
|
|
38
|
+
speed: 1,
|
|
39
|
+
showWarning: false,
|
|
40
|
+
showDebug: false,
|
|
41
|
+
blockClass: 'auditor-block'
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
replayer.play();
|
|
45
|
+
replayer.destroy(); // cleanup
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### `record(options)`
|
|
51
|
+
|
|
52
|
+
Starts recording. Returns `stopRecording(): void`.
|
|
53
|
+
|
|
54
|
+
### `class Replayer`
|
|
55
|
+
|
|
56
|
+
- `constructor(events: eventWithTime[], config: ReplayerConfig)`
|
|
57
|
+
- `play(): void`
|
|
58
|
+
- `pause(): void`
|
|
59
|
+
- `resume(): void`
|
|
60
|
+
- `destroy(): void`
|
|
61
|
+
- `isPlaying(): boolean`
|
|
62
|
+
- `wrapper: HTMLElement`
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MPL-2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/.test-helpers/setup.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { JSDOM } from 'jsdom';
|
|
2
|
+
const dom = new JSDOM('', {
|
|
3
|
+
contentType: 'text/html',
|
|
4
|
+
url: 'https://localhost/'
|
|
5
|
+
});
|
|
6
|
+
const domWindow = dom.window;
|
|
7
|
+
Object.defineProperty(globalThis, 'window', {
|
|
8
|
+
configurable: true,
|
|
9
|
+
value: domWindow,
|
|
10
|
+
writable: true
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(globalThis, 'document', {
|
|
13
|
+
configurable: true,
|
|
14
|
+
value: domWindow.document,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(globalThis, 'addEventListener', {
|
|
18
|
+
configurable: true,
|
|
19
|
+
value: domWindow.addEventListener.bind(domWindow),
|
|
20
|
+
writable: true
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(globalThis, 'removeEventListener', {
|
|
23
|
+
configurable: true,
|
|
24
|
+
value: domWindow.removeEventListener.bind(domWindow),
|
|
25
|
+
writable: true
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(globalThis, 'dispatchEvent', {
|
|
28
|
+
configurable: true,
|
|
29
|
+
value: domWindow.dispatchEvent.bind(domWindow),
|
|
30
|
+
writable: true
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(globalThis, 'Event', {
|
|
33
|
+
configurable: true,
|
|
34
|
+
value: domWindow.Event,
|
|
35
|
+
writable: true
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(globalThis, 'MutationObserver', {
|
|
38
|
+
configurable: true,
|
|
39
|
+
value: domWindow.MutationObserver,
|
|
40
|
+
writable: true
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(globalThis, 'requestAnimationFrame', {
|
|
43
|
+
configurable: true,
|
|
44
|
+
value: (cb) => {
|
|
45
|
+
return globalThis.setTimeout(() => cb(0), 0);
|
|
46
|
+
},
|
|
47
|
+
writable: true
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(globalThis, 'cancelAnimationFrame', {
|
|
50
|
+
configurable: true,
|
|
51
|
+
value: (id) => {
|
|
52
|
+
globalThis.clearTimeout(id);
|
|
53
|
+
},
|
|
54
|
+
writable: true
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(globalThis, 'HTMLElement', {
|
|
57
|
+
configurable: true,
|
|
58
|
+
value: domWindow.HTMLElement,
|
|
59
|
+
writable: true
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(globalThis, 'Element', {
|
|
62
|
+
configurable: true,
|
|
63
|
+
value: domWindow.Element,
|
|
64
|
+
writable: true
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(globalThis, 'HTMLInputElement', {
|
|
67
|
+
configurable: true,
|
|
68
|
+
value: domWindow.HTMLInputElement,
|
|
69
|
+
writable: true
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(globalThis, 'location', {
|
|
72
|
+
configurable: true,
|
|
73
|
+
value: domWindow.location,
|
|
74
|
+
writable: true
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(globalThis, 'Node', {
|
|
77
|
+
configurable: true,
|
|
78
|
+
value: domWindow.Node,
|
|
79
|
+
writable: true
|
|
80
|
+
});
|
|
81
|
+
Object.defineProperty(globalThis, 'DOMRect', {
|
|
82
|
+
configurable: true,
|
|
83
|
+
value: domWindow.DOMRect,
|
|
84
|
+
writable: true
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/.test-helpers/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,OAAO,CAAC;AAE9C,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE;IACxB,WAAW,EAAE,WAAW;IACxB,GAAG,EAAE,oBAAoB;CAC1B,CAAC,CAAC;AAEH,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AClB,KAAK,EAAE,SAAS,CAAC,IAAI;IACrB,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE;IAC3C,YAAY,EAAE,IAAI;IAClB,KAAK,EAAE,SAAS,CAAC,OAAO;IACxB,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/record.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,aAAa,EAAoB,MAAM,SAAS,CAAC;AAqG9E,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,SAAS,CAsL/E"}
|
package/dist/record.js
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { EventType, IncrementalSource } from './types';
|
|
2
|
+
const START_TIME = globalThis.Date.now();
|
|
3
|
+
const MAX_BUFFER_EVENTS = 5000;
|
|
4
|
+
const _MOUSEMOVE_THROTTLE_MS = 100;
|
|
5
|
+
const SCROLL_THROTTLE_MS = 150;
|
|
6
|
+
function getRelativeTime() {
|
|
7
|
+
return globalThis.Date.now() - START_TIME;
|
|
8
|
+
}
|
|
9
|
+
function createEvent(type, data) {
|
|
10
|
+
return {
|
|
11
|
+
data,
|
|
12
|
+
timestamp: getRelativeTime(),
|
|
13
|
+
type
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function buildCssSelector(target) {
|
|
17
|
+
if (target === null || !(target instanceof Element)) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
const parts = [];
|
|
21
|
+
let current = target;
|
|
22
|
+
while (current !== null && current.nodeType === globalThis.Node.ELEMENT_NODE) {
|
|
23
|
+
let selector = current.tagName.toLowerCase();
|
|
24
|
+
if (current.id) {
|
|
25
|
+
selector += `#${current.id}`;
|
|
26
|
+
}
|
|
27
|
+
const classes = Array.from(current.classList ?? []);
|
|
28
|
+
if (classes.length > 0) {
|
|
29
|
+
selector += `.${classes.join('.')}`;
|
|
30
|
+
}
|
|
31
|
+
parts.push(selector);
|
|
32
|
+
current = current.parentElement;
|
|
33
|
+
}
|
|
34
|
+
return parts.join(' > ');
|
|
35
|
+
}
|
|
36
|
+
function getAccessibleName(target) {
|
|
37
|
+
const ariaLabel = target.getAttribute('aria-label');
|
|
38
|
+
if (ariaLabel !== null && ariaLabel.length > 0) {
|
|
39
|
+
return ariaLabel;
|
|
40
|
+
}
|
|
41
|
+
const ariaLabelledby = target.getAttribute('aria-labelledby');
|
|
42
|
+
if (ariaLabelledby !== null) {
|
|
43
|
+
const labelledElement = globalThis.document.getElementById(ariaLabelledby);
|
|
44
|
+
if (labelledElement !== null) {
|
|
45
|
+
const text = labelledElement.textContent ?? '';
|
|
46
|
+
if (text.length > 0) {
|
|
47
|
+
return text.trim();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const textContent = target.textContent;
|
|
52
|
+
if (textContent !== null && textContent.trim().length > 0) {
|
|
53
|
+
return textContent.trim().slice(0, 80);
|
|
54
|
+
}
|
|
55
|
+
return target.tagName.toLowerCase();
|
|
56
|
+
}
|
|
57
|
+
function isSensitiveInput(target) {
|
|
58
|
+
if (target.tagName !== 'INPUT') {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
const input = target;
|
|
62
|
+
const type = (input.type ?? 'text').toLowerCase();
|
|
63
|
+
return type === 'password' || type === 'search';
|
|
64
|
+
}
|
|
65
|
+
function captureFullSnapshot() {
|
|
66
|
+
return {
|
|
67
|
+
html: globalThis.document.documentElement.outerHTML,
|
|
68
|
+
title: globalThis.document.title,
|
|
69
|
+
url: globalThis.location.href,
|
|
70
|
+
viewport: {
|
|
71
|
+
height: globalThis.innerHeight,
|
|
72
|
+
width: globalThis.innerWidth
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function record(options) {
|
|
77
|
+
const emit = options.emit;
|
|
78
|
+
const recordDOM = options.recordDOM ?? true;
|
|
79
|
+
const _sampling = options.sampling ?? {};
|
|
80
|
+
const events = [];
|
|
81
|
+
let isRecording = true;
|
|
82
|
+
const _lastMouseMoveTime = 0;
|
|
83
|
+
let lastScrollTime = 0;
|
|
84
|
+
let mutationObserver = null;
|
|
85
|
+
let clickListener = null;
|
|
86
|
+
let keydownListener = null;
|
|
87
|
+
let scrollListener = null;
|
|
88
|
+
let visibilityListener = null;
|
|
89
|
+
let popStateListener = null;
|
|
90
|
+
function emitEvent(event) {
|
|
91
|
+
if (isRecording === false) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
events.push(event);
|
|
95
|
+
if (events.length > MAX_BUFFER_EVENTS) {
|
|
96
|
+
events.shift();
|
|
97
|
+
}
|
|
98
|
+
emit(event);
|
|
99
|
+
}
|
|
100
|
+
function observeMutations() {
|
|
101
|
+
if (mutationObserver !== null) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
mutationObserver = new globalThis.MutationObserver((mutations) => {
|
|
105
|
+
if (isRecording === false) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
for (const mutation of mutations) {
|
|
109
|
+
emitEvent(createEvent(EventType.IncrementalSnapshot, {
|
|
110
|
+
attributeName: mutation.attributeName,
|
|
111
|
+
mutationType: mutation.type,
|
|
112
|
+
oldValue: mutation.oldValue,
|
|
113
|
+
source: IncrementalSource.MouseMove,
|
|
114
|
+
target: buildCssSelector(mutation.target)
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
try {
|
|
119
|
+
mutationObserver.observe(globalThis.document.documentElement, {
|
|
120
|
+
attributes: true,
|
|
121
|
+
childList: true,
|
|
122
|
+
subtree: true,
|
|
123
|
+
characterData: true
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
console.error('[webrewind.record] MutationObserver failed', error);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function stopObservers() {
|
|
131
|
+
if (mutationObserver !== null) {
|
|
132
|
+
mutationObserver.disconnect();
|
|
133
|
+
mutationObserver = null;
|
|
134
|
+
}
|
|
135
|
+
if (clickListener !== null && globalThis.document !== null) {
|
|
136
|
+
globalThis.document.removeEventListener('click', clickListener, true);
|
|
137
|
+
clickListener = null;
|
|
138
|
+
}
|
|
139
|
+
if (keydownListener !== null && globalThis.document !== null) {
|
|
140
|
+
globalThis.document.removeEventListener('keydown', keydownListener, true);
|
|
141
|
+
keydownListener = null;
|
|
142
|
+
}
|
|
143
|
+
if (scrollListener !== null) {
|
|
144
|
+
globalThis.removeEventListener('scroll', scrollListener, true);
|
|
145
|
+
scrollListener = null;
|
|
146
|
+
}
|
|
147
|
+
if (visibilityListener !== null) {
|
|
148
|
+
globalThis.removeEventListener('visibilitychange', visibilityListener);
|
|
149
|
+
visibilityListener = null;
|
|
150
|
+
}
|
|
151
|
+
if (popStateListener !== null) {
|
|
152
|
+
globalThis.removeEventListener('popstate', popStateListener);
|
|
153
|
+
popStateListener = null;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
clickListener = (event) => {
|
|
157
|
+
if (isRecording === false || ((event.target instanceof Element) === false)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
emitEvent(createEvent(EventType.IncrementalSnapshot, {
|
|
161
|
+
clientX: event.clientX,
|
|
162
|
+
clientY: event.clientY,
|
|
163
|
+
isSensitive: isSensitiveInput(event.target),
|
|
164
|
+
label: getAccessibleName(event.target),
|
|
165
|
+
source: IncrementalSource.MouseInteraction,
|
|
166
|
+
target: buildCssSelector(event.target),
|
|
167
|
+
type: 'click'
|
|
168
|
+
}));
|
|
169
|
+
};
|
|
170
|
+
keydownListener = (event) => {
|
|
171
|
+
if (isRecording === false || ((event.target instanceof Element) === false)) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
emitEvent(createEvent(EventType.IncrementalSnapshot, {
|
|
175
|
+
isSensitive: isSensitiveInput(event.target),
|
|
176
|
+
key: event.key,
|
|
177
|
+
source: IncrementalSource.Input,
|
|
178
|
+
target: buildCssSelector(event.target),
|
|
179
|
+
type: 'keydown'
|
|
180
|
+
}));
|
|
181
|
+
};
|
|
182
|
+
scrollListener = () => {
|
|
183
|
+
const now = globalThis.Date.now();
|
|
184
|
+
if (isRecording === false || now - lastScrollTime < SCROLL_THROTTLE_MS) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
lastScrollTime = now;
|
|
188
|
+
emitEvent(createEvent(EventType.IncrementalSnapshot, {
|
|
189
|
+
scrollX: globalThis.scrollX,
|
|
190
|
+
scrollY: globalThis.scrollY,
|
|
191
|
+
source: IncrementalSource.Scroll,
|
|
192
|
+
target: buildCssSelector(globalThis.document.scrollingElement)
|
|
193
|
+
}));
|
|
194
|
+
};
|
|
195
|
+
visibilityListener = () => {
|
|
196
|
+
emitEvent(createEvent(EventType.IncrementalSnapshot, {
|
|
197
|
+
source: IncrementalSource.MouseInteraction,
|
|
198
|
+
type: 'visibilitychange',
|
|
199
|
+
visibilityState: globalThis.document.visibilityState
|
|
200
|
+
}));
|
|
201
|
+
};
|
|
202
|
+
popStateListener = () => {
|
|
203
|
+
emitEvent(createEvent(EventType.IncrementalSnapshot, {
|
|
204
|
+
source: IncrementalSource.MouseInteraction,
|
|
205
|
+
type: 'popstate',
|
|
206
|
+
url: globalThis.location.href
|
|
207
|
+
}));
|
|
208
|
+
};
|
|
209
|
+
try {
|
|
210
|
+
globalThis.document.addEventListener('click', clickListener, true);
|
|
211
|
+
globalThis.document.addEventListener('keydown', keydownListener, true);
|
|
212
|
+
globalThis.addEventListener('scroll', scrollListener, true);
|
|
213
|
+
globalThis.addEventListener('visibilitychange', visibilityListener);
|
|
214
|
+
globalThis.addEventListener('popstate', popStateListener);
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
console.error('[webrewind.record] Failed to attach event listeners', error);
|
|
218
|
+
stopObservers();
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
observeMutations();
|
|
222
|
+
if (recordDOM) {
|
|
223
|
+
emitEvent(createEvent(EventType.FullSnapshot, captureFullSnapshot()));
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
stop: () => {
|
|
227
|
+
isRecording = false;
|
|
228
|
+
stopObservers();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEvD,MAAM,UAAU,GAAW,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;AACjD,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,EAAE,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.test.d.ts","sourceRoot":"","sources":["../src/record.test.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { record } from './index';
|
|
2
|
+
import './.test-helpers/setup';
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
describe('record', () => {
|
|
6
|
+
it('returns an object with a stop function', () => {
|
|
7
|
+
const events = [];
|
|
8
|
+
const result = record({
|
|
9
|
+
emit: (event) => {
|
|
10
|
+
events.push(event);
|
|
11
|
+
},
|
|
12
|
+
recordDOM: true
|
|
13
|
+
});
|
|
14
|
+
assert.ok(result !== undefined);
|
|
15
|
+
assert.ok(typeof result.stop === 'function');
|
|
16
|
+
result.stop();
|
|
17
|
+
});
|
|
18
|
+
it('emits a FullSnapshot event when recordDOM is true', () => {
|
|
19
|
+
const events = [];
|
|
20
|
+
const result = record({
|
|
21
|
+
emit: (event) => {
|
|
22
|
+
events.push(event);
|
|
23
|
+
},
|
|
24
|
+
recordDOM: true
|
|
25
|
+
});
|
|
26
|
+
assert.ok(result !== undefined);
|
|
27
|
+
result.stop();
|
|
28
|
+
assert.ok(events.length > 0);
|
|
29
|
+
assert.strictEqual(events[0].type, 2); // EventType.FullSnapshot
|
|
30
|
+
});
|
|
31
|
+
it('stops emitting events after stop() is called', () => {
|
|
32
|
+
const events = [];
|
|
33
|
+
const result = record({
|
|
34
|
+
emit: (event) => {
|
|
35
|
+
events.push(event);
|
|
36
|
+
},
|
|
37
|
+
recordDOM: false
|
|
38
|
+
});
|
|
39
|
+
const countBeforeStop = events.length;
|
|
40
|
+
result.stop();
|
|
41
|
+
// Clicking after stop should not add events
|
|
42
|
+
const clickEvent = new globalThis.Event('click');
|
|
43
|
+
globalThis.document.dispatchEvent(clickEvent);
|
|
44
|
+
assert.strictEqual(events.length, countBeforeStop);
|
|
45
|
+
});
|
|
46
|
+
it('accepts sampling options without throwing', () => {
|
|
47
|
+
assert.doesNotThrow(() => {
|
|
48
|
+
const result = record({
|
|
49
|
+
emit: () => {
|
|
50
|
+
// noop
|
|
51
|
+
},
|
|
52
|
+
recordDOM: false,
|
|
53
|
+
sampling: {
|
|
54
|
+
mousemove: 100,
|
|
55
|
+
scroll: 150,
|
|
56
|
+
input: 'last'
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
assert.ok(result !== undefined);
|
|
60
|
+
result.stop();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
it('emits events with timestamp and data', () => {
|
|
64
|
+
const events = [];
|
|
65
|
+
const result = record({
|
|
66
|
+
emit: (event) => {
|
|
67
|
+
events.push(event);
|
|
68
|
+
},
|
|
69
|
+
recordDOM: false
|
|
70
|
+
});
|
|
71
|
+
// Dispatch a click to generate an event
|
|
72
|
+
const clickEvent = new globalThis.Event('click');
|
|
73
|
+
Object.defineProperty(clickEvent, 'target', {
|
|
74
|
+
value: globalThis.document.body,
|
|
75
|
+
configurable: true
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(clickEvent, 'clientX', { value: 100, configurable: true });
|
|
78
|
+
Object.defineProperty(clickEvent, 'clientY', { value: 200, configurable: true });
|
|
79
|
+
globalThis.document.dispatchEvent(clickEvent);
|
|
80
|
+
result.stop();
|
|
81
|
+
assert.ok(events.length > 0);
|
|
82
|
+
for (const event of events) {
|
|
83
|
+
assert.ok(typeof event.timestamp === 'number');
|
|
84
|
+
assert.ok(event.data !== undefined);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
//# sourceMappingURL=record.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.test.js","sourceRoot":"","sources":["../src/record.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,SAAS,C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AK,CAAC,CAAC;YACrB,CAAC;YACD,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;QAEH,wCAAwC;QACxC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,QAAQ,EAAE;YAC1C,KAAK,EAAE,UAAU,CAAC,QAAQ,CAAC,IAAI;YAC/B,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;QACH,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QACjF,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QACjF,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAE9C,MAAO,CAAC,IAAI,EAAE,CAAC;QAEf,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAE7B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,EAAE,CAAC,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC;YAC/C,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/replay.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { eventWithTime, playerConfig, ReplayerEventName, ReplayerEventHandler } from './types';
|
|
2
|
+
export declare class Replayer {
|
|
3
|
+
private events;
|
|
4
|
+
private config;
|
|
5
|
+
private isPlayingValue;
|
|
6
|
+
private animationFrameId;
|
|
7
|
+
private startTime;
|
|
8
|
+
private eventIndex;
|
|
9
|
+
private eventListeners;
|
|
10
|
+
wrapper: HTMLElement;
|
|
11
|
+
constructor(events: Array<eventWithTime | string>, config: Partial<playerConfig>);
|
|
12
|
+
private emit;
|
|
13
|
+
private tick;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
isPlaying(): boolean;
|
|
16
|
+
off<T extends ReplayerEventName>(event: T, handler: ReplayerEventHandler<T>): this;
|
|
17
|
+
on<T extends ReplayerEventName>(event: T, handler: ReplayerEventHandler<T>): this;
|
|
18
|
+
pause(_timeOffset?: number): void;
|
|
19
|
+
play(timeOffset?: number): void;
|
|
20
|
+
resume(_timeOffset?: number): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAkB,MAAM,SAAS,CAAC;AA4FpH,qBAAa,QAAQ;IACnB,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,cAAc,CAAU;IAChC,OAAO,CAAC,gBAAgB,CAA6D;IACrF,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,cAAc,CAA4D;IAC3E,OAAO,EAAE,WAAW,CAAC;IAE5B,YAAY,MAAM,EAAE,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,EAmB/E;IAED,OAAO,CAAC,IAAI;IAeZ,OAAO,CAAC,IAAI;IA8BL,OAAO,IAAI,IAAI,CASrB;IAEM,SAAS,IAAI,OAAO,CAE1B;IAEM,GAAG,CAAC,CAAC,SAAS,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI,CASxF;IAEM,EAAE,CAAC,CAAC,SAAS,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI,CAYvF;IAEM,KAAK,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAavC;IAEM,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAcrC;IAEM,MAAM,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAaxC;CACF"}
|
package/dist/replay.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
function createWrapperElement() {
|
|
2
|
+
const wrapper = globalThis.document.createElement('div');
|
|
3
|
+
wrapper.style.position = 'relative';
|
|
4
|
+
wrapper.style.width = '100%';
|
|
5
|
+
wrapper.style.height = '100%';
|
|
6
|
+
wrapper.style.overflow = 'auto';
|
|
7
|
+
wrapper.style.backgroundColor = '#ffffff';
|
|
8
|
+
wrapper.style.fontFamily = 'system-ui, -apple-system, sans-serif';
|
|
9
|
+
wrapper.style.fontSize = '14px';
|
|
10
|
+
wrapper.style.lineHeight = '1.5';
|
|
11
|
+
return wrapper;
|
|
12
|
+
}
|
|
13
|
+
function applyIncrementalEvent(wrapper, event) {
|
|
14
|
+
const data = event.data;
|
|
15
|
+
if (data === null || typeof data !== 'object') {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const recordData = data;
|
|
19
|
+
if (recordData.type === 'click' && recordData.target) {
|
|
20
|
+
const selector = recordData.target;
|
|
21
|
+
if (typeof selector !== 'string') {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const element = wrapper.querySelector(selector);
|
|
25
|
+
if (element !== null) {
|
|
26
|
+
const clickIndicator = globalThis.document.createElement('div');
|
|
27
|
+
clickIndicator.textContent = `👆 ${recordData.label ?? 'click'}`;
|
|
28
|
+
clickIndicator.style.position = 'absolute';
|
|
29
|
+
clickIndicator.style.backgroundColor = 'rgba(255, 165, 0, 0.3)';
|
|
30
|
+
clickIndicator.style.border = '2px solid #ffa500';
|
|
31
|
+
clickIndicator.style.borderRadius = '4px';
|
|
32
|
+
clickIndicator.style.padding = '2px 6px';
|
|
33
|
+
clickIndicator.style.fontSize = '12px';
|
|
34
|
+
clickIndicator.style.zIndex = '10000';
|
|
35
|
+
clickIndicator.style.left = `${Number(recordData.clientX ?? 0)}px`;
|
|
36
|
+
clickIndicator.style.top = `${Number(recordData.clientY ?? 0)}px`;
|
|
37
|
+
clickIndicator.style.transform = 'translate(-50%, -50%)';
|
|
38
|
+
const rect = element.getBoundingClientRect();
|
|
39
|
+
const wrapperRect = wrapper.getBoundingClientRect();
|
|
40
|
+
if (rect !== null) {
|
|
41
|
+
clickIndicator.style.left = `${rect.left - wrapperRect.left + rect.width / 2}px`;
|
|
42
|
+
clickIndicator.style.top = `${rect.top - wrapperRect.top + rect.height / 2}px`;
|
|
43
|
+
}
|
|
44
|
+
wrapper.appendChild(clickIndicator);
|
|
45
|
+
globalThis.setTimeout(() => {
|
|
46
|
+
clickIndicator.remove();
|
|
47
|
+
}, 1500);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (recordData.type === 'visibilitychange') {
|
|
51
|
+
const state = recordData.visibilityState;
|
|
52
|
+
if (typeof state === 'string') {
|
|
53
|
+
const indicator = globalThis.document.createElement('div');
|
|
54
|
+
indicator.textContent = `👁️ visibility: ${state}`;
|
|
55
|
+
indicator.style.position = 'absolute';
|
|
56
|
+
indicator.style.backgroundColor = 'rgba(100, 100, 255, 0.3)';
|
|
57
|
+
indicator.style.border = '1px solid #6464ff';
|
|
58
|
+
indicator.style.borderRadius = '4px';
|
|
59
|
+
indicator.style.padding = '4px 8px';
|
|
60
|
+
indicator.style.fontSize = '12px';
|
|
61
|
+
indicator.style.zIndex = '10000';
|
|
62
|
+
indicator.style.top = '8px';
|
|
63
|
+
indicator.style.right = '8px';
|
|
64
|
+
wrapper.appendChild(indicator);
|
|
65
|
+
globalThis.setTimeout(() => {
|
|
66
|
+
indicator.remove();
|
|
67
|
+
}, 2000);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export class Replayer {
|
|
72
|
+
events;
|
|
73
|
+
config;
|
|
74
|
+
isPlayingValue;
|
|
75
|
+
animationFrameId;
|
|
76
|
+
startTime;
|
|
77
|
+
eventIndex;
|
|
78
|
+
eventListeners;
|
|
79
|
+
wrapper;
|
|
80
|
+
constructor(events, config) {
|
|
81
|
+
const defaultConfig = {
|
|
82
|
+
blockClass: 'auditor-block',
|
|
83
|
+
root: globalThis.document.body,
|
|
84
|
+
showDebug: false,
|
|
85
|
+
showWarning: false,
|
|
86
|
+
speed: 1
|
|
87
|
+
};
|
|
88
|
+
this.events = events.filter((e) => typeof e === 'object' && e !== null && 'type' in e && 'timestamp' in e);
|
|
89
|
+
this.config = { ...defaultConfig, ...config };
|
|
90
|
+
this.isPlayingValue = false;
|
|
91
|
+
this.animationFrameId = null;
|
|
92
|
+
this.startTime = 0;
|
|
93
|
+
this.eventIndex = 0;
|
|
94
|
+
this.eventListeners = new Map();
|
|
95
|
+
this.wrapper = createWrapperElement();
|
|
96
|
+
this.config.root.appendChild(this.wrapper);
|
|
97
|
+
}
|
|
98
|
+
emit(event, payload) {
|
|
99
|
+
const key = event;
|
|
100
|
+
const handlers = this.eventListeners.get(key);
|
|
101
|
+
if (handlers !== undefined) {
|
|
102
|
+
for (const handler of handlers) {
|
|
103
|
+
try {
|
|
104
|
+
handler(payload);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.error('[webrewind.Replayer] Event handler error', error);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
tick() {
|
|
113
|
+
if (!this.isPlayingValue) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const now = globalThis.Date.now();
|
|
117
|
+
const elapsed = (now - this.startTime) * this.config.speed;
|
|
118
|
+
while (this.eventIndex < this.events.length && this.events[this.eventIndex].timestamp <= elapsed) {
|
|
119
|
+
const event = this.events[this.eventIndex];
|
|
120
|
+
try {
|
|
121
|
+
applyIncrementalEvent(this.wrapper, event);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error('[webrewind.Replayer] Failed to apply event', error);
|
|
125
|
+
}
|
|
126
|
+
this.eventIndex += 1;
|
|
127
|
+
}
|
|
128
|
+
if (this.eventIndex < this.events.length) {
|
|
129
|
+
this.animationFrameId = globalThis.requestAnimationFrame(() => {
|
|
130
|
+
this.tick();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
this.isPlayingValue = false;
|
|
135
|
+
this.emit('finish', undefined);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
destroy() {
|
|
139
|
+
this.pause();
|
|
140
|
+
if (this.wrapper.parentElement !== null) {
|
|
141
|
+
this.wrapper.parentElement.removeChild(this.wrapper);
|
|
142
|
+
}
|
|
143
|
+
this.eventListeners.clear();
|
|
144
|
+
this.events = [];
|
|
145
|
+
}
|
|
146
|
+
isPlaying() {
|
|
147
|
+
return this.isPlayingValue;
|
|
148
|
+
}
|
|
149
|
+
off(event, handler) {
|
|
150
|
+
const key = event;
|
|
151
|
+
const handlers = this.eventListeners.get(key);
|
|
152
|
+
if (handlers !== undefined) {
|
|
153
|
+
handlers.delete(handler);
|
|
154
|
+
}
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
on(event, handler) {
|
|
158
|
+
const key = event;
|
|
159
|
+
let handlers = this.eventListeners.get(key);
|
|
160
|
+
if (handlers === undefined) {
|
|
161
|
+
handlers = new Set();
|
|
162
|
+
this.eventListeners.set(key, handlers);
|
|
163
|
+
}
|
|
164
|
+
handlers.add(handler);
|
|
165
|
+
return this;
|
|
166
|
+
}
|
|
167
|
+
pause(_timeOffset) {
|
|
168
|
+
if (this.isPlayingValue === false) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.isPlayingValue = false;
|
|
172
|
+
if (this.animationFrameId !== null) {
|
|
173
|
+
globalThis.cancelAnimationFrame(this.animationFrameId);
|
|
174
|
+
this.animationFrameId = null;
|
|
175
|
+
}
|
|
176
|
+
this.emit('pause', undefined);
|
|
177
|
+
}
|
|
178
|
+
play(timeOffset) {
|
|
179
|
+
if (this.isPlayingValue === true) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
this.isPlayingValue = true;
|
|
183
|
+
this.startTime = globalThis.Date.now() - (timeOffset ?? 0);
|
|
184
|
+
this.eventIndex = 0;
|
|
185
|
+
this.emit('start', undefined);
|
|
186
|
+
this.animationFrameId = globalThis.requestAnimationFrame(() => {
|
|
187
|
+
this.tick();
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
resume(_timeOffset) {
|
|
191
|
+
if (this.isPlayingValue === true) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
this.isPlayingValue = true;
|
|
195
|
+
this.startTime = globalThis.Date.now() - (_timeOffset ?? 0);
|
|
196
|
+
this.emit('resume', undefined);
|
|
197
|
+
this.animationFrameId = globalThis.requestAnimationFrame(() => {
|
|
198
|
+
this.tick();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=replay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.js","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AAEA,SAAS,oBAAoB;IAC3B,MAAM,OAAO,GAAgB,UAAU,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAEtE,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;IACpC,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;IAC7B,OAAO,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC9B,OAAO,C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ChC,CAAC;IAEM,IAAI,CAAC,UAAmB;QAC7B,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC,CAAC;QAC3D,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QAEpB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAE9B,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,qBAAqB,CAAC,GAAS,EAAE;YAClE,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,WAAoB;QAChC,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,WAAW,IAAI,CAAC,CAAC,CAAC;QAE5D,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE/B,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC,qBAAqB,CAAC,GAAS,EAAE;YAClE,IAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.test.d.ts","sourceRoot":"","sources":["../src/replay.test.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Replayer } from './index';
|
|
2
|
+
import './.test-helpers/setup';
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
|
+
import assert from 'node:assert/strict';
|
|
5
|
+
const sampleEvents = [
|
|
6
|
+
{ type: 2, timestamp: 0, data: { html: '<html></html>', title: 'Test', url: 'https://localhost/', viewport: { width: 800, height: 600 } } },
|
|
7
|
+
{ type: 3, timestamp: 100, data: { source: 1, type: 'click', target: 'body', clientX: 100, clientY: 200 } }
|
|
8
|
+
];
|
|
9
|
+
describe('Replayer', () => {
|
|
10
|
+
it('constructs and creates a wrapper element', () => {
|
|
11
|
+
const container = globalThis.document.createElement('div');
|
|
12
|
+
globalThis.document.body.appendChild(container);
|
|
13
|
+
const replayer = new Replayer(sampleEvents, {
|
|
14
|
+
root: container,
|
|
15
|
+
speed: 1,
|
|
16
|
+
showWarning: false,
|
|
17
|
+
showDebug: false,
|
|
18
|
+
blockClass: 'auditor-block'
|
|
19
|
+
});
|
|
20
|
+
assert.ok(replayer.wrapper instanceof HTMLElement);
|
|
21
|
+
assert.strictEqual(replayer.wrapper.parentElement, container);
|
|
22
|
+
assert.strictEqual(replayer.isPlaying(), false);
|
|
23
|
+
replayer.destroy();
|
|
24
|
+
container.remove();
|
|
25
|
+
});
|
|
26
|
+
it('play() sets isPlaying to true', () => {
|
|
27
|
+
const container = globalThis.document.createElement('div');
|
|
28
|
+
globalThis.document.body.appendChild(container);
|
|
29
|
+
const replayer = new Replayer(sampleEvents, {
|
|
30
|
+
root: container,
|
|
31
|
+
speed: 1,
|
|
32
|
+
showWarning: false,
|
|
33
|
+
showDebug: false,
|
|
34
|
+
blockClass: 'auditor-block'
|
|
35
|
+
});
|
|
36
|
+
replayer.play();
|
|
37
|
+
assert.strictEqual(replayer.isPlaying(), true);
|
|
38
|
+
replayer.destroy();
|
|
39
|
+
container.remove();
|
|
40
|
+
});
|
|
41
|
+
it('pause() sets isPlaying to false', () => {
|
|
42
|
+
const container = globalThis.document.createElement('div');
|
|
43
|
+
globalThis.document.body.appendChild(container);
|
|
44
|
+
const replayer = new Replayer(sampleEvents, {
|
|
45
|
+
root: container,
|
|
46
|
+
speed: 1,
|
|
47
|
+
showWarning: false,
|
|
48
|
+
showDebug: false,
|
|
49
|
+
blockClass: 'auditor-block'
|
|
50
|
+
});
|
|
51
|
+
replayer.play();
|
|
52
|
+
assert.strictEqual(replayer.isPlaying(), true);
|
|
53
|
+
replayer.pause();
|
|
54
|
+
assert.strictEqual(replayer.isPlaying(), false);
|
|
55
|
+
replayer.destroy();
|
|
56
|
+
container.remove();
|
|
57
|
+
});
|
|
58
|
+
it('destroy() removes wrapper from DOM', () => {
|
|
59
|
+
const container = globalThis.document.createElement('div');
|
|
60
|
+
globalThis.document.body.appendChild(container);
|
|
61
|
+
const replayer = new Replayer(sampleEvents, {
|
|
62
|
+
root: container,
|
|
63
|
+
speed: 1,
|
|
64
|
+
showWarning: false,
|
|
65
|
+
showDebug: false,
|
|
66
|
+
blockClass: 'auditor-block'
|
|
67
|
+
});
|
|
68
|
+
replayer.destroy();
|
|
69
|
+
assert.strictEqual(replayer.wrapper.parentElement, null);
|
|
70
|
+
assert.strictEqual(replayer.isPlaying(), false);
|
|
71
|
+
assert.strictEqual(container.children.length, 0);
|
|
72
|
+
container.remove();
|
|
73
|
+
});
|
|
74
|
+
it('on/off event handlers work', () => {
|
|
75
|
+
const container = globalThis.document.createElement('div');
|
|
76
|
+
globalThis.document.body.appendChild(container);
|
|
77
|
+
const replayer = new Replayer(sampleEvents, {
|
|
78
|
+
root: container,
|
|
79
|
+
speed: 1,
|
|
80
|
+
showWarning: false,
|
|
81
|
+
showDebug: false,
|
|
82
|
+
blockClass: 'auditor-block'
|
|
83
|
+
});
|
|
84
|
+
let startCalled = false;
|
|
85
|
+
let _finishCalled = false;
|
|
86
|
+
const startHandler = () => {
|
|
87
|
+
startCalled = true;
|
|
88
|
+
};
|
|
89
|
+
const finishHandler = () => {
|
|
90
|
+
_finishCalled = true;
|
|
91
|
+
};
|
|
92
|
+
replayer.on('start', startHandler);
|
|
93
|
+
replayer.on('finish', finishHandler);
|
|
94
|
+
replayer.play();
|
|
95
|
+
// Wait a tick for events to process
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
replayer.off('start', startHandler);
|
|
99
|
+
replayer.off('finish', finishHandler);
|
|
100
|
+
assert.strictEqual(startCalled, true);
|
|
101
|
+
replayer.destroy();
|
|
102
|
+
container.remove();
|
|
103
|
+
resolve();
|
|
104
|
+
}, 50);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
it('handles empty events array', () => {
|
|
108
|
+
const container = globalThis.document.createElement('div');
|
|
109
|
+
globalThis.document.body.appendChild(container);
|
|
110
|
+
const replayer = new Replayer([], {
|
|
111
|
+
root: container,
|
|
112
|
+
speed: 1,
|
|
113
|
+
showWarning: false,
|
|
114
|
+
showDebug: false,
|
|
115
|
+
blockClass: 'auditor-block'
|
|
116
|
+
});
|
|
117
|
+
replayer.play();
|
|
118
|
+
return new Promise((resolve) => {
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
assert.strictEqual(replayer.isPlaying(), false);
|
|
121
|
+
replayer.destroy();
|
|
122
|
+
container.remove();
|
|
123
|
+
resolve();
|
|
124
|
+
}, 50);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=replay.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.test.js","sourceRoot":"","sources":["../src/replay.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,SAAS,CAAC;AACvD,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,MAAM,YAAY,GAAoB;IACpC,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,oBAAoB,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,UAAU,CAAC,GAAS,EAAE;gBACpB,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;gBAChD,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACnB,SAAS,CAAC,MAAM,EAAE,CAAC;gBACnB,OAAO,EAAE,CAAC;YACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export declare enum EventType {
|
|
2
|
+
DomContentLoaded = 0,
|
|
3
|
+
Load = 1,
|
|
4
|
+
FullSnapshot = 2,
|
|
5
|
+
IncrementalSnapshot = 3,
|
|
6
|
+
Meta = 4,
|
|
7
|
+
Custom = 5,
|
|
8
|
+
Plugin = 6
|
|
9
|
+
}
|
|
10
|
+
export declare enum IncrementalSource {
|
|
11
|
+
MouseMove = 0,
|
|
12
|
+
MouseInteraction = 1,
|
|
13
|
+
Scroll = 2,
|
|
14
|
+
TouchMove = 3,
|
|
15
|
+
Input = 5,
|
|
16
|
+
MediaInteraction = 6,
|
|
17
|
+
StyleSheetRule = 7,
|
|
18
|
+
CanvasMutation = 8,
|
|
19
|
+
Font = 9,
|
|
20
|
+
Log = 10,
|
|
21
|
+
Drag = 11,
|
|
22
|
+
StyleSheetDeclaration = 13,
|
|
23
|
+
Selection = 14,
|
|
24
|
+
AdoptedStyleSheet = 18,
|
|
25
|
+
CanvasTooltipData = 20,
|
|
26
|
+
StyleSheetInsertRule = 21,
|
|
27
|
+
ViewportResize = 22,
|
|
28
|
+
TextSelection = 23
|
|
29
|
+
}
|
|
30
|
+
export interface eventWithTime {
|
|
31
|
+
data: unknown;
|
|
32
|
+
timestamp: number;
|
|
33
|
+
type: EventType;
|
|
34
|
+
}
|
|
35
|
+
export interface recordOptions {
|
|
36
|
+
emit: (event: eventWithTime, isCheckout?: boolean) => void;
|
|
37
|
+
recordDOM?: boolean;
|
|
38
|
+
sampling?: SamplingStrategy;
|
|
39
|
+
}
|
|
40
|
+
export interface SamplingStrategy {
|
|
41
|
+
canvas?: 'all' | number;
|
|
42
|
+
input?: 'all' | 'last';
|
|
43
|
+
media?: number;
|
|
44
|
+
mouseInteraction?: boolean | Record<string, boolean | undefined>;
|
|
45
|
+
mousemove?: boolean | number;
|
|
46
|
+
mousemoveCallback?: number;
|
|
47
|
+
scroll?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface playerConfig {
|
|
50
|
+
blockClass: string;
|
|
51
|
+
root: Element;
|
|
52
|
+
showDebug: boolean;
|
|
53
|
+
showWarning: boolean;
|
|
54
|
+
speed: number;
|
|
55
|
+
}
|
|
56
|
+
export interface ReplayerEvents {
|
|
57
|
+
finish: void;
|
|
58
|
+
pause: void;
|
|
59
|
+
resize: {
|
|
60
|
+
height: number;
|
|
61
|
+
width: number;
|
|
62
|
+
};
|
|
63
|
+
resume: void;
|
|
64
|
+
start: void;
|
|
65
|
+
}
|
|
66
|
+
export type ReplayerEventName = keyof ReplayerEvents;
|
|
67
|
+
export type ReplayerEventHandler<T extends ReplayerEventName> = (event: ReplayerEvents[T]) => void;
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,gBAAgB,IAAI;IACpB,IAAI,IAAI;IACR,YAAY,IAAI;IAChB,mBAAmB,IAAI;IACvB,IAAI,IAAI;IACR,MAAM,IAAI;IACV,MAAM,IAAI;CACX;AAED,oBAAY,iBAAiB;IAC3B,SAAS,IAAI;IACb,gBAAgB,IAAI;IACpB,MAAM,IAAI;IACV,SAAS,IAAI;IACb,KAAK,IAAI;IACT,gBAAgB,IAAI;IACpB,cAAc,IAAI;IAClB,cAAc,IAAI;IAClB,IAAI,IAAI;IACR,GA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AAE,IAAI,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,cAAc,CAAC;AAErD,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,iBAAiB,IAAI,CAC9D,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,KACrB,IAAI,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export var EventType;
|
|
2
|
+
(function (EventType) {
|
|
3
|
+
EventType[EventType["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
4
|
+
EventType[EventType["Load"] = 1] = "Load";
|
|
5
|
+
EventType[EventType["FullSnapshot"] = 2] = "FullSnapshot";
|
|
6
|
+
EventType[EventType["IncrementalSnapshot"] = 3] = "IncrementalSnapshot";
|
|
7
|
+
EventType[EventType["Meta"] = 4] = "Meta";
|
|
8
|
+
EventType[EventType["Custom"] = 5] = "Custom";
|
|
9
|
+
EventType[EventType["Plugin"] = 6] = "Plugin";
|
|
10
|
+
})(EventType || (EventType = {}));
|
|
11
|
+
export var IncrementalSource;
|
|
12
|
+
(function (IncrementalSource) {
|
|
13
|
+
IncrementalSource[IncrementalSource["MouseMove"] = 0] = "MouseMove";
|
|
14
|
+
IncrementalSource[IncrementalSource["MouseInteraction"] = 1] = "MouseInteraction";
|
|
15
|
+
IncrementalSource[IncrementalSource["Scroll"] = 2] = "Scroll";
|
|
16
|
+
IncrementalSource[IncrementalSource["TouchMove"] = 3] = "TouchMove";
|
|
17
|
+
IncrementalSource[IncrementalSource["Input"] = 5] = "Input";
|
|
18
|
+
IncrementalSource[IncrementalSource["MediaInteraction"] = 6] = "MediaInteraction";
|
|
19
|
+
IncrementalSource[IncrementalSource["StyleSheetRule"] = 7] = "StyleSheetRule";
|
|
20
|
+
IncrementalSource[IncrementalSource["CanvasMutation"] = 8] = "CanvasMutation";
|
|
21
|
+
IncrementalSource[IncrementalSource["Font"] = 9] = "Font";
|
|
22
|
+
IncrementalSource[IncrementalSource["Log"] = 10] = "Log";
|
|
23
|
+
IncrementalSource[IncrementalSource["Drag"] = 11] = "Drag";
|
|
24
|
+
IncrementalSource[IncrementalSource["StyleSheetDeclaration"] = 13] = "StyleSheetDeclaration";
|
|
25
|
+
IncrementalSource[IncrementalSource["Selection"] = 14] = "Selection";
|
|
26
|
+
IncrementalSource[IncrementalSource["AdoptedStyleSheet"] = 18] = "AdoptedStyleSheet";
|
|
27
|
+
IncrementalSource[IncrementalSource["CanvasTooltipData"] = 20] = "CanvasTooltipData";
|
|
28
|
+
IncrementalSource[IncrementalSource["StyleSheetInsertRule"] = 21] = "StyleSheetInsertRule";
|
|
29
|
+
IncrementalSource[IncrementalSource["ViewportResize"] = 22] = "ViewportResize";
|
|
30
|
+
IncrementalSource[IncrementalSource["TextSelection"] = 23] = "TextSelection";
|
|
31
|
+
})(IncrementalSource || (IncrementalSource = {}));
|
|
32
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,iEAAoB,CAAA;IACpB,yCAAQ,CAAA;IACR,yDAAgB,CAAA;IAChB,uEAAuB,CAAA;IACvB,yCAAQ,CAAA;IACR,6CAAU,CAAA;IACV,6CAAU,CAAA;AACZ,CAAC,EARW,SAAS,KAAT,SAAS,QAQpB;AAED,MAAM,CAAN,IAAY,iBAmBX;AAnBD,WAAY,iBAAiB;IAC3B,mEAAa,CAAA;IACb,iFAAoB,CAAA;IACpB,6DAAU,CAAA;IACV,mEAAa,CAAA;IACb,2DAAS,CAAA;IACT,iFAAoB,CAAA;IACpB,6EAAkB,CAAA;IAClB,6EAAkB,CAAA;IAClB,yDAAQ,CAAA;IACR,wDAAQ,CAAA;IACR,0DAAS,CAAA;IACT,4FAA0B,CAAA;IAC1B,oEAAc,CAAA;IACd,oFAAsB,CAAA;IACtB,oFAAsB,CAAA;IACtB,0FAAyB,CAAA;IACzB,8EAAmB,CAAA;IACnB,4EAAkB,CAAA;AACpB,CAAC,EAnBW,iBAAiB,KAAjB,iBAAiB,QAmB5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test.d.ts","sourceRoot":"","sources":["../src/types.test.ts"],"names":[],"mappings":"AAWA,OAAO,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { record, Replayer } from './index';
|
|
2
|
+
import { IncrementalSource } from './index';
|
|
3
|
+
import './.test-helpers/setup';
|
|
4
|
+
import { describe, it } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
describe('types', () => {
|
|
7
|
+
it('record is a function', () => {
|
|
8
|
+
assert.strictEqual(typeof record, 'function');
|
|
9
|
+
});
|
|
10
|
+
it('Replayer is a class', () => {
|
|
11
|
+
assert.strictEqual(typeof Replayer, 'function');
|
|
12
|
+
assert.ok(Replayer.prototype instanceof Object);
|
|
13
|
+
assert.strictEqual(typeof Replayer.prototype.play, 'function');
|
|
14
|
+
assert.strictEqual(typeof Replayer.prototype.pause, 'function');
|
|
15
|
+
assert.strictEqual(typeof Replayer.prototype.resume, 'function');
|
|
16
|
+
assert.strictEqual(typeof Replayer.prototype.destroy, 'function');
|
|
17
|
+
assert.strictEqual(typeof Replayer.prototype.isPlaying, 'function');
|
|
18
|
+
});
|
|
19
|
+
it('type imports resolve without error', () => {
|
|
20
|
+
// These are type-only imports that exist at compile time.
|
|
21
|
+
// At runtime they are undefined, but the import statement itself
|
|
22
|
+
// should not throw. This test verifies the module graph is valid.
|
|
23
|
+
const event = { type: 0, timestamp: 0, data: null };
|
|
24
|
+
const options = { emit: () => { }, recordDOM: false };
|
|
25
|
+
const config = {
|
|
26
|
+
blockClass: 'test',
|
|
27
|
+
root: globalThis.document.body,
|
|
28
|
+
showDebug: false,
|
|
29
|
+
showWarning: false,
|
|
30
|
+
speed: 1
|
|
31
|
+
};
|
|
32
|
+
const sampling = { mousemove: 100, scroll: 150, input: 'last' };
|
|
33
|
+
assert.strictEqual(event.type, 0);
|
|
34
|
+
assert.strictEqual(event.timestamp, 0);
|
|
35
|
+
assert.strictEqual(event.data, null);
|
|
36
|
+
assert.strictEqual(typeof options.emit, 'function');
|
|
37
|
+
assert.strictEqual(options.recordDOM, false);
|
|
38
|
+
assert.strictEqual(config.blockClass, 'test');
|
|
39
|
+
assert.strictEqual(config.speed, 1);
|
|
40
|
+
assert.strictEqual(sampling.mousemove, 100);
|
|
41
|
+
assert.strictEqual(sampling.input, 'last');
|
|
42
|
+
assert.strictEqual(IncrementalSource.MouseMove, 0);
|
|
43
|
+
assert.strictEqual(IncrementalSource.Scroll, 2);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=types.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test.js","sourceRoot":"","sources":["../src/types.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAEL,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAOjB,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,WAAW,CAAC,OAAO,MAAM,EAAE,UAAU,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC7B,MAAM,CAAC,WAAW,CAAC,OAAO,QAAQ,EAAE,UAAU,CAAC,CAAC;QAChD,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,YAAY,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AAC,CAAC;QACvC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACrC,MAAM,CAAC,WAAW,CAAC,OAAO,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACpD,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAC7C,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACpC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAC5C,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC3C,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACnD,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitelint/webrewind",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Record and replay the web - independent DOM mutation + interaction capture for runtime issue reproduction.",
|
|
5
|
+
"license": "MPL-2.0",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "SiteLint"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/sitelint/webrewind.git"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"lint": "npm run lint:markdown && npm run lint:scripts && dpdm --transform=true --tree=false --warning=false ./src/index.ts",
|
|
21
|
+
"lint:markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
|
|
22
|
+
"lint:scripts": "oxlint --fix",
|
|
23
|
+
"test": "node --no-warnings --import tsx --import ./src/.test-helpers/setup.ts --test src/*.test.ts",
|
|
24
|
+
"prepack": "npm run build",
|
|
25
|
+
"release": "release-it --config release-it.json",
|
|
26
|
+
"start": "node ./dist/index.js",
|
|
27
|
+
"check": "tsc --noEmit"
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/index.d.cts",
|
|
37
|
+
"default": "./dist/index.js"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"devtools",
|
|
46
|
+
"dom",
|
|
47
|
+
"mutation-observer",
|
|
48
|
+
"product-analytics",
|
|
49
|
+
"real-user-monitoring",
|
|
50
|
+
"record",
|
|
51
|
+
"replay",
|
|
52
|
+
"session-replay",
|
|
53
|
+
"webrewind"
|
|
54
|
+
],
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=20"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@types/jsdom": "30.0.0",
|
|
60
|
+
"@types/node": "26.6.11",
|
|
61
|
+
"dpdm": "4.3.0",
|
|
62
|
+
"jsdom": "31.0.1",
|
|
63
|
+
"markdownlint-cli": "0.50.1",
|
|
64
|
+
"oxlint": "1.94.0",
|
|
65
|
+
"release-it": "21.1.3",
|
|
66
|
+
"tsx": "4.23.15",
|
|
67
|
+
"typescript": "7.0.2"
|
|
68
|
+
}
|
|
69
|
+
}
|