@mittwald/react-tunnel 0.2.0-alpha.6 → 0.2.0-alpha.600

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,66 +1,67 @@
1
1
  "use client"
2
2
  /* */
3
- var g = Object.defineProperty;
4
- var E = (s, e, t) => e in s ? g(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
5
- var o = (s, e, t) => E(s, typeof e != "symbol" ? e + "" : e, t);
6
- import C, { useRef as f, createContext as b, useContext as m, useId as v, useEffect as w } from "react";
7
- import { observable as a, makeObservable as x, action as p } from "mobx";
8
- import { observer as y } from "mobx-react-lite";
9
- const l = "default";
10
- class c {
3
+ import { jsx as C } from "react/jsx-runtime";
4
+ import { useState as m, createContext as g, useContext as f, useId as E, useRef as b, useEffect as u } from "react";
5
+ import { observable as p, makeObservable as v, action as a } from "mobx";
6
+ import { observer as w } from "mobx-react-lite";
7
+ const d = "default";
8
+ class l {
9
+ children = p.map(
10
+ {},
11
+ {
12
+ deep: !1
13
+ }
14
+ );
15
+ preparedChildren = /* @__PURE__ */ new Map();
11
16
  constructor() {
12
- o(this, "children", a.map(
13
- {},
14
- {
15
- deep: !1
16
- }
17
- ));
18
- o(this, "preparedChildren", /* @__PURE__ */ new Map());
19
- x(this, {
20
- deleteChildren: p.bound,
21
- setChildren: p.bound
17
+ v(this, {
18
+ deleteChildren: a.bound,
19
+ setChildren: a.bound
22
20
  });
23
21
  }
24
22
  static useNew() {
25
- return f(new c()).current;
23
+ return m(() => new l())[0];
26
24
  }
27
- setChildren(e = l, t, n) {
28
- var i;
29
- const r = this.children.get(e) ?? a.map({}, { deep: !1 });
30
- r.set(t, n), (i = this.preparedChildren.get(e)) == null || i.delete(t), this.children.set(e, r);
25
+ setChildren(e = d, r, n) {
26
+ const t = this.children.get(e) ?? p.map({}, { deep: !1 });
27
+ t.set(r, n), this.preparedChildren.get(e)?.delete(r), this.children.set(e, t);
31
28
  }
32
- prepareChildren(e = l, t, n) {
33
- const r = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
34
- r.set(t, n), this.preparedChildren.set(e, r);
29
+ prepareChildren(e = d, r, n) {
30
+ const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
31
+ t.set(r, n), this.preparedChildren.set(e, t);
35
32
  }
36
- deleteChildren(e = l, t) {
37
- var n, r;
38
- (n = this.children.get(e)) == null || n.delete(t), (r = this.preparedChildren.get(e)) == null || r.delete(t);
33
+ deleteChildrenFromMap(e, r, n) {
34
+ const t = e.get(r);
35
+ t?.delete(n), t?.size === 0 && e.delete(r);
39
36
  }
40
- getChildren(e = l) {
41
- var n, r;
42
- const t = ((n = this.children.get(e)) == null ? void 0 : n.entries()) ?? ((r = this.preparedChildren.get(e)) == null ? void 0 : r.entries());
43
- if (t)
44
- return Array.from(t);
37
+ deleteChildren(e = d, r) {
38
+ this.deleteChildrenFromMap(this.children, e, r), this.deleteChildrenFromMap(this.preparedChildren, e, r);
39
+ }
40
+ getChildren(e = d) {
41
+ const r = this.children.get(e)?.entries() ?? this.preparedChildren.get(e)?.entries();
42
+ if (r)
43
+ return Array.from(r);
45
44
  }
46
45
  }
47
- const h = b(new c()), P = (s) => {
48
- const { children: e } = s;
49
- return /* @__PURE__ */ C.createElement(h.Provider, { value: c.useNew() }, e);
50
- }, A = (s) => {
51
- const { children: e, id: t, staticEntryId: n } = s, r = m(h), i = v(), d = n ?? i, u = f(!1);
52
- return u.current || r.prepareChildren(t, d, e), w(() => (u.current = !0, r.setChildren(t, d, e), () => {
53
- r.deleteChildren(t, d);
54
- }), [e, t, d]), null;
55
- }, R = (s) => {
56
- const { children: e } = s;
46
+ const h = g(new l()), N = (i) => {
47
+ const { children: e } = i;
48
+ return /* @__PURE__ */ C(h.Provider, { value: l.useNew(), children: e });
49
+ }, P = (i) => {
50
+ const { children: e, id: r, staticEntryId: n } = i, t = f(h), o = E(), s = n ?? o, c = b(!1);
51
+ return c.current || t.prepareChildren(r, s, e), u(() => {
52
+ c.current = !0, t.setChildren(r, s, e);
53
+ }, [e, r, s]), u(() => () => {
54
+ t.deleteChildren(r, s);
55
+ }, [r, s]), null;
56
+ }, x = (i) => {
57
+ const { children: e } = i;
57
58
  return typeof e == "function" ? e() : e;
58
- }, O = y((s) => {
59
- const { children: e, id: t } = s, n = m(h).getChildren(t);
60
- return n ? n.map(([r, i]) => /* @__PURE__ */ C.createElement(R, { key: r }, i)) : e;
59
+ }, R = w((i) => {
60
+ const { children: e, id: r } = i, n = f(h).getChildren(r), t = n ? n.map(([o, s]) => /* @__PURE__ */ C(x, { children: s }, o)) : null;
61
+ return typeof e == "function" ? e(t) : t ?? e;
61
62
  });
62
63
  export {
63
- A as TunnelEntry,
64
- O as TunnelExit,
65
- P as TunnelProvider
64
+ P as TunnelEntry,
65
+ R as TunnelExit,
66
+ N as TunnelProvider
66
67
  };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Tunnel.browser.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tunnel.browser.test.d.ts","sourceRoot":"","sources":["../../src/Tunnel.browser.test.tsx"],"names":[],"mappings":""}
@@ -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,8 @@ 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
  }
15
+ //# sourceMappingURL=TunnelState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TunnelState.d.ts","sourceRoot":"","sources":["../../src/TunnelState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAK1C,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,SAAS,GACT,CAAC,CAAC,cAAc,CAAC,EAAE,SAAS,GAAG,SAAS,KAAK,SAAS,GAAG,SAAS,CAAC,CAAC;AAExE,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;IASP,OAAO,CAAC,qBAAqB;IAYtB,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,10 +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
+ //# 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,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,CA8B5C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,6 +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;
10
+ //# 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,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,3 +1,4 @@
1
1
  import { FC, PropsWithChildren } from 'react';
2
2
  export declare const TunnelProvider: FC<PropsWithChildren>;
3
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,3 +1,4 @@
1
1
  import { TunnelState } from './TunnelState';
2
2
  export declare const tunnelContext: import('react').Context<TunnelState>;
3
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
- 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
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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.6",
3
+ "version": "0.2.0-alpha.600",
4
4
  "type": "module",
5
5
  "description": "It's like a Portal – but with React components",
6
6
  "keywords": [
@@ -23,40 +23,44 @@
23
23
  "dist"
24
24
  ],
25
25
  "scripts": {
26
- "build": "run vite build --config vite.build.config.ts",
27
- "build:deps:watch": "run -T build:deps:watch @mittwald/react-tunnel",
28
- "test": "",
29
- "test:compile": "run tsc --noEmit",
30
- "test:unit": "run vitest run"
26
+ "build": "vite build --config vite.build.config.ts",
27
+ "clean": "rimraf dist",
28
+ "test": "exit 0",
29
+ "test:browser": "vitest run --project=browser --browser.headless",
30
+ "test:browser:dev": "vitest dev --project=browser",
31
+ "test:browser:prepare": "pnpm playwright install chromium",
32
+ "test:compile": "tsc --noEmit"
31
33
  },
32
34
  "dependencies": {
33
- "mobx": "^6.13.5",
34
- "mobx-react-lite": "^4.1.0"
35
+ "mobx": "^6.15.0",
36
+ "mobx-react-lite": "^4.1.1"
35
37
  },
36
38
  "devDependencies": {
37
- "@testing-library/dom": "^10.4.0",
38
- "@testing-library/react": "^16.1.0",
39
- "@types/node": "^22.10.5",
40
- "@types/react": "^19.0.4",
41
- "@types/react-dom": "^19.0.2",
42
- "@vitejs/plugin-react": "^4.3.4",
43
- "@vitest/coverage-v8": "^2.1.8",
44
- "happy-dom": "^15.11.7",
45
- "nx": "^20.3.1",
46
- "prettier": "^3.4.2",
47
- "react": "19.0.0",
48
- "react-dom": "19.0.0",
49
- "typescript": "^5.7.3",
50
- "vite": "^5.4.11",
51
- "vite-plugin-banner": "^0.8.0",
52
- "vite-plugin-checker": "^0.8.0",
53
- "vite-plugin-dts": "^4.4.0",
54
- "vite-plugin-externalize-deps": "^0.8.0",
55
- "vitest": "^2.1.8"
39
+ "@mittwald/typescript-config": "workspace:*",
40
+ "@types/node": "^24.10.1",
41
+ "@types/react": "^19.2.6",
42
+ "@types/react-dom": "^19.2.3",
43
+ "@vitejs/plugin-react": "^5.1.1",
44
+ "@vitest/browser-playwright": "^4.0.12",
45
+ "@vitest/coverage-v8": "^4.0.12",
46
+ "nx": "^22.1.0",
47
+ "playwright": "^1.56.1",
48
+ "prettier": "^3.6.2",
49
+ "react": "^19.2.0",
50
+ "react-dom": "^19.2.0",
51
+ "rimraf": "^6.1.2",
52
+ "typescript": "^5.9.3",
53
+ "vite": "^7.2.4",
54
+ "vite-plugin-banner": "^0.8.1",
55
+ "vite-plugin-checker": "^0.11.0",
56
+ "vite-plugin-dts": "^4.5.4",
57
+ "vite-plugin-externalize-deps": "^0.10.0",
58
+ "vitest": "^4.0.12",
59
+ "vitest-browser-react": "^2.0.2"
56
60
  },
57
61
  "peerDependencies": {
58
- "react": "^19.0.0",
59
- "react-dom": "^19.0.0"
62
+ "react": "^19",
63
+ "react-dom": "^19"
60
64
  },
61
- "gitHead": "aa86664e40c05c44693eb8499be88974ecabfc20"
65
+ "gitHead": "672854ba7249323d4b8b9616d03aa6d88499e0d6"
62
66
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export type TunnelChildren = ReactNode | undefined | (() => ReactNode | undefined);