@pracht/core 0.2.0 → 0.2.1
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.mjs +14 -11
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -28,30 +28,33 @@ function forwardRef(fn) {
|
|
|
28
28
|
}
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/hydration.ts
|
|
31
|
+
const MODE_HYDRATE = 32;
|
|
31
32
|
let _hydrating = false;
|
|
32
33
|
let _suspensionCount = 0;
|
|
33
34
|
let _hydrated = false;
|
|
34
35
|
const oldCatchError = options.__e;
|
|
35
36
|
options.__e = (err, newVNode, oldVNode, errorInfo) => {
|
|
36
37
|
if (_hydrating && !_hydrated && err && err.then) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
if (!!(newVNode && newVNode.__u && newVNode.__u & MODE_HYDRATE) || !!(newVNode && newVNode.__h)) {
|
|
39
|
+
_suspensionCount++;
|
|
40
|
+
let settled = false;
|
|
41
|
+
const onSettled = () => {
|
|
42
|
+
if (settled) return;
|
|
43
|
+
settled = true;
|
|
44
|
+
_suspensionCount--;
|
|
45
|
+
};
|
|
46
|
+
err.then(onSettled, onSettled);
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
if (oldCatchError) oldCatchError(err, newVNode, oldVNode, errorInfo);
|
|
47
50
|
};
|
|
48
|
-
const
|
|
49
|
-
options.
|
|
51
|
+
const oldCommit = options.__c;
|
|
52
|
+
options.__c = (vnode, commitQueue) => {
|
|
50
53
|
if (_hydrating && !_hydrated && _suspensionCount <= 0) {
|
|
51
54
|
_hydrated = true;
|
|
52
55
|
_hydrating = false;
|
|
53
56
|
}
|
|
54
|
-
if (
|
|
57
|
+
if (oldCommit) oldCommit(vnode, commitQueue);
|
|
55
58
|
};
|
|
56
59
|
/**
|
|
57
60
|
* Mark the start of a hydration pass. Call this right before `hydrate()`.
|