universal-test-renderer 0.2.0 → 0.3.1-react19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +183 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +188 -70
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
8
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
9
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
10
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
11
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
12
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
13
|
+
var __spreadValues = (a, b) => {
|
|
14
|
+
for (var prop in b || (b = {}))
|
|
15
|
+
if (__hasOwnProp.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
if (__getOwnPropSymbols)
|
|
18
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
19
|
+
if (__propIsEnum.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
}
|
|
22
|
+
return a;
|
|
23
|
+
};
|
|
24
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
10
25
|
var __objRest = (source, exclude) => {
|
|
11
26
|
var target = {};
|
|
12
27
|
for (var prop in source)
|
|
@@ -70,8 +85,8 @@ function formatComponentList(names) {
|
|
|
70
85
|
}
|
|
71
86
|
|
|
72
87
|
// src/reconciler.ts
|
|
73
|
-
var UPDATE_SIGNAL = {};
|
|
74
88
|
var nodeToInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
89
|
+
var currentUpdatePriority = import_constants.NoEventPriority;
|
|
75
90
|
var hostConfig = {
|
|
76
91
|
/**
|
|
77
92
|
* The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
|
|
@@ -112,6 +127,8 @@ var hostConfig = {
|
|
|
112
127
|
*/
|
|
113
128
|
supportsPersistence: false,
|
|
114
129
|
/**
|
|
130
|
+
* #### `createInstance(type, props, rootContainer, hostContext, internalHandle)`
|
|
131
|
+
*
|
|
115
132
|
* This method should return a newly created node. For example, the DOM renderer would call
|
|
116
133
|
* `document.createElement(type)` here and then set the properties from `props`.
|
|
117
134
|
*
|
|
@@ -144,14 +161,16 @@ var hostConfig = {
|
|
|
144
161
|
};
|
|
145
162
|
},
|
|
146
163
|
/**
|
|
164
|
+
* #### `createTextInstance(text, rootContainer, hostContext, internalHandle)`
|
|
165
|
+
*
|
|
147
166
|
* Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can
|
|
148
167
|
* throw here.
|
|
149
168
|
*/
|
|
150
169
|
createTextInstance(text, rootContainer, hostContext, _internalHandle) {
|
|
151
|
-
if (rootContainer.textComponents && !hostContext.isInsideText) {
|
|
170
|
+
if (rootContainer.config.textComponents && !hostContext.isInsideText) {
|
|
152
171
|
throw new Error(
|
|
153
172
|
`Invariant Violation: Text strings must be rendered within a ${formatComponentList(
|
|
154
|
-
rootContainer.textComponents
|
|
173
|
+
rootContainer.config.textComponents
|
|
155
174
|
)} component. Detected attempt to render "${text}" string within a <${hostContext.type}> component.`
|
|
156
175
|
);
|
|
157
176
|
}
|
|
@@ -162,8 +181,20 @@ var hostConfig = {
|
|
|
162
181
|
isHidden: false
|
|
163
182
|
};
|
|
164
183
|
},
|
|
184
|
+
/**
|
|
185
|
+
* #### `appendInitialChild(parentInstance, child)`
|
|
186
|
+
*
|
|
187
|
+
* This method should mutate the `parentInstance` and add the child to its list of children.
|
|
188
|
+
* For example, in the DOM this would translate to a `parentInstance.appendChild(child)` call.
|
|
189
|
+
*
|
|
190
|
+
* This method happens **in the render phase**. It can mutate `parentInstance` and `child`, but it
|
|
191
|
+
* must not modify any other nodes. It's called while the tree is still being built up and not connected
|
|
192
|
+
* to the actual tree on the screen.
|
|
193
|
+
*/
|
|
165
194
|
appendInitialChild: appendChild,
|
|
166
195
|
/**
|
|
196
|
+
* #### `finalizeInitialChildren(instance, type, props, rootContainer, hostContext)`
|
|
197
|
+
*
|
|
167
198
|
* In this method, you can perform some final mutations on the `instance`. Unlike with `createInstance`,
|
|
168
199
|
* by the time `finalizeInitialChildren` is called, all the initial children have already been added to
|
|
169
200
|
* the `instance`, but the instance itself has not yet been connected to the tree on the screen.
|
|
@@ -181,22 +212,8 @@ var hostConfig = {
|
|
|
181
212
|
return false;
|
|
182
213
|
},
|
|
183
214
|
/**
|
|
184
|
-
*
|
|
185
|
-
* need to update the underlying instance or not. If you don't need to update it, return `null`. If you
|
|
186
|
-
* need to update it, you can return an arbitrary object representing the changes that need to happen.
|
|
187
|
-
* Then in `commitUpdate` you would need to apply those changes to the instance.
|
|
215
|
+
* #### `shouldSetTextContent(type, props)`
|
|
188
216
|
*
|
|
189
|
-
* This method happens **in the render phase**. It should only *calculate* the update — but not apply it!
|
|
190
|
-
* For example, the DOM renderer returns an array that looks like `[prop1, value1, prop2, value2, ...]`
|
|
191
|
-
* for all props that have actually changed. And only in `commitUpdate` it applies those changes. You should
|
|
192
|
-
* calculate as much as you can in `prepareUpdate` so that `commitUpdate` can be very fast and straightforward.
|
|
193
|
-
*
|
|
194
|
-
* See the meaning of `rootContainer` and `hostContext` in the `createInstance` documentation.
|
|
195
|
-
*/
|
|
196
|
-
prepareUpdate(_instance, _type, _oldProps, _newProps, _rootContainer, _hostContext) {
|
|
197
|
-
return UPDATE_SIGNAL;
|
|
198
|
-
},
|
|
199
|
-
/**
|
|
200
217
|
* Some target platforms support setting an instance's text content without manually creating a text node.
|
|
201
218
|
* For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.
|
|
202
219
|
*
|
|
@@ -212,17 +229,37 @@ var hostConfig = {
|
|
|
212
229
|
shouldSetTextContent(_type, _props) {
|
|
213
230
|
return false;
|
|
214
231
|
},
|
|
232
|
+
setCurrentUpdatePriority(newPriority) {
|
|
233
|
+
currentUpdatePriority = newPriority;
|
|
234
|
+
},
|
|
235
|
+
getCurrentUpdatePriority() {
|
|
236
|
+
return currentUpdatePriority;
|
|
237
|
+
},
|
|
238
|
+
resolveUpdatePriority() {
|
|
239
|
+
return currentUpdatePriority || import_constants.DefaultEventPriority;
|
|
240
|
+
},
|
|
241
|
+
shouldAttemptEagerTransition() {
|
|
242
|
+
return false;
|
|
243
|
+
},
|
|
215
244
|
/**
|
|
245
|
+
* #### `getRootHostContext(rootContainer)`
|
|
246
|
+
*
|
|
216
247
|
* This method lets you return the initial host context from the root of the tree. See `getChildHostContext`
|
|
217
248
|
* for the explanation of host context.
|
|
218
249
|
*
|
|
219
250
|
* If you don't intend to use host context, you can return `null`.
|
|
220
251
|
* This method happens **in the render phase**. Do not mutate the tree from it.
|
|
221
252
|
*/
|
|
222
|
-
getRootHostContext(
|
|
223
|
-
return {
|
|
253
|
+
getRootHostContext(rootContainer) {
|
|
254
|
+
return {
|
|
255
|
+
type: "ROOT",
|
|
256
|
+
config: rootContainer.config,
|
|
257
|
+
isInsideText: false
|
|
258
|
+
};
|
|
224
259
|
},
|
|
225
260
|
/**
|
|
261
|
+
* #### `getChildHostContext(parentHostContext, type, rootContainer)`
|
|
262
|
+
*
|
|
226
263
|
* Host context lets you track some information about where you are in the tree so that it's available
|
|
227
264
|
* inside `createInstance` as the `hostContext` parameter. For example, the DOM renderer uses it to track
|
|
228
265
|
* whether it's inside an HTML or an SVG tree, because `createInstance` implementation needs to be
|
|
@@ -236,12 +273,16 @@ var hostConfig = {
|
|
|
236
273
|
*
|
|
237
274
|
* This method happens **in the render phase**. Do not mutate the tree from it.
|
|
238
275
|
*/
|
|
239
|
-
getChildHostContext(parentHostContext, type
|
|
276
|
+
getChildHostContext(parentHostContext, type) {
|
|
240
277
|
var _a;
|
|
241
|
-
const isInsideText = Boolean(
|
|
242
|
-
|
|
278
|
+
const isInsideText = Boolean(
|
|
279
|
+
(_a = parentHostContext.config.textComponents) == null ? void 0 : _a.includes(type)
|
|
280
|
+
);
|
|
281
|
+
return __spreadProps(__spreadValues({}, parentHostContext), { type, isInsideText });
|
|
243
282
|
},
|
|
244
283
|
/**
|
|
284
|
+
* #### `getPublicInstance(instance)`
|
|
285
|
+
*
|
|
245
286
|
* Determines what object gets exposed as a ref. You'll likely want to return the `instance` itself. But
|
|
246
287
|
* in some cases it might make sense to only expose some part of it.
|
|
247
288
|
*
|
|
@@ -250,7 +291,7 @@ var hostConfig = {
|
|
|
250
291
|
getPublicInstance(instance) {
|
|
251
292
|
switch (instance.tag) {
|
|
252
293
|
case "INSTANCE": {
|
|
253
|
-
const createNodeMock = instance.rootContainer.createNodeMock;
|
|
294
|
+
const createNodeMock = instance.rootContainer.config.createNodeMock;
|
|
254
295
|
const mockNode = createNodeMock({
|
|
255
296
|
type: instance.type,
|
|
256
297
|
props: instance.props,
|
|
@@ -264,6 +305,8 @@ var hostConfig = {
|
|
|
264
305
|
}
|
|
265
306
|
},
|
|
266
307
|
/**
|
|
308
|
+
* #### `prepareForCommit(containerInfo)`
|
|
309
|
+
*
|
|
267
310
|
* This method lets you store some information before React starts making changes to the tree on
|
|
268
311
|
* the screen. For example, the DOM renderer stores the current text selection so that it can later
|
|
269
312
|
* restore it. This method is mirrored by `resetAfterCommit`.
|
|
@@ -274,6 +317,8 @@ var hostConfig = {
|
|
|
274
317
|
return null;
|
|
275
318
|
},
|
|
276
319
|
/**
|
|
320
|
+
* #### `resetAfterCommit(containerInfo)`
|
|
321
|
+
*
|
|
277
322
|
* This method is called right after React has performed the tree mutations. You can use it to restore
|
|
278
323
|
* something you've stored in `prepareForCommit` — for example, text selection.
|
|
279
324
|
*
|
|
@@ -282,21 +327,34 @@ var hostConfig = {
|
|
|
282
327
|
resetAfterCommit(_containerInfo) {
|
|
283
328
|
},
|
|
284
329
|
/**
|
|
330
|
+
* #### `preparePortalMount(containerInfo)`
|
|
331
|
+
*
|
|
285
332
|
* This method is called for a container that's used as a portal target. Usually you can leave it empty.
|
|
286
333
|
*/
|
|
287
334
|
preparePortalMount(_containerInfo) {
|
|
288
335
|
},
|
|
289
336
|
/**
|
|
337
|
+
* #### `scheduleTimeout(fn, delay)`
|
|
338
|
+
*
|
|
290
339
|
* You can proxy this to `setTimeout` or its equivalent in your environment.
|
|
291
340
|
*/
|
|
292
341
|
scheduleTimeout: setTimeout,
|
|
342
|
+
/**
|
|
343
|
+
* #### `cancelTimeout(id)`
|
|
344
|
+
*
|
|
345
|
+
* You can proxy this to `clearTimeout` or its equivalent in your environment.
|
|
346
|
+
*/
|
|
293
347
|
cancelTimeout: clearTimeout,
|
|
294
348
|
/**
|
|
349
|
+
* #### `noTimeout`
|
|
350
|
+
*
|
|
295
351
|
* This is a property (not a function) that should be set to something that can never be a valid timeout ID.
|
|
296
352
|
* For example, you can set it to `-1`.
|
|
297
353
|
*/
|
|
298
354
|
noTimeout: -1,
|
|
299
355
|
/**
|
|
356
|
+
* #### `supportsMicrotasks`
|
|
357
|
+
*
|
|
300
358
|
* Set this to `true` to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part
|
|
301
359
|
* of our discrete event implementation in React DOM. If you're not sure if your renderer should support this,
|
|
302
360
|
* you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control
|
|
@@ -304,10 +362,14 @@ var hostConfig = {
|
|
|
304
362
|
*/
|
|
305
363
|
supportsMicrotasks: true,
|
|
306
364
|
/**
|
|
365
|
+
* #### `scheduleMicrotask(fn)`
|
|
366
|
+
*
|
|
307
367
|
* Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
|
|
308
368
|
*/
|
|
309
369
|
scheduleMicrotask: queueMicrotask,
|
|
310
370
|
/**
|
|
371
|
+
* #### `isPrimaryRenderer`
|
|
372
|
+
*
|
|
311
373
|
* This is a property (not a function) that should be set to `true` if your renderer is the main one on the
|
|
312
374
|
* page. For example, if you're writing a renderer for the Terminal, it makes sense to set it to `true`, but
|
|
313
375
|
* if your renderer is used *on top of* React DOM or some other existing renderer, set it to `false`.
|
|
@@ -317,46 +379,6 @@ var hostConfig = {
|
|
|
317
379
|
* Whether the renderer shouldn't trigger missing `act()` warnings
|
|
318
380
|
*/
|
|
319
381
|
warnsIfNotActing: true,
|
|
320
|
-
/**
|
|
321
|
-
* To implement this method, you'll need some constants available on the special `react-reconciler/constants` entry point:
|
|
322
|
-
*
|
|
323
|
-
* ```
|
|
324
|
-
* import {
|
|
325
|
-
* DiscreteEventPriority,
|
|
326
|
-
* ContinuousEventPriority,
|
|
327
|
-
* DefaultEventPriority,
|
|
328
|
-
* } from 'react-reconciler/constants';
|
|
329
|
-
*
|
|
330
|
-
* const HostConfig = {
|
|
331
|
-
* // ...
|
|
332
|
-
* getCurrentEventPriority() {
|
|
333
|
-
* return DefaultEventPriority;
|
|
334
|
-
* },
|
|
335
|
-
* // ...
|
|
336
|
-
* }
|
|
337
|
-
*
|
|
338
|
-
* const MyRenderer = Reconciler(HostConfig);
|
|
339
|
-
* ```
|
|
340
|
-
*
|
|
341
|
-
* The constant you return depends on which event, if any, is being handled right now. (In the browser, you can
|
|
342
|
-
* check this using `window.event && window.event.type`).
|
|
343
|
-
*
|
|
344
|
-
* - **Discrete events**: If the active event is directly caused by the user (such as mouse and keyboard events)
|
|
345
|
-
* and each event in a sequence is intentional (e.g. click), return DiscreteEventPriority. This tells React that
|
|
346
|
-
* they should interrupt any background work and cannot be batched across time.
|
|
347
|
-
*
|
|
348
|
-
* - **Continuous events**: If the active event is directly caused by the user but the user can't distinguish between
|
|
349
|
-
* individual events in a sequence (e.g. mouseover), return ContinuousEventPriority. This tells React they
|
|
350
|
-
* should interrupt any background work but can be batched across time.
|
|
351
|
-
*
|
|
352
|
-
* - **Other events / No active event**: In all other cases, return DefaultEventPriority. This tells React that
|
|
353
|
-
* this event is considered background work, and interactive events will be prioritized over it.
|
|
354
|
-
*
|
|
355
|
-
* You can consult the `getCurrentEventPriority()` implementation in `ReactDOMHostConfig.js` for a reference implementation.
|
|
356
|
-
*/
|
|
357
|
-
getCurrentEventPriority() {
|
|
358
|
-
return import_constants.DefaultEventPriority;
|
|
359
|
-
},
|
|
360
382
|
getInstanceFromNode(node) {
|
|
361
383
|
const instance = nodeToInstanceMap.get(node);
|
|
362
384
|
if (instance !== void 0) {
|
|
@@ -378,6 +400,8 @@ var hostConfig = {
|
|
|
378
400
|
detachDeletedInstance(_node) {
|
|
379
401
|
},
|
|
380
402
|
/**
|
|
403
|
+
* #### `appendChild(parentInstance, child)`
|
|
404
|
+
*
|
|
381
405
|
* This method should mutate the `parentInstance` and add the child to its list of children. For example,
|
|
382
406
|
* in the DOM this would translate to a `parentInstance.appendChild(child)` call.
|
|
383
407
|
*
|
|
@@ -386,12 +410,16 @@ var hostConfig = {
|
|
|
386
410
|
*/
|
|
387
411
|
appendChild,
|
|
388
412
|
/**
|
|
413
|
+
* #### `appendChildToContainer(container, child)`
|
|
414
|
+
*
|
|
389
415
|
* Same as `appendChild`, but for when a node is attached to the root container. This is useful if attaching
|
|
390
416
|
* to the root has a slightly different implementation, or if the root container nodes are of a different
|
|
391
417
|
* type than the rest of the tree.
|
|
392
418
|
*/
|
|
393
419
|
appendChildToContainer: appendChild,
|
|
394
420
|
/**
|
|
421
|
+
* #### `insertBefore(parentInstance, child, beforeChild)`
|
|
422
|
+
*
|
|
395
423
|
* This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list of
|
|
396
424
|
* its children. For example, in the DOM this would translate to a `parentInstance.insertBefore(child, beforeChild)` call.
|
|
397
425
|
*
|
|
@@ -400,12 +428,16 @@ var hostConfig = {
|
|
|
400
428
|
*/
|
|
401
429
|
insertBefore,
|
|
402
430
|
/**
|
|
431
|
+
* #### `insertInContainerBefore(container, child, beforeChild)
|
|
432
|
+
*
|
|
403
433
|
* Same as `insertBefore`, but for when a node is attached to the root container. This is useful if attaching
|
|
404
434
|
* to the root has a slightly different implementation, or if the root container nodes are of a different type
|
|
405
435
|
* than the rest of the tree.
|
|
406
436
|
*/
|
|
407
437
|
insertInContainerBefore: insertBefore,
|
|
408
438
|
/**
|
|
439
|
+
* #### `removeChild(parentInstance, child)`
|
|
440
|
+
*
|
|
409
441
|
* This method should mutate the `parentInstance` to remove the `child` from the list of its children.
|
|
410
442
|
*
|
|
411
443
|
* React will only call it for the top-level node that is being removed. It is expected that garbage collection
|
|
@@ -413,12 +445,16 @@ var hostConfig = {
|
|
|
413
445
|
*/
|
|
414
446
|
removeChild,
|
|
415
447
|
/**
|
|
448
|
+
* #### `removeChildFromContainer(container, child)`
|
|
449
|
+
*
|
|
416
450
|
* Same as `removeChild`, but for when a node is detached from the root container. This is useful if attaching
|
|
417
451
|
* to the root has a slightly different implementation, or if the root container nodes are of a different type
|
|
418
452
|
* than the rest of the tree.
|
|
419
453
|
*/
|
|
420
454
|
removeChildFromContainer: removeChild,
|
|
421
455
|
/**
|
|
456
|
+
* #### `resetTextContent(instance)`
|
|
457
|
+
*
|
|
422
458
|
* If you returned `true` from `shouldSetTextContent` for the previous props, but returned `false` from
|
|
423
459
|
* `shouldSetTextContent` for the next props, React will call this method so that you can clear the text
|
|
424
460
|
* content you were managing manually. For example, in the DOM you could set `node.textContent = ''`.
|
|
@@ -428,6 +464,8 @@ var hostConfig = {
|
|
|
428
464
|
resetTextContent(_instance) {
|
|
429
465
|
},
|
|
430
466
|
/**
|
|
467
|
+
* #### `commitTextUpdate(textInstance, prevText, nextText)`
|
|
468
|
+
*
|
|
431
469
|
* This method should mutate the `textInstance` and update its text content to `nextText`.
|
|
432
470
|
*
|
|
433
471
|
* Here, `textInstance` is a node created by `createTextInstance`.
|
|
@@ -436,6 +474,8 @@ var hostConfig = {
|
|
|
436
474
|
textInstance.text = newText;
|
|
437
475
|
},
|
|
438
476
|
/**
|
|
477
|
+
* #### `commitMount(instance, type, props, internalHandle)`
|
|
478
|
+
*
|
|
439
479
|
* This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.
|
|
440
480
|
*
|
|
441
481
|
* It lets you do some additional work after the node is actually attached to the tree on the screen for
|
|
@@ -455,6 +495,8 @@ var hostConfig = {
|
|
|
455
495
|
commitMount(_instance, _type, _props, _internalHandle) {
|
|
456
496
|
},
|
|
457
497
|
/**
|
|
498
|
+
* #### `commitUpdate(instance, type, prevProps, nextProps, internalHandle)`
|
|
499
|
+
*
|
|
458
500
|
* This method should mutate the `instance` according to the set of changes in `updatePayload`. Here, `updatePayload`
|
|
459
501
|
* is the object that you've returned from `prepareUpdate` and has an arbitrary structure that makes sense for your
|
|
460
502
|
* renderer. For example, the DOM renderer returns an update payload like `[prop1, value1, prop2, value2, ...]` from
|
|
@@ -465,12 +507,15 @@ var hostConfig = {
|
|
|
465
507
|
* be aware that it may change significantly between versions. You're taking on additional maintenance risk by
|
|
466
508
|
* reading from it, and giving up all guarantees if you write something to it.
|
|
467
509
|
*/
|
|
468
|
-
|
|
510
|
+
// @ts-expect-error types are not updated
|
|
511
|
+
commitUpdate(instance, type, _prevProps, nextProps, internalHandle) {
|
|
469
512
|
instance.type = type;
|
|
470
513
|
instance.props = nextProps;
|
|
471
514
|
instance.internalHandle = internalHandle;
|
|
472
515
|
},
|
|
473
516
|
/**
|
|
517
|
+
* #### `hideInstance(instance)`
|
|
518
|
+
*
|
|
474
519
|
* This method should make the `instance` invisible without removing it from the tree. For example, it can apply
|
|
475
520
|
* visual styling to hide it. It is used by Suspense to hide the tree while the fallback is visible.
|
|
476
521
|
*/
|
|
@@ -478,24 +523,32 @@ var hostConfig = {
|
|
|
478
523
|
instance.isHidden = true;
|
|
479
524
|
},
|
|
480
525
|
/**
|
|
526
|
+
* #### `hideTextInstance(textInstance)`
|
|
527
|
+
*
|
|
481
528
|
* Same as `hideInstance`, but for nodes created by `createTextInstance`.
|
|
482
529
|
*/
|
|
483
530
|
hideTextInstance(textInstance) {
|
|
484
531
|
textInstance.isHidden = true;
|
|
485
532
|
},
|
|
486
533
|
/**
|
|
534
|
+
* #### `unhideInstance(instance, props)`
|
|
535
|
+
*
|
|
487
536
|
* This method should make the `instance` visible, undoing what `hideInstance` did.
|
|
488
537
|
*/
|
|
489
538
|
unhideInstance(instance, _props) {
|
|
490
539
|
instance.isHidden = false;
|
|
491
540
|
},
|
|
492
541
|
/**
|
|
542
|
+
* #### `unhideTextInstance(textInstance, text)`
|
|
543
|
+
*
|
|
493
544
|
* Same as `unhideInstance`, but for nodes created by `createTextInstance`.
|
|
494
545
|
*/
|
|
495
546
|
unhideTextInstance(textInstance, _text) {
|
|
496
547
|
textInstance.isHidden = false;
|
|
497
548
|
},
|
|
498
549
|
/**
|
|
550
|
+
* #### `clearContainer(container)`
|
|
551
|
+
*
|
|
499
552
|
* This method should mutate the `container` root node and remove all children from it.
|
|
500
553
|
*/
|
|
501
554
|
clearContainer(container) {
|
|
@@ -504,6 +557,53 @@ var hostConfig = {
|
|
|
504
557
|
});
|
|
505
558
|
container.children.splice(0);
|
|
506
559
|
},
|
|
560
|
+
/**
|
|
561
|
+
* #### `maySuspendCommit(type, props)`
|
|
562
|
+
*
|
|
563
|
+
* This method is called during render to determine if the Host Component type and props require
|
|
564
|
+
* some kind of loading process to complete before committing an update.
|
|
565
|
+
*/
|
|
566
|
+
maySuspendCommit(_type, _props) {
|
|
567
|
+
return false;
|
|
568
|
+
},
|
|
569
|
+
/**
|
|
570
|
+
* #### `preloadInstance(type, props)`
|
|
571
|
+
*
|
|
572
|
+
* This method may be called during render if the Host Component type and props might suspend a commit.
|
|
573
|
+
* It can be used to initiate any work that might shorten the duration of a suspended commit.
|
|
574
|
+
*/
|
|
575
|
+
preloadInstance(_type, _props) {
|
|
576
|
+
return true;
|
|
577
|
+
},
|
|
578
|
+
/**
|
|
579
|
+
* #### `startSuspendingCommit()`
|
|
580
|
+
*
|
|
581
|
+
* This method is called just before the commit phase. Use it to set up any necessary state while any Host
|
|
582
|
+
* Components that might suspend this commit are evaluated to determine if the commit must be suspended.
|
|
583
|
+
*/
|
|
584
|
+
startSuspendingCommit() {
|
|
585
|
+
},
|
|
586
|
+
/**
|
|
587
|
+
* #### `suspendInstance(type, props)`
|
|
588
|
+
*
|
|
589
|
+
* This method is called after `startSuspendingCommit` for each Host Component that indicated it might
|
|
590
|
+
* suspend a commit.
|
|
591
|
+
*/
|
|
592
|
+
suspendInstance() {
|
|
593
|
+
},
|
|
594
|
+
/**
|
|
595
|
+
* #### `waitForCommitToBeReady()`
|
|
596
|
+
*
|
|
597
|
+
* This method is called after all `suspendInstance` calls are complete.
|
|
598
|
+
*
|
|
599
|
+
* Return `null` if the commit can happen immediately.
|
|
600
|
+
* Return `(initiateCommit: Function) => Function` if the commit must be suspended. The argument to this
|
|
601
|
+
* callback will initiate the commit when called. The return value is a cancellation function that the
|
|
602
|
+
* Reconciler can use to abort the commit.
|
|
603
|
+
*/
|
|
604
|
+
waitForCommitToBeReady() {
|
|
605
|
+
return null;
|
|
606
|
+
},
|
|
507
607
|
// -------------------
|
|
508
608
|
// Hydration Methods
|
|
509
609
|
// (optional)
|
|
@@ -514,7 +614,12 @@ var hostConfig = {
|
|
|
514
614
|
// the "Hydration" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js).
|
|
515
615
|
// File an issue if you need help.
|
|
516
616
|
// -------------------
|
|
517
|
-
supportsHydration: false
|
|
617
|
+
supportsHydration: false,
|
|
618
|
+
NotPendingTransition: null,
|
|
619
|
+
resetFormInstance(_form) {
|
|
620
|
+
},
|
|
621
|
+
requestPostPaintCallback(_callback) {
|
|
622
|
+
}
|
|
518
623
|
};
|
|
519
624
|
var TestReconciler = (0, import_react_reconciler.default)(hostConfig);
|
|
520
625
|
function appendChild(parentInstance, child) {
|
|
@@ -679,14 +784,16 @@ function createRenderer(options) {
|
|
|
679
784
|
tag: "CONTAINER",
|
|
680
785
|
children: [],
|
|
681
786
|
parent: null,
|
|
682
|
-
|
|
683
|
-
|
|
787
|
+
config: {
|
|
788
|
+
textComponents: options == null ? void 0 : options.textComponents,
|
|
789
|
+
createNodeMock: (_a = options == null ? void 0 : options.createNodeMock) != null ? _a : () => ({})
|
|
790
|
+
}
|
|
684
791
|
};
|
|
685
792
|
let containerFiber = TestReconciler.createContainer(
|
|
686
793
|
container,
|
|
687
794
|
(options == null ? void 0 : options.isConcurrent) ? import_constants4.ConcurrentRoot : import_constants4.LegacyRoot,
|
|
688
795
|
null,
|
|
689
|
-
//
|
|
796
|
+
// hydration callbacks
|
|
690
797
|
false,
|
|
691
798
|
// isStrictMode
|
|
692
799
|
null,
|
|
@@ -695,6 +802,13 @@ function createRenderer(options) {
|
|
|
695
802
|
// identifierPrefix
|
|
696
803
|
() => {
|
|
697
804
|
},
|
|
805
|
+
// onUncaughtError
|
|
806
|
+
() => {
|
|
807
|
+
},
|
|
808
|
+
// onCaughtError
|
|
809
|
+
// @ts-expect-error missing types
|
|
810
|
+
() => {
|
|
811
|
+
},
|
|
698
812
|
// onRecoverableError
|
|
699
813
|
null
|
|
700
814
|
// transitionCallbacks
|