@@ -5,11 +5,7 @@ import Gradient from "./Gradient";
55import Text from "./Text" ;
66import Group from "./Group" ;
77import { RawImage } from "./Image" ;
8- import {
9- unstable_now as now ,
10- unstable_scheduleWork as scheduleDeferredCallback ,
11- unstable_cancelScheduledWork as cancelDeferredCallback
12- } from 'scheduler'
8+ import ReactDOMFrameScheduling from "./ReactDOMFrameScheduling" ;
139import ReactFiberReconciler from "react-reconciler" ;
1410import CanvasComponent from "./CanvasComponent" ;
1511import { getClosestInstanceFromNode } from "./ReactDOMComponentTree" ;
@@ -124,88 +120,86 @@ const CanvasHostConfig = {
124120 return emptyObject ;
125121 } ,
126122
127- scheduleDeferredCallback,
128- cancelDeferredCallback,
123+ scheduleDeferredCallback : ReactDOMFrameScheduling . rIC ,
129124
130125 shouldSetTextContent ( type , props ) {
131126 return (
132127 typeof props . children === "string" || typeof props . children === "number"
133128 ) ;
134129 } ,
135130
136- now,
131+ now : ReactDOMFrameScheduling . now ,
137132
138133 isPrimaryRenderer : false ,
139134
140135 useSyncScheduling : true ,
141136
142- supportsMutation : true ,
143-
144- // mutation
145- appendChild ( parentInstance , child ) {
146- const childLayer = child . getLayer ( ) ;
147- const parentLayer = parentInstance . getLayer ( ) ;
148-
149- if ( childLayer . parentLayer === parentLayer ) {
150- childLayer . moveToTop ( ) ;
151- } else {
152- childLayer . inject ( parentLayer ) ;
153- }
154-
155- parentLayer . invalidateLayout ( ) ;
156- } ,
157-
158- appendChildToContainer ( parentInstance , child ) {
159- const childLayer = child . getLayer ( ) ;
160- const parentLayer = parentInstance . getLayer ( ) ;
161-
162- if ( childLayer . parentLayer === parentLayer ) {
163- childLayer . moveToTop ( ) ;
164- } else {
165- childLayer . inject ( parentLayer ) ;
166- }
167-
168- parentLayer . invalidateLayout ( ) ;
169- } ,
170-
171- insertBefore ( parentInstance , child , beforeChild ) {
172- const parentLayer = parentInstance . getLayer ( ) ;
173- child . getLayer ( ) . injectBefore ( parentLayer , beforeChild . getLayer ( ) ) ;
174- parentLayer . invalidateLayout ( ) ;
175- } ,
176-
177- insertInContainerBefore ( parentInstance , child , beforeChild ) {
178- const parentLayer = parentInstance . getLayer ( ) ;
179- child . getLayer ( ) . injectBefore ( parentLayer , beforeChild . getLayer ( ) ) ;
180- parentLayer . invalidateLayout ( ) ;
181- } ,
182-
183- removeChild ( parentInstance , child ) {
184- const parentLayer = parentInstance . getLayer ( ) ;
185- child . getLayer ( ) . remove ( ) ;
186- freeComponentAndChildren ( child ) ;
187- parentLayer . invalidateLayout ( ) ;
188- } ,
189-
190- removeChildFromContainer ( parentInstance , child ) {
191- const parentLayer = parentInstance . getLayer ( ) ;
192- child . getLayer ( ) . remove ( ) ;
193- freeComponentAndChildren ( child ) ;
194- parentLayer . invalidateLayout ( ) ;
195- } ,
196-
197- commitTextUpdate ( /*textInstance, oldText, newText*/ ) {
198- // Noop
199- } ,
200-
201- commitMount ( /*instance, type, newProps*/ ) {
202- // Noop
203- } ,
204-
205- commitUpdate ( instance , updatePayload , type , oldProps , newProps ) {
206- if ( typeof instance . applyLayerProps !== "undefined" ) {
207- instance . applyLayerProps ( oldProps , newProps ) ;
208- instance . getLayer ( ) . invalidateLayout ( ) ;
137+ mutation : {
138+ appendChild ( parentInstance , child ) {
139+ const childLayer = child . getLayer ( ) ;
140+ const parentLayer = parentInstance . getLayer ( ) ;
141+
142+ if ( childLayer . parentLayer === parentLayer ) {
143+ childLayer . moveToTop ( ) ;
144+ } else {
145+ childLayer . inject ( parentLayer ) ;
146+ }
147+
148+ parentLayer . invalidateLayout ( ) ;
149+ } ,
150+
151+ appendChildToContainer ( parentInstance , child ) {
152+ const childLayer = child . getLayer ( ) ;
153+ const parentLayer = parentInstance . getLayer ( ) ;
154+
155+ if ( childLayer . parentLayer === parentLayer ) {
156+ childLayer . moveToTop ( ) ;
157+ } else {
158+ childLayer . inject ( parentLayer ) ;
159+ }
160+
161+ parentLayer . invalidateLayout ( ) ;
162+ } ,
163+
164+ insertBefore ( parentInstance , child , beforeChild ) {
165+ const parentLayer = parentInstance . getLayer ( ) ;
166+ child . getLayer ( ) . injectBefore ( parentLayer , beforeChild . getLayer ( ) ) ;
167+ parentLayer . invalidateLayout ( ) ;
168+ } ,
169+
170+ insertInContainerBefore ( parentInstance , child , beforeChild ) {
171+ const parentLayer = parentInstance . getLayer ( ) ;
172+ child . getLayer ( ) . injectBefore ( parentLayer , beforeChild . getLayer ( ) ) ;
173+ parentLayer . invalidateLayout ( ) ;
174+ } ,
175+
176+ removeChild ( parentInstance , child ) {
177+ const parentLayer = parentInstance . getLayer ( ) ;
178+ child . getLayer ( ) . remove ( ) ;
179+ freeComponentAndChildren ( child ) ;
180+ parentLayer . invalidateLayout ( ) ;
181+ } ,
182+
183+ removeChildFromContainer ( parentInstance , child ) {
184+ const parentLayer = parentInstance . getLayer ( ) ;
185+ child . getLayer ( ) . remove ( ) ;
186+ freeComponentAndChildren ( child ) ;
187+ parentLayer . invalidateLayout ( ) ;
188+ } ,
189+
190+ commitTextUpdate ( /*textInstance, oldText, newText*/ ) {
191+ // Noop
192+ } ,
193+
194+ commitMount ( /*instance, type, newProps*/ ) {
195+ // Noop
196+ } ,
197+
198+ commitUpdate ( instance , updatePayload , type , oldProps , newProps ) {
199+ if ( typeof instance . applyLayerProps !== "undefined" ) {
200+ instance . applyLayerProps ( oldProps , newProps ) ;
201+ instance . getLayer ( ) . invalidateLayout ( ) ;
202+ }
209203 }
210204 }
211205} ;
@@ -222,11 +216,8 @@ CanvasRenderer.injectIntoDevTools({
222216 }
223217} ) ;
224218
225- const registerComponentConstructor = ( name , ctor ) => {
219+ CanvasRenderer . registerComponentConstructor = ( name , ctor ) => {
226220 componentConstructors [ name ] = ctor ;
227221} ;
228222
229- export {
230- CanvasRenderer ,
231- registerComponentConstructor
232- } ;
223+ export default CanvasRenderer ;
0 commit comments