@mittwald/react-tunnel 0.2.0-alpha.818 → 0.2.0-alpha.819
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 +29 -29
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { observable as
|
|
6
|
-
import { observer as
|
|
7
|
-
const u = "default",
|
|
3
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
4
|
+
import { useState as I, useRef as v, createContext as E, useContext as p, useId as w, useLayoutEffect as y, useEffect as b } from "react";
|
|
5
|
+
import { observable as h, makeObservable as T, action as f } from "mobx";
|
|
6
|
+
import { observer as g } from "mobx-react-lite";
|
|
7
|
+
const u = "default", C = "default";
|
|
8
8
|
class l {
|
|
9
9
|
id;
|
|
10
|
-
children =
|
|
10
|
+
children = h.map(
|
|
11
11
|
{},
|
|
12
12
|
{
|
|
13
13
|
deep: !1
|
|
14
14
|
}
|
|
15
15
|
);
|
|
16
16
|
nextIndex = 0;
|
|
17
|
-
constructor(e =
|
|
18
|
-
this.id = e,
|
|
17
|
+
constructor(e = C) {
|
|
18
|
+
this.id = e, T(this, {
|
|
19
19
|
id: !1,
|
|
20
|
-
deleteChildren:
|
|
21
|
-
setChildren:
|
|
20
|
+
deleteChildren: f.bound,
|
|
21
|
+
setChildren: f.bound
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
static useNew(e) {
|
|
25
|
-
const t =
|
|
25
|
+
const t = I(() => new l(e))[0];
|
|
26
26
|
return t.resetIndex(), t;
|
|
27
27
|
}
|
|
28
28
|
resetIndex() {
|
|
29
29
|
this.nextIndex = 0;
|
|
30
30
|
}
|
|
31
31
|
useEntryIndex() {
|
|
32
|
-
const e =
|
|
32
|
+
const e = v(null);
|
|
33
33
|
return e.current === null && (e.current = this.nextIndex++), e.current;
|
|
34
34
|
}
|
|
35
35
|
setChildren(e = u, t, n, s) {
|
|
@@ -37,7 +37,7 @@ class l {
|
|
|
37
37
|
id: t,
|
|
38
38
|
index: n,
|
|
39
39
|
children: s
|
|
40
|
-
}, d = this.children.get(e) ??
|
|
40
|
+
}, d = this.children.get(e) ?? h.map({}, { deep: !1 });
|
|
41
41
|
d.set(t, i), this.children.set(e, d);
|
|
42
42
|
}
|
|
43
43
|
deleteChildren(e = u, t) {
|
|
@@ -52,10 +52,10 @@ class l {
|
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
const c =
|
|
55
|
+
const c = E({
|
|
56
56
|
state: new l()
|
|
57
|
-
}),
|
|
58
|
-
let e =
|
|
57
|
+
}), m = (r = C) => {
|
|
58
|
+
let e = p(c);
|
|
59
59
|
for (; e; ) {
|
|
60
60
|
if (e.state.id === r)
|
|
61
61
|
return e.state;
|
|
@@ -64,9 +64,9 @@ const c = w({
|
|
|
64
64
|
throw new Error(
|
|
65
65
|
`Could not get tunnel for provider ${r}. Please provider a TunnelProvider with this ID.`
|
|
66
66
|
);
|
|
67
|
-
},
|
|
68
|
-
const { children: e, id: t } = r, n =
|
|
69
|
-
return /* @__PURE__ */
|
|
67
|
+
}, k = (r) => {
|
|
68
|
+
const { children: e, id: t } = r, n = p(c);
|
|
69
|
+
return /* @__PURE__ */ x(
|
|
70
70
|
c.Provider,
|
|
71
71
|
{
|
|
72
72
|
value: {
|
|
@@ -76,22 +76,22 @@ const c = w({
|
|
|
76
76
|
children: e
|
|
77
77
|
}
|
|
78
78
|
);
|
|
79
|
-
},
|
|
80
|
-
const { children: e, id: t, staticEntryId: n, providerId: s } = r, i =
|
|
81
|
-
return
|
|
79
|
+
}, z = (r) => {
|
|
80
|
+
const { children: e, id: t, staticEntryId: n, providerId: s } = r, i = m(s), d = w(), o = n ?? d, a = i.useEntryIndex();
|
|
81
|
+
return y(() => {
|
|
82
82
|
i.setChildren(t, o, a, e);
|
|
83
|
-
}, [e, t, o, a, s]),
|
|
83
|
+
}, [e, t, o, a, s]), b(() => () => {
|
|
84
84
|
i.deleteChildren(t, o);
|
|
85
85
|
}, [t, o, s]), null;
|
|
86
|
-
},
|
|
86
|
+
}, P = (r) => {
|
|
87
87
|
const { children: e } = r;
|
|
88
88
|
return typeof e == "function" ? e() : e;
|
|
89
|
-
},
|
|
90
|
-
const { children: e, id: t, providerId: n } = r, s =
|
|
89
|
+
}, A = g((r) => {
|
|
90
|
+
const { children: e, id: t, providerId: n } = r, s = m(n).getEntries(t), i = s ? s.map((d) => /* @__PURE__ */ x(P, { children: d.children }, d.id)) : null;
|
|
91
91
|
return typeof e == "function" ? e(i) : i ?? e;
|
|
92
92
|
});
|
|
93
93
|
export {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
z as TunnelEntry,
|
|
95
|
+
A as TunnelExit,
|
|
96
|
+
k as TunnelProvider
|
|
97
97
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/react-tunnel",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.819",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"react": "^19.2.0",
|
|
60
60
|
"react-dom": "^19.2.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "f475d198902ad9e857714633d6ce7900326d9125"
|
|
63
63
|
}
|