@tachui/core 0.8.1-alpha → 0.8.5-alpha

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 (161) hide show
  1. package/README.md +40 -2
  2. package/dist/assets/AssetCollection.d.ts.map +1 -1
  3. package/dist/assets/ColorAsset.d.ts.map +1 -1
  4. package/dist/assets/index.d.ts +1 -0
  5. package/dist/assets/index.d.ts.map +1 -1
  6. package/dist/assets/index.js +486 -0
  7. package/dist/assets/types.d.ts +8 -68
  8. package/dist/assets/types.d.ts.map +1 -1
  9. package/dist/binding-CYpEQquE.js +308 -0
  10. package/dist/build-plugins/index.d.ts +3 -0
  11. package/dist/build-plugins/index.d.ts.map +1 -0
  12. package/dist/build-plugins/modifier-types.d.ts +12 -0
  13. package/dist/build-plugins/modifier-types.d.ts.map +1 -0
  14. package/dist/build-tools/typegen-runner.d.ts +29 -0
  15. package/dist/build-tools/typegen-runner.d.ts.map +1 -0
  16. package/dist/bundles/minimal.d.ts +2 -0
  17. package/dist/bundles/minimal.d.ts.map +1 -1
  18. package/dist/common.js +427 -394
  19. package/dist/{component-XAzF1xqs.js → component-CECyfUOE.js} +80 -68
  20. package/dist/{component-base-x2XmHFjy.js → component-base-CJ__jTlr.js} +9 -7
  21. package/dist/component-context-B6qX_Qsg.js +176 -0
  22. package/dist/components/factory.d.ts +24 -0
  23. package/dist/components/factory.d.ts.map +1 -0
  24. package/dist/components/index.d.ts +3 -2
  25. package/dist/components/index.d.ts.map +1 -1
  26. package/dist/components/index.js +8 -6
  27. package/dist/components/wrapper.d.ts +70 -30
  28. package/dist/components/wrapper.d.ts.map +1 -1
  29. package/dist/concatenated-component-_tF1eMvy.js +2288 -0
  30. package/dist/concatenation/concatenated-component.d.ts +16 -2
  31. package/dist/concatenation/concatenated-component.d.ts.map +1 -1
  32. package/dist/concatenation/text-optimizer.d.ts.map +1 -1
  33. package/dist/config.d.ts +7 -0
  34. package/dist/config.d.ts.map +1 -0
  35. package/dist/constants/layout.d.ts +2 -9
  36. package/dist/constants/layout.d.ts.map +1 -1
  37. package/dist/css-classes/index.js +15 -173
  38. package/dist/{effect-B9Knft0b.js → effect-DGmdACI2.js} +3 -3
  39. package/dist/enhanced-renderer-Bwqsh8Ku.js +172 -0
  40. package/dist/essential.js +427 -394
  41. package/dist/{index-DIvMCJQO.js → factories-Co2Lv2kJ.js} +13 -13
  42. package/dist/factory-D7jAY5Kn.js +485 -0
  43. package/dist/gradients/css-generator.js +99 -0
  44. package/dist/gradients/index.js +56 -0
  45. package/dist/gradients/reactive.d.ts.map +1 -1
  46. package/dist/gradients/types.d.ts +3 -91
  47. package/dist/gradients/types.d.ts.map +1 -1
  48. package/dist/hooks-DeLasj54.js +446 -0
  49. package/dist/index-JQ1sW1SK.js +2049 -0
  50. package/dist/index-X8MVY78C.js +618 -0
  51. package/dist/index.d.ts +8 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +427 -394
  54. package/dist/minimal-prod.js +94 -93
  55. package/dist/minimal.js +114 -108
  56. package/dist/modifiers/alignment.d.ts +5 -0
  57. package/dist/modifiers/alignment.d.ts.map +1 -0
  58. package/dist/modifiers/base.d.ts +6 -7
  59. package/dist/modifiers/base.d.ts.map +1 -1
  60. package/dist/modifiers/base.js +24 -16
  61. package/dist/modifiers/builder.d.ts +28 -165
  62. package/dist/modifiers/builder.d.ts.map +1 -1
  63. package/dist/modifiers/builder.js +7 -7
  64. package/dist/modifiers/core.d.ts +0 -1
  65. package/dist/modifiers/core.d.ts.map +1 -1
  66. package/dist/modifiers/corner-radius.d.ts +8 -0
  67. package/dist/modifiers/corner-radius.d.ts.map +1 -0
  68. package/dist/modifiers/index.d.ts +9 -6
  69. package/dist/modifiers/index.d.ts.map +1 -1
  70. package/dist/modifiers/index.js +36 -30
  71. package/dist/modifiers/layout-priority.d.ts +8 -0
  72. package/dist/modifiers/layout-priority.d.ts.map +1 -0
  73. package/dist/modifiers/opacity.d.ts +8 -0
  74. package/dist/modifiers/opacity.d.ts.map +1 -0
  75. package/dist/modifiers/presets.d.ts.map +1 -1
  76. package/dist/modifiers/proxy.d.ts +4 -0
  77. package/dist/modifiers/proxy.d.ts.map +1 -0
  78. package/dist/modifiers/registration-utils.d.ts +7 -0
  79. package/dist/modifiers/registration-utils.d.ts.map +1 -0
  80. package/dist/modifiers/registry.d.ts +18 -9
  81. package/dist/modifiers/registry.d.ts.map +1 -1
  82. package/dist/modifiers/registry.js +2 -2
  83. package/dist/modifiers/type-generator.d.ts +82 -0
  84. package/dist/modifiers/type-generator.d.ts.map +1 -0
  85. package/dist/modifiers/types.d.ts +2 -479
  86. package/dist/modifiers/types.d.ts.map +1 -1
  87. package/dist/modifiers/types.js +1 -4
  88. package/dist/{observed-object-Cos-FtjP.js → observed-object-DepiqSgg.js} +3 -3
  89. package/dist/optimization-CbKNA9w4.js +21 -0
  90. package/dist/plugins/index.js +28 -8
  91. package/dist/plugins/simplified-lazy-loader.d.ts.map +1 -1
  92. package/dist/presets-B9x94uRn.js +381 -0
  93. package/dist/proxy-Cqmbiyx0.js +175 -0
  94. package/dist/reactive/cleanup.d.ts.map +1 -1
  95. package/dist/reactive/computed.d.ts +1 -1
  96. package/dist/reactive/computed.d.ts.map +1 -1
  97. package/dist/reactive/context.d.ts +4 -3
  98. package/dist/reactive/context.d.ts.map +1 -1
  99. package/dist/reactive/index.d.ts +1 -0
  100. package/dist/reactive/index.d.ts.map +1 -1
  101. package/dist/reactive/index.js +84 -490
  102. package/dist/reactive/signal-list.d.ts +100 -0
  103. package/dist/reactive/signal-list.d.ts.map +1 -0
  104. package/dist/reactive/signal.d.ts.map +1 -1
  105. package/dist/reactive/types.d.ts +2 -89
  106. package/dist/reactive/types.d.ts.map +1 -1
  107. package/dist/reactive/types.js +1 -4
  108. package/dist/registration-utils-CNsN4eoU.js +27 -0
  109. package/dist/runtime/component.d.ts.map +1 -1
  110. package/dist/runtime/concatenation-aria.d.ts.map +1 -1
  111. package/dist/runtime/concatenation-aria.js +18 -13
  112. package/dist/runtime/concatenation-full.d.ts.map +1 -1
  113. package/dist/runtime/concatenation-full.js +42 -34
  114. package/dist/runtime/concatenation-minimal.d.ts.map +1 -1
  115. package/dist/runtime/concatenation-minimal.js +13 -8
  116. package/dist/runtime/context.d.ts.map +1 -1
  117. package/dist/runtime/dom-bridge.d.ts +1 -1
  118. package/dist/runtime/dom-bridge.d.ts.map +1 -1
  119. package/dist/runtime/dom-bridge.js +239 -12
  120. package/dist/runtime/event-delegation.d.ts +59 -0
  121. package/dist/runtime/event-delegation.d.ts.map +1 -0
  122. package/dist/runtime/index.d.ts +3 -1
  123. package/dist/runtime/index.d.ts.map +1 -1
  124. package/dist/runtime/index.js +96 -0
  125. package/dist/runtime/layout-scheduler.d.ts +89 -0
  126. package/dist/runtime/layout-scheduler.d.ts.map +1 -0
  127. package/dist/runtime/props.d.ts.map +1 -1
  128. package/dist/runtime/renderer.d.ts +54 -2
  129. package/dist/runtime/renderer.d.ts.map +1 -1
  130. package/dist/runtime/renderer.js +11 -7
  131. package/dist/runtime/semantic-role-manager.d.ts.map +1 -1
  132. package/dist/runtime/types.d.ts +2 -226
  133. package/dist/runtime/types.d.ts.map +1 -1
  134. package/dist/runtime/types.js +1 -1
  135. package/dist/scheduler-DI_8ykMk.js +169 -0
  136. package/dist/signal-list-BdpxSodS.js +525 -0
  137. package/dist/state/index.js +319 -0
  138. package/dist/theme-BFaKUcjZ.js +677 -0
  139. package/dist/utils/clone-helpers.d.ts +11 -0
  140. package/dist/utils/clone-helpers.d.ts.map +1 -0
  141. package/dist/validation/index.js +28 -26
  142. package/dist/version.d.ts +19 -0
  143. package/dist/version.d.ts.map +1 -0
  144. package/dist/version.js +6 -0
  145. package/package.json +51 -11
  146. package/dist/concatenated-component-ByPl3_FF.js +0 -2933
  147. package/dist/dom-bridge-CAa1N2zX.js +0 -406
  148. package/dist/index-DEBd8cq7.js +0 -1144
  149. package/dist/index-vdsiw6gQ.js +0 -777
  150. package/dist/modifiers/as-html-validator.d.ts +0 -20
  151. package/dist/modifiers/as-html-validator.d.ts.map +0 -1
  152. package/dist/modifiers/as-html.d.ts +0 -65
  153. package/dist/modifiers/as-html.d.ts.map +0 -1
  154. package/dist/modifiers/background.d.ts +0 -51
  155. package/dist/modifiers/background.d.ts.map +0 -1
  156. package/dist/modifiers/basic-sanitizer.d.ts +0 -54
  157. package/dist/modifiers/basic-sanitizer.d.ts.map +0 -1
  158. package/dist/modifiers/css.d.ts +0 -86
  159. package/dist/modifiers/css.d.ts.map +0 -1
  160. package/dist/production-minimal-BY_gMc-l.js +0 -2532
  161. package/dist/scheduler-BKeqwrYE.js +0 -814
