update typings file

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent b1b25447ff
commit e339ebb90b
9 changed files with 102 additions and 35 deletions

View File

@@ -3,5 +3,6 @@ declare function record<T = eventWithTime>(options?: recordOptions<T>): listener
declare namespace record { declare namespace record {
var addCustomEvent: <T>(tag: string, payload: T) => void; var addCustomEvent: <T>(tag: string, payload: T) => void;
var freezePage: () => void; var freezePage: () => void;
var takeFullSnapshot: (isCheckout?: boolean | undefined) => void;
} }
export default record; export default record;

View File

@@ -1,6 +1,7 @@
import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'; import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';
import { mutationRecord, blockClass, mutationCallBack } from '../types'; import { mutationRecord, blockClass, maskTextClass, mutationCallBack, MaskTextFn } from '../types';
import { IframeManager } from './iframe-manager'; import { IframeManager } from './iframe-manager';
import { ShadowDomManager } from './shadow-dom-manager';
export default class MutationBuffer { export default class MutationBuffer {
private frozen; private frozen;
private locked; private locked;
@@ -15,13 +16,17 @@ export default class MutationBuffer {
private emissionCallback; private emissionCallback;
private blockClass; private blockClass;
private blockSelector; private blockSelector;
private maskTextClass;
private maskTextSelector;
private inlineStylesheet; private inlineStylesheet;
private maskInputOptions; private maskInputOptions;
private maskTextFn;
private recordCanvas; private recordCanvas;
private slimDOMOptions; private slimDOMOptions;
private doc; private doc;
private iframeManager; private iframeManager;
init(cb: mutationCallBack, blockClass: blockClass, blockSelector: string | null, inlineStylesheet: boolean, maskInputOptions: MaskInputOptions, recordCanvas: boolean, slimDOMOptions: SlimDOMOptions, doc: Document, iframeManager: IframeManager): void; private shadowDomManager;
init(cb: mutationCallBack, blockClass: blockClass, blockSelector: string | null, maskTextClass: maskTextClass, maskTextSelector: string | null, inlineStylesheet: boolean, maskInputOptions: MaskInputOptions, maskTextFn: MaskTextFn | undefined, recordCanvas: boolean, slimDOMOptions: SlimDOMOptions, doc: Document, iframeManager: IframeManager, shadowDomManager: ShadowDomManager): void;
freeze(): void; freeze(): void;
unfreeze(): void; unfreeze(): void;
isFrozen(): boolean; isFrozen(): boolean;

View File

@@ -1,5 +1,9 @@
import { observerParam, listenerHandler, hooksParam } from '../types'; import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';
import { mutationCallBack, observerParam, listenerHandler, blockClass, maskTextClass, hooksParam, MaskTextFn } from '../types';
import MutationBuffer from './mutation'; import MutationBuffer from './mutation';
import { IframeManager } from './iframe-manager';
import { ShadowDomManager } from './shadow-dom-manager';
export declare const mutationBuffers: MutationBuffer[]; export declare const mutationBuffers: MutationBuffer[];
export declare function initMutationObserver(cb: mutationCallBack, doc: Document, blockClass: blockClass, blockSelector: string | null, maskTextClass: maskTextClass, maskTextSelector: string | null, inlineStylesheet: boolean, maskInputOptions: MaskInputOptions, maskTextFn: MaskTextFn | undefined, recordCanvas: boolean, slimDOMOptions: SlimDOMOptions, iframeManager: IframeManager, shadowDomManager: ShadowDomManager, rootEl: Node): MutationObserver;
export declare const INPUT_TAGS: string[]; export declare const INPUT_TAGS: string[];
export declare function initObservers(o: observerParam, hooks?: hooksParam): listenerHandler; export declare function initObservers(o: observerParam, hooks?: hooksParam): listenerHandler;

25
typings/record/shadow-dom-manager.d.ts vendored Normal file
View File

@@ -0,0 +1,25 @@
import { mutationCallBack, blockClass, maskTextClass, MaskTextFn } from '../types';
import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';
import { IframeManager } from './iframe-manager';
declare type BypassOptions = {
blockClass: blockClass;
blockSelector: string | null;
maskTextClass: maskTextClass;
maskTextSelector: string | null;
inlineStylesheet: boolean;
maskInputOptions: MaskInputOptions;
maskTextFn: MaskTextFn | undefined;
recordCanvas: boolean;
slimDOMOptions: SlimDOMOptions;
iframeManager: IframeManager;
};
export declare class ShadowDomManager {
private mutationCb;
private bypassOptions;
constructor(options: {
mutationCb: mutationCallBack;
bypassOptions: BypassOptions;
});
addShadowRoot(shadowRoot: ShadowRoot, doc: Document): void;
}
export {};

View File

@@ -19,6 +19,7 @@ export declare class Replayer {
private fragmentParentMap; private fragmentParentMap;
private elementStateMap; private elementStateMap;
private imageMap; private imageMap;
private firstPlayedEvent;
private newDocumentQueue; private newDocumentQueue;
constructor(events: Array<eventWithTime | string>, config?: Partial<playerConfig>); constructor(events: Array<eventWithTime | string>, config?: Partial<playerConfig>);
on(event: string, handler: Handler): this; on(event: string, handler: Handler): this;

1
typings/rrdom/index.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
export {};

20
typings/rrdom/tree-node.d.ts vendored Normal file
View File

@@ -0,0 +1,20 @@
export declare type AnyObject = {
[key: string]: any;
__rrdom__?: RRdomTreeNode;
};
export declare class RRdomTreeNode implements AnyObject {
parent: AnyObject | null;
previousSibling: AnyObject | null;
nextSibling: AnyObject | null;
firstChild: AnyObject | null;
lastChild: AnyObject | null;
childrenVersion: number;
childIndexCachedUpTo: AnyObject | null;
cachedIndex: number;
cachedIndexVersion: number;
get isAttached(): boolean;
get hasChildren(): boolean;
childrenChanged(): void;
getCachedIndex(parentNode: AnyObject): number;
setCachedIndex(parentNode: AnyObject, index: number): void;
}

69
typings/types.d.ts vendored
View File

@@ -1,9 +1,8 @@
/// <reference types="node" />
import { serializedNodeWithId, idNodeMap, INode, MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot'; import { serializedNodeWithId, idNodeMap, INode, MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';
import { PackFn, UnpackFn } from './packer/base'; import { PackFn, UnpackFn } from './packer/base';
import { FontFaceDescriptors } from 'css-font-loading-module'; import { FontFaceDescriptors } from 'css-font-loading-module';
import { IframeManager } from './record/iframe-manager'; import { IframeManager } from './record/iframe-manager';
import { MaskTextFn } from '../src/types'; import { ShadowDomManager } from './record/shadow-dom-manager';
export declare enum EventType { export declare enum EventType {
DomContentLoaded = 0, DomContentLoaded = 0,
Load = 1, Load = 1,
@@ -66,13 +65,14 @@ export declare enum IncrementalSource {
StyleSheetRule = 8, StyleSheetRule = 8,
CanvasMutation = 9, CanvasMutation = 9,
Font = 10, Font = 10,
Log = 11 Log = 11,
Drag = 12
} }
export declare type mutationData = { export declare type mutationData = {
source: IncrementalSource.Mutation; source: IncrementalSource.Mutation;
} & mutationCallbackParam; } & mutationCallbackParam;
export declare type mousemoveData = { export declare type mousemoveData = {
source: IncrementalSource.MouseMove | IncrementalSource.TouchMove; source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag;
positions: mousePosition[]; positions: mousePosition[];
}; };
export declare type mouseInteractionData = { export declare type mouseInteractionData = {
@@ -126,7 +126,7 @@ export declare type recordOptions<T> = {
blockSelector?: string; blockSelector?: string;
ignoreClass?: string; ignoreClass?: string;
maskTextClass?: maskTextClass; maskTextClass?: maskTextClass;
maskTextSelector?: string | null; maskTextSelector?: string;
maskAllInputs?: boolean; maskAllInputs?: boolean;
maskInputOptions?: MaskInputOptions; maskInputOptions?: MaskInputOptions;
maskInputFn?: MaskInputFn; maskInputFn?: MaskInputFn;
@@ -151,9 +151,9 @@ export declare type observerParam = {
mediaInteractionCb: mediaInteractionCallback; mediaInteractionCb: mediaInteractionCallback;
blockClass: blockClass; blockClass: blockClass;
blockSelector: string | null; blockSelector: string | null;
ignoreClass: string;
maskTextClass: maskTextClass; maskTextClass: maskTextClass;
maskTextSelector: string | null; maskTextSelector: string | null;
ignoreClass: string;
maskInputOptions: MaskInputOptions; maskInputOptions: MaskInputOptions;
maskInputFn?: MaskInputFn; maskInputFn?: MaskInputFn;
maskTextFn?: MaskTextFn; maskTextFn?: MaskTextFn;
@@ -169,6 +169,7 @@ export declare type observerParam = {
slimDOMOptions: SlimDOMOptions; slimDOMOptions: SlimDOMOptions;
doc: Document; doc: Document;
iframeManager: IframeManager; iframeManager: IframeManager;
shadowDomManager: ShadowDomManager;
}; };
export declare type hooksParam = { export declare type hooksParam = {
mutation?: mutationCallBack; mutation?: mutationCallBack;
@@ -214,6 +215,7 @@ export declare type attributeMutation = {
export declare type removedNodeMutation = { export declare type removedNodeMutation = {
parentId: number; parentId: number;
id: number; id: number;
isShadow?: boolean;
}; };
export declare type addedNodeMutation = { export declare type addedNodeMutation = {
parentId: number; parentId: number;
@@ -221,14 +223,15 @@ export declare type addedNodeMutation = {
nextId: number | null; nextId: number | null;
node: serializedNodeWithId; node: serializedNodeWithId;
}; };
declare type mutationCallbackParam = { export declare type mutationCallbackParam = {
texts: textMutation[]; texts: textMutation[];
attributes: attributeMutation[]; attributes: attributeMutation[];
removes: removedNodeMutation[]; removes: removedNodeMutation[];
adds: addedNodeMutation[]; adds: addedNodeMutation[];
isAttachIframe?: true;
}; };
export declare type mutationCallBack = (m: mutationCallbackParam) => void; export declare type mutationCallBack = (m: mutationCallbackParam) => void;
export declare type mousemoveCallBack = (p: mousePosition[], source: IncrementalSource.MouseMove | IncrementalSource.TouchMove) => void; export declare type mousemoveCallBack = (p: mousePosition[], source: IncrementalSource.MouseMove | IncrementalSource.TouchMove | IncrementalSource.Drag) => void;
export declare type mousePosition = { export declare type mousePosition = {
x: number; x: number;
y: number; y: number;
@@ -288,31 +291,31 @@ export declare type fontParam = {
}; };
export declare type LogLevel = 'assert' | 'clear' | 'count' | 'countReset' | 'debug' | 'dir' | 'dirxml' | 'error' | 'group' | 'groupCollapsed' | 'groupEnd' | 'info' | 'log' | 'table' | 'time' | 'timeEnd' | 'timeLog' | 'trace' | 'warn'; export declare type LogLevel = 'assert' | 'clear' | 'count' | 'countReset' | 'debug' | 'dir' | 'dirxml' | 'error' | 'group' | 'groupCollapsed' | 'groupEnd' | 'info' | 'log' | 'table' | 'time' | 'timeEnd' | 'timeLog' | 'trace' | 'warn';
export declare type Logger = { export declare type Logger = {
assert?: (value: any, message?: string, ...optionalParams: any[]) => void; assert?: typeof console.assert;
clear?: () => void; clear?: typeof console.clear;
count?: (label?: string) => void; count?: typeof console.count;
countReset?: (label?: string) => void; countReset?: typeof console.countReset;
debug?: (message?: any, ...optionalParams: any[]) => void; debug?: typeof console.debug;
dir?: (obj: any, options?: NodeJS.InspectOptions) => void; dir?: typeof console.dir;
dirxml?: (...data: any[]) => void; dirxml?: typeof console.dirxml;
error?: (message?: any, ...optionalParams: any[]) => void; error?: typeof console.error;
group?: (...label: any[]) => void; group?: typeof console.group;
groupCollapsed?: (label?: any[]) => void; groupCollapsed?: typeof console.groupCollapsed;
groupEnd?: () => void; groupEnd?: () => void;
info?: (message?: any, ...optionalParams: any[]) => void; info?: typeof console.info;
log?: (message?: any, ...optionalParams: any[]) => void; log?: typeof console.log;
table?: (tabularData: any, properties?: ReadonlyArray<string>) => void; table?: typeof console.table;
time?: (label?: string) => void; time?: typeof console.time;
timeEnd?: (label?: string) => void; timeEnd?: typeof console.timeEnd;
timeLog?: (label?: string, ...data: any[]) => void; timeLog?: typeof console.timeLog;
trace?: (message?: any, ...optionalParams: any[]) => void; trace?: typeof console.trace;
warn?: (message?: any, ...optionalParams: any[]) => void; warn?: typeof console.warn;
}; };
export declare type ReplayLogger = Partial<Record<LogLevel, (data: logData) => void>>; export declare type ReplayLogger = Partial<Record<LogLevel, (data: logData) => void>>;
export declare type LogParam = { export declare type LogParam = {
level: LogLevel; level: LogLevel;
trace: Array<string>; trace: string[];
payload: Array<string>; payload: string[];
}; };
export declare type fontCallback = (p: fontParam) => void; export declare type fontCallback = (p: fontParam) => void;
export declare type logCallback = (p: LogParam) => void; export declare type logCallback = (p: LogParam) => void;
@@ -349,6 +352,7 @@ export declare type Mirror = {
getNode: (id: number) => INode | null; getNode: (id: number) => INode | null;
removeNodeFromMap: (n: INode) => void; removeNodeFromMap: (n: INode) => void;
has: (id: number) => boolean; has: (id: number) => boolean;
reset: () => void;
}; };
export declare type throttleOptions = { export declare type throttleOptions = {
leading?: boolean; leading?: boolean;
@@ -358,6 +362,7 @@ export declare type listenerHandler = () => void;
export declare type hookResetter = () => void; export declare type hookResetter = () => void;
export declare type playerConfig = { export declare type playerConfig = {
speed: number; speed: number;
maxSpeed: number;
root: Element; root: Element;
loadTimeout: number; loadTimeout: number;
skipInactive: boolean; skipInactive: boolean;
@@ -379,7 +384,7 @@ export declare type playerConfig = {
logConfig: LogReplayConfig; logConfig: LogReplayConfig;
}; };
export declare type LogReplayConfig = { export declare type LogReplayConfig = {
level?: Array<LogLevel> | undefined; level?: LogLevel[] | undefined;
replayLogger: ReplayLogger | undefined; replayLogger: ReplayLogger | undefined;
}; };
export declare type playerMetaData = { export declare type playerMetaData = {
@@ -420,9 +425,11 @@ export declare enum ReplayerEvents {
EventCast = "event-cast", EventCast = "event-cast",
CustomEvent = "custom-event", CustomEvent = "custom-event",
Flush = "flush", Flush = "flush",
StateChange = "state-change" StateChange = "state-change",
PlayBack = "play-back"
} }
export declare type MaskInputFn = (text: string) => string; export declare type MaskInputFn = (text: string) => string;
export declare type MaskTextFn = (text: string) => string;
export declare type ElementState = { export declare type ElementState = {
scroll?: [number, number]; scroll?: [number, number];
}; };
@@ -431,7 +438,7 @@ export declare type StringifyOptions = {
numOfKeysLimit: number; numOfKeysLimit: number;
}; };
export declare type LogRecordOptions = { export declare type LogRecordOptions = {
level?: Array<LogLevel> | undefined; level?: LogLevel[] | undefined;
lengthThreshold?: number; lengthThreshold?: number;
stringifyOptions?: StringifyOptions; stringifyOptions?: StringifyOptions;
logger?: Logger; logger?: Logger;

5
typings/utils.d.ts vendored
View File

@@ -60,6 +60,9 @@ export declare type AppendedIframe = {
mutationInQueue: addedNodeMutation; mutationInQueue: addedNodeMutation;
builtNode: HTMLIFrameINode; builtNode: HTMLIFrameINode;
}; };
export declare function isIframeINode(node: INode): node is HTMLIFrameINode; export declare function isIframeINode(node: INode | ShadowRoot): node is HTMLIFrameINode;
export declare function getBaseDimension(node: Node, rootIframe: Node): DocumentDimension; export declare function getBaseDimension(node: Node, rootIframe: Node): DocumentDimension;
export declare function hasShadowRoot<T extends Node>(n: T): n is T & {
shadowRoot: ShadowRoot;
};
export {}; export {};