@@ -5,7 +5,11 @@ import Gradient from "./Gradient";
5
5
import Text from "./Text" ;
6
6
import Group from "./Group" ;
7
7
import { RawImage } from "./Image" ;
8
- import ReactDOMFrameScheduling from "./ReactDOMFrameScheduling" ;
8
+ import {
9
+ unstable_now as now ,
10
+ unstable_scheduleWork as scheduleDeferredCallback ,
11
+ unstable_cancelScheduledWork as cancelDeferredCallback
12
+ } from 'scheduler'
9
13
import ReactFiberReconciler from "react-reconciler" ;
10
14
import CanvasComponent from "./CanvasComponent" ;
11
15
import { getClosestInstanceFromNode } from "./ReactDOMComponentTree" ;
@@ -120,86 +124,88 @@ const CanvasHostConfig = {
120
124
return emptyObject ;
121
125
} ,
122
126
123
- scheduleDeferredCallback : ReactDOMFrameScheduling . rIC ,
127
+ scheduleDeferredCallback,
128
+ cancelDeferredCallback,
124
129
125
130
shouldSetTextContent ( type , props ) {
126
131
return (
127
132
typeof props . children === "string" || typeof props . children === "number"
128
133
) ;
129
134
} ,
130
135
131
- now : ReactDOMFrameScheduling . now ,
136
+ now,
132
137
133
138
isPrimaryRenderer : false ,
134
139
135
140
useSyncScheduling : true ,
136
141
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
- }
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 ( ) ;
203
209
}
204
210
}
205
211
} ;
@@ -216,8 +222,11 @@ CanvasRenderer.injectIntoDevTools({
216
222
}
217
223
} ) ;
218
224
219
- CanvasRenderer . registerComponentConstructor = ( name , ctor ) => {
225
+ const registerComponentConstructor = ( name , ctor ) => {
220
226
componentConstructors [ name ] = ctor ;
221
227
} ;
222
228
223
- export default CanvasRenderer ;
229
+ export {
230
+ CanvasRenderer ,
231
+ registerComponentConstructor
232
+ } ;
0 commit comments