@mittwald/react-tunnel 0.2.0-alpha.826 → 0.2.0-alpha.827

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,14 +1,14 @@
1
1
  "use client"
2
2
  /* */
3
- import { jsx as P } from "react/jsx-runtime";
4
- import { useId as v, useState as E, useRef as a, createContext as g, useContext as I, useEffect as f, useLayoutEffect as R } from "react";
5
- import { observable as p, makeObservable as T, action as x } from "mobx";
6
- import { observer as b } from "mobx-react-lite";
7
- const h = "default", u = "default";
8
- class l {
3
+ import { jsx as x } from "react/jsx-runtime";
4
+ import { useId as P, useState as w, useRef as a, createContext as I, useContext as v, useLayoutEffect as g, useEffect as b } from "react";
5
+ import { observable as m, makeObservable as y, action as p } from "mobx";
6
+ import { observer as R } from "mobx-react-lite";
7
+ const l = "default", u = "default";
8
+ class c {
9
9
  id;
10
10
  instanceId;
11
- committedChildren = p.map(
11
+ committedChildren = m.map(
12
12
  {},
13
13
  {
14
14
  deep: !1
@@ -17,15 +17,15 @@ class l {
17
17
  renderPhaseChildren = /* @__PURE__ */ new Map();
18
18
  nextIndex = 0;
19
19
  constructor(e = u, t = u) {
20
- this.id = e, this.instanceId = t, T(this, {
20
+ this.id = e, this.instanceId = t, y(this, {
21
21
  id: !1,
22
- deleteChildren: x.bound,
23
- setChildren: x.bound
22
+ deleteChildren: p.bound,
23
+ setChildren: p.bound
24
24
  });
25
25
  }
26
26
  static useNew(e) {
27
- const t = v(), r = E(() => new l(e, t))[0];
28
- return r.resetIndex(), r;
27
+ const t = P(), n = w(() => new c(e, t))[0];
28
+ return n.resetIndex(), n;
29
29
  }
30
30
  resetIndex() {
31
31
  this.nextIndex = 0;
@@ -34,89 +34,85 @@ class l {
34
34
  const e = a(this.instanceId), t = a(null);
35
35
  return (t.current === null || e.current !== this.instanceId) && (e.current = this.instanceId, t.current = this.nextIndex++), t.current;
36
36
  }
37
- setChildren(e = h, t, r, n) {
37
+ setChildren(e = l, t, n, r) {
38
38
  const s = {
39
39
  id: t,
40
- index: r,
41
- children: n
42
- }, i = this.committedChildren.get(e) ?? p.map({}, { deep: !1 });
40
+ index: n,
41
+ children: r
42
+ }, i = this.committedChildren.get(e) ?? m.map({}, { deep: !1 });
43
43
  i.set(t, s), this.renderPhaseChildren.get(e)?.delete(t), this.committedChildren.set(e, i);
44
44
  }
45
- setRenderPhaseChildren(e = h, t, r, n) {
45
+ setRenderPhaseChildren(e = l, t, n, r) {
46
46
  const s = {
47
47
  id: t,
48
- index: r,
49
- children: n
48
+ index: n,
49
+ children: r
50
50
  }, i = this.renderPhaseChildren.get(e) ?? /* @__PURE__ */ new Map();
51
51
  i.set(t, s), this.renderPhaseChildren.set(e, i);
52
52
  }
53
- deleteChildrenFromMap(e, t, r) {
54
- const n = e.get(t);
55
- n?.delete(r), n?.size === 0 && e.delete(t);
53
+ deleteChildrenFromMap(e, t, n) {
54
+ const r = e.get(t);
55
+ r?.delete(n), r?.size === 0 && e.delete(t);
56
56
  }
57
- deleteChildren(e = h, t) {
57
+ deleteChildren(e = l, t) {
58
58
  this.deleteChildrenFromMap(this.committedChildren, e, t), this.deleteChildrenFromMap(this.renderPhaseChildren, e, t);
59
59
  }
60
60
  takeRenderPhaseChildren(e) {
61
61
  if (this.renderPhaseChildren.has(e)) {
62
62
  const t = this.renderPhaseChildren.get(e)?.values();
63
- return this.renderPhaseChildren.delete(e), t;
63
+ return typeof window < "u" && this.renderPhaseChildren.delete(e), t;
64
64
  }
65
65
  }
66
- getEntries(e = h) {
67
- const t = this.committedChildren.get(e)?.values(), r = t ?? this.takeRenderPhaseChildren(e);
66
+ getEntries(e = l) {
67
+ const t = this.takeRenderPhaseChildren(e), n = this.committedChildren.get(e)?.values(), r = n ?? t;
68
68
  if (r) {
69
- const n = !!t, s = Array.from(r).sort(
70
- (i, d) => i.index - d.index
69
+ const s = !!n, i = Array.from(r).sort(
70
+ (o, h) => o.index - h.index
71
71
  );
72
72
  return {
73
- committed: n,
74
- entries: s
73
+ committed: s,
74
+ entries: i
75
75
  };
76
76
  }
77
77
  }
78
78
  }
79
- const C = g({
80
- state: new l()
81
- }), w = (o = u) => {
82
- let e = I(C);
79
+ const C = I({
80
+ state: new c()
81
+ }), E = (d = u) => {
82
+ let e = v(C);
83
83
  for (; e; ) {
84
- if (e.state.id === o)
84
+ if (e.state.id === d)
85
85
  return e.state;
86
86
  e = e.parentContext;
87
87
  }
88
88
  throw new Error(
89
- `Could not get tunnel for provider ${o}. Please provider a TunnelProvider with this ID.`
89
+ `Could not get tunnel for provider ${d}. Please provider a TunnelProvider with this ID.`
90
90
  );
91
- }, N = (o) => {
92
- const { children: e, id: t } = o, r = I(C), n = l.useNew(t);
93
- return /* @__PURE__ */ P(
91
+ }, N = (d) => {
92
+ const { children: e, id: t } = d, n = v(C), r = c.useNew(t);
93
+ return /* @__PURE__ */ x(
94
94
  C.Provider,
95
95
  {
96
96
  value: {
97
- state: n,
98
- parentContext: r
97
+ state: r,
98
+ parentContext: n
99
99
  },
100
100
  children: e
101
101
  }
102
102
  );
103
- }, j = (o) => {
104
- const { children: e, id: t, staticEntryId: r, providerId: n } = o, s = w(n), i = v(), d = r ?? i, c = s.useEntryIndex(), m = a(!1);
105
- return m.current || s.setRenderPhaseChildren(t, d, c, e), f(() => {
106
- m.current = !0, s.setChildren(t, d, c, e);
107
- }, [e, t, d, c, n]), f(() => () => {
108
- s.deleteChildren(t, d);
109
- }, [t, d, n]), null;
110
- }, y = (o) => {
111
- const { children: e } = o;
103
+ }, j = (d) => {
104
+ const { children: e, id: t, staticEntryId: n, providerId: r } = d, s = E(r), i = P(), o = n ?? i, h = s.useEntryIndex(), f = a(!1);
105
+ return f.current || s.setRenderPhaseChildren(t, o, h, e), g(() => {
106
+ f.current = !0, s.setChildren(t, o, h, e);
107
+ }, [e, t, o, h, r]), b(() => () => {
108
+ s.deleteChildren(t, o);
109
+ }, [t, o, r]), null;
110
+ }, T = (d) => {
111
+ const { children: e } = d;
112
112
  return typeof e == "function" ? e() : e;
113
- }, z = b((o) => {
114
- const { children: e, id: t, providerId: r } = o, n = w(r).getEntries(t), [, s] = E(0);
115
- R(() => {
116
- n && !n.committed && s((d) => d + 1);
117
- }, [n?.committed]);
118
- const i = n?.entries.map((d) => /* @__PURE__ */ P(y, { children: d.children }, d.id));
119
- return typeof e == "function" ? e(i) : i ?? e;
113
+ }, z = R((d) => {
114
+ const { children: e, id: t, providerId: n } = d, s = E(n).getEntries(t)?.entries.map((i) => /* @__PURE__ */ x(T, { children: i.children }, i.id));
115
+ return typeof e == "function" ? e(s) : s ?? e;
120
116
  });
121
117
  export {
122
118
  j as TunnelEntry,
@@ -1 +1 @@
1
- {"version":3,"file":"TunnelState.d.ts","sourceRoot":"","sources":["../../src/TunnelState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAA2B,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAI1C,eAAO,MAAM,uBAAuB,YAAY,CAAC;AAEjD,MAAM,MAAM,cAAc,GACtB,SAAS,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,UAAU,aAAa;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAED,qBAAa,WAAW;IACtB,SAAgB,EAAE,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,UAAU,CAAS;IAE3B,SAAgB,iBAAiB,iEAQ/B;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAGhC;IAEJ,OAAO,CAAC,SAAS,CAAK;gBAGpB,EAAE,SAA0B,EAC5B,U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AiB,iEAQ/B;IAEF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAGhC;IAEJ,OAAO,CAAC,SAAS,CAAK;gBAGpB,EAAE,SAA0B,EAC5B,UAAU,SAA0B;WAWxB,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,WAAW;IAOvC,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,sBAAsB,CAC3B,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;IAK1E,OAAO,CAAC,uBAAuB;IAUxB,UAAU,CAAC,QAAQ,SAAY,GAAG,aAAa,GAAG,SAAS;CAiBnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"TunnelExit.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelExit.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3D,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,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAOD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAoBzC,CAAC;AAEH,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"TunnelExit.d.ts","sourceRoot":"","sources":["../../../src/components/TunnelExit.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGhC,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,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAOD,eAAO,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAazC,CAAC;AAEH,eAAe,UAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/react-tunnel",
3
- "version": "0.2.0-alpha.826",
3
+ "version": "0.2.0-alpha.827",
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": "58ea0f98d8d15fbbf09f450a2c18027a482591fc"
62
+ "gitHead": "2f4aed0a0787db35dee2ee95cfb184ffffbe418f"
63
63
  }