@mittwald/react-tunnel 0.2.0-alpha.816 → 0.2.0-alpha.818
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
CHANGED
|
@@ -1,109 +1,97 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { observable as
|
|
6
|
-
import { observer as
|
|
7
|
-
const
|
|
8
|
-
class
|
|
3
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
4
|
+
import { useState as v, useRef as E, createContext as w, useContext as C, useId as y, useLayoutEffect as h } from "react";
|
|
5
|
+
import { observable as f, makeObservable as b, action as x } from "mobx";
|
|
6
|
+
import { observer as T } from "mobx-react-lite";
|
|
7
|
+
const u = "default", m = "default";
|
|
8
|
+
class l {
|
|
9
9
|
id;
|
|
10
|
-
children =
|
|
10
|
+
children = f.map(
|
|
11
11
|
{},
|
|
12
12
|
{
|
|
13
13
|
deep: !1
|
|
14
14
|
}
|
|
15
15
|
);
|
|
16
|
-
preparedChildren = /* @__PURE__ */ new Map();
|
|
17
16
|
nextIndex = 0;
|
|
18
|
-
constructor(e =
|
|
19
|
-
this.id = e,
|
|
17
|
+
constructor(e = m) {
|
|
18
|
+
this.id = e, b(this, {
|
|
20
19
|
id: !1,
|
|
21
20
|
deleteChildren: x.bound,
|
|
22
21
|
setChildren: x.bound
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
static useNew(e) {
|
|
26
|
-
const t =
|
|
25
|
+
const t = v(() => new l(e))[0];
|
|
27
26
|
return t.resetIndex(), t;
|
|
28
27
|
}
|
|
29
28
|
resetIndex() {
|
|
30
29
|
this.nextIndex = 0;
|
|
31
30
|
}
|
|
32
31
|
useEntryIndex() {
|
|
33
|
-
const e =
|
|
34
|
-
return
|
|
32
|
+
const e = E(null);
|
|
33
|
+
return e.current === null && (e.current = this.nextIndex++), e.current;
|
|
35
34
|
}
|
|
36
|
-
setChildren(e =
|
|
37
|
-
const
|
|
35
|
+
setChildren(e = u, t, n, s) {
|
|
36
|
+
const i = {
|
|
38
37
|
id: t,
|
|
39
|
-
index:
|
|
40
|
-
children:
|
|
41
|
-
}, d = this.children.get(e) ??
|
|
42
|
-
d.set(t,
|
|
38
|
+
index: n,
|
|
39
|
+
children: s
|
|
40
|
+
}, d = this.children.get(e) ?? f.map({}, { deep: !1 });
|
|
41
|
+
d.set(t, i), this.children.set(e, d);
|
|
43
42
|
}
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
index: r,
|
|
48
|
-
children: n
|
|
49
|
-
}, d = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
50
|
-
d.set(t, s), this.preparedChildren.set(e, d);
|
|
51
|
-
}
|
|
52
|
-
deleteChildrenFromMap(e, t, r) {
|
|
53
|
-
const n = e.get(t);
|
|
54
|
-
n?.delete(r), n?.size === 0 && e.delete(t);
|
|
55
|
-
}
|
|
56
|
-
deleteChildren(e = o, t) {
|
|
57
|
-
this.deleteChildrenFromMap(this.children, e, t), this.deleteChildrenFromMap(this.preparedChildren, e, t);
|
|
43
|
+
deleteChildren(e = u, t) {
|
|
44
|
+
const n = this.children.get(e);
|
|
45
|
+
n?.delete(t), n?.size === 0 && this.children.delete(e);
|
|
58
46
|
}
|
|
59
|
-
getEntries(e =
|
|
60
|
-
const t = this.children.get(e)?.values()
|
|
47
|
+
getEntries(e = u) {
|
|
48
|
+
const t = this.children.get(e)?.values();
|
|
61
49
|
if (t)
|
|
62
50
|
return Array.from(t).sort(
|
|
63
|
-
(
|
|
51
|
+
(n, s) => n.index - s.index
|
|
64
52
|
);
|
|
65
53
|
}
|
|
66
54
|
}
|
|
67
|
-
const
|
|
68
|
-
state: new
|
|
69
|
-
}),
|
|
70
|
-
let e =
|
|
55
|
+
const c = w({
|
|
56
|
+
state: new l()
|
|
57
|
+
}), I = (r = m) => {
|
|
58
|
+
let e = C(c);
|
|
71
59
|
for (; e; ) {
|
|
72
|
-
if (e.state.id ===
|
|
60
|
+
if (e.state.id === r)
|
|
73
61
|
return e.state;
|
|
74
62
|
e = e.parentContext;
|
|
75
63
|
}
|
|
76
64
|
throw new Error(
|
|
77
|
-
`Could not get tunnel for provider ${
|
|
65
|
+
`Could not get tunnel for provider ${r}. Please provider a TunnelProvider with this ID.`
|
|
78
66
|
);
|
|
79
|
-
},
|
|
80
|
-
const { children: e, id: t } =
|
|
81
|
-
return /* @__PURE__ */
|
|
82
|
-
|
|
67
|
+
}, j = (r) => {
|
|
68
|
+
const { children: e, id: t } = r, n = C(c);
|
|
69
|
+
return /* @__PURE__ */ p(
|
|
70
|
+
c.Provider,
|
|
83
71
|
{
|
|
84
72
|
value: {
|
|
85
|
-
state:
|
|
86
|
-
parentContext:
|
|
73
|
+
state: l.useNew(t),
|
|
74
|
+
parentContext: n
|
|
87
75
|
},
|
|
88
76
|
children: e
|
|
89
77
|
}
|
|
90
78
|
);
|
|
91
|
-
},
|
|
92
|
-
const { children: e, id: t, staticEntryId:
|
|
93
|
-
return
|
|
94
|
-
|
|
95
|
-
}, [e, t,
|
|
96
|
-
|
|
97
|
-
}, [t,
|
|
98
|
-
},
|
|
99
|
-
const { children: e } =
|
|
79
|
+
}, k = (r) => {
|
|
80
|
+
const { children: e, id: t, staticEntryId: n, providerId: s } = r, i = I(s), d = y(), o = n ?? d, a = i.useEntryIndex();
|
|
81
|
+
return h(() => {
|
|
82
|
+
i.setChildren(t, o, a, e);
|
|
83
|
+
}, [e, t, o, a, s]), h(() => () => {
|
|
84
|
+
i.deleteChildren(t, o);
|
|
85
|
+
}, [t, o, s]), null;
|
|
86
|
+
}, g = (r) => {
|
|
87
|
+
const { children: e } = r;
|
|
100
88
|
return typeof e == "function" ? e() : e;
|
|
101
|
-
},
|
|
102
|
-
const { children: e, id: t, providerId:
|
|
103
|
-
return typeof e == "function" ? e(
|
|
89
|
+
}, z = T((r) => {
|
|
90
|
+
const { children: e, id: t, providerId: n } = r, s = I(n).getEntries(t), i = s ? s.map((d) => /* @__PURE__ */ p(g, { children: d.children }, d.id)) : null;
|
|
91
|
+
return typeof e == "function" ? e(i) : i ?? e;
|
|
104
92
|
});
|
|
105
93
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
94
|
+
k as TunnelEntry,
|
|
95
|
+
z as TunnelExit,
|
|
96
|
+
j as TunnelProvider
|
|
109
97
|
};
|
|
@@ -10,15 +10,12 @@ interface TunnelEntryState {
|
|
|
10
10
|
export declare class TunnelState {
|
|
11
11
|
readonly id: string;
|
|
12
12
|
readonly children: ObservableMap<string, ObservableMap<string, TunnelEntryState>>;
|
|
13
|
-
private readonly preparedChildren;
|
|
14
13
|
private nextIndex;
|
|
15
14
|
constructor(id?: string);
|
|
16
15
|
static useNew(id?: string): TunnelState;
|
|
17
16
|
resetIndex(): void;
|
|
18
17
|
useEntryIndex(): number;
|
|
19
18
|
setChildren(tunnelId: string | undefined, entryId: string, index: number, children: TunnelChildren): void;
|
|
20
|
-
prepareChildren(tunnelId: string | undefined, entryId: string, index: number, children: TunnelChildren): void;
|
|
21
|
-
private deleteChildrenFromMap;
|
|
22
19
|
deleteChildren(tunnelId: string | undefined, entryId: string): void;
|
|
23
20
|
getEntries(tunnelId?: string): TunnelEntryState[] | undefined;
|
|
24
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TunnelState.d.ts","sourceRoot":"","sources":["../../src/TunnelState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoB,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAI1C,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,SAAS,GACT,CAAC,CAAC,cAAc,CAAC,EAAE,SAAS,GAAG,SAAS,KAAK,SAAS,GAAG,SAAS,CAAC,CAAC;AAExE,UA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
|
-
{"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;IACvB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,
|
|
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;IACvB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAwB5C,CAAC;AAEF,eAAe,WAAW,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.818",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"react": "^19.2.0",
|
|
60
60
|
"react-dom": "^19.2.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "16f2d94681685aa3ca97b55c3117b4be248fe2e0"
|
|
63
63
|
}
|