@@ -1,814 +0,0 @@
1
- import { ComputationState as n } from "./reactive/types.js";
2
- var P = Object.defineProperty, T = (t, e, s) => e in t ? P(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, u = (t, e, s) => T(t, typeof e != "symbol" ? e + "" : e, s);
3
- let O = 0, D = 0, h = null, a = null, d = !1;
4
- function I() {
5
- return h;
6
- }
7
- function N() {
8
- return a;
9
- }
10
- function Q() {
11
- return d;
12
- }
13
- class H {
14
- constructor(e = null) {
15
- u(this, "id"), u(this, "parent"), u(this, "context", /* @__PURE__ */ new Map()), u(this, "cleanups", []), u(this, "sources", /* @__PURE__ */ new Set()), u(this, "disposed", !1), this.id = ++D, this.parent = e;
16
- }
17
- dispose() {
18
- if (!this.disposed) {
19
- this.disposed = !0;
20
- for (const e of this.sources)
21
- e.dispose();
22
- this.sources.clear();
23
- for (const e of this.cleanups)
24
- try {
25
- e();
26
- } catch (s) {
27
- console.error("Error in cleanup function:", s);
28
- }
29
- this.cleanups.length = 0, this.parent && !this.parent.disposed && this.parent.sources.delete(this);
30
- }
31
- }
32
- }
33
- class V {
34
- constructor(e, s = null) {
35
- u(this, "id"), u(this, "owner"), u(this, "fn"), u(this, "sources", /* @__PURE__ */ new Set()), u(this, "observers", /* @__PURE__ */ new Set()), u(this, "state", n.Dirty), u(this, "value"), this.id = ++O, this.fn = e, this.owner = s, s && !s.disposed && s.sources.add(this);
36
- }
37
- execute() {
38
- if (this.state === n.Disposed)
39
- return this.value;
40
- for (const s of this.sources)
41
- s && typeof s == "object" && "removeObserver" in s && s.removeObserver(this);
42
- this.sources.clear();
43
- const e = h;
44
- h = this;
45
- try {
46
- return this.state = n.Clean, this.value = this.fn(), this.value;
47
- } catch (s) {
48
- throw this.state = n.Disposed, (typeof process > "u" || process.env.NODE_ENV !== "test") && console.error("Error in computation:", s), s;
49
- } finally {
50
- h = e;
51
- }
52
- }
53
- dispose() {
54
- if (this.state !== n.Disposed) {
55
- this.state = n.Disposed;
56
- for (const e of this.sources)
57
- e && typeof e == "object" && "removeObserver" in e && e.removeObserver(this);
58
- this.sources.clear();
59
- for (const e of this.observers)
60
- e.sources.delete(this);
61
- this.observers.clear(), this.owner && !this.owner.disposed && this.owner.sources.delete(this);
62
- }
63
- }
64
- }
65
- function ce(t) {
66
- const e = new H(a), s = a;
67
- a = e;
68
- try {
69
- return t(() => e.dispose());
70
- } finally {
71
- a = s;
72
- }
73
- }
74
- function he(t, e) {
75
- const s = a;
76
- a = t;
77
- try {
78
- return e();
79
- } finally {
80
- a = s;
81
- }
82
- }
83
- function fe() {
84
- return a;
85
- }
86
- let C = null;
87
- function B(t) {
88
- C = t;
89
- }
90
- function de(t) {
91
- if (d)
92
- return t();
93
- const e = d;
94
- d = !0;
95
- try {
96
- const s = t();
97
- return !e && C && C(), s;
98
- } finally {
99
- d = e;
100
- }
101
- }
102
- function pe(t) {
103
- const e = h;
104
- h = null;
105
- try {
106
- return t();
107
- } finally {
108
- h = e;
109
- }
110
- }
111
- function me(t, e) {
112
- const s = new V(t, e || a);
113
- return s.execute(), s;
114
- }
115
- function ye() {
116
- return {
117
- computation: h,
118
- batch: d
119
- };
120
- }
121
- const ge = {
122
- getCurrentComputation: () => h,
123
- getCurrentOwner: () => a,
124
- getComputationCount: () => O,
125
- getOwnerCount: () => D,
126
- isBatching: () => d
127
- };
128
- var U = Object.defineProperty, W = (t, e, s) => e in t ? U(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, q = (t, e, s) => W(t, typeof e != "symbol" ? e + "" : e, s);
129
- let L = 0;
130
- class G {
131
- constructor(e) {
132
- q(this, "id"), q(this, "observers", /* @__PURE__ */ new Set()), q(this, "_value"), this.id = ++L, this._value = e;
133
- }
134
- /**
135
- * Get the current value and track dependency
136
- */
137
- getValue() {
138
- const e = I();
139
- return e && e.state !== n.Disposed && (this.observers.add(e), e.sources.add(this)), this._value;
140
- }
141
- /**
142
- * Get the current value without tracking dependency
143
- */
144
- peek() {
145
- return this._value;
146
- }
147
- /**
148
- * Set a new value and notify observers
149
- */
150
- set(e) {
151
- const s = typeof e == "function" ? e(this._value) : e;
152
- return s !== this._value && (this._value = s, this.notify()), s;
153
- }
154
- /**
155
- * Notify all observers that this signal has changed
156
- */
157
- notify() {
158
- for (const e of this.observers)
159
- e.state !== n.Disposed && (e.state = n.Dirty, J(e));
160
- }
161
- /**
162
- * Remove an observer (cleanup)
163
- */
164
- removeObserver(e) {
165
- this.observers.delete(e);
166
- }
167
- /**
168
- * Get debug information about this signal
169
- */
170
- [Symbol.for("tachui.debug")]() {
171
- return {
172
- id: this.id,
173
- value: this._value,
174
- observerCount: this.observers.size,
175
- type: "Signal"
176
- };
177
- }
178
- }
179
- const b = /* @__PURE__ */ new Set();
180
- let _ = !1;
181
- function J(t) {
182
- b.add(t), !_ && !Q() && queueMicrotask(M);
183
- }
184
- function M() {
185
- if (!_) {
186
- _ = !0;
187
- try {
188
- for (; b.size > 0; ) {
189
- const t = Array.from(b).sort((e, s) => e.id - s.id);
190
- b.clear();
191
- for (const e of t)
192
- e.state === n.Dirty && e.execute();
193
- }
194
- } finally {
195
- _ = !1;
196
- }
197
- }
198
- }
199
- function K(t) {
200
- const e = new G(t), s = e.getValue.bind(e);
201
- s.peek = e.peek.bind(e);
202
- const r = e.set.bind(e);
203
- return Object.defineProperty(s, Symbol.for("tachui.signal"), {
204
- value: e,
205
- enumerable: !1
206
- }), [s, r];
207
- }
208
- function ve(t) {
209
- return typeof t == "function" && Symbol.for("tachui.signal") in t;
210
- }
211
- function be(t) {
212
- return t[Symbol.for("tachui.signal")] || null;
213
- }
214
- B(M);
215
- const w = (t, e) => t === e, E = (t, e) => {
216
- if (t === e) return !0;
217
- if (t == null || e == null || typeof t != typeof e) return !1;
218
- if (typeof t == "object") {
219
- if (Array.isArray(t) !== Array.isArray(e)) return !1;
220
- if (Array.isArray(t)) {
221
- const l = t, F = e;
222
- return l.length !== F.length ? !1 : l.every((A, j) => E(A, F[j]));
223
- }
224
- const s = t, r = e, i = Object.keys(s), o = Object.keys(r);
225
- return i.length !== o.length ? !1 : i.every((l) => E(s[l], r[l]));
226
- }
227
- return !1;
228
- }, _e = (t, e) => {
229
- if (t === e) return !0;
230
- if (typeof t != "object" || typeof e != "object" || t == null || e == null) return !1;
231
- const s = t, r = e, i = Object.keys(s), o = Object.keys(r);
232
- return i.length !== o.length ? !1 : i.every((l) => s[l] === r[l]);
233
- }, we = (t, e) => {
234
- if (t === e) return !0;
235
- if (t instanceof Date && e instanceof Date)
236
- return t.getTime() === e.getTime();
237
- if (t instanceof RegExp && e instanceof RegExp)
238
- return t.toString() === e.toString();
239
- if (t instanceof Set && e instanceof Set) {
240
- if (t.size !== e.size) return !1;
241
- for (const s of t)
242
- if (!e.has(s)) return !1;
243
- return !0;
244
- }
245
- if (t instanceof Map && e instanceof Map) {
246
- if (t.size !== e.size) return !1;
247
- for (const [s, r] of t)
248
- if (!e.has(s) || e.get(s) !== r) return !1;
249
- return !0;
250
- }
251
- return E(t, e);
252
- }, Se = (t, e) => {
253
- if (t === e) return !0;
254
- try {
255
- return JSON.stringify(t) === JSON.stringify(e);
256
- } catch {
257
- return t === e;
258
- }
259
- }, qe = (t, e = w) => (s, r) => e(t(s), t(r)), Ce = (t = w) => (e, s) => e === s ? !0 : e.length !== s.length ? !1 : e.every((r, i) => t(r, s[i])), Ee = (t = w) => (e, s) => {
260
- if (e === s) return !0;
261
- if (e == null || s == null) return !1;
262
- const r = Object.keys(e), i = Object.keys(s);
263
- return r.length !== i.length ? !1 : r.every((o) => t(e[o], s[o]));
264
- }, Fe = (...t) => (e, s) => t.every((r) => r(e, s)), Oe = (t, e) => (s, r) => {
265
- const i = t(s, r);
266
- return process.env.NODE_ENV === "development" && console.log(`[${e || "equals"}]`, { a: s, b: r, equal: i }), i;
267
- };
268
- var X = Object.defineProperty, Y = (t, e, s) => e in t ? X(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, c = (t, e, s) => Y(t, typeof e != "symbol" ? e + "" : e, s), g = /* @__PURE__ */ ((t) => (t[t.Immediate = 0] = "Immediate", t[t.High = 1] = "High", t[t.Normal = 2] = "Normal", t[t.Low = 3] = "Low", t[t.Idle = 4] = "Idle", t))(g || {});
269
- class Z extends Error {
270
- constructor(e, s, r) {
271
- super(e), this.cause = s, this.node = r, this.name = "ReactiveError";
272
- }
273
- }
274
- const k = class m {
275
- constructor() {
276
- c(this, "updateQueues", /* @__PURE__ */ new Map()), c(this, "isFlushPending", !1), c(this, "isDestroyed", !1), c(this, "errorHandlers", /* @__PURE__ */ new Set()), c(this, "maxRetries", 3), c(this, "totalUpdateCycles", 0), c(this, "totalUpdateTime", 0), c(this, "errorCount", 0), c(this, "nodeRegistry", /* @__PURE__ */ new WeakSet());
277
- for (const e of Object.values(g))
278
- typeof e == "number" && this.updateQueues.set(e, /* @__PURE__ */ new Set());
279
- }
280
- static getInstance() {
281
- return m.instance || (m.instance = new m()), m.instance;
282
- }
283
- /**
284
- * Schedule reactive node for update
285
- */
286
- schedule(e) {
287
- if (this.isDestroyed) return;
288
- this.nodeRegistry.add(e), this.getQueue(e.priority).add(e), this.isFlushPending || (this.isFlushPending = !0, this.scheduleFlush(e.priority));
289
- }
290
- /**
291
- * Process all queued updates by priority
292
- */
293
- async flush() {
294
- if (this.isDestroyed) return;
295
- this.isFlushPending = !1;
296
- const e = performance.now();
297
- try {
298
- for (const s of [
299
- 0,
300
- 1,
301
- 2,
302
- 3,
303
- 4
304
- /* Idle */
305
- ]) {
306
- const r = this.updateQueues.get(s);
307
- if (!r || r.size === 0) continue;
308
- const i = Array.from(r);
309
- r.clear();
310
- for (const o of i)
311
- try {
312
- await this.updateNodeWithRetry(o);
313
- } catch (l) {
314
- this.handleReactiveError(
315
- new Z(`Failed to update ${o.type} node ${o.id}`, l, o)
316
- );
317
- }
318
- if (this.hasHigherPriorityWork(s))
319
- return this.flush();
320
- }
321
- this.totalUpdateCycles++;
322
- } finally {
323
- const s = performance.now();
324
- this.totalUpdateTime += s - e;
325
- }
326
- }
327
- /**
328
- * Update node with retry logic
329
- */
330
- async updateNodeWithRetry(e, s = 1) {
331
- try {
332
- e.notify();
333
- } catch (r) {
334
- if (s < this.maxRetries)
335
- return console.warn(`Reactive update failed, retrying (${s}/${this.maxRetries})`), await new Promise((i) => setTimeout(i, s * 10)), this.updateNodeWithRetry(e, s + 1);
336
- throw r;
337
- }
338
- }
339
- /**
340
- * Schedule flush based on priority
341
- */
342
- scheduleFlush(e) {
343
- switch (e) {
344
- case 0:
345
- this.flush();
346
- break;
347
- case 1:
348
- queueMicrotask(() => this.flush());
349
- break;
350
- case 2:
351
- typeof requestAnimationFrame < "u" ? requestAnimationFrame(() => this.flush()) : queueMicrotask(() => this.flush());
352
- break;
353
- case 3:
354
- case 4:
355
- typeof requestIdleCallback < "u" ? requestIdleCallback(() => this.flush(), { timeout: 1e3 }) : setTimeout(() => this.flush(), 50);
356
- break;
357
- }
358
- }
359
- /**
360
- * Check if there's higher priority work waiting
361
- */
362
- hasHigherPriorityWork(e) {
363
- for (let s = 0; s < e; s++) {
364
- const r = this.updateQueues.get(s);
365
- if (r && r.size > 0)
366
- return !0;
367
- }
368
- return !1;
369
- }
370
- /**
371
- * Get queue for priority level
372
- */
373
- getQueue(e) {
374
- const s = this.updateQueues.get(e);
375
- if (!s)
376
- throw new Error(`Invalid priority level: ${e}`);
377
- return s;
378
- }
379
- /**
380
- * Register error handler
381
- */
382
- onError(e) {
383
- return this.errorHandlers.add(e), () => this.errorHandlers.delete(e);
384
- }
385
- /**
386
- * Handle reactive errors with recovery
387
- */
388
- handleReactiveError(e) {
389
- this.errorCount++;
390
- let s = !1;
391
- for (const r of this.errorHandlers)
392
- try {
393
- r(e), s = !0;
394
- } catch (i) {
395
- console.error("Error handler threw error:", i);
396
- }
397
- if (!s && (console.error("Unhandled reactive error:", e), process.env.NODE_ENV === "development"))
398
- throw e;
399
- }
400
- /**
401
- * Get performance metrics
402
- */
403
- getPerformanceMetrics() {
404
- let e = 0;
405
- for (const s of this.updateQueues.values())
406
- e += s.size;
407
- return {
408
- totalNodes: e,
409
- updateCycles: this.totalUpdateCycles,
410
- averageUpdateTime: this.totalUpdateCycles > 0 ? this.totalUpdateTime / this.totalUpdateCycles : 0,
411
- memoryUsage: this.estimateMemoryUsage(),
412
- errorCount: this.errorCount
413
- };
414
- }
415
- /**
416
- * Estimate memory usage (rough approximation)
417
- */
418
- estimateMemoryUsage() {
419
- let e = 0;
420
- for (const s of this.updateQueues.values())
421
- e += s.size * 50;
422
- return e += this.errorHandlers.size * 100, e;
423
- }
424
- /**
425
- * Check if node is scheduled
426
- */
427
- hasNode(e) {
428
- for (const s of this.updateQueues.values())
429
- if (s.has(e))
430
- return !0;
431
- return !1;
432
- }
433
- /**
434
- * Flush all pending updates synchronously
435
- */
436
- flushSync() {
437
- this.isFlushPending && (this.isFlushPending = !1, this.flush());
438
- }
439
- /**
440
- * Clear all pending updates
441
- */
442
- clearPending() {
443
- for (const e of this.updateQueues.values())
444
- e.clear();
445
- this.isFlushPending = !1;
446
- }
447
- /**
448
- * Cleanup all reactive nodes and destroy scheduler
449
- */
450
- destroy() {
451
- this.isDestroyed = !0;
452
- for (const e of this.updateQueues.values()) {
453
- for (const s of e)
454
- try {
455
- s.cleanup();
456
- } catch (r) {
457
- console.error("Error cleaning up reactive node:", r);
458
- }
459
- e.clear();
460
- }
461
- this.updateQueues.clear(), this.errorHandlers.clear(), m.instance = null;
462
- }
463
- /**
464
- * Get debug information
465
- */
466
- getDebugInfo() {
467
- const e = {};
468
- for (const [s, r] of this.updateQueues)
469
- e[g[s]] = r.size;
470
- return {
471
- isFlushPending: this.isFlushPending,
472
- isDestroyed: this.isDestroyed,
473
- queueSizes: e,
474
- errorHandlerCount: this.errorHandlers.size,
475
- performance: this.getPerformanceMetrics()
476
- };
477
- }
478
- };
479
- c(k, "instance", null);
480
- let De = k;
481
- var ee = Object.defineProperty, te = (t, e, s) => e in t ? ee(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, p = (t, e, s) => te(t, typeof e != "symbol" ? e + "" : e, s);
482
- class se extends V {
483
- constructor(e, s = {}, r = N()) {
484
- super(e, r), p(this, "type", "computed"), p(this, "priority"), p(this, "_hasValue", !1), p(this, "_error", null), p(this, "equalsFn"), p(this, "options"), this.priority = s.priority ?? g.Normal, this.equalsFn = s.equals ?? w, this.options = s;
485
- }
486
- /**
487
- * Get the computed value, tracking dependency and lazily computing
488
- */
489
- getValue() {
490
- const e = I();
491
- return e && e.state !== n.Disposed && (this.observers.add(e), e.sources.add(this)), (this.state === n.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
492
- }
493
- /**
494
- * Get the current value without tracking dependency
495
- */
496
- peek() {
497
- return (this.state === n.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
498
- }
499
- /**
500
- * Remove an observer (cleanup)
501
- */
502
- removeObserver(e) {
503
- this.observers.delete(e);
504
- }
505
- /**
506
- * Execute the computation and notify observers
507
- */
508
- execute() {
509
- const e = this._hasValue ? this.value : void 0, s = super.execute();
510
- if (!this._hasValue || !this.equalsFn(e, s))
511
- for (const r of this.observers)
512
- r.state !== n.Disposed && (r.state = n.Dirty, "execute" in r && typeof r.execute == "function" && queueMicrotask(() => {
513
- r.state === n.Dirty && r.execute();
514
- }));
515
- return s;
516
- }
517
- /**
518
- * Notify method for ReactiveNode compatibility
519
- */
520
- notify() {
521
- this.execute();
522
- }
523
- /**
524
- * Complete cleanup for memory management
525
- */
526
- cleanup() {
527
- for (const e of this.sources)
528
- "removeObserver" in e && e.removeObserver(this);
529
- this.sources.clear();
530
- for (const e of this.observers)
531
- e.sources.delete(this);
532
- this.observers.clear(), this._hasValue = !1, this._error = null, this.state = n.Disposed;
533
- }
534
- /**
535
- * Dispose the computed value
536
- */
537
- dispose() {
538
- this.cleanup(), super.dispose();
539
- }
540
- /**
541
- * Debug information
542
- */
543
- [Symbol.for("tachui.debug")]() {
544
- return {
545
- id: this.id,
546
- type: this.type,
547
- value: this._hasValue ? this.value : void 0,
548
- hasValue: this._hasValue,
549
- error: this._error?.message,
550
- state: this.state,
551
- sourceCount: this.sources.size,
552
- observerCount: this.observers.size,
553
- priority: g[this.priority],
554
- debugName: this.options.debugName,
555
- equalsFn: this.equalsFn.name || "anonymous"
556
- };
557
- }
558
- toString() {
559
- return `Computed(${this.options.debugName || this.id}): ${this._hasValue ? this.value : "no value"}`;
560
- }
561
- }
562
- function v(t, e) {
563
- const s = new se(t, e), r = s.getValue.bind(s);
564
- return r.peek = s.peek.bind(s), Object.defineProperty(r, Symbol.for("tachui.computed"), {
565
- value: s,
566
- enumerable: !1
567
- }), r;
568
- }
569
- function Ie(t, e) {
570
- return v(t, e);
571
- }
572
- function Ne(t) {
573
- return typeof t == "function" && Symbol.for("tachui.computed") in t;
574
- }
575
- function Ve(t) {
576
- return t[Symbol.for("tachui.computed")] || null;
577
- }
578
- function Me(t, e) {
579
- return v(e ? () => {
580
- for (const r of e)
581
- r();
582
- return t();
583
- } : t);
584
- }
585
- function ke(t, e) {
586
- let s, r = !1;
587
- return v(() => (e() && (s = t(), r = !0), r || (s = t(), r = !0), s));
588
- }
589
- const [x, re] = K("light");
590
- function xe() {
591
- const t = x();
592
- return t === "system" ? $() : t;
593
- }
594
- function $e(t) {
595
- re(t);
596
- }
597
- const ie = v(() => {
598
- const t = x();
599
- return t === "system" ? $() : t;
600
- });
601
- function ze() {
602
- return ie;
603
- }
604
- function $() {
605
- return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
606
- }
607
- function S(t) {
608
- const e = N();
609
- e && !e.disposed ? e.cleanups.push(t) : __DEV__ && console.warn("onCleanup called outside of reactive context");
610
- }
611
- function Re(t) {
612
- "dispose" in t && typeof t.dispose == "function" && t.dispose();
613
- }
614
- function Ae(t) {
615
- const [e, s] = t();
616
- return S(s), e;
617
- }
618
- function je() {
619
- const t = [];
620
- let e = !1;
621
- return {
622
- add(s) {
623
- if (e) {
624
- __DEV__ && console.warn("Adding cleanup to disposed group");
625
- return;
626
- }
627
- t.push(s);
628
- },
629
- dispose() {
630
- if (!e) {
631
- e = !0;
632
- for (const s of t)
633
- try {
634
- s();
635
- } catch (r) {
636
- console.error("Error in cleanup function:", r);
637
- }
638
- t.length = 0;
639
- }
640
- },
641
- get disposed() {
642
- return e;
643
- }
644
- };
645
- }
646
- function Pe(t, e) {
647
- const s = setTimeout(t, e);
648
- return S(() => clearTimeout(s)), s;
649
- }
650
- function Te(t, e) {
651
- const s = setInterval(t, e);
652
- return S(() => clearInterval(s)), s;
653
- }
654
- function Qe(t, e, s, r) {
655
- t.addEventListener(e, s, r), S(() => t.removeEventListener(e, s, r));
656
- }
657
- typeof globalThis.__DEV__ > "u" && (globalThis.__DEV__ = process.env.NODE_ENV !== "production");
658
- var ne = Object.defineProperty, oe = (t, e, s) => e in t ? ne(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s, y = (t, e, s) => oe(t, typeof e != "symbol" ? e + "" : e, s);
659
- class z {
660
- constructor() {
661
- y(this, "pending", /* @__PURE__ */ new Set()), y(this, "isFlushScheduled", !1);
662
- }
663
- schedule(e) {
664
- this.pending.add(e), this.isFlushScheduled || (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
665
- }
666
- flush() {
667
- if (this.pending.size === 0) {
668
- this.isFlushScheduled = !1;
669
- return;
670
- }
671
- const e = Array.from(this.pending);
672
- this.pending.clear(), this.isFlushScheduled = !1;
673
- for (const s of e)
674
- try {
675
- s();
676
- } catch (r) {
677
- console.error("Error in scheduled task:", r);
678
- }
679
- this.pending.size > 0 && (this.isFlushScheduled = !0, queueMicrotask(() => this.flush()));
680
- }
681
- }
682
- class ue {
683
- schedule(e) {
684
- try {
685
- e();
686
- } catch (s) {
687
- console.error("Error in sync scheduled task:", s);
688
- }
689
- }
690
- flush() {
691
- }
692
- }
693
- var R = /* @__PURE__ */ ((t) => (t[t.Immediate = 0] = "Immediate", t[t.High = 1] = "High", t[t.Normal = 2] = "Normal", t[t.Low = 3] = "Low", t[t.Idle = 4] = "Idle", t))(R || {});
694
- class ae {
695
- constructor() {
696
- y(this, "queues", /* @__PURE__ */ new Map()), y(this, "taskIdCounter", 0), y(this, "isFlushScheduled", !1);
697
- for (const e of Object.values(R))
698
- typeof e == "number" && this.queues.set(e, /* @__PURE__ */ new Set());
699
- }
700
- schedule(e, s = 2) {
701
- const r = {
702
- fn: e,
703
- priority: s,
704
- id: ++this.taskIdCounter
705
- }, i = this.queues.get(s);
706
- i && i.add(r), this.isFlushScheduled || (this.isFlushScheduled = !0, s === 0 ? this.flush() : queueMicrotask(() => this.flush()));
707
- }
708
- flush() {
709
- this.isFlushScheduled = !1;
710
- for (const e of [
711
- 0,
712
- 1,
713
- 2,
714
- 3,
715
- 4
716
- /* Idle */
717
- ]) {
718
- const s = this.queues.get(e);
719
- if (!s || s.size === 0) continue;
720
- const r = Array.from(s).sort((i, o) => i.id - o.id);
721
- s.clear();
722
- for (const i of r)
723
- try {
724
- i.fn();
725
- } catch (o) {
726
- console.error(`Error in priority ${e} task:`, o);
727
- }
728
- if (s.size === 0 && this.hasMoreTasks()) {
729
- queueMicrotask(() => this.flush());
730
- return;
731
- }
732
- }
733
- }
734
- hasMoreTasks() {
735
- for (const e of this.queues.values())
736
- if (e.size > 0) return !0;
737
- return !1;
738
- }
739
- }
740
- let f = new z();
741
- function He() {
742
- return f;
743
- }
744
- function Be(t) {
745
- f = t;
746
- }
747
- function Ue(t = !0) {
748
- t ? f = new z() : f = new ue();
749
- }
750
- function We(t) {
751
- f.schedule(t);
752
- }
753
- function Le(t, e) {
754
- f instanceof ae ? f.schedule(t, e) : f.schedule(t);
755
- }
756
- function Ge(t) {
757
- typeof requestIdleCallback < "u" ? requestIdleCallback(t) : setTimeout(t, 0);
758
- }
759
- export {
760
- ge as $,
761
- Ue as A,
762
- He as B,
763
- Ge as C,
764
- We as D,
765
- Le as E,
766
- Be as F,
767
- K as G,
768
- M as H,
769
- be as I,
770
- ve as J,
771
- $ as K,
772
- xe as L,
773
- ze as M,
774
- $e as N,
775
- De as O,
776
- Ve as P,
777
- Me as Q,
778
- Z as R,
779
- ke as S,
780
- R as T,
781
- g as U,
782
- I as V,
783
- N as W,
784
- Q as X,
785
- V as Y,
786
- B as Z,
787
- me as _,
788
- Qe as a,
789
- Te as b,
790
- je as c,
791
- Ae as d,
792
- Pe as e,
793
- Re as f,
794
- v as g,
795
- Ie as h,
796
- Ne as i,
797
- de as j,
798
- ce as k,
799
- fe as l,
800
- ye as m,
801
- Fe as n,
802
- S as o,
803
- Ce as p,
804
- Ee as q,
805
- he as r,
806
- qe as s,
807
- Oe as t,
808
- pe as u,
809
- E as v,
810
- w,
811
- Se as x,
812
- _e as y,
813
- we as z
814
- };