what-react 0.13.4 → 0.13.5
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/package.json +2 -2
- package/src/dom.js +1 -0
- package/src/index.js +9 -1
- package/src/runtime.js +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "what-react",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"description": "React compatibility layer for What Framework — real React semantics (value hooks, re-renders, context) on a dedicated compat runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"compatibility"
|
|
54
54
|
],
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"what-core": "^0.13.
|
|
56
|
+
"what-core": "^0.13.5"
|
|
57
57
|
},
|
|
58
58
|
"author": "ZVN DEV (https://zvndev.com)",
|
|
59
59
|
"license": "MIT",
|
package/src/dom.js
CHANGED
package/src/index.js
CHANGED
|
@@ -340,7 +340,7 @@ export function lazy(loader) {
|
|
|
340
340
|
export function Suspense(props) {
|
|
341
341
|
const inst = _getCurrentInstance();
|
|
342
342
|
if (inst) inst._isSuspense = true;
|
|
343
|
-
if (inst && inst._suspendCount > 0) {
|
|
343
|
+
if (inst && (inst._suspendCount ?? 0) > 0) {
|
|
344
344
|
return props.fallback !== undefined ? props.fallback : null;
|
|
345
345
|
}
|
|
346
346
|
return props.children;
|
|
@@ -463,6 +463,10 @@ export function act(callback) {
|
|
|
463
463
|
// Function constructors (not native classes) so transpiled code using
|
|
464
464
|
// Component.call(this, props) works alongside native class extends.
|
|
465
465
|
|
|
466
|
+
/**
|
|
467
|
+
* @this {{ props: any, state: any, _mounted: boolean, _forceUpdate: (() => void) | null, [key: string]: any }}
|
|
468
|
+
* @param {any} props
|
|
469
|
+
*/
|
|
466
470
|
export function Component(props) {
|
|
467
471
|
this.props = props;
|
|
468
472
|
this.state = {};
|
|
@@ -491,6 +495,10 @@ Component.prototype.render = function () {
|
|
|
491
495
|
return null;
|
|
492
496
|
};
|
|
493
497
|
|
|
498
|
+
/**
|
|
499
|
+
* @this {{ props: any, state: any, _mounted: boolean, _forceUpdate: (() => void) | null, [key: string]: any }}
|
|
500
|
+
* @param {any} props
|
|
501
|
+
*/
|
|
494
502
|
export function PureComponent(props) {
|
|
495
503
|
Component.call(this, props);
|
|
496
504
|
}
|
package/src/runtime.js
CHANGED
|
@@ -49,12 +49,14 @@ const EMPTY_OBJ = {};
|
|
|
49
49
|
// Hook dispatcher state
|
|
50
50
|
// =====================================================================
|
|
51
51
|
|
|
52
|
+
/** @type {WhatCompatInstance | null} */
|
|
52
53
|
let currentInstance = null;
|
|
53
54
|
|
|
54
55
|
export function _getCurrentInstance() {
|
|
55
56
|
return currentInstance;
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
/** @returns {WhatCompatInstance} */
|
|
58
60
|
export function _requireInstance(hookName) {
|
|
59
61
|
if (!currentInstance) {
|
|
60
62
|
// ERROR_CODES.HOOK_OUTSIDE_RENDER
|
|
@@ -325,6 +327,7 @@ function canPatch(rn, v, kind) {
|
|
|
325
327
|
* - Pass 3 walks right-to-left fixing DOM positions with a moving anchor.
|
|
326
328
|
*/
|
|
327
329
|
export function patchChildren(parentDom, old, newValues, anchor, svg, owner) {
|
|
330
|
+
/** @type {Map<any, any> | null} */
|
|
328
331
|
let keyed = null;
|
|
329
332
|
const unkeyed = [];
|
|
330
333
|
for (let i = 0; i < old.length; i++) {
|
|
@@ -600,7 +603,9 @@ function mountOpaque(v, container) {
|
|
|
600
603
|
const end = document.createComment('/w:o');
|
|
601
604
|
container.appendChild(start);
|
|
602
605
|
|
|
606
|
+
/** @type {(() => void) | null} */
|
|
603
607
|
let dispose = null;
|
|
608
|
+
/** @type {DocumentFragment | null} */
|
|
604
609
|
let holder = null;
|
|
605
610
|
if (typeof v === 'object' && typeof v.nodeType === 'number') {
|
|
606
611
|
// Raw DOM node — insert as-is, caller owns its lifecycle.
|