@voila.dev/replay 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +53 -2
- package/dist/format/index.d.ts +141 -0
- package/dist/format.js +34 -0
- package/dist/modules/index.d.ts +12 -0
- package/dist/modules.js +213 -0
- package/dist/play/index.d.ts +58 -0
- package/dist/play/mirror.d.ts +48 -0
- package/dist/play.js +903 -0
- package/dist/record/index.d.ts +91 -0
- package/dist/record/natives.d.ts +16 -0
- package/dist/record.js +880 -0
- package/dist/send/index.d.ts +57 -0
- package/dist/send.js +241 -0
- package/dist/shared/chunk-6US53Q3A.js +337 -0
- package/dist/testing/cases.d.ts +23 -0
- package/dist/testing/fuzz.d.ts +8 -0
- package/dist/testing/index.d.ts +5 -0
- package/dist/testing/oracle.d.ts +18 -0
- package/dist/testing.js +1207 -0
- package/package.json +63 -5
- package/src/format/index.ts +442 -0
- package/src/modules/index.ts +224 -0
- package/src/play/index.ts +299 -0
- package/src/play/mirror.ts +767 -0
- package/src/record/index.ts +1042 -0
- package/src/record/natives.ts +100 -0
- package/src/send/index.ts +339 -0
- package/src/testing/cases.ts +670 -0
- package/src/testing/fuzz.ts +317 -0
- package/src/testing/index.ts +8 -0
- package/src/testing/oracle.ts +318 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { End, type Tape } from "../format/index";
|
|
2
|
+
import { type Natives } from "./natives";
|
|
3
|
+
export type Mask = "inputs" | "text" | "none";
|
|
4
|
+
/** 0 clear, 1 masked, 2 blocked */
|
|
5
|
+
export type Zone = 0 | 1 | 2;
|
|
6
|
+
export interface Options {
|
|
7
|
+
/** What is hidden: `inputs` (what is typed, the default), `text` (every text too), `none`. */
|
|
8
|
+
readonly mask?: Mask;
|
|
9
|
+
/** Text and attributes under an element with this attribute are recorded as stars. */
|
|
10
|
+
readonly maskAttr?: string;
|
|
11
|
+
/** An element with this attribute is recorded as an empty box of its size. */
|
|
12
|
+
readonly blockAttr?: string;
|
|
13
|
+
/** A field under this attribute is recorded in clear (never a password or a card number). */
|
|
14
|
+
readonly unmaskAttr?: string;
|
|
15
|
+
/** The page is read at most once per this many milliseconds. */
|
|
16
|
+
readonly rate?: number;
|
|
17
|
+
/** Bytes of tape, roughly, a page view may take before recording stops. */
|
|
18
|
+
readonly budget?: number;
|
|
19
|
+
/** Milliseconds between two fingerprints of the page (PRINT); 0: none. */
|
|
20
|
+
readonly printEvery?: number;
|
|
21
|
+
/** Milliseconds a read of the mutations may take before it hands back to the page. */
|
|
22
|
+
readonly slice?: number;
|
|
23
|
+
readonly modules?: ReadonlyArray<Module>;
|
|
24
|
+
}
|
|
25
|
+
export interface Kit {
|
|
26
|
+
readonly w: Window;
|
|
27
|
+
readonly d: Document;
|
|
28
|
+
readonly native: Natives;
|
|
29
|
+
/** Serializes a node under a zone, through the masking rule. */
|
|
30
|
+
readonly ser: (n: Node, zone: Zone) => void;
|
|
31
|
+
readonly push: (...tokens: Tape) => void;
|
|
32
|
+
/** Puts a tick on the tape when time went by. */
|
|
33
|
+
readonly stamp: () => void;
|
|
34
|
+
readonly id: (n: Node) => number | undefined;
|
|
35
|
+
/** Numbers a root (a shadow root, a frame's document) and ties it to its host. */
|
|
36
|
+
readonly take: (root: Node, host: Element) => number;
|
|
37
|
+
readonly zone: (n: Node) => Zone;
|
|
38
|
+
/** The number of a stylesheet, given once per sheet and page view. */
|
|
39
|
+
readonly sheet: (s: CSSStyleSheet) => number;
|
|
40
|
+
readonly sheetKnown: (s: CSSStyleSheet) => boolean;
|
|
41
|
+
readonly observe: (root: Node) => void;
|
|
42
|
+
readonly listen: (root: Document | ShadowRoot) => void;
|
|
43
|
+
/** Records an element again from scratch, at the next read. */
|
|
44
|
+
readonly redo: (el: Element) => void;
|
|
45
|
+
/** Asks for a read at rest. */
|
|
46
|
+
readonly dirty: () => void;
|
|
47
|
+
readonly masked: (s: string) => string;
|
|
48
|
+
}
|
|
49
|
+
export interface Module {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
/** Once, as the recorder starts. */
|
|
52
|
+
setup?(kit: Kit): void;
|
|
53
|
+
/** On each element, once its attributes are on the tape and before its children. */
|
|
54
|
+
onElement?(el: Element, zone: Zone): void;
|
|
55
|
+
/** The tree an element holds besides its children: a shadow root, a frame's document. */
|
|
56
|
+
inner?(n: Node): Node | null | undefined;
|
|
57
|
+
/** At the end of each read at rest. */
|
|
58
|
+
onSync?(): void;
|
|
59
|
+
/** At the end of each snapshot. */
|
|
60
|
+
onSnap?(): void;
|
|
61
|
+
onStop?(): void;
|
|
62
|
+
}
|
|
63
|
+
export interface Snapshot {
|
|
64
|
+
readonly tape: Tape;
|
|
65
|
+
/** Where the tape can be cut into pieces that stay the same from one visitor to the next. */
|
|
66
|
+
readonly cuts: ReadonlyArray<number>;
|
|
67
|
+
readonly base: number;
|
|
68
|
+
readonly startedAt: number;
|
|
69
|
+
readonly endedAt: number;
|
|
70
|
+
}
|
|
71
|
+
export interface Drained {
|
|
72
|
+
readonly tape: Tape;
|
|
73
|
+
/** The number the first node made in this tape takes. */
|
|
74
|
+
readonly base: number;
|
|
75
|
+
readonly startedAt: number;
|
|
76
|
+
readonly endedAt: number;
|
|
77
|
+
}
|
|
78
|
+
export interface Recorder {
|
|
79
|
+
/** Records the page as it is and starts numbering nodes again. */
|
|
80
|
+
snap(): Snapshot;
|
|
81
|
+
/** What happened since the last call. */
|
|
82
|
+
drain(): Drained;
|
|
83
|
+
/** Stops; `reason` is written on the tape, for the next drain. */
|
|
84
|
+
stop(reason?: End): void;
|
|
85
|
+
readonly stopped: boolean;
|
|
86
|
+
/** True when the next thing to send must be a new snapshot: a module failed mid-way, or the page came back from the back/forward cache. */
|
|
87
|
+
readonly needsSnap: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** The recorder starts on Safari 15.4, Chrome 92, Firefox 90 and later: `Array.prototype.at`. */
|
|
90
|
+
export declare function supported(w: Window): boolean;
|
|
91
|
+
export declare function record(w: Window, o?: Options): Recorder | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Natives {
|
|
2
|
+
readonly first: (n: Node) => Node | null;
|
|
3
|
+
readonly next: (n: Node) => Node | null;
|
|
4
|
+
readonly parent: (n: Node) => Node | null;
|
|
5
|
+
readonly attributes: (el: Element) => NamedNodeMap;
|
|
6
|
+
readonly get: (el: Element, name: string) => string | null;
|
|
7
|
+
readonly has: (el: Element, name: string) => boolean;
|
|
8
|
+
readonly local: (el: Element) => string;
|
|
9
|
+
readonly ns: (el: Element) => string | null;
|
|
10
|
+
readonly rect: (el: Element) => DOMRect;
|
|
11
|
+
readonly shadow: (el: Element) => ShadowRoot | null;
|
|
12
|
+
readonly host: (root: ShadowRoot) => Element;
|
|
13
|
+
readonly content: (template: HTMLTemplateElement) => DocumentFragment;
|
|
14
|
+
readonly Observer: typeof MutationObserver;
|
|
15
|
+
}
|
|
16
|
+
export declare function natives(w: Window): Natives;
|