export utils as public API

This commit is contained in:
Yanzhen Yu
2020-06-15 17:10:18 +08:00
parent 7feb2c945c
commit 4cf196718c
7 changed files with 16 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
import record from './record';
import { Replayer } from './replay';
import { mirror } from './utils';
import * as utils from './utils';
export {
EventType,
@@ -11,4 +12,4 @@ export {
const { addCustomEvent } = record;
export { record, addCustomEvent, Replayer, mirror };
export { record, addCustomEvent, Replayer, mirror, utils };

View File

@@ -181,8 +181,8 @@ function initViewportResizeObserver(
return on('resize', updateDimension, window);
}
const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
const MASK_TYPES = [
export const INPUT_TAGS = ['INPUT', 'TEXTAREA', 'SELECT'];
export const MASK_TYPES = [
'color',
'date',
'datetime-local',

View File

@@ -1,4 +1,4 @@
import { rebuild, buildNodeWithSN, idNodeMap } from 'rrweb-snapshot';
import { rebuild, buildNodeWithSN } from 'rrweb-snapshot';
import * as mittProxy from 'mitt';
import * as smoothscroll from 'smoothscroll-polyfill';
import { Timer } from './timer';

View File

@@ -34,7 +34,7 @@ export const mirror: Mirror = {
const id = n.__sn && n.__sn.id;
delete mirror.map[id];
if (n.childNodes) {
n.childNodes.forEach(child =>
n.childNodes.forEach((child) =>
mirror.removeNodeFromMap((child as Node) as INode),
);
}
@@ -53,7 +53,7 @@ export function throttle<T>(
let timeout: number | null = null;
let previous = 0;
// tslint:disable-next-line: only-arrow-functions
return function(arg: T) {
return function (arg: T) {
let now = Date.now();
if (!previous && options.leading === false) {
previous = now;
@@ -83,9 +83,10 @@ export function hookSetter<T>(
key: string | number | symbol,
d: PropertyDescriptor,
isRevoked?: boolean,
win = window,
): hookResetter {
const original = Object.getOwnPropertyDescriptor(target, key);
Object.defineProperty(
const original = win.Object.getOwnPropertyDescriptor(target, key);
win.Object.defineProperty(
target,
key,
isRevoked
@@ -130,7 +131,7 @@ export function isBlocked(node: Node | null, blockClass: blockClass): boolean {
if (typeof blockClass === 'string') {
needBlock = (node as HTMLElement).classList.contains(blockClass);
} else {
(node as HTMLElement).classList.forEach(className => {
(node as HTMLElement).classList.forEach((className) => {
if (blockClass.test(className)) {
needBlock = true;
}