@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
@@ -0,0 +1,677 @@
1
+ import { ComputationState as o } from "@tachui/types/reactive";
2
+ var M = Object.defineProperty, j = (t, e, r) => e in t ? M(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, u = (t, e, r) => j(t, typeof e != "symbol" ? e + "" : e, r);
3
+ let S = 0, E = 0;
4
+ const D = Math.random().toString(36).substr(2, 6);
5
+ let O = null, _ = null, q = !1;
6
+ const F = /* @__PURE__ */ new Set();
7
+ F.add(D);
8
+ const n = {
9
+ get currentComputation() {
10
+ return O;
11
+ },
12
+ set currentComputation(t) {
13
+ O = t;
14
+ },
15
+ get currentOwner() {
16
+ return _;
17
+ },
18
+ set currentOwner(t) {
19
+ _ = t;
20
+ },
21
+ get isBatching() {
22
+ return q;
23
+ },
24
+ set isBatching(t) {
25
+ q = t;
26
+ }
27
+ };
28
+ function I() {
29
+ return n.currentComputation;
30
+ }
31
+ function k() {
32
+ return n.currentOwner;
33
+ }
34
+ function z() {
35
+ return n.isBatching;
36
+ }
37
+ class T {
38
+ constructor(e = null) {
39
+ 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 = ++E, this.parent = e;
40
+ }
41
+ dispose() {
42
+ if (!this.disposed) {
43
+ this.disposed = !0;
44
+ for (const e of this.sources)
45
+ e.dispose();
46
+ this.sources.clear();
47
+ for (const e of this.cleanups)
48
+ try {
49
+ e();
50
+ } catch (r) {
51
+ console.error("Error in cleanup function:", r);
52
+ }
53
+ this.cleanups.length = 0, this.parent && !this.parent.disposed && this.parent.sources.delete(this);
54
+ }
55
+ }
56
+ }
57
+ class x {
58
+ constructor(e, r = null) {
59
+ u(this, "id"), u(this, "owner"), u(this, "fn"), u(this, "sources", /* @__PURE__ */ new Set()), u(this, "observers", /* @__PURE__ */ new Set()), u(this, "state", o.Dirty), u(this, "value"), this.id = ++S, this.fn = e, this.owner = r, r && !r.disposed && r.sources.add(this);
60
+ }
61
+ execute() {
62
+ if (this.state === o.Disposed)
63
+ return this.value;
64
+ for (const r of this.sources)
65
+ r && typeof r == "object" && "removeObserver" in r && r.removeObserver(this);
66
+ this.sources.clear();
67
+ const e = n.currentComputation;
68
+ n.currentComputation = this;
69
+ try {
70
+ return this.state = o.Clean, this.value = this.fn(), this.value;
71
+ } catch (r) {
72
+ throw this.state = o.Disposed, (typeof process > "u" || process.env.NODE_ENV !== "test") && console.error("Error in computation:", r), r;
73
+ } finally {
74
+ n.currentComputation = e;
75
+ }
76
+ }
77
+ dispose() {
78
+ if (this.state !== o.Disposed) {
79
+ this.state = o.Disposed;
80
+ for (const e of this.sources)
81
+ e && typeof e == "object" && "removeObserver" in e && e.removeObserver(this);
82
+ this.sources.clear();
83
+ for (const e of this.observers)
84
+ e.sources.delete(this);
85
+ this.observers.clear(), this.owner && !this.owner.disposed && this.owner.sources.delete(this);
86
+ }
87
+ }
88
+ }
89
+ function ne(t) {
90
+ const e = new T(n.currentOwner), r = n.currentOwner;
91
+ n.currentOwner = e;
92
+ try {
93
+ return t(() => e.dispose());
94
+ } finally {
95
+ n.currentOwner = r;
96
+ }
97
+ }
98
+ function ie(t, e) {
99
+ const r = n.currentOwner;
100
+ n.currentOwner = t;
101
+ try {
102
+ return e();
103
+ } finally {
104
+ n.currentOwner = r;
105
+ }
106
+ }
107
+ function oe() {
108
+ return n.currentOwner;
109
+ }
110
+ let w = null;
111
+ function $(t) {
112
+ w = t;
113
+ }
114
+ function ue(t) {
115
+ if (n.isBatching)
116
+ return t();
117
+ const e = n.isBatching;
118
+ n.isBatching = !0;
119
+ try {
120
+ const r = t();
121
+ return !e && w && w(), r;
122
+ } finally {
123
+ n.isBatching = e;
124
+ }
125
+ }
126
+ function ae(t) {
127
+ const e = n.currentComputation;
128
+ n.currentComputation = null;
129
+ try {
130
+ return t();
131
+ } finally {
132
+ n.currentComputation = e;
133
+ }
134
+ }
135
+ function ce(t, e) {
136
+ const r = new x(
137
+ t,
138
+ e || n.currentOwner
139
+ );
140
+ return r.execute(), r;
141
+ }
142
+ function le() {
143
+ return {
144
+ computation: n.currentComputation,
145
+ batch: n.isBatching
146
+ };
147
+ }
148
+ const he = {
149
+ getCurrentComputation: () => n.currentComputation,
150
+ getCurrentOwner: () => n.currentOwner,
151
+ getComputationCount: () => S,
152
+ getOwnerCount: () => E,
153
+ isBatching: () => n.isBatching,
154
+ getModuleInstances: () => Array.from(F),
155
+ getModuleId: () => D
156
+ };
157
+ var Q = Object.defineProperty, H = (t, e, r) => e in t ? Q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, v = (t, e, r) => H(t, typeof e != "symbol" ? e + "" : e, r);
158
+ let U = 0;
159
+ class W {
160
+ constructor(e) {
161
+ v(this, "id"), v(this, "observers", /* @__PURE__ */ new Set()), v(this, "_value"), this.id = ++U, this._value = e;
162
+ }
163
+ /**
164
+ * Get the current value and track dependency
165
+ */
166
+ getValue() {
167
+ const e = I();
168
+ return e && e.state !== o.Disposed && (this.observers.add(e), e.sources.add(this)), this._value;
169
+ }
170
+ /**
171
+ * Get the current value without tracking dependency
172
+ */
173
+ peek() {
174
+ return this._value;
175
+ }
176
+ /**
177
+ * Set a new value and notify observers
178
+ */
179
+ set(e) {
180
+ const r = typeof e == "function" ? e(this._value) : e;
181
+ return r !== this._value && (this._value = r, this.notify()), r;
182
+ }
183
+ /**
184
+ * Notify all observers that this signal has changed
185
+ */
186
+ notify() {
187
+ for (const e of this.observers)
188
+ e.state !== o.Disposed && (e.state = o.Dirty, J(e));
189
+ }
190
+ /**
191
+ * Remove an observer (cleanup)
192
+ */
193
+ removeObserver(e) {
194
+ this.observers.delete(e);
195
+ }
196
+ /**
197
+ * Get debug information about this signal
198
+ */
199
+ [Symbol.for("tachui.debug")]() {
200
+ return {
201
+ id: this.id,
202
+ value: this._value,
203
+ observerCount: this.observers.size,
204
+ type: "Signal"
205
+ };
206
+ }
207
+ }
208
+ const m = /* @__PURE__ */ new Set();
209
+ let y = !1;
210
+ function J(t) {
211
+ m.add(t), !y && !z() && queueMicrotask(N);
212
+ }
213
+ function N() {
214
+ if (!y) {
215
+ y = !0;
216
+ try {
217
+ for (; m.size > 0; ) {
218
+ const t = Array.from(m).sort((e, r) => e.id - r.id);
219
+ m.clear();
220
+ for (const e of t)
221
+ e.state === o.Dirty && e.execute();
222
+ }
223
+ } finally {
224
+ y = !1;
225
+ }
226
+ }
227
+ }
228
+ function L(t) {
229
+ const e = new W(t), r = e.getValue.bind(e);
230
+ r.peek = e.peek.bind(e);
231
+ const s = e.set.bind(e);
232
+ return Object.defineProperty(r, Symbol.for("tachui.signal"), {
233
+ value: e,
234
+ enumerable: !1
235
+ }), [r, s];
236
+ }
237
+ function fe(t) {
238
+ return typeof t == "function" && Symbol.for("tachui.signal") in t;
239
+ }
240
+ function de(t) {
241
+ return t[Symbol.for("tachui.signal")] || null;
242
+ }
243
+ $(N);
244
+ const g = (t, e) => t === e, b = (t, e) => {
245
+ if (t === e) return !0;
246
+ if (t == null || e == null || typeof t != typeof e) return !1;
247
+ if (typeof t == "object") {
248
+ if (Array.isArray(t) !== Array.isArray(e)) return !1;
249
+ if (Array.isArray(t)) {
250
+ const c = t, C = e;
251
+ return c.length !== C.length ? !1 : c.every((V, A) => b(V, C[A]));
252
+ }
253
+ const r = t, s = e, i = Object.keys(r), a = Object.keys(s);
254
+ return i.length !== a.length ? !1 : i.every((c) => b(r[c], s[c]));
255
+ }
256
+ return !1;
257
+ }, pe = (t, e) => {
258
+ if (t === e) return !0;
259
+ if (typeof t != "object" || typeof e != "object" || t == null || e == null) return !1;
260
+ const r = t, s = e, i = Object.keys(r), a = Object.keys(s);
261
+ return i.length !== a.length ? !1 : i.every((c) => r[c] === s[c]);
262
+ }, me = (t, e) => {
263
+ if (t === e) return !0;
264
+ if (t instanceof Date && e instanceof Date)
265
+ return t.getTime() === e.getTime();
266
+ if (t instanceof RegExp && e instanceof RegExp)
267
+ return t.toString() === e.toString();
268
+ if (t instanceof Set && e instanceof Set) {
269
+ if (t.size !== e.size) return !1;
270
+ for (const r of t)
271
+ if (!e.has(r)) return !1;
272
+ return !0;
273
+ }
274
+ if (t instanceof Map && e instanceof Map) {
275
+ if (t.size !== e.size) return !1;
276
+ for (const [r, s] of t)
277
+ if (!e.has(r) || e.get(r) !== s) return !1;
278
+ return !0;
279
+ }
280
+ return b(t, e);
281
+ }, ye = (t, e) => {
282
+ if (t === e) return !0;
283
+ try {
284
+ return JSON.stringify(t) === JSON.stringify(e);
285
+ } catch {
286
+ return t === e;
287
+ }
288
+ }, ge = (t, e = g) => (r, s) => e(t(r), t(s)), ve = (t = g) => (e, r) => e === r ? !0 : e.length !== r.length ? !1 : e.every((s, i) => t(s, r[i])), we = (t = g) => (e, r) => {
289
+ if (e === r) return !0;
290
+ if (e == null || r == null) return !1;
291
+ const s = Object.keys(e), i = Object.keys(r);
292
+ return s.length !== i.length ? !1 : s.every((a) => t(e[a], r[a]));
293
+ }, be = (...t) => (e, r) => t.every((s) => s(e, r)), Ce = (t, e) => (r, s) => {
294
+ const i = t(r, s);
295
+ return process.env.NODE_ENV === "development" && console.log(`[${e || "equals"}]`, { a: r, b: s, equal: i }), i;
296
+ };
297
+ var G = Object.defineProperty, K = (t, e, r) => e in t ? G(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, l = (t, e, r) => K(t, typeof e != "symbol" ? e + "" : e, r), d = /* @__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))(d || {});
298
+ class X extends Error {
299
+ constructor(e, r, s) {
300
+ super(e), this.cause = r, this.node = s, this.name = "ReactiveError";
301
+ }
302
+ }
303
+ const B = class f {
304
+ constructor() {
305
+ l(this, "updateQueues", /* @__PURE__ */ new Map()), l(this, "isFlushPending", !1), l(this, "isDestroyed", !1), l(this, "errorHandlers", /* @__PURE__ */ new Set()), l(this, "maxRetries", 3), l(this, "totalUpdateCycles", 0), l(this, "totalUpdateTime", 0), l(this, "errorCount", 0), l(this, "nodeRegistry", /* @__PURE__ */ new WeakSet());
306
+ for (const e of Object.values(d))
307
+ typeof e == "number" && this.updateQueues.set(e, /* @__PURE__ */ new Set());
308
+ }
309
+ static getInstance() {
310
+ return f.instance || (f.instance = new f()), f.instance;
311
+ }
312
+ /**
313
+ * Schedule reactive node for update
314
+ */
315
+ schedule(e) {
316
+ if (this.isDestroyed) return;
317
+ this.nodeRegistry.add(e), this.getQueue(e.priority).add(e), this.isFlushPending || (this.isFlushPending = !0, this.scheduleFlush(e.priority));
318
+ }
319
+ /**
320
+ * Process all queued updates by priority
321
+ */
322
+ async flush() {
323
+ if (this.isDestroyed) return;
324
+ this.isFlushPending = !1;
325
+ const e = performance.now();
326
+ try {
327
+ for (const r of [
328
+ 0,
329
+ 1,
330
+ 2,
331
+ 3,
332
+ 4
333
+ /* Idle */
334
+ ]) {
335
+ const s = this.updateQueues.get(r);
336
+ if (!s || s.size === 0) continue;
337
+ const i = Array.from(s);
338
+ s.clear();
339
+ for (const a of i)
340
+ try {
341
+ await this.updateNodeWithRetry(a);
342
+ } catch (c) {
343
+ this.handleReactiveError(
344
+ new X(`Failed to update ${a.type} node ${a.id}`, c, a)
345
+ );
346
+ }
347
+ if (this.hasHigherPriorityWork(r))
348
+ return this.flush();
349
+ }
350
+ this.totalUpdateCycles++;
351
+ } finally {
352
+ const r = performance.now();
353
+ this.totalUpdateTime += r - e;
354
+ }
355
+ }
356
+ /**
357
+ * Update node with retry logic
358
+ */
359
+ async updateNodeWithRetry(e, r = 1) {
360
+ try {
361
+ e.notify();
362
+ } catch (s) {
363
+ if (r < this.maxRetries)
364
+ return console.warn(`Reactive update failed, retrying (${r}/${this.maxRetries})`), await new Promise((i) => setTimeout(i, r * 10)), this.updateNodeWithRetry(e, r + 1);
365
+ throw s;
366
+ }
367
+ }
368
+ /**
369
+ * Schedule flush based on priority
370
+ */
371
+ scheduleFlush(e) {
372
+ switch (e) {
373
+ case 0:
374
+ this.flush();
375
+ break;
376
+ case 1:
377
+ queueMicrotask(() => this.flush());
378
+ break;
379
+ case 2:
380
+ typeof requestAnimationFrame < "u" ? requestAnimationFrame(() => this.flush()) : queueMicrotask(() => this.flush());
381
+ break;
382
+ case 3:
383
+ case 4:
384
+ typeof requestIdleCallback < "u" ? requestIdleCallback(() => this.flush(), { timeout: 1e3 }) : setTimeout(() => this.flush(), 50);
385
+ break;
386
+ }
387
+ }
388
+ /**
389
+ * Check if there's higher priority work waiting
390
+ */
391
+ hasHigherPriorityWork(e) {
392
+ for (let r = 0; r < e; r++) {
393
+ const s = this.updateQueues.get(r);
394
+ if (s && s.size > 0)
395
+ return !0;
396
+ }
397
+ return !1;
398
+ }
399
+ /**
400
+ * Get queue for priority level
401
+ */
402
+ getQueue(e) {
403
+ const r = this.updateQueues.get(e);
404
+ if (!r)
405
+ throw new Error(`Invalid priority level: ${e}`);
406
+ return r;
407
+ }
408
+ /**
409
+ * Register error handler
410
+ */
411
+ onError(e) {
412
+ return this.errorHandlers.add(e), () => this.errorHandlers.delete(e);
413
+ }
414
+ /**
415
+ * Handle reactive errors with recovery
416
+ */
417
+ handleReactiveError(e) {
418
+ this.errorCount++;
419
+ let r = !1;
420
+ for (const s of this.errorHandlers)
421
+ try {
422
+ s(e), r = !0;
423
+ } catch (i) {
424
+ console.error("Error handler threw error:", i);
425
+ }
426
+ if (!r && (console.error("Unhandled reactive error:", e), process.env.NODE_ENV === "development"))
427
+ throw e;
428
+ }
429
+ /**
430
+ * Get performance metrics
431
+ */
432
+ getPerformanceMetrics() {
433
+ let e = 0;
434
+ for (const r of this.updateQueues.values())
435
+ e += r.size;
436
+ return {
437
+ totalNodes: e,
438
+ updateCycles: this.totalUpdateCycles,
439
+ averageUpdateTime: this.totalUpdateCycles > 0 ? this.totalUpdateTime / this.totalUpdateCycles : 0,
440
+ memoryUsage: this.estimateMemoryUsage(),
441
+ errorCount: this.errorCount
442
+ };
443
+ }
444
+ /**
445
+ * Estimate memory usage (rough approximation)
446
+ */
447
+ estimateMemoryUsage() {
448
+ let e = 0;
449
+ for (const r of this.updateQueues.values())
450
+ e += r.size * 50;
451
+ return e += this.errorHandlers.size * 100, e;
452
+ }
453
+ /**
454
+ * Check if node is scheduled
455
+ */
456
+ hasNode(e) {
457
+ for (const r of this.updateQueues.values())
458
+ if (r.has(e))
459
+ return !0;
460
+ return !1;
461
+ }
462
+ /**
463
+ * Flush all pending updates synchronously
464
+ */
465
+ flushSync() {
466
+ this.isFlushPending && (this.isFlushPending = !1, this.flush());
467
+ }
468
+ /**
469
+ * Clear all pending updates
470
+ */
471
+ clearPending() {
472
+ for (const e of this.updateQueues.values())
473
+ e.clear();
474
+ this.isFlushPending = !1;
475
+ }
476
+ /**
477
+ * Cleanup all reactive nodes and destroy scheduler
478
+ */
479
+ destroy() {
480
+ this.isDestroyed = !0;
481
+ for (const e of this.updateQueues.values()) {
482
+ for (const r of e)
483
+ try {
484
+ r.cleanup();
485
+ } catch (s) {
486
+ console.error("Error cleaning up reactive node:", s);
487
+ }
488
+ e.clear();
489
+ }
490
+ this.updateQueues.clear(), this.errorHandlers.clear(), f.instance = null;
491
+ }
492
+ /**
493
+ * Get debug information
494
+ */
495
+ getDebugInfo() {
496
+ const e = {};
497
+ for (const [r, s] of this.updateQueues)
498
+ e[d[r]] = s.size;
499
+ return {
500
+ isFlushPending: this.isFlushPending,
501
+ isDestroyed: this.isDestroyed,
502
+ queueSizes: e,
503
+ errorHandlerCount: this.errorHandlers.size,
504
+ performance: this.getPerformanceMetrics()
505
+ };
506
+ }
507
+ };
508
+ l(B, "instance", null);
509
+ let Oe = B;
510
+ var Y = Object.defineProperty, Z = (t, e, r) => e in t ? Y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, h = (t, e, r) => Z(t, typeof e != "symbol" ? e + "" : e, r);
511
+ class ee extends x {
512
+ constructor(e, r = {}, s = k()) {
513
+ super(e, s), h(this, "type", "computed"), h(this, "priority"), h(this, "_hasValue", !1), h(this, "_error", null), h(this, "equalsFn"), h(this, "options"), this.priority = r.priority ?? d.Normal, this.equalsFn = r.equals ?? g, this.options = r;
514
+ }
515
+ /**
516
+ * Get the computed value, tracking dependency and lazily computing
517
+ */
518
+ getValue() {
519
+ const e = I();
520
+ return e && e.state !== o.Disposed && (this.observers.add(e), e.sources.add(this)), (this.state === o.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
521
+ }
522
+ /**
523
+ * Get the current value without tracking dependency
524
+ */
525
+ peek() {
526
+ return (this.state === o.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
527
+ }
528
+ /**
529
+ * Remove an observer (cleanup)
530
+ */
531
+ removeObserver(e) {
532
+ this.observers.delete(e);
533
+ }
534
+ /**
535
+ * Execute the computation and notify observers
536
+ */
537
+ execute() {
538
+ const e = this._hasValue ? this.value : void 0, r = super.execute();
539
+ if (!this._hasValue || !this.equalsFn(e, r))
540
+ for (const s of this.observers)
541
+ s.state !== o.Disposed && (s.state = o.Dirty, "execute" in s && typeof s.execute == "function" && queueMicrotask(() => {
542
+ s.state === o.Dirty && s.execute();
543
+ }));
544
+ return r;
545
+ }
546
+ /**
547
+ * Notify method for ReactiveNode compatibility
548
+ */
549
+ notify() {
550
+ this.execute();
551
+ }
552
+ /**
553
+ * Complete cleanup for memory management
554
+ */
555
+ cleanup() {
556
+ for (const e of this.sources)
557
+ "removeObserver" in e && e.removeObserver(this);
558
+ this.sources.clear();
559
+ for (const e of this.observers)
560
+ e.sources.delete(this);
561
+ this.observers.clear(), this._hasValue = !1, this._error = null, this.state = o.Disposed;
562
+ }
563
+ /**
564
+ * Dispose the computed value
565
+ */
566
+ dispose() {
567
+ this.cleanup(), super.dispose();
568
+ }
569
+ /**
570
+ * Debug information
571
+ */
572
+ [Symbol.for("tachui.debug")]() {
573
+ return {
574
+ id: this.id,
575
+ type: this.type,
576
+ value: this._hasValue ? this.value : void 0,
577
+ hasValue: this._hasValue,
578
+ error: this._error?.message,
579
+ state: this.state,
580
+ sourceCount: this.sources.size,
581
+ observerCount: this.observers.size,
582
+ priority: d[this.priority],
583
+ debugName: this.options.debugName,
584
+ equalsFn: this.equalsFn.name || "anonymous"
585
+ };
586
+ }
587
+ toString() {
588
+ return `Computed(${this.options.debugName || this.id}): ${this._hasValue ? this.value : "no value"}`;
589
+ }
590
+ }
591
+ function p(t, e) {
592
+ const r = new ee(t, e), s = r.getValue.bind(r);
593
+ return s.peek = r.peek.bind(r), Object.defineProperty(s, Symbol.for("tachui.computed"), {
594
+ value: r,
595
+ enumerable: !1
596
+ }), s;
597
+ }
598
+ function _e(t, e) {
599
+ return p(t, e);
600
+ }
601
+ function qe(t) {
602
+ return typeof t == "function" && Symbol.for("tachui.computed") in t;
603
+ }
604
+ function Se(t) {
605
+ return t[Symbol.for("tachui.computed")] || null;
606
+ }
607
+ function Ee(t, e) {
608
+ return p(e ? () => {
609
+ for (const s of e)
610
+ s();
611
+ return t();
612
+ } : t);
613
+ }
614
+ function De(t, e) {
615
+ let r, s = !1;
616
+ return p(() => (e() && (r = t(), s = !0), s || (r = t(), s = !0), r));
617
+ }
618
+ const [R, te] = L("light");
619
+ function Fe() {
620
+ const t = R();
621
+ return t === "system" ? P() : t;
622
+ }
623
+ function Ie(t) {
624
+ te(t);
625
+ }
626
+ const re = p(() => {
627
+ const t = R();
628
+ return t === "system" ? P() : t;
629
+ });
630
+ function xe() {
631
+ return re;
632
+ }
633
+ function P() {
634
+ return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
635
+ }
636
+ export {
637
+ b as A,
638
+ g as B,
639
+ x as C,
640
+ he as D,
641
+ ye as E,
642
+ pe as F,
643
+ me as G,
644
+ P as H,
645
+ Fe as I,
646
+ xe as J,
647
+ Ie as K,
648
+ Oe as L,
649
+ X as R,
650
+ d as U,
651
+ p as a,
652
+ _e as b,
653
+ L as c,
654
+ qe as d,
655
+ Se as e,
656
+ N as f,
657
+ de as g,
658
+ Ee as h,
659
+ fe as i,
660
+ De as j,
661
+ I as k,
662
+ k as l,
663
+ z as m,
664
+ ne as n,
665
+ oe as o,
666
+ ue as p,
667
+ ce as q,
668
+ ie as r,
669
+ $ as s,
670
+ le as t,
671
+ ae as u,
672
+ be as v,
673
+ ve as w,
674
+ we as x,
675
+ ge as y,
676
+ Ce as z
677
+ };
@@ -0,0 +1,11 @@
1
+ import type { ComponentInstance, CloneOptions } from '../runtime/types';
2
+ export declare function clonePropsPreservingReactivity<T extends Record<string, unknown>>(props: T, options?: CloneOptions): T;
3
+ export declare function createResetLifecycleState(): {
4
+ mounted: boolean;
5
+ cleanup: (() => void)[];
6
+ domElements: Map<string, Element> | undefined;
7
+ primaryElement: Element | undefined;
8
+ domReady: boolean;
9
+ };
10
+ export declare function resetLifecycleState(target: ComponentInstance): void;
11
+ //# sourceMappingURL=clone-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clone-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/clone-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAyBvE,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9E,KAAK,EAAE,CAAC,EACR,OAAO,GAAE,YAAiB,GACzB,CAAC,CAwCH;AAED,wBAAgB,yBAAyB;;aAGtB,CAAC,MAAM,IAAI,CAAC,EAAE;iBACH,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;oBAC7B,OAAO,GAAG,SAAS;;EAGnD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,QAO5D"}