@mittwald/react-tunnel 0.1.0-alpha.99 → 0.2.0-alpha.11

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,60 +1,67 @@
1
1
  "use client"
2
2
  /* */
3
- var m = Object.defineProperty;
4
- var C = (r, e, t) => e in r ? m(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
5
- var d = (r, e, t) => (C(r, typeof e != "symbol" ? e + "" : e, t), t);
6
- import a, { useState as p, createContext as b, useContext as f, useId as E, useRef as v, useLayoutEffect as y } from "react";
7
- import { observable as u, makeObservable as g, action as h } from "mobx";
8
- import { observer as x } from "mobx-react-lite";
9
- const o = "default";
10
- class i {
3
+ var g = Object.defineProperty;
4
+ var b = (i, e, r) => e in i ? g(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
5
+ var c = (i, e, r) => b(i, typeof e != "symbol" ? e + "" : e, r);
6
+ import { jsx as C } from "react/jsx-runtime";
7
+ import { useRef as f, createContext as E, useContext as m, useId as v, useEffect as w } from "react";
8
+ import { observable as p, makeObservable as x, action as a } from "mobx";
9
+ import { observer as y } from "mobx-react-lite";
10
+ const l = "default";
11
+ class o {
11
12
  constructor() {
12
- d(this, "children", u.map(
13
+ c(this, "children", p.map(
13
14
  {},
14
15
  {
15
16
  deep: !1
16
17
  }
17
18
  ));
18
- g(this, {
19
- deleteChildren: h.bound,
20
- setChildren: h.bound
19
+ c(this, "preparedChildren", /* @__PURE__ */ new Map());
20
+ x(this, {
21
+ deleteChildren: a.bound,
22
+ setChildren: a.bound
21
23
  });
22
24
  }
23
25
  static useNew() {
24
- return p(new i())[0];
26
+ return f(new o()).current;
25
27
  }
26
- setChildren(e = o, t, n) {
27
- const s = this.children.get(e) ?? u.map({}, { deep: !1 });
28
- s.set(t, n), this.children.set(e, s);
28
+ setChildren(e = l, r, n) {
29
+ var s;
30
+ const t = this.children.get(e) ?? p.map({}, { deep: !1 });
31
+ t.set(r, n), (s = this.preparedChildren.get(e)) == null || s.delete(r), this.children.set(e, t);
29
32
  }
30
- deleteChildren(e = o, t) {
31
- var n;
32
- (n = this.children.get(e)) == null || n.delete(t);
33
+ prepareChildren(e = l, r, n) {
34
+ const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
35
+ t.set(r, n), this.preparedChildren.set(e, t);
33
36
  }
34
- getChildren(e = o) {
35
- var n;
36
- const t = (n = this.children.get(e)) == null ? void 0 : n.entries();
37
- if (t)
38
- return Array.from(t);
37
+ 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);
40
+ }
41
+ 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());
44
+ if (r)
45
+ return Array.from(r);
39
46
  }
40
47
  }
41
- const c = b(new i()), N = (r) => {
42
- const { children: e } = r;
43
- return /* @__PURE__ */ a.createElement(c.Provider, { value: i.useNew() }, e);
44
- }, P = (r) => {
45
- const { children: e, id: t } = r, n = f(c), s = E(), l = v(!1);
46
- return l.current || n.setChildren(t, s, e), y(() => (l.current = !0, n.setChildren(t, s, e), () => {
47
- n.deleteChildren(t, s);
48
- }), [e, t, s]), null;
49
- }, w = (r) => {
50
- const { children: e } = r;
48
+ const h = E(new o()), k = (i) => {
49
+ const { children: e } = i;
50
+ return /* @__PURE__ */ C(h.Provider, { value: o.useNew(), children: e });
51
+ }, A = (i) => {
52
+ const { children: e, id: r, staticEntryId: n } = i, t = m(h), s = v(), d = n ?? s, u = f(!1);
53
+ return u.current || t.prepareChildren(r, d, e), w(() => (u.current = !0, t.setChildren(r, d, e), () => {
54
+ t.deleteChildren(r, d);
55
+ }), [e, r, d]), null;
56
+ }, T = (i) => {
57
+ const { children: e } = i;
51
58
  return typeof e == "function" ? e() : e;
52
- }, A = x((r) => {
53
- const { children: e, id: t } = r, n = f(c).getChildren(t);
54
- return n ? n.map(([s, l]) => /* @__PURE__ */ a.createElement(w, { key: s }, l)) : e;
59
+ }, O = y((i) => {
60
+ const { children: e, id: r } = i, n = m(h).getChildren(r);
61
+ return n ? n.map(([t, s]) => /* @__PURE__ */ C(T, { children: s }, t)) : e;
55
62
  });
56
63
  export {
57
- P as TunnelEntry,
58
- A as TunnelExit,
59
- N as TunnelProvider
64
+ A as TunnelEntry,
65
+ O as TunnelExit,
66
+ k as TunnelProvider
60
67
  };
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=Tunnel.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tunnel.test.d.ts","sourceRoot":"","sources":["../../src/Tunnel.test.tsx"],"names":[],"mappings":""}
@@ -1,11 +1,13 @@
1
- import { TunnelChildren } from './types';
2
1
  import { ObservableMap } from 'mobx';
3
-
2
+ import { TunnelChildren } from './types';
4
3
  export declare class TunnelState {
5
4
  readonly children: ObservableMap<string, ObservableMap<string, TunnelChildren>>;
5
+ private readonly preparedChildren;
6
6
  constructor();
7
7
  static useNew(): TunnelState;
8
8
  setChildren(tunnelId: string | undefined, entryId: string, children: TunnelChildren): void;
9
+ prepareChildren(tunnelId: string | undefined, entryId: string, children: TunnelChildren): void;
9
10
  deleteChildren(tunnelId: string | undefined, entryId: string): void;
10
- getChildren(tunnelId?: string): Array<[string, TunnelChildren]> | undefined;
11
+ getChildren(tunnelId?: string): [string, TunnelChildren][] | undefined;
11
12
  }
13
+ //# sourceMappingURL=TunnelState.d.ts.map
@@ -0,0 +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,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C,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;IASA,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,9 +1,11 @@
1
- import { TunnelChildren } from '../types';
2
1
  import { FC } from 'react';
3
-
2
+ import { TunnelChildren } from '../types';
4
3
  interface Props {
5
4
  id?: string;
6
5
  children?: TunnelChildren;
6
+ /** Static entry ID instead of generated ID by `useId` */
7
+ staticEntryId?: string;
7
8
  }
8
9
  export declare const TunnelEntry: FC<Props>;
9
10
  export default TunnelEntry;
11
+ //# sourceMappingURL=TunnelEntry.d.ts.map
@@ -0,0 +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,7 +1,7 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
-
3
2
  interface Props extends PropsWithChildren {
4
3
  id?: string;
5
4
  }
6
5
  export declare const TunnelExit: FC<Props>;
7
6
  export default TunnelExit;
7
+ //# sourceMappingURL=TunnelExit.d.ts.map
@@ -0,0 +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,4 +1,4 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
-
3
2
  export declare const TunnelProvider: FC<PropsWithChildren>;
4
3
  export default TunnelProvider;
4
+ //# sourceMappingURL=TunnelProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TunnelProvider.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAKnD,eAAO,MAAM,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAQhD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { TunnelState } from './TunnelState';
2
-
3
2
  export declare const tunnelContext: import('react').Context<TunnelState>;
4
3
  export default tunnelContext;
4
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,aAAa,sCAAgD,CAAC;AAE3E,eAAe,aAAa,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { TunnelProvider } from './components/TunnelProvider';
2
2
  export { TunnelEntry } from './components/TunnelEntry';
3
3
  export { TunnelExit } from './components/TunnelExit';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,3 +1,3 @@
1
1
  import { ReactNode } from 'react';
2
-
3
2
  export type TunnelChildren = ReactNode | undefined | (() => ReactNode | undefined);
3
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/react-tunnel",
3
- "version": "0.1.0-alpha.99",
3
+ "version": "0.2.0-alpha.11",
4
4
  "type": "module",
5
5
  "description": "It's like a Portal – but with React components",
6
6
  "keywords": [
@@ -10,7 +10,7 @@
10
10
  "react tree",
11
11
  "teleport"
12
12
  ],
13
- "homepage": "https://mittwald.github.io/flow",
13
+ "homepage": "https://github.com/mittwald/flow/tree/main/packages/react-tunnel",
14
14
  "repository": "https://github.com/mittwald/flow",
15
15
  "exports": {
16
16
  ".": {
@@ -24,38 +24,41 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "build": "run vite build --config vite.build.config.ts",
27
- "build:deps:watch": "run -T build:deps:watch @mittwald/react-tunnel",
27
+ "clean": "rimraf dist",
28
28
  "test": "",
29
29
  "test:compile": "run tsc --noEmit",
30
30
  "test:unit": "run vitest run"
31
31
  },
32
32
  "dependencies": {
33
- "mobx": "^6.12.3",
34
- "mobx-react-lite": "^4.0.7"
33
+ "mobx": "^6.13.5",
34
+ "mobx-react-lite": "^4.1.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@testing-library/react": "^15.0.6",
38
- "@types/node": "^20.12.8",
39
- "@types/react": "^18.3.1",
40
- "@types/react-dom": "^18.3.0",
41
- "@vitejs/plugin-react": "^4.2.1",
42
- "@vitest/coverage-v8": "^1.5.3",
43
- "happy-dom": "^14.7.1",
44
- "nx": "^18.3.4",
45
- "prettier": "^3.2.5",
46
- "react": "^18.3.1",
47
- "react-dom": "^18.3.1",
48
- "typescript": "^5.4.5",
49
- "vite": "^5.2.10",
50
- "vite-plugin-banner": "^0.7.1",
51
- "vite-plugin-checker": "^0.6.4",
52
- "vite-plugin-dts": "^3.9.0",
53
- "vite-plugin-externalize-deps": "^0.8.0",
54
- "vitest": "^1.5.3"
37
+ "@mittwald/typescript-config": "workspace:*",
38
+ "@testing-library/dom": "^10.4.0",
39
+ "@testing-library/react": "^16.2.0",
40
+ "@types/node": "^22.10.7",
41
+ "@types/react": "^19.0.7",
42
+ "@types/react-dom": "^19.0.3",
43
+ "@vitejs/plugin-react": "^4.3.4",
44
+ "@vitest/coverage-v8": "^2.1.8",
45
+ "happy-dom": "^16.6.0",
46
+ "nx": "^20.3.2",
47
+ "prettier": "^3.4.2",
48
+ "react": "19.0.0",
49
+ "react-dom": "19.0.0",
50
+ "rimraf": "^6.0.1",
51
+ "typescript": "^5.7.3",
52
+ "vite": "^6.0.9",
53
+ "vite-plugin-banner": "^0.8.0",
54
+ "vite-plugin-checker": "^0.8.0",
55
+ "vite-plugin-dts": "^4.5.0",
56
+ "vite-plugin-externalize-deps": "^0.9.0",
57
+ "vitest": "^2.1.8"
55
58
  },
56
59
  "peerDependencies": {
57
- "react": "^18.2.0",
58
- "react-dom": "^18.2.0"
60
+ "react": "^19.0.0",
61
+ "react-dom": "^19.0.0"
59
62
  },
60
- "gitHead": "81dfd5f1c9a4360327cf6fa2f8e375cb61cfc75f"
63
+ "gitHead": "f6d587a22f532d575d699a5ff6f41e571af9454d"
61
64
  }