@mittwald/react-tunnel 1.6.0-next.43 → 1.6.0-next.44
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.js +37 -37
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
|
|
2
|
-
import { createContext as e, useContext as t, useEffect as n, useId as r, useLayoutEffect as i,
|
|
3
|
-
import { action as
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { observer as
|
|
2
|
+
import { createContext as e, useContext as t, useEffect as n, useId as r, useLayoutEffect as i, useMemo as a, useReducer as o, useRef as s, useState as c, useSyncExternalStore as l } from "react";
|
|
3
|
+
import { action as u, makeObservable as d, observable as f } from "mobx";
|
|
4
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
5
|
+
import { observer as m } from "mobx-react-lite";
|
|
6
6
|
//#region src/TunnelState.ts
|
|
7
|
-
var
|
|
7
|
+
var h = "default", g = "default", _ = class e {
|
|
8
8
|
id;
|
|
9
9
|
instanceId;
|
|
10
|
-
committedChildren =
|
|
10
|
+
committedChildren = f.map({}, { deep: !1 });
|
|
11
11
|
renderPhaseChildren = /* @__PURE__ */ new Map();
|
|
12
12
|
nextIndex = 0;
|
|
13
|
-
constructor(e =
|
|
14
|
-
this.id = e, this.instanceId = t,
|
|
13
|
+
constructor(e = g, t = g) {
|
|
14
|
+
this.id = e, this.instanceId = t, d(this, {
|
|
15
15
|
id: !1,
|
|
16
|
-
deleteChildren:
|
|
17
|
-
setChildren:
|
|
16
|
+
deleteChildren: u.bound,
|
|
17
|
+
setChildren: u.bound
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
static useNew(t) {
|
|
21
|
-
let n = r(), i =
|
|
21
|
+
let n = r(), i = c(() => new e(t, n))[0];
|
|
22
22
|
return i.resetIndex(), i;
|
|
23
23
|
}
|
|
24
24
|
resetIndex() {
|
|
25
25
|
this.nextIndex = 0;
|
|
26
26
|
}
|
|
27
27
|
useEntryIndex() {
|
|
28
|
-
let e =
|
|
28
|
+
let e = s(this.instanceId), t = s(null);
|
|
29
29
|
return (t.current === null || e.current !== this.instanceId) && (e.current = this.instanceId, t.current = this.nextIndex++), t.current;
|
|
30
30
|
}
|
|
31
31
|
buildEntryState(e, t, n, r, i) {
|
|
@@ -37,11 +37,11 @@ var m = "default", h = "default", g = class e {
|
|
|
37
37
|
owners: a
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
setChildren(e =
|
|
41
|
-
let a = this.committedChildren.get(e) ??
|
|
40
|
+
setChildren(e = h, t, n, r, i) {
|
|
41
|
+
let a = this.committedChildren.get(e) ?? f.map({}, { deep: !1 });
|
|
42
42
|
a.set(t, this.buildEntryState(a.get(t), t, n, r, i)), this.deleteOwnerFromMap(this.renderPhaseChildren, e, t, n), this.committedChildren.set(e, a);
|
|
43
43
|
}
|
|
44
|
-
setRenderPhaseChildren(e =
|
|
44
|
+
setRenderPhaseChildren(e = h, t, n, r, i) {
|
|
45
45
|
let a = this.renderPhaseChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
46
46
|
a.set(t, this.buildEntryState(a.get(t), t, n, r, i)), this.renderPhaseChildren.set(e, a);
|
|
47
47
|
}
|
|
@@ -58,34 +58,34 @@ var m = "default", h = "default", g = class e {
|
|
|
58
58
|
}
|
|
59
59
|
i.delete(n), i.size === 0 && e.delete(t);
|
|
60
60
|
}
|
|
61
|
-
deleteChildren(e =
|
|
61
|
+
deleteChildren(e = h, t, n) {
|
|
62
62
|
this.deleteOwnerFromMap(this.committedChildren, e, t, n), this.deleteOwnerFromMap(this.renderPhaseChildren, e, t, n);
|
|
63
63
|
}
|
|
64
|
-
getEntries(e =
|
|
64
|
+
getEntries(e = h, t = !1) {
|
|
65
65
|
let n = this.committedChildren.get(e)?.values(), r = t ? this.renderPhaseChildren.get(e)?.values() : void 0, i = n ?? r;
|
|
66
66
|
if (i) return {
|
|
67
67
|
committed: !!n,
|
|
68
68
|
entries: Array.from(i).sort((e, t) => e.index - t.index)
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
},
|
|
72
|
-
let n = t(
|
|
71
|
+
}, v = e({ state: new _() }), y = (e = g) => {
|
|
72
|
+
let n = t(v);
|
|
73
73
|
for (; n;) {
|
|
74
74
|
if (n.state.id === e) return n.state;
|
|
75
75
|
n = n.parentContext;
|
|
76
76
|
}
|
|
77
77
|
throw Error(`Could not get tunnel for provider ${e}. Please provider a TunnelProvider with this ID.`);
|
|
78
|
-
},
|
|
79
|
-
let { children: n, id: r } = e, i = t(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
}, b = (e) => {
|
|
79
|
+
let { children: n, id: r } = e, i = t(v), o = _.useNew(r), s = a(() => ({
|
|
80
|
+
state: o,
|
|
81
|
+
parentContext: i
|
|
82
|
+
}), [o, i]);
|
|
83
|
+
return /* @__PURE__ */ p(v.Provider, {
|
|
84
|
+
value: s,
|
|
85
85
|
children: n
|
|
86
86
|
});
|
|
87
|
-
},
|
|
88
|
-
let { children: t, id: a, staticEntryId:
|
|
87
|
+
}, x = (e) => {
|
|
88
|
+
let { children: t, id: a, staticEntryId: o, providerId: c } = e, l = y(c), u = r(), d = o ?? u, f = l.useEntryIndex(), p = s(!1);
|
|
89
89
|
return p.current || l.setRenderPhaseChildren(a, d, u, f, t), i(() => {
|
|
90
90
|
p.current = !0, l.setChildren(a, d, u, f, t);
|
|
91
91
|
}, [
|
|
@@ -103,20 +103,20 @@ var m = "default", h = "default", g = class e {
|
|
|
103
103
|
u,
|
|
104
104
|
c
|
|
105
105
|
]), null;
|
|
106
|
-
},
|
|
106
|
+
}, S = (e) => {
|
|
107
107
|
let { children: t } = e;
|
|
108
108
|
return typeof t == "function" ? t() : t;
|
|
109
|
-
},
|
|
110
|
-
let { children: t, id: n, providerId: r } = e,
|
|
109
|
+
}, C = m((e) => {
|
|
110
|
+
let { children: t, id: n, providerId: r } = e, a = l(() => () => null, () => !1, () => !0), c = s(!0);
|
|
111
111
|
i(() => {
|
|
112
|
-
|
|
112
|
+
c.current = !1;
|
|
113
113
|
}, []);
|
|
114
|
-
let u =
|
|
114
|
+
let u = y(r).getEntries(n, a || c.current), [, d] = o((e) => e + 1, 0), f = u?.committed === !0;
|
|
115
115
|
i(() => {
|
|
116
|
-
|
|
117
|
-
}, [
|
|
118
|
-
let m = u?.entries.map((e) => /* @__PURE__ */
|
|
116
|
+
f || d();
|
|
117
|
+
}, [f]);
|
|
118
|
+
let m = u?.entries.map((e) => /* @__PURE__ */ p(S, { children: e.children }, e.id));
|
|
119
119
|
return typeof t == "function" ? t(m) : m ?? t;
|
|
120
120
|
});
|
|
121
121
|
//#endregion
|
|
122
|
-
export {
|
|
122
|
+
export { x as TunnelEntry, C as TunnelExit, b as TunnelProvider };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/react-tunnel",
|
|
3
|
-
"version": "1.6.0-next.
|
|
3
|
+
"version": "1.6.0-next.44",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"mobx-react-lite": "^4.1.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@mittwald/flow-core": "1.6.0-next.
|
|
43
|
-
"@mittwald/typescript-config": "1.6.0-next.
|
|
42
|
+
"@mittwald/flow-core": "1.6.0-next.44",
|
|
43
|
+
"@mittwald/typescript-config": "1.6.0-next.44",
|
|
44
44
|
"@types/node": "^25.9.3",
|
|
45
45
|
"@types/react": "^19.2",
|
|
46
46
|
"@types/react-dom": "^19.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"react": "^19.2.0",
|
|
63
63
|
"react-dom": "^19.2.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "d78a04592e71e0174113920f2c2eacec46a373a1"
|
|
66
66
|
}
|