@mittwald/react-tunnel 0.2.0-alpha.61 → 0.2.0-alpha.610
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 +46 -46
- package/dist/types/Tunnel.browser.test.d.ts +2 -0
- package/dist/types/Tunnel.browser.test.d.ts.map +1 -0
- package/dist/types/TunnelState.d.ts +3 -1
- package/dist/types/TunnelState.d.ts.map +1 -1
- package/dist/types/components/TunnelEntry.d.ts +5 -5
- package/dist/types/components/TunnelEntry.d.ts.map +1 -1
- package/dist/types/components/TunnelExit.d.ts +6 -3
- package/dist/types/components/TunnelExit.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +29 -29
- package/dist/types/Tunnel.test.d.ts +0 -2
- package/dist/types/Tunnel.test.d.ts.map +0 -1
- package/dist/types/types.d.ts +0 -3
- package/dist/types/types.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
var m = Object.defineProperty;
|
|
4
|
-
var g = (s, e, r) => e in s ? m(s, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : s[e] = r;
|
|
5
|
-
var c = (s, e, r) => g(s, typeof e != "symbol" ? e + "" : e, r);
|
|
6
3
|
import { jsx as C } from "react/jsx-runtime";
|
|
7
|
-
import { useState as
|
|
8
|
-
import { observable as
|
|
9
|
-
import { observer as
|
|
10
|
-
const
|
|
11
|
-
class
|
|
4
|
+
import { useState as m, createContext as g, useContext as f, useId as E, useRef as b, useEffect as u } from "react";
|
|
5
|
+
import { observable as p, makeObservable as v, action as a } from "mobx";
|
|
6
|
+
import { observer as w } from "mobx-react-lite";
|
|
7
|
+
const d = "default";
|
|
8
|
+
class l {
|
|
9
|
+
children = p.map(
|
|
10
|
+
{},
|
|
11
|
+
{
|
|
12
|
+
deep: !1
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
preparedChildren = /* @__PURE__ */ new Map();
|
|
12
16
|
constructor() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
deep: !1
|
|
17
|
-
}
|
|
18
|
-
));
|
|
19
|
-
c(this, "preparedChildren", /* @__PURE__ */ new Map());
|
|
20
|
-
y(this, {
|
|
21
|
-
deleteChildren: p.bound,
|
|
22
|
-
setChildren: p.bound
|
|
17
|
+
v(this, {
|
|
18
|
+
deleteChildren: a.bound,
|
|
19
|
+
setChildren: a.bound
|
|
23
20
|
});
|
|
24
21
|
}
|
|
25
22
|
static useNew() {
|
|
26
|
-
return
|
|
23
|
+
return m(() => new l())[0];
|
|
27
24
|
}
|
|
28
|
-
setChildren(e =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
t.set(r, n), (i = this.preparedChildren.get(e)) == null || i.delete(r), this.children.set(e, t);
|
|
25
|
+
setChildren(e = d, r, n) {
|
|
26
|
+
const t = this.children.get(e) ?? p.map({}, { deep: !1 });
|
|
27
|
+
t.set(r, n), this.preparedChildren.get(e)?.delete(r), this.children.set(e, t);
|
|
32
28
|
}
|
|
33
|
-
prepareChildren(e =
|
|
29
|
+
prepareChildren(e = d, r, n) {
|
|
34
30
|
const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
35
31
|
t.set(r, n), this.preparedChildren.set(e, t);
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
(n
|
|
33
|
+
deleteChildrenFromMap(e, r, n) {
|
|
34
|
+
const t = e.get(r);
|
|
35
|
+
t?.delete(n), t?.size === 0 && e.delete(r);
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
deleteChildren(e = d, r) {
|
|
38
|
+
this.deleteChildrenFromMap(this.children, e, r), this.deleteChildrenFromMap(this.preparedChildren, e, r);
|
|
39
|
+
}
|
|
40
|
+
getChildren(e = d) {
|
|
41
|
+
const r = this.children.get(e)?.entries() ?? this.preparedChildren.get(e)?.entries();
|
|
44
42
|
if (r)
|
|
45
43
|
return Array.from(r);
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
|
-
const h =
|
|
49
|
-
const { children: e } =
|
|
50
|
-
return /* @__PURE__ */ C(h.Provider, { value:
|
|
51
|
-
},
|
|
52
|
-
const { children: e, id: r, staticEntryId: n } =
|
|
53
|
-
return
|
|
54
|
-
t.
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
const h = g(new l()), N = (i) => {
|
|
47
|
+
const { children: e } = i;
|
|
48
|
+
return /* @__PURE__ */ C(h.Provider, { value: l.useNew(), children: e });
|
|
49
|
+
}, P = (i) => {
|
|
50
|
+
const { children: e, id: r, staticEntryId: n } = i, t = f(h), o = E(), s = n ?? o, c = b(!1);
|
|
51
|
+
return c.current || t.prepareChildren(r, s, e), u(() => {
|
|
52
|
+
c.current = !0, t.setChildren(r, s, e);
|
|
53
|
+
}, [e, r, s]), u(() => () => {
|
|
54
|
+
t.deleteChildren(r, s);
|
|
55
|
+
}, [r, s]), null;
|
|
56
|
+
}, x = (i) => {
|
|
57
|
+
const { children: e } = i;
|
|
58
58
|
return typeof e == "function" ? e() : e;
|
|
59
|
-
},
|
|
60
|
-
const { children: e, id: r } =
|
|
61
|
-
return
|
|
59
|
+
}, R = w((i) => {
|
|
60
|
+
const { children: e, id: r } = i, n = f(h).getChildren(r), t = n ? n.map(([o, s]) => /* @__PURE__ */ C(x, { children: s }, o)) : null;
|
|
61
|
+
return typeof e == "function" ? e(t) : t ?? e;
|
|
62
62
|
});
|
|
63
63
|
export {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
P as TunnelEntry,
|
|
65
|
+
R as TunnelExit,
|
|
66
|
+
N as TunnelProvider
|
|
67
67
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tunnel.browser.test.d.ts","sourceRoot":"","sources":["../../src/Tunnel.browser.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,7 @@ 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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TunnelState.d.ts","sourceRoot":"","sources":["../../src/TunnelState.ts"],"names":[],"mappings":"
|
|
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,11 +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
11
|
//# sourceMappingURL=TunnelEntry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TunnelEntry.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelEntry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
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,7 +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;
|
|
7
10
|
//# sourceMappingURL=TunnelExit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TunnelExit.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelExit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,
|
|
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"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export * from './components/TunnelProvider';
|
|
2
|
+
export * from './components/TunnelEntry';
|
|
3
|
+
export * from './components/TunnelExit';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
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.610",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -25,40 +25,40 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "vite build --config vite.build.config.ts",
|
|
27
27
|
"clean": "rimraf dist",
|
|
28
|
-
"test": "
|
|
29
|
-
"test:
|
|
30
|
-
"test:
|
|
28
|
+
"test:browser": "vitest run --project=browser --browser.headless",
|
|
29
|
+
"test:browser:dev": "vitest dev --project=browser",
|
|
30
|
+
"test:compile": "tsc --noEmit"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"mobx": "^6.
|
|
34
|
-
"mobx-react-lite": "^4.1.
|
|
33
|
+
"mobx": "^6.15.0",
|
|
34
|
+
"mobx-react-lite": "^4.1.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@mittwald/typescript-config": "workspace:*",
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"@types/
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"react": "^19.
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"vite": "^
|
|
53
|
-
"vite-plugin-
|
|
54
|
-
"vite-plugin-
|
|
55
|
-
"vite-plugin-
|
|
56
|
-
"
|
|
57
|
-
"vitest": "^2.
|
|
38
|
+
"@types/node": "^24.10.1",
|
|
39
|
+
"@types/react": "^19.2.7",
|
|
40
|
+
"@types/react-dom": "^19.2",
|
|
41
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
42
|
+
"@vitest/browser-playwright": "^4.0.15",
|
|
43
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
44
|
+
"nx": "^22.1.0",
|
|
45
|
+
"playwright": "^1.57.0",
|
|
46
|
+
"prettier": "^3.6.2",
|
|
47
|
+
"react": "^19.2.0",
|
|
48
|
+
"react-dom": "^19.2.0",
|
|
49
|
+
"rimraf": "^6.1.2",
|
|
50
|
+
"typescript": "^5.9.3",
|
|
51
|
+
"vite": "^7.2.7",
|
|
52
|
+
"vite-plugin-banner": "^0.8.1",
|
|
53
|
+
"vite-plugin-checker": "^0.11.0",
|
|
54
|
+
"vite-plugin-dts": "^4.5.4",
|
|
55
|
+
"vite-plugin-externalize-deps": "^0.10.0",
|
|
56
|
+
"vitest": "^4.0.15",
|
|
57
|
+
"vitest-browser-react": "^2.0.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"react": "^19",
|
|
61
|
-
"react-dom": "^19"
|
|
60
|
+
"react": "^19.2.0",
|
|
61
|
+
"react-dom": "^19.2.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "44dba174d15f7cfb181b10e47f1a2bde81f545ff"
|
|
64
64
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tunnel.test.d.ts","sourceRoot":"","sources":["../../src/Tunnel.test.tsx"],"names":[],"mappings":""}
|
package/dist/types/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,SAAS,GACT,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC"}
|