@mittwald/react-tunnel 0.2.0-alpha.825 → 0.2.0-alpha.827
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,14 +1,14 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
/* */
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { useId as
|
|
5
|
-
import { observable as
|
|
6
|
-
import { observer as
|
|
7
|
-
const
|
|
8
|
-
class
|
|
3
|
+
import { jsx as x } from "react/jsx-runtime";
|
|
4
|
+
import { useId as P, useState as w, useRef as a, createContext as I, useContext as v, useLayoutEffect as g, useEffect as b } from "react";
|
|
5
|
+
import { observable as m, makeObservable as y, action as p } from "mobx";
|
|
6
|
+
import { observer as R } from "mobx-react-lite";
|
|
7
|
+
const l = "default", u = "default";
|
|
8
|
+
class c {
|
|
9
9
|
id;
|
|
10
10
|
instanceId;
|
|
11
|
-
committedChildren =
|
|
11
|
+
committedChildren = m.map(
|
|
12
12
|
{},
|
|
13
13
|
{
|
|
14
14
|
deep: !1
|
|
@@ -17,15 +17,15 @@ class l {
|
|
|
17
17
|
renderPhaseChildren = /* @__PURE__ */ new Map();
|
|
18
18
|
nextIndex = 0;
|
|
19
19
|
constructor(e = u, t = u) {
|
|
20
|
-
this.id = e, this.instanceId = t,
|
|
20
|
+
this.id = e, this.instanceId = t, y(this, {
|
|
21
21
|
id: !1,
|
|
22
|
-
deleteChildren:
|
|
23
|
-
setChildren:
|
|
22
|
+
deleteChildren: p.bound,
|
|
23
|
+
setChildren: p.bound
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
static useNew(e) {
|
|
27
|
-
const t =
|
|
28
|
-
return
|
|
27
|
+
const t = P(), n = w(() => new c(e, t))[0];
|
|
28
|
+
return n.resetIndex(), n;
|
|
29
29
|
}
|
|
30
30
|
resetIndex() {
|
|
31
31
|
this.nextIndex = 0;
|
|
@@ -34,89 +34,85 @@ class l {
|
|
|
34
34
|
const e = a(this.instanceId), t = a(null);
|
|
35
35
|
return (t.current === null || e.current !== this.instanceId) && (e.current = this.instanceId, t.current = this.nextIndex++), t.current;
|
|
36
36
|
}
|
|
37
|
-
setChildren(e =
|
|
37
|
+
setChildren(e = l, t, n, r) {
|
|
38
38
|
const s = {
|
|
39
39
|
id: t,
|
|
40
|
-
index:
|
|
41
|
-
children:
|
|
42
|
-
}, i = this.committedChildren.get(e) ??
|
|
40
|
+
index: n,
|
|
41
|
+
children: r
|
|
42
|
+
}, i = this.committedChildren.get(e) ?? m.map({}, { deep: !1 });
|
|
43
43
|
i.set(t, s), this.renderPhaseChildren.get(e)?.delete(t), this.committedChildren.set(e, i);
|
|
44
44
|
}
|
|
45
|
-
setRenderPhaseChildren(e =
|
|
45
|
+
setRenderPhaseChildren(e = l, t, n, r) {
|
|
46
46
|
const s = {
|
|
47
47
|
id: t,
|
|
48
|
-
index:
|
|
49
|
-
children:
|
|
48
|
+
index: n,
|
|
49
|
+
children: r
|
|
50
50
|
}, i = this.renderPhaseChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
51
51
|
i.set(t, s), this.renderPhaseChildren.set(e, i);
|
|
52
52
|
}
|
|
53
|
-
deleteChildrenFromMap(e, t,
|
|
54
|
-
const
|
|
55
|
-
|
|
53
|
+
deleteChildrenFromMap(e, t, n) {
|
|
54
|
+
const r = e.get(t);
|
|
55
|
+
r?.delete(n), r?.size === 0 && e.delete(t);
|
|
56
56
|
}
|
|
57
|
-
deleteChildren(e =
|
|
57
|
+
deleteChildren(e = l, t) {
|
|
58
58
|
this.deleteChildrenFromMap(this.committedChildren, e, t), this.deleteChildrenFromMap(this.renderPhaseChildren, e, t);
|
|
59
59
|
}
|
|
60
60
|
takeRenderPhaseChildren(e) {
|
|
61
61
|
if (this.renderPhaseChildren.has(e)) {
|
|
62
62
|
const t = this.renderPhaseChildren.get(e)?.values();
|
|
63
|
-
return this.renderPhaseChildren.delete(e), t;
|
|
63
|
+
return typeof window < "u" && this.renderPhaseChildren.delete(e), t;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
getEntries(e =
|
|
67
|
-
const t = this.committedChildren.get(e)?.values(), r =
|
|
66
|
+
getEntries(e = l) {
|
|
67
|
+
const t = this.takeRenderPhaseChildren(e), n = this.committedChildren.get(e)?.values(), r = n ?? t;
|
|
68
68
|
if (r) {
|
|
69
|
-
const
|
|
70
|
-
(
|
|
69
|
+
const s = !!n, i = Array.from(r).sort(
|
|
70
|
+
(o, h) => o.index - h.index
|
|
71
71
|
);
|
|
72
72
|
return {
|
|
73
|
-
committed:
|
|
74
|
-
entries:
|
|
73
|
+
committed: s,
|
|
74
|
+
entries: i
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
const C =
|
|
80
|
-
state: new
|
|
81
|
-
}),
|
|
82
|
-
let e =
|
|
79
|
+
const C = I({
|
|
80
|
+
state: new c()
|
|
81
|
+
}), E = (d = u) => {
|
|
82
|
+
let e = v(C);
|
|
83
83
|
for (; e; ) {
|
|
84
|
-
if (e.state.id ===
|
|
84
|
+
if (e.state.id === d)
|
|
85
85
|
return e.state;
|
|
86
86
|
e = e.parentContext;
|
|
87
87
|
}
|
|
88
88
|
throw new Error(
|
|
89
|
-
`Could not get tunnel for provider ${
|
|
89
|
+
`Could not get tunnel for provider ${d}. Please provider a TunnelProvider with this ID.`
|
|
90
90
|
);
|
|
91
|
-
}, N = (
|
|
92
|
-
const { children: e, id: t } =
|
|
93
|
-
return /* @__PURE__ */
|
|
91
|
+
}, N = (d) => {
|
|
92
|
+
const { children: e, id: t } = d, n = v(C), r = c.useNew(t);
|
|
93
|
+
return /* @__PURE__ */ x(
|
|
94
94
|
C.Provider,
|
|
95
95
|
{
|
|
96
96
|
value: {
|
|
97
|
-
state:
|
|
98
|
-
parentContext:
|
|
97
|
+
state: r,
|
|
98
|
+
parentContext: n
|
|
99
99
|
},
|
|
100
100
|
children: e
|
|
101
101
|
}
|
|
102
102
|
);
|
|
103
|
-
}, j = (
|
|
104
|
-
const { children: e, id: t, staticEntryId:
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
}, [e, t,
|
|
108
|
-
s.deleteChildren(t,
|
|
109
|
-
}, [t,
|
|
110
|
-
},
|
|
111
|
-
const { children: e } =
|
|
103
|
+
}, j = (d) => {
|
|
104
|
+
const { children: e, id: t, staticEntryId: n, providerId: r } = d, s = E(r), i = P(), o = n ?? i, h = s.useEntryIndex(), f = a(!1);
|
|
105
|
+
return f.current || s.setRenderPhaseChildren(t, o, h, e), g(() => {
|
|
106
|
+
f.current = !0, s.setChildren(t, o, h, e);
|
|
107
|
+
}, [e, t, o, h, r]), b(() => () => {
|
|
108
|
+
s.deleteChildren(t, o);
|
|
109
|
+
}, [t, o, r]), null;
|
|
110
|
+
}, T = (d) => {
|
|
111
|
+
const { children: e } = d;
|
|
112
112
|
return typeof e == "function" ? e() : e;
|
|
113
|
-
}, z =
|
|
114
|
-
const { children: e, id: t, providerId:
|
|
115
|
-
|
|
116
|
-
n && !n.committed && s((d) => d + 1);
|
|
117
|
-
}, [n?.committed]);
|
|
118
|
-
const i = n?.entries.map((d) => /* @__PURE__ */ P(y, { children: d.children }, d.id));
|
|
119
|
-
return typeof e == "function" ? e(i) : i ?? e;
|
|
113
|
+
}, z = R((d) => {
|
|
114
|
+
const { children: e, id: t, providerId: n } = d, s = E(n).getEntries(t)?.entries.map((i) => /* @__PURE__ */ x(T, { children: i.children }, i.id));
|
|
115
|
+
return typeof e == "function" ? e(s) : s ?? e;
|
|
120
116
|
});
|
|
121
117
|
export {
|
|
122
118
|
j as TunnelEntry,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TunnelState.d.ts","sourceRoot":"","sources":["../../src/TunnelState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,C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nE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TunnelExit.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelExit.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"TunnelExit.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelExit.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,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,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAOD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAazC,CAAC;AAEH,eAAe,UAAU,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.827",
|
|
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": "2f4aed0a0787db35dee2ee95cfb184ffffbe418f"
|
|
63
63
|
}
|