@@ -202,8 +202,10 @@ export class Replayer {
202202
203203    /** 
204204     * Exposes mirror to the plugins 
205-      * We ignore plugins here, as we don't have any 
206205     */ 
206+     for  ( const  plugin  of  this . config . plugins  ||  [ ] )  { 
207+       if  ( plugin . getMirror )  plugin . getMirror ( {  nodeMirror : this . mirror  } ) ; 
208+     } 
207209
208210    this . emitter . on ( ReplayerEvents . Flush ,  ( )  =>  { 
209211      if  ( this . usingVirtualDom )  { 
@@ -234,7 +236,11 @@ export class Replayer {
234236            else  if  ( data . source  ===  IncrementalSource . StyleDeclaration ) 
235237              this . applyStyleDeclaration ( data ,  styleSheet ) ; 
236238          } , 
237-           // we ignore plugins here, as we don't have any 
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+           } , 
238244        } ; 
239245        if  ( this . iframe . contentDocument ) 
240246          try  { 
@@ -717,7 +723,9 @@ export class Replayer {
717723        castFn ( ) ; 
718724      } 
719725
720-       // we ignore plugins here, as we don't have any 
726+       for  ( const  plugin  of  this . config . plugins  ||  [ ] )  { 
727+         if  ( plugin . handler )  plugin . handler ( event ,  isSync ,  {  replayer : this  } ) ; 
728+       } 
721729
722730      this . service . send ( {  type : 'CAST_EVENT' ,  payload : {  event }  } ) ; 
723731
@@ -770,7 +778,13 @@ export class Replayer {
770778    const  collected : AppendedIframe [ ]  =  [ ] ; 
771779    const  afterAppend  =  ( builtNode : Node ,  id : number )  =>  { 
772780      this . collectIframeAndAttachDocument ( collected ,  builtNode ) ; 
773-       // we ignore plugins here, as we don't have any 
781+       for  ( const  plugin  of  this . config . plugins  ||  [ ] )  { 
782+         if  ( plugin . onBuild ) 
783+           plugin . onBuild ( builtNode ,  { 
784+             id, 
785+             replayer : this , 
786+           } ) ; 
787+       } 
774788    } ; 
775789
776790    /** 
@@ -863,7 +877,7 @@ export class Replayer {
863877    type  TMirror  =  typeof  mirror  extends  Mirror  ? Mirror  : RRDOMMirror ; 
864878
865879    const  collected : AppendedIframe [ ]  =  [ ] ; 
866-     const  afterAppend  =  ( builtNode : Node ,  _id : number )  =>  { 
880+     const  afterAppend  =  ( builtNode : Node ,  id : number )  =>  { 
867881      this . collectIframeAndAttachDocument ( collected ,  builtNode ) ; 
868882      const  sn  =  ( mirror  as  TMirror ) . getMeta ( builtNode  as  unknown  as  TNode ) ; 
869883      if  ( 
@@ -878,7 +892,14 @@ export class Replayer {
878892      } 
879893
880894      // Skip the plugin onBuild callback in the virtual dom mode 
881-       // we ignore plugins here, as we don't have any 
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+       } 
882903    } ; 
883904
884905    buildNodeWithSN ( mutation . node ,  { 
@@ -1498,7 +1519,13 @@ export class Replayer {
14981519        ) ; 
14991520        return ; 
15001521      } 
1501-       // we ignore plugins here, as we don't have any 
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+       } ; 
15021529
15031530      const  target  =  buildNodeWithSN ( mutation . node ,  { 
15041531        doc : targetDoc  as  Document ,  // can be Document or RRDocument 
@@ -1510,6 +1537,7 @@ export class Replayer {
15101537         * caveat: `afterAppend` only gets called on child nodes of target 
15111538         * we have to call it again below when this target was added to the DOM 
15121539         */ 
1540+         afterAppend, 
15131541      } )  as  Node  |  RRNode ; 
15141542
15151543      // legacy data, we should not have -1 siblings any more 
@@ -1584,7 +1612,10 @@ export class Replayer {
15841612      }  else  { 
15851613        ( parent  as  TNode ) . appendChild ( target  as  TNode ) ; 
15861614      } 
1587-       // we ignore plugins here, as we don't have any 
1615+       /** 
1616+        * target was added, execute plugin hooks 
1617+        */ 
1618+       afterAppend ( target ,  mutation . node . id ) ; 
15881619
15891620      /** 
15901621       * https://github.com/rrweb-io/rrweb/pull/887 
0 commit comments