From 3c406bd49f340157b6248e9aaa199f2edc961962 Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Sat, 22 Aug 2020 15:42:55 +0800 Subject: [PATCH] rename visit to visitSnapshot --- src/index.ts | 4 ++-- src/snapshot.ts | 2 +- typings/index.d.ts | 4 ++-- typings/rebuild.d.ts | 2 +- typings/snapshot.d.ts | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index 1d5c89ea..0688bb24 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import snapshot, { serializeNodeWithId, transformAttribute, - visit, + visitSnapshot, } from './snapshot'; import rebuild, { buildNodeWithSN, addHoverClass } from './rebuild'; export * from './types'; @@ -13,5 +13,5 @@ export { buildNodeWithSN, addHoverClass, transformAttribute, - visit, + visitSnapshot, }; diff --git a/src/snapshot.ts b/src/snapshot.ts index 10a6d857..6d321575 100644 --- a/src/snapshot.ts +++ b/src/snapshot.ts @@ -425,7 +425,7 @@ function snapshot( ]; } -export function visit( +export function visitSnapshot( node: serializedNodeWithId, onVisit: (node: serializedNodeWithId) => unknown, ) { diff --git a/typings/index.d.ts b/typings/index.d.ts index 81e7b277..b871ef01 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1,4 +1,4 @@ -import snapshot, { serializeNodeWithId, transformAttribute } from './snapshot'; +import snapshot, { serializeNodeWithId, transformAttribute, visitSnapshot } from './snapshot'; import rebuild, { buildNodeWithSN, addHoverClass } from './rebuild'; export * from './types'; -export { snapshot, serializeNodeWithId, rebuild, buildNodeWithSN, addHoverClass, transformAttribute, }; +export { snapshot, serializeNodeWithId, rebuild, buildNodeWithSN, addHoverClass, transformAttribute, visitSnapshot, }; diff --git a/typings/rebuild.d.ts b/typings/rebuild.d.ts index 5ea522d8..f61a762a 100644 --- a/typings/rebuild.d.ts +++ b/typings/rebuild.d.ts @@ -1,5 +1,5 @@ import { serializedNodeWithId, idNodeMap, INode } from './types'; export declare function addHoverClass(cssText: string): string; export declare function buildNodeWithSN(n: serializedNodeWithId, doc: Document, map: idNodeMap, skipChild?: boolean, HACK_CSS?: boolean): INode | null; -declare function rebuild(n: serializedNodeWithId, doc: Document, HACK_CSS?: boolean): [Node | null, idNodeMap]; +declare function rebuild(n: serializedNodeWithId, doc: Document, onVisit?: (node: INode) => unknown, HACK_CSS?: boolean): [Node | null, idNodeMap]; export default rebuild; diff --git a/typings/snapshot.d.ts b/typings/snapshot.d.ts index 3b6ed5d7..2c03a806 100644 --- a/typings/snapshot.d.ts +++ b/typings/snapshot.d.ts @@ -4,4 +4,5 @@ export declare function absoluteToDoc(doc: Document, attributeValue: string): st export declare function transformAttribute(doc: Document, name: string, value: string): string; export declare function serializeNodeWithId(n: Node | INode, doc: Document, map: idNodeMap, blockClass: string | RegExp, skipChild?: boolean, inlineStylesheet?: boolean, maskInputOptions?: MaskInputOptions): serializedNodeWithId | null; declare function snapshot(n: Document, blockClass: string | RegExp | undefined, inlineStylesheet: boolean | undefined, maskAllInputsOrOptions: boolean | MaskInputOptions): [serializedNodeWithId | null, idNodeMap]; +export declare function visitSnapshot(node: serializedNodeWithId, onVisit: (node: serializedNodeWithId) => unknown): void; export default snapshot;