@@ -86,26 +86,27 @@ const flushPendingGroups = (
8686 pendingGroups . length = 0 ;
8787} ;
8888
89- const playGroup = ( ctx : DrawingContext , group : GroupCommand ) => {
90- "worklet" ;
91- const pending : PendingGroup [ ] = [ ] ;
92- group . children . forEach ( ( child ) => {
93- if ( isGroup ( child ) ) {
94- pending . push ( {
95- command : child ,
96- zIndex : getZIndex ( child ) ,
97- order : pending . length ,
98- } ) ;
99- return ;
100- }
89+ const play = ( ctx : DrawingContext , _command : Command ) => {
90+ // eslint-disable-next-line @typescript-eslint/no-shadow
91+ const playGroup = ( ctx : DrawingContext , group : GroupCommand ) => {
92+ "worklet" ;
93+ const pending : PendingGroup [ ] = [ ] ;
94+ group . children . forEach ( ( child ) => {
95+ if ( isGroup ( child ) ) {
96+ pending . push ( {
97+ command : child ,
98+ zIndex : getZIndex ( child ) ,
99+ order : pending . length ,
100+ } ) ;
101+ return ;
102+ }
103+ flushPendingGroups ( ctx , pending ) ;
104+ play ( ctx , child ) ;
105+ } ) ;
101106 flushPendingGroups ( ctx , pending ) ;
102- play ( ctx , child ) ;
103- } ) ;
104- flushPendingGroups ( ctx , pending ) ;
105- } ;
107+ } ;
106108
107- function play ( ctx : DrawingContext , _command : Command ) {
108- "worklet" ;
109+ ( "worklet" ) ;
109110 if ( isGroup ( _command ) ) {
110111 playGroup ( ctx , _command ) ;
111112 return ;
@@ -220,12 +221,11 @@ function play(ctx: DrawingContext, _command: Command) {
220221 ctx . paints . pop ( ) ;
221222 } ) ;
222223 }
223- }
224-
225- export const replay = ( ctx : DrawingContext , commands : Command [ ] ) => {
224+ } ;
225+ export function replay ( ctx : DrawingContext , commands : Command [ ] ) {
226226 "worklet" ;
227227 //console.log(debugTree(commands));
228228 commands . forEach ( ( command ) => {
229229 play ( ctx , command ) ;
230230 } ) ;
231- } ;
231+ }
0 commit comments