universal-test-renderer 0.3.0-react19.0 → 0.4.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/README.md +2 -2
- package/dist/index.cjs +151 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +153 -113
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -24,10 +24,10 @@ Note: this package is now compatible with React 18.3. In the near future I will
|
|
|
24
24
|
|
|
25
25
|
```tsx
|
|
26
26
|
import { act } from "react";
|
|
27
|
-
import {
|
|
27
|
+
import { createRoot } from "universal-test-renderer";
|
|
28
28
|
|
|
29
29
|
test("basic renderer usage", () => {
|
|
30
|
-
const renderer =
|
|
30
|
+
const renderer = createRoot();
|
|
31
31
|
act(() => {
|
|
32
32
|
renderer.render(<div>Hello!</div>);
|
|
33
33
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -60,7 +60,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
60
60
|
var src_exports = {};
|
|
61
61
|
__export(src_exports, {
|
|
62
62
|
CONTAINER_TYPE: () => CONTAINER_TYPE,
|
|
63
|
-
|
|
63
|
+
createRoot: () => createRoot
|
|
64
64
|
});
|
|
65
65
|
module.exports = __toCommonJS(src_exports);
|
|
66
66
|
|
|
@@ -85,10 +85,8 @@ function formatComponentList(names) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// src/reconciler.ts
|
|
88
|
-
var NoEventPriority = 0;
|
|
89
|
-
var UPDATE_SIGNAL = {};
|
|
90
88
|
var nodeToInstanceMap = /* @__PURE__ */ new WeakMap();
|
|
91
|
-
var currentUpdatePriority = NoEventPriority;
|
|
89
|
+
var currentUpdatePriority = import_constants.NoEventPriority;
|
|
92
90
|
var hostConfig = {
|
|
93
91
|
/**
|
|
94
92
|
* The reconciler has two modes: mutation mode and persistent mode. You must specify one of them.
|
|
@@ -129,6 +127,8 @@ var hostConfig = {
|
|
|
129
127
|
*/
|
|
130
128
|
supportsPersistence: false,
|
|
131
129
|
/**
|
|
130
|
+
* #### `createInstance(type, props, rootContainer, hostContext, internalHandle)`
|
|
131
|
+
*
|
|
132
132
|
* This method should return a newly created node. For example, the DOM renderer would call
|
|
133
133
|
* `document.createElement(type)` here and then set the properties from `props`.
|
|
134
134
|
*
|
|
@@ -161,14 +161,16 @@ var hostConfig = {
|
|
|
161
161
|
};
|
|
162
162
|
},
|
|
163
163
|
/**
|
|
164
|
+
* #### `createTextInstance(text, rootContainer, hostContext, internalHandle)`
|
|
165
|
+
*
|
|
164
166
|
* Same as `createInstance`, but for text nodes. If your renderer doesn't support text nodes, you can
|
|
165
167
|
* throw here.
|
|
166
168
|
*/
|
|
167
169
|
createTextInstance(text, rootContainer, hostContext, _internalHandle) {
|
|
168
|
-
if (rootContainer.textComponents && !hostContext.isInsideText) {
|
|
170
|
+
if (rootContainer.config.textComponents && !hostContext.isInsideText) {
|
|
169
171
|
throw new Error(
|
|
170
172
|
`Invariant Violation: Text strings must be rendered within a ${formatComponentList(
|
|
171
|
-
rootContainer.textComponents
|
|
173
|
+
rootContainer.config.textComponents
|
|
172
174
|
)} component. Detected attempt to render "${text}" string within a <${hostContext.type}> component.`
|
|
173
175
|
);
|
|
174
176
|
}
|
|
@@ -179,8 +181,20 @@ var hostConfig = {
|
|
|
179
181
|
isHidden: false
|
|
180
182
|
};
|
|
181
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
|
+
*/
|
|
182
194
|
appendInitialChild: appendChild,
|
|
183
195
|
/**
|
|
196
|
+
* #### `finalizeInitialChildren(instance, type, props, rootContainer, hostContext)`
|
|
197
|
+
*
|
|
184
198
|
* In this method, you can perform some final mutations on the `instance`. Unlike with `createInstance`,
|
|
185
199
|
* by the time `finalizeInitialChildren` is called, all the initial children have already been added to
|
|
186
200
|
* the `instance`, but the instance itself has not yet been connected to the tree on the screen.
|
|
@@ -198,22 +212,8 @@ var hostConfig = {
|
|
|
198
212
|
return false;
|
|
199
213
|
},
|
|
200
214
|
/**
|
|
201
|
-
*
|
|
202
|
-
* need to update the underlying instance or not. If you don't need to update it, return `null`. If you
|
|
203
|
-
* need to update it, you can return an arbitrary object representing the changes that need to happen.
|
|
204
|
-
* Then in `commitUpdate` you would need to apply those changes to the instance.
|
|
205
|
-
*
|
|
206
|
-
* This method happens **in the render phase**. It should only *calculate* the update — but not apply it!
|
|
207
|
-
* For example, the DOM renderer returns an array that looks like `[prop1, value1, prop2, value2, ...]`
|
|
208
|
-
* for all props that have actually changed. And only in `commitUpdate` it applies those changes. You should
|
|
209
|
-
* calculate as much as you can in `prepareUpdate` so that `commitUpdate` can be very fast and straightforward.
|
|
215
|
+
* #### `shouldSetTextContent(type, props)`
|
|
210
216
|
*
|
|
211
|
-
* See the meaning of `rootContainer` and `hostContext` in the `createInstance` documentation.
|
|
212
|
-
*/
|
|
213
|
-
prepareUpdate(_instance, _type, _oldProps, _newProps, _rootContainer, _hostContext) {
|
|
214
|
-
return UPDATE_SIGNAL;
|
|
215
|
-
},
|
|
216
|
-
/**
|
|
217
217
|
* Some target platforms support setting an instance's text content without manually creating a text node.
|
|
218
218
|
* For example, in the DOM, you can set `node.textContent` instead of creating a text node and appending it.
|
|
219
219
|
*
|
|
@@ -229,7 +229,21 @@ var hostConfig = {
|
|
|
229
229
|
shouldSetTextContent(_type, _props) {
|
|
230
230
|
return false;
|
|
231
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
|
+
},
|
|
232
244
|
/**
|
|
245
|
+
* #### `getRootHostContext(rootContainer)`
|
|
246
|
+
*
|
|
233
247
|
* This method lets you return the initial host context from the root of the tree. See `getChildHostContext`
|
|
234
248
|
* for the explanation of host context.
|
|
235
249
|
*
|
|
@@ -239,11 +253,13 @@ var hostConfig = {
|
|
|
239
253
|
getRootHostContext(rootContainer) {
|
|
240
254
|
return {
|
|
241
255
|
type: "ROOT",
|
|
242
|
-
|
|
243
|
-
|
|
256
|
+
config: rootContainer.config,
|
|
257
|
+
isInsideText: false
|
|
244
258
|
};
|
|
245
259
|
},
|
|
246
260
|
/**
|
|
261
|
+
* #### `getChildHostContext(parentHostContext, type, rootContainer)`
|
|
262
|
+
*
|
|
247
263
|
* Host context lets you track some information about where you are in the tree so that it's available
|
|
248
264
|
* inside `createInstance` as the `hostContext` parameter. For example, the DOM renderer uses it to track
|
|
249
265
|
* whether it's inside an HTML or an SVG tree, because `createInstance` implementation needs to be
|
|
@@ -260,11 +276,13 @@ var hostConfig = {
|
|
|
260
276
|
getChildHostContext(parentHostContext, type) {
|
|
261
277
|
var _a;
|
|
262
278
|
const isInsideText = Boolean(
|
|
263
|
-
(_a = parentHostContext.textComponents) == null ? void 0 : _a.includes(type)
|
|
279
|
+
(_a = parentHostContext.config.textComponents) == null ? void 0 : _a.includes(type)
|
|
264
280
|
);
|
|
265
281
|
return __spreadProps(__spreadValues({}, parentHostContext), { type, isInsideText });
|
|
266
282
|
},
|
|
267
283
|
/**
|
|
284
|
+
* #### `getPublicInstance(instance)`
|
|
285
|
+
*
|
|
268
286
|
* Determines what object gets exposed as a ref. You'll likely want to return the `instance` itself. But
|
|
269
287
|
* in some cases it might make sense to only expose some part of it.
|
|
270
288
|
*
|
|
@@ -273,7 +291,7 @@ var hostConfig = {
|
|
|
273
291
|
getPublicInstance(instance) {
|
|
274
292
|
switch (instance.tag) {
|
|
275
293
|
case "INSTANCE": {
|
|
276
|
-
const createNodeMock = instance.rootContainer.createNodeMock;
|
|
294
|
+
const createNodeMock = instance.rootContainer.config.createNodeMock;
|
|
277
295
|
const mockNode = createNodeMock({
|
|
278
296
|
type: instance.type,
|
|
279
297
|
props: instance.props,
|
|
@@ -287,6 +305,8 @@ var hostConfig = {
|
|
|
287
305
|
}
|
|
288
306
|
},
|
|
289
307
|
/**
|
|
308
|
+
* #### `prepareForCommit(containerInfo)`
|
|
309
|
+
*
|
|
290
310
|
* This method lets you store some information before React starts making changes to the tree on
|
|
291
311
|
* the screen. For example, the DOM renderer stores the current text selection so that it can later
|
|
292
312
|
* restore it. This method is mirrored by `resetAfterCommit`.
|
|
@@ -297,6 +317,8 @@ var hostConfig = {
|
|
|
297
317
|
return null;
|
|
298
318
|
},
|
|
299
319
|
/**
|
|
320
|
+
* #### `resetAfterCommit(containerInfo)`
|
|
321
|
+
*
|
|
300
322
|
* This method is called right after React has performed the tree mutations. You can use it to restore
|
|
301
323
|
* something you've stored in `prepareForCommit` — for example, text selection.
|
|
302
324
|
*
|
|
@@ -305,21 +327,34 @@ var hostConfig = {
|
|
|
305
327
|
resetAfterCommit(_containerInfo) {
|
|
306
328
|
},
|
|
307
329
|
/**
|
|
330
|
+
* #### `preparePortalMount(containerInfo)`
|
|
331
|
+
*
|
|
308
332
|
* This method is called for a container that's used as a portal target. Usually you can leave it empty.
|
|
309
333
|
*/
|
|
310
334
|
preparePortalMount(_containerInfo) {
|
|
311
335
|
},
|
|
312
336
|
/**
|
|
337
|
+
* #### `scheduleTimeout(fn, delay)`
|
|
338
|
+
*
|
|
313
339
|
* You can proxy this to `setTimeout` or its equivalent in your environment.
|
|
314
340
|
*/
|
|
315
341
|
scheduleTimeout: setTimeout,
|
|
342
|
+
/**
|
|
343
|
+
* #### `cancelTimeout(id)`
|
|
344
|
+
*
|
|
345
|
+
* You can proxy this to `clearTimeout` or its equivalent in your environment.
|
|
346
|
+
*/
|
|
316
347
|
cancelTimeout: clearTimeout,
|
|
317
348
|
/**
|
|
349
|
+
* #### `noTimeout`
|
|
350
|
+
*
|
|
318
351
|
* This is a property (not a function) that should be set to something that can never be a valid timeout ID.
|
|
319
352
|
* For example, you can set it to `-1`.
|
|
320
353
|
*/
|
|
321
354
|
noTimeout: -1,
|
|
322
355
|
/**
|
|
356
|
+
* #### `supportsMicrotasks`
|
|
357
|
+
*
|
|
323
358
|
* Set this to `true` to indicate that your renderer supports `scheduleMicrotask`. We use microtasks as part
|
|
324
359
|
* of our discrete event implementation in React DOM. If you're not sure if your renderer should support this,
|
|
325
360
|
* you probably should. The option to not implement `scheduleMicrotask` exists so that platforms with more control
|
|
@@ -327,10 +362,14 @@ var hostConfig = {
|
|
|
327
362
|
*/
|
|
328
363
|
supportsMicrotasks: true,
|
|
329
364
|
/**
|
|
365
|
+
* #### `scheduleMicrotask(fn)`
|
|
366
|
+
*
|
|
330
367
|
* Optional. You can proxy this to `queueMicrotask` or its equivalent in your environment.
|
|
331
368
|
*/
|
|
332
369
|
scheduleMicrotask: queueMicrotask,
|
|
333
370
|
/**
|
|
371
|
+
* #### `isPrimaryRenderer`
|
|
372
|
+
*
|
|
334
373
|
* This is a property (not a function) that should be set to `true` if your renderer is the main one on the
|
|
335
374
|
* page. For example, if you're writing a renderer for the Terminal, it makes sense to set it to `true`, but
|
|
336
375
|
* if your renderer is used *on top of* React DOM or some other existing renderer, set it to `false`.
|
|
@@ -340,47 +379,6 @@ var hostConfig = {
|
|
|
340
379
|
* Whether the renderer shouldn't trigger missing `act()` warnings
|
|
341
380
|
*/
|
|
342
381
|
warnsIfNotActing: true,
|
|
343
|
-
/**
|
|
344
|
-
* To implement this method, you'll need some constants available on the special `react-reconciler/constants` entry point:
|
|
345
|
-
*
|
|
346
|
-
* ```
|
|
347
|
-
* import {
|
|
348
|
-
* DiscreteEventPriority,
|
|
349
|
-
* ContinuousEventPriority,
|
|
350
|
-
* DefaultEventPriority,
|
|
351
|
-
* } from 'react-reconciler/constants';
|
|
352
|
-
*
|
|
353
|
-
* const HostConfig = {
|
|
354
|
-
* // ...
|
|
355
|
-
* getCurrentEventPriority() {
|
|
356
|
-
* return DefaultEventPriority;
|
|
357
|
-
* },
|
|
358
|
-
* // ...
|
|
359
|
-
* }
|
|
360
|
-
*
|
|
361
|
-
* const MyRenderer = Reconciler(HostConfig);
|
|
362
|
-
* ```
|
|
363
|
-
*
|
|
364
|
-
* The constant you return depends on which event, if any, is being handled right now. (In the browser, you can
|
|
365
|
-
* check this using `window.event && window.event.type`).
|
|
366
|
-
*
|
|
367
|
-
* - **Discrete events**: If the active event is directly caused by the user (such as mouse and keyboard events)
|
|
368
|
-
* and each event in a sequence is intentional (e.g. click), return DiscreteEventPriority. This tells React that
|
|
369
|
-
* they should interrupt any background work and cannot be batched across time.
|
|
370
|
-
*
|
|
371
|
-
* - **Continuous events**: If the active event is directly caused by the user but the user can't distinguish between
|
|
372
|
-
* individual events in a sequence (e.g. mouseover), return ContinuousEventPriority. This tells React they
|
|
373
|
-
* should interrupt any background work but can be batched across time.
|
|
374
|
-
*
|
|
375
|
-
* - **Other events / No active event**: In all other cases, return DefaultEventPriority. This tells React that
|
|
376
|
-
* this event is considered background work, and interactive events will be prioritized over it.
|
|
377
|
-
*
|
|
378
|
-
* You can consult the `getCurrentEventPriority()` implementation in `ReactDOMHostConfig.js` for a reference implementation.
|
|
379
|
-
*/
|
|
380
|
-
// Removed in React 19
|
|
381
|
-
// getCurrentEventPriority() {
|
|
382
|
-
// return DefaultEventPriority;
|
|
383
|
-
// },
|
|
384
382
|
getInstanceFromNode(node) {
|
|
385
383
|
const instance = nodeToInstanceMap.get(node);
|
|
386
384
|
if (instance !== void 0) {
|
|
@@ -402,6 +400,8 @@ var hostConfig = {
|
|
|
402
400
|
detachDeletedInstance(_node) {
|
|
403
401
|
},
|
|
404
402
|
/**
|
|
403
|
+
* #### `appendChild(parentInstance, child)`
|
|
404
|
+
*
|
|
405
405
|
* This method should mutate the `parentInstance` and add the child to its list of children. For example,
|
|
406
406
|
* in the DOM this would translate to a `parentInstance.appendChild(child)` call.
|
|
407
407
|
*
|
|
@@ -410,12 +410,16 @@ var hostConfig = {
|
|
|
410
410
|
*/
|
|
411
411
|
appendChild,
|
|
412
412
|
/**
|
|
413
|
+
* #### `appendChildToContainer(container, child)`
|
|
414
|
+
*
|
|
413
415
|
* Same as `appendChild`, but for when a node is attached to the root container. This is useful if attaching
|
|
414
416
|
* to the root has a slightly different implementation, or if the root container nodes are of a different
|
|
415
417
|
* type than the rest of the tree.
|
|
416
418
|
*/
|
|
417
419
|
appendChildToContainer: appendChild,
|
|
418
420
|
/**
|
|
421
|
+
* #### `insertBefore(parentInstance, child, beforeChild)`
|
|
422
|
+
*
|
|
419
423
|
* This method should mutate the `parentInstance` and place the `child` before `beforeChild` in the list of
|
|
420
424
|
* its children. For example, in the DOM this would translate to a `parentInstance.insertBefore(child, beforeChild)` call.
|
|
421
425
|
*
|
|
@@ -424,12 +428,16 @@ var hostConfig = {
|
|
|
424
428
|
*/
|
|
425
429
|
insertBefore,
|
|
426
430
|
/**
|
|
431
|
+
* #### `insertInContainerBefore(container, child, beforeChild)
|
|
432
|
+
*
|
|
427
433
|
* Same as `insertBefore`, but for when a node is attached to the root container. This is useful if attaching
|
|
428
434
|
* to the root has a slightly different implementation, or if the root container nodes are of a different type
|
|
429
435
|
* than the rest of the tree.
|
|
430
436
|
*/
|
|
431
437
|
insertInContainerBefore: insertBefore,
|
|
432
438
|
/**
|
|
439
|
+
* #### `removeChild(parentInstance, child)`
|
|
440
|
+
*
|
|
433
441
|
* This method should mutate the `parentInstance` to remove the `child` from the list of its children.
|
|
434
442
|
*
|
|
435
443
|
* React will only call it for the top-level node that is being removed. It is expected that garbage collection
|
|
@@ -437,12 +445,16 @@ var hostConfig = {
|
|
|
437
445
|
*/
|
|
438
446
|
removeChild,
|
|
439
447
|
/**
|
|
448
|
+
* #### `removeChildFromContainer(container, child)`
|
|
449
|
+
*
|
|
440
450
|
* Same as `removeChild`, but for when a node is detached from the root container. This is useful if attaching
|
|
441
451
|
* to the root has a slightly different implementation, or if the root container nodes are of a different type
|
|
442
452
|
* than the rest of the tree.
|
|
443
453
|
*/
|
|
444
454
|
removeChildFromContainer: removeChild,
|
|
445
455
|
/**
|
|
456
|
+
* #### `resetTextContent(instance)`
|
|
457
|
+
*
|
|
446
458
|
* If you returned `true` from `shouldSetTextContent` for the previous props, but returned `false` from
|
|
447
459
|
* `shouldSetTextContent` for the next props, React will call this method so that you can clear the text
|
|
448
460
|
* content you were managing manually. For example, in the DOM you could set `node.textContent = ''`.
|
|
@@ -452,6 +464,8 @@ var hostConfig = {
|
|
|
452
464
|
resetTextContent(_instance) {
|
|
453
465
|
},
|
|
454
466
|
/**
|
|
467
|
+
* #### `commitTextUpdate(textInstance, prevText, nextText)`
|
|
468
|
+
*
|
|
455
469
|
* This method should mutate the `textInstance` and update its text content to `nextText`.
|
|
456
470
|
*
|
|
457
471
|
* Here, `textInstance` is a node created by `createTextInstance`.
|
|
@@ -460,6 +474,8 @@ var hostConfig = {
|
|
|
460
474
|
textInstance.text = newText;
|
|
461
475
|
},
|
|
462
476
|
/**
|
|
477
|
+
* #### `commitMount(instance, type, props, internalHandle)`
|
|
478
|
+
*
|
|
463
479
|
* This method is only called if you returned `true` from `finalizeInitialChildren` for this instance.
|
|
464
480
|
*
|
|
465
481
|
* It lets you do some additional work after the node is actually attached to the tree on the screen for
|
|
@@ -479,6 +495,8 @@ var hostConfig = {
|
|
|
479
495
|
commitMount(_instance, _type, _props, _internalHandle) {
|
|
480
496
|
},
|
|
481
497
|
/**
|
|
498
|
+
* #### `commitUpdate(instance, type, prevProps, nextProps, internalHandle)`
|
|
499
|
+
*
|
|
482
500
|
* This method should mutate the `instance` according to the set of changes in `updatePayload`. Here, `updatePayload`
|
|
483
501
|
* is the object that you've returned from `prepareUpdate` and has an arbitrary structure that makes sense for your
|
|
484
502
|
* renderer. For example, the DOM renderer returns an update payload like `[prop1, value1, prop2, value2, ...]` from
|
|
@@ -489,12 +507,15 @@ var hostConfig = {
|
|
|
489
507
|
* be aware that it may change significantly between versions. You're taking on additional maintenance risk by
|
|
490
508
|
* reading from it, and giving up all guarantees if you write something to it.
|
|
491
509
|
*/
|
|
492
|
-
|
|
510
|
+
// @ts-expect-error types are not updated
|
|
511
|
+
commitUpdate(instance, type, _prevProps, nextProps, internalHandle) {
|
|
493
512
|
instance.type = type;
|
|
494
513
|
instance.props = nextProps;
|
|
495
514
|
instance.internalHandle = internalHandle;
|
|
496
515
|
},
|
|
497
516
|
/**
|
|
517
|
+
* #### `hideInstance(instance)`
|
|
518
|
+
*
|
|
498
519
|
* This method should make the `instance` invisible without removing it from the tree. For example, it can apply
|
|
499
520
|
* visual styling to hide it. It is used by Suspense to hide the tree while the fallback is visible.
|
|
500
521
|
*/
|
|
@@ -502,24 +523,32 @@ var hostConfig = {
|
|
|
502
523
|
instance.isHidden = true;
|
|
503
524
|
},
|
|
504
525
|
/**
|
|
526
|
+
* #### `hideTextInstance(textInstance)`
|
|
527
|
+
*
|
|
505
528
|
* Same as `hideInstance`, but for nodes created by `createTextInstance`.
|
|
506
529
|
*/
|
|
507
530
|
hideTextInstance(textInstance) {
|
|
508
531
|
textInstance.isHidden = true;
|
|
509
532
|
},
|
|
510
533
|
/**
|
|
534
|
+
* #### `unhideInstance(instance, props)`
|
|
535
|
+
*
|
|
511
536
|
* This method should make the `instance` visible, undoing what `hideInstance` did.
|
|
512
537
|
*/
|
|
513
538
|
unhideInstance(instance, _props) {
|
|
514
539
|
instance.isHidden = false;
|
|
515
540
|
},
|
|
516
541
|
/**
|
|
542
|
+
* #### `unhideTextInstance(textInstance, text)`
|
|
543
|
+
*
|
|
517
544
|
* Same as `unhideInstance`, but for nodes created by `createTextInstance`.
|
|
518
545
|
*/
|
|
519
546
|
unhideTextInstance(textInstance, _text) {
|
|
520
547
|
textInstance.isHidden = false;
|
|
521
548
|
},
|
|
522
549
|
/**
|
|
550
|
+
* #### `clearContainer(container)`
|
|
551
|
+
*
|
|
523
552
|
* This method should mutate the `container` root node and remove all children from it.
|
|
524
553
|
*/
|
|
525
554
|
clearContainer(container) {
|
|
@@ -528,62 +557,68 @@ var hostConfig = {
|
|
|
528
557
|
});
|
|
529
558
|
container.children.splice(0);
|
|
530
559
|
},
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
// the "Hydration" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js).
|
|
539
|
-
// File an issue if you need help.
|
|
540
|
-
// -------------------
|
|
541
|
-
supportsHydration: false,
|
|
542
|
-
// React 19
|
|
543
|
-
// @ts-expect-error missing types
|
|
544
|
-
setCurrentUpdatePriority(newPriority) {
|
|
545
|
-
currentUpdatePriority = newPriority;
|
|
546
|
-
},
|
|
547
|
-
getCurrentUpdatePriority() {
|
|
548
|
-
return currentUpdatePriority;
|
|
549
|
-
},
|
|
550
|
-
resolveUpdatePriority() {
|
|
551
|
-
return currentUpdatePriority || import_constants.DefaultEventPriority;
|
|
552
|
-
},
|
|
553
|
-
shouldAttemptEagerTransition() {
|
|
554
|
-
return false;
|
|
555
|
-
},
|
|
556
|
-
// #### `maySuspendCommit(type, props)`
|
|
557
|
-
// This method is called during render to determine if the Host Component type and props require
|
|
558
|
-
// some kind of loading process to complete before committing an update.
|
|
559
|
-
maySuspendCommit() {
|
|
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) {
|
|
560
567
|
return false;
|
|
561
568
|
},
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
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) {
|
|
566
576
|
return true;
|
|
567
577
|
},
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
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
|
+
*/
|
|
571
584
|
startSuspendingCommit() {
|
|
572
585
|
},
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
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
|
+
*/
|
|
576
592
|
suspendInstance() {
|
|
577
593
|
},
|
|
578
|
-
|
|
579
|
-
|
|
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
|
+
*/
|
|
580
604
|
waitForCommitToBeReady() {
|
|
581
605
|
return null;
|
|
582
606
|
},
|
|
607
|
+
// -------------------
|
|
608
|
+
// Hydration Methods
|
|
609
|
+
// (optional)
|
|
610
|
+
// You can optionally implement hydration to "attach" to the existing tree during the initial render instead
|
|
611
|
+
// of creating it from scratch. For example, the DOM renderer uses this to attach to an HTML markup.
|
|
612
|
+
//
|
|
613
|
+
// To support hydration, you need to declare `supportsHydration: true` and then implement the methods in
|
|
614
|
+
// the "Hydration" section [listed in this file](https://github.com/facebook/react/blob/master/packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js).
|
|
615
|
+
// File an issue if you need help.
|
|
616
|
+
// -------------------
|
|
617
|
+
supportsHydration: false,
|
|
583
618
|
NotPendingTransition: null,
|
|
584
|
-
resetFormInstance() {
|
|
619
|
+
resetFormInstance(_form) {
|
|
585
620
|
},
|
|
586
|
-
requestPostPaintCallback() {
|
|
621
|
+
requestPostPaintCallback(_callback) {
|
|
587
622
|
}
|
|
588
623
|
};
|
|
589
624
|
var TestReconciler = (0, import_react_reconciler.default)(hostConfig);
|
|
@@ -743,14 +778,16 @@ var HostElement = class _HostElement {
|
|
|
743
778
|
|
|
744
779
|
// src/renderer.ts
|
|
745
780
|
var import_constants4 = require("react-reconciler/constants");
|
|
746
|
-
function
|
|
781
|
+
function createRoot(options) {
|
|
747
782
|
var _a;
|
|
748
783
|
let container = {
|
|
749
784
|
tag: "CONTAINER",
|
|
750
785
|
children: [],
|
|
751
786
|
parent: null,
|
|
752
|
-
|
|
753
|
-
|
|
787
|
+
config: {
|
|
788
|
+
textComponents: options == null ? void 0 : options.textComponents,
|
|
789
|
+
createNodeMock: (_a = options == null ? void 0 : options.createNodeMock) != null ? _a : () => ({})
|
|
790
|
+
}
|
|
754
791
|
};
|
|
755
792
|
let containerFiber = TestReconciler.createContainer(
|
|
756
793
|
container,
|
|
@@ -814,6 +851,6 @@ function createRenderer(options) {
|
|
|
814
851
|
// Annotate the CommonJS export names for ESM import in node:
|
|
815
852
|
0 && (module.exports = {
|
|
816
853
|
CONTAINER_TYPE,
|
|
817
|
-
|
|
854
|
+
createRoot
|
|
818
855
|
});
|
|
819
856
|
//# sourceMappingURL=index.cjs.map
|