add typings autogen command
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"non-interactive": true,
|
"non-interactive": true,
|
||||||
"buildCommand": "npm run bundle"
|
"buildCommand": "npm run bundle && npm run typings"
|
||||||
}
|
}
|
||||||
|
|||||||
21
index.d.ts
vendored
21
index.d.ts
vendored
@@ -1,21 +0,0 @@
|
|||||||
import { serializedNodeWithId, idNodeMap, INode } from './src/types';
|
|
||||||
export * from './src/types';
|
|
||||||
|
|
||||||
export function snapshot(n: Document): [serializedNodeWithId | null, idNodeMap];
|
|
||||||
export function rebuild(
|
|
||||||
n: serializedNodeWithId,
|
|
||||||
doc: Document,
|
|
||||||
): [Node | null, idNodeMap];
|
|
||||||
export function serializeNodeWithId(
|
|
||||||
n: Node,
|
|
||||||
doc: Document,
|
|
||||||
map: idNodeMap,
|
|
||||||
skipChild?: boolean,
|
|
||||||
): serializedNodeWithId | null;
|
|
||||||
export function resetId(): void;
|
|
||||||
export function buildNodeWithSN(
|
|
||||||
n: serializedNodeWithId,
|
|
||||||
doc: Document,
|
|
||||||
map: idNodeMap,
|
|
||||||
skipChild?: boolean,
|
|
||||||
): INode | null;
|
|
||||||
@@ -4,7 +4,8 @@
|
|||||||
"description": "rrweb's component to take a snapshot of DOM, aka DOM serializer",
|
"description": "rrweb's component to take a snapshot of DOM, aka DOM serializer",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register test/**/*.ts",
|
"test": "cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register test/**/*.ts",
|
||||||
"bundle": "rollup --config"
|
"bundle": "rollup --config",
|
||||||
|
"typings": "tsc -d --declarationDir typings"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -18,7 +19,7 @@
|
|||||||
"main": "lib/rrweb-snapshot.js",
|
"main": "lib/rrweb-snapshot.js",
|
||||||
"module": "es/rrweb-snapshot.js",
|
"module": "es/rrweb-snapshot.js",
|
||||||
"unpkg": "dist/rrweb-snapshot.js",
|
"unpkg": "dist/rrweb-snapshot.js",
|
||||||
"typings": "./index.d.ts",
|
"typings": "typings/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
"lib",
|
"lib",
|
||||||
|
|||||||
4
typings/index.d.ts
vendored
Normal file
4
typings/index.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import snapshot, { serializeNodeWithId, resetId } from './snapshot';
|
||||||
|
import rebuild, { buildNodeWithSN } from './rebuild';
|
||||||
|
export * from './types';
|
||||||
|
export { snapshot, serializeNodeWithId, resetId, rebuild, buildNodeWithSN };
|
||||||
5
typings/rebuild.d.ts
vendored
Normal file
5
typings/rebuild.d.ts
vendored
Normal file
@@ -0,0 +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): INode | null;
|
||||||
|
declare function rebuild(n: serializedNodeWithId, doc: Document): [Node | null, idNodeMap];
|
||||||
|
export default rebuild;
|
||||||
6
typings/snapshot.d.ts
vendored
Normal file
6
typings/snapshot.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { serializedNodeWithId, idNodeMap } from './types';
|
||||||
|
export declare function resetId(): void;
|
||||||
|
export declare function absoluteToStylesheet(cssText: string, href: string): string;
|
||||||
|
export declare function serializeNodeWithId(n: Node, doc: Document, map: idNodeMap, blockClass: string, skipChild?: boolean): serializedNodeWithId | null;
|
||||||
|
declare function snapshot(n: Document, blockClass?: string): [serializedNodeWithId | null, idNodeMap];
|
||||||
|
export default snapshot;
|
||||||
55
typings/types.d.ts
vendored
Normal file
55
typings/types.d.ts
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
export declare enum NodeType {
|
||||||
|
Document = 0,
|
||||||
|
DocumentType = 1,
|
||||||
|
Element = 2,
|
||||||
|
Text = 3,
|
||||||
|
CDATA = 4,
|
||||||
|
Comment = 5
|
||||||
|
}
|
||||||
|
export declare type documentNode = {
|
||||||
|
type: NodeType.Document;
|
||||||
|
childNodes: serializedNodeWithId[];
|
||||||
|
};
|
||||||
|
export declare type documentTypeNode = {
|
||||||
|
type: NodeType.DocumentType;
|
||||||
|
name: string;
|
||||||
|
publicId: string;
|
||||||
|
systemId: string;
|
||||||
|
};
|
||||||
|
export declare type attributes = {
|
||||||
|
[key: string]: string | boolean;
|
||||||
|
};
|
||||||
|
export declare type elementNode = {
|
||||||
|
type: NodeType.Element;
|
||||||
|
tagName: string;
|
||||||
|
attributes: attributes;
|
||||||
|
childNodes: serializedNodeWithId[];
|
||||||
|
isSVG?: true;
|
||||||
|
needBlock?: boolean;
|
||||||
|
};
|
||||||
|
export declare type textNode = {
|
||||||
|
type: NodeType.Text;
|
||||||
|
textContent: string;
|
||||||
|
isStyle?: true;
|
||||||
|
};
|
||||||
|
export declare type cdataNode = {
|
||||||
|
type: NodeType.CDATA;
|
||||||
|
textContent: '';
|
||||||
|
};
|
||||||
|
export declare type commentNode = {
|
||||||
|
type: NodeType.Comment;
|
||||||
|
textContent: string;
|
||||||
|
};
|
||||||
|
export declare type serializedNode = documentNode | documentTypeNode | elementNode | textNode | cdataNode | commentNode;
|
||||||
|
export declare type serializedNodeWithId = serializedNode & {
|
||||||
|
id: number;
|
||||||
|
};
|
||||||
|
export declare type tagMap = {
|
||||||
|
[key: string]: string;
|
||||||
|
};
|
||||||
|
export interface INode extends Node {
|
||||||
|
__sn: serializedNodeWithId;
|
||||||
|
}
|
||||||
|
export declare type idNodeMap = {
|
||||||
|
[key: number]: INode;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user