@tachui/core 0.8.22 → 0.8.24
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/assets/FontAsset.d.ts.map +1 -1
- package/dist/assets/index.js +42 -41
- package/dist/{binding-DCV5PKkK.js → binding-DCr-JHsC.js} +9 -9
- package/dist/build-tools/typegen-runner.d.ts +4 -0
- package/dist/build-tools/typegen-runner.d.ts.map +1 -1
- package/dist/cleanup-BR8UpYPX.js +61 -0
- package/dist/common.js +272 -277
- package/dist/{component-D-O9yq0P.js → component-BzvSm8rM.js} +19 -19
- package/dist/{component-base-C41K3NTe.js → component-base-Do2EdQkr.js} +32 -33
- package/dist/{component-context-B9HI2nZH.js → component-context-C7Y6Xu6h.js} +1 -1
- package/dist/components/index.js +1 -1
- package/dist/computed-CA4Cgtoe.js +407 -0
- package/dist/{concatenated-component-2Gzy5e2c.js → concatenated-component-CA54ng_j.js} +43 -44
- package/dist/css-classes/index.js +2 -2
- package/dist/{effect-BsW3fy1q.js → effect-DgNm6jk9.js} +3 -3
- package/dist/{enhanced-renderer-t9Ni2EEG.js → enhanced-renderer-D05CCloF.js} +26 -28
- package/dist/essential.js +276 -281
- package/dist/factories-B05hE6kc.js +644 -0
- package/dist/{factory-gqfMcmOy.js → factory-B1YXfgU1.js} +23 -29
- package/dist/full.d.ts +12 -0
- package/dist/full.d.ts.map +1 -0
- package/dist/full.js +436 -0
- package/dist/gradients/index.js +53 -53
- package/dist/hooks-w_FYPLjI.js +158 -0
- package/dist/{index-DL9Cys3t.js → index-CmQmIgPK.js} +220 -233
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +295 -300
- package/dist/minimal-prod.js +106 -108
- package/dist/minimal.js +97 -98
- package/dist/modifiers/base.d.ts.map +1 -1
- package/dist/modifiers/base.js +121 -120
- package/dist/modifiers/builder.js +1 -1
- package/dist/modifiers/index.js +22 -23
- package/dist/modifiers/registry.js +1 -1
- package/dist/{observed-object-p1CLdrFm.js → observed-object-DCoyucmV.js} +3 -3
- package/dist/optimization-D9t53vNJ.js +308 -0
- package/dist/{proxy-Cp0QUXME.js → proxy-B7ZIqGd0.js} +3 -3
- package/dist/reactive/index.js +87 -85
- package/dist/runtime/dom-bridge.js +15 -17
- package/dist/runtime/index.js +71 -71
- package/dist/runtime/renderer.js +10 -11
- package/dist/signal-BRoiFOO7.js +262 -0
- package/dist/{signal-list-07gNXGiW.js → signal-list-_Eid-N7_.js} +285 -176
- package/dist/state/index.js +43 -44
- package/dist/theme-D5-09a8N.js +26 -0
- package/dist/validation/index.js +24 -26
- package/dist/version.js +1 -1
- package/package.json +16 -3
- package/dist/factories-B3-rmvkB.js +0 -268
- package/dist/hooks-WGmpzYgD.js +0 -446
- package/dist/optimization-CbKNA9w4.js +0 -21
- package/dist/presets-B9x94uRn.js +0 -381
- package/dist/scheduler-DppMK9mR.js +0 -169
- package/dist/theme-CRLPHryV.js +0 -687
- package/dist/{index-JQ1sW1SK.js → index-7vhCZc7g.js} +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as x } from "./
|
|
2
|
-
import { c as
|
|
3
|
-
import "
|
|
4
|
-
import { c as
|
|
5
|
-
import {
|
|
1
|
+
import { o as x } from "./cleanup-BR8UpYPX.js";
|
|
2
|
+
import { c as h } from "./effect-DgNm6jk9.js";
|
|
3
|
+
import { b as _, r as K } from "./component-context-C7Y6Xu6h.js";
|
|
4
|
+
import { c as $ } from "./computed-CA4Cgtoe.js";
|
|
5
|
+
import { d as P } from "./signal-BRoiFOO7.js";
|
|
6
6
|
var Q = Object.defineProperty, N = (n, e, r) => e in n ? Q(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r, p = (n, e, r) => N(n, typeof e != "symbol" ? e + "" : e, r);
|
|
7
7
|
class b {
|
|
8
8
|
constructor(e, r) {
|
|
@@ -48,7 +48,7 @@ class b {
|
|
|
48
48
|
* Create reactive computed for a specific prop
|
|
49
49
|
*/
|
|
50
50
|
createPropComputed(e) {
|
|
51
|
-
return
|
|
51
|
+
return $(() => this.getProps()[e]);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Create effect that runs when specific props change
|
|
@@ -360,14 +360,14 @@ u(E, "instance");
|
|
|
360
360
|
let F = E;
|
|
361
361
|
function m(n, e = {}) {
|
|
362
362
|
const r = (t) => {
|
|
363
|
-
const o = R(), i = F.getInstance(), s = [], l =
|
|
363
|
+
const o = R(), i = F.getInstance(), s = [], l = _(o), C = new b(t, {
|
|
364
364
|
defaults: e.defaultProps || void 0,
|
|
365
365
|
...e.validation
|
|
366
366
|
}), w = new d(t.children), U = new g();
|
|
367
367
|
let c, A = !1, v = !1;
|
|
368
368
|
const M = {
|
|
369
369
|
type: "component",
|
|
370
|
-
render: () =>
|
|
370
|
+
render: () => K(l, () => {
|
|
371
371
|
if (e.lifecycle?.onMount && !A) {
|
|
372
372
|
const a = e.lifecycle.onMount();
|
|
373
373
|
typeof a == "function" && s.push(a), A = !0;
|
|
@@ -482,18 +482,18 @@ export {
|
|
|
482
482
|
F as C,
|
|
483
483
|
b as P,
|
|
484
484
|
g as R,
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
485
|
+
m as a,
|
|
486
|
+
Z as b,
|
|
487
|
+
Y as c,
|
|
488
|
+
J as d,
|
|
489
|
+
ee as e,
|
|
490
|
+
re as f,
|
|
491
|
+
d as g,
|
|
492
|
+
T as h,
|
|
493
493
|
G as i,
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
494
|
+
W as j,
|
|
495
|
+
z as k,
|
|
496
|
+
X as l,
|
|
497
497
|
S as p,
|
|
498
498
|
H as w
|
|
499
499
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { i as n
|
|
3
|
-
import "@tachui/types/reactive";
|
|
1
|
+
import { i as f, c as h } from "./computed-CA4Cgtoe.js";
|
|
2
|
+
import { i as n } from "./signal-BRoiFOO7.js";
|
|
4
3
|
var g = Object.defineProperty, u = (i, s, e) => s in i ? g(i, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[s] = e, o = (i, s, e) => u(i, typeof s != "symbol" ? s + "" : s, e);
|
|
5
4
|
const d = {
|
|
6
5
|
sanitizeClassNames: !0,
|
|
@@ -84,8 +83,8 @@ class p {
|
|
|
84
83
|
processClasses(s) {
|
|
85
84
|
if (!s) return [];
|
|
86
85
|
if (n(s) || f(s)) {
|
|
87
|
-
const
|
|
88
|
-
return this.processClasses(
|
|
86
|
+
const a = s();
|
|
87
|
+
return this.processClasses(a);
|
|
89
88
|
}
|
|
90
89
|
const e = this.getCacheKey(s);
|
|
91
90
|
if (this.config.enableCaching && this.cacheHas(this.classCache, e))
|
|
@@ -94,18 +93,18 @@ class p {
|
|
|
94
93
|
if (typeof s == "string")
|
|
95
94
|
t = s.trim().split(/\s+/).filter(Boolean);
|
|
96
95
|
else if (Array.isArray(s))
|
|
97
|
-
t = s.flatMap((
|
|
98
|
-
if (
|
|
96
|
+
t = s.flatMap((a) => {
|
|
97
|
+
if (a == null || a === "")
|
|
99
98
|
return [];
|
|
100
|
-
const c = (typeof
|
|
101
|
-
return typeof
|
|
99
|
+
const c = (typeof a == "string" ? a : String(a)).trim();
|
|
100
|
+
return typeof a != "string" && c ? [c] : c.split(/\s+/);
|
|
102
101
|
}).filter(Boolean);
|
|
103
102
|
else {
|
|
104
|
-
const
|
|
105
|
-
t =
|
|
103
|
+
const a = String(s).trim();
|
|
104
|
+
t = a ? [a] : [];
|
|
106
105
|
}
|
|
107
|
-
const
|
|
108
|
-
return this.config.enableCaching && this.setCachedClasses(e,
|
|
106
|
+
const r = this.processClassArray(t);
|
|
107
|
+
return this.config.enableCaching && this.setCachedClasses(e, r), r;
|
|
109
108
|
}
|
|
110
109
|
/**
|
|
111
110
|
* Process an array of class names
|
|
@@ -114,7 +113,7 @@ class p {
|
|
|
114
113
|
let e = s;
|
|
115
114
|
return this.config.sanitizeClassNames && (e = e.map((t) => this.sanitizeClassName(t))), e = this.deduplicateClasses(e), this.config.warnDuplicateClasses && s.length !== e.length && console.warn(
|
|
116
115
|
"[tachUI] Duplicate CSS classes detected and removed:",
|
|
117
|
-
s.filter((t,
|
|
116
|
+
s.filter((t, r) => s.indexOf(t) !== r)
|
|
118
117
|
), e;
|
|
119
118
|
}
|
|
120
119
|
/**
|
|
@@ -124,11 +123,11 @@ class p {
|
|
|
124
123
|
if (!s || typeof s != "string") return "";
|
|
125
124
|
const e = this.config.sanitizationRules;
|
|
126
125
|
let t = s.trim();
|
|
127
|
-
t.includes(" ") && (t = t.replace(/\s+/g, "-"), this.config.warnInvalidClasses && console.warn(`[tachUI] CSS class names cannot contain spaces. Converted "${s}" to "${t}"`)), Object.entries(e.customReplacements || {}).forEach(([
|
|
128
|
-
t = t.replace(new RegExp(
|
|
126
|
+
t.includes(" ") && (t = t.replace(/\s+/g, "-"), this.config.warnInvalidClasses && console.warn(`[tachUI] CSS class names cannot contain spaces. Converted "${s}" to "${t}"`)), Object.entries(e.customReplacements || {}).forEach(([a, C]) => {
|
|
127
|
+
t = t.replace(new RegExp(a, "g"), C);
|
|
129
128
|
});
|
|
130
|
-
let
|
|
131
|
-
return e.allowNumbers && (
|
|
129
|
+
let r = "a-zA-Z\\-\\.";
|
|
130
|
+
return e.allowNumbers && (r += "0-9"), e.allowUnderscores && (r += "_"), r += ":\\[\\]/%", t = t.replace(new RegExp(`[^${r}]`, "g"), "-"), /^[0-9]/.test(t) && (t = "cls-" + t), t = t.replace(/---+/g, "--"), this.config.warnInvalidClasses && t !== s.trim() && console.warn(`[tachUI] CSS class "${s}" sanitized to "${t}"`), t;
|
|
132
131
|
}
|
|
133
132
|
/**
|
|
134
133
|
* Deduplicate classes while preserving first occurrence order
|
|
@@ -141,8 +140,8 @@ class p {
|
|
|
141
140
|
* User classes come AFTER tachUI classes for proper CSS cascade
|
|
142
141
|
*/
|
|
143
142
|
combineClasses(s, e) {
|
|
144
|
-
const t = this.processClasses(e),
|
|
145
|
-
return this.deduplicateClasses(
|
|
143
|
+
const t = this.processClasses(e), r = [...s, ...t];
|
|
144
|
+
return this.deduplicateClasses(r);
|
|
146
145
|
}
|
|
147
146
|
/**
|
|
148
147
|
* Update configuration
|
|
@@ -184,21 +183,21 @@ class p {
|
|
|
184
183
|
*/
|
|
185
184
|
setCachedClasses(s, e) {
|
|
186
185
|
if (this.cacheSize(this.classCache) >= this.config.maxCacheSize) {
|
|
187
|
-
const t = this.cacheKeys(this.classCache),
|
|
188
|
-
|
|
186
|
+
const t = this.cacheKeys(this.classCache), r = Array.isArray(t) ? t[0] : t.next().value;
|
|
187
|
+
r !== void 0 && this.cacheDelete(this.classCache, r);
|
|
189
188
|
}
|
|
190
189
|
this.cacheSet(this.classCache, s, e);
|
|
191
190
|
}
|
|
192
191
|
}
|
|
193
192
|
const l = new p();
|
|
194
|
-
function
|
|
193
|
+
function w(i) {
|
|
195
194
|
l.updateConfig(i);
|
|
196
195
|
}
|
|
197
|
-
function
|
|
196
|
+
function v() {
|
|
198
197
|
return l.getConfig();
|
|
199
198
|
}
|
|
200
199
|
var m = Object.defineProperty, y = (i, s, e) => s in i ? m(i, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[s] = e, S = (i, s, e) => y(i, s + "", e);
|
|
201
|
-
class
|
|
200
|
+
class z {
|
|
202
201
|
constructor() {
|
|
203
202
|
S(this, "cssClassManager", l);
|
|
204
203
|
}
|
|
@@ -231,27 +230,27 @@ class M {
|
|
|
231
230
|
return;
|
|
232
231
|
const e = s.css;
|
|
233
232
|
if (typeof e == "string" || Array.isArray(e) || n(e) || console.warn("[tachUI] css must be a string, array of strings, or signal. Got:", typeof e), Array.isArray(e)) {
|
|
234
|
-
const
|
|
235
|
-
|
|
233
|
+
const r = e.filter((a) => typeof a != "string");
|
|
234
|
+
r.length > 0 && console.warn("[tachUI] All items in css array must be strings. Invalid items:", r);
|
|
236
235
|
}
|
|
237
236
|
}
|
|
238
237
|
/**
|
|
239
238
|
* Get debug information about processed classes
|
|
240
239
|
*/
|
|
241
240
|
getClassDebugInfo(s, e = []) {
|
|
242
|
-
const t = s.css ? this.cssClassManager.processClasses(s.css) : [],
|
|
241
|
+
const t = s.css ? this.cssClassManager.processClasses(s.css) : [], r = this.processComponentClasses(s, e);
|
|
243
242
|
return {
|
|
244
243
|
base: e,
|
|
245
244
|
user: t,
|
|
246
|
-
processed:
|
|
247
|
-
final:
|
|
245
|
+
processed: r,
|
|
246
|
+
final: r.join(" ")
|
|
248
247
|
};
|
|
249
248
|
}
|
|
250
249
|
}
|
|
251
250
|
export {
|
|
252
251
|
p as C,
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
w as a,
|
|
253
|
+
z as b,
|
|
255
254
|
l as c,
|
|
256
|
-
|
|
255
|
+
v as g
|
|
257
256
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as u } from "./signal-BRoiFOO7.js";
|
|
2
2
|
var d = Object.defineProperty, l = (e, t, n) => t in e ? d(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, r = (e, t, n) => l(e, typeof t != "symbol" ? t + "" : t, n);
|
|
3
3
|
const a = Symbol("TachUI.ComponentContext"), v = Symbol("TachUI.Environment");
|
|
4
4
|
let o = null;
|
package/dist/components/index.js
CHANGED
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { C as b, j as q, h as C } from "./signal-BRoiFOO7.js";
|
|
2
|
+
import { ComputationState as a } from "@tachui/types/reactive";
|
|
3
|
+
const d = (s, e) => s === e, p = (s, e) => {
|
|
4
|
+
if (s === e) return !0;
|
|
5
|
+
if (s == null || e == null || typeof s != typeof e) return !1;
|
|
6
|
+
if (typeof s == "object") {
|
|
7
|
+
if (Array.isArray(s) !== Array.isArray(e)) return !1;
|
|
8
|
+
if (Array.isArray(s)) {
|
|
9
|
+
const u = s, y = e;
|
|
10
|
+
return u.length !== y.length ? !1 : u.every((v, g) => p(v, y[g]));
|
|
11
|
+
}
|
|
12
|
+
const t = s, r = e, i = Object.keys(t), o = Object.keys(r);
|
|
13
|
+
return i.length !== o.length ? !1 : i.every((u) => p(t[u], r[u]));
|
|
14
|
+
}
|
|
15
|
+
return !1;
|
|
16
|
+
}, V = (s, e) => {
|
|
17
|
+
if (s === e) return !0;
|
|
18
|
+
if (typeof s != "object" || typeof e != "object" || s == null || e == null) return !1;
|
|
19
|
+
const t = s, r = e, i = Object.keys(t), o = Object.keys(r);
|
|
20
|
+
return i.length !== o.length ? !1 : i.every((u) => t[u] === r[u]);
|
|
21
|
+
}, k = (s, e) => {
|
|
22
|
+
if (s === e) return !0;
|
|
23
|
+
if (s instanceof Date && e instanceof Date)
|
|
24
|
+
return s.getTime() === e.getTime();
|
|
25
|
+
if (s instanceof RegExp && e instanceof RegExp)
|
|
26
|
+
return s.toString() === e.toString();
|
|
27
|
+
if (s instanceof Set && e instanceof Set) {
|
|
28
|
+
if (s.size !== e.size) return !1;
|
|
29
|
+
for (const t of s)
|
|
30
|
+
if (!e.has(t)) return !1;
|
|
31
|
+
return !0;
|
|
32
|
+
}
|
|
33
|
+
if (s instanceof Map && e instanceof Map) {
|
|
34
|
+
if (s.size !== e.size) return !1;
|
|
35
|
+
for (const [t, r] of s)
|
|
36
|
+
if (!e.has(t) || e.get(t) !== r) return !1;
|
|
37
|
+
return !0;
|
|
38
|
+
}
|
|
39
|
+
return p(s, e);
|
|
40
|
+
}, j = (s, e) => {
|
|
41
|
+
if (s === e) return !0;
|
|
42
|
+
try {
|
|
43
|
+
return JSON.stringify(s) === JSON.stringify(e);
|
|
44
|
+
} catch {
|
|
45
|
+
return s === e;
|
|
46
|
+
}
|
|
47
|
+
}, x = (s, e = d) => (t, r) => e(s(t), s(r)), z = (s = d) => (e, t) => e === t ? !0 : e.length !== t.length ? !1 : e.every((r, i) => s(r, t[i])), A = (s = d) => (e, t) => {
|
|
48
|
+
if (e === t) return !0;
|
|
49
|
+
if (e == null || t == null) return !1;
|
|
50
|
+
const r = Object.keys(e), i = Object.keys(t);
|
|
51
|
+
return r.length !== i.length ? !1 : r.every((o) => s(e[o], t[o]));
|
|
52
|
+
}, I = (...s) => (e, t) => s.every((r) => r(e, t)), Q = (s, e) => (t, r) => {
|
|
53
|
+
const i = s(t, r);
|
|
54
|
+
return process.env.NODE_ENV === "development" && console.log(`[${e || "equals"}]`, { a: t, b: r, equal: i }), i;
|
|
55
|
+
};
|
|
56
|
+
var w = Object.defineProperty, O = (s, e, t) => e in s ? w(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, n = (s, e, t) => O(s, typeof e != "symbol" ? e + "" : e, t), h = /* @__PURE__ */ ((s) => (s[s.Immediate = 0] = "Immediate", s[s.High = 1] = "High", s[s.Normal = 2] = "Normal", s[s.Low = 3] = "Low", s[s.Idle = 4] = "Idle", s))(h || {});
|
|
57
|
+
class E extends Error {
|
|
58
|
+
constructor(e, t, r) {
|
|
59
|
+
super(e), this.cause = t, this.node = r, this.name = "ReactiveError";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const m = class c {
|
|
63
|
+
constructor() {
|
|
64
|
+
n(this, "updateQueues", /* @__PURE__ */ new Map()), n(this, "isFlushPending", !1), n(this, "isDestroyed", !1), n(this, "errorHandlers", /* @__PURE__ */ new Set()), n(this, "maxRetries", 3), n(this, "totalUpdateCycles", 0), n(this, "totalUpdateTime", 0), n(this, "errorCount", 0), n(this, "nodeRegistry", /* @__PURE__ */ new WeakSet());
|
|
65
|
+
for (const e of Object.values(h))
|
|
66
|
+
typeof e == "number" && this.updateQueues.set(e, /* @__PURE__ */ new Set());
|
|
67
|
+
}
|
|
68
|
+
static getInstance() {
|
|
69
|
+
return c.instance || (c.instance = new c()), c.instance;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Schedule reactive node for update
|
|
73
|
+
*/
|
|
74
|
+
schedule(e) {
|
|
75
|
+
if (this.isDestroyed) return;
|
|
76
|
+
this.nodeRegistry.add(e), this.getQueue(e.priority).add(e), this.isFlushPending || (this.isFlushPending = !0, this.scheduleFlush(e.priority));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Process all queued updates by priority
|
|
80
|
+
*/
|
|
81
|
+
async flush() {
|
|
82
|
+
if (this.isDestroyed) return;
|
|
83
|
+
this.isFlushPending = !1;
|
|
84
|
+
const e = performance.now();
|
|
85
|
+
try {
|
|
86
|
+
for (const t of [
|
|
87
|
+
0,
|
|
88
|
+
1,
|
|
89
|
+
2,
|
|
90
|
+
3,
|
|
91
|
+
4
|
|
92
|
+
/* Idle */
|
|
93
|
+
]) {
|
|
94
|
+
const r = this.updateQueues.get(t);
|
|
95
|
+
if (!r || r.size === 0) continue;
|
|
96
|
+
const i = Array.from(r);
|
|
97
|
+
r.clear();
|
|
98
|
+
for (const o of i)
|
|
99
|
+
try {
|
|
100
|
+
await this.updateNodeWithRetry(o);
|
|
101
|
+
} catch (u) {
|
|
102
|
+
this.handleReactiveError(
|
|
103
|
+
new E(`Failed to update ${o.type} node ${o.id}`, u, o)
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (this.hasHigherPriorityWork(t))
|
|
107
|
+
return this.flush();
|
|
108
|
+
}
|
|
109
|
+
this.totalUpdateCycles++;
|
|
110
|
+
} finally {
|
|
111
|
+
const t = performance.now();
|
|
112
|
+
this.totalUpdateTime += t - e;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Update node with retry logic
|
|
117
|
+
*/
|
|
118
|
+
async updateNodeWithRetry(e, t = 1) {
|
|
119
|
+
try {
|
|
120
|
+
e.notify();
|
|
121
|
+
} catch (r) {
|
|
122
|
+
if (t < this.maxRetries)
|
|
123
|
+
return console.warn(`Reactive update failed, retrying (${t}/${this.maxRetries})`), await new Promise((i) => setTimeout(i, t * 10)), this.updateNodeWithRetry(e, t + 1);
|
|
124
|
+
throw r;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Schedule flush based on priority
|
|
129
|
+
*/
|
|
130
|
+
scheduleFlush(e) {
|
|
131
|
+
switch (e) {
|
|
132
|
+
case 0:
|
|
133
|
+
this.flush();
|
|
134
|
+
break;
|
|
135
|
+
case 1:
|
|
136
|
+
queueMicrotask(() => this.flush());
|
|
137
|
+
break;
|
|
138
|
+
case 2:
|
|
139
|
+
typeof requestAnimationFrame < "u" ? requestAnimationFrame(() => this.flush()) : queueMicrotask(() => this.flush());
|
|
140
|
+
break;
|
|
141
|
+
case 3:
|
|
142
|
+
case 4:
|
|
143
|
+
typeof requestIdleCallback < "u" ? requestIdleCallback(() => this.flush(), { timeout: 1e3 }) : setTimeout(() => this.flush(), 50);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Check if there's higher priority work waiting
|
|
149
|
+
*/
|
|
150
|
+
hasHigherPriorityWork(e) {
|
|
151
|
+
for (let t = 0; t < e; t++) {
|
|
152
|
+
const r = this.updateQueues.get(t);
|
|
153
|
+
if (r && r.size > 0)
|
|
154
|
+
return !0;
|
|
155
|
+
}
|
|
156
|
+
return !1;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get queue for priority level
|
|
160
|
+
*/
|
|
161
|
+
getQueue(e) {
|
|
162
|
+
const t = this.updateQueues.get(e);
|
|
163
|
+
if (!t)
|
|
164
|
+
throw new Error(`Invalid priority level: ${e}`);
|
|
165
|
+
return t;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Register error handler
|
|
169
|
+
*/
|
|
170
|
+
onError(e) {
|
|
171
|
+
return this.errorHandlers.add(e), () => this.errorHandlers.delete(e);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Handle reactive errors with recovery
|
|
175
|
+
*/
|
|
176
|
+
handleReactiveError(e) {
|
|
177
|
+
this.errorCount++;
|
|
178
|
+
let t = !1;
|
|
179
|
+
for (const r of this.errorHandlers)
|
|
180
|
+
try {
|
|
181
|
+
r(e), t = !0;
|
|
182
|
+
} catch (i) {
|
|
183
|
+
console.error("Error handler threw error:", i);
|
|
184
|
+
}
|
|
185
|
+
if (!t && (console.error("Unhandled reactive error:", e), process.env.NODE_ENV === "development"))
|
|
186
|
+
throw e;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get performance metrics
|
|
190
|
+
*/
|
|
191
|
+
getPerformanceMetrics() {
|
|
192
|
+
let e = 0;
|
|
193
|
+
for (const t of this.updateQueues.values())
|
|
194
|
+
e += t.size;
|
|
195
|
+
return {
|
|
196
|
+
totalNodes: e,
|
|
197
|
+
updateCycles: this.totalUpdateCycles,
|
|
198
|
+
averageUpdateTime: this.totalUpdateCycles > 0 ? this.totalUpdateTime / this.totalUpdateCycles : 0,
|
|
199
|
+
memoryUsage: this.estimateMemoryUsage(),
|
|
200
|
+
errorCount: this.errorCount
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Estimate memory usage (rough approximation)
|
|
205
|
+
*/
|
|
206
|
+
estimateMemoryUsage() {
|
|
207
|
+
let e = 0;
|
|
208
|
+
for (const t of this.updateQueues.values())
|
|
209
|
+
e += t.size * 50;
|
|
210
|
+
return e += this.errorHandlers.size * 100, e;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Check if node is scheduled
|
|
214
|
+
*/
|
|
215
|
+
hasNode(e) {
|
|
216
|
+
for (const t of this.updateQueues.values())
|
|
217
|
+
if (t.has(e))
|
|
218
|
+
return !0;
|
|
219
|
+
return !1;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Flush all pending updates synchronously
|
|
223
|
+
*/
|
|
224
|
+
flushSync() {
|
|
225
|
+
this.isFlushPending && (this.isFlushPending = !1, this.flush());
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Clear all pending updates
|
|
229
|
+
*/
|
|
230
|
+
clearPending() {
|
|
231
|
+
for (const e of this.updateQueues.values())
|
|
232
|
+
e.clear();
|
|
233
|
+
this.isFlushPending = !1;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Cleanup all reactive nodes and destroy scheduler
|
|
237
|
+
*/
|
|
238
|
+
destroy() {
|
|
239
|
+
this.isDestroyed = !0;
|
|
240
|
+
for (const e of this.updateQueues.values()) {
|
|
241
|
+
for (const t of e)
|
|
242
|
+
try {
|
|
243
|
+
t.cleanup();
|
|
244
|
+
} catch (r) {
|
|
245
|
+
console.error("Error cleaning up reactive node:", r);
|
|
246
|
+
}
|
|
247
|
+
e.clear();
|
|
248
|
+
}
|
|
249
|
+
this.updateQueues.clear(), this.errorHandlers.clear(), c.instance = null;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Get debug information
|
|
253
|
+
*/
|
|
254
|
+
getDebugInfo() {
|
|
255
|
+
const e = {};
|
|
256
|
+
for (const [t, r] of this.updateQueues)
|
|
257
|
+
e[h[t]] = r.size;
|
|
258
|
+
return {
|
|
259
|
+
isFlushPending: this.isFlushPending,
|
|
260
|
+
isDestroyed: this.isDestroyed,
|
|
261
|
+
queueSizes: e,
|
|
262
|
+
errorHandlerCount: this.errorHandlers.size,
|
|
263
|
+
performance: this.getPerformanceMetrics()
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
n(m, "instance", null);
|
|
268
|
+
let P = m;
|
|
269
|
+
var S = Object.defineProperty, _ = (s, e, t) => e in s ? S(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, l = (s, e, t) => _(s, typeof e != "symbol" ? e + "" : e, t);
|
|
270
|
+
class F extends b {
|
|
271
|
+
constructor(e, t = {}, r = q()) {
|
|
272
|
+
super(e, r), l(this, "type", "computed"), l(this, "priority"), l(this, "_hasValue", !1), l(this, "_error", null), l(this, "equalsFn"), l(this, "options"), this.priority = t.priority ?? h.Normal, this.equalsFn = t.equals ?? d, this.options = t;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Get the computed value, tracking dependency and lazily computing
|
|
276
|
+
*/
|
|
277
|
+
getValue() {
|
|
278
|
+
const e = C();
|
|
279
|
+
return e && e.state !== a.Disposed && (this.observers.add(e), e.sources.add(this)), (this.state === a.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Get the current value without tracking dependency
|
|
283
|
+
*/
|
|
284
|
+
peek() {
|
|
285
|
+
return (this.state === a.Dirty || !this._hasValue) && (this.execute(), this._hasValue = !0), this.value;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Remove an observer (cleanup)
|
|
289
|
+
*/
|
|
290
|
+
removeObserver(e) {
|
|
291
|
+
this.observers.delete(e), this.options.releaseOnNoObservers === !0 && this.observers.size === 0 && e.state === a.Disposed && this.releaseSources();
|
|
292
|
+
}
|
|
293
|
+
releaseSources() {
|
|
294
|
+
for (const e of this.sources)
|
|
295
|
+
"removeObserver" in e && e.removeObserver(this);
|
|
296
|
+
this.sources.clear(), this._hasValue = !1, this.state = a.Dirty;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Execute the computation and notify observers
|
|
300
|
+
*/
|
|
301
|
+
execute() {
|
|
302
|
+
const e = this._hasValue ? this.value : void 0, t = super.execute();
|
|
303
|
+
if (!this._hasValue || !this.equalsFn(e, t))
|
|
304
|
+
for (const r of this.observers)
|
|
305
|
+
r.state !== a.Disposed && (r.state = a.Dirty, "execute" in r && typeof r.execute == "function" && queueMicrotask(() => {
|
|
306
|
+
r.state === a.Dirty && r.execute();
|
|
307
|
+
}));
|
|
308
|
+
return t;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Notify method for ReactiveNode compatibility
|
|
312
|
+
*/
|
|
313
|
+
notify() {
|
|
314
|
+
this.execute();
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Complete cleanup for memory management
|
|
318
|
+
*/
|
|
319
|
+
cleanup() {
|
|
320
|
+
for (const e of this.sources)
|
|
321
|
+
"removeObserver" in e && e.removeObserver(this);
|
|
322
|
+
this.sources.clear();
|
|
323
|
+
for (const e of this.observers)
|
|
324
|
+
e.sources.delete(this);
|
|
325
|
+
this.observers.clear(), this._hasValue = !1, this._error = null, this.state = a.Disposed;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Dispose the computed value
|
|
329
|
+
*/
|
|
330
|
+
dispose() {
|
|
331
|
+
this.cleanup(), super.dispose();
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Debug information
|
|
335
|
+
*/
|
|
336
|
+
[Symbol.for("tachui.debug")]() {
|
|
337
|
+
return {
|
|
338
|
+
id: this.id,
|
|
339
|
+
type: this.type,
|
|
340
|
+
value: this._hasValue ? this.value : void 0,
|
|
341
|
+
hasValue: this._hasValue,
|
|
342
|
+
error: this._error?.message,
|
|
343
|
+
state: this.state,
|
|
344
|
+
sourceCount: this.sources.size,
|
|
345
|
+
observerCount: this.observers.size,
|
|
346
|
+
priority: h[this.priority],
|
|
347
|
+
debugName: this.options.debugName,
|
|
348
|
+
equalsFn: this.equalsFn.name || "anonymous"
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
toString() {
|
|
352
|
+
return `Computed(${this.options.debugName || this.id}): ${this._hasValue ? this.value : "no value"}`;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function f(s, e) {
|
|
356
|
+
const t = new F(s, e), r = t.getValue.bind(t);
|
|
357
|
+
return r.peek = t.peek.bind(t), Object.defineProperty(r, Symbol.for("tachui.computed"), {
|
|
358
|
+
value: t,
|
|
359
|
+
enumerable: !1
|
|
360
|
+
}), r;
|
|
361
|
+
}
|
|
362
|
+
function H(s, e) {
|
|
363
|
+
return f(s, e);
|
|
364
|
+
}
|
|
365
|
+
function M(s) {
|
|
366
|
+
return typeof s == "function" && Symbol.for("tachui.computed") in s;
|
|
367
|
+
}
|
|
368
|
+
function N(s) {
|
|
369
|
+
return s[Symbol.for("tachui.computed")] || null;
|
|
370
|
+
}
|
|
371
|
+
function T(s) {
|
|
372
|
+
const e = N(s);
|
|
373
|
+
!e || e.observers.size !== 0 || e.releaseSources();
|
|
374
|
+
}
|
|
375
|
+
function $(s, e) {
|
|
376
|
+
return f(e ? () => {
|
|
377
|
+
for (const r of e)
|
|
378
|
+
r();
|
|
379
|
+
return s();
|
|
380
|
+
} : s);
|
|
381
|
+
}
|
|
382
|
+
function U(s, e) {
|
|
383
|
+
let t, r = !1;
|
|
384
|
+
return f(() => (e() && (t = s(), r = !0), r || (t = s(), r = !0), t));
|
|
385
|
+
}
|
|
386
|
+
export {
|
|
387
|
+
E as R,
|
|
388
|
+
h as U,
|
|
389
|
+
H as a,
|
|
390
|
+
I as b,
|
|
391
|
+
f as c,
|
|
392
|
+
z as d,
|
|
393
|
+
A as e,
|
|
394
|
+
x as f,
|
|
395
|
+
Q as g,
|
|
396
|
+
p as h,
|
|
397
|
+
M as i,
|
|
398
|
+
d as j,
|
|
399
|
+
j as k,
|
|
400
|
+
k as l,
|
|
401
|
+
P as m,
|
|
402
|
+
N as n,
|
|
403
|
+
$ as o,
|
|
404
|
+
U as p,
|
|
405
|
+
T as r,
|
|
406
|
+
V as s
|
|
407
|
+
};
|