@mittwald/react-tunnel 0.2.0-alpha.5 → 0.2.0-alpha.500
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 +48 -42
- package/dist/types/Tunnel.test.d.ts +1 -0
- package/dist/types/Tunnel.test.d.ts.map +1 -0
- package/dist/types/TunnelState.d.ts +4 -1
- package/dist/types/TunnelState.d.ts.map +1 -0
- package/dist/types/components/TunnelEntry.d.ts +6 -5
- package/dist/types/components/TunnelEntry.d.ts.map +1 -0
- package/dist/types/components/TunnelExit.d.ts +7 -3
- package/dist/types/components/TunnelExit.d.ts.map +1 -0
- package/dist/types/components/TunnelProvider.d.ts +1 -0
- package/dist/types/components/TunnelProvider.d.ts.map +1 -0
- package/dist/types/context.d.ts +1 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +32 -29
- package/dist/types/types.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -1,66 +1,72 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
3
|
var g = Object.defineProperty;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
var b = (n, e, r) => e in n ? g(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r;
|
|
5
|
+
var h = (n, e, r) => b(n, typeof e != "symbol" ? e + "" : e, r);
|
|
6
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
7
|
+
import { useState as v, createContext as w, useContext as m, useId as x, useRef as M, useEffect as p } from "react";
|
|
8
|
+
import { observable as a, makeObservable as y, action as C } from "mobx";
|
|
9
|
+
import { observer as E } from "mobx-react-lite";
|
|
9
10
|
const l = "default";
|
|
10
|
-
class
|
|
11
|
+
class o {
|
|
11
12
|
constructor() {
|
|
12
|
-
|
|
13
|
+
h(this, "children", a.map(
|
|
13
14
|
{},
|
|
14
15
|
{
|
|
15
16
|
deep: !1
|
|
16
17
|
}
|
|
17
18
|
));
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
deleteChildren:
|
|
21
|
-
setChildren:
|
|
19
|
+
h(this, "preparedChildren", /* @__PURE__ */ new Map());
|
|
20
|
+
y(this, {
|
|
21
|
+
deleteChildren: C.bound,
|
|
22
|
+
setChildren: C.bound
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
static useNew() {
|
|
25
|
-
return
|
|
26
|
+
return v(() => new o())[0];
|
|
26
27
|
}
|
|
27
|
-
setChildren(e = l,
|
|
28
|
-
var
|
|
29
|
-
const
|
|
30
|
-
|
|
28
|
+
setChildren(e = l, r, i) {
|
|
29
|
+
var d;
|
|
30
|
+
const t = this.children.get(e) ?? a.map({}, { deep: !1 });
|
|
31
|
+
t.set(r, i), (d = this.preparedChildren.get(e)) == null || d.delete(r), this.children.set(e, t);
|
|
31
32
|
}
|
|
32
|
-
prepareChildren(e = l,
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
prepareChildren(e = l, r, i) {
|
|
34
|
+
const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
35
|
+
t.set(r, i), this.preparedChildren.set(e, t);
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
deleteChildrenFromMap(e, r, i) {
|
|
38
|
+
const t = e.get(r);
|
|
39
|
+
t == null || t.delete(i), (t == null ? void 0 : t.size) === 0 && e.delete(r);
|
|
40
|
+
}
|
|
41
|
+
deleteChildren(e = l, r) {
|
|
42
|
+
this.deleteChildrenFromMap(this.children, e, r), this.deleteChildrenFromMap(this.preparedChildren, e, r);
|
|
39
43
|
}
|
|
40
44
|
getChildren(e = l) {
|
|
41
|
-
var
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
return Array.from(
|
|
45
|
+
var i, t;
|
|
46
|
+
const r = ((i = this.children.get(e)) == null ? void 0 : i.entries()) ?? ((t = this.preparedChildren.get(e)) == null ? void 0 : t.entries());
|
|
47
|
+
if (r)
|
|
48
|
+
return Array.from(r);
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
|
-
const
|
|
48
|
-
const { children: e } =
|
|
49
|
-
return /* @__PURE__ */
|
|
50
|
-
},
|
|
51
|
-
const { children: e, id:
|
|
52
|
-
return u.current ||
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
const c = w(new o()), k = (n) => {
|
|
52
|
+
const { children: e } = n;
|
|
53
|
+
return /* @__PURE__ */ f(c.Provider, { value: o.useNew(), children: e });
|
|
54
|
+
}, z = (n) => {
|
|
55
|
+
const { children: e, id: r, staticEntryId: i } = n, t = m(c), d = x(), s = i ?? d, u = M(!1);
|
|
56
|
+
return u.current || t.prepareChildren(r, s, e), p(() => {
|
|
57
|
+
u.current = !0, t.setChildren(r, s, e);
|
|
58
|
+
}, [e, r, s]), p(() => () => {
|
|
59
|
+
t.deleteChildren(r, s);
|
|
60
|
+
}, [r, s]), null;
|
|
61
|
+
}, T = (n) => {
|
|
62
|
+
const { children: e } = n;
|
|
57
63
|
return typeof e == "function" ? e() : e;
|
|
58
|
-
},
|
|
59
|
-
const { children: e, id:
|
|
60
|
-
return
|
|
64
|
+
}, A = E((n) => {
|
|
65
|
+
const { children: e, id: r } = n, i = m(c).getChildren(r), t = i ? i.map(([d, s]) => /* @__PURE__ */ f(T, { children: s }, d)) : null;
|
|
66
|
+
return typeof e == "function" ? e(t) : t ?? e;
|
|
61
67
|
});
|
|
62
68
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
z as TunnelEntry,
|
|
70
|
+
A as TunnelExit,
|
|
71
|
+
k as TunnelProvider
|
|
66
72
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tunnel.test.d.ts","sourceRoot":"","sources":["../../src/Tunnel.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { ObservableMap } from 'mobx';
|
|
2
|
-
|
|
3
|
+
export type TunnelChildren = ReactNode | undefined | ((tunnelChildren?: ReactNode | undefined) => ReactNode | undefined);
|
|
3
4
|
export declare class TunnelState {
|
|
4
5
|
readonly children: ObservableMap<string, ObservableMap<string, TunnelChildren>>;
|
|
5
6
|
private readonly preparedChildren;
|
|
@@ -7,6 +8,8 @@ export declare class TunnelState {
|
|
|
7
8
|
static useNew(): TunnelState;
|
|
8
9
|
setChildren(tunnelId: string | undefined, entryId: string, children: TunnelChildren): void;
|
|
9
10
|
prepareChildren(tunnelId: string | undefined, entryId: string, children: TunnelChildren): void;
|
|
11
|
+
private deleteChildrenFromMap;
|
|
10
12
|
deleteChildren(tunnelId: string | undefined, entryId: string): void;
|
|
11
13
|
getChildren(tunnelId?: string): [string, TunnelChildren][] | undefined;
|
|
12
14
|
}
|
|
15
|
+
//# sourceMappingURL=TunnelState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TunnelState.d.ts","sourceRoot":"","sources":["../../src/TunnelState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAK1C,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,SAAS,GACT,CAAC,CAAC,cAAc,CAAC,EAAE,SAAS,GAAG,SAAS,KAAK,SAAS,GAAG,SAAS,CAAC,CAAC;AAExE,qBAAa,WAAW;IACtB,SAAgB,QAAQ,+DAQtB;IAEF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAG7B;;WASU,MAAM,IAAI,WAAW;IAI5B,WAAW,CAChB,QAAQ,EAAE,MAAM,YAAY,EAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc,GACvB,IAAI;IAWA,eAAe,CACpB,QAAQ,EAAE,MAAM,YAAY,EAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,cAAc,GACvB,IAAI;IASP,OAAO,CAAC,qBAAqB;IAYtB,cAAc,CAAC,QAAQ,EAAE,MAAM,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAKnE,WAAW,CAChB,QAAQ,GAAE,MAAkB,GAC3B,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,GAAG,SAAS;CAQ1C"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
|
|
3
|
-
interface
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
export type TunnelEntryChildren = ReactNode | undefined | (() => ReactNode | undefined);
|
|
3
|
+
export interface TunnelEntryProps {
|
|
4
4
|
id?: string;
|
|
5
|
-
children?:
|
|
5
|
+
children?: TunnelEntryChildren;
|
|
6
6
|
/** Static entry ID instead of generated ID by `useId` */
|
|
7
7
|
staticEntryId?: string;
|
|
8
8
|
}
|
|
9
|
-
export declare const TunnelEntry: FC<
|
|
9
|
+
export declare const TunnelEntry: FC<TunnelEntryProps>;
|
|
10
10
|
export default TunnelEntry;
|
|
11
|
+
//# sourceMappingURL=TunnelEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TunnelEntry.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelEntry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAI3C,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,SAAS,GACT,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC;AAElC,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA8B5C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { FC
|
|
2
|
-
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { TunnelChildren } from '../TunnelState';
|
|
3
|
+
export type TunnelExitChildren = TunnelChildren;
|
|
4
|
+
export interface TunnelExitProps {
|
|
3
5
|
id?: string;
|
|
6
|
+
children?: TunnelExitChildren;
|
|
4
7
|
}
|
|
5
|
-
export declare const TunnelExit: FC<
|
|
8
|
+
export declare const TunnelExit: FC<TunnelExitProps>;
|
|
6
9
|
export default TunnelExit;
|
|
10
|
+
//# sourceMappingURL=TunnelExit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TunnelExit.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelExit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAOD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAezC,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TunnelProvider.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnD,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAQhD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
package/dist/types/context.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,aAAa,sCAAgD,CAAC;AAE3E,eAAe,aAAa,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from './components/TunnelProvider';
|
|
2
|
+
export * from './components/TunnelEntry';
|
|
3
|
+
export * from './components/TunnelExit';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
|
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.500",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -23,40 +23,43 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "
|
|
27
|
-
"
|
|
28
|
-
"test": "",
|
|
29
|
-
"test:compile": "
|
|
30
|
-
"test:
|
|
26
|
+
"build": "vite build --config vite.build.config.ts",
|
|
27
|
+
"clean": "rimraf dist",
|
|
28
|
+
"test": "exit 0",
|
|
29
|
+
"test:compile": "tsc --noEmit",
|
|
30
|
+
"test:dev": "vitest dev",
|
|
31
|
+
"test:unit": "vitest run"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"mobx": "^6.13.
|
|
34
|
+
"mobx": "^6.13.7",
|
|
34
35
|
"mobx-react-lite": "^4.1.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@testing-library/
|
|
39
|
-
"@
|
|
40
|
-
"@types/
|
|
41
|
-
"@types/react
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"react
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"vite
|
|
53
|
-
"vite-plugin-
|
|
54
|
-
"vite-plugin-
|
|
55
|
-
"
|
|
38
|
+
"@mittwald/typescript-config": "workspace:*",
|
|
39
|
+
"@testing-library/dom": "^10.4.1",
|
|
40
|
+
"@testing-library/react": "^16.3.0",
|
|
41
|
+
"@types/node": "^22.18.6",
|
|
42
|
+
"@types/react": "^19.1.13",
|
|
43
|
+
"@types/react-dom": "^19.1.9",
|
|
44
|
+
"@vitejs/plugin-react": "^4.7.0",
|
|
45
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
46
|
+
"happy-dom": "^17.6.3",
|
|
47
|
+
"nx": "^20.8.2",
|
|
48
|
+
"prettier": "^3.6.2",
|
|
49
|
+
"react": "^19.1.1",
|
|
50
|
+
"react-dom": "^19.1.1",
|
|
51
|
+
"rimraf": "^6.0.1",
|
|
52
|
+
"typescript": "^5.9.2",
|
|
53
|
+
"vite": "^6.3.6",
|
|
54
|
+
"vite-plugin-banner": "^0.8.1",
|
|
55
|
+
"vite-plugin-checker": "^0.9.3",
|
|
56
|
+
"vite-plugin-dts": "^4.5.4",
|
|
57
|
+
"vite-plugin-externalize-deps": "^0.9.0",
|
|
58
|
+
"vitest": "^3.2.4"
|
|
56
59
|
},
|
|
57
60
|
"peerDependencies": {
|
|
58
|
-
"react": "^19
|
|
59
|
-
"react-dom": "^19
|
|
61
|
+
"react": "^19",
|
|
62
|
+
"react-dom": "^19"
|
|
60
63
|
},
|
|
61
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "c5cf4febe182072ea7ebdaad8a6928ae7c3ea45f"
|
|
62
65
|
}
|
package/dist/types/types.d.ts
DELETED