@mittwald/react-tunnel 0.1.0-alpha.59 → 0.1.0-alpha.65
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 +43 -37
- package/dist/types/TunnelState.d.ts +4 -6
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,51 +1,57 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import C, { useState as
|
|
7
|
-
import {
|
|
8
|
-
import { observer as
|
|
9
|
-
const
|
|
10
|
-
class
|
|
3
|
+
var f = Object.defineProperty;
|
|
4
|
+
var m = (r, e, t) => e in r ? f(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
5
|
+
var u = (r, e, t) => (m(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
6
|
+
import C, { useState as p, createContext as b, useContext as a, useId as v, useRef as E, useLayoutEffect as g } from "react";
|
|
7
|
+
import { observable as c, makeObservable as x, action as h } from "mobx";
|
|
8
|
+
import { observer as w } from "mobx-react-lite";
|
|
9
|
+
const i = "default";
|
|
10
|
+
class l {
|
|
11
11
|
constructor() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
u(this, "children", c.map(
|
|
13
|
+
{},
|
|
14
|
+
{
|
|
15
|
+
deep: !1
|
|
16
|
+
}
|
|
17
|
+
));
|
|
18
|
+
x(this, {
|
|
19
|
+
deleteChildren: h.bound,
|
|
20
|
+
setChildren: h.bound
|
|
17
21
|
});
|
|
18
22
|
}
|
|
19
23
|
static useNew() {
|
|
20
|
-
return
|
|
24
|
+
return p(new l())[0];
|
|
21
25
|
}
|
|
22
|
-
setChildren(e =
|
|
23
|
-
this.children
|
|
26
|
+
setChildren(e = i, t, n) {
|
|
27
|
+
const s = this.children.get(e) ?? c.map({}, { deep: !1 });
|
|
28
|
+
s.set(t, n), this.children.set(e, s);
|
|
24
29
|
}
|
|
25
|
-
deleteChildren(e =
|
|
26
|
-
|
|
30
|
+
deleteChildren(e = i, t) {
|
|
31
|
+
var n;
|
|
32
|
+
(n = this.children.get(e)) == null || n.delete(t);
|
|
27
33
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
getChildren(e = i) {
|
|
35
|
+
var n;
|
|
36
|
+
const t = (n = this.children.get(e)) == null ? void 0 : n.values();
|
|
37
|
+
if (t)
|
|
38
|
+
return Array.from(t);
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
|
-
const
|
|
36
|
-
const { children: e } =
|
|
37
|
-
return /* @__PURE__ */ C.createElement(
|
|
38
|
-
},
|
|
39
|
-
const { children: e, id:
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
}), [e,
|
|
43
|
-
}
|
|
44
|
-
const { children: e, id:
|
|
45
|
-
return
|
|
41
|
+
const o = b(new l()), P = (r) => {
|
|
42
|
+
const { children: e } = r;
|
|
43
|
+
return /* @__PURE__ */ C.createElement(o.Provider, { value: l.useNew() }, e);
|
|
44
|
+
}, R = (r) => {
|
|
45
|
+
const { children: e, id: t } = r, n = a(o), s = v(), d = E(!1);
|
|
46
|
+
return d.current || n.setChildren(t, s, e), g(() => (d.current = !0, n.setChildren(t, s, e), () => {
|
|
47
|
+
n.deleteChildren(t, s);
|
|
48
|
+
}), [e, t, s]), null;
|
|
49
|
+
}, k = w((r) => {
|
|
50
|
+
const { children: e, id: t } = r;
|
|
51
|
+
return a(o).getChildren(t) ?? e;
|
|
46
52
|
});
|
|
47
53
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
R as TunnelEntry,
|
|
55
|
+
k as TunnelExit,
|
|
56
|
+
P as TunnelProvider
|
|
51
57
|
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import { ObservableMap } from 'mobx';
|
|
1
2
|
import { ReactNode } from 'react';
|
|
2
3
|
|
|
3
|
-
type TunnelNodes = Record<string, ReactNode>;
|
|
4
4
|
export declare class TunnelState {
|
|
5
|
-
readonly children:
|
|
5
|
+
readonly children: ObservableMap<string, ObservableMap<string, ReactNode>>;
|
|
6
6
|
constructor();
|
|
7
7
|
static useNew(): TunnelState;
|
|
8
|
-
setChildren(tunnelId: string | undefined, children: ReactNode): void;
|
|
9
|
-
deleteChildren(tunnelId
|
|
10
|
-
hasChildren(tunnelId?: string): boolean;
|
|
8
|
+
setChildren(tunnelId: string | undefined, entryId: string, children: ReactNode): void;
|
|
9
|
+
deleteChildren(tunnelId: string | undefined, entryId: string): void;
|
|
11
10
|
getChildren(tunnelId?: string): ReactNode;
|
|
12
11
|
}
|
|
13
|
-
export {};
|
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.65",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
"mobx-react-lite": "^4.0.7"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@testing-library/react": "^14.
|
|
38
|
-
"@types/node": "^20.12.
|
|
39
|
-
"@types/react": "^18.2.
|
|
37
|
+
"@testing-library/react": "^14.3.0",
|
|
38
|
+
"@types/node": "^20.12.7",
|
|
39
|
+
"@types/react": "^18.2.75",
|
|
40
40
|
"@types/react-dom": "^18.2.24",
|
|
41
41
|
"@vitejs/plugin-react": "^4.2.1",
|
|
42
42
|
"@vitest/coverage-v8": "^1.4.0",
|
|
43
43
|
"happy-dom": "^14.7.1",
|
|
44
|
-
"nx": "^18.2.
|
|
44
|
+
"nx": "^18.2.4",
|
|
45
45
|
"prettier": "^3.2.5",
|
|
46
46
|
"react": "^18.2.0",
|
|
47
47
|
"react-dom": "^18.2.0",
|
|
48
|
-
"typescript": "^5.4.
|
|
48
|
+
"typescript": "^5.4.5",
|
|
49
49
|
"vite": "^5.2.8",
|
|
50
50
|
"vite-plugin-banner": "^0.7.1",
|
|
51
51
|
"vite-plugin-checker": "^0.6.4",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"react": "^18.2.0",
|
|
58
58
|
"react-dom": "^18.2.0"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "000868d3499fd78147a5a50f1d5e6571c18527b7"
|
|
61
61
|
}
|