@posthog/rrweb-snapshot 0.0.10 → 0.0.12
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/dist/index.d.cts +69 -12
- package/dist/index.d.ts +69 -12
- package/dist/rrweb-snapshot.cjs +85 -195
- package/dist/rrweb-snapshot.cjs.map +1 -1
- package/dist/rrweb-snapshot.js +85 -195
- package/dist/rrweb-snapshot.js.map +1 -1
- package/dist/rrweb-snapshot.umd.cjs +85 -195
- package/dist/rrweb-snapshot.umd.cjs.map +4 -4
- package/dist/rrweb-snapshot.umd.min.cjs +19 -19
- package/dist/rrweb-snapshot.umd.min.cjs.map +4 -4
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { DataURLOptions } from '@posthog/rrweb-types';
|
|
2
2
|
import { IMirror } from '@posthog/rrweb-types';
|
|
3
|
-
import { serializedElementNodeWithId } from '@posthog/rrweb-types';
|
|
4
|
-
import { serializedNode } from '@posthog/rrweb-types';
|
|
3
|
+
import { serializedElementNodeWithId as serializedElementNodeWithId_2 } from '@posthog/rrweb-types';
|
|
4
|
+
import { serializedNode as serializedNode_2 } from '@posthog/rrweb-types';
|
|
5
5
|
import { serializedNodeWithId } from '@posthog/rrweb-types';
|
|
6
6
|
|
|
7
7
|
export declare function absolutifyURLs(cssText: string | null, href: string): string;
|
|
8
8
|
|
|
9
9
|
export declare function adaptCssForReplay(cssText: string, cache: BuildCache): string;
|
|
10
10
|
|
|
11
|
+
export declare type attributes = {
|
|
12
|
+
[key: string]: string | number | true | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
11
15
|
export declare type BuildCache = {
|
|
12
16
|
stylesWithHoverClass: Map<string, string>;
|
|
13
17
|
};
|
|
@@ -21,10 +25,20 @@ export declare function buildNodeWithSN(n: serializedNodeWithId, options: {
|
|
|
21
25
|
cache: BuildCache;
|
|
22
26
|
}): Node | null;
|
|
23
27
|
|
|
28
|
+
export declare type cdataNode = {
|
|
29
|
+
type: NodeType.CDATA;
|
|
30
|
+
textContent: '';
|
|
31
|
+
};
|
|
32
|
+
|
|
24
33
|
export declare function classMatchesRegex(node: Node | null, regex: RegExp, checkAncestors: boolean): boolean;
|
|
25
34
|
|
|
26
35
|
export declare function cleanupSnapshot(): void;
|
|
27
36
|
|
|
37
|
+
export declare type commentNode = {
|
|
38
|
+
type: NodeType.Comment;
|
|
39
|
+
textContent: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
28
42
|
export declare function createCache(): BuildCache;
|
|
29
43
|
|
|
30
44
|
export declare function createMirror(): Mirror;
|
|
@@ -42,6 +56,29 @@ export declare type DialogAttributes = {
|
|
|
42
56
|
rr_open_mode: 'modal' | 'non-modal';
|
|
43
57
|
};
|
|
44
58
|
|
|
59
|
+
export declare type documentNode = {
|
|
60
|
+
type: NodeType.Document;
|
|
61
|
+
childNodes: serializedNodeWithId[];
|
|
62
|
+
compatMode?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export declare type documentTypeNode = {
|
|
66
|
+
type: NodeType.DocumentType;
|
|
67
|
+
name: string;
|
|
68
|
+
publicId: string;
|
|
69
|
+
systemId: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export declare type elementNode = {
|
|
73
|
+
type: NodeType.Element;
|
|
74
|
+
tagName: string;
|
|
75
|
+
attributes: attributes;
|
|
76
|
+
childNodes: serializedNodeWithId[];
|
|
77
|
+
isSVG?: true;
|
|
78
|
+
needBlock?: boolean;
|
|
79
|
+
isCustom?: true;
|
|
80
|
+
};
|
|
81
|
+
|
|
45
82
|
export declare function escapeImportStatement(rule: CSSImportRule_2): string;
|
|
46
83
|
|
|
47
84
|
export declare function extractFileExtension(path: string, baseURL?: string): string | null;
|
|
@@ -72,13 +109,15 @@ export declare function isElement(n: Node): n is Element;
|
|
|
72
109
|
|
|
73
110
|
export declare function isNativeShadowDom(shadowRoot: ShadowRoot): boolean;
|
|
74
111
|
|
|
75
|
-
export declare function isNodeMetaEqual(a:
|
|
112
|
+
export declare function isNodeMetaEqual(a: serializedNode_2, b: serializedNode_2): boolean;
|
|
76
113
|
|
|
77
114
|
export declare function isShadowRoot(n: Node): n is ShadowRoot;
|
|
78
115
|
|
|
79
116
|
export declare type KeepIframeSrcFn = (src: string) => boolean;
|
|
80
117
|
|
|
81
|
-
export declare
|
|
118
|
+
export declare type legacyAttributes = {
|
|
119
|
+
selected: false;
|
|
120
|
+
};
|
|
82
121
|
|
|
83
122
|
export declare type MaskInputFn = (text: string, element: HTMLElement) => string;
|
|
84
123
|
|
|
@@ -131,7 +170,14 @@ export declare function needMaskingText(node: Node, maskTextClass: string | RegE
|
|
|
131
170
|
|
|
132
171
|
export declare type nodeMetaMap = WeakMap<Node, serializedNodeWithId>;
|
|
133
172
|
|
|
134
|
-
export declare
|
|
173
|
+
export declare enum NodeType {
|
|
174
|
+
Document = 0,
|
|
175
|
+
DocumentType = 1,
|
|
176
|
+
Element = 2,
|
|
177
|
+
Text = 3,
|
|
178
|
+
CDATA = 4,
|
|
179
|
+
Comment = 5
|
|
180
|
+
}
|
|
135
181
|
|
|
136
182
|
export declare function rebuild(n: serializedNodeWithId, options: {
|
|
137
183
|
doc: Document;
|
|
@@ -142,6 +188,14 @@ export declare function rebuild(n: serializedNodeWithId, options: {
|
|
|
142
188
|
mirror: Mirror;
|
|
143
189
|
}): Node | null;
|
|
144
190
|
|
|
191
|
+
export declare type serializedElementNodeWithId = Extract<serializedNodeWithId, Record<'type', NodeType.Element>>;
|
|
192
|
+
|
|
193
|
+
export declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
|
|
194
|
+
rootId?: number;
|
|
195
|
+
isShadowHost?: boolean;
|
|
196
|
+
isShadow?: boolean;
|
|
197
|
+
};
|
|
198
|
+
|
|
145
199
|
export declare function serializeNodeWithId(n: Node, options: {
|
|
146
200
|
doc: Document;
|
|
147
201
|
mirror: Mirror;
|
|
@@ -163,11 +217,10 @@ export declare function serializeNodeWithId(n: Node, options: {
|
|
|
163
217
|
recordCanvas?: boolean;
|
|
164
218
|
preserveWhiteSpace?: boolean;
|
|
165
219
|
onSerialize?: (n: Node) => unknown;
|
|
166
|
-
onIframeLoad?: (iframeNode: HTMLIFrameElement, node:
|
|
220
|
+
onIframeLoad?: (iframeNode: HTMLIFrameElement, node: serializedElementNodeWithId_2) => unknown;
|
|
167
221
|
iframeLoadTimeout?: number;
|
|
168
|
-
onStylesheetLoad?: (linkNode: HTMLLinkElement, node:
|
|
222
|
+
onStylesheetLoad?: (linkNode: HTMLLinkElement, node: serializedElementNodeWithId_2) => unknown;
|
|
169
223
|
stylesheetLoadTimeout?: number;
|
|
170
|
-
cssCaptured?: boolean;
|
|
171
224
|
}): serializedNodeWithId | null;
|
|
172
225
|
|
|
173
226
|
export declare type SlimDOMOptions = Partial<{
|
|
@@ -200,15 +253,13 @@ export declare function snapshot(n: Document, options?: {
|
|
|
200
253
|
recordCanvas?: boolean;
|
|
201
254
|
preserveWhiteSpace?: boolean;
|
|
202
255
|
onSerialize?: (n: Node) => unknown;
|
|
203
|
-
onIframeLoad?: (iframeNode: HTMLIFrameElement, node:
|
|
256
|
+
onIframeLoad?: (iframeNode: HTMLIFrameElement, node: serializedElementNodeWithId_2) => unknown;
|
|
204
257
|
iframeLoadTimeout?: number;
|
|
205
|
-
onStylesheetLoad?: (linkNode: HTMLLinkElement, node:
|
|
258
|
+
onStylesheetLoad?: (linkNode: HTMLLinkElement, node: serializedElementNodeWithId_2) => unknown;
|
|
206
259
|
stylesheetLoadTimeout?: number;
|
|
207
260
|
keepIframeSrcFn?: KeepIframeSrcFn;
|
|
208
261
|
}): serializedNodeWithId | null;
|
|
209
262
|
|
|
210
|
-
export declare function splitCssText(cssText: string, style: HTMLStyleElement): string[];
|
|
211
|
-
|
|
212
263
|
export declare function stringifyRule(rule: CSSRule, sheetHref: string | null): string;
|
|
213
264
|
|
|
214
265
|
export declare function stringifyStylesheet(s: CSSStyleSheet): string | null;
|
|
@@ -217,6 +268,12 @@ export declare type tagMap = {
|
|
|
217
268
|
[key: string]: string;
|
|
218
269
|
};
|
|
219
270
|
|
|
271
|
+
export declare type textNode = {
|
|
272
|
+
type: NodeType.Text;
|
|
273
|
+
textContent: string;
|
|
274
|
+
isStyle?: true;
|
|
275
|
+
};
|
|
276
|
+
|
|
220
277
|
export declare function toLowerCase<T extends string>(str: T): Lowercase<T>;
|
|
221
278
|
|
|
222
279
|
export declare function transformAttribute(doc: Document, tagName: Lowercase<string>, name: Lowercase<string>, value: string | null): string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { DataURLOptions } from '@posthog/rrweb-types';
|
|
2
2
|
import { IMirror } from '@posthog/rrweb-types';
|
|
3
|
-
import { serializedElementNodeWithId } from '@posthog/rrweb-types';
|
|
4
|
-
import { serializedNode } from '@posthog/rrweb-types';
|
|
3
|
+
import { serializedElementNodeWithId as serializedElementNodeWithId_2 } from '@posthog/rrweb-types';
|
|
4
|
+
import { serializedNode as serializedNode_2 } from '@posthog/rrweb-types';
|
|
5
5
|
import { serializedNodeWithId } from '@posthog/rrweb-types';
|
|
6
6
|
|
|
7
7
|
export declare function absolutifyURLs(cssText: string | null, href: string): string;
|
|
8
8
|
|
|
9
9
|
export declare function adaptCssForReplay(cssText: string, cache: BuildCache): string;
|
|
10
10
|
|
|
11
|
+
export declare type attributes = {
|
|
12
|
+
[key: string]: string | number | true | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
11
15
|
export declare type BuildCache = {
|
|
12
16
|
stylesWithHoverClass: Map<string, string>;
|
|
13
17
|
};
|
|
@@ -21,10 +25,20 @@ export declare function buildNodeWithSN(n: serializedNodeWithId, options: {
|
|
|
21
25
|
cache: BuildCache;
|
|
22
26
|
}): Node | null;
|
|
23
27
|
|
|
28
|
+
export declare type cdataNode = {
|
|
29
|
+
type: NodeType.CDATA;
|
|
30
|
+
textContent: '';
|
|
31
|
+
};
|
|
32
|
+
|
|
24
33
|
export declare function classMatchesRegex(node: Node | null, regex: RegExp, checkAncestors: boolean): boolean;
|
|
25
34
|
|
|
26
35
|
export declare function cleanupSnapshot(): void;
|
|
27
36
|
|
|
37
|
+
export declare type commentNode = {
|
|
38
|
+
type: NodeType.Comment;
|
|
39
|
+
textContent: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
28
42
|
export declare function createCache(): BuildCache;
|
|
29
43
|
|
|
30
44
|
export declare function createMirror(): Mirror;
|
|
@@ -42,6 +56,29 @@ export declare type DialogAttributes = {
|
|
|
42
56
|
rr_open_mode: 'modal' | 'non-modal';
|
|
43
57
|
};
|
|
44
58
|
|
|
59
|
+
export declare type documentNode = {
|
|
60
|
+
type: NodeType.Document;
|
|
61
|
+
childNodes: serializedNodeWithId[];
|
|
62
|
+
compatMode?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export declare type documentTypeNode = {
|
|
66
|
+
type: NodeType.DocumentType;
|
|
67
|
+
name: string;
|
|
68
|
+
publicId: string;
|
|
69
|
+
systemId: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export declare type elementNode = {
|
|
73
|
+
type: NodeType.Element;
|
|
74
|
+
tagName: string;
|
|
75
|
+
attributes: attributes;
|
|
76
|
+
childNodes: serializedNodeWithId[];
|
|
77
|
+
isSVG?: true;
|
|
78
|
+
needBlock?: boolean;
|
|
79
|
+
isCustom?: true;
|
|
80
|
+
};
|
|
81
|
+
|
|
45
82
|
export declare function escapeImportStatement(rule: CSSImportRule_2): string;
|
|
46
83
|
|
|
47
84
|
export declare function extractFileExtension(path: string, baseURL?: string): string | null;
|
|
@@ -72,13 +109,15 @@ export declare function isElement(n: Node): n is Element;
|
|
|
72
109
|
|
|
73
110
|
export declare function isNativeShadowDom(shadowRoot: ShadowRoot): boolean;
|
|
74
111
|
|
|
75
|
-
export declare function isNodeMetaEqual(a:
|
|
112
|
+
export declare function isNodeMetaEqual(a: serializedNode_2, b: serializedNode_2): boolean;
|
|
76
113
|
|
|
77
114
|
export declare function isShadowRoot(n: Node): n is ShadowRoot;
|
|
78
115
|
|
|
79
116
|
export declare type KeepIframeSrcFn = (src: string) => boolean;
|
|
80
117
|
|
|
81
|
-
export declare
|
|
118
|
+
export declare type legacyAttributes = {
|
|
119
|
+
selected: false;
|
|
120
|
+
};
|
|
82
121
|
|
|
83
122
|
export declare type MaskInputFn = (text: string, element: HTMLElement) => string;
|
|
84
123
|
|
|
@@ -131,7 +170,14 @@ export declare function needMaskingText(node: Node, maskTextClass: string | RegE
|
|
|
131
170
|
|
|
132
171
|
export declare type nodeMetaMap = WeakMap<Node, serializedNodeWithId>;
|
|
133
172
|
|
|
134
|
-
export declare
|
|
173
|
+
export declare enum NodeType {
|
|
174
|
+
Document = 0,
|
|
175
|
+
DocumentType = 1,
|
|
176
|
+
Element = 2,
|
|
177
|
+
Text = 3,
|
|
178
|
+
CDATA = 4,
|
|
179
|
+
Comment = 5
|
|
180
|
+
}
|
|
135
181
|
|
|
136
182
|
export declare function rebuild(n: serializedNodeWithId, options: {
|
|
137
183
|
doc: Document;
|
|
@@ -142,6 +188,14 @@ export declare function rebuild(n: serializedNodeWithId, options: {
|
|
|
142
188
|
mirror: Mirror;
|
|
143
189
|
}): Node | null;
|
|
144
190
|
|
|
191
|
+
export declare type serializedElementNodeWithId = Extract<serializedNodeWithId, Record<'type', NodeType.Element>>;
|
|
192
|
+
|
|
193
|
+
export declare type serializedNode = (documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode) & {
|
|
194
|
+
rootId?: number;
|
|
195
|
+
isShadowHost?: boolean;
|
|
196
|
+
isShadow?: boolean;
|
|
197
|
+
};
|
|
198
|
+
|
|
145
199
|
export declare function serializeNodeWithId(n: Node, options: {
|
|
146
200
|
doc: Document;
|
|
147
201
|
mirror: Mirror;
|
|
@@ -163,11 +217,10 @@ export declare function serializeNodeWithId(n: Node, options: {
|
|
|
163
217
|
recordCanvas?: boolean;
|
|
164
218
|
preserveWhiteSpace?: boolean;
|
|
165
219
|
onSerialize?: (n: Node) => unknown;
|
|
166
|
-
onIframeLoad?: (iframeNode: HTMLIFrameElement, node:
|
|
220
|
+
onIframeLoad?: (iframeNode: HTMLIFrameElement, node: serializedElementNodeWithId_2) => unknown;
|
|
167
221
|
iframeLoadTimeout?: number;
|
|
168
|
-
onStylesheetLoad?: (linkNode: HTMLLinkElement, node:
|
|
222
|
+
onStylesheetLoad?: (linkNode: HTMLLinkElement, node: serializedElementNodeWithId_2) => unknown;
|
|
169
223
|
stylesheetLoadTimeout?: number;
|
|
170
|
-
cssCaptured?: boolean;
|
|
171
224
|
}): serializedNodeWithId | null;
|
|
172
225
|
|
|
173
226
|
export declare type SlimDOMOptions = Partial<{
|
|
@@ -200,15 +253,13 @@ export declare function snapshot(n: Document, options?: {
|
|
|
200
253
|
recordCanvas?: boolean;
|
|
201
254
|
preserveWhiteSpace?: boolean;
|
|
202
255
|
onSerialize?: (n: Node) => unknown;
|
|
203
|
-
onIframeLoad?: (iframeNode: HTMLIFrameElement, node:
|
|
256
|
+
onIframeLoad?: (iframeNode: HTMLIFrameElement, node: serializedElementNodeWithId_2) => unknown;
|
|
204
257
|
iframeLoadTimeout?: number;
|
|
205
|
-
onStylesheetLoad?: (linkNode: HTMLLinkElement, node:
|
|
258
|
+
onStylesheetLoad?: (linkNode: HTMLLinkElement, node: serializedElementNodeWithId_2) => unknown;
|
|
206
259
|
stylesheetLoadTimeout?: number;
|
|
207
260
|
keepIframeSrcFn?: KeepIframeSrcFn;
|
|
208
261
|
}): serializedNodeWithId | null;
|
|
209
262
|
|
|
210
|
-
export declare function splitCssText(cssText: string, style: HTMLStyleElement): string[];
|
|
211
|
-
|
|
212
263
|
export declare function stringifyRule(rule: CSSRule, sheetHref: string | null): string;
|
|
213
264
|
|
|
214
265
|
export declare function stringifyStylesheet(s: CSSStyleSheet): string | null;
|
|
@@ -217,6 +268,12 @@ export declare type tagMap = {
|
|
|
217
268
|
[key: string]: string;
|
|
218
269
|
};
|
|
219
270
|
|
|
271
|
+
export declare type textNode = {
|
|
272
|
+
type: NodeType.Text;
|
|
273
|
+
textContent: string;
|
|
274
|
+
isStyle?: true;
|
|
275
|
+
};
|
|
276
|
+
|
|
220
277
|
export declare function toLowerCase<T extends string>(str: T): Lowercase<T>;
|
|
221
278
|
|
|
222
279
|
export declare function transformAttribute(doc: Document, tagName: Lowercase<string>, name: Lowercase<string>, value: string | null): string | null;
|