@tachui/core 0.8.16 → 0.8.18
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/common.js +383 -382
- package/dist/components/index.js +1 -1
- package/dist/components/wrapper.d.ts.map +1 -1
- package/dist/{concatenated-component-BCrw_7cC.js → concatenated-component-2Gzy5e2c.js} +2 -2
- package/dist/essential.js +396 -395
- package/dist/{factory-oMYyVSAY.js → factory-gqfMcmOy.js} +73 -66
- package/dist/index-DL9Cys3t.js +733 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +376 -375
- package/dist/modifiers/builder.js +1 -1
- package/dist/modifiers/index.js +2 -2
- package/dist/modifiers/registry.js +1 -1
- package/dist/{proxy-gO-vDCUZ.js → proxy-Cp0QUXME.js} +1 -1
- package/dist/runtime/dom-bridge.js +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/renderer.js +1 -1
- package/dist/utils/sanitize-svg.d.ts +2 -0
- package/dist/utils/sanitize-svg.d.ts.map +1 -0
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/dist/index-BaBj0d3d.js +0 -618
|
@@ -0,0 +1,733 @@
|
|
|
1
|
+
import { infinity as c } from "./constants/layout.js";
|
|
2
|
+
import { LayoutModifier as m } from "./modifiers/base.js";
|
|
3
|
+
import { y as h, t as z, h as M } from "./concatenated-component-2Gzy5e2c.js";
|
|
4
|
+
import { g as O, a as N } from "./proxy-Cp0QUXME.js";
|
|
5
|
+
import "./assets/index.js";
|
|
6
|
+
import "./scheduler-DppMK9mR.js";
|
|
7
|
+
import "./theme-CRLPHryV.js";
|
|
8
|
+
import "@tachui/types/reactive";
|
|
9
|
+
import "@tachui/types/modifiers";
|
|
10
|
+
import "typescript";
|
|
11
|
+
import "@tachui/registry";
|
|
12
|
+
import "./presets-B9x94uRn.js";
|
|
13
|
+
import "./component-D-O9yq0P.js";
|
|
14
|
+
import "./hooks-WGmpzYgD.js";
|
|
15
|
+
import "./runtime/dom-bridge.js";
|
|
16
|
+
import "./component-base-C41K3NTe.js";
|
|
17
|
+
import "@tachui/types/gradients";
|
|
18
|
+
import "./index-JQ1sW1SK.js";
|
|
19
|
+
import "./plugins/index.js";
|
|
20
|
+
import "./state/index.js";
|
|
21
|
+
import "./validation/index.js";
|
|
22
|
+
function st() {
|
|
23
|
+
return new m({
|
|
24
|
+
frame: {
|
|
25
|
+
maxWidth: c
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function ct() {
|
|
30
|
+
return new m({
|
|
31
|
+
frame: {
|
|
32
|
+
maxHeight: c
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function mt() {
|
|
37
|
+
return new m({
|
|
38
|
+
frame: {
|
|
39
|
+
maxWidth: c,
|
|
40
|
+
maxHeight: c
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function lt() {
|
|
45
|
+
return new m({
|
|
46
|
+
frame: {
|
|
47
|
+
width: c,
|
|
48
|
+
height: c
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function ut(r) {
|
|
53
|
+
return new m({
|
|
54
|
+
frame: {
|
|
55
|
+
width: r,
|
|
56
|
+
maxHeight: c
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function dt(r) {
|
|
61
|
+
return new m({
|
|
62
|
+
frame: {
|
|
63
|
+
height: r,
|
|
64
|
+
maxWidth: c
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function pt(r, t) {
|
|
69
|
+
return new m({
|
|
70
|
+
frame: {
|
|
71
|
+
width: c,
|
|
72
|
+
height: c,
|
|
73
|
+
maxWidth: r,
|
|
74
|
+
maxHeight: t
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function ft(r, t, e, n) {
|
|
79
|
+
return new m({
|
|
80
|
+
frame: {
|
|
81
|
+
width: c,
|
|
82
|
+
height: c,
|
|
83
|
+
minWidth: r,
|
|
84
|
+
maxWidth: t,
|
|
85
|
+
minHeight: e,
|
|
86
|
+
maxHeight: n
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function ht() {
|
|
91
|
+
return new m({
|
|
92
|
+
frame: {
|
|
93
|
+
maxWidth: c,
|
|
94
|
+
maxHeight: c
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function gt() {
|
|
99
|
+
return new m({
|
|
100
|
+
frame: {
|
|
101
|
+
width: "100vw",
|
|
102
|
+
height: "100vh"
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
function yt() {
|
|
107
|
+
return new m({
|
|
108
|
+
frame: {
|
|
109
|
+
width: c,
|
|
110
|
+
height: c
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function xt() {
|
|
115
|
+
return new m({
|
|
116
|
+
frame: {
|
|
117
|
+
width: c
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const w = "http://www.w3.org/2000/svg", k = /* @__PURE__ */ new Set([
|
|
122
|
+
"svg",
|
|
123
|
+
"g",
|
|
124
|
+
"path",
|
|
125
|
+
"circle",
|
|
126
|
+
"rect",
|
|
127
|
+
"ellipse",
|
|
128
|
+
"line",
|
|
129
|
+
"polyline",
|
|
130
|
+
"polygon",
|
|
131
|
+
"text",
|
|
132
|
+
"tspan",
|
|
133
|
+
"defs",
|
|
134
|
+
"clippath",
|
|
135
|
+
"mask",
|
|
136
|
+
"symbol",
|
|
137
|
+
"use",
|
|
138
|
+
"lineargradient",
|
|
139
|
+
"radialgradient",
|
|
140
|
+
"stop"
|
|
141
|
+
]), v = /* @__PURE__ */ new Set(["script", "foreignobject", "style"]), A = /* @__PURE__ */ new Set([
|
|
142
|
+
"viewbox",
|
|
143
|
+
"d",
|
|
144
|
+
"fill",
|
|
145
|
+
"stroke",
|
|
146
|
+
"stroke-width",
|
|
147
|
+
"stroke-linecap",
|
|
148
|
+
"stroke-linejoin",
|
|
149
|
+
"width",
|
|
150
|
+
"height",
|
|
151
|
+
"cx",
|
|
152
|
+
"cy",
|
|
153
|
+
"r",
|
|
154
|
+
"rx",
|
|
155
|
+
"ry",
|
|
156
|
+
"x",
|
|
157
|
+
"y",
|
|
158
|
+
"x1",
|
|
159
|
+
"y1",
|
|
160
|
+
"x2",
|
|
161
|
+
"y2",
|
|
162
|
+
"points",
|
|
163
|
+
"transform",
|
|
164
|
+
"opacity",
|
|
165
|
+
"clip-path",
|
|
166
|
+
"mask",
|
|
167
|
+
"filter",
|
|
168
|
+
"gradientunits",
|
|
169
|
+
"gradienttransform",
|
|
170
|
+
"offset",
|
|
171
|
+
"stop-color",
|
|
172
|
+
"stop-opacity",
|
|
173
|
+
"id",
|
|
174
|
+
"class",
|
|
175
|
+
"preserveaspectratio",
|
|
176
|
+
"href",
|
|
177
|
+
"xlink:href",
|
|
178
|
+
"xmlns:xlink"
|
|
179
|
+
]);
|
|
180
|
+
function L(r) {
|
|
181
|
+
return r.replace(/<\?[\s\S]*?\?>/g, "").replace(/<!DOCTYPE[\s\S]*?>/gi, "").replace(/<!ENTITY[\s\S]*?>/gi, "");
|
|
182
|
+
}
|
|
183
|
+
function _(r) {
|
|
184
|
+
const t = r.toLowerCase().replace(/[\u0000-\u0020]+/g, "");
|
|
185
|
+
return t.includes("javascript:") || t.includes("data:");
|
|
186
|
+
}
|
|
187
|
+
function R(r) {
|
|
188
|
+
const t = r.trim();
|
|
189
|
+
return /^#[A-Za-z_][\w:.-]*$/.test(t);
|
|
190
|
+
}
|
|
191
|
+
function P(r) {
|
|
192
|
+
return !!r.trim().match(/^url\((["']?)(#[A-Za-z_][\w:.-]*)\1\)$/);
|
|
193
|
+
}
|
|
194
|
+
function D(r, t) {
|
|
195
|
+
const e = r.toLowerCase();
|
|
196
|
+
if (A.has(e) && !e.startsWith("on") && !_(t))
|
|
197
|
+
return e === "href" || e === "xlink:href" ? R(t) ? t.trim() : void 0 : t.includes("url(") ? P(t) ? t.trim() : void 0 : t;
|
|
198
|
+
}
|
|
199
|
+
function E(r, t) {
|
|
200
|
+
const e = r.tagName.toLowerCase();
|
|
201
|
+
if (v.has(e))
|
|
202
|
+
return [];
|
|
203
|
+
if (!k.has(e)) {
|
|
204
|
+
const i = [];
|
|
205
|
+
for (const o of r.childNodes)
|
|
206
|
+
i.push(...C(o, t));
|
|
207
|
+
return i;
|
|
208
|
+
}
|
|
209
|
+
const n = t.createElementNS(w, r.tagName);
|
|
210
|
+
for (const i of r.getAttributeNames()) {
|
|
211
|
+
const o = r.getAttribute(i);
|
|
212
|
+
if (o === null) continue;
|
|
213
|
+
const a = D(i, o);
|
|
214
|
+
a !== void 0 && n.setAttribute(i, a);
|
|
215
|
+
}
|
|
216
|
+
for (const i of r.childNodes) {
|
|
217
|
+
const o = C(i, t);
|
|
218
|
+
for (const a of o)
|
|
219
|
+
n.appendChild(a);
|
|
220
|
+
}
|
|
221
|
+
return [n];
|
|
222
|
+
}
|
|
223
|
+
function C(r, t) {
|
|
224
|
+
return r.nodeType === Node.ELEMENT_NODE ? E(r, t) : r.nodeType === Node.TEXT_NODE ? [t.createTextNode(r.textContent ?? "")] : [];
|
|
225
|
+
}
|
|
226
|
+
function St(r) {
|
|
227
|
+
if (typeof r != "string" || r.trim() === "") return "";
|
|
228
|
+
const n = new DOMParser().parseFromString(L(r), "image/svg+xml").documentElement;
|
|
229
|
+
if (!n || n.tagName.toLowerCase() !== "svg") return "";
|
|
230
|
+
const i = document.implementation.createDocument(w, "svg", null), a = E(n, i).find(
|
|
231
|
+
(s) => s.nodeType === Node.ELEMENT_NODE
|
|
232
|
+
);
|
|
233
|
+
return !a || a.tagName.toLowerCase() !== "svg" ? "" : (i.replaceChild(a, i.documentElement), new XMLSerializer().serializeToString(i.documentElement));
|
|
234
|
+
}
|
|
235
|
+
const Ct = Symbol.for("tachui.concat");
|
|
236
|
+
function bt(r) {
|
|
237
|
+
return r && typeof r == "object" && typeof r.isConcatenatable == "function" && r.isConcatenatable();
|
|
238
|
+
}
|
|
239
|
+
function Tt(r) {
|
|
240
|
+
return r && typeof r == "object" && r.constructor.name === "ConcatenatedComponent";
|
|
241
|
+
}
|
|
242
|
+
const wt = Symbol.for("tachui.concat");
|
|
243
|
+
class Et {
|
|
244
|
+
/**
|
|
245
|
+
* Concatenate this component with another concatenatable component
|
|
246
|
+
*/
|
|
247
|
+
concat(t) {
|
|
248
|
+
const e = this.toSegment(), n = t.toSegment();
|
|
249
|
+
return t instanceof h ? new h(
|
|
250
|
+
[e, ...t.segments],
|
|
251
|
+
this.mergeMetadata(t.metadata, t.segments.length + 1)
|
|
252
|
+
) : new h(
|
|
253
|
+
[e, n],
|
|
254
|
+
this.createMetadata(2)
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Check if this component supports concatenation
|
|
259
|
+
*/
|
|
260
|
+
isConcatenatable() {
|
|
261
|
+
return !0;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Create metadata for a new concatenated component
|
|
265
|
+
*/
|
|
266
|
+
createMetadata(t) {
|
|
267
|
+
return {
|
|
268
|
+
totalSegments: t,
|
|
269
|
+
accessibilityRole: this.determineAccessibilityRole(),
|
|
270
|
+
semanticStructure: this.determineSemanticStructure()
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Merge metadata when concatenating with existing concatenated component
|
|
275
|
+
*/
|
|
276
|
+
mergeMetadata(t, e) {
|
|
277
|
+
return {
|
|
278
|
+
totalSegments: e,
|
|
279
|
+
accessibilityRole: this.mergeAccessibilityRoles(t.accessibilityRole),
|
|
280
|
+
semanticStructure: this.mergeSemanticStructures(t.semanticStructure)
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Determine the accessibility role for this component
|
|
285
|
+
*/
|
|
286
|
+
determineAccessibilityRole() {
|
|
287
|
+
const t = this.constructor.name;
|
|
288
|
+
return t === "EnhancedText" ? "text" : t === "EnhancedImage" || t === "EnhancedButton" || t === "EnhancedLink" ? "group" : "composite";
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Determine the semantic structure for this component
|
|
292
|
+
*/
|
|
293
|
+
determineSemanticStructure() {
|
|
294
|
+
const t = this.constructor.name;
|
|
295
|
+
return t === "EnhancedText" || t === "EnhancedImage" ? "inline" : "mixed";
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Merge accessibility roles when combining components
|
|
299
|
+
*/
|
|
300
|
+
mergeAccessibilityRoles(t) {
|
|
301
|
+
const e = this.determineAccessibilityRole();
|
|
302
|
+
return e === "text" && t === "text" ? "text" : e === "composite" || t === "composite" ? "composite" : "group";
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Merge semantic structures when combining components
|
|
306
|
+
*/
|
|
307
|
+
mergeSemanticStructures(t) {
|
|
308
|
+
const e = this.determineSemanticStructure();
|
|
309
|
+
return e === "inline" && t === "inline" ? "inline" : e === "block" && t === "block" ? "block" : "mixed";
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function zt(r) {
|
|
313
|
+
const t = r;
|
|
314
|
+
return t.concat = function(e) {
|
|
315
|
+
const n = {
|
|
316
|
+
id: this.id,
|
|
317
|
+
component: this,
|
|
318
|
+
modifiers: this.modifiers || [],
|
|
319
|
+
render: () => {
|
|
320
|
+
const o = this.render();
|
|
321
|
+
return Array.isArray(o) ? o[0] : o;
|
|
322
|
+
}
|
|
323
|
+
}, i = e.toSegment();
|
|
324
|
+
return e instanceof h ? new h(
|
|
325
|
+
[n, ...e.segments],
|
|
326
|
+
{
|
|
327
|
+
totalSegments: e.segments.length + 1,
|
|
328
|
+
accessibilityRole: "group",
|
|
329
|
+
semanticStructure: "mixed"
|
|
330
|
+
}
|
|
331
|
+
) : new h(
|
|
332
|
+
[n, i],
|
|
333
|
+
{
|
|
334
|
+
totalSegments: 2,
|
|
335
|
+
accessibilityRole: "group",
|
|
336
|
+
semanticStructure: "mixed"
|
|
337
|
+
}
|
|
338
|
+
);
|
|
339
|
+
}, t.toSegment = function() {
|
|
340
|
+
return {
|
|
341
|
+
id: this.id,
|
|
342
|
+
component: this,
|
|
343
|
+
modifiers: this.modifiers || [],
|
|
344
|
+
render: () => {
|
|
345
|
+
const e = this.render();
|
|
346
|
+
return Array.isArray(e) ? e[0] : e;
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}, t.isConcatenatable = function() {
|
|
350
|
+
return !0;
|
|
351
|
+
}, t;
|
|
352
|
+
}
|
|
353
|
+
const u = /* @__PURE__ */ new Map(), H = 300 * 1e3, b = 100;
|
|
354
|
+
class Mt {
|
|
355
|
+
/**
|
|
356
|
+
* Optimize an array of segments by merging compatible adjacent text segments
|
|
357
|
+
* Enhanced with caching and performance monitoring
|
|
358
|
+
*/
|
|
359
|
+
static optimize(t) {
|
|
360
|
+
const e = performance.now();
|
|
361
|
+
if (t.length < 2) return t;
|
|
362
|
+
const n = this.generateCacheKey(t), i = this.getCachedOptimization(n);
|
|
363
|
+
if (i)
|
|
364
|
+
return i.optimizedSegments;
|
|
365
|
+
const o = this.performOptimization(t), a = performance.now() - e, s = {
|
|
366
|
+
...this.getOptimizationStats(t, o),
|
|
367
|
+
processingTimeMs: a
|
|
368
|
+
};
|
|
369
|
+
return this.cacheOptimization(n, o, s), process.env.NODE_ENV === "development" && a > 5 && console.log(`TachUI Concatenation: Optimization took ${a.toFixed(2)}ms for ${t.length} segments`), o;
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Core optimization algorithm separated for clarity
|
|
373
|
+
*/
|
|
374
|
+
static performOptimization(t) {
|
|
375
|
+
const e = [];
|
|
376
|
+
for (const n of t) {
|
|
377
|
+
const i = e[e.length - 1];
|
|
378
|
+
i && this.canMergeTextSegments(i, n) ? e[e.length - 1] = this.mergeTextSegments(i, n) : e.push(n);
|
|
379
|
+
}
|
|
380
|
+
return e;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Generate a cache key from segments
|
|
384
|
+
*/
|
|
385
|
+
static generateCacheKey(t) {
|
|
386
|
+
return t.map((n) => {
|
|
387
|
+
const i = n.component, o = this.extractTextContent(i), a = this.hashModifiers(n.modifiers);
|
|
388
|
+
return `${i.constructor.name}:${o}:${a}`;
|
|
389
|
+
}).join("|");
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Hash modifiers for cache key generation
|
|
393
|
+
*/
|
|
394
|
+
static hashModifiers(t) {
|
|
395
|
+
if (t.length === 0) return "none";
|
|
396
|
+
try {
|
|
397
|
+
const e = t.map((i) => ({
|
|
398
|
+
type: i.type,
|
|
399
|
+
props: i.properties
|
|
400
|
+
})), n = JSON.stringify(e);
|
|
401
|
+
return typeof btoa == "function" ? btoa(n).substring(0, 8) : this.simpleHash(n).toString(16).substring(0, 8);
|
|
402
|
+
} catch {
|
|
403
|
+
return "hash-error";
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Simple hash function fallback for environments without btoa
|
|
408
|
+
*/
|
|
409
|
+
static simpleHash(t) {
|
|
410
|
+
let e = 0;
|
|
411
|
+
for (let n = 0; n < t.length; n++) {
|
|
412
|
+
const i = t.charCodeAt(n);
|
|
413
|
+
e = (e << 5) - e + i, e = e & e;
|
|
414
|
+
}
|
|
415
|
+
return Math.abs(e);
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Get cached optimization result
|
|
419
|
+
*/
|
|
420
|
+
static getCachedOptimization(t) {
|
|
421
|
+
const e = u.get(t);
|
|
422
|
+
return e ? Date.now() - e.timestamp > H ? (u.delete(t), null) : e : null;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Cache optimization result
|
|
426
|
+
*/
|
|
427
|
+
static cacheOptimization(t, e, n) {
|
|
428
|
+
if (u.size >= b) {
|
|
429
|
+
const i = u.keys().next().value;
|
|
430
|
+
i && u.delete(i);
|
|
431
|
+
}
|
|
432
|
+
u.set(t, {
|
|
433
|
+
optimizedSegments: e,
|
|
434
|
+
stats: n,
|
|
435
|
+
timestamp: Date.now()
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Clear optimization cache (useful for testing)
|
|
440
|
+
*/
|
|
441
|
+
static clearCache() {
|
|
442
|
+
u.clear();
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Get cache statistics
|
|
446
|
+
*/
|
|
447
|
+
static getCacheStats() {
|
|
448
|
+
return {
|
|
449
|
+
size: u.size,
|
|
450
|
+
maxSize: b,
|
|
451
|
+
hitRate: 0
|
|
452
|
+
// Would need to track hits/misses to calculate this
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Check if two segments can be merged
|
|
457
|
+
*/
|
|
458
|
+
static canMergeTextSegments(t, e) {
|
|
459
|
+
return t.component.constructor.name !== "EnhancedText" || e.component.constructor.name !== "EnhancedText" ? !1 : this.modifiersCompatible(t.modifiers, e.modifiers);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Check if two modifier arrays are compatible for merging
|
|
463
|
+
*/
|
|
464
|
+
static modifiersCompatible(t, e) {
|
|
465
|
+
if (t.length !== e.length) return !1;
|
|
466
|
+
for (let n = 0; n < t.length; n++)
|
|
467
|
+
if (!this.modifierEqual(t[n], e[n]))
|
|
468
|
+
return !1;
|
|
469
|
+
return !0;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Check if two modifiers are equal (simplified comparison)
|
|
473
|
+
*/
|
|
474
|
+
static modifierEqual(t, e) {
|
|
475
|
+
if (t.type !== e.type) return !1;
|
|
476
|
+
try {
|
|
477
|
+
return JSON.stringify(t.properties) === JSON.stringify(e.properties);
|
|
478
|
+
} catch {
|
|
479
|
+
return !1;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Merge two text segments into a single segment
|
|
484
|
+
*/
|
|
485
|
+
static mergeTextSegments(t, e) {
|
|
486
|
+
const n = t.component, i = e.component, o = this.extractTextContent(n), a = this.extractTextContent(i), s = o + a;
|
|
487
|
+
return {
|
|
488
|
+
id: `merged-${t.id}-${e.id}`,
|
|
489
|
+
component: this.createMergedTextComponent(s, n.props, t.modifiers),
|
|
490
|
+
modifiers: t.modifiers,
|
|
491
|
+
// Use modifiers from first segment (they're identical)
|
|
492
|
+
render: () => this.createMergedTextComponent(s, n.props, t.modifiers).render()[0]
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Extract text content from a text component
|
|
497
|
+
*/
|
|
498
|
+
static extractTextContent(t) {
|
|
499
|
+
const e = t.props?.content;
|
|
500
|
+
return typeof e == "string" ? e : typeof e == "function" ? e() : e && typeof e == "object" && "peek" in e && e.peek() || "";
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Create a new merged text component
|
|
504
|
+
*/
|
|
505
|
+
static createMergedTextComponent(t, e, n) {
|
|
506
|
+
const i = {
|
|
507
|
+
...e,
|
|
508
|
+
content: t
|
|
509
|
+
};
|
|
510
|
+
return {
|
|
511
|
+
type: "Text",
|
|
512
|
+
id: `merged-text-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
|
|
513
|
+
props: i,
|
|
514
|
+
mounted: !1,
|
|
515
|
+
cleanup: [],
|
|
516
|
+
modifiers: n,
|
|
517
|
+
render() {
|
|
518
|
+
const o = z(t);
|
|
519
|
+
return [M("span", {}, o)];
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Analyze segments and determine if optimization would be beneficial
|
|
525
|
+
*/
|
|
526
|
+
static shouldOptimize(t) {
|
|
527
|
+
if (t.length < 2) return !1;
|
|
528
|
+
let e = 0;
|
|
529
|
+
for (let n = 0; n < t.length - 1; n++) {
|
|
530
|
+
const i = t[n], o = t[n + 1];
|
|
531
|
+
i.component.constructor.name === "EnhancedText" && o.component.constructor.name === "EnhancedText" && e++;
|
|
532
|
+
}
|
|
533
|
+
return e > 0;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Get optimization statistics (enhanced for Phase 4.1)
|
|
537
|
+
*/
|
|
538
|
+
static getOptimizationStats(t, e) {
|
|
539
|
+
const n = t.length - e.length, i = t.length > 0 ? Math.round(n / t.length * 100) : 0;
|
|
540
|
+
return {
|
|
541
|
+
originalCount: t.length,
|
|
542
|
+
optimizedCount: e.length,
|
|
543
|
+
reductionPercent: i,
|
|
544
|
+
textSegmentsMerged: n
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Advanced optimization analysis for performance monitoring
|
|
549
|
+
*/
|
|
550
|
+
static analyzeOptimizationOpportunities(t) {
|
|
551
|
+
let e = 0, n = 0, i = 0, o = 0;
|
|
552
|
+
for (let s = 0; s < t.length; s++) {
|
|
553
|
+
const l = t[s];
|
|
554
|
+
switch (l.component.constructor.name) {
|
|
555
|
+
case "EnhancedText":
|
|
556
|
+
if (e++, s < t.length - 1) {
|
|
557
|
+
const f = t[s + 1];
|
|
558
|
+
this.canMergeTextSegments(l, f) && o++;
|
|
559
|
+
}
|
|
560
|
+
break;
|
|
561
|
+
case "EnhancedImage":
|
|
562
|
+
n++;
|
|
563
|
+
break;
|
|
564
|
+
case "EnhancedButton":
|
|
565
|
+
case "EnhancedLinkComponent":
|
|
566
|
+
i++;
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
const a = t.length > 0 ? Math.round(o / t.length * 100) : 0;
|
|
571
|
+
return {
|
|
572
|
+
totalSegments: t.length,
|
|
573
|
+
textSegments: e,
|
|
574
|
+
imageSegments: n,
|
|
575
|
+
interactiveSegments: i,
|
|
576
|
+
optimizableTextPairs: o,
|
|
577
|
+
estimatedReductionPercent: a
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
function S(r, t = {}) {
|
|
582
|
+
const { fallback: e, errorFallback: n, timeout: i = 1e4, preload: o = "never" } = t;
|
|
583
|
+
let a = !1, s = null, l = !1, p = null, f = null;
|
|
584
|
+
const y = async () => {
|
|
585
|
+
a || l || s || f || (a = !0, l = !0, p = null, f = (async () => {
|
|
586
|
+
try {
|
|
587
|
+
const d = await Promise.race([
|
|
588
|
+
r(),
|
|
589
|
+
new Promise(
|
|
590
|
+
(g, x) => setTimeout(() => x(new Error("Component load timeout")), i)
|
|
591
|
+
)
|
|
592
|
+
]);
|
|
593
|
+
s = "default" in d ? d.default : d;
|
|
594
|
+
} catch (d) {
|
|
595
|
+
const g = d;
|
|
596
|
+
(typeof process > "u" || process.env.NODE_ENV !== "test") && console.error("Failed to load lazy component:", g), p = g;
|
|
597
|
+
} finally {
|
|
598
|
+
l = !1, f = null;
|
|
599
|
+
}
|
|
600
|
+
})(), await f);
|
|
601
|
+
};
|
|
602
|
+
return o === "idle" && typeof requestIdleCallback < "u" ? requestIdleCallback(() => {
|
|
603
|
+
y().catch(() => {
|
|
604
|
+
});
|
|
605
|
+
}) : o === "idle" ? setTimeout(() => {
|
|
606
|
+
y().catch(() => {
|
|
607
|
+
});
|
|
608
|
+
}, 100) : o === "immediate" && y().catch(() => {
|
|
609
|
+
}), (d) => {
|
|
610
|
+
if (!a && !l && !s && y().catch(() => {
|
|
611
|
+
}), p)
|
|
612
|
+
return n ? n(p) : T(p);
|
|
613
|
+
if (l || !s)
|
|
614
|
+
return e || j();
|
|
615
|
+
try {
|
|
616
|
+
return typeof s == "function" ? s(d) : s;
|
|
617
|
+
} catch (g) {
|
|
618
|
+
const x = g;
|
|
619
|
+
return (typeof process > "u" || process.env.NODE_ENV !== "test") && console.error("Error rendering lazy component:", x), T(x);
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
function Ot(r) {
|
|
624
|
+
return {
|
|
625
|
+
type: "component",
|
|
626
|
+
render: () => ({
|
|
627
|
+
type: "element",
|
|
628
|
+
tag: "div",
|
|
629
|
+
props: { class: "tachui-suspense" },
|
|
630
|
+
children: r.children.map(() => ({
|
|
631
|
+
type: "element",
|
|
632
|
+
tag: "div",
|
|
633
|
+
children: []
|
|
634
|
+
}))
|
|
635
|
+
}),
|
|
636
|
+
props: r,
|
|
637
|
+
id: `suspense-${Math.random().toString(36).substr(2, 9)}`
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
function $(r) {
|
|
641
|
+
return r().then((t) => t && typeof t == "object" && "default" in t ? t.default : t);
|
|
642
|
+
}
|
|
643
|
+
function Nt(r, t = {}) {
|
|
644
|
+
const e = {};
|
|
645
|
+
for (const [n, i] of Object.entries(r))
|
|
646
|
+
e[n] = S(i, t);
|
|
647
|
+
return e;
|
|
648
|
+
}
|
|
649
|
+
function kt(r) {
|
|
650
|
+
const t = Object.entries(r).map(
|
|
651
|
+
async ([e, n]) => [e, await $(n)]
|
|
652
|
+
);
|
|
653
|
+
return Promise.all(t).then((e) => {
|
|
654
|
+
const n = {};
|
|
655
|
+
for (const [i, o] of e)
|
|
656
|
+
n[i] = o;
|
|
657
|
+
return n;
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
function j() {
|
|
661
|
+
return {
|
|
662
|
+
type: "element",
|
|
663
|
+
tag: "div",
|
|
664
|
+
props: {
|
|
665
|
+
class: "tachui-lazy-loading",
|
|
666
|
+
style: "padding: 16px; color: #666; text-align: center;"
|
|
667
|
+
},
|
|
668
|
+
children: [
|
|
669
|
+
{
|
|
670
|
+
type: "text",
|
|
671
|
+
text: "Loading component..."
|
|
672
|
+
}
|
|
673
|
+
]
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function T(r) {
|
|
677
|
+
return {
|
|
678
|
+
type: "element",
|
|
679
|
+
tag: "div",
|
|
680
|
+
props: {
|
|
681
|
+
class: "tachui-lazy-error",
|
|
682
|
+
style: "padding: 16px; color: #d32f2f; border: 1px solid #d32f2f; border-radius: 4px; background: #ffeaea;"
|
|
683
|
+
},
|
|
684
|
+
children: [
|
|
685
|
+
{
|
|
686
|
+
type: "text",
|
|
687
|
+
text: `Failed to load component: ${r.message}`
|
|
688
|
+
}
|
|
689
|
+
]
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
function vt(r, t = {}) {
|
|
693
|
+
const { rootMargin: e = "50px", threshold: n = 0.1, ...i } = t;
|
|
694
|
+
return i.preload === "visible" && typeof IntersectionObserver < "u" ? (o) => {
|
|
695
|
+
const a = S(r, { ...i, preload: "never" });
|
|
696
|
+
return setTimeout(() => {
|
|
697
|
+
a(o);
|
|
698
|
+
}, 100), a(o);
|
|
699
|
+
} : S(r, i);
|
|
700
|
+
}
|
|
701
|
+
const At = Object.freeze({
|
|
702
|
+
configure: N,
|
|
703
|
+
getFeatureFlags: O
|
|
704
|
+
});
|
|
705
|
+
export {
|
|
706
|
+
Ct as C,
|
|
707
|
+
Ot as S,
|
|
708
|
+
Mt as T,
|
|
709
|
+
Tt as a,
|
|
710
|
+
Et as b,
|
|
711
|
+
wt as c,
|
|
712
|
+
ct as d,
|
|
713
|
+
mt as e,
|
|
714
|
+
st as f,
|
|
715
|
+
lt as g,
|
|
716
|
+
ut as h,
|
|
717
|
+
bt as i,
|
|
718
|
+
dt as j,
|
|
719
|
+
pt as k,
|
|
720
|
+
ht as l,
|
|
721
|
+
zt as m,
|
|
722
|
+
gt as n,
|
|
723
|
+
yt as o,
|
|
724
|
+
xt as p,
|
|
725
|
+
Nt as q,
|
|
726
|
+
ft as r,
|
|
727
|
+
St as s,
|
|
728
|
+
At as t,
|
|
729
|
+
vt as u,
|
|
730
|
+
S as v,
|
|
731
|
+
$ as w,
|
|
732
|
+
kt as x
|
|
733
|
+
};
|