@mittwald/react-tunnel 0.2.0-alpha.783 → 0.2.0-alpha.784
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 +83 -79
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,82 +1,86 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { observer as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
3
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
4
|
+
import { useState as E, useRef as h, createContext as g, useContext as m, useId as v, useEffect as p } from "react";
|
|
5
|
+
import { observable as f, makeObservable as b, action as C } from "mobx";
|
|
6
|
+
import { observer as w } from "mobx-react-lite";
|
|
7
|
+
const l = "default";
|
|
8
|
+
class o {
|
|
9
|
+
children = f.map(
|
|
10
|
+
{},
|
|
11
|
+
{
|
|
12
|
+
deep: !1
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
preparedChildren = /* @__PURE__ */ new Map();
|
|
16
|
+
nextIndex = 0;
|
|
17
|
+
constructor() {
|
|
18
|
+
b(this, {
|
|
19
|
+
deleteChildren: C.bound,
|
|
20
|
+
setChildren: C.bound
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
static useNew() {
|
|
24
|
+
const e = E(() => new o())[0];
|
|
25
|
+
return e.resetIndex(), e;
|
|
26
|
+
}
|
|
27
|
+
resetIndex() {
|
|
28
|
+
this.nextIndex = 0;
|
|
29
|
+
}
|
|
30
|
+
useEntryIndex() {
|
|
31
|
+
const e = h(this), t = h(null);
|
|
32
|
+
return (t.current === null || e.current !== this) && (e.current = this, t.current = this.nextIndex++), t.current;
|
|
33
|
+
}
|
|
34
|
+
setChildren(e = l, t, r, n) {
|
|
35
|
+
const i = {
|
|
36
|
+
id: t,
|
|
37
|
+
index: r,
|
|
38
|
+
children: n
|
|
39
|
+
}, s = this.children.get(e) ?? f.map({}, { deep: !1 });
|
|
40
|
+
s.set(t, i), this.preparedChildren.get(e)?.delete(t), this.children.set(e, s);
|
|
41
|
+
}
|
|
42
|
+
prepareChildren(e = l, t, r, n) {
|
|
43
|
+
const i = {
|
|
44
|
+
id: t,
|
|
45
|
+
index: r,
|
|
46
|
+
children: n
|
|
47
|
+
}, s = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
48
|
+
s.set(t, i), this.preparedChildren.set(e, s);
|
|
49
|
+
}
|
|
50
|
+
deleteChildrenFromMap(e, t, r) {
|
|
51
|
+
const n = e.get(t);
|
|
52
|
+
n?.delete(r), n?.size === 0 && e.delete(t);
|
|
53
|
+
}
|
|
54
|
+
deleteChildren(e = l, t) {
|
|
55
|
+
this.deleteChildrenFromMap(this.children, e, t), this.deleteChildrenFromMap(this.preparedChildren, e, t);
|
|
56
|
+
}
|
|
57
|
+
getEntries(e = l) {
|
|
58
|
+
const t = this.children.get(e)?.values() ?? this.preparedChildren.get(e)?.values();
|
|
59
|
+
if (t)
|
|
60
|
+
return Array.from(t).sort(
|
|
61
|
+
(r, n) => r.index - n.index
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const u = g(new o()), I = (d) => {
|
|
66
|
+
const { children: e } = d;
|
|
67
|
+
return /* @__PURE__ */ x(u.Provider, { value: o.useNew(), children: e });
|
|
68
|
+
}, R = (d) => {
|
|
69
|
+
const { children: e, id: t, staticEntryId: r } = d, n = m(u), i = v(), s = r ?? i, c = n.useEntryIndex(), a = h(!1);
|
|
70
|
+
return a.current || n.prepareChildren(t, s, c, e), p(() => {
|
|
71
|
+
a.current = !0, n.setChildren(t, s, c, e);
|
|
72
|
+
}, [e, t, s, c]), p(() => () => {
|
|
73
|
+
n.deleteChildren(t, s);
|
|
74
|
+
}, [t, s]), null;
|
|
75
|
+
}, y = (d) => {
|
|
76
|
+
const { children: e } = d;
|
|
77
|
+
return typeof e == "function" ? e() : e;
|
|
78
|
+
}, N = w((d) => {
|
|
79
|
+
const { children: e, id: t } = d, r = m(u).getEntries(t), n = r ? r.map((i) => /* @__PURE__ */ x(y, { children: i.children }, i.id)) : null;
|
|
80
|
+
return typeof e == "function" ? e(n) : n ?? e;
|
|
80
81
|
});
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
export {
|
|
83
|
+
R as TunnelEntry,
|
|
84
|
+
N as TunnelExit,
|
|
85
|
+
I as TunnelProvider
|
|
86
|
+
};
|
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.784",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -38,26 +38,26 @@
|
|
|
38
38
|
"@types/node": "^24.10.9",
|
|
39
39
|
"@types/react": "^19.2",
|
|
40
40
|
"@types/react-dom": "^19.2",
|
|
41
|
-
"@vitejs/plugin-react": "^
|
|
42
|
-
"@vitest/browser-playwright": "^4.
|
|
43
|
-
"@vitest/coverage-v8": "^4.
|
|
41
|
+
"@vitejs/plugin-react": "^5.1.3",
|
|
42
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
43
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
44
44
|
"nx": "^22.4.4",
|
|
45
45
|
"prettier": "^3.8.1",
|
|
46
46
|
"react": "^19.2.0",
|
|
47
47
|
"react-dom": "^19.2.0",
|
|
48
48
|
"rimraf": "^6.1.2",
|
|
49
49
|
"typescript": "^5.9.3",
|
|
50
|
-
"vite": "^
|
|
50
|
+
"vite": "^7.3.1",
|
|
51
51
|
"vite-plugin-banner": "^0.8.1",
|
|
52
52
|
"vite-plugin-checker": "^0.12.0",
|
|
53
53
|
"vite-plugin-dts": "^4.5.4",
|
|
54
54
|
"vite-plugin-externalize-deps": "^0.10.0",
|
|
55
|
-
"vitest": "^4.
|
|
56
|
-
"vitest-browser-react": "^2.2
|
|
55
|
+
"vitest": "^4.0.18",
|
|
56
|
+
"vitest-browser-react": "^2.0.2"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"react": "^19.2.0",
|
|
60
60
|
"react-dom": "^19.2.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "38762a66c3e86e5d5613dc18dc111cbeb5b402b4"
|
|
63
63
|
}
|