@mittwald/react-tunnel 0.2.0-alpha.35 → 0.2.0-alpha.351

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,67 +1,70 @@
1
1
  "use client"
2
2
  /* */
3
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);
4
+ var g = (n, e, r) => e in n ? m(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r;
5
+ var h = (n, e, r) => g(n, typeof e != "symbol" ? e + "" : e, r);
6
6
  import { jsx as C } from "react/jsx-runtime";
7
- import { useState as b, createContext as E, useContext as f, useId as v, useRef as w, useEffect as x } from "react";
8
- import { observable as a, makeObservable as y, action as p } from "mobx";
9
- import { observer as T } from "mobx-react-lite";
7
+ import { useState as b, createContext as v, useContext as f, useId as w, useRef as x, useEffect as M } from "react";
8
+ import { observable as p, makeObservable as y, action as a } from "mobx";
9
+ import { observer as E } from "mobx-react-lite";
10
10
  const l = "default";
11
11
  class o {
12
12
  constructor() {
13
- c(this, "children", a.map(
13
+ h(this, "children", p.map(
14
14
  {},
15
15
  {
16
16
  deep: !1
17
17
  }
18
18
  ));
19
- c(this, "preparedChildren", /* @__PURE__ */ new Map());
19
+ h(this, "preparedChildren", /* @__PURE__ */ new Map());
20
20
  y(this, {
21
- deleteChildren: p.bound,
22
- setChildren: p.bound
21
+ deleteChildren: a.bound,
22
+ setChildren: a.bound
23
23
  });
24
24
  }
25
25
  static useNew() {
26
26
  return b(() => new o())[0];
27
27
  }
28
- setChildren(e = l, r, n) {
29
- var i;
30
- const t = this.children.get(e) ?? a.map({}, { deep: !1 });
31
- t.set(r, n), (i = this.preparedChildren.get(e)) == null || i.delete(r), this.children.set(e, t);
28
+ setChildren(e = l, r, i) {
29
+ var s;
30
+ const t = this.children.get(e) ?? p.map({}, { deep: !1 });
31
+ t.set(r, i), (s = this.preparedChildren.get(e)) == null || s.delete(r), this.children.set(e, t);
32
32
  }
33
- prepareChildren(e = l, r, n) {
33
+ prepareChildren(e = l, r, i) {
34
34
  const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
35
- t.set(r, n), this.preparedChildren.set(e, t);
35
+ t.set(r, i), this.preparedChildren.set(e, t);
36
+ }
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);
36
40
  }
37
41
  deleteChildren(e = l, r) {
38
- var n, t;
39
- (n = this.children.get(e)) == null || n.delete(r), (t = this.preparedChildren.get(e)) == null || t.delete(r);
42
+ this.deleteChildrenFromMap(this.children, e, r), this.deleteChildrenFromMap(this.preparedChildren, e, r);
40
43
  }
41
44
  getChildren(e = l) {
42
- var n, t;
43
- const r = ((n = this.children.get(e)) == null ? void 0 : n.entries()) ?? ((t = this.preparedChildren.get(e)) == null ? void 0 : t.entries());
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());
44
47
  if (r)
45
48
  return Array.from(r);
46
49
  }
47
50
  }
48
- const h = E(new o()), A = (s) => {
49
- const { children: e } = s;
50
- return /* @__PURE__ */ C(h.Provider, { value: o.useNew(), children: e });
51
- }, O = (s) => {
52
- const { children: e, id: r, staticEntryId: n } = s, t = f(h), i = v(), d = n ?? i, u = w(!1);
53
- return u.current || t.prepareChildren(r, d, e), x(() => (u.current = !0, t.setChildren(r, d, e), () => {
51
+ const c = v(new o()), k = (n) => {
52
+ const { children: e } = n;
53
+ return /* @__PURE__ */ C(c.Provider, { value: o.useNew(), children: e });
54
+ }, z = (n) => {
55
+ const { children: e, id: r, staticEntryId: i } = n, t = f(c), s = w(), d = i ?? s, u = x(!1);
56
+ return u.current || t.prepareChildren(r, d, e), M(() => (u.current = !0, t.setChildren(r, d, e), () => {
54
57
  t.deleteChildren(r, d);
55
58
  }), [e, r, d]), null;
56
- }, M = (s) => {
57
- const { children: e } = s;
59
+ }, T = (n) => {
60
+ const { children: e } = n;
58
61
  return typeof e == "function" ? e() : e;
59
- }, S = T((s) => {
60
- const { children: e, id: r } = s, n = f(h).getChildren(r);
61
- return n ? n.map(([t, i]) => /* @__PURE__ */ C(M, { children: i }, t)) : e;
62
+ }, A = E((n) => {
63
+ const { children: e, id: r } = n, i = f(c).getChildren(r), t = i ? i.map(([s, d]) => /* @__PURE__ */ C(T, { children: d }, s)) : null;
64
+ return typeof e == "function" ? e(t) : t ?? e;
62
65
  });
63
66
  export {
64
- O as TunnelEntry,
65
- S as TunnelExit,
66
- A as TunnelProvider
67
+ z as TunnelEntry,
68
+ A as TunnelExit,
69
+ k as TunnelProvider
67
70
  };
@@ -1,5 +1,6 @@
1
+ import { ReactNode } from 'react';
1
2
  import { ObservableMap } from 'mobx';
2
- import { TunnelChildren } from './types';
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":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAAE,cA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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
- import { TunnelChildren } from '../types';
3
- interface Props {
1
+ import { FC, ReactNode } from 'react';
2
+ export type TunnelEntryChildren = ReactNode | undefined | (() => ReactNode | undefined);
3
+ export interface TunnelEntryProps {
4
4
  id?: string;
5
- children?: TunnelChildren;
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<Props>;
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;AAGhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,UAAU,KAAK;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,yDAAyD;IACzD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,KAAK,CAqBjC,CAAC;AAEF,eAAe,WAAW,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,CAqB5C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,7 +1,10 @@
1
- import { FC, PropsWithChildren } from 'react';
2
- interface Props extends PropsWithChildren {
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<Props>;
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,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAOnD,UAAU,KAAM,SAAQ,iBAAiB;IACvC,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAOD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,KAAK,CAU/B,CAAC;AAEH,eAAe,UAAU,CAAC"}
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"}
@@ -1,4 +1,4 @@
1
- export { TunnelProvider } from './components/TunnelProvider';
2
- export { TunnelEntry } from './components/TunnelEntry';
3
- export { TunnelExit } from './components/TunnelExit';
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,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC"}
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.35",
3
+ "version": "0.2.0-alpha.351",
4
4
  "type": "module",
5
5
  "description": "It's like a Portal – but with React components",
6
6
  "keywords": [
@@ -30,35 +30,35 @@
30
30
  "test:unit": "vitest run"
31
31
  },
32
32
  "dependencies": {
33
- "mobx": "^6.13.6",
33
+ "mobx": "^6.13.7",
34
34
  "mobx-react-lite": "^4.1.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@mittwald/typescript-config": "workspace:*",
38
38
  "@testing-library/dom": "^10.4.0",
39
- "@testing-library/react": "^16.2.0",
40
- "@types/node": "^22.13.4",
41
- "@types/react": "^19.0.10",
42
- "@types/react-dom": "^19.0.4",
43
- "@vitejs/plugin-react": "^4.3.4",
44
- "@vitest/coverage-v8": "^2.1.9",
45
- "happy-dom": "^16.8.1",
46
- "nx": "^20.4.4",
47
- "prettier": "^3.5.1",
48
- "react": "^19.0.0",
49
- "react-dom": "^19.0.0",
39
+ "@testing-library/react": "^16.3.0",
40
+ "@types/node": "^22.16.2",
41
+ "@types/react": "^19.1.8",
42
+ "@types/react-dom": "^19.1.6",
43
+ "@vitejs/plugin-react": "^4.6.0",
44
+ "@vitest/coverage-v8": "^3.2.4",
45
+ "happy-dom": "^17.6.3",
46
+ "nx": "^20.8.2",
47
+ "prettier": "^3.6.2",
48
+ "react": "^19.1.0",
49
+ "react-dom": "^19.1.0",
50
50
  "rimraf": "^6.0.1",
51
- "typescript": "^5.7.3",
52
- "vite": "^6.1.0",
53
- "vite-plugin-banner": "^0.8.0",
54
- "vite-plugin-checker": "^0.8.0",
55
- "vite-plugin-dts": "^4.5.0",
51
+ "typescript": "^5.8.3",
52
+ "vite": "^6.3.5",
53
+ "vite-plugin-banner": "^0.8.1",
54
+ "vite-plugin-checker": "^0.9.3",
55
+ "vite-plugin-dts": "^4.5.4",
56
56
  "vite-plugin-externalize-deps": "^0.9.0",
57
- "vitest": "^2.1.9"
57
+ "vitest": "^3.2.4"
58
58
  },
59
59
  "peerDependencies": {
60
60
  "react": "^19",
61
61
  "react-dom": "^19"
62
62
  },
63
- "gitHead": "20bb00e126bf30f39e7dc3fc08336be4a9103604"
63
+ "gitHead": "7eabd5739ff76f8157368c34a32d2efc9a242c2d"
64
64
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Mittwald CM Service GmbH & Co. KG and contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,3 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export type TunnelChildren = ReactNode | undefined | (() => ReactNode | undefined);
3
- //# sourceMappingURL=types.d.ts.map
@@ -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"}