@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.
Files changed (2) hide show
  1. package/dist/index.mjs +14 -11
  2. 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
- _suspensionCount++;
38
- let settled = false;
39
- const onSettled = () => {
40
- if (settled) return;
41
- settled = true;
42
- _suspensionCount--;
43
- };
44
- err.then(onSettled, onSettled);
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 oldDiffed = options.diffed;
49
- options.diffed = (vnode) => {
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 (oldDiffed) oldDiffed(vnode);
57
+ if (oldCommit) oldCommit(vnode, commitQueue);
55
58
  };
56
59
  /**
57
60
  * Mark the start of a hydration pass. Call this right before `hydrate()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pracht/core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "homepage": "https://github.com/JoviDeCroock/pracht/tree/main/packages/framework",
5
5
  "bugs": {
6
6
  "url": "https://github.com/JoviDeCroock/pracht/issues"