Cache addHoverClass as it is quite expensive (#643)
* Add cache and cache purging Needed for https://github.com/rrweb-io/rrweb-snapshot/pull/85 * Add cache and cache purging Needed for https://github.com/rrweb-io/rrweb-snapshot/pull/85 * Cache addHoverClass as it is quite expensive https://github.com/rrweb-io/rrweb-snapshot/pull/85 * Make cache non-optional * Make cache required on addHoverClass
This commit is contained in:
4
packages/rrweb-snapshot/typings/index.d.ts
vendored
4
packages/rrweb-snapshot/typings/index.d.ts
vendored
@@ -1,5 +1,5 @@
|
||||
import snapshot, { serializeNodeWithId, transformAttribute, visitSnapshot, cleanupSnapshot, needMaskingText, IGNORED_NODE } from './snapshot';
|
||||
import rebuild, { buildNodeWithSN, addHoverClass } from './rebuild';
|
||||
import rebuild, { buildNodeWithSN, addHoverClass, createCache } from './rebuild';
|
||||
export * from './types';
|
||||
export * from './utils';
|
||||
export { snapshot, serializeNodeWithId, rebuild, buildNodeWithSN, addHoverClass, transformAttribute, visitSnapshot, cleanupSnapshot, needMaskingText, IGNORED_NODE, };
|
||||
export { snapshot, serializeNodeWithId, rebuild, buildNodeWithSN, addHoverClass, createCache, transformAttribute, visitSnapshot, cleanupSnapshot, needMaskingText, IGNORED_NODE, };
|
||||
|
||||
7
packages/rrweb-snapshot/typings/rebuild.d.ts
vendored
7
packages/rrweb-snapshot/typings/rebuild.d.ts
vendored
@@ -1,16 +1,19 @@
|
||||
import { serializedNodeWithId, idNodeMap, INode } from './types';
|
||||
export declare function addHoverClass(cssText: string): string;
|
||||
import { serializedNodeWithId, idNodeMap, INode, BuildCache } from './types';
|
||||
export declare function addHoverClass(cssText: string, cache: BuildCache): string;
|
||||
export declare function createCache(): BuildCache;
|
||||
export declare function buildNodeWithSN(n: serializedNodeWithId, options: {
|
||||
doc: Document;
|
||||
map: idNodeMap;
|
||||
skipChild?: boolean;
|
||||
hackCss: boolean;
|
||||
afterAppend?: (n: INode) => unknown;
|
||||
cache: BuildCache;
|
||||
}): INode | null;
|
||||
declare function rebuild(n: serializedNodeWithId, options: {
|
||||
doc: Document;
|
||||
onVisit?: (node: INode) => unknown;
|
||||
hackCss?: boolean;
|
||||
afterAppend?: (n: INode) => unknown;
|
||||
cache: BuildCache;
|
||||
}): [Node | null, idNodeMap];
|
||||
export default rebuild;
|
||||
|
||||
3
packages/rrweb-snapshot/typings/types.d.ts
vendored
3
packages/rrweb-snapshot/typings/types.d.ts
vendored
@@ -90,3 +90,6 @@ export declare type SlimDOMOptions = Partial<{
|
||||
export declare type MaskTextFn = (text: string) => string;
|
||||
export declare type MaskInputFn = (text: string) => string;
|
||||
export declare type KeepIframeSrcFn = (src: string) => boolean;
|
||||
export declare type BuildCache = {
|
||||
stylesWithHoverClass: Map<string, string>;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user