@mittwald/react-tunnel 0.1.0-alpha.130 → 0.1.0-alpha.131

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.
Files changed (2) hide show
  1. package/dist/index.js +37 -37
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  "use client"
2
2
  /* */
3
- var C = Object.defineProperty;
4
- var f = (i, e, t) => e in i ? C(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
5
- var o = (i, e, t) => (f(i, typeof e != "symbol" ? e + "" : e, t), t);
6
- import u, { useState as m, createContext as g, useContext as p, useId as E, useRef as b, useLayoutEffect as v } from "react";
7
- import { observable as h, makeObservable as w, action as a } from "mobx";
8
- import { observer as x } from "mobx-react-lite";
3
+ var f = Object.defineProperty;
4
+ var m = (i, e, r) => e in i ? f(i, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[e] = r;
5
+ var o = (i, e, r) => (m(i, typeof e != "symbol" ? e + "" : e, r), r);
6
+ import a, { useRef as p, createContext as g, useContext as C, useId as E, useLayoutEffect as b } from "react";
7
+ import { observable as h, makeObservable as v, action as u } from "mobx";
8
+ import { observer as w } from "mobx-react-lite";
9
9
  const l = "default";
10
10
  class d {
11
11
  constructor() {
@@ -16,51 +16,51 @@ class d {
16
16
  }
17
17
  ));
18
18
  o(this, "preparedChildren", /* @__PURE__ */ new Map());
19
- w(this, {
20
- deleteChildren: a.bound,
21
- setChildren: a.bound
19
+ v(this, {
20
+ deleteChildren: u.bound,
21
+ setChildren: u.bound
22
22
  });
23
23
  }
24
24
  static useNew() {
25
- return m(new d())[0];
25
+ return p(new d()).current;
26
26
  }
27
- setChildren(e = l, t, n) {
27
+ setChildren(e = l, r, n) {
28
28
  var s;
29
- const r = this.children.get(e) ?? h.map({}, { deep: !1 });
30
- r.set(t, n), (s = this.preparedChildren.get(e)) == null || s.delete(t), this.children.set(e, r);
29
+ const t = this.children.get(e) ?? h.map({}, { deep: !1 });
30
+ t.set(r, n), (s = this.preparedChildren.get(e)) == null || s.delete(r), this.children.set(e, t);
31
31
  }
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);
32
+ prepareChildren(e = l, r, n) {
33
+ const t = this.preparedChildren.get(e) ?? /* @__PURE__ */ new Map();
34
+ t.set(r, n), this.preparedChildren.set(e, t);
35
35
  }
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);
36
+ deleteChildren(e = l, r) {
37
+ var n, t;
38
+ (n = this.children.get(e)) == null || n.delete(r), (t = this.preparedChildren.get(e)) == null || t.delete(r);
39
39
  }
40
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);
41
+ var n, t;
42
+ const r = ((n = this.children.get(e)) == null ? void 0 : n.entries()) ?? ((t = this.preparedChildren.get(e)) == null ? void 0 : t.entries());
43
+ if (r)
44
+ return Array.from(r);
45
45
  }
46
46
  }
47
- const c = g(new d()), N = (i) => {
47
+ const c = g(new d()), M = (i) => {
48
48
  const { children: e } = i;
49
- return /* @__PURE__ */ u.createElement(c.Provider, { value: d.useNew() }, e);
50
- }, P = (i) => {
51
- const { children: e, id: t } = i, n = p(c), r = E(), s = b(!1);
52
- return s.current || n.prepareChildren(t, r, e), v(() => (s.current = !0, n.setChildren(t, r, e), () => {
53
- n.deleteChildren(t, r);
54
- }), [e, t, r]), null;
55
- }, y = (i) => {
49
+ return /* @__PURE__ */ a.createElement(c.Provider, { value: d.useNew() }, e);
50
+ }, N = (i) => {
51
+ const { children: e, id: r } = i, n = C(c), t = E(), s = p(!1);
52
+ return s.current || n.prepareChildren(r, t, e), b(() => (s.current = !0, n.setChildren(r, t, e), () => {
53
+ n.deleteChildren(r, t);
54
+ }), [e, r, t]), null;
55
+ }, x = (i) => {
56
56
  const { children: e } = i;
57
57
  return typeof e == "function" ? e() : e;
58
- }, A = x((i) => {
59
- const { children: e, id: t } = i, n = p(c).getChildren(t);
60
- return n ? n.map(([r, s]) => /* @__PURE__ */ u.createElement(y, { key: r }, s)) : e;
58
+ }, P = w((i) => {
59
+ const { children: e, id: r } = i, n = C(c).getChildren(r);
60
+ return n ? n.map(([t, s]) => /* @__PURE__ */ a.createElement(x, { key: t }, s)) : e;
61
61
  });
62
62
  export {
63
- P as TunnelEntry,
64
- A as TunnelExit,
65
- N as TunnelProvider
63
+ N as TunnelEntry,
64
+ P as TunnelExit,
65
+ M as TunnelProvider
66
66
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/react-tunnel",
3
- "version": "0.1.0-alpha.130",
3
+ "version": "0.1.0-alpha.131",
4
4
  "type": "module",
5
5
  "description": "It's like a Portal – but with React components",
6
6
  "keywords": [
@@ -36,12 +36,12 @@
36
36
  "devDependencies": {
37
37
  "@testing-library/react": "^15.0.7",
38
38
  "@types/node": "^20.12.12",
39
- "@types/react": "^18.3.2",
39
+ "@types/react": "^18.3.3",
40
40
  "@types/react-dom": "^18.3.0",
41
- "@vitejs/plugin-react": "^4.2.1",
41
+ "@vitejs/plugin-react": "^4.3.0",
42
42
  "@vitest/coverage-v8": "^1.6.0",
43
43
  "happy-dom": "^14.11.0",
44
- "nx": "^19.0.5",
44
+ "nx": "^19.1.0",
45
45
  "prettier": "^3.2.5",
46
46
  "react": "^18.3.1",
47
47
  "react-dom": "^18.3.1",
@@ -57,5 +57,5 @@
57
57
  "react": "^18.2.0",
58
58
  "react-dom": "^18.2.0"
59
59
  },
60
- "gitHead": "a052dc83a84b7e064c43727acd11f33658c52ac4"
60
+ "gitHead": "cd7bf7ba3a6a246a62b7665f8877597b3fb226f0"
61
61
  }