@mittwald/react-tunnel 1.2.0-next.9 → 2.0.0-next.0
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 +39 -23
- package/dist/types/TunnelState.d.ts +14 -5
- package/dist/types/components/TunnelEntry.d.ts +14 -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/index.d.ts +0 -1
- package/package.json +5 -4
- package/dist/types/Tunnel.browser.test.d.ts +0 -2
- package/dist/types/Tunnel.browser.test.d.ts.map +0 -1
- package/dist/types/TunnelState.d.ts.map +0 -1
- package/dist/types/components/TunnelEntry.d.ts.map +0 -1
- package/dist/types/components/TunnelExit.d.ts.map +0 -1
- package/dist/types/components/TunnelProvider.d.ts.map +0 -1
- package/dist/types/context.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -28,28 +28,38 @@ var p = "default", m = "default", h = class e {
|
|
|
28
28
|
let e = a(this.instanceId), t = a(null);
|
|
29
29
|
return (t.current === null || e.current !== this.instanceId) && (e.current = this.instanceId, t.current = this.nextIndex++), t.current;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
let
|
|
31
|
+
buildEntryState(e, t, n, r, i) {
|
|
32
|
+
let a = new Set(e?.owners);
|
|
33
|
+
return a.add(n), {
|
|
33
34
|
id: t,
|
|
34
|
-
index:
|
|
35
|
-
children:
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
index: r,
|
|
36
|
+
children: i,
|
|
37
|
+
owners: a
|
|
38
|
+
};
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
a.set(t, i), this.renderPhaseChildren.set(e, a);
|
|
40
|
+
setChildren(e = p, t, n, r, i) {
|
|
41
|
+
let a = this.committedChildren.get(e) ?? u.map({}, { deep: !1 });
|
|
42
|
+
a.set(t, this.buildEntryState(a.get(t), t, n, r, i)), this.deleteOwnerFromMap(this.renderPhaseChildren, e, t, n), this.committedChildren.set(e, a);
|
|
43
|
+
}
|
|
44
|
+
setRenderPhaseChildren(e = p, t, n, r, i) {
|
|
45
|
+
let a = this.renderPhaseChildren.get(e) ?? /* @__PURE__ */ new Map();
|
|
46
|
+
a.set(t, this.buildEntryState(a.get(t), t, n, r, i)), this.renderPhaseChildren.set(e, a);
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
-
let
|
|
49
|
-
|
|
48
|
+
deleteOwnerFromMap(e, t, n, r) {
|
|
49
|
+
let i = e.get(t), a = i?.get(n);
|
|
50
|
+
if (!i || !a) return;
|
|
51
|
+
let o = new Set(a.owners);
|
|
52
|
+
if (o.delete(r), o.size > 0) {
|
|
53
|
+
i.set(n, {
|
|
54
|
+
...a,
|
|
55
|
+
owners: o
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
i.delete(n), i.size === 0 && e.delete(t);
|
|
50
60
|
}
|
|
51
|
-
deleteChildren(e = p, t) {
|
|
52
|
-
this.
|
|
61
|
+
deleteChildren(e = p, t, n) {
|
|
62
|
+
this.deleteOwnerFromMap(this.committedChildren, e, t, n), this.deleteOwnerFromMap(this.renderPhaseChildren, e, t, n);
|
|
53
63
|
}
|
|
54
64
|
getEntries(e = p, t = !1) {
|
|
55
65
|
let n = this.committedChildren.get(e)?.values(), r = t ? this.renderPhaseChildren.get(e)?.values() : void 0, i = n ?? r;
|
|
@@ -76,27 +86,33 @@ var p = "default", m = "default", h = class e {
|
|
|
76
86
|
});
|
|
77
87
|
}, y = (e) => {
|
|
78
88
|
let { children: t, id: o, staticEntryId: s, providerId: c } = e, l = _(c), u = r(), d = s ?? u, f = l.useEntryIndex(), p = a(!1);
|
|
79
|
-
return p.current || l.setRenderPhaseChildren(o, d, f, t), i(() => {
|
|
80
|
-
p.current = !0, l.setChildren(o, d, f, t);
|
|
89
|
+
return p.current || l.setRenderPhaseChildren(o, d, u, f, t), i(() => {
|
|
90
|
+
p.current = !0, l.setChildren(o, d, u, f, t);
|
|
81
91
|
}, [
|
|
82
92
|
t,
|
|
83
93
|
o,
|
|
84
94
|
d,
|
|
95
|
+
u,
|
|
85
96
|
f,
|
|
86
97
|
c
|
|
87
98
|
]), n(() => () => {
|
|
88
|
-
l.deleteChildren(o, d);
|
|
99
|
+
l.deleteChildren(o, d, u);
|
|
89
100
|
}, [
|
|
90
101
|
o,
|
|
91
102
|
d,
|
|
103
|
+
u,
|
|
92
104
|
c
|
|
93
105
|
]), null;
|
|
94
106
|
}, b = (e) => {
|
|
95
107
|
let { children: t } = e;
|
|
96
108
|
return typeof t == "function" ? t() : t;
|
|
97
109
|
}, x = f((e) => {
|
|
98
|
-
let { children: t, id: n, providerId: r } = e,
|
|
99
|
-
|
|
110
|
+
let { children: t, id: n, providerId: r } = e, o = s(() => () => null, () => !1, () => !0), c = a(!0);
|
|
111
|
+
i(() => {
|
|
112
|
+
c.current = !1;
|
|
113
|
+
}, []);
|
|
114
|
+
let l = _(r).getEntries(n, o || c.current)?.entries.map((e) => /* @__PURE__ */ d(b, { children: e.children }, e.id));
|
|
115
|
+
return typeof t == "function" ? t(l) : l ?? t;
|
|
100
116
|
});
|
|
101
117
|
//#endregion
|
|
102
118
|
export { y as TunnelEntry, x as TunnelExit, v as TunnelProvider };
|
|
@@ -6,6 +6,15 @@ interface TunnelEntryState {
|
|
|
6
6
|
index: number;
|
|
7
7
|
id: string;
|
|
8
8
|
children: TunnelChildren;
|
|
9
|
+
/**
|
|
10
|
+
* The `TunnelEntry` instances currently registered under this entry id.
|
|
11
|
+
* Usually exactly one, but a `staticEntryId` is shared on purpose: react-aria
|
|
12
|
+
* renders collection children twice (once into its hidden collection
|
|
13
|
+
* document, once for real), and both renders register the same entry. The
|
|
14
|
+
* entry is only removed once the last of them unmounts — deleting it when the
|
|
15
|
+
* first one goes would drop content that is still being rendered.
|
|
16
|
+
*/
|
|
17
|
+
owners: Set<string>;
|
|
9
18
|
}
|
|
10
19
|
interface TunnelEntries {
|
|
11
20
|
committed: boolean;
|
|
@@ -21,11 +30,11 @@ export declare class TunnelState {
|
|
|
21
30
|
static useNew(id?: string): TunnelState;
|
|
22
31
|
resetIndex(): void;
|
|
23
32
|
useEntryIndex(): number;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
private buildEntryState;
|
|
34
|
+
setChildren(tunnelId: string | undefined, entryId: string, ownerId: string, index: number, children: TunnelChildren): void;
|
|
35
|
+
setRenderPhaseChildren(tunnelId: string | undefined, entryId: string, ownerId: string, index: number, children: TunnelChildren): void;
|
|
36
|
+
private deleteOwnerFromMap;
|
|
37
|
+
deleteChildren(tunnelId: string | undefined, entryId: string, ownerId: string): void;
|
|
28
38
|
getEntries(tunnelId?: string, useRenderPhaseFallback?: boolean): TunnelEntries | undefined;
|
|
29
39
|
}
|
|
30
40
|
export {};
|
|
31
|
-
//# sourceMappingURL=TunnelState.d.ts.map
|
|
@@ -3,11 +3,23 @@ export type TunnelEntryChildren = ReactNode | undefined | (() => ReactNode | und
|
|
|
3
3
|
export interface TunnelEntryProps {
|
|
4
4
|
id?: string;
|
|
5
5
|
children?: TunnelEntryChildren;
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Static entry ID instead of generated ID by `useId`.
|
|
8
|
+
*
|
|
9
|
+
* Needed wherever one logical element is rendered by more than one component
|
|
10
|
+
* instance — react-aria, for example, renders the children of a collection
|
|
11
|
+
* twice: once into its hidden collection document, once for real. Each
|
|
12
|
+
* instance generates its own `useId`, so with a generated entry id the exit
|
|
13
|
+
* renders the element once per instance. A static id derived from the element
|
|
14
|
+
* itself collapses them into one entry; the entry is kept until the last of
|
|
15
|
+
* the instances unmounts.
|
|
16
|
+
*
|
|
17
|
+
* Must be unique among the siblings of one tunnel — two unrelated entries
|
|
18
|
+
* sharing an id overwrite each other.
|
|
19
|
+
*/
|
|
7
20
|
staticEntryId?: string;
|
|
8
21
|
/** Select a dedicated tunnel provider by ID. */
|
|
9
22
|
providerId?: string;
|
|
10
23
|
}
|
|
11
24
|
export declare const TunnelEntry: FC<TunnelEntryProps>;
|
|
12
25
|
export default TunnelEntry;
|
|
13
|
-
//# sourceMappingURL=TunnelEntry.d.ts.map
|
package/dist/types/context.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/react-tunnel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "It's like a Portal – but with React components",
|
|
6
6
|
"keywords": [
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
],
|
|
13
13
|
"homepage": "https://github.com/mittwald/flow/tree/main/packages/react-tunnel",
|
|
14
14
|
"repository": "https://github.com/mittwald/flow",
|
|
15
|
+
"license": "MIT",
|
|
15
16
|
"exports": {
|
|
16
17
|
".": {
|
|
17
18
|
"types": "./dist/types/index.d.ts",
|
|
@@ -37,8 +38,8 @@
|
|
|
37
38
|
"mobx-react-lite": "^4.1.1"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@mittwald/flow-core": "
|
|
41
|
-
"@mittwald/typescript-config": "
|
|
41
|
+
"@mittwald/flow-core": "2.0.0-next.0",
|
|
42
|
+
"@mittwald/typescript-config": "2.0.0-next.0",
|
|
42
43
|
"@types/node": "^25.9.3",
|
|
43
44
|
"@types/react": "^19.2",
|
|
44
45
|
"@types/react-dom": "^19.2",
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
"react": "^19.2.0",
|
|
61
62
|
"react-dom": "^19.2.0"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "08f1ba9b272fb8a4857a78f1b4dc034f2cbb441f"
|
|
64
65
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tunnel.browser.test.d.ts","sourceRoot":"","sources":["../../src/Tunnel.browser.test.tsx"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
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,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,UAAU,gBAAgB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,UAAU,aAAa;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED,qBAAa,WAAW;IACtB,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,UAAU,CAAS;IAE3B,SAAgB,iBAAiB,iEAQ/B;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAGhC;IAEJ,OAAO,CAAC,SAAS,CAAK;gBAGpB,EAAE,SAA0B,EAC5B,UAAU,SAA0B;WAWxB,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW;IAOvC,UAAU;IAIV,aAAa;IAUb,WAAW,CAChB,QAAQ,EAAE,MAAM,YAAY,EAC5B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,cAAc,GACvB,IAAI;IAiBA,sBAAsB,CAC3B,QAAQ,EAAE,MAAM,YAAY,EAC5B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,cAAc,GACvB,IAAI;IAgBP,OAAO,CAAC,qBAAqB;IAYtB,cAAc,CAAC,QAAQ,EAAE,MAAM,YAAY,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAcnE,UAAU,CACf,QAAQ,SAAY,EACpB,sBAAsB,UAAQ,GAC7B,aAAa,GAAG,SAAS;CAmB7B"}
|
|
@@ -1 +0,0 @@
|
|
|
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,GAC7B,SAAS,GAAG,SAAS,GAAG,CAAC,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC;AAExD,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,CA+B5C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TunnelExit.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelExit.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAwB,MAAM,OAAO,CAAC;AAGtD,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,CAmBzC,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TunnelProvider.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAIpE,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAgBlD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,WAAW,EAAE,MAAM,eAAe,CAAC;AAErE,UAAU,aAAa;IACrB,KAAK,EAAE,WAAW,CAAC;IACnB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,eAAO,MAAM,aAAa,wCAExB,CAAC;AAEH,eAAe,aAAa,CAAC;AAE7B,eAAO,MAAM,cAAc,GAAI,WAA4B,gBAa1D,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|