update typing files

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 0efa7b0491
commit a517b9dd90
5 changed files with 55 additions and 7 deletions

View File

@@ -24,6 +24,8 @@ export declare class Replayer {
private mirror; private mirror;
private firstFullSnapshot; private firstFullSnapshot;
private newDocumentQueue; private newDocumentQueue;
private mousePos;
private touchActive;
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;
off(event: string, handler: Handler): this; off(event: string, handler: Handler): this;
@@ -42,6 +44,7 @@ export declare class Replayer {
resetCache(): void; resetCache(): void;
private setupDom; private setupDom;
private handleResize; private handleResize;
private applyEventsSynchronously;
private getCastFn; private getCastFn;
private rebuildFullSnapshot; private rebuildFullSnapshot;
private insertStyleRules; private insertStyleRules;

View File

@@ -46,9 +46,10 @@ export declare type PlayerState = {
export declare function discardPriorSnapshots(events: eventWithTime[], baselineTime: number): eventWithTime[]; export declare function discardPriorSnapshots(events: eventWithTime[], baselineTime: number): eventWithTime[];
declare type PlayerAssets = { declare type PlayerAssets = {
emitter: Emitter; emitter: Emitter;
applyEventsSynchronously(events: Array<eventWithTime>): void;
getCastFn(event: eventWithTime, isSync: boolean): () => void; getCastFn(event: eventWithTime, isSync: boolean): () => void;
}; };
export declare function createPlayerService(context: PlayerContext, { getCastFn, emitter }: PlayerAssets): StateMachine.Service<PlayerContext, PlayerEvent, PlayerState>; export declare function createPlayerService(context: PlayerContext, { getCastFn, applyEventsSynchronously, emitter }: PlayerAssets): StateMachine.Service<PlayerContext, PlayerEvent, PlayerState>;
export declare type SpeedContext = { export declare type SpeedContext = {
normalSpeed: playerConfig['speed']; normalSpeed: playerConfig['speed'];
timer: Timer; timer: Timer;

View File

@@ -2,7 +2,9 @@ import { INode } from 'rrweb-snapshot';
export declare enum StyleRuleType { export declare enum StyleRuleType {
Insert = 0, Insert = 0,
Remove = 1, Remove = 1,
Snapshot = 2 Snapshot = 2,
SetProperty = 3,
RemoveProperty = 4
} }
declare type InsertRule = { declare type InsertRule = {
cssText: string; cssText: string;
@@ -17,9 +19,25 @@ declare type SnapshotRule = {
type: StyleRuleType.Snapshot; type: StyleRuleType.Snapshot;
cssTexts: string[]; cssTexts: string[];
}; };
export declare type VirtualStyleRules = Array<InsertRule | RemoveRule | SnapshotRule>; declare type SetPropertyRule = {
type: StyleRuleType.SetProperty;
index: number[];
property: string;
value: string | null;
priority: string | undefined;
};
declare type RemovePropertyRule = {
type: StyleRuleType.RemoveProperty;
index: number[];
property: string;
};
export declare type VirtualStyleRules = Array<InsertRule | RemoveRule | SnapshotRule | SetPropertyRule | RemovePropertyRule>;
export declare type VirtualStyleRulesMap = Map<INode, VirtualStyleRules>; export declare type VirtualStyleRulesMap = Map<INode, VirtualStyleRules>;
export declare function getNestedRule(rules: CSSRuleList, position: number[]): CSSGroupingRule; export declare function getNestedRule(rules: CSSRuleList, position: number[]): CSSGroupingRule;
export declare function getPositionsAndIndex(nestedIndex: number[]): {
positions: number[];
index: number | undefined;
};
export declare function applyVirtualStyleRulesToNode(storedRules: VirtualStyleRules, styleNode: HTMLStyleElement): void; export declare function applyVirtualStyleRulesToNode(storedRules: VirtualStyleRules, styleNode: HTMLStyleElement): void;
export declare function storeCSSRules(parentElement: HTMLStyleElement, virtualStyleRulesMap: VirtualStyleRulesMap): void; export declare function storeCSSRules(parentElement: HTMLStyleElement, virtualStyleRulesMap: VirtualStyleRulesMap): void;
export {}; export {};

View File

@@ -71,7 +71,8 @@ export declare enum IncrementalSource {
CanvasMutation = 9, CanvasMutation = 9,
Font = 10, Font = 10,
Log = 11, Log = 11,
Drag = 12 Drag = 12,
StyleDeclaration = 13
} }
export declare type mutationData = { export declare type mutationData = {
source: IncrementalSource.Mutation; source: IncrementalSource.Mutation;
@@ -99,13 +100,16 @@ export declare type mediaInteractionData = {
export declare type styleSheetRuleData = { export declare type styleSheetRuleData = {
source: IncrementalSource.StyleSheetRule; source: IncrementalSource.StyleSheetRule;
} & styleSheetRuleParam; } & styleSheetRuleParam;
export declare type styleDeclarationData = {
source: IncrementalSource.StyleDeclaration;
} & styleDeclarationParam;
export declare type canvasMutationData = { export declare type canvasMutationData = {
source: IncrementalSource.CanvasMutation; source: IncrementalSource.CanvasMutation;
} & canvasMutationParam; } & canvasMutationParam;
export declare type fontData = { export declare type fontData = {
source: IncrementalSource.Font; source: IncrementalSource.Font;
} & fontParam; } & fontParam;
export declare type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData; export declare type incrementalData = mutationData | mousemoveData | mouseInteractionData | scrollData | viewportResizeData | inputData | mediaInteractionData | styleSheetRuleData | canvasMutationData | fontData | styleDeclarationData;
export declare type event = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent; export declare type event = domContentLoadedEvent | loadedEvent | fullSnapshotEvent | incrementalSnapshotEvent | metaEvent | customEvent | pluginEvent;
export declare type eventWithTime = event & { export declare type eventWithTime = event & {
timestamp: number; timestamp: number;
@@ -168,6 +172,7 @@ export declare type observerParam = {
maskTextFn?: MaskTextFn; maskTextFn?: MaskTextFn;
inlineStylesheet: boolean; inlineStylesheet: boolean;
styleSheetRuleCb: styleSheetRuleCallback; styleSheetRuleCb: styleSheetRuleCallback;
styleDeclarationCb: styleDeclarationCallback;
canvasMutationCb: canvasMutationCallback; canvasMutationCb: canvasMutationCallback;
fontCb: fontCallback; fontCb: fontCallback;
sampling: SamplingStrategy; sampling: SamplingStrategy;
@@ -194,6 +199,7 @@ export declare type hooksParam = {
input?: inputCallback; input?: inputCallback;
mediaInteaction?: mediaInteractionCallback; mediaInteaction?: mediaInteractionCallback;
styleSheetRule?: styleSheetRuleCallback; styleSheetRule?: styleSheetRuleCallback;
styleDeclaration?: styleDeclarationCallback;
canvasMutation?: canvasMutationCallback; canvasMutation?: canvasMutationCallback;
font?: fontCallback; font?: fontCallback;
}; };
@@ -255,6 +261,12 @@ export declare type mousePosition = {
id: number; id: number;
timeOffset: number; timeOffset: number;
}; };
export declare type mouseMovePos = {
x: number;
y: number;
id: number;
debugData: incrementalData;
};
export declare enum MouseInteractions { export declare enum MouseInteractions {
MouseUp = 0, MouseUp = 0,
MouseDown = 1, MouseDown = 1,
@@ -265,7 +277,8 @@ export declare enum MouseInteractions {
Blur = 6, Blur = 6,
TouchStart = 7, TouchStart = 7,
TouchMove_Departed = 8, TouchMove_Departed = 8,
TouchEnd = 9 TouchEnd = 9,
TouchCancel = 10
} }
declare type mouseInteractionParam = { declare type mouseInteractionParam = {
type: MouseInteractions; type: MouseInteractions;
@@ -293,6 +306,19 @@ export declare type styleSheetRuleParam = {
adds?: styleSheetAddRule[]; adds?: styleSheetAddRule[];
}; };
export declare type styleSheetRuleCallback = (s: styleSheetRuleParam) => void; export declare type styleSheetRuleCallback = (s: styleSheetRuleParam) => void;
export declare type styleDeclarationParam = {
id: number;
index: number[];
set?: {
property: string;
value: string | null;
priority: string | undefined;
};
remove?: {
property: string;
};
};
export declare type styleDeclarationCallback = (s: styleDeclarationParam) => void;
export declare type canvasMutationCallback = (p: canvasMutationParam) => void; export declare type canvasMutationCallback = (p: canvasMutationParam) => void;
export declare type canvasMutationParam = { export declare type canvasMutationParam = {
id: number; id: number;

View File

@@ -1,4 +1,4 @@
import { Mirror, throttleOptions, listenerHandler, hookResetter, blockClass, eventWithTime, addedNodeMutation, removedNodeMutation, textMutation, attributeMutation, mutationData, scrollData, inputData, DocumentDimension } from './types'; import { Mirror, throttleOptions, listenerHandler, hookResetter, blockClass, addedNodeMutation, removedNodeMutation, textMutation, attributeMutation, mutationData, scrollData, inputData, DocumentDimension } from './types';
import { INode, serializedNodeWithId } from 'rrweb-snapshot'; import { INode, serializedNodeWithId } from 'rrweb-snapshot';
export declare function on(type: string, fn: EventListenerOrEventListenerObject, target?: Document | Window): listenerHandler; export declare function on(type: string, fn: EventListenerOrEventListenerObject, target?: Document | Window): listenerHandler;
export declare function createMirror(): Mirror; export declare function createMirror(): Mirror;