Skip to content

Commit 7a31a7e

Browse files
mydeabillyvg
authored andcommitted
feat: Remove hooks related code, which is not used (#126)
We do not use this, so removing this reduces some overhead & bundle size.
1 parent 49fec35 commit 7a31a7e

3 files changed

Lines changed: 125 additions & 242 deletions

File tree

packages/rrweb/src/record/index.ts

Lines changed: 120 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ function record<T = eventWithTime>(
9090
maskAttributeFn,
9191
maskInputFn,
9292
maskTextFn,
93-
hooks,
9493
packFn,
9594
sampling = {},
9695
dataURLOptions = {},
@@ -454,130 +453,127 @@ function record<T = eventWithTime>(
454453
const handlers: listenerHandler[] = [];
455454

456455
const observe = (doc: Document) => {
457-
return callbackWrapper(initObservers)(
458-
{
459-
onMutation,
460-
mutationCb: wrappedMutationEmit,
461-
mousemoveCb: (positions, source) =>
462-
wrappedEmit({
463-
type: EventType.IncrementalSnapshot,
464-
data: {
465-
source,
466-
positions,
467-
},
468-
}),
469-
mouseInteractionCb: (d) =>
470-
wrappedEmit({
471-
type: EventType.IncrementalSnapshot,
472-
data: {
473-
source: IncrementalSource.MouseInteraction,
474-
...d,
475-
},
476-
}),
477-
scrollCb: wrappedScrollEmit,
478-
viewportResizeCb: (d) =>
479-
wrappedEmit({
480-
type: EventType.IncrementalSnapshot,
481-
data: {
482-
source: IncrementalSource.ViewportResize,
483-
...d,
484-
},
485-
}),
486-
inputCb: (v) =>
487-
wrappedEmit({
488-
type: EventType.IncrementalSnapshot,
489-
data: {
490-
source: IncrementalSource.Input,
491-
...v,
492-
},
493-
}),
494-
mediaInteractionCb: (p) =>
495-
wrappedEmit({
496-
type: EventType.IncrementalSnapshot,
497-
data: {
498-
source: IncrementalSource.MediaInteraction,
499-
...p,
500-
},
501-
}),
502-
styleSheetRuleCb: (r) =>
503-
wrappedEmit({
504-
type: EventType.IncrementalSnapshot,
505-
data: {
506-
source: IncrementalSource.StyleSheetRule,
507-
...r,
508-
},
509-
}),
510-
styleDeclarationCb: (r) =>
511-
wrappedEmit({
512-
type: EventType.IncrementalSnapshot,
513-
data: {
514-
source: IncrementalSource.StyleDeclaration,
515-
...r,
516-
},
517-
}),
518-
canvasMutationCb: wrappedCanvasMutationEmit,
519-
fontCb: (p) =>
520-
wrappedEmit({
521-
type: EventType.IncrementalSnapshot,
522-
data: {
523-
source: IncrementalSource.Font,
524-
...p,
525-
},
526-
}),
527-
selectionCb: (p) => {
528-
wrappedEmit({
529-
type: EventType.IncrementalSnapshot,
530-
data: {
531-
source: IncrementalSource.Selection,
532-
...p,
533-
},
534-
});
535-
},
536-
customElementCb: (c) => {
537-
wrappedEmit({
538-
type: EventType.IncrementalSnapshot,
539-
data: {
540-
source: IncrementalSource.CustomElement,
541-
...c,
542-
},
543-
});
544-
},
545-
blockClass,
546-
ignoreClass,
547-
ignoreSelector,
548-
maskAllText,
549-
maskTextClass,
550-
unmaskTextClass,
551-
maskTextSelector,
552-
unmaskTextSelector,
553-
maskInputOptions,
554-
inlineStylesheet,
555-
sampling,
556-
recordDOM,
557-
recordCanvas,
558-
inlineImages,
559-
userTriggeredOnInput,
560-
collectFonts,
561-
doc,
562-
maskAttributeFn,
563-
maskInputFn,
564-
maskTextFn,
565-
keepIframeSrcFn,
566-
blockSelector,
567-
unblockSelector,
568-
slimDOMOptions,
569-
dataURLOptions,
570-
mirror,
571-
iframeManager,
572-
stylesheetManager,
573-
shadowDomManager,
574-
processedNodeManager,
575-
canvasManager,
576-
ignoreCSSAttributes,
577-
plugins: [],
456+
return callbackWrapper(initObservers)({
457+
onMutation,
458+
mutationCb: wrappedMutationEmit,
459+
mousemoveCb: (positions, source) =>
460+
wrappedEmit({
461+
type: EventType.IncrementalSnapshot,
462+
data: {
463+
source,
464+
positions,
465+
},
466+
}),
467+
mouseInteractionCb: (d) =>
468+
wrappedEmit({
469+
type: EventType.IncrementalSnapshot,
470+
data: {
471+
source: IncrementalSource.MouseInteraction,
472+
...d,
473+
},
474+
}),
475+
scrollCb: wrappedScrollEmit,
476+
viewportResizeCb: (d) =>
477+
wrappedEmit({
478+
type: EventType.IncrementalSnapshot,
479+
data: {
480+
source: IncrementalSource.ViewportResize,
481+
...d,
482+
},
483+
}),
484+
inputCb: (v) =>
485+
wrappedEmit({
486+
type: EventType.IncrementalSnapshot,
487+
data: {
488+
source: IncrementalSource.Input,
489+
...v,
490+
},
491+
}),
492+
mediaInteractionCb: (p) =>
493+
wrappedEmit({
494+
type: EventType.IncrementalSnapshot,
495+
data: {
496+
source: IncrementalSource.MediaInteraction,
497+
...p,
498+
},
499+
}),
500+
styleSheetRuleCb: (r) =>
501+
wrappedEmit({
502+
type: EventType.IncrementalSnapshot,
503+
data: {
504+
source: IncrementalSource.StyleSheetRule,
505+
...r,
506+
},
507+
}),
508+
styleDeclarationCb: (r) =>
509+
wrappedEmit({
510+
type: EventType.IncrementalSnapshot,
511+
data: {
512+
source: IncrementalSource.StyleDeclaration,
513+
...r,
514+
},
515+
}),
516+
canvasMutationCb: wrappedCanvasMutationEmit,
517+
fontCb: (p) =>
518+
wrappedEmit({
519+
type: EventType.IncrementalSnapshot,
520+
data: {
521+
source: IncrementalSource.Font,
522+
...p,
523+
},
524+
}),
525+
selectionCb: (p) => {
526+
wrappedEmit({
527+
type: EventType.IncrementalSnapshot,
528+
data: {
529+
source: IncrementalSource.Selection,
530+
...p,
531+
},
532+
});
578533
},
579-
hooks,
580-
);
534+
customElementCb: (c) => {
535+
wrappedEmit({
536+
type: EventType.IncrementalSnapshot,
537+
data: {
538+
source: IncrementalSource.CustomElement,
539+
...c,
540+
},
541+
});
542+
},
543+
blockClass,
544+
ignoreClass,
545+
ignoreSelector,
546+
maskAllText,
547+
maskTextClass,
548+
unmaskTextClass,
549+
maskTextSelector,
550+
unmaskTextSelector,
551+
maskInputOptions,
552+
inlineStylesheet,
553+
sampling,
554+
recordDOM,
555+
recordCanvas,
556+
inlineImages,
557+
userTriggeredOnInput,
558+
collectFonts,
559+
doc,
560+
maskAttributeFn,
561+
maskInputFn,
562+
maskTextFn,
563+
keepIframeSrcFn,
564+
blockSelector,
565+
unblockSelector,
566+
slimDOMOptions,
567+
dataURLOptions,
568+
mirror,
569+
iframeManager,
570+
stylesheetManager,
571+
shadowDomManager,
572+
processedNodeManager,
573+
canvasManager,
574+
ignoreCSSAttributes,
575+
plugins: [],
576+
});
581577
};
582578

583579
iframeManager.addLoadListener((iframeEl) => {

0 commit comments

Comments
 (0)