import { serializedNodeWithId, idNodeMap, INode } from 'rrweb-snapshot'; export enum EventType { DomContentLoaded, Load, FullSnapshot, IncrementalSnapshot, Meta, } export type domContentLoadedEvent = { type: EventType.DomContentLoaded; data: {}; }; export type loadedEvent = { type: EventType.Load; data: {}; }; export type fullSnapshotEvent = { type: EventType.FullSnapshot; data: { node: serializedNodeWithId; initialOffset: { top: number; left: number; }; }; }; export type incrementalSnapshotEvent = { type: EventType.IncrementalSnapshot; data: incrementalData; }; export type metaEvent = { type: EventType.Meta; data: { href: string; width: number; height: number; }; }; export enum IncrementalSource { Mutation, MouseMove, MouseInteraction, Scroll, ViewportResize, Input, } export type mutationData = { source: IncrementalSource.Mutation; } & mutationCallbackParam; export type mousemoveData = { source: IncrementalSource.MouseMove; positions: mousePosition[]; }; export type mouseInteractionData = { source: IncrementalSource.MouseInteraction; } & mouseInteractionParam; export type scrollData = { source: IncrementalSource.Scroll; } & scrollPosition; export type viewportResizeData = { source: IncrementalSource.ViewportResize; } & viewportResizeDimention; export type inputData = { source: IncrementalSource.Input; id: number; } & inputValue; export type incrementalData = | mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData; export type event = | domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent; export type eventWithTime = event & { timestamp: number; delay?: number; }; export type recordOptions = { emit?: (e: eventWithTime, isCheckout?: boolean) => void; checkoutEveryNth?: number; checkoutEveryNms?: number; blockClass?: string; ignoreClass?: string; }; export type observerParam = { mutationCb: mutationCallBack; mousemoveCb: mousemoveCallBack; mouseInteractionCb: mouseInteractionCallBack; scrollCb: scrollCallback; viewportResizeCb: viewportResizeCallback; inputCb: inputCallback; blockClass: string; ignoreClass: string; }; export type textCursor = { node: Node; value: string | null; }; export type textMutation = { id: number; value: string | null; }; export type attributeCursor = { node: Node; attributes: { [key: string]: string | null; }; }; export type attributeMutation = { id: number; attributes: { [key: string]: string | null; }; }; export type removedNodeMutation = { parentId: number; id: number; }; export type addedNodeMutation = { parentId: number; previousId: number | null; nextId: number | null; node: serializedNodeWithId; }; type mutationCallbackParam = { texts: textMutation[]; attributes: attributeMutation[]; removes: removedNodeMutation[]; adds: addedNodeMutation[]; }; export type mutationCallBack = (m: mutationCallbackParam) => void; export type mousemoveCallBack = (p: mousePosition[]) => void; export type mousePosition = { x: number; y: number; id: number; timeOffset: number; }; export enum MouseInteractions { MouseUp, MouseDown, Click, ContextMenu, DblClick, Focus, Blur, TouchStart, TouchMove, TouchEnd, } type mouseInteractionParam = { type: MouseInteractions; id: number; x: number; y: number; }; export type mouseInteractionCallBack = (d: mouseInteractionParam) => void; export type scrollPosition = { id: number; x: number; y: number; }; export type scrollCallback = (p: scrollPosition) => void; export type viewportResizeDimention = { width: number; height: number; }; export type viewportResizeCallback = (d: viewportResizeDimention) => void; export type inputValue = { text: string; isChecked: boolean; }; export type inputCallback = (v: inputValue & { id: number }) => void; export type Mirror = { map: idNodeMap; getId: (n: INode) => number; getNode: (id: number) => INode | null; removeNodeFromMap: (n: INode) => void; has: (id: number) => boolean; }; export type throttleOptions = { leading?: boolean; trailing?: boolean; }; export type listenerHandler = () => void; export type hookResetter = () => void; export type playerConfig = { speed: number; root: Element; loadTimeout: number; skipInactive: boolean; showWarning: boolean; showDebug: boolean; blockClass: string; }; export type playerMetaData = { totalTime: number; }; export type missingNode = { node: Node; mutation: addedNodeMutation; }; export type missingNodeMap = { [id: number]: missingNode; }; export type actionWithDelay = { doAction: () => void; delay: number; }; export enum ReplayerEvents { Start = 'start', Pause = 'pause', Resume = 'resume', Resize = 'resize', Finish = 'finish', FullsnapshotRebuilded = 'fullsnapshot-rebuilded', LoadStylesheetStart = 'load-stylesheet-start', LoadStylesheetEnd = 'load-stylesheet-end', SkipStart = 'skip-start', SkipEnd = 'skip-end', }