@mittwald/react-tunnel 0.1.0-alpha.130 → 0.1.0-alpha.131
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 +5 -5
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var o = (i, e,
|
|
6
|
-
import
|
|
7
|
-
import { observable as h, makeObservable as
|
|
8
|
-
import { observer as
|
|
3
|
+
var f = Object.defineProperty;
|
|
4
|
+
var m = (i, e, r) => e in i ? f(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
|
|
5
|
+
var o = (i, e, r) => (m(i, typeof e != "symbol" ? e + "" : e, r), r);
|
|
6
|
+
import a, { useRef as p, createContext as g, useContext as C, useId as E, useLayoutEffect as b } from "react";
|
|
7
|
+
import { observable as h, makeObservable as v, action as u } from "mobx";
|
|
8
|
+
import { observer as w } from "mobx-react-lite";
|
|
9
9
|
const l = "default";
|
|
10
10
|
class d {
|
|
11
11
|
constructor() {
|
|
@@ -16,51 +16,51 @@ class d {
|
|
|
16
16
|
}
|
|
17
17
|
));
|
|
18
18
|
o(this, "preparedChildren", /* @__PURE__ */ new Map());
|
|
19
|
-
|
|
20
|
-
deleteChildren:
|
|
21
|
-
setChildren:
|
|
19
|
+
v(this, {
|
|
20
|
+
deleteChildren: u.bound,
|
|
21
|
+
setChildren: u.bound
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
static useNew() {
|
|
25
|
-
return
|
|
25
|
+
return p(new d()).current;
|
|
26
26
|
}
|
|
27
|
-
setChildren(e = l,
|
|
27
|
+
setChildren(e = l, r, n) {
|
|
28
28
|
var s;
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const t = this.children.get(e) ?? h.map({}, { deep: !1 });
|
|
30
|
+
t.set(r, n), (s = this.preparedChildren.get(e)) == null || s.delete(r), this.children.set(e, t);
|
|
31
31
|
}
|
|
32
|
-
prepareChildren(e = l,
|
|
33
|
-
const
|
|
34
|
-
|
|
32
|
+
prepareChildren(e = l, r, n) {
|
|
33
|
+
const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
34
|
+
t.set(r, n), this.preparedChildren.set(e, t);
|
|
35
35
|
}
|
|
36
|
-
deleteChildren(e = l,
|
|
37
|
-
var n,
|
|
38
|
-
(n = this.children.get(e)) == null || n.delete(
|
|
36
|
+
deleteChildren(e = l, r) {
|
|
37
|
+
var n, t;
|
|
38
|
+
(n = this.children.get(e)) == null || n.delete(r), (t = this.preparedChildren.get(e)) == null || t.delete(r);
|
|
39
39
|
}
|
|
40
40
|
getChildren(e = l) {
|
|
41
|
-
var n,
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return Array.from(
|
|
41
|
+
var n, t;
|
|
42
|
+
const r = ((n = this.children.get(e)) == null ? void 0 : n.entries()) ?? ((t = this.preparedChildren.get(e)) == null ? void 0 : t.entries());
|
|
43
|
+
if (r)
|
|
44
|
+
return Array.from(r);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const c = g(new d()),
|
|
47
|
+
const c = g(new d()), M = (i) => {
|
|
48
48
|
const { children: e } = i;
|
|
49
|
-
return /* @__PURE__ */
|
|
50
|
-
},
|
|
51
|
-
const { children: e, id:
|
|
52
|
-
return s.current || n.prepareChildren(
|
|
53
|
-
n.deleteChildren(
|
|
54
|
-
}), [e,
|
|
55
|
-
},
|
|
49
|
+
return /* @__PURE__ */ a.createElement(c.Provider, { value: d.useNew() }, e);
|
|
50
|
+
}, N = (i) => {
|
|
51
|
+
const { children: e, id: r } = i, n = C(c), t = E(), s = p(!1);
|
|
52
|
+
return s.current || n.prepareChildren(r, t, e), b(() => (s.current = !0, n.setChildren(r, t, e), () => {
|
|
53
|
+
n.deleteChildren(r, t);
|
|
54
|
+
}), [e, r, t]), null;
|
|
55
|
+
}, x = (i) => {
|
|
56
56
|
const { children: e } = i;
|
|
57
57
|
return typeof e == "function" ? e() : e;
|
|
58
|
-
},
|
|
59
|
-
const { children: e, id:
|
|
60
|
-
return n ? n.map(([
|
|
58
|
+
}, P = w((i) => {
|
|
59
|
+
const { children: e, id: r } = i, n = C(c).getChildren(r);
|
|
60
|
+
return n ? n.map(([t, s]) => /* @__PURE__ */ a.createElement(x, { key: t }, s)) : e;
|
|
61
61
|
});
|
|
62
62
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
N as TunnelEntry,
|
|
64
|
+
P as TunnelExit,
|
|
65
|
+
M as TunnelProvider
|
|
66
66
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/react-tunnel",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.131",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@testing-library/react": "^15.0.7",
|
|
38
38
|
"@types/node": "^20.12.12",
|
|
39
|
-
"@types/react": "^18.3.
|
|
39
|
+
"@types/react": "^18.3.3",
|
|
40
40
|
"@types/react-dom": "^18.3.0",
|
|
41
|
-
"@vitejs/plugin-react": "^4.
|
|
41
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
42
42
|
"@vitest/coverage-v8": "^1.6.0",
|
|
43
43
|
"happy-dom": "^14.11.0",
|
|
44
|
-
"nx": "^19.0
|
|
44
|
+
"nx": "^19.1.0",
|
|
45
45
|
"prettier": "^3.2.5",
|
|
46
46
|
"react": "^18.3.1",
|
|
47
47
|
"react-dom": "^18.3.1",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"react": "^18.2.0",
|
|
58
58
|
"react-dom": "^18.2.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "cd7bf7ba3a6a246a62b7665f8877597b3fb226f0"
|
|
61
61
|
}
|