@tachui/viewport 0.8.1-alpha → 0.8.8

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,9 +1,10 @@
1
- var J = Object.defineProperty;
2
- var Z = (n, e, t) => e in n ? J(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var o = (n, e, t) => Z(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { createSignal as z, mountComponentTree as Y, createRoot as ee, withComponentContext as te, createContext as ne, useContext as ie } from "@tachui/core";
5
- function O(n = {}) {
6
- const e = se(), t = le(e, n), i = ue(), s = pe(), a = we();
1
+ var me = Object.defineProperty;
2
+ var ge = (n, e, t) => e in n ? me(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var o = (n, e, t) => ge(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { createSignal as L, mountComponentTree as be, createRoot as ye, withComponentContext as ve, createContext as We, useContext as Se } from "@tachui/core";
5
+ import { registerModifierWithMetadata as j } from "@tachui/modifiers";
6
+ function U(n = {}) {
7
+ const e = Ee(), t = Pe(e, n), i = Oe(), s = ze(), a = De();
7
8
  return {
8
9
  platform: e,
9
10
  capabilities: t,
@@ -12,20 +13,20 @@ function O(n = {}) {
12
13
  isTouch: a
13
14
  };
14
15
  }
15
- function se() {
16
- return oe() ? "electron" : re() ? "mobile" : ae() ? "embedded" : "web";
16
+ function Ee() {
17
+ return Ce() ? "electron" : Me() ? "mobile" : ke() ? "embedded" : "web";
17
18
  }
18
- function oe() {
19
+ function Ce() {
19
20
  return typeof window < "u" ? !!window.electronAPI || !!window.electron || !!window.require || navigator.userAgent.toLowerCase().includes("electron") : typeof process < "u" ? !!process.electron || !!process.versions?.electron || process.env.ELECTRON === "true" : !1;
20
21
  }
21
- function re() {
22
+ function Me() {
22
23
  if (typeof window > "u") return !1;
23
24
  const n = "ontouchstart" in window && !("onmousedown" in window), e = window.innerWidth <= 768 || window.innerHeight <= 768, t = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
24
25
  navigator.userAgent
25
26
  ), i = window.matchMedia?.("(pointer: coarse)")?.matches, s = window.matchMedia?.("(max-width: 768px)")?.matches;
26
27
  return n || e && t || i || s;
27
28
  }
28
- function ae() {
29
+ function ke() {
29
30
  if (typeof window > "u") return !1;
30
31
  try {
31
32
  return window.self !== window.top;
@@ -33,7 +34,7 @@ function ae() {
33
34
  return !0;
34
35
  }
35
36
  }
36
- function le(n, e) {
37
+ function Pe(n, e) {
37
38
  const t = {
38
39
  multiWindow: !1,
39
40
  nativeWindows: !1,
@@ -59,9 +60,9 @@ function le(n, e) {
59
60
  case "web":
60
61
  return {
61
62
  ...t,
62
- multiWindow: e.enablePopupTest ? de() : !1,
63
- crossWindowCommunication: ce() || he(),
64
- fullscreenSupport: V(),
63
+ multiWindow: e.enablePopupTest ? xe() : !1,
64
+ crossWindowCommunication: Te() || Ie(),
65
+ fullscreenSupport: q(),
65
66
  windowResizing: !1,
66
67
  // Browser windows can't be resized programmatically
67
68
  windowMinimizing: !1
@@ -69,7 +70,7 @@ function le(n, e) {
69
70
  case "mobile":
70
71
  return {
71
72
  ...t,
72
- fullscreenSupport: V(),
73
+ fullscreenSupport: q(),
73
74
  modalOverlays: !0
74
75
  };
75
76
  case "embedded":
@@ -81,7 +82,7 @@ function le(n, e) {
81
82
  return t;
82
83
  }
83
84
  }
84
- function de() {
85
+ function xe() {
85
86
  if (typeof window > "u" || typeof window.navigator < "u" && window.navigator.userAgent.includes("jsdom"))
86
87
  return !1;
87
88
  try {
@@ -91,28 +92,28 @@ function de() {
91
92
  return !1;
92
93
  }
93
94
  }
94
- function ce() {
95
+ function Te() {
95
96
  return typeof window < "u" && "BroadcastChannel" in window;
96
97
  }
97
- function he() {
98
+ function Ie() {
98
99
  return typeof window < "u" && "MessageChannel" in window;
99
100
  }
100
- function V() {
101
+ function q() {
101
102
  return typeof document > "u" ? !1 : !!(document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled);
102
103
  }
103
- function ue() {
104
+ function Oe() {
104
105
  return typeof navigator > "u" ? "unknown" : navigator.userAgent;
105
106
  }
106
- function pe() {
107
+ function ze() {
107
108
  return typeof window > "u" ? { width: 1920, height: 1080 } : {
108
109
  width: window.screen?.width || window.innerWidth || 1920,
109
110
  height: window.screen?.height || window.innerHeight || 1080
110
111
  };
111
112
  }
112
- function we() {
113
+ function De() {
113
114
  return typeof window > "u" ? !1 : "ontouchstart" in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
114
115
  }
115
- function fe() {
116
+ function He() {
116
117
  if (typeof navigator > "u")
117
118
  return {
118
119
  name: "unknown",
@@ -140,7 +141,7 @@ function fe() {
140
141
  }
141
142
  return { name: e, version: t, engine: i };
142
143
  }
143
- function me() {
144
+ function Ae() {
144
145
  if (typeof navigator > "u")
145
146
  return {
146
147
  name: "unknown",
@@ -167,7 +168,7 @@ function me() {
167
168
  }
168
169
  return { name: e, version: t };
169
170
  }
170
- function ge() {
171
+ function _e() {
171
172
  return typeof window > "u" ? {
172
173
  webgl: !1,
173
174
  webgl2: !1,
@@ -188,7 +189,7 @@ function ge() {
188
189
  resizeObserver: "ResizeObserver" in window
189
190
  };
190
191
  }
191
- function H(n) {
192
+ function F(n) {
192
193
  return {
193
194
  canOpenWindow: (e = !1) => e ? n.capabilities.nativeWindows : n.capabilities.multiWindow || n.capabilities.modalOverlays,
194
195
  canCommunicateBetweenWindows: () => n.capabilities.crossWindowCommunication,
@@ -199,7 +200,7 @@ function H(n) {
199
200
  getOptimalViewportType: (e = !1) => e && n.capabilities.nativeWindows ? "window" : n.capabilities.modalOverlays ? "modal" : n.platform === "mobile" ? "sheet" : "portal"
200
201
  };
201
202
  }
202
- class be {
203
+ class Fe {
203
204
  // Fallback strategies
204
205
  createModal(e) {
205
206
  throw new Error("Modal fallback not implemented");
@@ -208,7 +209,7 @@ class be {
208
209
  throw new Error("Portal fallback not implemented");
209
210
  }
210
211
  }
211
- class D extends be {
212
+ class V extends Fe {
212
213
  constructor(t = {}) {
213
214
  super();
214
215
  o(this, "environment");
@@ -217,7 +218,7 @@ class D extends be {
217
218
  o(this, "popups", /* @__PURE__ */ new Map());
218
219
  o(this, "portalContainer", null);
219
220
  o(this, "broadcastChannel", null);
220
- this.environment = O(t), this.initializePortalContainer();
221
+ this.environment = U(t), this.initializePortalContainer();
221
222
  }
222
223
  /**
223
224
  * Check if we can create a window with given config
@@ -321,21 +322,21 @@ class D extends be {
321
322
  * Create popup window (native browser window)
322
323
  */
323
324
  createPopupWindow(t) {
324
- const i = new ye(t);
325
+ const i = new Ve(t);
325
326
  return this.popups.set(t.id, i), i;
326
327
  }
327
328
  /**
328
329
  * Create modal overlay
329
330
  */
330
331
  createModal(t) {
331
- const i = new ve(t);
332
+ const i = new Ne(t);
332
333
  return this.modals.set(t.id, i), i;
333
334
  }
334
335
  /**
335
336
  * Create portal
336
337
  */
337
338
  createPortal(t) {
338
- const i = new We(t, this.portalContainer);
339
+ const i = new Ge(t, this.portalContainer);
339
340
  return this.portals.set(t.id, i), i;
340
341
  }
341
342
  /**
@@ -428,7 +429,7 @@ class D extends be {
428
429
  `, document.head.appendChild(i);
429
430
  }
430
431
  }
431
- class ye {
432
+ class Ve {
432
433
  constructor(e) {
433
434
  o(this, "id");
434
435
  o(this, "type", "window");
@@ -439,7 +440,7 @@ class ye {
439
440
  o(this, "eventHandlers", /* @__PURE__ */ new Map());
440
441
  o(this, "setState");
441
442
  this.id = e.id, this.config = e;
442
- const [t, i] = z({
443
+ const [t, i] = L({
443
444
  id: e.id,
444
445
  title: e.title || e.id,
445
446
  isVisible: !1,
@@ -637,7 +638,7 @@ class ye {
637
638
  removeChildWindow(e) {
638
639
  }
639
640
  }
640
- class ve {
641
+ class Ne {
641
642
  constructor(e) {
642
643
  o(this, "id");
643
644
  o(this, "type", "modal");
@@ -655,7 +656,7 @@ class ve {
655
656
  o(this, "parentWindow", null);
656
657
  o(this, "tabContainer", null);
657
658
  this.id = e.id, this.config = e;
658
- const [t, i] = z({
659
+ const [t, i] = L({
659
660
  id: e.id,
660
661
  title: e.title || e.id,
661
662
  isVisible: !1,
@@ -859,7 +860,7 @@ class ve {
859
860
  e && e.remove();
860
861
  }
861
862
  }
862
- class We {
863
+ class Ge {
863
864
  constructor(e, t) {
864
865
  o(this, "id");
865
866
  o(this, "type", "portal");
@@ -877,7 +878,7 @@ class We {
877
878
  o(this, "parentWindow", null);
878
879
  o(this, "tabContainer", null);
879
880
  this.container = t, this.id = e.id, this.config = e;
880
- const [i, s] = z({
881
+ const [i, s] = L({
881
882
  id: e.id,
882
883
  title: e.title || e.id,
883
884
  isVisible: !1,
@@ -904,7 +905,7 @@ class We {
904
905
  if (this.portalElement) {
905
906
  this.portalElement.innerHTML = "";
906
907
  try {
907
- const t = Y(e, this.portalElement);
908
+ const t = be(e, this.portalElement);
908
909
  this.cleanupFunction = t;
909
910
  } catch (t) {
910
911
  console.error("Error during mountComponentTree:", t);
@@ -1084,7 +1085,7 @@ class We {
1084
1085
  e && e.remove();
1085
1086
  }
1086
1087
  }
1087
- class A {
1088
+ class R {
1088
1089
  constructor(e, t = {}) {
1089
1090
  o(this, "adapter");
1090
1091
  o(this, "windows", /* @__PURE__ */ new Map());
@@ -1095,7 +1096,7 @@ class A {
1095
1096
  o(this, "globalStateCallbacks", /* @__PURE__ */ new Map());
1096
1097
  o(this, "environment");
1097
1098
  o(this, "platformConfig");
1098
- this.platformConfig = t, this.environment = O(t), e ? this.adapter = e : this.adapter = this.createDefaultAdapter(), this.adapter.setupCrossWindowCommunication(), this.adapter.optimizeForPlatform();
1099
+ this.platformConfig = t, this.environment = U(t), e ? this.adapter = e : this.adapter = this.createDefaultAdapter(), this.adapter.setupCrossWindowCommunication(), this.adapter.optimizeForPlatform();
1099
1100
  }
1100
1101
  /**
1101
1102
  * Open a new window/viewport
@@ -1142,20 +1143,20 @@ class A {
1142
1143
  createWindowGroup(e) {
1143
1144
  if (this.windowGroups.has(e))
1144
1145
  return this.windowGroups.get(e);
1145
- const t = new Se(e, this);
1146
+ const t = new Le(e, this);
1146
1147
  return this.windowGroups.set(e, t), t;
1147
1148
  }
1148
1149
  /**
1149
1150
  * Check if we can open a window with given options
1150
1151
  */
1151
1152
  canOpenWindow(e = {}) {
1152
- return H(this.environment).canOpenWindow(e.preferNativeWindow);
1153
+ return F(this.environment).canOpenWindow(e.preferNativeWindow);
1153
1154
  }
1154
1155
  /**
1155
1156
  * Get optimal window type for given options
1156
1157
  */
1157
1158
  getOptimalWindowType(e = {}) {
1158
- const t = H(this.environment);
1159
+ const t = F(this.environment);
1159
1160
  return e.preferNativeWindow && this.environment.capabilities.nativeWindows ? "window" : e.modal !== !1 && this.environment.capabilities.modalOverlays ? "modal" : t.getOptimalViewportType(e.preferNativeWindow);
1160
1161
  }
1161
1162
  /**
@@ -1200,9 +1201,9 @@ class A {
1200
1201
  createDefaultAdapter() {
1201
1202
  switch (this.environment.platform) {
1202
1203
  case "electron":
1203
- return new D(this.platformConfig);
1204
+ return new V(this.platformConfig);
1204
1205
  default:
1205
- return new D(this.platformConfig);
1206
+ return new V(this.platformConfig);
1206
1207
  }
1207
1208
  }
1208
1209
  // ==================== Phase 2: Global State Management ====================
@@ -1266,7 +1267,7 @@ class A {
1266
1267
  });
1267
1268
  }
1268
1269
  }
1269
- class Se {
1270
+ class Le {
1270
1271
  constructor(e, t, i = "any") {
1271
1272
  o(this, "windows", /* @__PURE__ */ new Map());
1272
1273
  o(this, "defaultOptions", {});
@@ -1304,8 +1305,8 @@ class Se {
1304
1305
  return await a.show(), await a.focus(), a.markAsUsed(), a;
1305
1306
  let r = await this.getPooledWindow();
1306
1307
  if (r) {
1307
- const c = t(e);
1308
- return r.render(c), this.setWindowGroupMetadata(r, {
1308
+ const d = t(e);
1309
+ return r.render(d), this.setWindowGroupMetadata(r, {
1309
1310
  id: s,
1310
1311
  groupId: this.id,
1311
1312
  isPooled: !1,
@@ -1313,13 +1314,13 @@ class Se {
1313
1314
  }), await r.show(), await r.focus(), this.windows.set(i, r), this.emitEvent("window:reused", r, e), r;
1314
1315
  }
1315
1316
  if (this.windows.size >= this.maxInstances) {
1316
- const c = this.windows.values().next().value;
1317
- c && (this.poolConfig.enabled ? await this.returnToPool(c) : await c.close());
1317
+ const d = this.windows.values().next().value;
1318
+ d && (this.poolConfig.enabled ? await this.returnToPool(d) : await d.close());
1318
1319
  }
1319
- const h = t(e);
1320
+ const u = t(e);
1320
1321
  return r = await this.manager.openWindow(
1321
1322
  s,
1322
- h,
1323
+ u,
1323
1324
  this.defaultOptions
1324
1325
  ), this.setWindowGroupMetadata(r, {
1325
1326
  groupId: this.id,
@@ -1553,17 +1554,17 @@ class Se {
1553
1554
  });
1554
1555
  }
1555
1556
  arrangeWindowsAsTiles(e) {
1556
- const t = typeof window < "u" ? window.screen.width : 1920, i = typeof window < "u" ? window.screen.height : 1080, s = Math.ceil(Math.sqrt(e.length)), a = Math.ceil(e.length / s), r = t / s, h = i / a;
1557
- e.forEach((c, l) => {
1558
- const w = l % s, F = Math.floor(l / s);
1559
- this.setWindowGroupMetadata(c, {
1557
+ const t = typeof window < "u" ? window.screen.width : 1920, i = typeof window < "u" ? window.screen.height : 1080, s = Math.ceil(Math.sqrt(e.length)), a = Math.ceil(e.length / s), r = t / s, u = i / a;
1558
+ e.forEach((d, l) => {
1559
+ const p = l % s, b = Math.floor(l / s);
1560
+ this.setWindowGroupMetadata(d, {
1560
1561
  tilePosition: {
1561
- col: w,
1562
- row: F,
1563
- x: w * r,
1564
- y: F * h,
1562
+ col: p,
1563
+ row: b,
1564
+ x: p * r,
1565
+ y: b * u,
1565
1566
  width: r,
1566
- height: h
1567
+ height: u
1567
1568
  },
1568
1569
  arrangementStyle: "tile"
1569
1570
  });
@@ -1614,17 +1615,17 @@ class Se {
1614
1615
  }
1615
1616
  }
1616
1617
  }
1617
- let m = null;
1618
- function u(n = {}) {
1619
- return m || (m = new A(void 0, n)), m;
1618
+ let g = null;
1619
+ function h(n = {}) {
1620
+ return g || (g = new R(void 0, n)), g;
1620
1621
  }
1621
- function R(n) {
1622
- m?.dispose(), m = n;
1622
+ function se(n) {
1623
+ g?.dispose(), g = n;
1623
1624
  }
1624
- function Ee() {
1625
- m?.dispose(), m = null;
1625
+ function Ue() {
1626
+ g?.dispose(), g = null;
1626
1627
  }
1627
- function y(n) {
1628
+ function S(n) {
1628
1629
  return {
1629
1630
  type: "window-scene",
1630
1631
  sceneType: "window",
@@ -1649,27 +1650,27 @@ function y(n) {
1649
1650
  },
1650
1651
  // Open this window
1651
1652
  async open() {
1652
- const e = u(), t = ee(() => te((i) => n.children(), `Window-${n.id}`)({}));
1653
+ const e = h(), t = ye(() => ve((i) => n.children(), `Window-${n.id}`)({}));
1653
1654
  await e.openWindow(n.id, t, n);
1654
1655
  },
1655
1656
  // Close this window
1656
1657
  async close() {
1657
- await u().dismissWindow(n.id);
1658
+ await h().dismissWindow(n.id);
1658
1659
  }
1659
1660
  };
1660
1661
  }
1661
- function T(n) {
1662
- const e = u(), t = e.createWindowGroup(n.id);
1662
+ function H(n) {
1663
+ const e = h(), t = e.createWindowGroup(n.id);
1663
1664
  n.groupingStrategy && t.setGroupingStrategy(n.groupingStrategy), n.tabConfig && t.configureTabbing(n.tabConfig), n.poolConfig && t.configurePool(n.poolConfig), n.stateSyncScope && t.enableStateSync(n.stateSyncScope), n.maxInstances && t.setMaxInstances(n.maxInstances);
1664
1665
  const {
1665
1666
  groupingStrategy: i,
1666
1667
  tabConfig: s,
1667
1668
  poolConfig: a,
1668
1669
  stateSyncScope: r,
1669
- maxInstances: h,
1670
- ...c
1670
+ maxInstances: u,
1671
+ ...d
1671
1672
  } = n;
1672
- return t.setDefaultOptions(c), {
1673
+ return t.setDefaultOptions(d), {
1673
1674
  type: "window-group",
1674
1675
  sceneType: "window-group",
1675
1676
  id: n.id,
@@ -1700,8 +1701,8 @@ function T(n) {
1700
1701
  n.children
1701
1702
  );
1702
1703
  else {
1703
- const w = n.children();
1704
- await e.openWindow(n.id, w, n);
1704
+ const p = n.children();
1705
+ await e.openWindow(n.id, p, n);
1705
1706
  }
1706
1707
  },
1707
1708
  // Open window for specific data
@@ -1736,18 +1737,18 @@ function T(n) {
1736
1737
  enableStateSync(l) {
1737
1738
  t.enableStateSync(l);
1738
1739
  },
1739
- syncGroupState(l, w) {
1740
- t.syncState(l, w);
1740
+ syncGroupState(l, p) {
1741
+ t.syncState(l, p);
1741
1742
  },
1742
1743
  getGroupState(l) {
1743
1744
  return t.getSharedState(l);
1744
1745
  },
1745
- onGroupStateChange(l, w) {
1746
- return t.onStateChange(l, w);
1746
+ onGroupStateChange(l, p) {
1747
+ return t.onStateChange(l, p);
1747
1748
  }
1748
1749
  };
1749
1750
  }
1750
- function M(n) {
1751
+ function T(n) {
1751
1752
  return {
1752
1753
  type: "app",
1753
1754
  scenes: n.children,
@@ -1767,8 +1768,8 @@ function M(n) {
1767
1768
  },
1768
1769
  // Initialize all scenes
1769
1770
  async initialize() {
1770
- if (!u(n.platformConfig)) {
1771
- const { initializeViewportSystem: t } = await Promise.resolve().then(() => ct);
1771
+ if (!h(n.platformConfig)) {
1772
+ const { initializeViewportSystem: t } = await Promise.resolve().then(() => Ut);
1772
1773
  t();
1773
1774
  }
1774
1775
  },
@@ -1785,12 +1786,12 @@ function M(n) {
1785
1786
  }
1786
1787
  };
1787
1788
  }
1788
- const k = {
1789
+ const I = {
1789
1790
  /**
1790
1791
  * Create a document window group
1791
1792
  */
1792
1793
  documentGroup(n, e, t, i) {
1793
- return T({
1794
+ return H({
1794
1795
  id: n,
1795
1796
  title: e,
1796
1797
  for: t,
@@ -1804,7 +1805,7 @@ const k = {
1804
1805
  * Create a settings window
1805
1806
  */
1806
1807
  settingsWindow(n) {
1807
- return y({
1808
+ return S({
1808
1809
  id: "settings",
1809
1810
  title: "Settings",
1810
1811
  width: 600,
@@ -1817,7 +1818,7 @@ const k = {
1817
1818
  * Create an inspector window
1818
1819
  */
1819
1820
  inspectorWindow(n) {
1820
- return y({
1821
+ return S({
1821
1822
  id: "inspector",
1822
1823
  title: "Inspector",
1823
1824
  width: 300,
@@ -1831,7 +1832,7 @@ const k = {
1831
1832
  * Create a palette window
1832
1833
  */
1833
1834
  paletteWindow(n, e, t) {
1834
- return y({
1835
+ return S({
1835
1836
  id: n,
1836
1837
  title: e,
1837
1838
  width: 250,
@@ -1841,13 +1842,13 @@ const k = {
1841
1842
  children: t
1842
1843
  });
1843
1844
  }
1844
- }, $ = {
1845
+ }, oe = {
1845
1846
  /**
1846
1847
  * Basic app with main window and settings
1847
1848
  */
1848
- basicApp: () => M({
1849
+ basicApp: () => T({
1849
1850
  children: [
1850
- y({
1851
+ S({
1851
1852
  id: "main",
1852
1853
  title: "My App",
1853
1854
  children: () => ({
@@ -1863,7 +1864,7 @@ const k = {
1863
1864
  })
1864
1865
  })
1865
1866
  }),
1866
- k.settingsWindow(() => ({
1867
+ I.settingsWindow(() => ({
1867
1868
  type: "component",
1868
1869
  id: "settings-content",
1869
1870
  props: {},
@@ -1880,9 +1881,9 @@ const k = {
1880
1881
  /**
1881
1882
  * Document-based app
1882
1883
  */
1883
- documentApp: () => M({
1884
+ documentApp: () => T({
1884
1885
  children: [
1885
- T({
1886
+ H({
1886
1887
  id: "document",
1887
1888
  title: "Document",
1888
1889
  for: class {
@@ -1904,7 +1905,7 @@ const k = {
1904
1905
  })
1905
1906
  })
1906
1907
  }),
1907
- k.settingsWindow(() => ({
1908
+ I.settingsWindow(() => ({
1908
1909
  type: "component",
1909
1910
  id: "settings",
1910
1911
  props: {},
@@ -1918,12 +1919,12 @@ const k = {
1918
1919
  }))
1919
1920
  ]
1920
1921
  })
1921
- }, q = ne(null);
1922
- function B({
1922
+ }, re = We(null);
1923
+ function ae({
1923
1924
  children: n,
1924
1925
  manager: e
1925
1926
  }) {
1926
- const t = e || u(), i = {
1927
+ const t = e || h(), i = {
1927
1928
  openWindow: async (s, a, r) => await t.openWindow(s, a, r),
1928
1929
  dismissWindow: async (s) => await t.dismissWindow(s),
1929
1930
  viewportEnvironment: t.environment,
@@ -1932,47 +1933,47 @@ function B({
1932
1933
  };
1933
1934
  return {
1934
1935
  type: "context-provider",
1935
- context: q,
1936
+ context: re,
1936
1937
  value: i,
1937
1938
  children: Array.isArray(n) ? n : [n]
1938
1939
  };
1939
1940
  }
1940
- function v() {
1941
- const n = ie(q);
1941
+ function C() {
1942
+ const n = Se(re);
1942
1943
  if (!n)
1943
1944
  throw new Error(
1944
1945
  "useViewportEnvironment must be used within a ViewportEnvironmentProvider"
1945
1946
  );
1946
1947
  return n();
1947
1948
  }
1948
- function P() {
1949
- const { openWindow: n } = v();
1949
+ function O() {
1950
+ const { openWindow: n } = C();
1950
1951
  return n;
1951
1952
  }
1952
- function x() {
1953
- const { dismissWindow: n } = v();
1953
+ function z() {
1954
+ const { dismissWindow: n } = C();
1954
1955
  return n;
1955
1956
  }
1956
- function _() {
1957
- const { viewportEnvironment: n } = v();
1957
+ function $() {
1958
+ const { viewportEnvironment: n } = C();
1958
1959
  return n;
1959
1960
  }
1960
- function Ce() {
1961
- const { currentWindow: n } = v();
1961
+ function Re() {
1962
+ const { currentWindow: n } = C();
1962
1963
  return n;
1963
1964
  }
1964
- function Me() {
1965
- return u();
1965
+ function $e() {
1966
+ return h();
1966
1967
  }
1967
- function ke(n, e) {
1968
- return (t) => B({
1968
+ function Be(n, e) {
1969
+ return (t) => ae({
1969
1970
  children: n(t),
1970
1971
  manager: e
1971
1972
  });
1972
1973
  }
1973
- function Pe(n) {
1974
+ function je(n) {
1974
1975
  return (e) => {
1975
- const t = P(), i = x(), s = _();
1976
+ const t = O(), i = z(), s = $();
1976
1977
  return n({
1977
1978
  ...e,
1978
1979
  openWindow: t,
@@ -1981,46 +1982,70 @@ function Pe(n) {
1981
1982
  });
1982
1983
  };
1983
1984
  }
1984
- const xe = {
1985
+ const qe = {
1985
1986
  openWindow: "openWindow",
1986
1987
  dismissWindow: "dismissWindow",
1987
1988
  viewportEnvironment: "viewportEnvironment",
1988
1989
  currentWindow: "currentWindow"
1989
1990
  };
1990
- function Te(n) {
1991
- return v()[n];
1991
+ function Qe(n) {
1992
+ return C()[n];
1992
1993
  }
1993
- var d = /* @__PURE__ */ ((n) => (n[n.Clean = 0] = "Clean", n[n.Check = 1] = "Check", n[n.Dirty = 2] = "Dirty", n[n.Disposed = 3] = "Disposed", n))(d || {}), Ie = Object.defineProperty, He = (n, e, t) => e in n ? Ie(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, f = (n, e, t) => He(n, typeof e != "symbol" ? e + "" : e, t);
1994
- let De = 0, S = null, ze = null;
1995
- function j() {
1996
- return S;
1994
+ const Ke = "0.8.8", Xe = Ke, c = {
1995
+ Clean: 0,
1996
+ Check: 1,
1997
+ Dirty: 2,
1998
+ Disposed: 3
1999
+ };
2000
+ var Je = Object.defineProperty, Ze = (n, e, t) => e in n ? Je(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, f = (n, e, t) => Ze(n, typeof e != "symbol" ? e + "" : e, t);
2001
+ let Ye = 0;
2002
+ const et = Math.random().toString(36).substr(2, 6);
2003
+ let Q = null, K = null;
2004
+ const tt = /* @__PURE__ */ new Set();
2005
+ tt.add(et);
2006
+ const E = {
2007
+ get currentComputation() {
2008
+ return Q;
2009
+ },
2010
+ set currentComputation(n) {
2011
+ Q = n;
2012
+ },
2013
+ get currentOwner() {
2014
+ return K;
2015
+ },
2016
+ set currentOwner(n) {
2017
+ K = n;
2018
+ }
2019
+ };
2020
+ function le() {
2021
+ return E.currentComputation;
1997
2022
  }
1998
- function Q() {
1999
- return ze;
2023
+ function B() {
2024
+ return E.currentOwner;
2000
2025
  }
2001
- class K {
2026
+ let de = class {
2002
2027
  constructor(e, t = null) {
2003
- f(this, "id"), f(this, "owner"), f(this, "fn"), f(this, "sources", /* @__PURE__ */ new Set()), f(this, "observers", /* @__PURE__ */ new Set()), f(this, "state", d.Dirty), f(this, "value"), this.id = ++De, this.fn = e, this.owner = t, t && !t.disposed && t.sources.add(this);
2028
+ f(this, "id"), f(this, "owner"), f(this, "fn"), f(this, "sources", /* @__PURE__ */ new Set()), f(this, "observers", /* @__PURE__ */ new Set()), f(this, "state", c.Dirty), f(this, "value"), this.id = ++Ye, this.fn = e, this.owner = t, t && !t.disposed && t.sources.add(this);
2004
2029
  }
2005
2030
  execute() {
2006
- if (this.state === d.Disposed)
2031
+ if (this.state === c.Disposed)
2007
2032
  return this.value;
2008
2033
  for (const t of this.sources)
2009
2034
  t && typeof t == "object" && "removeObserver" in t && t.removeObserver(this);
2010
2035
  this.sources.clear();
2011
- const e = S;
2012
- S = this;
2036
+ const e = E.currentComputation;
2037
+ E.currentComputation = this;
2013
2038
  try {
2014
- return this.state = d.Clean, this.value = this.fn(), this.value;
2039
+ return this.state = c.Clean, this.value = this.fn(), this.value;
2015
2040
  } catch (t) {
2016
- throw this.state = d.Disposed, (typeof process > "u" || process.env.NODE_ENV !== "test") && console.error("Error in computation:", t), t;
2041
+ throw this.state = c.Disposed, (typeof process > "u" || process.env.NODE_ENV !== "test") && console.error("Error in computation:", t), t;
2017
2042
  } finally {
2018
- S = e;
2043
+ E.currentComputation = e;
2019
2044
  }
2020
2045
  }
2021
2046
  dispose() {
2022
- if (this.state !== d.Disposed) {
2023
- this.state = d.Disposed;
2047
+ if (this.state !== c.Disposed) {
2048
+ this.state = c.Disposed;
2024
2049
  for (const e of this.sources)
2025
2050
  e && typeof e == "object" && "removeObserver" in e && e.removeObserver(this);
2026
2051
  this.sources.clear();
@@ -2029,19 +2054,21 @@ class K {
2029
2054
  this.observers.clear(), this.owner && !this.owner.disposed && this.owner.sources.delete(this);
2030
2055
  }
2031
2056
  }
2057
+ };
2058
+ function nt() {
2059
+ return E.currentOwner;
2032
2060
  }
2033
- var Oe = Object.defineProperty, Ae = (n, e, t) => e in n ? Oe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, I = (n, e, t) => Ae(n, typeof e != "symbol" ? e + "" : e, t);
2034
- let _e = 0;
2035
- class Fe {
2061
+ var it = Object.defineProperty, st = (n, e, t) => e in n ? it(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, A = (n, e, t) => st(n, typeof e != "symbol" ? e + "" : e, t);
2062
+ let ot = 0, rt = class {
2036
2063
  constructor(e) {
2037
- I(this, "id"), I(this, "observers", /* @__PURE__ */ new Set()), I(this, "_value"), this.id = ++_e, this._value = e;
2064
+ A(this, "id"), A(this, "observers", /* @__PURE__ */ new Set()), A(this, "_value"), this.id = ++ot, this._value = e;
2038
2065
  }
2039
2066
  /**
2040
2067
  * Get the current value and track dependency
2041
2068
  */
2042
2069
  getValue() {
2043
- const e = j();
2044
- return e && e.state !== d.Disposed && (this.observers.add(e), e.sources.add(this)), this._value;
2070
+ const e = le();
2071
+ return e && e.state !== c.Disposed && (this.observers.add(e), e.sources.add(this)), this._value;
2045
2072
  }
2046
2073
  /**
2047
2074
  * Get the current value without tracking dependency
@@ -2061,7 +2088,7 @@ class Fe {
2061
2088
  */
2062
2089
  notify() {
2063
2090
  for (const e of this.observers)
2064
- e.state !== d.Disposed && (e.state = d.Dirty, Ve(e));
2091
+ e.state !== c.Disposed && (e.state = c.Dirty, at(e));
2065
2092
  }
2066
2093
  /**
2067
2094
  * Remove an observer (cleanup)
@@ -2080,29 +2107,29 @@ class Fe {
2080
2107
  type: "Signal"
2081
2108
  };
2082
2109
  }
2110
+ };
2111
+ const P = /* @__PURE__ */ new Set();
2112
+ let x = !1;
2113
+ function at(n) {
2114
+ P.add(n), !x && queueMicrotask(lt);
2083
2115
  }
2084
- const E = /* @__PURE__ */ new Set();
2085
- let C = !1;
2086
- function Ve(n) {
2087
- E.add(n), !C && queueMicrotask(Ge);
2088
- }
2089
- function Ge() {
2090
- if (!C) {
2091
- C = !0;
2116
+ function lt() {
2117
+ if (!x) {
2118
+ x = !0;
2092
2119
  try {
2093
- for (; E.size > 0; ) {
2094
- const n = Array.from(E).sort((e, t) => e.id - t.id);
2095
- E.clear();
2120
+ for (; P.size > 0; ) {
2121
+ const n = Array.from(P).sort((e, t) => e.id - t.id);
2122
+ P.clear();
2096
2123
  for (const e of n)
2097
- e.state === d.Dirty && e.execute();
2124
+ e.state === c.Dirty && e.execute();
2098
2125
  }
2099
2126
  } finally {
2100
- C = !1;
2127
+ x = !1;
2101
2128
  }
2102
2129
  }
2103
2130
  }
2104
- function Ne(n) {
2105
- const e = new Fe(n), t = e.getValue.bind(e);
2131
+ function dt(n) {
2132
+ const e = new rt(n), t = e.getValue.bind(e);
2106
2133
  t.peek = e.peek.bind(e);
2107
2134
  const i = e.set.bind(e);
2108
2135
  return Object.defineProperty(t, Symbol.for("tachui.signal"), {
@@ -2110,24 +2137,24 @@ function Ne(n) {
2110
2137
  enumerable: !1
2111
2138
  }), [t, i];
2112
2139
  }
2113
- function G(n) {
2140
+ function X(n) {
2114
2141
  return typeof n == "function" && Symbol.for("tachui.signal") in n;
2115
2142
  }
2116
- const Le = (n, e) => n === e;
2117
- var Ue = Object.defineProperty, Re = (n, e, t) => e in n ? Ue(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, p = (n, e, t) => Re(n, typeof e != "symbol" ? e + "" : e, t), W = /* @__PURE__ */ ((n) => (n[n.Immediate = 0] = "Immediate", n[n.High = 1] = "High", n[n.Normal = 2] = "Normal", n[n.Low = 3] = "Low", n[n.Idle = 4] = "Idle", n))(W || {});
2118
- class $e extends Error {
2143
+ const ct = (n, e) => n === e;
2144
+ var ut = Object.defineProperty, ht = (n, e, t) => e in n ? ut(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, w = (n, e, t) => ht(n, typeof e != "symbol" ? e + "" : e, t), k = /* @__PURE__ */ ((n) => (n[n.Immediate = 0] = "Immediate", n[n.High = 1] = "High", n[n.Normal = 2] = "Normal", n[n.Low = 3] = "Low", n[n.Idle = 4] = "Idle", n))(k || {});
2145
+ class pt extends Error {
2119
2146
  constructor(e, t, i) {
2120
2147
  super(e), this.cause = t, this.node = i, this.name = "ReactiveError";
2121
2148
  }
2122
2149
  }
2123
- const qe = class b {
2150
+ const wt = class v {
2124
2151
  constructor() {
2125
- p(this, "updateQueues", /* @__PURE__ */ new Map()), p(this, "isFlushPending", !1), p(this, "isDestroyed", !1), p(this, "errorHandlers", /* @__PURE__ */ new Set()), p(this, "maxRetries", 3), p(this, "totalUpdateCycles", 0), p(this, "totalUpdateTime", 0), p(this, "errorCount", 0), p(this, "nodeRegistry", /* @__PURE__ */ new WeakSet());
2126
- for (const e of Object.values(W))
2152
+ w(this, "updateQueues", /* @__PURE__ */ new Map()), w(this, "isFlushPending", !1), w(this, "isDestroyed", !1), w(this, "errorHandlers", /* @__PURE__ */ new Set()), w(this, "maxRetries", 3), w(this, "totalUpdateCycles", 0), w(this, "totalUpdateTime", 0), w(this, "errorCount", 0), w(this, "nodeRegistry", /* @__PURE__ */ new WeakSet());
2153
+ for (const e of Object.values(k))
2127
2154
  typeof e == "number" && this.updateQueues.set(e, /* @__PURE__ */ new Set());
2128
2155
  }
2129
2156
  static getInstance() {
2130
- return b.instance || (b.instance = new b()), b.instance;
2157
+ return v.instance || (v.instance = new v()), v.instance;
2131
2158
  }
2132
2159
  /**
2133
2160
  * Schedule reactive node for update
@@ -2160,7 +2187,7 @@ const qe = class b {
2160
2187
  await this.updateNodeWithRetry(a);
2161
2188
  } catch (r) {
2162
2189
  this.handleReactiveError(
2163
- new $e(`Failed to update ${a.type} node ${a.id}`, r, a)
2190
+ new pt(`Failed to update ${a.type} node ${a.id}`, r, a)
2164
2191
  );
2165
2192
  }
2166
2193
  if (this.hasHigherPriorityWork(t))
@@ -2306,7 +2333,7 @@ const qe = class b {
2306
2333
  }
2307
2334
  e.clear();
2308
2335
  }
2309
- this.updateQueues.clear(), this.errorHandlers.clear(), b.instance = null;
2336
+ this.updateQueues.clear(), this.errorHandlers.clear(), v.instance = null;
2310
2337
  }
2311
2338
  /**
2312
2339
  * Get debug information
@@ -2314,7 +2341,7 @@ const qe = class b {
2314
2341
  getDebugInfo() {
2315
2342
  const e = {};
2316
2343
  for (const [t, i] of this.updateQueues)
2317
- e[W[t]] = i.size;
2344
+ e[k[t]] = i.size;
2318
2345
  return {
2319
2346
  isFlushPending: this.isFlushPending,
2320
2347
  isDestroyed: this.isDestroyed,
@@ -2324,30 +2351,35 @@ const qe = class b {
2324
2351
  };
2325
2352
  }
2326
2353
  };
2327
- p(qe, "instance", null);
2328
- var Be = Object.defineProperty, je = (n, e, t) => e in n ? Be(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t) => je(n, typeof e != "symbol" ? e + "" : e, t);
2329
- class Qe extends K {
2330
- constructor(e, t = {}, i = Q()) {
2331
- super(e, i), g(this, "type", "computed"), g(this, "priority"), g(this, "_hasValue", !1), g(this, "_error", null), g(this, "equalsFn"), g(this, "options"), this.priority = t.priority ?? W.Normal, this.equalsFn = t.equals ?? Le, this.options = t;
2354
+ w(wt, "instance", null);
2355
+ var ft = Object.defineProperty, mt = (n, e, t) => e in n ? ft(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, y = (n, e, t) => mt(n, typeof e != "symbol" ? e + "" : e, t);
2356
+ class gt extends de {
2357
+ constructor(e, t = {}, i = B()) {
2358
+ super(e, i), y(this, "type", "computed"), y(this, "priority"), y(this, "_hasValue", !1), y(this, "_error", null), y(this, "equalsFn"), y(this, "options"), this.priority = t.priority ?? k.Normal, this.equalsFn = t.equals ?? ct, this.options = t;
2332
2359
  }
2333
2360
  /**
2334
2361
  * Get the computed value, tracking dependency and lazily computing
2335
2362
  */
2336
2363
  getValue() {
2337
- const e = j();
2338
- return e && e.state !== d.Disposed && (this.observers.add(e), e.sources.add(this)), (this.state === d.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
2364
+ const e = le();
2365
+ return e && e.state !== c.Disposed && (this.observers.add(e), e.sources.add(this)), (this.state === c.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
2339
2366
  }
2340
2367
  /**
2341
2368
  * Get the current value without tracking dependency
2342
2369
  */
2343
2370
  peek() {
2344
- return (this.state === d.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
2371
+ return (this.state === c.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
2345
2372
  }
2346
2373
  /**
2347
2374
  * Remove an observer (cleanup)
2348
2375
  */
2349
2376
  removeObserver(e) {
2350
- this.observers.delete(e);
2377
+ this.observers.delete(e), this.options.releaseOnNoObservers === !0 && this.observers.size === 0 && e.state === c.Disposed && this.releaseSources();
2378
+ }
2379
+ releaseSources() {
2380
+ for (const e of this.sources)
2381
+ "removeObserver" in e && e.removeObserver(this);
2382
+ this.sources.clear(), this._hasValue = !1, this.state = c.Dirty;
2351
2383
  }
2352
2384
  /**
2353
2385
  * Execute the computation and notify observers
@@ -2356,8 +2388,8 @@ class Qe extends K {
2356
2388
  const e = this._hasValue ? this.value : void 0, t = super.execute();
2357
2389
  if (!this._hasValue || !this.equalsFn(e, t))
2358
2390
  for (const i of this.observers)
2359
- i.state !== d.Disposed && (i.state = d.Dirty, "execute" in i && typeof i.execute == "function" && queueMicrotask(() => {
2360
- i.state === d.Dirty && i.execute();
2391
+ i.state !== c.Disposed && (i.state = c.Dirty, "execute" in i && typeof i.execute == "function" && queueMicrotask(() => {
2392
+ i.state === c.Dirty && i.execute();
2361
2393
  }));
2362
2394
  return t;
2363
2395
  }
@@ -2376,7 +2408,7 @@ class Qe extends K {
2376
2408
  this.sources.clear();
2377
2409
  for (const e of this.observers)
2378
2410
  e.sources.delete(this);
2379
- this.observers.clear(), this._hasValue = !1, this._error = null, this.state = d.Disposed;
2411
+ this.observers.clear(), this._hasValue = !1, this._error = null, this.state = c.Disposed;
2380
2412
  }
2381
2413
  /**
2382
2414
  * Dispose the computed value
@@ -2397,7 +2429,7 @@ class Qe extends K {
2397
2429
  state: this.state,
2398
2430
  sourceCount: this.sources.size,
2399
2431
  observerCount: this.observers.size,
2400
- priority: W[this.priority],
2432
+ priority: k[this.priority],
2401
2433
  debugName: this.options.debugName,
2402
2434
  equalsFn: this.equalsFn.name || "anonymous"
2403
2435
  };
@@ -2406,8 +2438,8 @@ class Qe extends K {
2406
2438
  return `Computed(${this.options.debugName || this.id}): ${this._hasValue ? this.value : "no value"}`;
2407
2439
  }
2408
2440
  }
2409
- function Ke(n, e) {
2410
- const t = new Qe(n, e), i = t.getValue.bind(t);
2441
+ function bt(n, e) {
2442
+ const t = new gt(n, e), i = t.getValue.bind(t);
2411
2443
  return i.peek = t.peek.bind(t), Object.defineProperty(i, Symbol.for("tachui.computed"), {
2412
2444
  value: t,
2413
2445
  enumerable: !1
@@ -2416,19 +2448,30 @@ function Ke(n, e) {
2416
2448
  function N(n) {
2417
2449
  return typeof n == "function" && Symbol.for("tachui.computed") in n;
2418
2450
  }
2419
- const [Xe, wt] = Ne("light");
2420
- Ke(() => {
2421
- const n = Xe();
2422
- return n === "system" ? Je() : n;
2451
+ function yt(n) {
2452
+ return n[Symbol.for("tachui.computed")] || null;
2453
+ }
2454
+ function vt(n) {
2455
+ const e = yt(n);
2456
+ !e || e.observers.size !== 0 || e.releaseSources();
2457
+ }
2458
+ const [Wt, Kt] = dt("light");
2459
+ bt(() => {
2460
+ const n = Wt();
2461
+ return n === "system" ? St() : n;
2423
2462
  });
2424
- function Je() {
2463
+ function St() {
2425
2464
  return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
2426
2465
  }
2466
+ function Et(n) {
2467
+ const e = B();
2468
+ e && !e.disposed ? e.cleanups.push(n) : __DEV__ && console.warn("onCleanup called outside of reactive context");
2469
+ }
2427
2470
  typeof globalThis.__DEV__ > "u" && (globalThis.__DEV__ = process.env.NODE_ENV !== "production");
2428
- var Ze = Object.defineProperty, Ye = (n, e, t) => e in n ? Ze(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, L = (n, e, t) => Ye(n, typeof e != "symbol" ? e + "" : e, t);
2429
- class et {
2471
+ var Ct = Object.defineProperty, Mt = (n, e, t) => e in n ? Ct(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, J = (n, e, t) => Mt(n, typeof e != "symbol" ? e + "" : e, t);
2472
+ class kt {
2430
2473
  constructor() {
2431
- L(this, "pending", /* @__PURE__ */ new Set()), L(this, "isFlushScheduled", !1);
2474
+ J(this, "pending", /* @__PURE__ */ new Set()), J(this, "isFlushScheduled", !1);
2432
2475
  }
2433
2476
  schedule(e) {
2434
2477
  this.pending.add(e), this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
@@ -2449,20 +2492,122 @@ class et {
2449
2492
  this.pending.size > 0 && (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
2450
2493
  }
2451
2494
  }
2452
- new et();
2453
- function U(n, e = {}) {
2454
- const t = Q();
2495
+ new kt();
2496
+ function ce(n, e = {}) {
2497
+ const t = B();
2455
2498
  let i;
2456
2499
  const s = () => {
2457
2500
  const r = n(i);
2458
2501
  return i = r, r;
2459
- }, a = new K(s, t);
2502
+ }, a = new de(s, t);
2460
2503
  return e.name && Object.defineProperty(a, "name", {
2461
2504
  value: e.name,
2462
2505
  enumerable: !1
2463
2506
  }), a.execute(), a;
2464
2507
  }
2465
- class tt {
2508
+ const M = /* @__PURE__ */ new WeakMap();
2509
+ function Z(n, e, t) {
2510
+ try {
2511
+ n(e);
2512
+ } catch (i) {
2513
+ console.error(`Reactive style updater failed (${t}):`, i);
2514
+ }
2515
+ }
2516
+ const G = 200, m = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new Set();
2517
+ let Y = !1, _ = !1;
2518
+ function Pt(n) {
2519
+ m.get(n)?.forEach((e) => e()), m.delete(n), D.delete(n);
2520
+ }
2521
+ function ue() {
2522
+ const n = Date.now();
2523
+ for (const e of Array.from(W)) {
2524
+ const t = e.deref();
2525
+ if (!t) {
2526
+ W.delete(e);
2527
+ continue;
2528
+ }
2529
+ const i = D.get(t), s = m.get(t);
2530
+ if (!i || !s || s.size === 0) {
2531
+ W.delete(e);
2532
+ continue;
2533
+ }
2534
+ if (t.isConnected) {
2535
+ i.wasConnected = !0;
2536
+ continue;
2537
+ }
2538
+ (i.wasConnected || n - i.trackedAt >= G) && (Pt(t), W.delete(e));
2539
+ }
2540
+ }
2541
+ function xt() {
2542
+ if (_ || typeof setTimeout != "function") return;
2543
+ _ = !0;
2544
+ const n = () => {
2545
+ if (ue(), W.size === 0) {
2546
+ _ = !1;
2547
+ return;
2548
+ }
2549
+ setTimeout(n, G);
2550
+ };
2551
+ setTimeout(n, G);
2552
+ }
2553
+ function Tt() {
2554
+ Y || typeof document > "u" || !document.documentElement || typeof MutationObserver > "u" || (new MutationObserver(() => {
2555
+ ue();
2556
+ }).observe(document.documentElement, { childList: !0, subtree: !0 }), Y = !0);
2557
+ }
2558
+ function It(n, e) {
2559
+ Tt(), xt();
2560
+ const t = m.get(n) ?? /* @__PURE__ */ new Set(), i = t.size > 0;
2561
+ return t.add(e), m.set(n, t), i || (D.set(n, {
2562
+ trackedAt: Date.now(),
2563
+ wasConnected: n.isConnected
2564
+ }), W.add(new WeakRef(n))), () => {
2565
+ const s = m.get(n);
2566
+ s && (s.delete(e), s.size === 0 && (m.delete(n), D.delete(n)));
2567
+ };
2568
+ }
2569
+ function Ot({
2570
+ element: n,
2571
+ accessor: e,
2572
+ updater: t,
2573
+ updaterId: i
2574
+ }) {
2575
+ const s = M.get(n) ?? /* @__PURE__ */ new Map();
2576
+ M.has(n) || M.set(n, s);
2577
+ let a = s.get(e);
2578
+ if (!a) {
2579
+ const d = /* @__PURE__ */ new Map();
2580
+ a = { effect: ce(() => {
2581
+ const l = e();
2582
+ d.forEach(
2583
+ (p, b) => Z(p, l, b)
2584
+ );
2585
+ }), updaters: d }, s.set(e, a);
2586
+ }
2587
+ a.updaters.set(i, t), Z(t, e(), i);
2588
+ let r = null;
2589
+ const u = () => {
2590
+ r && (r(), r = null);
2591
+ const d = M.get(n), l = d?.get(e);
2592
+ l && (l.updaters.delete(i), l.updaters.size === 0 && (l.effect.dispose(), d?.delete(e), N(e) && vt(e)), d && d.size === 0 && M.delete(n));
2593
+ };
2594
+ nt() ? Et(u) : r = It(n, u);
2595
+ }
2596
+ const ee = Symbol.for("tachui.modifier.instanceId"), zt = "core";
2597
+ let te = 0;
2598
+ function Dt(n) {
2599
+ const e = n[ee];
2600
+ if (typeof e == "number") return e;
2601
+ te += 1;
2602
+ const t = te;
2603
+ return Object.defineProperty(n, ee, {
2604
+ value: t,
2605
+ enumerable: !1,
2606
+ configurable: !1,
2607
+ writable: !1
2608
+ }), t;
2609
+ }
2610
+ class Ht {
2466
2611
  constructor(e) {
2467
2612
  this.properties = e;
2468
2613
  }
@@ -2481,12 +2626,12 @@ class tt {
2481
2626
  applyStyleChange(e, t, i) {
2482
2627
  if (e instanceof HTMLElement) {
2483
2628
  const s = this.toCSSProperty(t);
2484
- if (G(i) || N(i))
2485
- U(() => {
2629
+ if (X(i) || N(i))
2630
+ ce(() => {
2486
2631
  const a = i(), r = String(a);
2487
2632
  if (r.includes("!important")) {
2488
- const h = r.replace(/\s*!important\s*$/, "").trim();
2489
- e.style.setProperty(s, h, "important");
2633
+ const u = r.replace(/\s*!important\s*$/, "").trim();
2634
+ e.style.setProperty(s, u, "important");
2490
2635
  } else
2491
2636
  e.style.setProperty(s, r);
2492
2637
  });
@@ -2532,35 +2677,33 @@ class tt {
2532
2677
  */
2533
2678
  applyStyles(e, t) {
2534
2679
  if (e instanceof HTMLElement || e.style) {
2535
- const i = e.style;
2536
- for (const [s, a] of Object.entries(t))
2537
- if (a !== void 0) {
2538
- const r = this.toCSSProperty(s);
2539
- if (G(a) || N(a))
2540
- U(() => {
2541
- const h = a(), c = this.toCSSValueForProperty(
2542
- r,
2543
- h
2544
- );
2545
- if (i.setProperty)
2546
- if (typeof c == "string" && c.includes("!important")) {
2547
- const l = c.replace(/\s*!important\s*$/, "").trim();
2548
- i.setProperty(r, l, "important");
2549
- } else
2550
- i.setProperty(r, c);
2551
- else
2552
- i[r] = c;
2680
+ const i = e.style, s = (a, r) => {
2681
+ if (i.setProperty)
2682
+ if (typeof r == "string" && r.includes("!important")) {
2683
+ const u = r.replace(/\s*!important\s*$/, "").trim();
2684
+ i.setProperty(a, u, "important");
2685
+ } else
2686
+ i.setProperty(a, r);
2687
+ else
2688
+ i[a] = r;
2689
+ };
2690
+ for (const [a, r] of Object.entries(t))
2691
+ if (r !== void 0) {
2692
+ const u = this.toCSSProperty(a);
2693
+ if (X(r) || N(r)) {
2694
+ const d = r, l = Dt(this);
2695
+ Ot({
2696
+ element: e,
2697
+ accessor: d,
2698
+ updaterId: `${zt}:${l}:${u}`,
2699
+ updater: (p) => {
2700
+ const b = this.toCSSValueForProperty(u, p);
2701
+ s(u, b);
2702
+ }
2553
2703
  });
2554
- else {
2555
- const h = this.toCSSValueForProperty(r, a);
2556
- if (i.setProperty)
2557
- if (typeof h == "string" && h.includes("!important")) {
2558
- const c = h.replace(/\s*!important\s*$/, "").trim();
2559
- i.setProperty(r, c, "important");
2560
- } else
2561
- i.setProperty(r, h);
2562
- else
2563
- i[r] = h;
2704
+ } else {
2705
+ const d = this.toCSSValueForProperty(u, r);
2706
+ s(u, d);
2564
2707
  }
2565
2708
  }
2566
2709
  }
@@ -2590,7 +2733,7 @@ class tt {
2590
2733
  };
2591
2734
  }
2592
2735
  }
2593
- class X extends tt {
2736
+ class he extends Ht {
2594
2737
  constructor() {
2595
2738
  super(...arguments);
2596
2739
  o(this, "type", "viewportLifecycle");
@@ -2616,59 +2759,94 @@ class X extends tt {
2616
2759
  ).observe(t);
2617
2760
  }
2618
2761
  }
2619
- function nt(n) {
2620
- return new X({ onAppear: n });
2762
+ function pe(n) {
2763
+ return new he({ onAppear: n });
2764
+ }
2765
+ function we(n) {
2766
+ return new he({ onDisappear: n });
2621
2767
  }
2622
- function it(n) {
2623
- return new X({ onDisappear: n });
2768
+ const At = {
2769
+ name: "@tachui/viewport",
2770
+ version: Xe,
2771
+ author: "TachUI Team",
2772
+ verified: !0
2773
+ }, ne = {
2774
+ category: "interaction",
2775
+ priority: 110,
2776
+ signature: "(handler: () => void) => Modifier",
2777
+ description: "Triggers handlers when an element appears in or disappears from the viewport."
2778
+ };
2779
+ let ie = !1;
2780
+ function fe(n) {
2781
+ const e = n?.registry, t = n?.plugin ?? At, i = n?.force === !0, s = !!(e || n?.plugin);
2782
+ !s && ie && !i || (j(
2783
+ "onAppear",
2784
+ pe,
2785
+ {
2786
+ ...ne,
2787
+ description: "Executes a callback when the component enters the viewport."
2788
+ },
2789
+ e,
2790
+ t
2791
+ ), j(
2792
+ "onDisappear",
2793
+ we,
2794
+ {
2795
+ ...ne,
2796
+ description: "Executes a callback when the component leaves the viewport."
2797
+ },
2798
+ e,
2799
+ t
2800
+ ), s || (ie = !0));
2624
2801
  }
2625
- const st = {
2802
+ fe();
2803
+ const _t = {
2626
2804
  // Manager
2627
- getManager: u,
2805
+ getManager: h,
2628
2806
  // Environment
2629
- useOpenWindow: P,
2630
- useDismissWindow: x,
2631
- useViewportInfo: _,
2807
+ useOpenWindow: O,
2808
+ useDismissWindow: z,
2809
+ useViewportInfo: $,
2632
2810
  // Components
2633
- Window: y,
2634
- WindowGroup: T,
2635
- App: M,
2811
+ Window: S,
2812
+ WindowGroup: H,
2813
+ App: T,
2636
2814
  // Utilities
2637
- Utils: k,
2638
- Examples: $
2815
+ Utils: I,
2816
+ Examples: oe
2639
2817
  };
2640
- function ot(n) {
2641
- const e = new A(n?.customAdapter);
2642
- return R(e), e;
2818
+ function Ft(n) {
2819
+ const e = new R(n?.customAdapter);
2820
+ return se(e), e;
2643
2821
  }
2644
- const rt = {
2822
+ const Vt = {
2645
2823
  isWindow: (n) => n.type === "window",
2646
2824
  isModal: (n) => n.type === "modal",
2647
2825
  isPortal: (n) => n.type === "portal",
2648
2826
  isSheet: (n) => n.type === "sheet",
2649
2827
  isPopover: (n) => n.type === "popover"
2650
- }, at = {
2828
+ }, Nt = {
2651
2829
  /**
2652
2830
  * Check if running in Electron
2653
2831
  */
2654
- isElectron: () => u().environment.platform === "electron",
2832
+ isElectron: () => h().environment.platform === "electron",
2655
2833
  /**
2656
2834
  * Check if on mobile
2657
2835
  */
2658
- isMobile: () => u().environment.platform === "mobile",
2836
+ isMobile: () => h().environment.platform === "mobile",
2659
2837
  /**
2660
2838
  * Check if multi-window is supported
2661
2839
  */
2662
- supportsMultiWindow: () => u().environment.capabilities.multiWindow,
2840
+ supportsMultiWindow: () => h().environment.capabilities.multiWindow,
2663
2841
  /**
2664
2842
  * Check if native windows are supported
2665
2843
  */
2666
- supportsNativeWindows: () => u().environment.capabilities.nativeWindows,
2844
+ supportsNativeWindows: () => h().environment.capabilities.nativeWindows,
2667
2845
  /**
2668
2846
  * Get optimal window type for current platform
2669
2847
  */
2670
- getOptimalWindowType: (n = !1) => u().getOptimalWindowType({ preferNativeWindow: n })
2671
- }, lt = {
2848
+ getOptimalWindowType: (n = !1) => h().getOptimalWindowType({ preferNativeWindow: n })
2849
+ }, Gt = {
2672
2850
  /**
2673
2851
  * Standard document window
2674
2852
  */
@@ -2735,7 +2913,7 @@ const rt = {
2735
2913
  minimizable: !1,
2736
2914
  maximizable: !1
2737
2915
  })
2738
- }, dt = {
2916
+ }, Lt = {
2739
2917
  DEFAULT_WINDOW_WIDTH: 800,
2740
2918
  DEFAULT_WINDOW_HEIGHT: 600,
2741
2919
  MIN_WINDOW_WIDTH: 300,
@@ -2743,81 +2921,82 @@ const rt = {
2743
2921
  MODAL_Z_INDEX: 1e3,
2744
2922
  PORTAL_Z_INDEX: 999,
2745
2923
  ANIMATION_DURATION: 200
2746
- }, ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2924
+ }, Ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2747
2925
  __proto__: null,
2748
- App: M,
2749
- EnvironmentKeys: xe,
2750
- ExampleScenes: $,
2751
- PlatformUtils: at,
2752
- TachUIViewportManager: A,
2753
- Viewport: st,
2754
- ViewportConstants: dt,
2755
- ViewportEnvironmentProvider: B,
2756
- ViewportTypeGuards: rt,
2757
- WebViewportAdapter: D,
2758
- Window: y,
2759
- WindowConfigs: lt,
2760
- WindowGroup: T,
2761
- WindowUtils: k,
2762
- checkFeatureSupport: ge,
2763
- createCapabilityChecker: H,
2764
- createWindowAwareComponent: Pe,
2765
- detectViewportEnvironment: O,
2766
- disposeViewportManager: Ee,
2767
- getBrowserInfo: fe,
2768
- getEnvironmentValue: Te,
2769
- getOSInfo: me,
2770
- getViewportManager: u,
2771
- initializeViewportSystem: ot,
2772
- onAppear: nt,
2773
- onDisappear: it,
2774
- setViewportManager: R,
2775
- useCurrentWindow: Ce,
2776
- useDismissWindow: x,
2777
- useEnvironmentDismissWindow: x,
2778
- useEnvironmentOpenWindow: P,
2779
- useOpenWindow: P,
2780
- useViewportEnvironment: v,
2781
- useViewportInfo: _,
2782
- useViewportManager: Me,
2783
- withViewportEnvironment: ke
2926
+ App: T,
2927
+ EnvironmentKeys: qe,
2928
+ ExampleScenes: oe,
2929
+ PlatformUtils: Nt,
2930
+ TachUIViewportManager: R,
2931
+ Viewport: _t,
2932
+ ViewportConstants: Lt,
2933
+ ViewportEnvironmentProvider: ae,
2934
+ ViewportTypeGuards: Vt,
2935
+ WebViewportAdapter: V,
2936
+ Window: S,
2937
+ WindowConfigs: Gt,
2938
+ WindowGroup: H,
2939
+ WindowUtils: I,
2940
+ checkFeatureSupport: _e,
2941
+ createCapabilityChecker: F,
2942
+ createWindowAwareComponent: je,
2943
+ detectViewportEnvironment: U,
2944
+ disposeViewportManager: Ue,
2945
+ getBrowserInfo: He,
2946
+ getEnvironmentValue: Qe,
2947
+ getOSInfo: Ae,
2948
+ getViewportManager: h,
2949
+ initializeViewportSystem: Ft,
2950
+ onAppear: pe,
2951
+ onDisappear: we,
2952
+ registerViewportModifiers: fe,
2953
+ setViewportManager: se,
2954
+ useCurrentWindow: Re,
2955
+ useDismissWindow: z,
2956
+ useEnvironmentDismissWindow: z,
2957
+ useEnvironmentOpenWindow: O,
2958
+ useOpenWindow: O,
2959
+ useViewportEnvironment: C,
2960
+ useViewportInfo: $,
2961
+ useViewportManager: $e,
2962
+ withViewportEnvironment: Be
2784
2963
  }, Symbol.toStringTag, { value: "Module" }));
2785
2964
  export {
2786
- M as App,
2787
- xe as EnvironmentKeys,
2788
- $ as ExampleScenes,
2789
- at as PlatformUtils,
2790
- A as TachUIViewportManager,
2791
- st as Viewport,
2792
- dt as ViewportConstants,
2793
- B as ViewportEnvironmentProvider,
2794
- rt as ViewportTypeGuards,
2795
- D as WebViewportAdapter,
2796
- y as Window,
2797
- lt as WindowConfigs,
2798
- T as WindowGroup,
2799
- k as WindowUtils,
2800
- ge as checkFeatureSupport,
2801
- H as createCapabilityChecker,
2802
- Pe as createWindowAwareComponent,
2803
- O as detectViewportEnvironment,
2804
- Ee as disposeViewportManager,
2805
- fe as getBrowserInfo,
2806
- Te as getEnvironmentValue,
2807
- me as getOSInfo,
2808
- u as getViewportManager,
2809
- ot as initializeViewportSystem,
2810
- nt as onAppear,
2811
- it as onDisappear,
2812
- R as setViewportManager,
2813
- Ce as useCurrentWindow,
2814
- x as useDismissWindow,
2815
- x as useEnvironmentDismissWindow,
2816
- P as useEnvironmentOpenWindow,
2817
- P as useOpenWindow,
2818
- v as useViewportEnvironment,
2819
- _ as useViewportInfo,
2820
- Me as useViewportManager,
2821
- ke as withViewportEnvironment
2965
+ T as App,
2966
+ qe as EnvironmentKeys,
2967
+ oe as ExampleScenes,
2968
+ Nt as PlatformUtils,
2969
+ R as TachUIViewportManager,
2970
+ _t as Viewport,
2971
+ Lt as ViewportConstants,
2972
+ ae as ViewportEnvironmentProvider,
2973
+ Vt as ViewportTypeGuards,
2974
+ V as WebViewportAdapter,
2975
+ S as Window,
2976
+ Gt as WindowConfigs,
2977
+ H as WindowGroup,
2978
+ I as WindowUtils,
2979
+ _e as checkFeatureSupport,
2980
+ F as createCapabilityChecker,
2981
+ je as createWindowAwareComponent,
2982
+ U as detectViewportEnvironment,
2983
+ Ue as disposeViewportManager,
2984
+ He as getBrowserInfo,
2985
+ Qe as getEnvironmentValue,
2986
+ Ae as getOSInfo,
2987
+ h as getViewportManager,
2988
+ Ft as initializeViewportSystem,
2989
+ pe as onAppear,
2990
+ we as onDisappear,
2991
+ fe as registerViewportModifiers,
2992
+ se as setViewportManager,
2993
+ Re as useCurrentWindow,
2994
+ z as useDismissWindow,
2995
+ z as useEnvironmentDismissWindow,
2996
+ O as useEnvironmentOpenWindow,
2997
+ O as useOpenWindow,
2998
+ C as useViewportEnvironment,
2999
+ $ as useViewportInfo,
3000
+ $e as useViewportManager,
3001
+ Be as withViewportEnvironment
2822
3002
  };
2823
- //# sourceMappingURL=index.js.map