@mittwald/react-tunnel 0.2.0-alpha.685 → 0.2.0-alpha.686

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,12 +1,12 @@
1
1
  "use client"
2
2
  /* */
3
- import { jsx as f } from "react/jsx-runtime";
4
- import { useState as m, createContext as g, useContext as x, useId as E, useRef as v, useEffect as a } from "react";
5
- import { observable as p, makeObservable as b, action as C } from "mobx";
3
+ import { jsx as x } from "react/jsx-runtime";
4
+ import { useState as E, useRef as h, createContext as g, useContext as m, useId as v, useEffect as p } from "react";
5
+ import { observable as f, makeObservable as b, action as C } from "mobx";
6
6
  import { observer as w } from "mobx-react-lite";
7
7
  const l = "default";
8
8
  class o {
9
- children = p.map(
9
+ children = f.map(
10
10
  {},
11
11
  {
12
12
  deep: !1
@@ -21,21 +21,22 @@ class o {
21
21
  });
22
22
  }
23
23
  static useNew() {
24
- const e = m(() => new o())[0];
24
+ const e = E(() => new o())[0];
25
25
  return e.resetIndex(), e;
26
26
  }
27
27
  resetIndex() {
28
28
  this.nextIndex = 0;
29
29
  }
30
- getIndex() {
31
- return this.nextIndex++;
30
+ useEntryIndex() {
31
+ const e = h(this), t = h(null);
32
+ return (t.current === null || e.current !== this) && (e.current = this, t.current = this.nextIndex++), t.current;
32
33
  }
33
34
  setChildren(e = l, t, r, n) {
34
35
  const i = {
35
36
  id: t,
36
37
  index: r,
37
38
  children: n
38
- }, s = this.children.get(e) ?? p.map({}, { deep: !1 });
39
+ }, s = this.children.get(e) ?? f.map({}, { deep: !1 });
39
40
  s.set(t, i), this.preparedChildren.get(e)?.delete(t), this.children.set(e, s);
40
41
  }
41
42
  prepareChildren(e = l, t, r, n) {
@@ -61,25 +62,25 @@ class o {
61
62
  );
62
63
  }
63
64
  }
64
- const h = g(new o()), I = (d) => {
65
+ const u = g(new o()), I = (d) => {
65
66
  const { children: e } = d;
66
- return /* @__PURE__ */ f(h.Provider, { value: o.useNew(), children: e });
67
- }, N = (d) => {
68
- const { children: e, id: t, staticEntryId: r } = d, n = x(h), i = E(), s = r ?? i, c = n.getIndex(), u = v(!1);
69
- return u.current || n.prepareChildren(t, s, c, e), a(() => {
70
- u.current = !0, n.setChildren(t, s, c, e);
71
- }, [e, t, s, c]), a(() => () => {
67
+ return /* @__PURE__ */ x(u.Provider, { value: o.useNew(), children: e });
68
+ }, R = (d) => {
69
+ const { children: e, id: t, staticEntryId: r } = d, n = m(u), i = v(), s = r ?? i, c = n.useEntryIndex(), a = h(!1);
70
+ return a.current || n.prepareChildren(t, s, c, e), p(() => {
71
+ a.current = !0, n.setChildren(t, s, c, e);
72
+ }, [e, t, s, c]), p(() => () => {
72
73
  n.deleteChildren(t, s);
73
74
  }, [t, s]), null;
74
- }, M = (d) => {
75
+ }, y = (d) => {
75
76
  const { children: e } = d;
76
77
  return typeof e == "function" ? e() : e;
77
- }, P = w((d) => {
78
- const { children: e, id: t } = d, r = x(h).getEntries(t), n = r ? r.map((i) => /* @__PURE__ */ f(M, { children: i.children }, i.id)) : null;
78
+ }, N = w((d) => {
79
+ const { children: e, id: t } = d, r = m(u).getEntries(t), n = r ? r.map((i) => /* @__PURE__ */ x(y, { children: i.children }, i.id)) : null;
79
80
  return typeof e == "function" ? e(n) : n ?? e;
80
81
  });
81
82
  export {
82
- N as TunnelEntry,
83
- P as TunnelExit,
83
+ R as TunnelEntry,
84
+ N as TunnelExit,
84
85
  I as TunnelProvider
85
86
  };
@@ -13,7 +13,7 @@ export declare class TunnelState {
13
13
  constructor();
14
14
  static useNew(): TunnelState;
15
15
  resetIndex(): void;
16
- getIndex(): number;
16
+ useEntryIndex(): number;
17
17
  setChildren(tunnelId: string | undefined, entryId: string, index: number, children: TunnelChildren): void;
18
18
  prepareChildren(tunnelId: string | undefined, entryId: string, index: number, children: TunnelChildren): void;
19
19
  private deleteChildrenFromMap;
@@ -1 +1 @@
1
- {"version":3,"file":"TunnelState.d.ts","sourceRoot":"","sources":["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AAS,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,qBAAa,WAAW;IACtB,SAAgB,QAAQ,iEAQtB;IAEF,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAG7B;IAEJ,OAAO,CAAC,SAAS,CAAK;;WASR,MAAM,IAAI,WAAW;IAM5B,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,eAAe,CACpB,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;IAKnE,UAAU,CACf,QAAQ,GAAE,MAAkB,GAC3B,gBAAgB,EAAE,GAAG,SAAS;CAUlC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/react-tunnel",
3
- "version": "0.2.0-alpha.685",
3
+ "version": "0.2.0-alpha.686",
4
4
  "type": "module",
5
5
  "description": "It's like a Portal – but with React components",
6
6
  "keywords": [
@@ -59,5 +59,5 @@
59
59
  "react": "^19.2.0",
60
60
  "react-dom": "^19.2.0"
61
61
  },
62
- "gitHead": "9b017e80821090536beac9d8d587171e65ce3000"
62
+ "gitHead": "0e4b1f9a56b1099d77ee5f0c47fa5d1520cdf800"
63
63
  }