@mittwald/react-tunnel 0.2.0-alpha.780 → 0.2.0-alpha.782
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 +79 -83
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,86 +1,82 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { observer as
|
|
7
|
-
|
|
8
|
-
class
|
|
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
|
-
|
|
80
|
-
return typeof e == "function" ? e(n) : n ?? e;
|
|
3
|
+
import { createContext as e, useContext as t, useEffect as n, useId as r, useRef as i, useState as a } from "react";
|
|
4
|
+
import { action as o, makeObservable as s, observable as c } from "mobx";
|
|
5
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
6
|
+
import { observer as u } from "mobx-react-lite";
|
|
7
|
+
//#region src/TunnelState.ts
|
|
8
|
+
var d = "default", f = class e {
|
|
9
|
+
children = c.map({}, { deep: !1 });
|
|
10
|
+
preparedChildren = /* @__PURE__ */ new Map();
|
|
11
|
+
nextIndex = 0;
|
|
12
|
+
constructor() {
|
|
13
|
+
s(this, {
|
|
14
|
+
deleteChildren: o.bound,
|
|
15
|
+
setChildren: o.bound
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
static useNew() {
|
|
19
|
+
let t = a(() => new e())[0];
|
|
20
|
+
return t.resetIndex(), t;
|
|
21
|
+
}
|
|
22
|
+
resetIndex() {
|
|
23
|
+
this.nextIndex = 0;
|
|
24
|
+
}
|
|
25
|
+
useEntryIndex() {
|
|
26
|
+
let e = i(this), t = i(null);
|
|
27
|
+
return (t.current === null || e.current !== this) && (e.current = this, t.current = this.nextIndex++), t.current;
|
|
28
|
+
}
|
|
29
|
+
setChildren(e = d, t, n, r) {
|
|
30
|
+
let i = {
|
|
31
|
+
id: t,
|
|
32
|
+
index: n,
|
|
33
|
+
children: r
|
|
34
|
+
}, a = this.children.get(e) ?? c.map({}, { deep: !1 });
|
|
35
|
+
a.set(t, i), this.preparedChildren.get(e)?.delete(t), this.children.set(e, a);
|
|
36
|
+
}
|
|
37
|
+
prepareChildren(e = d, t, n, r) {
|
|
38
|
+
let i = {
|
|
39
|
+
id: t,
|
|
40
|
+
index: n,
|
|
41
|
+
children: r
|
|
42
|
+
}, a = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
43
|
+
a.set(t, i), this.preparedChildren.set(e, a);
|
|
44
|
+
}
|
|
45
|
+
deleteChildrenFromMap(e, t, n) {
|
|
46
|
+
let r = e.get(t);
|
|
47
|
+
r?.delete(n), r?.size === 0 && e.delete(t);
|
|
48
|
+
}
|
|
49
|
+
deleteChildren(e = d, t) {
|
|
50
|
+
this.deleteChildrenFromMap(this.children, e, t), this.deleteChildrenFromMap(this.preparedChildren, e, t);
|
|
51
|
+
}
|
|
52
|
+
getEntries(e = d) {
|
|
53
|
+
let t = this.children.get(e)?.values() ?? this.preparedChildren.get(e)?.values();
|
|
54
|
+
if (t) return Array.from(t).sort((e, t) => e.index - t.index);
|
|
55
|
+
}
|
|
56
|
+
}, p = e(new f()), m = (e) => {
|
|
57
|
+
let { children: t } = e;
|
|
58
|
+
return /* @__PURE__ */ l(p.Provider, {
|
|
59
|
+
value: f.useNew(),
|
|
60
|
+
children: t
|
|
61
|
+
});
|
|
62
|
+
}, h = (e) => {
|
|
63
|
+
let { children: a, id: o, staticEntryId: s } = e, c = t(p), l = r(), u = s ?? l, d = c.useEntryIndex(), f = i(!1);
|
|
64
|
+
return f.current || c.prepareChildren(o, u, d, a), n(() => {
|
|
65
|
+
f.current = !0, c.setChildren(o, u, d, a);
|
|
66
|
+
}, [
|
|
67
|
+
a,
|
|
68
|
+
o,
|
|
69
|
+
u,
|
|
70
|
+
d
|
|
71
|
+
]), n(() => () => {
|
|
72
|
+
c.deleteChildren(o, u);
|
|
73
|
+
}, [o, u]), null;
|
|
74
|
+
}, g = (e) => {
|
|
75
|
+
let { children: t } = e;
|
|
76
|
+
return typeof t == "function" ? t() : t;
|
|
77
|
+
}, _ = u((e) => {
|
|
78
|
+
let { children: n, id: r } = e, i = t(p).getEntries(r), a = i ? i.map((e) => /* @__PURE__ */ l(g, { children: e.children }, e.id)) : null;
|
|
79
|
+
return typeof n == "function" ? n(a) : a ?? n;
|
|
81
80
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
N as TunnelExit,
|
|
85
|
-
I as TunnelProvider
|
|
86
|
-
};
|
|
81
|
+
//#endregion
|
|
82
|
+
export { h as TunnelEntry, _ as TunnelExit, m as TunnelProvider };
|
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.782",
|
|
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": "^6.0.1",
|
|
42
|
+
"@vitest/browser-playwright": "^4.1.3",
|
|
43
|
+
"@vitest/coverage-v8": "^4.1.3",
|
|
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": "^8.0.8",
|
|
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.0
|
|
55
|
+
"vitest": "^4.1.3",
|
|
56
|
+
"vitest-browser-react": "^2.2.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"react": "^19.2.0",
|
|
60
60
|
"react-dom": "^19.2.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "064502040a73940325804ff924f88c5f618fb15b"
|
|
63
63
|
}
|