Skip to content

Commit 2bfd19f

Browse files
committed
feat: Remove plugins related code, which is not used
1 parent 6987090 commit 2bfd19f

File tree

4 files changed

+12
-366
lines changed

4 files changed

+12
-366
lines changed

packages/rrweb/src/record/index.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ function record<T = eventWithTime>(
109109
userTriggeredOnInput = false,
110110
collectFonts = false,
111111
inlineImages = false,
112-
plugins,
113112
keepIframeSrcFn = () => false,
114113
ignoreCSSAttributes = new Set([]),
115114
errorHandler,
@@ -197,11 +196,7 @@ function record<T = eventWithTime>(
197196
let incrementalSnapshotCount = 0;
198197

199198
const eventProcessor = (e: eventWithTime): T => {
200-
for (const plugin of plugins || []) {
201-
if (plugin.eventProcessor) {
202-
e = plugin.eventProcessor(e);
203-
}
204-
}
199+
// We ignore plugins here, as we do not have any
205200
if (
206201
packFn &&
207202
// Disable packing events which will be emitted to parent frames.
@@ -322,16 +317,8 @@ function record<T = eventWithTime>(
322317

323318
/**
324319
* Exposes mirror to the plugins
320+
* We ignore plugins here, as we don't use any
325321
*/
326-
for (const plugin of plugins || []) {
327-
if (plugin.getMirror)
328-
plugin.getMirror({
329-
nodeMirror: mirror,
330-
crossOriginIframeMirror: iframeManager.crossOriginIframeMirror,
331-
crossOriginIframeStyleMirror:
332-
iframeManager.crossOriginIframeStyleMirror,
333-
});
334-
}
335322

336323
const processedNodeManager = new ProcessedNodeManager();
337324

@@ -612,23 +599,7 @@ function record<T = eventWithTime>(
612599
processedNodeManager,
613600
canvasManager,
614601
ignoreCSSAttributes,
615-
plugins:
616-
plugins
617-
?.filter((p) => p.observer)
618-
?.map((p) => ({
619-
observer: p.observer!,
620-
options: p.options,
621-
callback: (payload: object) =>
622-
wrappedEmit(
623-
wrapEvent({
624-
type: EventType.Plugin,
625-
data: {
626-
plugin: p.name,
627-
payload,
628-
},
629-
}),
630-
),
631-
})) || [],
602+
plugins: [],
632603
},
633604
hooks,
634605
);

packages/rrweb/src/record/observer.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,12 +1440,7 @@ export function initObservers(
14401440
const customElementObserver = initCustomElementObserver(o);
14411441

14421442
// plugins
1443-
const pluginHandlers: listenerHandler[] = [];
1444-
for (const plugin of o.plugins) {
1445-
pluginHandlers.push(
1446-
plugin.observer(plugin.callback, currentWindow, plugin.options),
1447-
);
1448-
}
1443+
// we ignore plugins here, as we don't have any
14491444

14501445
return callbackWrapper(() => {
14511446
mutationBuffers.forEach((b) => b.reset());
@@ -1462,7 +1457,6 @@ export function initObservers(
14621457
fontObserver();
14631458
selectionObserver();
14641459
customElementObserver();
1465-
pluginHandlers.forEach((h) => h());
14661460
});
14671461
}
14681462

packages/rrweb/src/replay/index.ts

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,8 @@ export class Replayer {
202202

203203
/**
204204
* Exposes mirror to the plugins
205+
* We ignore plugins here, as we don't have any
205206
*/
206-
for (const plugin of this.config.plugins || []) {
207-
if (plugin.getMirror) plugin.getMirror({ nodeMirror: this.mirror });
208-
}
209207

210208
this.emitter.on(ReplayerEvents.Flush, () => {
211209
if (this.usingVirtualDom) {
@@ -236,11 +234,7 @@ export class Replayer {
236234
else if (data.source === IncrementalSource.StyleDeclaration)
237235
this.applyStyleDeclaration(data, styleSheet);
238236
},
239-
afterAppend: (node: Node, id: number) => {
240-
for (const plugin of this.config.plugins || []) {
241-
if (plugin.onBuild) plugin.onBuild(node, { id, replayer: this });
242-
}
243-
},
237+
// we ignore plugins here, as we don't have any
244238
};
245239
if (this.iframe.contentDocument)
246240
try {
@@ -723,9 +717,7 @@ export class Replayer {
723717
castFn();
724718
}
725719

726-
for (const plugin of this.config.plugins || []) {
727-
if (plugin.handler) plugin.handler(event, isSync, { replayer: this });
728-
}
720+
// we ignore plugins here, as we don't have any
729721

730722
this.service.send({ type: 'CAST_EVENT', payload: { event } });
731723

@@ -778,13 +770,7 @@ export class Replayer {
778770
const collected: AppendedIframe[] = [];
779771
const afterAppend = (builtNode: Node, id: number) => {
780772
this.collectIframeAndAttachDocument(collected, builtNode);
781-
for (const plugin of this.config.plugins || []) {
782-
if (plugin.onBuild)
783-
plugin.onBuild(builtNode, {
784-
id,
785-
replayer: this,
786-
});
787-
}
773+
// we ignore plugins here, as we don't have any
788774
};
789775

790776
/**
@@ -877,7 +863,7 @@ export class Replayer {
877863
type TMirror = typeof mirror extends Mirror ? Mirror : RRDOMMirror;
878864

879865
const collected: AppendedIframe[] = [];
880-
const afterAppend = (builtNode: Node, id: number) => {
866+
const afterAppend = (builtNode: Node, _id: number) => {
881867
this.collectIframeAndAttachDocument(collected, builtNode);
882868
const sn = (mirror as TMirror).getMeta(builtNode as unknown as TNode);
883869
if (
@@ -892,14 +878,7 @@ export class Replayer {
892878
}
893879

894880
// Skip the plugin onBuild callback in the virtual dom mode
895-
if (this.usingVirtualDom) return;
896-
for (const plugin of this.config.plugins || []) {
897-
if (plugin.onBuild)
898-
plugin.onBuild(builtNode, {
899-
id,
900-
replayer: this,
901-
});
902-
}
881+
// we ignore plugins here, as we don't have any
903882
};
904883

905884
buildNodeWithSN(mutation.node, {
@@ -1519,13 +1498,7 @@ export class Replayer {
15191498
);
15201499
return;
15211500
}
1522-
const afterAppend = (node: Node | RRNode, id: number) => {
1523-
// Skip the plugin onBuild callback for virtual dom
1524-
if (this.usingVirtualDom) return;
1525-
for (const plugin of this.config.plugins || []) {
1526-
if (plugin.onBuild) plugin.onBuild(node, { id, replayer: this });
1527-
}
1528-
};
1501+
// we ignore plugins here, as we don't have any
15291502

15301503
const target = buildNodeWithSN(mutation.node, {
15311504
doc: targetDoc as Document, // can be Document or RRDocument
@@ -1537,7 +1510,6 @@ export class Replayer {
15371510
* caveat: `afterAppend` only gets called on child nodes of target
15381511
* we have to call it again below when this target was added to the DOM
15391512
*/
1540-
afterAppend,
15411513
}) as Node | RRNode;
15421514

15431515
// legacy data, we should not have -1 siblings any more
@@ -1612,10 +1584,7 @@ export class Replayer {
16121584
} else {
16131585
(parent as TNode).appendChild(target as TNode);
16141586
}
1615-
/**
1616-
* target was added, execute plugin hooks
1617-
*/
1618-
afterAppend(target, mutation.node.id);
1587+
// we ignore plugins here, as we don't have any
16191588

16201589
/**
16211590
* https://github.com/rrweb-io/rrweb/pull/887

0 commit comments

Comments
 (0)