@mittwald/react-tunnel 0.2.0-alpha.515 → 0.2.0-alpha.517
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 +42 -47
- package/package.json +14 -14
package/dist/index.js
CHANGED
|
@@ -1,72 +1,67 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
4
|
+
import { useState as m, createContext as g, useContext as f, useId as E, useRef as b, useEffect as u } from "react";
|
|
5
|
+
import { observable as p, makeObservable as v, action as a } from "mobx";
|
|
6
|
+
import { observer as w } from "mobx-react-lite";
|
|
7
|
+
const d = "default";
|
|
8
|
+
class l {
|
|
9
|
+
children = p.map(
|
|
10
|
+
{},
|
|
11
|
+
{
|
|
12
|
+
deep: !1
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
preparedChildren = /* @__PURE__ */ new Map();
|
|
12
16
|
constructor() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
deep: !1
|
|
17
|
-
}
|
|
18
|
-
));
|
|
19
|
-
h(this, "preparedChildren", /* @__PURE__ */ new Map());
|
|
20
|
-
y(this, {
|
|
21
|
-
deleteChildren: C.bound,
|
|
22
|
-
setChildren: C.bound
|
|
17
|
+
v(this, {
|
|
18
|
+
deleteChildren: a.bound,
|
|
19
|
+
setChildren: a.bound
|
|
23
20
|
});
|
|
24
21
|
}
|
|
25
22
|
static useNew() {
|
|
26
|
-
return
|
|
23
|
+
return m(() => new l())[0];
|
|
27
24
|
}
|
|
28
|
-
setChildren(e =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
t.set(r, i), (d = this.preparedChildren.get(e)) == null || d.delete(r), this.children.set(e, t);
|
|
25
|
+
setChildren(e = d, r, n) {
|
|
26
|
+
const t = this.children.get(e) ?? p.map({}, { deep: !1 });
|
|
27
|
+
t.set(r, n), this.preparedChildren.get(e)?.delete(r), this.children.set(e, t);
|
|
32
28
|
}
|
|
33
|
-
prepareChildren(e =
|
|
29
|
+
prepareChildren(e = d, r, n) {
|
|
34
30
|
const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
35
|
-
t.set(r,
|
|
31
|
+
t.set(r, n), this.preparedChildren.set(e, t);
|
|
36
32
|
}
|
|
37
|
-
deleteChildrenFromMap(e, r,
|
|
33
|
+
deleteChildrenFromMap(e, r, n) {
|
|
38
34
|
const t = e.get(r);
|
|
39
|
-
t
|
|
35
|
+
t?.delete(n), t?.size === 0 && e.delete(r);
|
|
40
36
|
}
|
|
41
|
-
deleteChildren(e =
|
|
37
|
+
deleteChildren(e = d, r) {
|
|
42
38
|
this.deleteChildrenFromMap(this.children, e, r), this.deleteChildrenFromMap(this.preparedChildren, e, r);
|
|
43
39
|
}
|
|
44
|
-
getChildren(e =
|
|
45
|
-
|
|
46
|
-
const r = ((i = this.children.get(e)) == null ? void 0 : i.entries()) ?? ((t = this.preparedChildren.get(e)) == null ? void 0 : t.entries());
|
|
40
|
+
getChildren(e = d) {
|
|
41
|
+
const r = this.children.get(e)?.entries() ?? this.preparedChildren.get(e)?.entries();
|
|
47
42
|
if (r)
|
|
48
43
|
return Array.from(r);
|
|
49
44
|
}
|
|
50
45
|
}
|
|
51
|
-
const
|
|
52
|
-
const { children: e } =
|
|
53
|
-
return /* @__PURE__ */
|
|
54
|
-
},
|
|
55
|
-
const { children: e, id: r, staticEntryId:
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
}, [e, r, s]),
|
|
46
|
+
const h = g(new l()), N = (i) => {
|
|
47
|
+
const { children: e } = i;
|
|
48
|
+
return /* @__PURE__ */ C(h.Provider, { value: l.useNew(), children: e });
|
|
49
|
+
}, P = (i) => {
|
|
50
|
+
const { children: e, id: r, staticEntryId: n } = i, t = f(h), o = E(), s = n ?? o, c = b(!1);
|
|
51
|
+
return c.current || t.prepareChildren(r, s, e), u(() => {
|
|
52
|
+
c.current = !0, t.setChildren(r, s, e);
|
|
53
|
+
}, [e, r, s]), u(() => () => {
|
|
59
54
|
t.deleteChildren(r, s);
|
|
60
55
|
}, [r, s]), null;
|
|
61
|
-
},
|
|
62
|
-
const { children: e } =
|
|
56
|
+
}, x = (i) => {
|
|
57
|
+
const { children: e } = i;
|
|
63
58
|
return typeof e == "function" ? e() : e;
|
|
64
|
-
},
|
|
65
|
-
const { children: e, id: r } =
|
|
59
|
+
}, R = w((i) => {
|
|
60
|
+
const { children: e, id: r } = i, n = f(h).getChildren(r), t = n ? n.map(([o, s]) => /* @__PURE__ */ C(x, { children: s }, o)) : null;
|
|
66
61
|
return typeof e == "function" ? e(t) : t ?? e;
|
|
67
62
|
});
|
|
68
63
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
P as TunnelEntry,
|
|
65
|
+
R as TunnelExit,
|
|
66
|
+
N as TunnelProvider
|
|
72
67
|
};
|
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.517",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -38,28 +38,28 @@
|
|
|
38
38
|
"@mittwald/typescript-config": "workspace:*",
|
|
39
39
|
"@testing-library/dom": "^10.4.1",
|
|
40
40
|
"@testing-library/react": "^16.3.0",
|
|
41
|
-
"@types/node": "^
|
|
42
|
-
"@types/react": "^19.
|
|
43
|
-
"@types/react-dom": "^19.
|
|
44
|
-
"@vitejs/plugin-react": "^
|
|
41
|
+
"@types/node": "^24.7.2",
|
|
42
|
+
"@types/react": "^19.2.2",
|
|
43
|
+
"@types/react-dom": "^19.2.2",
|
|
44
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
45
45
|
"@vitest/coverage-v8": "^3.2.4",
|
|
46
|
-
"happy-dom": "^
|
|
47
|
-
"nx": "^
|
|
46
|
+
"happy-dom": "^20.0.1",
|
|
47
|
+
"nx": "^21.6.4",
|
|
48
48
|
"prettier": "^3.6.2",
|
|
49
|
-
"react": "^19.
|
|
50
|
-
"react-dom": "^19.
|
|
49
|
+
"react": "^19.2.0",
|
|
50
|
+
"react-dom": "^19.2.0",
|
|
51
51
|
"rimraf": "^6.0.1",
|
|
52
|
-
"typescript": "^5.9.
|
|
53
|
-
"vite": "^
|
|
52
|
+
"typescript": "^5.9.3",
|
|
53
|
+
"vite": "^7.1.10",
|
|
54
54
|
"vite-plugin-banner": "^0.8.1",
|
|
55
|
-
"vite-plugin-checker": "^0.
|
|
55
|
+
"vite-plugin-checker": "^0.11.0",
|
|
56
56
|
"vite-plugin-dts": "^4.5.4",
|
|
57
|
-
"vite-plugin-externalize-deps": "^0.
|
|
57
|
+
"vite-plugin-externalize-deps": "^0.10.0",
|
|
58
58
|
"vitest": "^3.2.4"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"react": "^19",
|
|
62
62
|
"react-dom": "^19"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "761ba9a36c7238153866514f7ec0a6c28f887c8f"
|
|
65
65
|
}
|