Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed Oct 15, 2022
1 parent a3e0036 commit c1b24e0
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 114 deletions.
2 changes: 1 addition & 1 deletion guide.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ setInterval(save, 10 * 1000);
| inlineImages | false | 是否将图片内容记内联录制 |
| collectFonts | false | 是否记录页面中的字体文件 |
| userTriggeredOnInput | false | [什么是 `userTriggered`](https://github.com/rrweb-io/rrweb/pull/495) |
| window | window | |
| window | window | |
| plugins | [] | 加载插件以获得额外的录制功能. [什么是插件?](./docs/recipes/plugin.zh_CN.md) |

#### 隐私
Expand Down
85 changes: 44 additions & 41 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,46 +94,46 @@ function record<T = eventWithTime>(
const maskInputOptions: MaskInputOptions =
maskAllInputs === true
? {
color: true,
date: true,
'datetime-local': true,
email: true,
month: true,
number: true,
range: true,
search: true,
tel: true,
text: true,
time: true,
url: true,
week: true,
textarea: true,
select: true,
password: true,
}
color: true,
date: true,
'datetime-local': true,
email: true,
month: true,
number: true,
range: true,
search: true,
tel: true,
text: true,
time: true,
url: true,
week: true,
textarea: true,
select: true,
password: true,
}
: _maskInputOptions !== undefined
? _maskInputOptions
: { password: true };
? _maskInputOptions
: { password: true };

const slimDOMOptions: SlimDOMOptions =
_slimDOMOptions === true || _slimDOMOptions === 'all'
? {
script: true,
comment: true,
headFavicon: true,
headWhitespace: true,
headMetaSocial: true,
headMetaRobots: true,
headMetaHttpEquiv: true,
headMetaVerification: true,
// the following are off for slimDOMOptions === true,
// as they destroy some (hidden) info:
headMetaAuthorship: _slimDOMOptions === 'all',
headMetaDescKeywords: _slimDOMOptions === 'all',
}
script: true,
comment: true,
headFavicon: true,
headWhitespace: true,
headMetaSocial: true,
headMetaRobots: true,
headMetaHttpEquiv: true,
headMetaVerification: true,
// the following are off for slimDOMOptions === true,
// as they destroy some (hidden) info:
headMetaAuthorship: _slimDOMOptions === 'all',
headMetaDescKeywords: _slimDOMOptions === 'all',
}
: _slimDOMOptions
? _slimDOMOptions
: {};
? _slimDOMOptions
: {};

polyfill();

Expand Down Expand Up @@ -353,24 +353,27 @@ function record<T = eventWithTime>(
win.pageXOffset !== undefined
? win.pageXOffset
: win.document?.documentElement.scrollLeft ||
win.document?.body?.parentElement?.scrollLeft ||
win.document?.body?.scrollLeft ||
0,
win.document?.body?.parentElement?.scrollLeft ||
win.document?.body?.scrollLeft ||
0,
top:
win.pageYOffset !== undefined
? win.pageYOffset
: win.document?.documentElement.scrollTop ||
win.document?.body?.parentElement?.scrollTop ||
win.document?.body?.scrollTop ||
0,
win.document?.body?.parentElement?.scrollTop ||
win.document?.body?.scrollTop ||
0,
},
},
}),
);
mutationBuffers.forEach((buf) => buf.unlock()); // generate & emit any mutations that happened during snapshotting, as can now apply against the newly built mirror

