@mittwald/react-tunnel 0.1.0-alpha.99 → 0.2.0-alpha.4
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 +44 -38
- package/dist/types/TunnelState.d.ts +4 -3
- package/dist/types/components/TunnelEntry.d.ts +3 -2
- package/dist/types/components/TunnelExit.d.ts +0 -1
- package/dist/types/components/TunnelProvider.d.ts +0 -1
- package/dist/types/context.d.ts +0 -1
- package/dist/types/types.d.ts +0 -1
- package/package.json +25 -24
package/dist/index.js
CHANGED
|
@@ -1,60 +1,66 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import
|
|
7
|
-
import { observable as
|
|
8
|
-
import { observer as
|
|
9
|
-
const
|
|
10
|
-
class
|
|
3
|
+
var g = Object.defineProperty;
|
|
4
|
+
var E = (s, e, t) => e in s ? g(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
5
|
+
var o = (s, e, t) => E(s, typeof e != "symbol" ? e + "" : e, t);
|
|
6
|
+
import C, { useRef as f, createContext as b, useContext as m, useId as v, useEffect as w } from "react";
|
|
7
|
+
import { observable as a, makeObservable as x, action as p } from "mobx";
|
|
8
|
+
import { observer as y } from "mobx-react-lite";
|
|
9
|
+
const l = "default";
|
|
10
|
+
class c {
|
|
11
11
|
constructor() {
|
|
12
|
-
|
|
12
|
+
o(this, "children", a.map(
|
|
13
13
|
{},
|
|
14
14
|
{
|
|
15
15
|
deep: !1
|
|
16
16
|
}
|
|
17
17
|
));
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
o(this, "preparedChildren", /* @__PURE__ */ new Map());
|
|
19
|
+
x(this, {
|
|
20
|
+
deleteChildren: p.bound,
|
|
21
|
+
setChildren: p.bound
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
24
|
static useNew() {
|
|
24
|
-
return
|
|
25
|
+
return f(new c()).current;
|
|
25
26
|
}
|
|
26
|
-
setChildren(e =
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
setChildren(e = l, t, n) {
|
|
28
|
+
var i;
|
|
29
|
+
const r = this.children.get(e) ?? a.map({}, { deep: !1 });
|
|
30
|
+
r.set(t, n), (i = this.preparedChildren.get(e)) == null || i.delete(t), this.children.set(e, r);
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(n
|
|
32
|
+
prepareChildren(e = l, t, n) {
|
|
33
|
+
const r = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
34
|
+
r.set(t, n), this.preparedChildren.set(e, r);
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
var n;
|
|
36
|
-
|
|
36
|
+
deleteChildren(e = l, t) {
|
|
37
|
+
var n, r;
|
|
38
|
+
(n = this.children.get(e)) == null || n.delete(t), (r = this.preparedChildren.get(e)) == null || r.delete(t);
|
|
39
|
+
}
|
|
40
|
+
getChildren(e = l) {
|
|
41
|
+
var n, r;
|
|
42
|
+
const t = ((n = this.children.get(e)) == null ? void 0 : n.entries()) ?? ((r = this.preparedChildren.get(e)) == null ? void 0 : r.entries());
|
|
37
43
|
if (t)
|
|
38
44
|
return Array.from(t);
|
|
39
45
|
}
|
|
40
46
|
}
|
|
41
|
-
const
|
|
42
|
-
const { children: e } =
|
|
43
|
-
return /* @__PURE__ */
|
|
44
|
-
},
|
|
45
|
-
const { children: e, id: t } =
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
}), [e, t,
|
|
49
|
-
},
|
|
50
|
-
const { children: e } =
|
|
47
|
+
const h = b(new c()), P = (s) => {
|
|
48
|
+
const { children: e } = s;
|
|
49
|
+
return /* @__PURE__ */ C.createElement(h.Provider, { value: c.useNew() }, e);
|
|
50
|
+
}, A = (s) => {
|
|
51
|
+
const { children: e, id: t, staticEntryId: n } = s, r = m(h), i = v(), d = n ?? i, u = f(!1);
|
|
52
|
+
return u.current || r.prepareChildren(t, d, e), w(() => (u.current = !0, r.setChildren(t, d, e), () => {
|
|
53
|
+
r.deleteChildren(t, d);
|
|
54
|
+
}), [e, t, d]), null;
|
|
55
|
+
}, R = (s) => {
|
|
56
|
+
const { children: e } = s;
|
|
51
57
|
return typeof e == "function" ? e() : e;
|
|
52
|
-
},
|
|
53
|
-
const { children: e, id: t } =
|
|
54
|
-
return n ? n.map(([
|
|
58
|
+
}, O = y((s) => {
|
|
59
|
+
const { children: e, id: t } = s, n = m(h).getChildren(t);
|
|
60
|
+
return n ? n.map(([r, i]) => /* @__PURE__ */ C.createElement(R, { key: r }, i)) : e;
|
|
55
61
|
});
|
|
56
62
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
63
|
+
A as TunnelEntry,
|
|
64
|
+
O as TunnelExit,
|
|
65
|
+
P as TunnelProvider
|
|
60
66
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { TunnelChildren } from './types';
|
|
2
1
|
import { ObservableMap } from 'mobx';
|
|
3
|
-
|
|
2
|
+
import { TunnelChildren } from './types';
|
|
4
3
|
export declare class TunnelState {
|
|
5
4
|
readonly children: ObservableMap<string, ObservableMap<string, TunnelChildren>>;
|
|
5
|
+
private readonly preparedChildren;
|
|
6
6
|
constructor();
|
|
7
7
|
static useNew(): TunnelState;
|
|
8
8
|
setChildren(tunnelId: string | undefined, entryId: string, children: TunnelChildren): void;
|
|
9
|
+
prepareChildren(tunnelId: string | undefined, entryId: string, children: TunnelChildren): void;
|
|
9
10
|
deleteChildren(tunnelId: string | undefined, entryId: string): void;
|
|
10
|
-
getChildren(tunnelId?: string):
|
|
11
|
+
getChildren(tunnelId?: string): [string, TunnelChildren][] | undefined;
|
|
11
12
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { TunnelChildren } from '../types';
|
|
2
1
|
import { FC } from 'react';
|
|
3
|
-
|
|
2
|
+
import { TunnelChildren } from '../types';
|
|
4
3
|
interface Props {
|
|
5
4
|
id?: string;
|
|
6
5
|
children?: TunnelChildren;
|
|
6
|
+
/** Static entry ID instead of generated ID by `useId` */
|
|
7
|
+
staticEntryId?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare const TunnelEntry: FC<Props>;
|
|
9
10
|
export default TunnelEntry;
|
package/dist/types/context.d.ts
CHANGED
package/dist/types/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/react-tunnel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-alpha.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"react tree",
|
|
11
11
|
"teleport"
|
|
12
12
|
],
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://github.com/mittwald/flow/tree/main/packages/react-tunnel",
|
|
14
14
|
"repository": "https://github.com/mittwald/flow",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
@@ -30,32 +30,33 @@
|
|
|
30
30
|
"test:unit": "run vitest run"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"mobx": "^6.
|
|
34
|
-
"mobx-react-lite": "^4.0
|
|
33
|
+
"mobx": "^6.13.5",
|
|
34
|
+
"mobx-react-lite": "^4.1.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@testing-library/
|
|
38
|
-
"@
|
|
39
|
-
"@types/
|
|
40
|
-
"@types/react
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"react
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"vite
|
|
51
|
-
"vite-plugin-
|
|
52
|
-
"vite-plugin-
|
|
37
|
+
"@testing-library/dom": "^10.4.0",
|
|
38
|
+
"@testing-library/react": "^16.1.0",
|
|
39
|
+
"@types/node": "^22.10.5",
|
|
40
|
+
"@types/react": "^19.0.4",
|
|
41
|
+
"@types/react-dom": "^19.0.2",
|
|
42
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
43
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
44
|
+
"happy-dom": "^15.11.7",
|
|
45
|
+
"nx": "^20.3.1",
|
|
46
|
+
"prettier": "^3.4.2",
|
|
47
|
+
"react": "19.0.0",
|
|
48
|
+
"react-dom": "19.0.0",
|
|
49
|
+
"typescript": "^5.7.3",
|
|
50
|
+
"vite": "^5.4.11",
|
|
51
|
+
"vite-plugin-banner": "^0.8.0",
|
|
52
|
+
"vite-plugin-checker": "^0.8.0",
|
|
53
|
+
"vite-plugin-dts": "^4.4.0",
|
|
53
54
|
"vite-plugin-externalize-deps": "^0.8.0",
|
|
54
|
-
"vitest": "^1.
|
|
55
|
+
"vitest": "^2.1.8"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
|
-
"react": "^
|
|
58
|
-
"react-dom": "^
|
|
58
|
+
"react": "^19.0.0",
|
|
59
|
+
"react-dom": "^19.0.0"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "24bbe11ee421ec40c75f32849d07f669600558cb"
|
|
61
62
|
}
|