// Some old browsers don't support adoptedStyleSheets.
if (win.document.adoptedStyleSheets && win.document.adoptedStyleSheets.length > 0)
if (
win.document.adoptedStyleSheets &&
win.document.adoptedStyleSheets.length > 0
)
stylesheetManager.adoptStyleSheets(
win.document.adoptedStyleSheets,
mirror.getId(win.document),
Expand Down
5 changes: 4 additions & 1 deletion packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ export default class MutationBuffer {
);
}
if (hasShadowRoot(n)) {
this.shadowDomManager.addShadowRoot(n.shadowRoot, this.window.document);
this.shadowDomManager.addShadowRoot(
n.shadowRoot,
this.window.document,
);
}
},
onIframeLoad: (iframe, childSn) => {
Expand Down
14 changes: 7 additions & 7 deletions packages/rrweb/src/record/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function initMutationObserver(
if (
angularZoneSymbol &&
((options.window as unknown) as Record<string, typeof MutationObserver>)[
angularZoneSymbol
angularZoneSymbol
]
) {
mutationObserverCtor = ((options.window as unknown) as Record<
Expand Down Expand Up @@ -187,8 +187,8 @@ function initMoveObserver({
typeof DragEvent !== 'undefined' && evt instanceof DragEvent
? IncrementalSource.Drag
: evt instanceof MouseEvent
? IncrementalSource.MouseMove
: IncrementalSource.TouchMove,
? IncrementalSource.MouseMove
: IncrementalSource.TouchMove,
);
},
threshold,
Expand Down Expand Up @@ -221,7 +221,7 @@ function initMouseInteractionObserver({
}
const disableMap: Record<string, boolean | undefined> =
sampling.mouseInteraction === true ||
sampling.mouseInteraction === undefined
sampling.mouseInteraction === undefined
? {}
: sampling.mouseInteraction;

Expand Down Expand Up @@ -369,7 +369,7 @@ function initInputObserver({
isChecked = (target as HTMLInputElement).checked;
} else if (
maskInputOptions[
(target as Element).tagName.toLowerCase() as keyof MaskInputOptions
(target as Element).tagName.toLowerCase() as keyof MaskInputOptions
] ||
maskInputOptions[type as keyof MaskInputOptions]
) {
Expand Down Expand Up @@ -1131,8 +1131,8 @@ export function initObservers(
const fontObserver = o.collectFonts
? initFontObserver(o)
: () => {
//
};
//
};
const selectionObserver = initSelectionObserver(o);

// plugins
Expand Down
4 changes: 2 additions & 2 deletions packages/rrweb/src/record/shadow-dom-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type BypassOptions = Omit<
};

export class ShadowDomManager {
private win: IWindow
private win: IWindow;
private shadowDoms = new WeakSet<ShadowRoot>();
private mutationCb: mutationCallBack;
private scrollCb: scrollCallback;
Expand All @@ -31,7 +31,7 @@ export class ShadowDomManager {
private restorePatches: (() => void)[] = [];

constructor(options: {
win: IWindow,
win: IWindow;
mutationCb: mutationCallBack;
scrollCb: scrollCallback;
bypassOptions: BypassOptions;
Expand Down
84 changes: 42 additions & 42 deletions packages/rrweb/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ export type mutationData = {

export type mousemoveData = {
source:
| IncrementalSource.MouseMove
| IncrementalSource.TouchMove
| IncrementalSource.Drag;
| IncrementalSource.MouseMove
| IncrementalSource.TouchMove
| IncrementalSource.Drag;
positions: mousePosition[];
};

Expand Down Expand Up @@ -300,7 +300,7 @@ export type observerParam = {
collectFonts: boolean;
slimDOMOptions: SlimDOMOptions;
dataURLOptions: DataURLOptions;
window: IWindow,
window: IWindow;
doc: Document;
mirror: Mirror;
iframeManager: IframeManager;
Expand Down Expand Up @@ -465,26 +465,26 @@ export enum CanvasContext {

export type SerializedCanvasArg =
| {
rr_type: 'ArrayBuffer';
base64: string; // base64
}
rr_type: 'ArrayBuffer';
base64: string; // base64
}
| {
rr_type: 'Blob';
data: Array<CanvasArg>;
type?: string;
}
rr_type: 'Blob';
data: Array<CanvasArg>;
type?: string;
}
| {
rr_type: string;
src: string; // url of image
}
rr_type: string;
src: string; // url of image
}
| {
rr_type: string;
args: Array<CanvasArg>;
}
rr_type: string;
args: Array<CanvasArg>;
}
| {
rr_type: string;
index: number;
};
rr_type: string;
index: number;
};

export type CanvasArg =
| SerializedCanvasArg
Expand Down Expand Up @@ -569,14 +569,14 @@ export type canvasMutationCommand = {

export type canvasMutationParam =
| {
id: number;
type: CanvasContext;
commands: canvasMutationCommand[];
}
id: number;
type: CanvasContext;
commands: canvasMutationCommand[];
}
| ({
id: number;
type: CanvasContext;
} & canvasMutationCommand);
id: number;
type: CanvasContext;
} & canvasMutationCommand);

export type canvasMutationWithType = {
type: CanvasContext;
Expand All @@ -599,15 +599,15 @@ export type ImageBitmapDataURLWorkerParams = {

export type ImageBitmapDataURLWorkerResponse =
| {
id: number;
}
id: number;
}
| {
id: number;
type: string;
base64: string;
width: number;
height: number;
};
id: number;
type: string;
base64: string;
width: number;
height: number;
};

export type fontParam = {
family: string;
Expand Down Expand Up @@ -725,13 +725,13 @@ export type playerConfig = {
UNSAFE_replayCanvas: boolean;
pauseAnimation?: boolean;
mouseTail:
| boolean
| {
duration?: number;
lineCap?: string;
lineWidth?: number;
strokeStyle?: string;
};
| boolean
| {
duration?: number;
lineCap?: string;
lineWidth?: number;
strokeStyle?: string;
};
unpackFn?: UnpackFn;
useVirtualDom: boolean;
plugins?: ReplayPlugin[];
Expand Down
Loading

0 comments on commit c1b24e0

Please sign in to comment.