@nonoun/native-ai 1.0.9 → 1.0.12
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/a2ui/a2ui-element.d.ts.map +1 -1
- package/dist/a2ui/protocol/a2ui-adapter.d.ts +2 -0
- package/dist/a2ui/protocol/a2ui-adapter.d.ts.map +1 -1
- package/dist/a2ui/protocol/a2ui-component-map.d.ts +41 -15
- package/dist/a2ui/protocol/a2ui-component-map.d.ts.map +1 -1
- package/dist/a2ui/protocol/a2ui-converter.d.ts +3 -0
- package/dist/a2ui/protocol/a2ui-converter.d.ts.map +1 -1
- package/dist/a2ui/protocol/a2ui-surface.d.ts +4 -3
- package/dist/a2ui/protocol/a2ui-surface.d.ts.map +1 -1
- package/dist/a2ui/protocol/index.d.ts +2 -2
- package/dist/a2ui/protocol/index.d.ts.map +1 -1
- package/dist/chat/message/chat-input-structured-element.d.ts.map +1 -1
- package/dist/chat/message/chat-message-genui-element.d.ts +1 -1
- package/dist/chat/message/chat-message-seed-element.d.ts.map +1 -1
- package/dist/native-ai.css +21 -40
- package/dist/native-ai.js +849 -637
- package/dist/register.js +895 -683
- package/package.json +1 -1
package/dist/native-ai.js
CHANGED
|
@@ -20,23 +20,23 @@ function T(e) {
|
|
|
20
20
|
function E(e) {
|
|
21
21
|
return "deleteSurface" in e;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function D(e) {
|
|
24
24
|
return "requestCatalog" in e;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function ee(e) {
|
|
27
27
|
return "action" in e;
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function te(e) {
|
|
30
30
|
return "error" in e;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function ne(e) {
|
|
33
33
|
return "catalog" in e;
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Parse a raw JSON string into a typed A2UI server message.
|
|
37
37
|
* Returns null if the JSON is not a valid A2UI message.
|
|
38
38
|
*/
|
|
39
|
-
function
|
|
39
|
+
function O(e) {
|
|
40
40
|
try {
|
|
41
41
|
let t = JSON.parse(e);
|
|
42
42
|
return "createSurface" in t || "updateComponents" in t || "updateDataModel" in t || "deleteSurface" in t || "requestCatalog" in t ? t : null;
|
|
@@ -44,11 +44,126 @@ function D(e) {
|
|
|
44
44
|
return null;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
47
|
+
/**
|
|
48
|
+
* A2UI Component Map
|
|
49
|
+
*
|
|
50
|
+
* Bidirectional mapping between A2UI abstract component types
|
|
51
|
+
* and native-ui concrete HTML/custom element tags.
|
|
52
|
+
*
|
|
53
|
+
* The `ComponentRegistry` class provides a mutable registry with
|
|
54
|
+
* change tracking via a signal. The default singleton (`defaultRegistry`)
|
|
55
|
+
* preserves backward compatibility with existing free-function imports.
|
|
56
|
+
*/
|
|
57
|
+
var re = class e {
|
|
58
|
+
#e = /* @__PURE__ */ new Map();
|
|
59
|
+
#t = /* @__PURE__ */ new Map();
|
|
60
|
+
#n = /* @__PURE__ */ new Map();
|
|
61
|
+
#r;
|
|
62
|
+
constructor(e, t) {
|
|
63
|
+
this.#r = d(0);
|
|
64
|
+
for (let t of e) this.#i(t);
|
|
65
|
+
if (t) for (let [e, n] of Object.entries(t)) this.#n.set(e, n);
|
|
66
|
+
}
|
|
67
|
+
get version() {
|
|
68
|
+
return this.#r;
|
|
69
|
+
}
|
|
70
|
+
get(e) {
|
|
71
|
+
return this.#e.get(e);
|
|
72
|
+
}
|
|
73
|
+
has(e) {
|
|
74
|
+
return this.#e.has(e);
|
|
75
|
+
}
|
|
76
|
+
get size() {
|
|
77
|
+
return this.#e.size;
|
|
78
|
+
}
|
|
79
|
+
keys() {
|
|
80
|
+
return this.#e.keys();
|
|
81
|
+
}
|
|
82
|
+
values() {
|
|
83
|
+
return this.#e.values();
|
|
84
|
+
}
|
|
85
|
+
entries() {
|
|
86
|
+
return this.#e.entries();
|
|
87
|
+
}
|
|
88
|
+
forEach(e) {
|
|
89
|
+
this.#e.forEach(e);
|
|
90
|
+
}
|
|
91
|
+
[Symbol.iterator]() {
|
|
92
|
+
return this.#e[Symbol.iterator]();
|
|
93
|
+
}
|
|
94
|
+
add(e, t = !0) {
|
|
95
|
+
this.#i(e), t && this.#r.value++;
|
|
96
|
+
}
|
|
97
|
+
update(e, t) {
|
|
98
|
+
let n = this.#e.get(e);
|
|
99
|
+
if (!n) return;
|
|
100
|
+
let r = {
|
|
101
|
+
...n,
|
|
102
|
+
...t
|
|
103
|
+
};
|
|
104
|
+
this.#e.set(e, r), this.#a(), this.#r.value++;
|
|
105
|
+
}
|
|
106
|
+
remove(e) {
|
|
107
|
+
this.#e.has(e) && (this.#e.delete(e), this.#n.delete(e), this.#a(), this.#r.value++);
|
|
108
|
+
}
|
|
109
|
+
setCategory(e, t) {
|
|
110
|
+
this.#n.set(e, t), this.#r.value++;
|
|
111
|
+
}
|
|
112
|
+
toJSON() {
|
|
113
|
+
let e = Array.from(this.#e.values()), t = {};
|
|
114
|
+
for (let [e, n] of this.#n) t[e] = n;
|
|
115
|
+
return {
|
|
116
|
+
mappings: e,
|
|
117
|
+
categories: t
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
static fromJSON(t) {
|
|
121
|
+
return new e(t.mappings, t.categories);
|
|
122
|
+
}
|
|
123
|
+
clone() {
|
|
124
|
+
return e.fromJSON(this.toJSON());
|
|
125
|
+
}
|
|
126
|
+
resolveNativeTag(e) {
|
|
127
|
+
return this.#e.get(e) ?? null;
|
|
128
|
+
}
|
|
129
|
+
resolveA2UIType(e, t) {
|
|
130
|
+
let n = t?.["data-a2ui"];
|
|
131
|
+
if (n && this.#e.has(n)) return n;
|
|
132
|
+
let r = this.#t.get(e);
|
|
133
|
+
if (r) return r.a2uiType;
|
|
134
|
+
if (e === "span") return t?.class?.includes("text"), "Text";
|
|
135
|
+
if (e === "n-stack") return t?.direction === "row" ? "Row" : "Column";
|
|
136
|
+
if (e === "div") {
|
|
137
|
+
if (t?.class?.includes("stack")) return t?.direction === "row" ? "Row" : "Column";
|
|
138
|
+
let e = t?.style ?? "";
|
|
139
|
+
return e.includes("flex-direction:column") || e.includes("flex-direction: column") ? "Column" : e.includes("display:flex") || e.includes("display: flex") ? "Row" : "Column";
|
|
140
|
+
}
|
|
141
|
+
return e === "img" ? "Image" : e === "video" ? "Video" : e === "audio" ? "AudioPlayer" : /^h[1-6]$/.test(e) ? "Text" : null;
|
|
142
|
+
}
|
|
143
|
+
getSupportedTypes() {
|
|
144
|
+
return Array.from(this.#e.keys());
|
|
145
|
+
}
|
|
146
|
+
getComponentCategory(e) {
|
|
147
|
+
return this.#n.get(e) ?? "other";
|
|
148
|
+
}
|
|
149
|
+
getCompatibleTypes(e) {
|
|
150
|
+
let t = this.getComponentCategory(e);
|
|
151
|
+
return Array.from(this.#e.keys()).filter((e) => this.getComponentCategory(e) === t);
|
|
152
|
+
}
|
|
153
|
+
#i(e) {
|
|
154
|
+
this.#e.set(e.a2uiType, e), e.nativeTag !== "div" && e.nativeTag !== "span" && !this.#t.has(e.nativeTag) && this.#t.set(e.nativeTag, e);
|
|
155
|
+
}
|
|
156
|
+
#a() {
|
|
157
|
+
this.#t.clear();
|
|
158
|
+
for (let e of this.#e.values()) e.nativeTag !== "div" && e.nativeTag !== "span" && !this.#t.has(e.nativeTag) && this.#t.set(e.nativeTag, e);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const k = new re([
|
|
48
162
|
{
|
|
49
163
|
a2uiType: "Text",
|
|
50
|
-
nativeTag: "
|
|
51
|
-
childStrategy: "textContent"
|
|
164
|
+
nativeTag: "span",
|
|
165
|
+
childStrategy: "textContent",
|
|
166
|
+
defaultAttributes: { class: "text" }
|
|
52
167
|
},
|
|
53
168
|
{
|
|
54
169
|
a2uiType: "Button",
|
|
@@ -150,7 +265,22 @@ var ie = [
|
|
|
150
265
|
},
|
|
151
266
|
{
|
|
152
267
|
a2uiType: "Card",
|
|
153
|
-
nativeTag: "n-
|
|
268
|
+
nativeTag: "n-container",
|
|
269
|
+
childStrategy: "children"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
a2uiType: "Header",
|
|
273
|
+
nativeTag: "n-header",
|
|
274
|
+
childStrategy: "children"
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
a2uiType: "Body",
|
|
278
|
+
nativeTag: "n-body",
|
|
279
|
+
childStrategy: "children"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
a2uiType: "Footer",
|
|
283
|
+
nativeTag: "n-footer",
|
|
154
284
|
childStrategy: "children"
|
|
155
285
|
},
|
|
156
286
|
{
|
|
@@ -267,68 +397,7 @@ var ie = [
|
|
|
267
397
|
nativeTag: "n-toast",
|
|
268
398
|
childStrategy: "textContent"
|
|
269
399
|
}
|
|
270
|
-
],
|
|
271
|
-
for (let e of ie) O.set(e.a2uiType, e), e.nativeTag !== "div" && e.nativeTag !== "span" && e.nativeTag !== "n-stack" && !k.has(e.nativeTag) && k.set(e.nativeTag, e);
|
|
272
|
-
/** All component mappings, keyed by A2UI type */
|
|
273
|
-
const A = O;
|
|
274
|
-
function j(e) {
|
|
275
|
-
return O.get(e) ?? null;
|
|
276
|
-
}
|
|
277
|
-
function M(e, t) {
|
|
278
|
-
let n = t?.["data-a2ui"];
|
|
279
|
-
if (n && O.has(n)) return n;
|
|
280
|
-
let r = k.get(e);
|
|
281
|
-
if (r) return r.a2uiType;
|
|
282
|
-
if (e === "span") return "Text";
|
|
283
|
-
if (e === "n-stack") return t?.direction === "row" ? "Row" : "Column";
|
|
284
|
-
if (e === "div") {
|
|
285
|
-
let e = t?.style ?? "";
|
|
286
|
-
return e.includes("flex-direction:column") || e.includes("flex-direction: column") ? "Column" : e.includes("display:flex") || e.includes("display: flex") ? "Row" : "Column";
|
|
287
|
-
}
|
|
288
|
-
return e === "img" ? "Image" : e === "video" ? "Video" : e === "audio" ? "AudioPlayer" : e === "hr" ? "Divider" : /^h[1-6]$/.test(e) ? "Text" : null;
|
|
289
|
-
}
|
|
290
|
-
var ae = {
|
|
291
|
-
h1: "h1",
|
|
292
|
-
h2: "h2",
|
|
293
|
-
h3: "h3",
|
|
294
|
-
h4: "h4",
|
|
295
|
-
h5: "h5",
|
|
296
|
-
heading: "h2",
|
|
297
|
-
caption: "small",
|
|
298
|
-
body: "n-text"
|
|
299
|
-
};
|
|
300
|
-
/**
|
|
301
|
-
* For A2UI Text components, resolve the variant to an HTML tag.
|
|
302
|
-
* Returns 'n-text' by default.
|
|
303
|
-
*/
|
|
304
|
-
function oe(e) {
|
|
305
|
-
return e ? ae[e] ?? "n-text" : "n-text";
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* For A2UI DateTimeInput components, resolve enableDate/enableTime to HTML input type.
|
|
309
|
-
*/
|
|
310
|
-
function se(e, t) {
|
|
311
|
-
return e && t ? "datetime-local" : t && !e ? "time" : "date";
|
|
312
|
-
}
|
|
313
|
-
var ce = {
|
|
314
|
-
number: "number",
|
|
315
|
-
obscured: "password",
|
|
316
|
-
shortText: "text",
|
|
317
|
-
longText: "text"
|
|
318
|
-
};
|
|
319
|
-
/**
|
|
320
|
-
* For A2UI TextField components, resolve the variant to an HTML input type attribute.
|
|
321
|
-
*/
|
|
322
|
-
function le(e) {
|
|
323
|
-
return e ? ce[e] ?? "text" : "text";
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Get all supported A2UI component types.
|
|
327
|
-
*/
|
|
328
|
-
function N() {
|
|
329
|
-
return Array.from(O.keys());
|
|
330
|
-
}
|
|
331
|
-
var ue = {
|
|
400
|
+
], {
|
|
332
401
|
Text: "display",
|
|
333
402
|
Icon: "display",
|
|
334
403
|
Image: "display",
|
|
@@ -348,6 +417,9 @@ var ue = {
|
|
|
348
417
|
Row: "layout",
|
|
349
418
|
Column: "layout",
|
|
350
419
|
Card: "container",
|
|
420
|
+
Header: "container",
|
|
421
|
+
Body: "container",
|
|
422
|
+
Footer: "container",
|
|
351
423
|
Modal: "container",
|
|
352
424
|
Accordion: "container",
|
|
353
425
|
AccordionItem: "container",
|
|
@@ -359,19 +431,50 @@ var ue = {
|
|
|
359
431
|
AudioPlayer: "media",
|
|
360
432
|
Table: "data",
|
|
361
433
|
Toast: "feedback"
|
|
434
|
+
}), ie = k;
|
|
435
|
+
function A(e) {
|
|
436
|
+
return k.resolveNativeTag(e);
|
|
437
|
+
}
|
|
438
|
+
function j(e, t) {
|
|
439
|
+
return k.resolveA2UIType(e, t);
|
|
440
|
+
}
|
|
441
|
+
function M() {
|
|
442
|
+
return k.getSupportedTypes();
|
|
443
|
+
}
|
|
444
|
+
var ae = {
|
|
445
|
+
h1: "h1",
|
|
446
|
+
h2: "h2",
|
|
447
|
+
h3: "h3",
|
|
448
|
+
h4: "h4",
|
|
449
|
+
h5: "h5",
|
|
450
|
+
heading: "h2",
|
|
451
|
+
caption: "small",
|
|
452
|
+
body: "span"
|
|
362
453
|
};
|
|
363
454
|
/**
|
|
364
|
-
*
|
|
455
|
+
* For A2UI Text components, resolve the variant to an HTML tag.
|
|
456
|
+
* Returns 'span' by default.
|
|
457
|
+
*/
|
|
458
|
+
function oe(e) {
|
|
459
|
+
return e ? ae[e] ?? "span" : "span";
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* For A2UI DateTimeInput components, resolve enableDate/enableTime to HTML input type.
|
|
365
463
|
*/
|
|
366
|
-
function
|
|
367
|
-
return
|
|
464
|
+
function se(e, t) {
|
|
465
|
+
return e && t ? "datetime-local" : t && !e ? "time" : "date";
|
|
368
466
|
}
|
|
467
|
+
var ce = {
|
|
468
|
+
number: "number",
|
|
469
|
+
obscured: "password",
|
|
470
|
+
shortText: "text",
|
|
471
|
+
longText: "text"
|
|
472
|
+
};
|
|
369
473
|
/**
|
|
370
|
-
*
|
|
474
|
+
* For A2UI TextField components, resolve the variant to an HTML input type attribute.
|
|
371
475
|
*/
|
|
372
|
-
function
|
|
373
|
-
|
|
374
|
-
return Array.from(O.keys()).filter((e) => P(e) === t);
|
|
476
|
+
function le(e) {
|
|
477
|
+
return e ? ce[e] ?? "text" : "text";
|
|
375
478
|
}
|
|
376
479
|
/**
|
|
377
480
|
* A2UI Converter
|
|
@@ -379,8 +482,12 @@ function de(e) {
|
|
|
379
482
|
* Bidirectional conversion between A2UI flat adjacency lists
|
|
380
483
|
* and native-ui nested UINode trees.
|
|
381
484
|
*/
|
|
382
|
-
var
|
|
383
|
-
|
|
485
|
+
var ue = new Set(/* @__PURE__ */ "id.component.children.child.text.label.variant.disabled.action.accessibility.value.placeholder.min.max.step.url.src.alt.name.fit.justify.align.weight.direction.enableDate.enableTime.options.filterable.displayStyle.validationRegexp.checks.trigger.content.tabs.poster.header.footer".split(".")), de = new Set([
|
|
486
|
+
"Header",
|
|
487
|
+
"Body",
|
|
488
|
+
"Footer"
|
|
489
|
+
]);
|
|
490
|
+
function N(e, t) {
|
|
384
491
|
if (e.length === 0) return {
|
|
385
492
|
root: {
|
|
386
493
|
id: "empty-root",
|
|
@@ -412,118 +519,118 @@ function F(e, t) {
|
|
|
412
519
|
warnings: ["No root component found"],
|
|
413
520
|
orphans: []
|
|
414
521
|
};
|
|
415
|
-
let a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map(), s = [], c = t?.surfaceId ?? "default", l =
|
|
416
|
-
return
|
|
417
|
-
root:
|
|
522
|
+
let a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map(), s = [], c = t?.surfaceId ?? "default", l = t?.registry ? (e) => t.registry.resolveNativeTag(e) : A, u = P(i, n, a, o, s, c, l), d = e.filter((e) => !a.has(e.id)).map((e) => e.id);
|
|
523
|
+
return d.length > 0 && s.push(`Orphan components not reachable from root: ${d.join(", ")}`), {
|
|
524
|
+
root: u,
|
|
418
525
|
bindings: o,
|
|
419
526
|
warnings: s,
|
|
420
|
-
orphans:
|
|
527
|
+
orphans: d
|
|
421
528
|
};
|
|
422
529
|
}
|
|
423
|
-
function
|
|
530
|
+
function P(e, t, n, r, i, a, o = A) {
|
|
424
531
|
if (n.has(e)) return i.push(`Cycle detected at component "${e}"`), {
|
|
425
532
|
id: `${e}-cycle`,
|
|
426
533
|
tag: "div",
|
|
427
534
|
textContent: `[Cycle: ${e}]`
|
|
428
535
|
};
|
|
429
536
|
n.add(e);
|
|
430
|
-
let
|
|
431
|
-
if (!
|
|
537
|
+
let s = t.get(e);
|
|
538
|
+
if (!s) return i.push(`Component "${e}" referenced but not found`), {
|
|
432
539
|
id: e,
|
|
433
540
|
tag: "div",
|
|
434
541
|
textContent: `[Missing: ${e}]`
|
|
435
542
|
};
|
|
436
|
-
let
|
|
437
|
-
if (!
|
|
543
|
+
let c = o(s.component);
|
|
544
|
+
if (!c) return i.push(`Unknown A2UI type "${s.component}" for component "${e}"`), {
|
|
438
545
|
id: e,
|
|
439
546
|
tag: "div",
|
|
440
|
-
textContent:
|
|
547
|
+
textContent: s.text ?? `[Unknown: ${s.component}]`
|
|
441
548
|
};
|
|
442
|
-
let
|
|
443
|
-
|
|
444
|
-
let
|
|
445
|
-
if (
|
|
446
|
-
let e =
|
|
447
|
-
e && (
|
|
448
|
-
} else
|
|
449
|
-
if (
|
|
450
|
-
let i =
|
|
549
|
+
let l = c.nativeTag;
|
|
550
|
+
s.component === "Text" && s.variant && (l = oe(s.variant));
|
|
551
|
+
let u = {};
|
|
552
|
+
if (u["data-a2ui"] = s.component, c.defaultAttributes && Object.assign(u, c.defaultAttributes), s.variant && c.variantMap) {
|
|
553
|
+
let e = c.variantMap[s.variant];
|
|
554
|
+
e && (u.variant = e);
|
|
555
|
+
} else s.variant && s.component !== "Text" && (u.variant = s.variant);
|
|
556
|
+
if (c.propertyMap) for (let [t, n] of Object.entries(c.propertyMap)) {
|
|
557
|
+
let i = s[t];
|
|
451
558
|
if (i !== void 0) if (S(i)) {
|
|
452
559
|
let t = r.get(e);
|
|
453
560
|
t || (t = [], r.set(e, t)), t.push({
|
|
454
561
|
property: n,
|
|
455
562
|
path: i.path
|
|
456
563
|
});
|
|
457
|
-
} else
|
|
564
|
+
} else u[n] = String(i);
|
|
458
565
|
}
|
|
459
|
-
if (
|
|
460
|
-
let e = le(
|
|
461
|
-
e !== "text" && (
|
|
566
|
+
if (s.disabled && (u.disabled = ""), s.accessibility?.label && (u["aria-label"] = s.accessibility.label), s.component === "TextField") {
|
|
567
|
+
let e = le(s.variant);
|
|
568
|
+
e !== "text" && (u.type = e);
|
|
462
569
|
}
|
|
463
|
-
if (
|
|
570
|
+
if (s.component === "DateTimeInput" && (u.type = se(s.enableDate, s.enableTime)), (s.component === "TextField" || s.component === "DateTimeInput" || s.component === "Slider") && s.label) if (S(s.label)) {
|
|
464
571
|
let t = r.get(e);
|
|
465
572
|
t || (t = [], r.set(e, t)), t.push({
|
|
466
573
|
property: "aria-label",
|
|
467
|
-
path:
|
|
574
|
+
path: s.label.path
|
|
468
575
|
});
|
|
469
|
-
} else
|
|
470
|
-
if (
|
|
471
|
-
let e = parseFloat(
|
|
472
|
-
|
|
576
|
+
} else u["aria-label"] = s.label;
|
|
577
|
+
if (s.component === "Slider" && (s.min !== void 0 && (u.min = String(s.min)), s.max !== void 0 && (u.max = String(s.max))), s.component === "Progress") {
|
|
578
|
+
let e = parseFloat(u.value ?? "0"), t = parseFloat(u.max ?? "100");
|
|
579
|
+
u.style = `--n-progress: ${t > 0 ? Math.min(1, Math.max(0, e / t)) : 0}`, u.value && (u["data-value"] = u.value, delete u.value), u.max && (u["data-max"] = u.max, delete u.max);
|
|
473
580
|
}
|
|
474
|
-
let
|
|
475
|
-
if (
|
|
581
|
+
let d;
|
|
582
|
+
if (s.text !== void 0) if (S(s.text)) {
|
|
476
583
|
let t = r.get(e);
|
|
477
584
|
t || (t = [], r.set(e, t)), t.push({
|
|
478
585
|
property: "textContent",
|
|
479
|
-
path:
|
|
586
|
+
path: s.text.path
|
|
480
587
|
});
|
|
481
|
-
} else
|
|
482
|
-
for (let [e, t] of Object.entries(
|
|
483
|
-
let
|
|
484
|
-
|
|
485
|
-
let
|
|
486
|
-
if (
|
|
487
|
-
|
|
488
|
-
let
|
|
489
|
-
for (let e = 0; e <
|
|
490
|
-
let
|
|
491
|
-
if (!
|
|
492
|
-
n.add(
|
|
493
|
-
let
|
|
494
|
-
|
|
495
|
-
id: `${
|
|
588
|
+
} else d = s.text;
|
|
589
|
+
for (let [e, t] of Object.entries(s)) ue.has(e) || typeof t == "string" && (u[e] = t);
|
|
590
|
+
let f;
|
|
591
|
+
s.action?.event && c.actionEvent && (f = { [c.actionEvent]: `a2ui:${a}:${e}:${s.action.event.name}` });
|
|
592
|
+
let p, m = s.children ?? (s.child ? [s.child] : void 0);
|
|
593
|
+
if (s.component === "Tabs" && m && m.length > 0) {
|
|
594
|
+
p = [];
|
|
595
|
+
let s = [];
|
|
596
|
+
for (let e = 0; e < m.length; e++) {
|
|
597
|
+
let c = m[e], l = t.get(c);
|
|
598
|
+
if (!l) continue;
|
|
599
|
+
n.add(c);
|
|
600
|
+
let u = String(l.value ?? l.id ?? `tab-${e}`), d = String(l.label ?? l.text ?? `Tab ${e + 1}`);
|
|
601
|
+
p.push({
|
|
602
|
+
id: `${c}-tab`,
|
|
496
603
|
tag: "n-tab",
|
|
497
|
-
attributes: { value:
|
|
498
|
-
textContent:
|
|
604
|
+
attributes: { value: u },
|
|
605
|
+
textContent: d
|
|
499
606
|
});
|
|
500
|
-
let
|
|
501
|
-
|
|
502
|
-
id: `${
|
|
607
|
+
let f = l.children ?? (l.child ? [l.child] : void 0), h = f ? f.map((e) => P(e, t, n, r, i, a, o)) : void 0, g = typeof l.text == "string" ? l.text : void 0;
|
|
608
|
+
s.push({
|
|
609
|
+
id: `${c}-panel`,
|
|
503
610
|
tag: "n-tab-panel",
|
|
504
|
-
attributes: { value:
|
|
505
|
-
...
|
|
506
|
-
...
|
|
611
|
+
attributes: { value: u },
|
|
612
|
+
...h && h.length > 0 ? { children: h } : {},
|
|
613
|
+
...g && !h ? { textContent: g } : {}
|
|
507
614
|
});
|
|
508
615
|
}
|
|
509
|
-
if (
|
|
616
|
+
if (p.push({
|
|
510
617
|
id: `${e}-panels`,
|
|
511
618
|
tag: "n-tab-panels",
|
|
512
|
-
children:
|
|
513
|
-
}), !
|
|
514
|
-
let e = t.get(
|
|
515
|
-
|
|
619
|
+
children: s
|
|
620
|
+
}), !u.value && m.length > 0) {
|
|
621
|
+
let e = t.get(m[0]);
|
|
622
|
+
u.value = String(e?.value ?? e?.id ?? "tab-0");
|
|
516
623
|
}
|
|
517
|
-
} else if (
|
|
518
|
-
if (Array.isArray(
|
|
519
|
-
let e =
|
|
624
|
+
} else if (s.component === "Select" || s.component === "ChoicePicker") {
|
|
625
|
+
if (Array.isArray(s.options) && s.options.length > 0) {
|
|
626
|
+
let e = s.options.map((e) => typeof e == "string" ? {
|
|
520
627
|
value: e,
|
|
521
628
|
label: e
|
|
522
629
|
} : e);
|
|
523
|
-
|
|
524
|
-
} else if (
|
|
630
|
+
u.options = JSON.stringify(e), s.label && (u.placeholder = String(s.label));
|
|
631
|
+
} else if (m && m.length > 0) {
|
|
525
632
|
let e = [];
|
|
526
|
-
for (let r of
|
|
633
|
+
for (let r of m) {
|
|
527
634
|
let i = t.get(r);
|
|
528
635
|
i && i.component === "ListItem" && (n.add(r), e.push({
|
|
529
636
|
value: String(i.value ?? ""),
|
|
@@ -531,95 +638,125 @@ function I(e, t, n, r, i, a) {
|
|
|
531
638
|
...i.disabled ? { disabled: !0 } : {}
|
|
532
639
|
}));
|
|
533
640
|
}
|
|
534
|
-
e.length > 0 && (
|
|
641
|
+
e.length > 0 && (u.options = JSON.stringify(e), s.label && (u.placeholder = String(s.label)));
|
|
535
642
|
}
|
|
536
|
-
} else
|
|
537
|
-
|
|
643
|
+
} else if (s.component === "Card" && m && m.length > 0) if (m.some((e) => {
|
|
644
|
+
let n = t.get(e);
|
|
645
|
+
return n ? de.has(n.component) : !1;
|
|
646
|
+
})) p = m.map((e) => P(e, t, n, r, i, a, o));
|
|
647
|
+
else {
|
|
648
|
+
p = [];
|
|
649
|
+
let c = s.header ?? s.label;
|
|
650
|
+
c && p.push({
|
|
651
|
+
id: `${e}-header`,
|
|
652
|
+
tag: "n-header",
|
|
653
|
+
children: [{
|
|
654
|
+
id: `${e}-header-label`,
|
|
655
|
+
tag: "span",
|
|
656
|
+
attributes: { slot: "label" },
|
|
657
|
+
textContent: c
|
|
658
|
+
}]
|
|
659
|
+
});
|
|
660
|
+
let l = m.map((e) => P(e, t, n, r, i, a, o));
|
|
661
|
+
p.push({
|
|
662
|
+
id: `${e}-body`,
|
|
663
|
+
tag: "n-body",
|
|
664
|
+
children: l
|
|
665
|
+
});
|
|
666
|
+
let u = s.footer;
|
|
667
|
+
u && p.push({
|
|
668
|
+
id: `${e}-footer`,
|
|
669
|
+
tag: "n-footer",
|
|
670
|
+
textContent: u
|
|
671
|
+
}), c && (d = void 0);
|
|
672
|
+
}
|
|
673
|
+
else m && m.length > 0 && (p = m.map((e) => P(e, t, n, r, i, a, o)));
|
|
674
|
+
if (c.childStrategy === "slot-label" && d && !p) p = [{
|
|
538
675
|
id: `${e}-label`,
|
|
539
676
|
tag: "span",
|
|
540
677
|
attributes: { slot: "label" },
|
|
541
|
-
textContent:
|
|
542
|
-
}],
|
|
543
|
-
else if (
|
|
678
|
+
textContent: d
|
|
679
|
+
}], d = void 0;
|
|
680
|
+
else if (c.childStrategy === "textContent" && s.label && !d) if (S(s.label)) {
|
|
544
681
|
let t = r.get(e);
|
|
545
682
|
t || (t = [], r.set(e, t)), t.push({
|
|
546
683
|
property: "textContent",
|
|
547
|
-
path:
|
|
684
|
+
path: s.label.path
|
|
548
685
|
});
|
|
549
|
-
} else
|
|
550
|
-
if (
|
|
551
|
-
let t =
|
|
686
|
+
} else d = s.label;
|
|
687
|
+
if (s.component === "ListItem" && s.value !== void 0 && (u.value = String(s.value)), s.component === "Image" || s.component === "Video" || s.component === "AudioPlayer") {
|
|
688
|
+
let t = s.component === "Image" ? "img" : s.component === "Video" ? "video" : "audio", n = {};
|
|
552
689
|
t !== "img" && (n.controls = "");
|
|
553
690
|
for (let e of [
|
|
554
691
|
"src",
|
|
555
692
|
"alt",
|
|
556
693
|
"poster"
|
|
557
|
-
])
|
|
558
|
-
if (
|
|
559
|
-
if (S(
|
|
694
|
+
]) u[e] && (n[e] = u[e], delete u[e]);
|
|
695
|
+
if (s.component === "Image" && s.url !== void 0) {
|
|
696
|
+
if (S(s.url)) {
|
|
560
697
|
let t = r.get(`${e}-inner`);
|
|
561
698
|
t || (t = [], r.set(`${e}-inner`, t)), t.push({
|
|
562
699
|
property: "src",
|
|
563
|
-
path:
|
|
700
|
+
path: s.url.path
|
|
564
701
|
});
|
|
565
|
-
} else n.src =
|
|
566
|
-
|
|
702
|
+
} else n.src = s.url;
|
|
703
|
+
s.alt && (n.alt = s.alt);
|
|
567
704
|
}
|
|
568
|
-
|
|
705
|
+
p = [{
|
|
569
706
|
id: `${e}-inner`,
|
|
570
707
|
tag: t,
|
|
571
708
|
...Object.keys(n).length > 0 ? { attributes: n } : {}
|
|
572
709
|
}];
|
|
573
710
|
}
|
|
574
|
-
let
|
|
711
|
+
let h = Object.keys(u).length > 0 ? u : void 0;
|
|
575
712
|
return {
|
|
576
713
|
id: e,
|
|
577
|
-
tag:
|
|
578
|
-
...
|
|
579
|
-
...
|
|
580
|
-
...
|
|
581
|
-
...
|
|
714
|
+
tag: l,
|
|
715
|
+
...h ? { attributes: h } : {},
|
|
716
|
+
...d === void 0 ? {} : { textContent: d },
|
|
717
|
+
...p && p.length > 0 ? { children: p } : {},
|
|
718
|
+
...f ? { events: f } : {}
|
|
582
719
|
};
|
|
583
720
|
}
|
|
584
|
-
function
|
|
585
|
-
let n = [];
|
|
586
|
-
return
|
|
721
|
+
function fe(e, t) {
|
|
722
|
+
let n = [], r = t?.registry ? (e, n) => t.registry.resolveA2UIType(e, n) : j, i = t?.registry ? (e) => t.registry.resolveNativeTag(e) : A;
|
|
723
|
+
return F(e, n, t?.surfaceId ?? "default", r, i), n;
|
|
587
724
|
}
|
|
588
|
-
function
|
|
589
|
-
let
|
|
590
|
-
if (!
|
|
591
|
-
let
|
|
725
|
+
function F(e, t, n, r = j, i = A) {
|
|
726
|
+
let a = r(e.tag, e.attributes);
|
|
727
|
+
if (!a) {
|
|
728
|
+
let a = {
|
|
592
729
|
id: e.id,
|
|
593
730
|
component: "Column",
|
|
594
731
|
...e.children ? { children: e.children.map((e) => e.id) } : {},
|
|
595
732
|
...e.textContent ? { text: e.textContent } : {}
|
|
596
733
|
};
|
|
597
|
-
if (t.push(
|
|
734
|
+
if (t.push(a), e.children) for (let a of e.children) F(a, t, n, r, i);
|
|
598
735
|
return;
|
|
599
736
|
}
|
|
600
|
-
let
|
|
737
|
+
let o = i(a), s = {
|
|
601
738
|
id: e.id,
|
|
602
|
-
component:
|
|
739
|
+
component: a
|
|
603
740
|
};
|
|
604
|
-
if (e.children && e.children.length > 0) if ((
|
|
741
|
+
if (e.children && e.children.length > 0) if ((a === "Image" || a === "Video" || a === "AudioPlayer") && e.children.length === 1 && (e.children[0].tag === "img" || e.children[0].tag === "video" || e.children[0].tag === "audio")) {
|
|
605
742
|
let t = e.children[0];
|
|
606
|
-
t.attributes?.src && (
|
|
607
|
-
} else if (
|
|
743
|
+
t.attributes?.src && (s.url = t.attributes.src), t.attributes?.alt && (s.alt = t.attributes.alt), t.attributes?.poster && (s.poster = t.attributes.poster);
|
|
744
|
+
} else if (o?.childStrategy === "slot-label" && e.children.length === 1 && e.children[0].attributes?.slot === "label" && e.children[0].textContent) s.text = e.children[0].textContent;
|
|
608
745
|
else {
|
|
609
|
-
|
|
610
|
-
for (let
|
|
746
|
+
s.children = e.children.map((e) => e.id);
|
|
747
|
+
for (let a of e.children) F(a, t, n, r, i);
|
|
611
748
|
}
|
|
612
|
-
if (e.textContent && (
|
|
613
|
-
let t =
|
|
614
|
-
for (let [n, r] of Object.entries(e.attributes)) n === "style" || n === "data-a2ui" || n === "slot" || (t[n] ?
|
|
749
|
+
if (e.textContent && (a === "CheckBox" || a === "Switch" || a === "ListItem" ? s.label = e.textContent : s.text = e.textContent), e.attributes) {
|
|
750
|
+
let t = o?.propertyMap ? pe(o.propertyMap) : {};
|
|
751
|
+
for (let [n, r] of Object.entries(e.attributes)) n === "style" || n === "data-a2ui" || n === "slot" || (t[n] ? s[t[n]] = r : n === "aria-label" ? s.label = r : n === "disabled" && r === "" ? s.disabled = !0 : n === "variant" && (s.variant = (o?.variantMap ? pe(o.variantMap) : {})[r] ?? r));
|
|
615
752
|
}
|
|
616
753
|
if (e.events) for (let [t, n] of Object.entries(e.events)) {
|
|
617
754
|
let e = n.split(":");
|
|
618
|
-
e[0] === "a2ui" && e.length >= 4 && (
|
|
755
|
+
e[0] === "a2ui" && e.length >= 4 && (s.action = { event: { name: e[3] } });
|
|
619
756
|
}
|
|
620
|
-
t.push(
|
|
757
|
+
t.push(s);
|
|
621
758
|
}
|
|
622
|
-
function
|
|
759
|
+
function pe(e) {
|
|
623
760
|
let t = {};
|
|
624
761
|
for (let [n, r] of Object.entries(e)) t[r] = n;
|
|
625
762
|
return t;
|
|
@@ -627,7 +764,7 @@ function me(e) {
|
|
|
627
764
|
/**
|
|
628
765
|
* Wrap a conversion result as a UIPlan.
|
|
629
766
|
*/
|
|
630
|
-
function
|
|
767
|
+
function me(e, t = "generated") {
|
|
631
768
|
return Object.freeze({
|
|
632
769
|
id: f("a2ui-plan"),
|
|
633
770
|
version: 1,
|
|
@@ -642,18 +779,18 @@ function R(e, t = "generated") {
|
|
|
642
779
|
* Manages A2UI surface lifecycle: create → updateComponents → updateDataModel → delete.
|
|
643
780
|
* Each surface maps to one UIPlan in the kernel.
|
|
644
781
|
*/
|
|
645
|
-
function
|
|
782
|
+
function I(e, t) {
|
|
646
783
|
if (!t || t === "/") return e;
|
|
647
|
-
let n = t.replace(/^\//, "").split("/").map(
|
|
784
|
+
let n = t.replace(/^\//, "").split("/").map(R), r = e;
|
|
648
785
|
for (let e of n) {
|
|
649
786
|
if (typeof r != "object" || !r) return;
|
|
650
787
|
r = r[e];
|
|
651
788
|
}
|
|
652
789
|
return r;
|
|
653
790
|
}
|
|
654
|
-
function
|
|
791
|
+
function L(e, t, n) {
|
|
655
792
|
if (!t || t === "/") return;
|
|
656
|
-
let r = t.replace(/^\//, "").split("/").map(
|
|
793
|
+
let r = t.replace(/^\//, "").split("/").map(R), i = e;
|
|
657
794
|
for (let e = 0; e < r.length - 1; e++) {
|
|
658
795
|
let t = r[e];
|
|
659
796
|
(i[t] == null || typeof i[t] != "object") && (i[t] = {}), i = i[t];
|
|
@@ -661,24 +798,25 @@ function he(e, t, n) {
|
|
|
661
798
|
let a = r[r.length - 1];
|
|
662
799
|
n === void 0 ? delete i[a] : i[a] = n;
|
|
663
800
|
}
|
|
664
|
-
function
|
|
801
|
+
function R(e) {
|
|
665
802
|
return e.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
666
803
|
}
|
|
667
|
-
var
|
|
804
|
+
var z = class {
|
|
668
805
|
#e;
|
|
669
806
|
#t;
|
|
670
807
|
#n;
|
|
671
|
-
#r
|
|
672
|
-
#i =
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
808
|
+
#r;
|
|
809
|
+
#i = /* @__PURE__ */ new Map();
|
|
810
|
+
#a = d(0);
|
|
811
|
+
surfaceCount = c(() => this.#a.value);
|
|
812
|
+
constructor(e, t, n, r) {
|
|
813
|
+
this.#e = e, this.#t = t, this.#n = n ?? null, this.#r = r;
|
|
676
814
|
}
|
|
677
815
|
handleMessage(e, t) {
|
|
678
|
-
C(e) ? this.#
|
|
816
|
+
C(e) ? this.#o(e, t) : w(e) ? this.#s(e, t) : T(e) ? this.#u(e) : E(e) && this.#d(e);
|
|
679
817
|
}
|
|
680
|
-
#
|
|
681
|
-
let { surfaceId: n, catalogId: r, theme: i } = e.createSurface, a = this.#
|
|
818
|
+
#o(e, t) {
|
|
819
|
+
let { surfaceId: n, catalogId: r, theme: i } = e.createSurface, a = this.#i.get(n);
|
|
682
820
|
if (a) {
|
|
683
821
|
a.catalogId = r, a.theme = i;
|
|
684
822
|
return;
|
|
@@ -696,10 +834,10 @@ var B = class {
|
|
|
696
834
|
actionDisposer: null,
|
|
697
835
|
rendered: !1
|
|
698
836
|
};
|
|
699
|
-
this.#
|
|
837
|
+
this.#i.set(n, o), this.#a.value = this.#i.size;
|
|
700
838
|
}
|
|
701
|
-
#
|
|
702
|
-
let { surfaceId: n, components: r } = e.updateComponents, i = this.#
|
|
839
|
+
#s(e, t) {
|
|
840
|
+
let { surfaceId: n, components: r } = e.updateComponents, i = this.#i.get(n);
|
|
703
841
|
i ? t && (i.container = t) : (i = {
|
|
704
842
|
surfaceId: n,
|
|
705
843
|
planId: f("a2ui-plan"),
|
|
@@ -710,20 +848,23 @@ var B = class {
|
|
|
710
848
|
bindingDisposers: [],
|
|
711
849
|
actionDisposer: null,
|
|
712
850
|
rendered: !1
|
|
713
|
-
}, this.#
|
|
851
|
+
}, this.#i.set(n, i), this.#a.value = this.#i.size), i.rendered ? (this.#l(i, r), i.components = [...r]) : (i.components = [...r], this.#c(i)), i.rendered && this.#n?.(i.surfaceId, i.container);
|
|
714
852
|
}
|
|
715
|
-
#
|
|
716
|
-
let t =
|
|
853
|
+
#c(e) {
|
|
854
|
+
let t = N(e.components, {
|
|
855
|
+
surfaceId: e.surfaceId,
|
|
856
|
+
registry: this.#r
|
|
857
|
+
});
|
|
717
858
|
e.bindings = new Map(t.bindings);
|
|
718
|
-
let n =
|
|
859
|
+
let n = me(t);
|
|
719
860
|
e.planId = n.id;
|
|
720
861
|
try {
|
|
721
862
|
let t = this.#e.executePlan(n, e.container);
|
|
722
|
-
e.rendered = !0, this.#
|
|
863
|
+
e.rendered = !0, this.#f(e, t), this.#p(e);
|
|
723
864
|
} catch {}
|
|
724
865
|
}
|
|
725
|
-
#
|
|
726
|
-
let n =
|
|
866
|
+
#l(e, t) {
|
|
867
|
+
let n = ve(e.components, t, e.surfaceId, this.#r);
|
|
727
868
|
if (n.length === 0) return;
|
|
728
869
|
this.#e.patchPlan({
|
|
729
870
|
planId: e.planId,
|
|
@@ -731,45 +872,48 @@ var B = class {
|
|
|
731
872
|
source: "generated",
|
|
732
873
|
timestamp: Date.now()
|
|
733
874
|
});
|
|
734
|
-
let r =
|
|
875
|
+
let r = N(t, {
|
|
876
|
+
surfaceId: e.surfaceId,
|
|
877
|
+
registry: this.#r
|
|
878
|
+
});
|
|
735
879
|
e.bindings = new Map(r.bindings);
|
|
736
880
|
for (let t of e.bindingDisposers) t();
|
|
737
881
|
e.bindingDisposers = [];
|
|
738
882
|
let i = this.#e.executor.getElements(e.planId);
|
|
739
|
-
i && this.#
|
|
883
|
+
i && this.#f(e, i);
|
|
740
884
|
}
|
|
741
|
-
#
|
|
742
|
-
let { surfaceId: t, path: n, value: r } = e.updateDataModel, i = this.#
|
|
885
|
+
#u(e) {
|
|
886
|
+
let { surfaceId: t, path: n, value: r } = e.updateDataModel, i = this.#i.get(t);
|
|
743
887
|
if (!i) return;
|
|
744
888
|
let a = { ...i.dataModel.value };
|
|
745
|
-
!n || n === "/" ? i.dataModel.value = r ?? {} : (
|
|
889
|
+
!n || n === "/" ? i.dataModel.value = r ?? {} : (L(a, n, r), i.dataModel.value = a);
|
|
746
890
|
}
|
|
747
|
-
#
|
|
748
|
-
let { surfaceId: t } = e.deleteSurface, n = this.#
|
|
891
|
+
#d(e) {
|
|
892
|
+
let { surfaceId: t } = e.deleteSurface, n = this.#i.get(t);
|
|
749
893
|
if (n) {
|
|
750
894
|
n.rendered && this.#e.teardownPlan(n.planId);
|
|
751
895
|
for (let e of n.bindingDisposers) e();
|
|
752
|
-
n.bindingDisposers = [], n.actionDisposer?.(), this.#
|
|
896
|
+
n.bindingDisposers = [], n.actionDisposer?.(), this.#i.delete(t), this.#a.value = this.#i.size;
|
|
753
897
|
}
|
|
754
898
|
}
|
|
755
|
-
#
|
|
899
|
+
#f(e, t) {
|
|
756
900
|
for (let [n, r] of e.bindings) {
|
|
757
901
|
let i = t.get(n);
|
|
758
902
|
if (i) for (let t of r) {
|
|
759
903
|
let n = u(() => {
|
|
760
|
-
let n = e.dataModel.value, r =
|
|
904
|
+
let n = e.dataModel.value, r = I(n, t.path);
|
|
761
905
|
r !== void 0 && (t.property === "textContent" ? i.textContent = String(r) : t.property === "src" || t.property === "alt" || t.property.startsWith("aria-") ? i.setAttribute(t.property, String(r)) : i[t.property] = r);
|
|
762
906
|
});
|
|
763
907
|
e.bindingDisposers.push(n);
|
|
764
908
|
}
|
|
765
909
|
}
|
|
766
910
|
}
|
|
767
|
-
#
|
|
911
|
+
#p(e) {
|
|
768
912
|
let t = `a2ui:${e.surfaceId}:`;
|
|
769
913
|
e.actionDisposer = this.#e.bus.on((e) => e.type.startsWith(t), (t) => {
|
|
770
914
|
let n = t.type.split(":");
|
|
771
915
|
if (n.length < 4) return;
|
|
772
|
-
let r = n[2], i = n[3], a = e.components.find((e) => e.id === r)?.action?.event?.context, o = a ?
|
|
916
|
+
let r = n[2], i = n[3], a = e.components.find((e) => e.id === r)?.action?.event?.context, o = a ? he(a, e.dataModel.value) : void 0;
|
|
773
917
|
this.#t({ action: {
|
|
774
918
|
surfaceId: e.surfaceId,
|
|
775
919
|
sourceComponentId: r,
|
|
@@ -780,7 +924,7 @@ var B = class {
|
|
|
780
924
|
});
|
|
781
925
|
}
|
|
782
926
|
getSurface(e) {
|
|
783
|
-
let t = this.#
|
|
927
|
+
let t = this.#i.get(e);
|
|
784
928
|
return t ? {
|
|
785
929
|
surfaceId: t.surfaceId,
|
|
786
930
|
planId: t.planId,
|
|
@@ -791,22 +935,22 @@ var B = class {
|
|
|
791
935
|
} : null;
|
|
792
936
|
}
|
|
793
937
|
getSurfaceIds() {
|
|
794
|
-
return Array.from(this.#
|
|
938
|
+
return Array.from(this.#i.keys());
|
|
795
939
|
}
|
|
796
940
|
getDataModel(e) {
|
|
797
|
-
return this.#
|
|
941
|
+
return this.#i.get(e)?.dataModel.value ?? null;
|
|
798
942
|
}
|
|
799
943
|
destroy() {
|
|
800
|
-
for (let e of this.#
|
|
944
|
+
for (let e of this.#i.keys()) this.#d({ deleteSurface: { surfaceId: e } });
|
|
801
945
|
}
|
|
802
946
|
};
|
|
803
|
-
function
|
|
947
|
+
function he(e, t) {
|
|
804
948
|
let n = {};
|
|
805
|
-
for (let [r, i] of Object.entries(e)) typeof i == "object" && i && "path" in i ? n[r] =
|
|
949
|
+
for (let [r, i] of Object.entries(e)) typeof i == "object" && i && "path" in i ? n[r] = I(t, i.path) : n[r] = i;
|
|
806
950
|
return n;
|
|
807
951
|
}
|
|
808
952
|
/** A2UI properties that map to HTML attributes on the rendered element. */
|
|
809
|
-
var
|
|
953
|
+
var ge = [
|
|
810
954
|
"variant",
|
|
811
955
|
"placeholder",
|
|
812
956
|
"name",
|
|
@@ -819,92 +963,95 @@ var ve = [
|
|
|
819
963
|
"fit",
|
|
820
964
|
"style",
|
|
821
965
|
"intent"
|
|
822
|
-
],
|
|
823
|
-
function
|
|
824
|
-
let r = /* @__PURE__ */ new Map();
|
|
825
|
-
for (let t of e) r.set(t.id, t);
|
|
966
|
+
], _e = ["value"];
|
|
967
|
+
function ve(e, t, n, r) {
|
|
826
968
|
let i = /* @__PURE__ */ new Map();
|
|
827
|
-
for (let
|
|
828
|
-
let a =
|
|
829
|
-
for (let
|
|
969
|
+
for (let t of e) i.set(t.id, t);
|
|
970
|
+
let a = /* @__PURE__ */ new Map();
|
|
971
|
+
for (let e of t) a.set(e.id, e);
|
|
972
|
+
let o = [];
|
|
973
|
+
for (let [e] of i) a.has(e) || o.push({
|
|
830
974
|
type: "remove",
|
|
831
975
|
targetId: e
|
|
832
976
|
});
|
|
833
|
-
for (let [e,
|
|
834
|
-
let
|
|
835
|
-
if (
|
|
836
|
-
let t =
|
|
977
|
+
for (let [e, s] of a) if (!i.has(e)) {
|
|
978
|
+
let i = ye(e, t);
|
|
979
|
+
if (i) {
|
|
980
|
+
let t = N([s], {
|
|
837
981
|
surfaceId: n,
|
|
838
|
-
rootId: e
|
|
982
|
+
rootId: e,
|
|
983
|
+
registry: r
|
|
839
984
|
});
|
|
840
|
-
|
|
985
|
+
o.push({
|
|
841
986
|
type: "add",
|
|
842
|
-
parentId:
|
|
987
|
+
parentId: i,
|
|
843
988
|
node: t.root
|
|
844
989
|
});
|
|
845
990
|
}
|
|
846
991
|
}
|
|
847
|
-
for (let [e,
|
|
848
|
-
let
|
|
849
|
-
if (
|
|
850
|
-
if (
|
|
851
|
-
let
|
|
992
|
+
for (let [e, s] of a) {
|
|
993
|
+
let a = i.get(e);
|
|
994
|
+
if (a) {
|
|
995
|
+
if (s.component !== a.component) {
|
|
996
|
+
let i = N(B(e, t), {
|
|
852
997
|
surfaceId: n,
|
|
853
|
-
rootId: e
|
|
998
|
+
rootId: e,
|
|
999
|
+
registry: r
|
|
854
1000
|
});
|
|
855
|
-
|
|
1001
|
+
o.push({
|
|
856
1002
|
type: "replace",
|
|
857
1003
|
targetId: e,
|
|
858
|
-
node:
|
|
1004
|
+
node: i.root
|
|
859
1005
|
});
|
|
860
1006
|
continue;
|
|
861
1007
|
}
|
|
862
|
-
if (JSON.stringify(
|
|
863
|
-
let
|
|
1008
|
+
if (JSON.stringify(a.children ?? a.child ?? []) !== JSON.stringify(s.children ?? s.child ?? [])) {
|
|
1009
|
+
let i = N(B(e, t), {
|
|
864
1010
|
surfaceId: n,
|
|
865
|
-
rootId: e
|
|
1011
|
+
rootId: e,
|
|
1012
|
+
registry: r
|
|
866
1013
|
});
|
|
867
|
-
|
|
1014
|
+
o.push({
|
|
868
1015
|
type: "replace",
|
|
869
1016
|
targetId: e,
|
|
870
|
-
node:
|
|
1017
|
+
node: i.root
|
|
871
1018
|
});
|
|
872
1019
|
continue;
|
|
873
1020
|
}
|
|
874
|
-
|
|
1021
|
+
s.text !== a.text && typeof s.text == "string" && o.push({
|
|
875
1022
|
type: "set-text",
|
|
876
1023
|
targetId: e,
|
|
877
|
-
text:
|
|
878
|
-
}),
|
|
1024
|
+
text: s.text
|
|
1025
|
+
}), s.label !== a.label && typeof s.label == "string" && o.push({
|
|
879
1026
|
type: "set-text",
|
|
880
1027
|
targetId: e,
|
|
881
|
-
text:
|
|
882
|
-
}),
|
|
1028
|
+
text: s.label
|
|
1029
|
+
}), s.disabled !== a.disabled && (s.disabled ? o.push({
|
|
883
1030
|
type: "set-attribute",
|
|
884
1031
|
targetId: e,
|
|
885
1032
|
name: "disabled",
|
|
886
1033
|
value: ""
|
|
887
|
-
}) :
|
|
1034
|
+
}) : o.push({
|
|
888
1035
|
type: "remove-attribute",
|
|
889
1036
|
targetId: e,
|
|
890
1037
|
name: "disabled"
|
|
891
1038
|
}));
|
|
892
|
-
for (let t of
|
|
893
|
-
let n =
|
|
894
|
-
r !== n && (r == null || r === !1 ?
|
|
1039
|
+
for (let t of ge) {
|
|
1040
|
+
let n = a[t], r = s[t];
|
|
1041
|
+
r !== n && (r == null || r === !1 ? o.push({
|
|
895
1042
|
type: "remove-attribute",
|
|
896
1043
|
targetId: e,
|
|
897
1044
|
name: t
|
|
898
|
-
}) :
|
|
1045
|
+
}) : o.push({
|
|
899
1046
|
type: "set-attribute",
|
|
900
1047
|
targetId: e,
|
|
901
1048
|
name: t,
|
|
902
1049
|
value: String(r)
|
|
903
1050
|
}));
|
|
904
1051
|
}
|
|
905
|
-
for (let t of
|
|
906
|
-
let n =
|
|
907
|
-
r !== n && r !== void 0 &&
|
|
1052
|
+
for (let t of _e) {
|
|
1053
|
+
let n = a[t], r = s[t];
|
|
1054
|
+
r !== n && r !== void 0 && o.push({
|
|
908
1055
|
type: "set-property",
|
|
909
1056
|
targetId: e,
|
|
910
1057
|
name: t,
|
|
@@ -913,13 +1060,13 @@ function be(e, t, n) {
|
|
|
913
1060
|
}
|
|
914
1061
|
}
|
|
915
1062
|
}
|
|
916
|
-
return
|
|
1063
|
+
return o;
|
|
917
1064
|
}
|
|
918
|
-
function
|
|
1065
|
+
function ye(e, t) {
|
|
919
1066
|
for (let n of t) if (n.children?.includes(e) || n.child === e) return n.id;
|
|
920
1067
|
return null;
|
|
921
1068
|
}
|
|
922
|
-
function
|
|
1069
|
+
function B(e, t) {
|
|
923
1070
|
let n = /* @__PURE__ */ new Map();
|
|
924
1071
|
for (let e of t) n.set(e.id, e);
|
|
925
1072
|
let r = [], i = /* @__PURE__ */ new Set();
|
|
@@ -934,18 +1081,18 @@ function Se(e, t) {
|
|
|
934
1081
|
}
|
|
935
1082
|
return a(e), r;
|
|
936
1083
|
}
|
|
937
|
-
function
|
|
938
|
-
return new
|
|
1084
|
+
function be(e, t, n) {
|
|
1085
|
+
return new z(e, t, void 0, n);
|
|
939
1086
|
}
|
|
940
1087
|
var V = class {
|
|
941
1088
|
#e;
|
|
942
1089
|
#t;
|
|
943
1090
|
constructor(e, t) {
|
|
944
|
-
this.#t = t ?? {}, this.#e = new
|
|
1091
|
+
this.#t = t ?? {}, this.#e = new z(e, (e) => {
|
|
945
1092
|
this.#t.onClientMessage?.(e);
|
|
946
1093
|
}, (e, t) => {
|
|
947
1094
|
this.#t.onRender?.(e, t);
|
|
948
|
-
});
|
|
1095
|
+
}, this.#t.registry);
|
|
949
1096
|
}
|
|
950
1097
|
/**
|
|
951
1098
|
* Process a raw A2UI server message.
|
|
@@ -953,7 +1100,7 @@ var V = class {
|
|
|
953
1100
|
* If a container is provided, it is used as the render target for new surfaces.
|
|
954
1101
|
*/
|
|
955
1102
|
receive(e, t) {
|
|
956
|
-
let n = typeof e == "string" ?
|
|
1103
|
+
let n = typeof e == "string" ? O(e) : e;
|
|
957
1104
|
if (!n) {
|
|
958
1105
|
this.#t.onClientMessage?.({ error: {
|
|
959
1106
|
surfaceId: "",
|
|
@@ -962,26 +1109,26 @@ var V = class {
|
|
|
962
1109
|
} });
|
|
963
1110
|
return;
|
|
964
1111
|
}
|
|
965
|
-
if (
|
|
1112
|
+
if (D(n)) {
|
|
966
1113
|
this.#n(n.requestCatalog.surfaceId);
|
|
967
1114
|
return;
|
|
968
1115
|
}
|
|
969
1116
|
this.#e.handleMessage(n, t);
|
|
970
1117
|
}
|
|
971
1118
|
#n(e) {
|
|
972
|
-
let t = { catalog: {
|
|
1119
|
+
let t = this.#t.registry?.getSupportedTypes() ?? M(), n = { catalog: {
|
|
973
1120
|
...e ? { surfaceId: e } : {},
|
|
974
|
-
supportedTypes: [...
|
|
1121
|
+
supportedTypes: [...t],
|
|
975
1122
|
version: this.#t.version ?? "0.9"
|
|
976
1123
|
} };
|
|
977
|
-
this.#t.onClientMessage?.(
|
|
1124
|
+
this.#t.onClientMessage?.(n);
|
|
978
1125
|
}
|
|
979
1126
|
/**
|
|
980
1127
|
* Parse a JSON string into a typed A2UI server message.
|
|
981
1128
|
* Returns null if invalid.
|
|
982
1129
|
*/
|
|
983
1130
|
parse(e) {
|
|
984
|
-
return
|
|
1131
|
+
return O(e);
|
|
985
1132
|
}
|
|
986
1133
|
/**
|
|
987
1134
|
* Convert a UIPlan to A2UI updateComponents format.
|
|
@@ -989,11 +1136,12 @@ var V = class {
|
|
|
989
1136
|
emit(e, t) {
|
|
990
1137
|
let n = t ?? e.id, r = {
|
|
991
1138
|
surfaceId: n,
|
|
992
|
-
version: this.#t.version
|
|
1139
|
+
version: this.#t.version,
|
|
1140
|
+
registry: this.#t.registry
|
|
993
1141
|
};
|
|
994
1142
|
return { updateComponents: {
|
|
995
1143
|
surfaceId: n,
|
|
996
|
-
components:
|
|
1144
|
+
components: fe(e.root, r)
|
|
997
1145
|
} };
|
|
998
1146
|
}
|
|
999
1147
|
/**
|
|
@@ -1015,16 +1163,16 @@ var V = class {
|
|
|
1015
1163
|
* Returns the list of A2UI component types supported by this adapter.
|
|
1016
1164
|
*/
|
|
1017
1165
|
getSupportedTypes() {
|
|
1018
|
-
return
|
|
1166
|
+
return this.#t.registry?.getSupportedTypes() ?? M();
|
|
1019
1167
|
}
|
|
1020
1168
|
destroy() {
|
|
1021
1169
|
this.#e.destroy();
|
|
1022
1170
|
}
|
|
1023
1171
|
};
|
|
1024
|
-
function
|
|
1172
|
+
function xe(e, t) {
|
|
1025
1173
|
return new V(e, t);
|
|
1026
1174
|
}
|
|
1027
|
-
var
|
|
1175
|
+
var Se = class {
|
|
1028
1176
|
#e;
|
|
1029
1177
|
#t;
|
|
1030
1178
|
#n;
|
|
@@ -1089,7 +1237,7 @@ var Te = class {
|
|
|
1089
1237
|
this.#o = null, this.#i !== "closed" && this.connect();
|
|
1090
1238
|
}, n);
|
|
1091
1239
|
}
|
|
1092
|
-
},
|
|
1240
|
+
}, Ce = class {
|
|
1093
1241
|
#e;
|
|
1094
1242
|
#t;
|
|
1095
1243
|
#n;
|
|
@@ -1149,13 +1297,13 @@ var Te = class {
|
|
|
1149
1297
|
this.#i !== e && (this.#i = e, this.#n.onStateChange?.(e));
|
|
1150
1298
|
}
|
|
1151
1299
|
};
|
|
1152
|
-
function
|
|
1153
|
-
return new
|
|
1300
|
+
function we(e, t, n) {
|
|
1301
|
+
return new Se(e, t, n);
|
|
1154
1302
|
}
|
|
1155
|
-
function
|
|
1156
|
-
return new
|
|
1303
|
+
function Te(e, t, n) {
|
|
1304
|
+
return new Ce(e, t, n);
|
|
1157
1305
|
}
|
|
1158
|
-
function
|
|
1306
|
+
function Ee(e, t) {
|
|
1159
1307
|
e.use("a2ui", () => new V(e, t));
|
|
1160
1308
|
}
|
|
1161
1309
|
var H = new Set([
|
|
@@ -1169,7 +1317,7 @@ var H = new Set([
|
|
|
1169
1317
|
* Find top-level `{}` blocks using brace-counting with string-escape awareness.
|
|
1170
1318
|
* Same algorithm as the workbench's `#getEnvelopes()` method.
|
|
1171
1319
|
*/
|
|
1172
|
-
function
|
|
1320
|
+
function De(e) {
|
|
1173
1321
|
let t = [], n = 0, r = -1, i = !1, a = !1;
|
|
1174
1322
|
for (let o = 0; o < e.length; o++) {
|
|
1175
1323
|
let s = e[o];
|
|
@@ -1202,8 +1350,8 @@ function Ae(e) {
|
|
|
1202
1350
|
* const ext = linter(a2uiLinter);
|
|
1203
1351
|
* ```
|
|
1204
1352
|
*/
|
|
1205
|
-
function
|
|
1206
|
-
let t = e.state.doc.toString(), n = [], r =
|
|
1353
|
+
function Oe(e) {
|
|
1354
|
+
let t = e.state.doc.toString(), n = [], r = De(t), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), o = [], s = /* @__PURE__ */ new Map();
|
|
1207
1355
|
for (let e of r) {
|
|
1208
1356
|
let { from: t, to: r, text: c } = e, l;
|
|
1209
1357
|
try {
|
|
@@ -1304,7 +1452,7 @@ function je(e) {
|
|
|
1304
1452
|
}
|
|
1305
1453
|
return n;
|
|
1306
1454
|
}
|
|
1307
|
-
const
|
|
1455
|
+
const ke = [
|
|
1308
1456
|
{
|
|
1309
1457
|
id: "general",
|
|
1310
1458
|
label: "General"
|
|
@@ -7660,36 +7808,39 @@ var W = [
|
|
|
7660
7808
|
"html",
|
|
7661
7809
|
"css",
|
|
7662
7810
|
"js",
|
|
7663
|
-
"components"
|
|
7664
|
-
|
|
7811
|
+
"components",
|
|
7812
|
+
"schema"
|
|
7813
|
+
], Ae = {
|
|
7665
7814
|
"json-in": "IN",
|
|
7666
7815
|
"json-out": "OUT",
|
|
7667
7816
|
html: "HTML",
|
|
7668
7817
|
css: "CSS",
|
|
7669
7818
|
js: "JS",
|
|
7670
|
-
components: "UI"
|
|
7671
|
-
|
|
7819
|
+
components: "UI",
|
|
7820
|
+
schema: "SCHEMA"
|
|
7821
|
+
}, je = {
|
|
7672
7822
|
"json-in": "brackets-curly",
|
|
7673
7823
|
"json-out": "chat-circle-dots",
|
|
7674
7824
|
html: "code",
|
|
7675
7825
|
css: "palette",
|
|
7676
7826
|
js: "terminal",
|
|
7677
|
-
components: "squares-four"
|
|
7678
|
-
|
|
7827
|
+
components: "squares-four",
|
|
7828
|
+
schema: "file-code"
|
|
7829
|
+
}, Me = h.define(), Ne = p.line({ class: "cm-a2ui-sent" }), Pe = p.line({ class: "cm-a2ui-next" }), Fe = g.define({
|
|
7679
7830
|
create() {
|
|
7680
7831
|
return p.none;
|
|
7681
7832
|
},
|
|
7682
7833
|
update(e, t) {
|
|
7683
|
-
for (let e of t.effects) if (e.is(
|
|
7834
|
+
for (let e of t.effects) if (e.is(Me)) {
|
|
7684
7835
|
let n = t.state.doc, { sentUpToLine: r, nextFromLine: i, nextToLine: a } = e.value, o = [];
|
|
7685
|
-
for (let e = 1; e <= Math.min(r, n.lines); e++) o.push(
|
|
7686
|
-
for (let e = Math.max(1, i); e <= Math.min(a, n.lines); e++) o.push(
|
|
7836
|
+
for (let e = 1; e <= Math.min(r, n.lines); e++) o.push(Ne.range(n.line(e).from));
|
|
7837
|
+
for (let e = Math.max(1, i); e <= Math.min(a, n.lines); e++) o.push(Pe.range(n.line(e).from));
|
|
7687
7838
|
return p.set(o, !0);
|
|
7688
7839
|
}
|
|
7689
7840
|
return e;
|
|
7690
7841
|
},
|
|
7691
7842
|
provide: (e) => m.decorations.from(e)
|
|
7692
|
-
}),
|
|
7843
|
+
}), Ie = class extends i {
|
|
7693
7844
|
static observedAttributes = ["stream"];
|
|
7694
7845
|
#e = d("");
|
|
7695
7846
|
#t = d(0);
|
|
@@ -7713,17 +7864,19 @@ var W = [
|
|
|
7713
7864
|
#y = null;
|
|
7714
7865
|
#b = null;
|
|
7715
7866
|
#x = null;
|
|
7716
|
-
#S =
|
|
7867
|
+
#S = null;
|
|
7717
7868
|
#C = /* @__PURE__ */ new Map();
|
|
7718
7869
|
#w = /* @__PURE__ */ new Map();
|
|
7719
|
-
#T =
|
|
7720
|
-
#E =
|
|
7870
|
+
#T = /* @__PURE__ */ new Map();
|
|
7871
|
+
#E = k.clone();
|
|
7721
7872
|
#D = null;
|
|
7722
7873
|
#O = null;
|
|
7723
7874
|
#k = null;
|
|
7724
7875
|
#A = null;
|
|
7725
7876
|
#j = null;
|
|
7726
7877
|
#M = null;
|
|
7878
|
+
#N = null;
|
|
7879
|
+
#P = null;
|
|
7727
7880
|
get stream() {
|
|
7728
7881
|
return this.#e.value;
|
|
7729
7882
|
}
|
|
@@ -7734,33 +7887,46 @@ var W = [
|
|
|
7734
7887
|
t !== n && (e === "stream" && (this.#e.value = n ?? "", this.#p && (this.#p.value = n ?? "")), super.attributeChangedCallback?.(e, t, n));
|
|
7735
7888
|
}
|
|
7736
7889
|
playAll() {
|
|
7737
|
-
this.#
|
|
7890
|
+
this.#ne();
|
|
7738
7891
|
}
|
|
7739
7892
|
step() {
|
|
7740
|
-
this.#
|
|
7893
|
+
this.#re();
|
|
7741
7894
|
}
|
|
7742
7895
|
stepBack() {
|
|
7743
|
-
this.#
|
|
7896
|
+
this.#ie();
|
|
7744
7897
|
}
|
|
7745
7898
|
reset() {
|
|
7746
|
-
this
|
|
7899
|
+
this.#ae();
|
|
7747
7900
|
}
|
|
7748
7901
|
setup() {
|
|
7749
|
-
super.setup(), this.#
|
|
7902
|
+
super.setup(), this.#Z(), this.#F(), this.#j = new a(this, { closeButton: !1 }), this.addEventListener("native:present", this.#ve), this.addEventListener("native:dismiss", this.#ye), this.#x && (this.#A = new o(this.#x, {
|
|
7750
7903
|
handleSelector: ".a2ui-resize-handle",
|
|
7751
7904
|
axis: "horizontal",
|
|
7752
7905
|
min: 200
|
|
7753
|
-
}), this.#
|
|
7906
|
+
}), this.#x.addEventListener("native:resize-end", this.#De)), this.#S && (this.#S.addEventListener("pointerdown", this.#q), this.#S.addEventListener("dblclick", this.#X)), this.addEffect(() => {
|
|
7754
7907
|
let e = this.#n.value;
|
|
7755
|
-
for (let [e, t] of this.#
|
|
7756
|
-
for (let [t, n] of this.#
|
|
7757
|
-
for (let [t, n] of this.#
|
|
7908
|
+
for (let [e, t] of this.#C) t.style.removeProperty("width");
|
|
7909
|
+
for (let [t, n] of this.#C) n.hidden = !e.has(t);
|
|
7910
|
+
for (let [t, n] of this.#T) n.toggleAttribute("data-active", e.has(t));
|
|
7758
7911
|
}), this.addEffect(() => {
|
|
7912
|
+
this.#E.version.value;
|
|
7759
7913
|
let e = this.#l.value;
|
|
7760
|
-
this.#v && this.#
|
|
7914
|
+
this.#v && this.#fe(this.#v, e);
|
|
7915
|
+
}), this.addEffect(() => {
|
|
7916
|
+
this.#E.version.value;
|
|
7917
|
+
let e = this.#y;
|
|
7918
|
+
if (e) {
|
|
7919
|
+
if (!e.extensions?.length) {
|
|
7920
|
+
requestAnimationFrame(() => {
|
|
7921
|
+
e.extensions = [v()], e.value = JSON.stringify(this.#E.toJSON(), null, 2);
|
|
7922
|
+
});
|
|
7923
|
+
return;
|
|
7924
|
+
}
|
|
7925
|
+
(e.shadowRoot ?? e).querySelector(".cm-focused") || (e.value = JSON.stringify(this.#E.toJSON(), null, 2));
|
|
7926
|
+
}
|
|
7761
7927
|
}), this.addEffect(() => {
|
|
7762
7928
|
let e = this.#i.value;
|
|
7763
|
-
this.#
|
|
7929
|
+
this.#le(e, this.#w.get("json-out") ?? null);
|
|
7764
7930
|
}), this.addEffect(() => {
|
|
7765
7931
|
let e = this.#a.value;
|
|
7766
7932
|
if (!this.#m) return;
|
|
@@ -7771,41 +7937,42 @@ var W = [
|
|
|
7771
7937
|
this.#m.value = r ? r + "\n\n" + n : n;
|
|
7772
7938
|
}), this.addEffect(() => {
|
|
7773
7939
|
let e = this.#s.value;
|
|
7774
|
-
this.#h && (this.#h.value = e ?
|
|
7940
|
+
this.#h && (this.#h.value = e ? Le(e) : "");
|
|
7775
7941
|
}), this.addEffect(() => {
|
|
7776
7942
|
let e = this.#c.value;
|
|
7777
7943
|
this.#g && (typeof e == "object" && e && Object.keys(e).length > 0 ? this.#g.value = JSON.stringify(e, null, 2) : this.#g.value = "");
|
|
7778
7944
|
}), this.addEffect(() => {
|
|
7779
7945
|
let e = this.#t.value, t = this.#p?.editorView;
|
|
7780
7946
|
if (!t) return;
|
|
7781
|
-
let n = this.#
|
|
7947
|
+
let n = this.#te(), r = 0, i = 0, a = 0;
|
|
7782
7948
|
for (let t = 0; t < n.length; t++) if (t < e) r = n[t].endLine;
|
|
7783
7949
|
else if (t === e) {
|
|
7784
7950
|
i = n[t].startLine, a = n[t].endLine;
|
|
7785
7951
|
break;
|
|
7786
7952
|
}
|
|
7787
|
-
t.dispatch({ effects:
|
|
7953
|
+
t.dispatch({ effects: Me.of({
|
|
7788
7954
|
sentUpToLine: r,
|
|
7789
7955
|
nextFromLine: i,
|
|
7790
7956
|
nextToLine: a
|
|
7791
7957
|
}) });
|
|
7792
7958
|
}), this.deferChildren(() => {
|
|
7793
|
-
this
|
|
7959
|
+
this.#$(), this.#ee(), this.#e.value || this.#xe("card");
|
|
7794
7960
|
});
|
|
7795
7961
|
}
|
|
7796
7962
|
teardown() {
|
|
7797
|
-
this.#
|
|
7963
|
+
this.#A?.destroy(), this.#A = null, this.removeEventListener("native:present", this.#ve), this.removeEventListener("native:dismiss", this.#ye), this.#j?.destroy(), this.#j = null, this.#M = null, this.#N = null, this.#x?.removeEventListener("native:resize-end", this.#De), this.#S?.removeEventListener("pointerdown", this.#q), this.#S?.removeEventListener("dblclick", this.#X), document.removeEventListener("pointermove", this.#J), document.removeEventListener("pointerup", this.#Y), this.#P = null, this.#x = null, this.#S = null, this.#C.clear(), this.#w.clear(), this.#T.clear(), this.#I(), this.#p = null, this.#m = null, this.#h = null, this.#g = null, this.#_ = null, this.#v = null, this.#y = null, this.#b = null, super.teardown();
|
|
7798
7964
|
}
|
|
7799
|
-
#
|
|
7800
|
-
x(), this.#
|
|
7965
|
+
#F() {
|
|
7966
|
+
x(), this.#D = new b({ allowUnregistered: !0 }), this.#O = xe(this.#D, {
|
|
7967
|
+
registry: this.#E,
|
|
7801
7968
|
onClientMessage: (e) => {
|
|
7802
|
-
this.#
|
|
7969
|
+
this.#se("received", e);
|
|
7803
7970
|
},
|
|
7804
7971
|
onRender: (e) => {
|
|
7805
|
-
this.#
|
|
7972
|
+
this.#se("info", { message: `Surface ${e} rendered` }), this.#V(), this.#H(), this.#G();
|
|
7806
7973
|
}
|
|
7807
|
-
}), this.#
|
|
7808
|
-
this.#
|
|
7974
|
+
}), this.#k = this.#D.bus.on((e) => e.type.startsWith("a2ui:"), (e) => {
|
|
7975
|
+
this.#ce("action", {
|
|
7809
7976
|
action: e.type,
|
|
7810
7977
|
payload: e.payload
|
|
7811
7978
|
}), this.dispatchEvent(new CustomEvent("native:a2ui-action", {
|
|
@@ -7817,18 +7984,44 @@ var W = [
|
|
|
7817
7984
|
}));
|
|
7818
7985
|
});
|
|
7819
7986
|
}
|
|
7820
|
-
#
|
|
7821
|
-
this.#
|
|
7987
|
+
#I() {
|
|
7988
|
+
this.#k?.(), this.#k = null;
|
|
7822
7989
|
try {
|
|
7823
|
-
this.#
|
|
7990
|
+
this.#O?.destroy();
|
|
7824
7991
|
} catch {}
|
|
7825
|
-
this.#
|
|
7992
|
+
this.#O = null, this.#D = null;
|
|
7826
7993
|
}
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
let e = this.#
|
|
7994
|
+
/** Destroy and recreate adapter (after registry swap). */
|
|
7995
|
+
#L() {
|
|
7996
|
+
let e = this.#e.value;
|
|
7997
|
+
this.#I(), this.#F(), e && (this.#t.value = 0, this.#b && (this.#b.textContent = ""), this.stream = e, this.#ne());
|
|
7998
|
+
}
|
|
7999
|
+
#R() {
|
|
8000
|
+
let e = this.#y;
|
|
8001
|
+
if (!e) return;
|
|
8002
|
+
let t;
|
|
8003
|
+
try {
|
|
8004
|
+
t = JSON.parse(e.value);
|
|
8005
|
+
} catch {
|
|
8006
|
+
return;
|
|
8007
|
+
}
|
|
8008
|
+
!t || typeof t != "object" || (this.#E = re.fromJSON(t), this.#L(), this.#v && this.#fe(this.#v, this.#l.value));
|
|
8009
|
+
}
|
|
8010
|
+
#z() {
|
|
8011
|
+
let e = this.#y;
|
|
8012
|
+
if (e) try {
|
|
8013
|
+
let t = JSON.parse(e.value);
|
|
8014
|
+
e.value = JSON.stringify(t, null, 2);
|
|
8015
|
+
} catch {}
|
|
8016
|
+
}
|
|
8017
|
+
#B() {
|
|
8018
|
+
this.#E = k.clone(), this.#L(), this.#y && (this.#y.value = JSON.stringify(this.#E.toJSON(), null, 2)), this.#v && this.#fe(this.#v, this.#l.value);
|
|
8019
|
+
}
|
|
8020
|
+
#V() {
|
|
8021
|
+
if (!this.#O) return;
|
|
8022
|
+
let e = this.#O.getSurfaceIds(), t = {};
|
|
7830
8023
|
for (let n of e) {
|
|
7831
|
-
let e = this.#
|
|
8024
|
+
let e = this.#O.getSurface(n), r = this.#O.getDataModel(n);
|
|
7832
8025
|
t[n] = {
|
|
7833
8026
|
surfaceId: n,
|
|
7834
8027
|
rendered: e?.rendered ?? !1,
|
|
@@ -7844,28 +8037,28 @@ var W = [
|
|
|
7844
8037
|
detail: n
|
|
7845
8038
|
}));
|
|
7846
8039
|
}
|
|
7847
|
-
#
|
|
7848
|
-
this.#
|
|
8040
|
+
#H() {
|
|
8041
|
+
this.#b && (this.#s.value = this.#b.innerHTML);
|
|
7849
8042
|
}
|
|
7850
8043
|
/** Cmd+S in the HTML pane: write edited HTML back to preview. */
|
|
7851
|
-
#
|
|
7852
|
-
!this.#h || !this.#
|
|
8044
|
+
#U() {
|
|
8045
|
+
!this.#h || !this.#b || (this.#b.innerHTML = this.#h.value, this.#G());
|
|
7853
8046
|
}
|
|
7854
8047
|
/** Cmd+S in the CSS pane: apply edited custom properties to the preview element. */
|
|
7855
|
-
#
|
|
7856
|
-
if (!(!this.#g || !this.#
|
|
8048
|
+
#W() {
|
|
8049
|
+
if (!(!this.#g || !this.#b)) try {
|
|
7857
8050
|
let e = JSON.parse(this.#g.value).computed;
|
|
7858
|
-
if (e) for (let [t, n] of Object.entries(e)) t.startsWith("--") && this.#
|
|
8051
|
+
if (e) for (let [t, n] of Object.entries(e)) t.startsWith("--") && this.#b.style.setProperty(t, n);
|
|
7859
8052
|
} catch {}
|
|
7860
8053
|
}
|
|
7861
|
-
#
|
|
7862
|
-
if (!this.#
|
|
7863
|
-
let e = this.#
|
|
8054
|
+
#G() {
|
|
8055
|
+
if (!this.#O || !this.#b) return;
|
|
8056
|
+
let e = this.#O.getSurfaceIds(), t = {};
|
|
7864
8057
|
for (let n of e) {
|
|
7865
|
-
let e = this.#
|
|
8058
|
+
let e = this.#O.getSurface(n);
|
|
7866
8059
|
e?.theme && (t[`${n}/theme`] = e.theme);
|
|
7867
8060
|
}
|
|
7868
|
-
let n = getComputedStyle(this.#
|
|
8061
|
+
let n = getComputedStyle(this.#b), r = [
|
|
7869
8062
|
"--n-ink",
|
|
7870
8063
|
"--n-background",
|
|
7871
8064
|
"--n-border-color",
|
|
@@ -7885,11 +8078,11 @@ var W = [
|
|
|
7885
8078
|
Object.keys(i).length && (t.computed = i), this.#c.value = t;
|
|
7886
8079
|
}
|
|
7887
8080
|
/** Get visible pane IDs in DOM order. */
|
|
7888
|
-
#
|
|
8081
|
+
#K() {
|
|
7889
8082
|
let e = this.#n.value;
|
|
7890
8083
|
return W.filter((t) => e.has(t));
|
|
7891
8084
|
}
|
|
7892
|
-
#
|
|
8085
|
+
#q = (e) => {
|
|
7893
8086
|
if (e.button !== 0) return;
|
|
7894
8087
|
let t = e.target.closest?.(".a2ui-resize-handle");
|
|
7895
8088
|
if (!t) return;
|
|
@@ -7897,33 +8090,33 @@ var W = [
|
|
|
7897
8090
|
if (!n?.classList.contains("a2ui-pane")) return;
|
|
7898
8091
|
let r = n.dataset.panel;
|
|
7899
8092
|
if (!r) return;
|
|
7900
|
-
let i = this.#
|
|
8093
|
+
let i = this.#K(), a = i.indexOf(r);
|
|
7901
8094
|
if (a === -1 || a >= i.length - 1) return;
|
|
7902
|
-
let o = i[a + 1], s = this.#
|
|
8095
|
+
let o = i[a + 1], s = this.#C.get(o);
|
|
7903
8096
|
if (!s) return;
|
|
7904
8097
|
e.preventDefault();
|
|
7905
|
-
let c = this.#
|
|
8098
|
+
let c = this.#x?.offsetWidth ?? 0, l = s.offsetWidth, u = [];
|
|
7906
8099
|
for (let e = 0; e <= a; e++) {
|
|
7907
|
-
let t = this.#
|
|
8100
|
+
let t = this.#C.get(i[e]);
|
|
7908
8101
|
t && u.push({
|
|
7909
8102
|
id: i[e],
|
|
7910
8103
|
startW: t.offsetWidth
|
|
7911
8104
|
});
|
|
7912
8105
|
}
|
|
7913
8106
|
for (let e of i) {
|
|
7914
|
-
let t = this.#
|
|
8107
|
+
let t = this.#C.get(e);
|
|
7915
8108
|
t && (t.style.width = `${t.offsetWidth}px`, t.style.removeProperty("flex-grow"));
|
|
7916
8109
|
}
|
|
7917
|
-
this.#
|
|
8110
|
+
this.#x && (this.#x.style.width = `${c}px`), this.#P = {
|
|
7918
8111
|
targetId: o,
|
|
7919
8112
|
startX: e.clientX,
|
|
7920
8113
|
previewStartW: c,
|
|
7921
8114
|
targetStartW: l,
|
|
7922
8115
|
leftPanes: u
|
|
7923
|
-
}, s.setAttribute("resizing", ""), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", this.#
|
|
8116
|
+
}, s.setAttribute("resizing", ""), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", this.#J), document.addEventListener("pointerup", this.#Y);
|
|
7924
8117
|
};
|
|
7925
|
-
#
|
|
7926
|
-
let t = this.#
|
|
8118
|
+
#J = (e) => {
|
|
8119
|
+
let t = this.#P;
|
|
7927
8120
|
if (!t) return;
|
|
7928
8121
|
let n = e.clientX - t.startX, r = Math.max(150, t.targetStartW - n), i = r - t.targetStartW, a = t.leftPanes.map((e) => e.startW), o = t.previewStartW, s = r;
|
|
7929
8122
|
if (i > 0) {
|
|
@@ -7942,45 +8135,45 @@ var W = [
|
|
|
7942
8135
|
let e = t.leftPanes.length - 1;
|
|
7943
8136
|
e >= 0 ? a[e] = t.leftPanes[e].startW + -i : o = t.previewStartW + -i;
|
|
7944
8137
|
}
|
|
7945
|
-
this.#
|
|
7946
|
-
let c = this.#
|
|
8138
|
+
this.#x && (this.#x.style.width = `${o}px`);
|
|
8139
|
+
let c = this.#C.get(t.targetId);
|
|
7947
8140
|
c && (c.style.width = `${s}px`);
|
|
7948
8141
|
for (let e = 0; e < t.leftPanes.length; e++) {
|
|
7949
|
-
let n = this.#
|
|
8142
|
+
let n = this.#C.get(t.leftPanes[e].id);
|
|
7950
8143
|
n && (n.style.width = `${a[e]}px`);
|
|
7951
8144
|
}
|
|
7952
8145
|
};
|
|
7953
|
-
#
|
|
7954
|
-
let t = this.#
|
|
8146
|
+
#Y = (e) => {
|
|
8147
|
+
let t = this.#P;
|
|
7955
8148
|
if (!t) return;
|
|
7956
|
-
if (this.#
|
|
7957
|
-
let e = this.#
|
|
8149
|
+
if (this.#x && this.#S) {
|
|
8150
|
+
let e = this.#S.offsetWidth;
|
|
7958
8151
|
if (e > 0) {
|
|
7959
|
-
let t = this.#
|
|
7960
|
-
this.#
|
|
8152
|
+
let t = this.#x.offsetWidth / e;
|
|
8153
|
+
this.#x.style.width = `${(t * 100).toFixed(2)}%`;
|
|
7961
8154
|
}
|
|
7962
8155
|
}
|
|
7963
|
-
let n = this.#
|
|
8156
|
+
let n = this.#K(), r = [];
|
|
7964
8157
|
for (let e of n) {
|
|
7965
|
-
let t = this.#
|
|
8158
|
+
let t = this.#C.get(e);
|
|
7966
8159
|
r.push(t?.offsetWidth ?? 0);
|
|
7967
8160
|
}
|
|
7968
8161
|
let i = r.reduce((e, t) => e + t, 0);
|
|
7969
8162
|
if (i > 0) for (let e = 0; e < n.length; e++) {
|
|
7970
|
-
let t = this.#
|
|
8163
|
+
let t = this.#C.get(n[e]);
|
|
7971
8164
|
t && (t.style.flexGrow = String(r[e] / i * n.length), t.style.removeProperty("width"));
|
|
7972
8165
|
}
|
|
7973
|
-
this.#
|
|
8166
|
+
this.#C.get(t.targetId)?.removeAttribute("resizing"), document.body.style.removeProperty("cursor"), document.body.style.removeProperty("user-select"), document.removeEventListener("pointermove", this.#J), document.removeEventListener("pointerup", this.#Y), this.#P = null;
|
|
7974
8167
|
};
|
|
7975
|
-
#
|
|
8168
|
+
#X = (e) => {
|
|
7976
8169
|
let t = e.target.closest?.(".a2ui-resize-handle");
|
|
7977
8170
|
if (t && t.parentElement?.classList.contains("a2ui-pane")) {
|
|
7978
|
-
this.#
|
|
7979
|
-
for (let [e, t] of this.#
|
|
8171
|
+
this.#x && this.#x.style.removeProperty("width");
|
|
8172
|
+
for (let [e, t] of this.#C) t.style.removeProperty("width"), t.style.removeProperty("flex-grow");
|
|
7980
8173
|
}
|
|
7981
8174
|
};
|
|
7982
|
-
#
|
|
7983
|
-
let e = document.createElement("header"), t = document.createElement("n-toolbar");
|
|
8175
|
+
#Z() {
|
|
8176
|
+
let e = document.createElement("n-header"), t = document.createElement("n-toolbar");
|
|
7984
8177
|
t.setAttribute("size", "sm"), t.setAttribute("variant", "ghost");
|
|
7985
8178
|
let n = document.createElement("n-select");
|
|
7986
8179
|
n.setAttribute("size", "sm"), n.setAttribute("inline", "");
|
|
@@ -7988,7 +8181,7 @@ var W = [
|
|
|
7988
8181
|
r.setAttribute("justify", "spread"), r.innerHTML = "<span slot=\"label\">Presets</span><n-icon name=\"caret-up-down\" slot=\"trailing\"></n-icon>", n.appendChild(r);
|
|
7989
8182
|
let i = document.createElement("n-listbox");
|
|
7990
8183
|
i.setAttribute("popover", "");
|
|
7991
|
-
for (let e of
|
|
8184
|
+
for (let e of ke) {
|
|
7992
8185
|
if ("hidden" in e && e.hidden) continue;
|
|
7993
8186
|
let t = Object.entries(U).filter(([t, n]) => n.group === e.id);
|
|
7994
8187
|
if (t.length === 0) continue;
|
|
@@ -8000,99 +8193,115 @@ var W = [
|
|
|
8000
8193
|
}
|
|
8001
8194
|
i.appendChild(n);
|
|
8002
8195
|
}
|
|
8003
|
-
n.appendChild(i), n.addEventListener("native:change", this.#
|
|
8196
|
+
n.appendChild(i), n.addEventListener("native:change", this.#be), t.appendChild(n);
|
|
8004
8197
|
for (let e of W) {
|
|
8005
8198
|
let n = document.createElement("n-button");
|
|
8006
|
-
n.setAttribute("variant", "ghost"), n.setAttribute("size", "sm"), n.textContent =
|
|
8199
|
+
n.setAttribute("variant", "ghost"), n.setAttribute("size", "sm"), n.textContent = Ae[e], this.#n.value.has(e) && n.toggleAttribute("data-active", !0), n.addEventListener("native:press", this.#je(e)), t.appendChild(n), this.#T.set(e, n);
|
|
8007
8200
|
}
|
|
8008
8201
|
let a = document.createElement("n-button");
|
|
8009
|
-
a.setAttribute("variant", "ghost"), a.setAttribute("size", "sm"), a.title = "Auto-play presets on load", a.innerHTML = "<n-icon name=\"lightning\"></n-icon>", a.addEventListener("native:press", this.#
|
|
8202
|
+
a.setAttribute("variant", "ghost"), a.setAttribute("size", "sm"), a.title = "Auto-play presets on load", a.innerHTML = "<n-icon name=\"lightning\"></n-icon>", a.addEventListener("native:press", this.#ke), t.appendChild(a), this.#N = a;
|
|
8010
8203
|
let o = document.createElement("n-button");
|
|
8011
|
-
o.setAttribute("variant", "ghost"), o.setAttribute("size", "sm"), o.title = "Expand", o.innerHTML = "<n-icon name=\"arrows-out-simple\"></n-icon>", o.addEventListener("native:press", this.#
|
|
8204
|
+
o.setAttribute("variant", "ghost"), o.setAttribute("size", "sm"), o.title = "Expand", o.innerHTML = "<n-icon name=\"arrows-out-simple\"></n-icon>", o.addEventListener("native:press", this.#_e), t.appendChild(o), this.#M = o;
|
|
8012
8205
|
let s = document.createElement("div");
|
|
8013
|
-
s.className = "a2ui-split", this.#
|
|
8206
|
+
s.className = "a2ui-split", this.#S = s;
|
|
8014
8207
|
let c = document.createElement("div");
|
|
8015
|
-
c.className = "a2ui-preview", this.#
|
|
8208
|
+
c.className = "a2ui-preview", this.#x = c;
|
|
8016
8209
|
let l = document.createElement("div");
|
|
8017
|
-
l.className = "a2ui-preview-content", c.appendChild(l), this.#
|
|
8210
|
+
l.className = "a2ui-preview-content", c.appendChild(l), this.#b = l;
|
|
8018
8211
|
let u = document.createElement("div");
|
|
8019
8212
|
u.className = "a2ui-resize-handle", c.appendChild(u), s.appendChild(c);
|
|
8020
8213
|
for (let e of W) {
|
|
8021
8214
|
let t = document.createElement("div");
|
|
8022
8215
|
t.className = "a2ui-pane", t.dataset.panel = e, this.#n.value.has(e) || (t.hidden = !0);
|
|
8023
|
-
let n = document.createElement("header"), r = document.createElement("nav"), i = document.createElement("n-icon");
|
|
8024
|
-
i.setAttribute("name",
|
|
8216
|
+
let n = document.createElement("n-header"), r = document.createElement("nav"), i = document.createElement("n-icon");
|
|
8217
|
+
i.setAttribute("name", je[e]), r.appendChild(i), n.appendChild(r);
|
|
8025
8218
|
let a = document.createElement("span");
|
|
8026
|
-
a.textContent =
|
|
8219
|
+
a.textContent = Ae[e], n.appendChild(a);
|
|
8027
8220
|
let o = document.createElement("aside");
|
|
8028
8221
|
if (e === "js" || e === "html" || e === "css") {
|
|
8029
8222
|
let t = document.createElement("n-button");
|
|
8030
|
-
t.setAttribute("variant", "ghost"), t.setAttribute("size", "sm"), t.title = "Reset to computed", t.innerHTML = "<n-icon name=\"arrow-counter-clockwise\"></n-icon>", t.addEventListener("native:press", this.#
|
|
8223
|
+
t.setAttribute("variant", "ghost"), t.setAttribute("size", "sm"), t.title = "Reset to computed", t.innerHTML = "<n-icon name=\"arrow-counter-clockwise\"></n-icon>", t.addEventListener("native:press", this.#Ae(e)), o.appendChild(t);
|
|
8031
8224
|
}
|
|
8032
8225
|
let c = document.createElement("n-button");
|
|
8033
|
-
if (c.setAttribute("variant", "ghost"), c.setAttribute("size", "sm"), c.title = "Close pane", c.innerHTML = "<n-icon name=\"x\"></n-icon>", c.addEventListener("native:press", this.#
|
|
8226
|
+
if (c.setAttribute("variant", "ghost"), c.setAttribute("size", "sm"), c.title = "Close pane", c.innerHTML = "<n-icon name=\"x\"></n-icon>", c.addEventListener("native:press", this.#je(e)), o.appendChild(c), n.appendChild(o), t.appendChild(n), e === "json-in") {
|
|
8034
8227
|
let e = document.createElement("n-toolbar");
|
|
8035
8228
|
e.setAttribute("variant", "plain"), e.setAttribute("size", "sm"), e.setAttribute("fill", "");
|
|
8036
|
-
let n = this.#
|
|
8037
|
-
n.addEventListener("native:press", this.#
|
|
8038
|
-
let r = this.#
|
|
8039
|
-
r.addEventListener("native:press", this.#
|
|
8040
|
-
let i = this.#
|
|
8041
|
-
i.addEventListener("native:press", this.#
|
|
8042
|
-
let a = this.#
|
|
8043
|
-
a.dataset.role = "run", a.addEventListener("native:press", this.#
|
|
8044
|
-
let o = document.createElement("
|
|
8045
|
-
o.setAttribute("orientation", "vertical");
|
|
8046
|
-
let s = this.#
|
|
8047
|
-
s.addEventListener("native:press", this.#
|
|
8048
|
-
let c = this.#
|
|
8049
|
-
c.addEventListener("native:press", this.#
|
|
8050
|
-
let l = this.#
|
|
8051
|
-
l.addEventListener("native:press", this.#
|
|
8052
|
-
let u = this.#
|
|
8053
|
-
u.addEventListener("native:press", this.#
|
|
8229
|
+
let n = this.#Q("Step back", "caret-left");
|
|
8230
|
+
n.addEventListener("native:press", this.#we);
|
|
8231
|
+
let r = this.#Q("Reset", "arrow-counter-clockwise");
|
|
8232
|
+
r.addEventListener("native:press", this.#Te);
|
|
8233
|
+
let i = this.#Q("Step forward", "caret-right");
|
|
8234
|
+
i.addEventListener("native:press", this.#Ce);
|
|
8235
|
+
let a = this.#Q("Play all", "play", !0);
|
|
8236
|
+
a.dataset.role = "run", a.addEventListener("native:press", this.#Se);
|
|
8237
|
+
let o = document.createElement("div");
|
|
8238
|
+
o.className = "divider", o.setAttribute("orientation", "vertical");
|
|
8239
|
+
let s = this.#Q("Insert createSurface", "plus-circle");
|
|
8240
|
+
s.addEventListener("native:press", this.#Ee("createSurface"));
|
|
8241
|
+
let c = this.#Q("Insert updateComponents", "squares-four");
|
|
8242
|
+
c.addEventListener("native:press", this.#Ee("updateComponents"));
|
|
8243
|
+
let l = this.#Q("Insert updateDataModel", "database");
|
|
8244
|
+
l.addEventListener("native:press", this.#Ee("updateDataModel"));
|
|
8245
|
+
let u = this.#Q("Insert deleteSurface", "minus-circle");
|
|
8246
|
+
u.addEventListener("native:press", this.#Ee("deleteSurface")), e.append(n, r, i, a, o, s, c, l, u), t.appendChild(e);
|
|
8247
|
+
}
|
|
8248
|
+
if (e === "schema") {
|
|
8249
|
+
let e = document.createElement("n-toolbar");
|
|
8250
|
+
e.setAttribute("variant", "plain"), e.setAttribute("size", "sm"), e.setAttribute("fill", "");
|
|
8251
|
+
let n = this.#Q("Apply schema", "play", !0);
|
|
8252
|
+
n.addEventListener("native:press", () => this.#R());
|
|
8253
|
+
let r = this.#Q("Format JSON", "text-align-left");
|
|
8254
|
+
r.addEventListener("native:press", () => this.#z());
|
|
8255
|
+
let i = document.createElement("div");
|
|
8256
|
+
i.className = "divider", i.setAttribute("orientation", "vertical");
|
|
8257
|
+
let a = this.#Q("Reset to defaults", "arrow-counter-clockwise");
|
|
8258
|
+
a.addEventListener("native:press", () => this.#B()), e.append(n, r, i, a), t.appendChild(e);
|
|
8054
8259
|
}
|
|
8055
8260
|
let l = document.createElement("div");
|
|
8056
|
-
if (l.className = "a2ui-pane-content", t.appendChild(l), this.#
|
|
8261
|
+
if (l.className = "a2ui-pane-content", t.appendChild(l), this.#w.set(e, l), e === "json-in" || e === "js" || e === "html" || e === "css") {
|
|
8057
8262
|
let t = document.createElement("native-codemirror");
|
|
8058
8263
|
t.setAttribute("line-numbers", "false"), l.appendChild(t), e === "json-in" ? this.#p = t : e === "js" ? this.#m = t : e === "html" ? this.#h = t : e === "css" && (this.#g = t);
|
|
8059
|
-
} else e === "components"
|
|
8264
|
+
} else if (e === "components") this.#v = l;
|
|
8265
|
+
else if (e === "schema") {
|
|
8266
|
+
let e = document.createElement("native-codemirror");
|
|
8267
|
+
e.setAttribute("line-numbers", "false"), l.appendChild(e), this.#y = e;
|
|
8268
|
+
}
|
|
8060
8269
|
let u = document.createElement("div");
|
|
8061
|
-
u.className = "a2ui-resize-handle", t.appendChild(u), s.appendChild(t), this.#
|
|
8270
|
+
u.className = "a2ui-resize-handle", t.appendChild(u), s.appendChild(t), this.#C.set(e, t);
|
|
8062
8271
|
}
|
|
8063
8272
|
e.appendChild(t), this.append(e, s);
|
|
8064
8273
|
}
|
|
8065
|
-
#
|
|
8274
|
+
#Q(e, t, n = !1) {
|
|
8066
8275
|
let r = document.createElement("n-button");
|
|
8067
8276
|
return r.title = e, r.setAttribute("variant", "ghost"), r.innerHTML = `<n-icon name="${t}"${n ? " weight=\"fill\"" : ""}></n-icon>`, r;
|
|
8068
8277
|
}
|
|
8069
|
-
|
|
8278
|
+
#$() {
|
|
8070
8279
|
let e = this.querySelector("script[type=\"a2ui/stream\"]");
|
|
8071
8280
|
if (e) {
|
|
8072
8281
|
let t = (e.textContent ?? "").trim();
|
|
8073
8282
|
this.#e.value = t, e.remove();
|
|
8074
8283
|
}
|
|
8075
8284
|
}
|
|
8076
|
-
#
|
|
8285
|
+
#ee() {
|
|
8077
8286
|
if (!this.#p) return;
|
|
8078
8287
|
this.#p.value = this.#e.value, this.#p.extensions = [
|
|
8079
8288
|
v(),
|
|
8080
|
-
|
|
8081
|
-
y(
|
|
8289
|
+
Fe,
|
|
8290
|
+
y(Oe)
|
|
8082
8291
|
], this.#p.addEventListener("native:input", (e) => {
|
|
8083
8292
|
this.#e.value = e.detail.value;
|
|
8084
8293
|
});
|
|
8085
8294
|
let e = _.of([{
|
|
8086
8295
|
key: "Mod-s",
|
|
8087
|
-
run: () => (this.#
|
|
8296
|
+
run: () => (this.#U(), !0)
|
|
8088
8297
|
}]), t = _.of([{
|
|
8089
8298
|
key: "Mod-s",
|
|
8090
|
-
run: () => (this.#
|
|
8299
|
+
run: () => (this.#W(), !0)
|
|
8091
8300
|
}]);
|
|
8092
8301
|
this.#m && (this.#m.extensions = [v()]), this.#h && (this.#h.extensions = [e]), this.#g && (this.#g.extensions = [v(), t]);
|
|
8093
8302
|
}
|
|
8094
8303
|
/** Parse JSON envelopes from the editor stream (supports multi-line formatted JSON). */
|
|
8095
|
-
#
|
|
8304
|
+
#te() {
|
|
8096
8305
|
let e = this.#e.value;
|
|
8097
8306
|
if (!e.trim()) return [];
|
|
8098
8307
|
let t = [], n = 0, r = -1, i = !1, a = !1;
|
|
@@ -8124,84 +8333,84 @@ var W = [
|
|
|
8124
8333
|
}
|
|
8125
8334
|
return t;
|
|
8126
8335
|
}
|
|
8127
|
-
#
|
|
8128
|
-
let e = this.#
|
|
8129
|
-
if (!(!this.#
|
|
8336
|
+
#ne() {
|
|
8337
|
+
let e = this.#te();
|
|
8338
|
+
if (!(!this.#O || !this.#b)) {
|
|
8130
8339
|
for (let t = this.#t.value; t < e.length; t++) try {
|
|
8131
8340
|
let n = JSON.parse(e[t].text);
|
|
8132
|
-
this.#
|
|
8341
|
+
this.#oe("sent", n), this.#O.receive(n, this.#b), this.#Oe(n);
|
|
8133
8342
|
} catch (n) {
|
|
8134
|
-
this.#
|
|
8343
|
+
this.#oe("error", {
|
|
8135
8344
|
envelope: t + 1,
|
|
8136
8345
|
message: String(n),
|
|
8137
8346
|
raw: e[t].text
|
|
8138
8347
|
});
|
|
8139
8348
|
}
|
|
8140
|
-
this.#t.value = e.length, this.#
|
|
8349
|
+
this.#t.value = e.length, this.#V(), this.#H(), this.#G();
|
|
8141
8350
|
}
|
|
8142
8351
|
}
|
|
8143
|
-
#
|
|
8144
|
-
let e = this.#
|
|
8145
|
-
if (!this.#
|
|
8352
|
+
#re() {
|
|
8353
|
+
let e = this.#te();
|
|
8354
|
+
if (!this.#O || !this.#b) return;
|
|
8146
8355
|
let t = this.#t.value;
|
|
8147
8356
|
if (!(t >= e.length)) {
|
|
8148
8357
|
try {
|
|
8149
8358
|
let n = JSON.parse(e[t].text);
|
|
8150
|
-
this.#
|
|
8359
|
+
this.#oe("sent", n), this.#O.receive(n, this.#b), this.#Oe(n);
|
|
8151
8360
|
} catch (n) {
|
|
8152
|
-
this.#
|
|
8361
|
+
this.#oe("error", {
|
|
8153
8362
|
envelope: t + 1,
|
|
8154
8363
|
message: String(n),
|
|
8155
8364
|
raw: e[t].text
|
|
8156
8365
|
});
|
|
8157
8366
|
}
|
|
8158
|
-
this.#t.value = t + 1, this.#
|
|
8367
|
+
this.#t.value = t + 1, this.#V(), this.#H(), this.#G();
|
|
8159
8368
|
}
|
|
8160
8369
|
}
|
|
8161
|
-
#
|
|
8370
|
+
#ie() {
|
|
8162
8371
|
if (this.#t.value <= 0) return;
|
|
8163
8372
|
let e = this.#t.value - 1;
|
|
8164
|
-
this.#
|
|
8165
|
-
let t = this.#
|
|
8166
|
-
if (!(!this.#
|
|
8373
|
+
this.#I(), this.#b && (this.#b.textContent = ""), this.#r.value = [], this.#i.value = [], this.#a.value = [], this.#o.value = null, this.#s.value = "", this.#c.value = null, this.#l.value = /* @__PURE__ */ new Set(), this.#u.value = "demo", this.#F(), this.#t.value = 0;
|
|
8374
|
+
let t = this.#te();
|
|
8375
|
+
if (!(!this.#O || !this.#b)) {
|
|
8167
8376
|
for (let n = 0; n < e; n++) try {
|
|
8168
8377
|
let e = JSON.parse(t[n].text);
|
|
8169
|
-
this.#
|
|
8378
|
+
this.#oe("sent", e), this.#O.receive(e, this.#b), this.#Oe(e);
|
|
8170
8379
|
} catch (e) {
|
|
8171
|
-
this.#
|
|
8380
|
+
this.#oe("error", {
|
|
8172
8381
|
envelope: n + 1,
|
|
8173
8382
|
message: String(e),
|
|
8174
8383
|
raw: t[n].text
|
|
8175
8384
|
});
|
|
8176
8385
|
}
|
|
8177
|
-
this.#t.value = e, this.#
|
|
8386
|
+
this.#t.value = e, this.#V(), this.#H(), this.#G();
|
|
8178
8387
|
}
|
|
8179
8388
|
}
|
|
8180
|
-
|
|
8181
|
-
this.#
|
|
8389
|
+
#ae() {
|
|
8390
|
+
this.#I(), this.#b && (this.#b.textContent = ""), this.#t.value = 0, this.#f = 0, this.#r.value = [], this.#i.value = [], this.#a.value = [], this.#m && (this.#m.value = ""), this.#o.value = null, this.#s.value = "", this.#c.value = null, this.#l.value = /* @__PURE__ */ new Set(), this.#ue = null, this.#de = "info", this.#u.value = "demo", this.#F();
|
|
8182
8391
|
}
|
|
8183
|
-
#
|
|
8392
|
+
#oe(e, t) {
|
|
8184
8393
|
this.#r.value = [...this.#r.value, {
|
|
8185
8394
|
type: e,
|
|
8186
8395
|
data: t,
|
|
8187
8396
|
timestamp: Date.now()
|
|
8188
8397
|
}];
|
|
8189
8398
|
}
|
|
8190
|
-
#
|
|
8399
|
+
#se(e, t) {
|
|
8191
8400
|
this.#i.value = [...this.#i.value, {
|
|
8192
8401
|
type: e,
|
|
8193
8402
|
data: t,
|
|
8194
8403
|
timestamp: Date.now()
|
|
8195
8404
|
}];
|
|
8196
8405
|
}
|
|
8197
|
-
#
|
|
8406
|
+
#ce(e, t) {
|
|
8198
8407
|
this.#a.value = [...this.#a.value, {
|
|
8199
8408
|
type: e,
|
|
8200
8409
|
data: t,
|
|
8201
8410
|
timestamp: Date.now()
|
|
8202
8411
|
}];
|
|
8203
8412
|
}
|
|
8204
|
-
#
|
|
8413
|
+
#le(e, t) {
|
|
8205
8414
|
if (t) {
|
|
8206
8415
|
if (t.textContent = "", e.length === 0) {
|
|
8207
8416
|
let e = document.createElement("span");
|
|
@@ -8211,8 +8420,8 @@ var W = [
|
|
|
8211
8420
|
for (let n of e) {
|
|
8212
8421
|
let e = document.createElement("div");
|
|
8213
8422
|
e.className = "a2ui-log-entry";
|
|
8214
|
-
let r = document.createElement("
|
|
8215
|
-
r.className = `a2ui-log-type a2ui-log-type--${n.type}`, r.textContent = n.type.toUpperCase();
|
|
8423
|
+
let r = document.createElement("span");
|
|
8424
|
+
r.className = `badge a2ui-log-type a2ui-log-type--${n.type}`, r.textContent = n.type.toUpperCase();
|
|
8216
8425
|
let i = document.createElement("span");
|
|
8217
8426
|
i.style.cssText = "opacity: 0.5; margin-left: 0.5rem; font-size: 0.75rem;";
|
|
8218
8427
|
let a = new Date(n.timestamp);
|
|
@@ -8224,11 +8433,11 @@ var W = [
|
|
|
8224
8433
|
}
|
|
8225
8434
|
}
|
|
8226
8435
|
/** Render the A2UI → native-ui component mapping table. */
|
|
8227
|
-
#
|
|
8228
|
-
#
|
|
8229
|
-
#
|
|
8230
|
-
if (e.textContent = "", this.#
|
|
8231
|
-
this.#
|
|
8436
|
+
#ue = null;
|
|
8437
|
+
#de = "info";
|
|
8438
|
+
#fe(e, t) {
|
|
8439
|
+
if (e.textContent = "", this.#ue) {
|
|
8440
|
+
this.#pe(e, this.#ue, t);
|
|
8232
8441
|
return;
|
|
8233
8442
|
}
|
|
8234
8443
|
let n = document.createElement("table");
|
|
@@ -8244,7 +8453,7 @@ var W = [
|
|
|
8244
8453
|
}
|
|
8245
8454
|
r.appendChild(i), n.appendChild(r);
|
|
8246
8455
|
let a = document.createElement("tbody");
|
|
8247
|
-
for (let [n, r] of
|
|
8456
|
+
for (let [n, r] of this.#E) {
|
|
8248
8457
|
let n = document.createElement("tr");
|
|
8249
8458
|
n.className = "a2ui-map-row", t.has(r.a2uiType) && n.classList.add("a2ui-map-active");
|
|
8250
8459
|
let i = document.createElement("td");
|
|
@@ -8252,39 +8461,39 @@ var W = [
|
|
|
8252
8461
|
let o = document.createElement("td"), s = document.createElement("code");
|
|
8253
8462
|
s.textContent = r.nativeTag, o.appendChild(s);
|
|
8254
8463
|
let c = document.createElement("td");
|
|
8255
|
-
c.textContent =
|
|
8256
|
-
this.#
|
|
8464
|
+
c.textContent = this.#E.getComponentCategory(r.a2uiType), c.className = "a2ui-map-category", n.append(i, o, c), n.addEventListener("click", () => {
|
|
8465
|
+
this.#ue = r.a2uiType, this.#fe(e, t);
|
|
8257
8466
|
}), a.appendChild(n);
|
|
8258
8467
|
}
|
|
8259
8468
|
n.appendChild(a);
|
|
8260
8469
|
let o = document.createElement("div");
|
|
8261
|
-
o.className = "a2ui-map-summary", o.textContent = t.size > 0 ? `${t.size} of ${
|
|
8470
|
+
o.className = "a2ui-map-summary", o.textContent = t.size > 0 ? `${t.size} of ${this.#E.size} types active` : `${this.#E.size} supported component types`, e.append(o, n);
|
|
8262
8471
|
}
|
|
8263
|
-
#
|
|
8264
|
-
let r =
|
|
8472
|
+
#pe(e, t, n) {
|
|
8473
|
+
let r = this.#E.get(t);
|
|
8265
8474
|
if (!r) return;
|
|
8266
|
-
let i = document.createElement("header");
|
|
8475
|
+
let i = document.createElement("n-header");
|
|
8267
8476
|
i.className = "a2ui-map-detail-header";
|
|
8268
8477
|
let a = document.createElement("nav"), o = document.createElement("n-button");
|
|
8269
8478
|
o.setAttribute("variant", "ghost"), o.setAttribute("size", "sm"), o.className = "a2ui-map-back", o.innerHTML = `<n-icon name="caret-left"></n-icon> ${r.a2uiType}`, o.addEventListener("native:press", () => {
|
|
8270
|
-
this.#
|
|
8479
|
+
this.#ue = null, this.#de = "info", this.#_ = null, this.#fe(e, n);
|
|
8271
8480
|
}), a.appendChild(o), i.appendChild(a);
|
|
8272
|
-
let s = this.#
|
|
8273
|
-
u.className = "a2ui-map-tab-bar", u.setAttribute("size", "xs"), u.setAttribute("inline", ""), u.value = this.#
|
|
8481
|
+
let s = this.#me(t), c = s.length > 0, l = document.createElement("aside"), u = document.createElement("n-segmented-control");
|
|
8482
|
+
u.className = "a2ui-map-tab-bar", u.setAttribute("size", "xs"), u.setAttribute("inline", ""), u.value = this.#de;
|
|
8274
8483
|
let d = document.createElement("n-segment");
|
|
8275
8484
|
d.setAttribute("value", "info"), d.textContent = "Info";
|
|
8276
8485
|
let f = document.createElement("n-segment");
|
|
8277
8486
|
if (f.setAttribute("value", "json"), f.textContent = c ? `JSON (${s.length})` : "JSON", c || f.setAttribute("disabled", ""), u.append(d, f), u.addEventListener("native:change", (t) => {
|
|
8278
8487
|
let r = t.detail;
|
|
8279
|
-
(r?.value === "info" || r?.value === "json") && (this.#
|
|
8280
|
-
}), l.appendChild(u), i.appendChild(l), e.appendChild(i), this.#
|
|
8488
|
+
(r?.value === "info" || r?.value === "json") && (this.#de = r.value, this.#fe(e, n));
|
|
8489
|
+
}), l.appendChild(u), i.appendChild(l), e.appendChild(i), this.#de === "info") {
|
|
8281
8490
|
this.#_ = null;
|
|
8282
8491
|
let i = document.createElement("div");
|
|
8283
8492
|
i.className = "a2ui-map-detail";
|
|
8284
8493
|
let a = [
|
|
8285
8494
|
["Tag", r.nativeTag],
|
|
8286
8495
|
["Children", r.childStrategy],
|
|
8287
|
-
["Category",
|
|
8496
|
+
["Category", this.#E.getComponentCategory(r.a2uiType)]
|
|
8288
8497
|
];
|
|
8289
8498
|
r.actionEvent && a.push(["Action", r.actionEvent]), r.defaultAttributes && a.push(["Defaults", Object.entries(r.defaultAttributes).map(([e, t]) => `${e}="${t}"`).join(", ")]), r.propertyMap && a.push(["Props", Object.entries(r.propertyMap).map(([e, t]) => `${e} → ${t}`).join(", ")]), r.variantMap && a.push(["Variants", Object.keys(r.variantMap).join(", ")]);
|
|
8290
8499
|
for (let [e, t] of a) {
|
|
@@ -8296,14 +8505,14 @@ var W = [
|
|
|
8296
8505
|
a.textContent = t, n.append(r, a), i.appendChild(n);
|
|
8297
8506
|
}
|
|
8298
8507
|
e.appendChild(i);
|
|
8299
|
-
let o =
|
|
8508
|
+
let o = this.#E.getCompatibleTypes(r.a2uiType).filter((e) => e !== t), s = n.has(t);
|
|
8300
8509
|
if (o.length > 0) {
|
|
8301
8510
|
let r = document.createElement("div");
|
|
8302
8511
|
r.className = "a2ui-map-alternatives";
|
|
8303
8512
|
let i = document.createElement("div");
|
|
8304
8513
|
i.className = "a2ui-map-alt-title", i.textContent = s ? "Swap To" : "Compatible Alternatives", r.appendChild(i);
|
|
8305
8514
|
for (let i of o) {
|
|
8306
|
-
let a =
|
|
8515
|
+
let a = this.#E.get(i);
|
|
8307
8516
|
if (!a) continue;
|
|
8308
8517
|
let o = document.createElement("div");
|
|
8309
8518
|
if (o.className = "a2ui-map-alt-row", n.has(i) && o.classList.add("a2ui-map-active"), s) {
|
|
@@ -8314,29 +8523,32 @@ var W = [
|
|
|
8314
8523
|
c.className = "a2ui-map-type", c.textContent = i;
|
|
8315
8524
|
let l = document.createElement("code");
|
|
8316
8525
|
l.textContent = a.nativeTag, o.append(c, l), s ? o.addEventListener("click", () => {
|
|
8317
|
-
this.#
|
|
8526
|
+
this.#ge(t, i), this.#ue = i, this.#de = "info", this.#_ = null, this.#fe(e, this.#l.value);
|
|
8318
8527
|
}) : o.addEventListener("click", () => {
|
|
8319
|
-
this.#
|
|
8528
|
+
this.#ue = i, this.#de = "info", this.#_ = null, this.#fe(e, n);
|
|
8320
8529
|
}), r.appendChild(o);
|
|
8321
8530
|
}
|
|
8322
8531
|
e.appendChild(r);
|
|
8323
8532
|
}
|
|
8324
8533
|
return;
|
|
8325
8534
|
}
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
|
|
8335
|
-
|
|
8535
|
+
if (this.#de === "json") {
|
|
8536
|
+
let n = document.createElement("div");
|
|
8537
|
+
n.className = "a2ui-map-editor-section";
|
|
8538
|
+
let r = document.createElement("n-toolbar");
|
|
8539
|
+
r.className = "a2ui-map-editor-toolbar";
|
|
8540
|
+
let i = document.createElement("n-button");
|
|
8541
|
+
i.setAttribute("variant", "ghost"), i.setAttribute("size", "sm"), i.title = "Apply changes to stream", i.innerHTML = "<n-icon name=\"play\" weight=\"fill\"></n-icon>", i.addEventListener("native:press", () => this.#he(t)), r.appendChild(i), n.appendChild(r);
|
|
8542
|
+
let a = document.createElement("native-codemirror");
|
|
8543
|
+
a.setAttribute("line-numbers", "false"), n.appendChild(a), this.#_ = a, requestAnimationFrame(() => {
|
|
8544
|
+
a.extensions = [v()], a.value = JSON.stringify(s, null, 2);
|
|
8545
|
+
}), e.appendChild(n);
|
|
8546
|
+
return;
|
|
8547
|
+
}
|
|
8336
8548
|
}
|
|
8337
8549
|
/** Extract all component instances of a given A2UI type from the current envelopes. */
|
|
8338
|
-
#
|
|
8339
|
-
let t = this.#
|
|
8550
|
+
#me(e) {
|
|
8551
|
+
let t = this.#te(), n = [];
|
|
8340
8552
|
for (let r of t) try {
|
|
8341
8553
|
let t = JSON.parse(r.text).updateComponents;
|
|
8342
8554
|
if (t?.components) for (let r of t.components) r.component === e && n.push(r);
|
|
@@ -8344,7 +8556,7 @@ var W = [
|
|
|
8344
8556
|
return n;
|
|
8345
8557
|
}
|
|
8346
8558
|
/** Apply edited component JSON back into the stream envelopes and replay. */
|
|
8347
|
-
#
|
|
8559
|
+
#he(e) {
|
|
8348
8560
|
if (!this.#_) return;
|
|
8349
8561
|
let t;
|
|
8350
8562
|
try {
|
|
@@ -8355,7 +8567,7 @@ var W = [
|
|
|
8355
8567
|
if (!Array.isArray(t)) return;
|
|
8356
8568
|
let n = /* @__PURE__ */ new Map();
|
|
8357
8569
|
for (let e of t) e.id && typeof e.id == "string" && n.set(e.id, e);
|
|
8358
|
-
let r = this.#
|
|
8570
|
+
let r = this.#te(), i = [];
|
|
8359
8571
|
for (let t of r) try {
|
|
8360
8572
|
let r = JSON.parse(t.text), a = r.updateComponents;
|
|
8361
8573
|
if (a?.components) for (let t = 0; t < a.components.length; t++) {
|
|
@@ -8369,15 +8581,15 @@ var W = [
|
|
|
8369
8581
|
} catch {
|
|
8370
8582
|
i.push(t.text);
|
|
8371
8583
|
}
|
|
8372
|
-
let a = i.join("\n\n"), o = this.#
|
|
8373
|
-
if (this
|
|
8374
|
-
let t = this.#
|
|
8584
|
+
let a = i.join("\n\n"), o = this.#ue;
|
|
8585
|
+
if (this.#ae(), this.#ue = o, this.stream = a, this.#ne(), this.#_) {
|
|
8586
|
+
let t = this.#me(e);
|
|
8375
8587
|
this.#_.value = JSON.stringify(t, null, 2);
|
|
8376
8588
|
}
|
|
8377
8589
|
}
|
|
8378
8590
|
/** Swap all instances of one A2UI component type for another in the stream and replay. */
|
|
8379
|
-
#
|
|
8380
|
-
let n = this.#
|
|
8591
|
+
#ge(e, t) {
|
|
8592
|
+
let n = this.#te();
|
|
8381
8593
|
if (n.length === 0) return;
|
|
8382
8594
|
let r = [];
|
|
8383
8595
|
for (let i of n) try {
|
|
@@ -8387,41 +8599,41 @@ var W = [
|
|
|
8387
8599
|
} catch {
|
|
8388
8600
|
r.push(i.text);
|
|
8389
8601
|
}
|
|
8390
|
-
let i = r.join("\n\n"), a = this.#
|
|
8391
|
-
this
|
|
8602
|
+
let i = r.join("\n\n"), a = this.#ue;
|
|
8603
|
+
this.#ae(), this.#ue = a, this.stream = i, this.#ne();
|
|
8392
8604
|
}
|
|
8393
|
-
#
|
|
8394
|
-
this.#
|
|
8605
|
+
#_e = () => {
|
|
8606
|
+
this.#j?.toggle();
|
|
8395
8607
|
};
|
|
8396
|
-
#
|
|
8397
|
-
this.#
|
|
8608
|
+
#ve = () => {
|
|
8609
|
+
this.#M && (this.#M.innerHTML = "<n-icon name=\"x\"></n-icon>", this.#M.title = "Close");
|
|
8398
8610
|
};
|
|
8399
|
-
#
|
|
8400
|
-
this.#
|
|
8611
|
+
#ye = () => {
|
|
8612
|
+
this.#M && (this.#M.innerHTML = "<n-icon name=\"arrows-out-simple\"></n-icon>", this.#M.title = "Expand");
|
|
8401
8613
|
};
|
|
8402
|
-
#
|
|
8614
|
+
#be = (e) => {
|
|
8403
8615
|
let t = e.detail?.value;
|
|
8404
|
-
t && this.#
|
|
8616
|
+
t && this.#xe(t);
|
|
8405
8617
|
};
|
|
8406
|
-
#
|
|
8618
|
+
#xe(e) {
|
|
8407
8619
|
if (!U[e]) return;
|
|
8408
8620
|
let t = U[e].envelopes.map((e) => JSON.stringify(e, null, 2)).join("\n\n");
|
|
8409
|
-
this
|
|
8621
|
+
this.#ae(), this.stream = t, this.#ne();
|
|
8410
8622
|
}
|
|
8411
|
-
#
|
|
8412
|
-
this.#
|
|
8623
|
+
#Se = () => {
|
|
8624
|
+
this.#ne();
|
|
8413
8625
|
};
|
|
8414
|
-
#
|
|
8415
|
-
this.#
|
|
8626
|
+
#Ce = () => {
|
|
8627
|
+
this.#re();
|
|
8416
8628
|
};
|
|
8417
|
-
#
|
|
8418
|
-
this.#
|
|
8629
|
+
#we = () => {
|
|
8630
|
+
this.#ie();
|
|
8419
8631
|
};
|
|
8420
|
-
#
|
|
8421
|
-
this
|
|
8632
|
+
#Te = () => {
|
|
8633
|
+
this.#ae();
|
|
8422
8634
|
};
|
|
8423
8635
|
/** Insert a lifecycle envelope template at the end of the editor stream. */
|
|
8424
|
-
#
|
|
8636
|
+
#Ee = (e) => () => {
|
|
8425
8637
|
let t = this.#u.value, n = {
|
|
8426
8638
|
createSurface: {
|
|
8427
8639
|
createSurface: { surfaceId: t },
|
|
@@ -8462,15 +8674,15 @@ var W = [
|
|
|
8462
8674
|
a.dispatch({ selection: { anchor: a.state.doc.line(e).from } }), a.dispatch({ effects: m.scrollIntoView(a.state.doc.line(e).from) });
|
|
8463
8675
|
}
|
|
8464
8676
|
};
|
|
8465
|
-
#
|
|
8466
|
-
if (!this.#
|
|
8467
|
-
let e = this.#
|
|
8677
|
+
#De = () => {
|
|
8678
|
+
if (!this.#x || !this.#S) return;
|
|
8679
|
+
let e = this.#S.offsetWidth;
|
|
8468
8680
|
if (e <= 0) return;
|
|
8469
|
-
let t = this.#
|
|
8470
|
-
this.#
|
|
8681
|
+
let t = this.#x.offsetWidth / e;
|
|
8682
|
+
this.#x.style.width = `${(t * 100).toFixed(2)}%`;
|
|
8471
8683
|
};
|
|
8472
8684
|
/** Track A2UI component types used in updateComponents envelopes. */
|
|
8473
|
-
#
|
|
8685
|
+
#Oe(e) {
|
|
8474
8686
|
let t = e.updateComponents;
|
|
8475
8687
|
if (t?.components) {
|
|
8476
8688
|
t.surfaceId && (this.#u.value = t.surfaceId);
|
|
@@ -8479,11 +8691,11 @@ var W = [
|
|
|
8479
8691
|
this.#l.value = e;
|
|
8480
8692
|
}
|
|
8481
8693
|
}
|
|
8482
|
-
#
|
|
8483
|
-
this.#d.value = !this.#d.value, this.#
|
|
8694
|
+
#ke = () => {
|
|
8695
|
+
this.#d.value = !this.#d.value, this.#N?.toggleAttribute("data-active", this.#d.value);
|
|
8484
8696
|
};
|
|
8485
8697
|
/** Reset an editable pane to its computed/generated content. */
|
|
8486
|
-
#
|
|
8698
|
+
#Ae = (e) => () => {
|
|
8487
8699
|
if (e === "js") {
|
|
8488
8700
|
if (!this.#m) return;
|
|
8489
8701
|
let e = this.#a.value;
|
|
@@ -8491,19 +8703,19 @@ var W = [
|
|
|
8491
8703
|
} else if (e === "html") {
|
|
8492
8704
|
if (!this.#h) return;
|
|
8493
8705
|
let e = this.#s.value;
|
|
8494
|
-
this.#h.value = e ?
|
|
8706
|
+
this.#h.value = e ? Le(e) : "";
|
|
8495
8707
|
} else if (e === "css") {
|
|
8496
8708
|
if (!this.#g) return;
|
|
8497
8709
|
let e = this.#c.value;
|
|
8498
8710
|
typeof e == "object" && e && Object.keys(e).length > 0 ? this.#g.value = JSON.stringify(e, null, 2) : this.#g.value = "";
|
|
8499
8711
|
}
|
|
8500
8712
|
};
|
|
8501
|
-
#
|
|
8713
|
+
#je = (e) => () => {
|
|
8502
8714
|
let t = new Set(this.#n.value);
|
|
8503
8715
|
t.has(e) ? t.delete(e) : t.add(e), this.#n.value = t;
|
|
8504
8716
|
};
|
|
8505
8717
|
};
|
|
8506
|
-
function
|
|
8718
|
+
function Le(e) {
|
|
8507
8719
|
let t = "", n = 0, r = 0;
|
|
8508
8720
|
for (; r < e.length;) if (e[r] === "<") {
|
|
8509
8721
|
let i = e.indexOf(">", r);
|
|
@@ -8518,7 +8730,7 @@ function Be(e) {
|
|
|
8518
8730
|
}
|
|
8519
8731
|
return t.trimEnd();
|
|
8520
8732
|
}
|
|
8521
|
-
var
|
|
8733
|
+
var Re = class {
|
|
8522
8734
|
#e = /* @__PURE__ */ new Set();
|
|
8523
8735
|
/** Emit an interaction event to all subscribers. */
|
|
8524
8736
|
emit(e) {
|
|
@@ -8534,7 +8746,7 @@ var G = class {
|
|
|
8534
8746
|
destroy() {
|
|
8535
8747
|
this.#e.clear();
|
|
8536
8748
|
}
|
|
8537
|
-
},
|
|
8749
|
+
}, ze = class {
|
|
8538
8750
|
id;
|
|
8539
8751
|
agentId;
|
|
8540
8752
|
catalog;
|
|
@@ -8546,9 +8758,9 @@ var G = class {
|
|
|
8546
8758
|
#i;
|
|
8547
8759
|
#a = /* @__PURE__ */ new Map();
|
|
8548
8760
|
constructor(e, t, n) {
|
|
8549
|
-
this.id = f("session"), this.agentId = n.agentId, this.catalog = n.catalog, this.#t = t, this.#i = new Set(n.surfaces ?? []), this.eventEmitter = new
|
|
8761
|
+
this.id = f("session"), this.agentId = n.agentId, this.catalog = n.catalog, this.#t = t, this.#i = new Set(n.surfaces ?? []), this.eventEmitter = new Re(), this.#e = new V(e, {
|
|
8550
8762
|
onClientMessage: (e) => {
|
|
8551
|
-
if (
|
|
8763
|
+
if (ee(e)) {
|
|
8552
8764
|
let t = e.action, n = {
|
|
8553
8765
|
surfaceId: t.surfaceId,
|
|
8554
8766
|
componentId: t.sourceComponentId,
|
|
@@ -8580,9 +8792,9 @@ var G = class {
|
|
|
8580
8792
|
*/
|
|
8581
8793
|
receive(e) {
|
|
8582
8794
|
if (this.#n === "terminated") return;
|
|
8583
|
-
let t = typeof e == "string" ?
|
|
8795
|
+
let t = typeof e == "string" ? O(e) : e;
|
|
8584
8796
|
if (!t) return;
|
|
8585
|
-
let n =
|
|
8797
|
+
let n = Be(t);
|
|
8586
8798
|
if (n && !this.#i.has(n) && !this.#t.isOwner(n, this)) {
|
|
8587
8799
|
this.#s("catalog-violation", n, "");
|
|
8588
8800
|
return;
|
|
@@ -8620,13 +8832,13 @@ var G = class {
|
|
|
8620
8832
|
if (n) for (let e of n) e(...t);
|
|
8621
8833
|
}
|
|
8622
8834
|
};
|
|
8623
|
-
function
|
|
8835
|
+
function Be(e) {
|
|
8624
8836
|
if (C(e)) return e.createSurface.surfaceId;
|
|
8625
8837
|
if (w(e)) return e.updateComponents.surfaceId;
|
|
8626
8838
|
if (T(e)) return e.updateDataModel.surfaceId;
|
|
8627
8839
|
if (E(e)) return e.deleteSurface.surfaceId;
|
|
8628
8840
|
}
|
|
8629
|
-
var
|
|
8841
|
+
var Ve = class {
|
|
8630
8842
|
#e = /* @__PURE__ */ new Map();
|
|
8631
8843
|
#t = /* @__PURE__ */ new Set();
|
|
8632
8844
|
#n = /* @__PURE__ */ new Set();
|
|
@@ -8706,7 +8918,7 @@ var Ue = class {
|
|
|
8706
8918
|
destroy() {
|
|
8707
8919
|
this.#e.clear(), this.#t.clear(), this.#n.clear();
|
|
8708
8920
|
}
|
|
8709
|
-
},
|
|
8921
|
+
}, He = class {
|
|
8710
8922
|
#e;
|
|
8711
8923
|
constructor(e) {
|
|
8712
8924
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -8755,7 +8967,7 @@ var Ue = class {
|
|
|
8755
8967
|
});
|
|
8756
8968
|
}
|
|
8757
8969
|
};
|
|
8758
|
-
function
|
|
8970
|
+
function Ue(e) {
|
|
8759
8971
|
return {
|
|
8760
8972
|
a2uiType: e.a2uiType,
|
|
8761
8973
|
tagName: e.nativeTag,
|
|
@@ -8768,23 +8980,23 @@ function Ge(e) {
|
|
|
8768
8980
|
* - `'core-only'`: excludes `native-dashboard-*` elements (recommended default)
|
|
8769
8981
|
* - `'full'`: all registered component types
|
|
8770
8982
|
*/
|
|
8771
|
-
function
|
|
8983
|
+
function G(e = "core-only") {
|
|
8772
8984
|
let t = [];
|
|
8773
|
-
for (let [n, r] of
|
|
8774
|
-
return new
|
|
8985
|
+
for (let [n, r] of ie) e === "core-only" && r.nativeTag.startsWith("native-dashboard-") || t.push(Ue(r));
|
|
8986
|
+
return new He(t);
|
|
8775
8987
|
}
|
|
8776
|
-
var
|
|
8988
|
+
var We = class {
|
|
8777
8989
|
surfaces;
|
|
8778
8990
|
#e;
|
|
8779
8991
|
#t = /* @__PURE__ */ new Map();
|
|
8780
8992
|
constructor(e) {
|
|
8781
|
-
this.#e = e, this.surfaces = new
|
|
8993
|
+
this.#e = e, this.surfaces = new Ve();
|
|
8782
8994
|
}
|
|
8783
8995
|
/** Create a new agent session with the given configuration. */
|
|
8784
8996
|
createSession(e) {
|
|
8785
8997
|
let t;
|
|
8786
|
-
t = e.catalog === "full" ?
|
|
8787
|
-
let n = new
|
|
8998
|
+
t = e.catalog === "full" ? G("full") : e.catalog === "core-only" ? G("core-only") : e.catalog;
|
|
8999
|
+
let n = new ze(this.#e, this.surfaces, {
|
|
8788
9000
|
agentId: e.agentId,
|
|
8789
9001
|
catalog: t,
|
|
8790
9002
|
surfaces: e.surfaces
|
|
@@ -8823,7 +9035,7 @@ var Ke = class {
|
|
|
8823
9035
|
destroy() {
|
|
8824
9036
|
this.terminateAll(), this.surfaces.destroy();
|
|
8825
9037
|
}
|
|
8826
|
-
},
|
|
9038
|
+
}, Ge = class {
|
|
8827
9039
|
type = "direct";
|
|
8828
9040
|
#e;
|
|
8829
9041
|
#t = null;
|
|
@@ -8860,7 +9072,7 @@ var Ke = class {
|
|
|
8860
9072
|
async disconnect() {
|
|
8861
9073
|
this.#r?.(), this.#r = null, this.#n && this.#t && this.#t.sessionManager.terminateSession(this.#n.id), this.#n = null, this.#t = null;
|
|
8862
9074
|
}
|
|
8863
|
-
},
|
|
9075
|
+
}, Ke = class {
|
|
8864
9076
|
type = "a2a";
|
|
8865
9077
|
#e;
|
|
8866
9078
|
#t = null;
|
|
@@ -8902,7 +9114,7 @@ var Ke = class {
|
|
|
8902
9114
|
#a() {
|
|
8903
9115
|
let e = this.#e.endpoint;
|
|
8904
9116
|
this.#r = new EventSource(e), this.#r.onmessage = (e) => {
|
|
8905
|
-
let t =
|
|
9117
|
+
let t = O(e.data);
|
|
8906
9118
|
t && this.#n?.receive(t);
|
|
8907
9119
|
}, this.#r.onerror = () => {};
|
|
8908
9120
|
}
|
|
@@ -8922,7 +9134,7 @@ var Ke = class {
|
|
|
8922
9134
|
});
|
|
8923
9135
|
} catch {}
|
|
8924
9136
|
}
|
|
8925
|
-
},
|
|
9137
|
+
}, qe = class {
|
|
8926
9138
|
type = "ag-ui";
|
|
8927
9139
|
#e;
|
|
8928
9140
|
#t = null;
|
|
@@ -8955,13 +9167,13 @@ var Ke = class {
|
|
|
8955
9167
|
}
|
|
8956
9168
|
#a(e, t) {
|
|
8957
9169
|
if (e.type === t && e.data) {
|
|
8958
|
-
let t =
|
|
9170
|
+
let t = O(typeof e.data == "string" ? e.data : JSON.stringify(e.data));
|
|
8959
9171
|
t && this.#n?.receive(t);
|
|
8960
9172
|
return;
|
|
8961
9173
|
}
|
|
8962
9174
|
e.type === "RUN_FINISHED" || e.type;
|
|
8963
9175
|
}
|
|
8964
|
-
},
|
|
9176
|
+
}, Je = class extends i {
|
|
8965
9177
|
static observedAttributes = [
|
|
8966
9178
|
"disabled",
|
|
8967
9179
|
"busy",
|
|
@@ -9091,7 +9303,7 @@ var Ke = class {
|
|
|
9091
9303
|
})) && !this.hasAttribute("no-auto-clear") && (this.value = "", this.#i?.setAttribute("disabled", ""));
|
|
9092
9304
|
}
|
|
9093
9305
|
}
|
|
9094
|
-
},
|
|
9306
|
+
}, Ye = class extends i {
|
|
9095
9307
|
static MAX_CONTEXT_MESSAGES = 50;
|
|
9096
9308
|
static observedAttributes = [
|
|
9097
9309
|
"show-stop",
|
|
@@ -9259,7 +9471,7 @@ var Ke = class {
|
|
|
9259
9471
|
}
|
|
9260
9472
|
setup() {
|
|
9261
9473
|
super.setup(), this.hasAttribute("open") && (this.#r.value = !0);
|
|
9262
|
-
let i = document.createElement("header");
|
|
9474
|
+
let i = document.createElement("n-header");
|
|
9263
9475
|
i.setAttribute("dividers", "");
|
|
9264
9476
|
let a = document.createElement("nav"), o = document.createElement("n-icon");
|
|
9265
9477
|
o.setAttribute("name", "chat-dots"), a.appendChild(o), i.appendChild(a);
|
|
@@ -9267,9 +9479,9 @@ var Ke = class {
|
|
|
9267
9479
|
s.textContent = "Assistant", i.appendChild(s);
|
|
9268
9480
|
let c = document.createElement("aside");
|
|
9269
9481
|
c.className = "n-chat-panel-header-trailing", i.appendChild(c), this.#v = c;
|
|
9270
|
-
let l = document.createElement("
|
|
9482
|
+
let l = document.createElement("n-body"), u = document.createElement("n-chat-content"), d = document.createElement("n-chat-feed");
|
|
9271
9483
|
d.setAttribute("auto-scroll", ""), u.appendChild(d), this.#h = d, l.appendChild(u);
|
|
9272
|
-
let f = document.createElement("footer");
|
|
9484
|
+
let f = document.createElement("n-footer");
|
|
9273
9485
|
f.setAttribute("dividers", ""), this.#m = f;
|
|
9274
9486
|
let p = document.createElement("n-chat-input"), m = document.createElement("n-textarea");
|
|
9275
9487
|
m.setAttribute("placeholder", "Ask anything"), m.setAttribute("autogrow", ""), m.setAttribute("rows", "3"), p.appendChild(m);
|
|
@@ -9610,7 +9822,7 @@ var Ke = class {
|
|
|
9610
9822
|
#B() {
|
|
9611
9823
|
this.#b &&= (this.#b.removeEventListener("native:change", this.#M), this.#b.remove(), null), this.#x = null;
|
|
9612
9824
|
}
|
|
9613
|
-
},
|
|
9825
|
+
}, Xe = 40, Ze = class extends i {
|
|
9614
9826
|
static observedAttributes = [
|
|
9615
9827
|
"auto-scroll",
|
|
9616
9828
|
"scrollable",
|
|
@@ -9719,7 +9931,7 @@ var Ke = class {
|
|
|
9719
9931
|
}
|
|
9720
9932
|
}
|
|
9721
9933
|
#f = () => {
|
|
9722
|
-
let e = this.#n.value, t = this.scrollTop + this.clientHeight >= this.scrollHeight -
|
|
9934
|
+
let e = this.#n.value, t = this.scrollTop + this.clientHeight >= this.scrollHeight - Xe;
|
|
9723
9935
|
this.#n.value = t, t !== e && this.dispatchEvent(new CustomEvent("native:feed-scroll", {
|
|
9724
9936
|
bubbles: !0,
|
|
9725
9937
|
composed: !0,
|
|
@@ -9737,7 +9949,7 @@ var Ke = class {
|
|
|
9737
9949
|
});
|
|
9738
9950
|
});
|
|
9739
9951
|
};
|
|
9740
|
-
},
|
|
9952
|
+
}, Qe = class extends i {
|
|
9741
9953
|
static observedAttributes = [
|
|
9742
9954
|
"src",
|
|
9743
9955
|
"name",
|
|
@@ -9777,7 +9989,7 @@ var Ke = class {
|
|
|
9777
9989
|
}
|
|
9778
9990
|
if (n) {
|
|
9779
9991
|
let e = document.createElement("span");
|
|
9780
|
-
e.className = "n-chat-avatar-initials", e.textContent =
|
|
9992
|
+
e.className = "n-chat-avatar-initials", e.textContent = $e(n), e.setAttribute("aria-hidden", "true"), this.appendChild(e);
|
|
9781
9993
|
return;
|
|
9782
9994
|
}
|
|
9783
9995
|
let r = document.createElement("n-icon");
|
|
@@ -9788,11 +10000,11 @@ var Ke = class {
|
|
|
9788
10000
|
this.textContent = "", super.teardown();
|
|
9789
10001
|
}
|
|
9790
10002
|
};
|
|
9791
|
-
function
|
|
10003
|
+
function $e(e) {
|
|
9792
10004
|
let t = e.trim().split(/\s+/);
|
|
9793
10005
|
return t.length === 0 ? "" : t.length === 1 ? t[0][0].toUpperCase() : (t[0][0] + t[t.length - 1][0]).toUpperCase();
|
|
9794
10006
|
}
|
|
9795
|
-
const
|
|
10007
|
+
const et = {
|
|
9796
10008
|
copy: {
|
|
9797
10009
|
label: "Copy",
|
|
9798
10010
|
icon: "copy"
|
|
@@ -9817,7 +10029,7 @@ const nt = {
|
|
|
9817
10029
|
label: "Continue",
|
|
9818
10030
|
icon: "arrow-right"
|
|
9819
10031
|
}
|
|
9820
|
-
},
|
|
10032
|
+
}, tt = {
|
|
9821
10033
|
assistant: [
|
|
9822
10034
|
"copy",
|
|
9823
10035
|
"retry",
|
|
@@ -9842,7 +10054,7 @@ const nt = {
|
|
|
9842
10054
|
* @fires native:message-action - Fired when an action button is clicked
|
|
9843
10055
|
* @fires native:continue-request - Fired when continue is requested for a partial message
|
|
9844
10056
|
*/
|
|
9845
|
-
var
|
|
10057
|
+
var nt = class extends i {
|
|
9846
10058
|
static observedAttributes = [
|
|
9847
10059
|
"data-role",
|
|
9848
10060
|
"message-id",
|
|
@@ -9961,12 +10173,12 @@ var it = class extends i {
|
|
|
9961
10173
|
#p(e, t, n, r, i) {
|
|
9962
10174
|
if (this.#o &&= (this.#f(), null), clearTimeout(this.#l), t === "none" || this.querySelector("[slot=\"actions\"]")) return;
|
|
9963
10175
|
let a;
|
|
9964
|
-
if (a = t ? t.split(",").map((e) => e.trim()).filter(Boolean) :
|
|
10176
|
+
if (a = t ? t.split(",").map((e) => e.trim()).filter(Boolean) : tt[e] ?? [], i === "partial" && !a.includes("continue") && (a = [...a, "continue"]), a.length === 0) return;
|
|
9965
10177
|
let o = document.createElement("n-toolbar");
|
|
9966
10178
|
o.dataset.role = "actions", o.setAttribute("padding", "tight"), o.setAttribute("aria-label", "Message actions"), n !== "label" && o.setAttribute("data-style", n);
|
|
9967
10179
|
for (let e of a) {
|
|
9968
|
-
let t =
|
|
9969
|
-
t && o.appendChild(
|
|
10180
|
+
let t = et[e];
|
|
10181
|
+
t && o.appendChild(rt(e, t, n));
|
|
9970
10182
|
}
|
|
9971
10183
|
if (o.children.length !== 0) {
|
|
9972
10184
|
if (o.addEventListener("native:press", this.#m), r === "below") {
|
|
@@ -9999,7 +10211,7 @@ var it = class extends i {
|
|
|
9999
10211
|
}
|
|
10000
10212
|
};
|
|
10001
10213
|
};
|
|
10002
|
-
function
|
|
10214
|
+
function rt(e, t, n) {
|
|
10003
10215
|
let r = document.createElement("n-button");
|
|
10004
10216
|
if (r.setAttribute("variant", "ghost"), r.setAttribute("size", "sm"), r.setAttribute("inline", ""), r.setAttribute("data-action", e), r.setAttribute("aria-label", t.label), n === "icon" || n === "icon-label") {
|
|
10005
10217
|
let e = document.createElement("n-icon");
|
|
@@ -10036,7 +10248,7 @@ function at(e, t, n) {
|
|
|
10036
10248
|
* @attr {string} sender - Display name of the sender
|
|
10037
10249
|
* @attr {string} avatar-align - `"top"` | `"center"` | `"bottom"` (default) — avatar vertical alignment
|
|
10038
10250
|
*/
|
|
10039
|
-
var
|
|
10251
|
+
var it = class extends i {
|
|
10040
10252
|
static observedAttributes = [
|
|
10041
10253
|
"data-role",
|
|
10042
10254
|
"sender",
|
|
@@ -10079,7 +10291,7 @@ var ot = class extends i {
|
|
|
10079
10291
|
for (let r of n) r instanceof Element && r.localName === "n-chat-avatar" || (r instanceof Element && r.localName === "n-chat-message" ? t.appendChild(r) : e.appendChild(r));
|
|
10080
10292
|
this.appendChild(e), this.appendChild(t), this.#t = e, this.#n = t;
|
|
10081
10293
|
}
|
|
10082
|
-
},
|
|
10294
|
+
}, at = class extends i {
|
|
10083
10295
|
static observedAttributes = ["format"];
|
|
10084
10296
|
#e = d("markdown");
|
|
10085
10297
|
#t = d("");
|
|
@@ -10105,7 +10317,7 @@ var ot = class extends i {
|
|
|
10105
10317
|
!this.#t.value && this.textContent?.trim() && (this.#t.value = this.textContent.trim()), this.#n = document.createElement("div"), this.#n.className = "n-chat-prose", this.textContent = "", this.appendChild(this.#n), this.addEffect(() => {
|
|
10106
10318
|
let e = this.#t.value, t = this.#e.value;
|
|
10107
10319
|
this.#n && (t === "plain" ? this.#n.textContent = e : (cancelAnimationFrame(this.#r), this.#r = requestAnimationFrame(() => {
|
|
10108
|
-
this.#n && (this.#n.innerHTML =
|
|
10320
|
+
this.#n && (this.#n.innerHTML = st(J(e)));
|
|
10109
10321
|
})));
|
|
10110
10322
|
});
|
|
10111
10323
|
});
|
|
@@ -10113,7 +10325,7 @@ var ot = class extends i {
|
|
|
10113
10325
|
teardown() {
|
|
10114
10326
|
cancelAnimationFrame(this.#r), this.#n = null, super.teardown();
|
|
10115
10327
|
}
|
|
10116
|
-
},
|
|
10328
|
+
}, ot = new Set([
|
|
10117
10329
|
"p",
|
|
10118
10330
|
"br",
|
|
10119
10331
|
"strong",
|
|
@@ -10133,14 +10345,14 @@ var ot = class extends i {
|
|
|
10133
10345
|
"blockquote",
|
|
10134
10346
|
"hr"
|
|
10135
10347
|
]);
|
|
10136
|
-
function
|
|
10348
|
+
function K(e) {
|
|
10137
10349
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
10138
10350
|
}
|
|
10139
|
-
function
|
|
10140
|
-
let t =
|
|
10351
|
+
function q(e) {
|
|
10352
|
+
let t = K(e);
|
|
10141
10353
|
return t = t.replace(/`([^`]+)`/g, "<code>$1</code>"), t = t.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), t = t.replace(/__(.+?)__/g, "<strong>$1</strong>"), t = t.replace(/\*(.+?)\*/g, "<em>$1</em>"), t = t.replace(/(?<!\w)_(.+?)_(?!\w)/g, "<em>$1</em>"), t = t.replace(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g, "<a href=\"$2\" rel=\"noopener noreferrer\" target=\"_blank\">$1</a>"), t;
|
|
10142
10354
|
}
|
|
10143
|
-
function
|
|
10355
|
+
function J(e) {
|
|
10144
10356
|
if (!e) return "";
|
|
10145
10357
|
let t = e.split("\n"), n = [], r = 0;
|
|
10146
10358
|
for (; r < t.length;) {
|
|
@@ -10149,14 +10361,14 @@ function Y(e) {
|
|
|
10149
10361
|
let i = e.slice(3).trim(), a = [];
|
|
10150
10362
|
for (r += 1; r < t.length && !t[r].startsWith("```");) a.push(t[r]), r += 1;
|
|
10151
10363
|
r += 1;
|
|
10152
|
-
let o = i ? ` data-lang="${
|
|
10153
|
-
n.push(`<pre${o}><code>${
|
|
10364
|
+
let o = i ? ` data-lang="${K(i)}"` : "";
|
|
10365
|
+
n.push(`<pre${o}><code>${K(a.join("\n"))}</code></pre>`);
|
|
10154
10366
|
continue;
|
|
10155
10367
|
}
|
|
10156
10368
|
let i = e.match(/^(#{1,6})\s+(.+)/);
|
|
10157
10369
|
if (i) {
|
|
10158
10370
|
let e = i[1].length;
|
|
10159
|
-
n.push(`<h${e}>${
|
|
10371
|
+
n.push(`<h${e}>${q(i[2])}</h${e}>`), r += 1;
|
|
10160
10372
|
continue;
|
|
10161
10373
|
}
|
|
10162
10374
|
if (/^---+$/.test(e.trim()) || /^\*\*\*+$/.test(e.trim())) {
|
|
@@ -10166,19 +10378,19 @@ function Y(e) {
|
|
|
10166
10378
|
if (e.startsWith("> ")) {
|
|
10167
10379
|
let e = [];
|
|
10168
10380
|
for (; r < t.length && t[r].startsWith("> ");) e.push(t[r].slice(2)), r += 1;
|
|
10169
|
-
n.push(`<blockquote>${
|
|
10381
|
+
n.push(`<blockquote>${J(e.join("\n"))}</blockquote>`);
|
|
10170
10382
|
continue;
|
|
10171
10383
|
}
|
|
10172
10384
|
if (/^[-*+]\s/.test(e)) {
|
|
10173
10385
|
let e = [];
|
|
10174
10386
|
for (; r < t.length && /^[-*+]\s/.test(t[r]);) e.push(t[r].replace(/^[-*+]\s/, "")), r += 1;
|
|
10175
|
-
n.push("<ul>" + e.map((e) => `<li>${
|
|
10387
|
+
n.push("<ul>" + e.map((e) => `<li>${q(e)}</li>`).join("") + "</ul>");
|
|
10176
10388
|
continue;
|
|
10177
10389
|
}
|
|
10178
10390
|
if (/^\d+\.\s/.test(e)) {
|
|
10179
10391
|
let e = [];
|
|
10180
10392
|
for (; r < t.length && /^\d+\.\s/.test(t[r]);) e.push(t[r].replace(/^\d+\.\s/, "")), r += 1;
|
|
10181
|
-
n.push("<ol>" + e.map((e) => `<li>${
|
|
10393
|
+
n.push("<ol>" + e.map((e) => `<li>${q(e)}</li>`).join("") + "</ol>");
|
|
10182
10394
|
continue;
|
|
10183
10395
|
}
|
|
10184
10396
|
if (!e.trim()) {
|
|
@@ -10187,15 +10399,15 @@ function Y(e) {
|
|
|
10187
10399
|
}
|
|
10188
10400
|
let a = [];
|
|
10189
10401
|
for (; r < t.length && t[r].trim() && !t[r].startsWith("#") && !t[r].startsWith("```") && !t[r].startsWith("> ") && !/^[-*+]\s/.test(t[r]) && !/^\d+\.\s/.test(t[r]) && !/^---+$/.test(t[r].trim());) a.push(t[r]), r += 1;
|
|
10190
|
-
a.length > 0 && n.push(`<p>${
|
|
10402
|
+
a.length > 0 && n.push(`<p>${q(a.join("\n"))}</p>`);
|
|
10191
10403
|
}
|
|
10192
10404
|
return n.join("");
|
|
10193
10405
|
}
|
|
10194
10406
|
/** Sanitize rendered HTML — strip any tags not in allowlist. */
|
|
10195
|
-
function
|
|
10407
|
+
function st(e) {
|
|
10196
10408
|
return e.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g, (e, t) => {
|
|
10197
10409
|
let n = t.toLowerCase();
|
|
10198
|
-
return
|
|
10410
|
+
return ot.has(n) ? e : "";
|
|
10199
10411
|
});
|
|
10200
10412
|
}
|
|
10201
10413
|
/**
|
|
@@ -10216,7 +10428,7 @@ function lt(e) {
|
|
|
10216
10428
|
* @attr {boolean} expandable - Allow click to expand trace content
|
|
10217
10429
|
* @fires native:activity-toggle - Fired when trace is expanded/collapsed
|
|
10218
10430
|
*/
|
|
10219
|
-
var
|
|
10431
|
+
var ct = class extends i {
|
|
10220
10432
|
static observedAttributes = [
|
|
10221
10433
|
"type",
|
|
10222
10434
|
"label",
|
|
@@ -10274,7 +10486,7 @@ var ut = class extends i {
|
|
|
10274
10486
|
this.#r.value ? (this.#p(), this.#e.states.add("active")) : (this.#m(), this.#e.states.delete("active"));
|
|
10275
10487
|
}), this.addEffect(() => {
|
|
10276
10488
|
if (!this.#c) return;
|
|
10277
|
-
let e = this.#n.value ||
|
|
10489
|
+
let e = this.#n.value || lt(this.#t.value);
|
|
10278
10490
|
this.#c.textContent = e;
|
|
10279
10491
|
}), this.addEffect(() => {
|
|
10280
10492
|
this.#u && (this.#u.hidden = !this.#r.value);
|
|
@@ -10304,7 +10516,7 @@ var ut = class extends i {
|
|
|
10304
10516
|
#h = () => {
|
|
10305
10517
|
if (!this.#r.value || !this.#l) return;
|
|
10306
10518
|
let e = performance.now() - this.#o;
|
|
10307
|
-
this.#l.textContent =
|
|
10519
|
+
this.#l.textContent = ut(e), this.#s = requestAnimationFrame(this.#h);
|
|
10308
10520
|
};
|
|
10309
10521
|
#g = () => {
|
|
10310
10522
|
this.#i.value && (this.#a.value = !this.#a.value, this.toggleAttribute("expanded", this.#a.value), this.dispatchEvent(new CustomEvent("native:activity-toggle", {
|
|
@@ -10314,14 +10526,14 @@ var ut = class extends i {
|
|
|
10314
10526
|
})));
|
|
10315
10527
|
};
|
|
10316
10528
|
};
|
|
10317
|
-
function
|
|
10529
|
+
function lt(e) {
|
|
10318
10530
|
switch (e) {
|
|
10319
10531
|
case "thinking": return "Thinking…";
|
|
10320
10532
|
case "tool-use": return "Using tools…";
|
|
10321
10533
|
default: return "Host is typing…";
|
|
10322
10534
|
}
|
|
10323
10535
|
}
|
|
10324
|
-
function
|
|
10536
|
+
function ut(e) {
|
|
10325
10537
|
let t = Math.floor(e / 1e3);
|
|
10326
10538
|
if (t < 60) return `${t}s`;
|
|
10327
10539
|
let n = Math.floor(t / 60), r = t % 60;
|
|
@@ -10341,7 +10553,7 @@ function ft(e) {
|
|
|
10341
10553
|
* @attr {boolean} disabled - Disables all chips
|
|
10342
10554
|
* @fires native:seed-select - Fired when a chip is clicked
|
|
10343
10555
|
*/
|
|
10344
|
-
var
|
|
10556
|
+
var dt = class extends i {
|
|
10345
10557
|
static observedAttributes = ["options", "disabled"];
|
|
10346
10558
|
#e;
|
|
10347
10559
|
#t = d([]);
|
|
@@ -10382,8 +10594,8 @@ var pt = class extends i {
|
|
|
10382
10594
|
super.setup(), this.addEffect(l(this, this.#n, this.#e)), this.addEffect(() => {
|
|
10383
10595
|
let e = this.#t.value;
|
|
10384
10596
|
this.textContent = "";
|
|
10385
|
-
let t = document.createElement("
|
|
10386
|
-
t.setAttribute("direction", "row"), t.setAttribute("wrap", "");
|
|
10597
|
+
let t = document.createElement("div");
|
|
10598
|
+
t.className = "stack", t.setAttribute("direction", "row"), t.setAttribute("wrap", "");
|
|
10387
10599
|
for (let n of e) {
|
|
10388
10600
|
let e = document.createElement("n-button");
|
|
10389
10601
|
if (e.setAttribute("variant", "outline"), e.setAttribute("size", "sm"), e.setAttribute("inline", ""), e.setAttribute("data-value", n.value), n.icon) {
|
|
@@ -10413,7 +10625,7 @@ var pt = class extends i {
|
|
|
10413
10625
|
}
|
|
10414
10626
|
}));
|
|
10415
10627
|
};
|
|
10416
|
-
},
|
|
10628
|
+
}, ft = new Set([
|
|
10417
10629
|
"script",
|
|
10418
10630
|
"style",
|
|
10419
10631
|
"link",
|
|
@@ -10430,7 +10642,7 @@ var pt = class extends i {
|
|
|
10430
10642
|
"frame",
|
|
10431
10643
|
"frameset",
|
|
10432
10644
|
"noscript"
|
|
10433
|
-
]),
|
|
10645
|
+
]), pt = class extends i {
|
|
10434
10646
|
static observedAttributes = ["schema-type", "mode"];
|
|
10435
10647
|
#e;
|
|
10436
10648
|
#t = d("a2ui");
|
|
@@ -10476,7 +10688,7 @@ var pt = class extends i {
|
|
|
10476
10688
|
super.setup(), this.#i = document.createElement("div"), this.#i.className = "n-chat-genui-container", this.appendChild(this.#i), this.addEffect(() => {
|
|
10477
10689
|
let e = this.#r.value, t = this.#n.value;
|
|
10478
10690
|
if (!this.#i || (this.#i.textContent = "", !e)) return;
|
|
10479
|
-
let n =
|
|
10691
|
+
let n = mt(e);
|
|
10480
10692
|
if (n.length > 0) {
|
|
10481
10693
|
this.#o(n), this.dispatchEvent(new CustomEvent("native:genui-error", {
|
|
10482
10694
|
bubbles: !0,
|
|
@@ -10487,7 +10699,7 @@ var pt = class extends i {
|
|
|
10487
10699
|
}
|
|
10488
10700
|
if (t === "lightbox") this.#s(e);
|
|
10489
10701
|
else {
|
|
10490
|
-
let t =
|
|
10702
|
+
let t = Y(e);
|
|
10491
10703
|
t && this.#i.appendChild(t);
|
|
10492
10704
|
}
|
|
10493
10705
|
this.#e.states.add("rendered");
|
|
@@ -10503,7 +10715,7 @@ var pt = class extends i {
|
|
|
10503
10715
|
}
|
|
10504
10716
|
#s(e) {
|
|
10505
10717
|
if (!this.#i) return;
|
|
10506
|
-
let t = document.createElement("n-
|
|
10718
|
+
let t = document.createElement("n-container");
|
|
10507
10719
|
t.dataset.role = "preview";
|
|
10508
10720
|
let n = document.createElement("span");
|
|
10509
10721
|
n.textContent = `Interactive UI (${e.tag})`, t.appendChild(n);
|
|
@@ -10512,7 +10724,7 @@ var pt = class extends i {
|
|
|
10512
10724
|
}
|
|
10513
10725
|
#c(e) {
|
|
10514
10726
|
this.#l();
|
|
10515
|
-
let t = document.createElement("n-dialog"), n =
|
|
10727
|
+
let t = document.createElement("n-dialog"), n = Y(e);
|
|
10516
10728
|
n && t.appendChild(n), this.appendChild(t), this.#a = t, requestAnimationFrame(() => {
|
|
10517
10729
|
let e = t.querySelector("dialog");
|
|
10518
10730
|
e && e.showModal();
|
|
@@ -10540,20 +10752,20 @@ var pt = class extends i {
|
|
|
10540
10752
|
}));
|
|
10541
10753
|
};
|
|
10542
10754
|
};
|
|
10543
|
-
function
|
|
10755
|
+
function mt(e, t = 0) {
|
|
10544
10756
|
let n = [];
|
|
10545
10757
|
if (t > 20) return n.push("Maximum nesting depth (20) exceeded"), n;
|
|
10546
10758
|
if (!e.tag || typeof e.tag != "string") return n.push("Node missing required \"tag\" property"), n;
|
|
10547
|
-
if (
|
|
10759
|
+
if (ft.has(e.tag.toLowerCase()) && n.push(`Forbidden tag: <${e.tag}>`), e.children) for (let r of e.children) n.push(...mt(r, t + 1));
|
|
10548
10760
|
return n;
|
|
10549
10761
|
}
|
|
10550
|
-
function
|
|
10551
|
-
if (
|
|
10762
|
+
function Y(e) {
|
|
10763
|
+
if (ft.has(e.tag.toLowerCase())) return null;
|
|
10552
10764
|
let t = document.createElement(e.tag);
|
|
10553
10765
|
if (e.id && (t.id = e.id), e.slot && (t.slot = e.slot), e.attributes) for (let [n, r] of Object.entries(e.attributes)) t.setAttribute(n, r);
|
|
10554
10766
|
if (e.properties) for (let [n, r] of Object.entries(e.properties)) t[n] = r;
|
|
10555
10767
|
if (e.text && (t.textContent = e.text), e.children) for (let n of e.children) {
|
|
10556
|
-
let e =
|
|
10768
|
+
let e = Y(n);
|
|
10557
10769
|
e && t.appendChild(e);
|
|
10558
10770
|
}
|
|
10559
10771
|
return t;
|
|
@@ -10578,7 +10790,7 @@ function X(e) {
|
|
|
10578
10790
|
* @fires native:structured-submit - Fired on submit with selections
|
|
10579
10791
|
* @fires native:structured-cancel - Fired when dismissed without selecting
|
|
10580
10792
|
*/
|
|
10581
|
-
var
|
|
10793
|
+
var ht = class extends i {
|
|
10582
10794
|
static observedAttributes = [
|
|
10583
10795
|
"question",
|
|
10584
10796
|
"type",
|
|
@@ -10667,8 +10879,8 @@ var _t = class extends i {
|
|
|
10667
10879
|
let t = document.createElement("div");
|
|
10668
10880
|
t.className = "n-chat-structured-question", t.textContent = e, this.appendChild(t);
|
|
10669
10881
|
}
|
|
10670
|
-
let r = document.createElement("
|
|
10671
|
-
r.setAttribute("direction", "row"), r.setAttribute("wrap", ""), r.setAttribute("role", n === "multi" ? "group" : "radiogroup");
|
|
10882
|
+
let r = document.createElement("div");
|
|
10883
|
+
r.className = "stack", r.setAttribute("direction", "row"), r.setAttribute("wrap", ""), r.setAttribute("role", n === "multi" ? "group" : "radiogroup");
|
|
10672
10884
|
for (let e of t) {
|
|
10673
10885
|
let t = document.createElement("n-button");
|
|
10674
10886
|
if (t.setAttribute("variant", "outline"), t.setAttribute("data-value", e.value), t.setAttribute("aria-pressed", "false"), e.icon) {
|
|
@@ -10719,7 +10931,7 @@ var _t = class extends i {
|
|
|
10719
10931
|
* Reads `data:` lines from the response body, skips empty lines and comments,
|
|
10720
10932
|
* handles the `[DONE]` sentinel, and accumulates the full message across chunks.
|
|
10721
10933
|
*/
|
|
10722
|
-
async function*
|
|
10934
|
+
async function* gt(e) {
|
|
10723
10935
|
let t = e.body.getReader(), n = new TextDecoder("utf-8"), r = "", i = "";
|
|
10724
10936
|
try {
|
|
10725
10937
|
for (;;) {
|
|
@@ -10799,7 +11011,7 @@ async function* vt(e) {
|
|
|
10799
11011
|
* Each non-empty line is parsed as a standalone JSON object.
|
|
10800
11012
|
* Accumulates the full message across chunks.
|
|
10801
11013
|
*/
|
|
10802
|
-
async function*
|
|
11014
|
+
async function* _t(e) {
|
|
10803
11015
|
let t = e.body.getReader(), n = new TextDecoder("utf-8"), r = "", i = "";
|
|
10804
11016
|
try {
|
|
10805
11017
|
for (;;) {
|
|
@@ -10860,7 +11072,7 @@ async function* yt(e) {
|
|
|
10860
11072
|
* Reads the entire response body, parses as JSON, and yields one chunk
|
|
10861
11073
|
* with `done: true`.
|
|
10862
11074
|
*/
|
|
10863
|
-
async function*
|
|
11075
|
+
async function* vt(e) {
|
|
10864
11076
|
let t = await e.json(), n = "";
|
|
10865
11077
|
typeof t.content == "string" ? n = t.content : typeof t.message == "string" ? n = t.message : typeof t.delta == "string" ? n = t.delta : Array.isArray(t.choices) && typeof t.choices[0]?.message?.content == "string" && (n = t.choices[0].message.content), yield {
|
|
10866
11078
|
delta: n,
|
|
@@ -10877,25 +11089,25 @@ async function* bt(e) {
|
|
|
10877
11089
|
* - `error` — an error occurred during streaming
|
|
10878
11090
|
* - `stopped` — consumer aborted the stream
|
|
10879
11091
|
*/
|
|
10880
|
-
function
|
|
11092
|
+
function yt(e, t) {
|
|
10881
11093
|
return t ? t.name === "AbortError" ? "stopped" : "error" : e.partial ? "partial" : "complete";
|
|
10882
11094
|
}
|
|
10883
11095
|
/**
|
|
10884
11096
|
* Classify an HTTP status code into a transport state.
|
|
10885
11097
|
*/
|
|
10886
|
-
function
|
|
11098
|
+
function bt(e) {
|
|
10887
11099
|
return e === 401 || e === 403 ? "auth-required" : e === 429 ? "rate-limited" : "server-error";
|
|
10888
11100
|
}
|
|
10889
11101
|
/**
|
|
10890
11102
|
* Calculate exponential backoff delay with jitter.
|
|
10891
11103
|
*/
|
|
10892
|
-
function
|
|
11104
|
+
function X(e, t = 1e3, n = 3e4) {
|
|
10893
11105
|
return Math.min(n, t * 2 ** e + Math.random() * 500);
|
|
10894
11106
|
}
|
|
10895
11107
|
/**
|
|
10896
11108
|
* Detect the stream format from a Content-Type header value.
|
|
10897
11109
|
*/
|
|
10898
|
-
function
|
|
11110
|
+
function xt(e) {
|
|
10899
11111
|
let t = e.toLowerCase();
|
|
10900
11112
|
return t.includes("text/event-stream") ? "sse" : t.includes("ndjson") || t.includes("x-ndjson") ? "ndjson" : "json";
|
|
10901
11113
|
}
|
|
@@ -10903,16 +11115,16 @@ function Ct(e) {
|
|
|
10903
11115
|
* Create an async generator that yields ChatStreamChunk values from a
|
|
10904
11116
|
* Response, auto-detecting the format from Content-Type when not specified.
|
|
10905
11117
|
*/
|
|
10906
|
-
async function*
|
|
10907
|
-
switch (t ??
|
|
11118
|
+
async function* Z(e, t) {
|
|
11119
|
+
switch (t ?? xt(e.headers.get("content-type") ?? "")) {
|
|
10908
11120
|
case "sse":
|
|
10909
|
-
yield*
|
|
11121
|
+
yield* gt(e);
|
|
10910
11122
|
break;
|
|
10911
11123
|
case "ndjson":
|
|
10912
|
-
yield*
|
|
11124
|
+
yield* _t(e);
|
|
10913
11125
|
break;
|
|
10914
11126
|
case "json":
|
|
10915
|
-
yield*
|
|
11127
|
+
yield* vt(e);
|
|
10916
11128
|
break;
|
|
10917
11129
|
}
|
|
10918
11130
|
}
|
|
@@ -10920,7 +11132,7 @@ async function* wt(e, t) {
|
|
|
10920
11132
|
* Create a reusable chat transport that sends requests and returns a
|
|
10921
11133
|
* streaming async generator. Supports retry/backoff and transport state callbacks.
|
|
10922
11134
|
*/
|
|
10923
|
-
function
|
|
11135
|
+
function St(e) {
|
|
10924
11136
|
let t = (t) => {
|
|
10925
11137
|
e.onStateChange?.(t);
|
|
10926
11138
|
}, n = e.retry?.maxAttempts ?? 1, r = e.retry?.baseDelayMs ?? 1e3, i = e.retry?.maxDelayMs ?? 3e4;
|
|
@@ -10952,19 +11164,19 @@ function Tt(e) {
|
|
|
10952
11164
|
attempt: c,
|
|
10953
11165
|
maxAttempts: n
|
|
10954
11166
|
}), c + 1 < n) {
|
|
10955
|
-
let e =
|
|
11167
|
+
let e = X(c, r, i);
|
|
10956
11168
|
t({
|
|
10957
11169
|
state: "retrying",
|
|
10958
11170
|
retryInMs: e,
|
|
10959
11171
|
attempt: c + 1,
|
|
10960
11172
|
maxAttempts: n
|
|
10961
|
-
}), await
|
|
11173
|
+
}), await wt(e);
|
|
10962
11174
|
continue;
|
|
10963
11175
|
}
|
|
10964
11176
|
break;
|
|
10965
11177
|
}
|
|
10966
11178
|
if (!l.ok) {
|
|
10967
|
-
let e =
|
|
11179
|
+
let e = bt(l.status);
|
|
10968
11180
|
s = /* @__PURE__ */ Error(`Chat transport error: ${l.status} ${l.statusText}`);
|
|
10969
11181
|
let a;
|
|
10970
11182
|
if (l.status === 429) {
|
|
@@ -10982,18 +11194,18 @@ function Tt(e) {
|
|
|
10982
11194
|
attempt: c,
|
|
10983
11195
|
maxAttempts: n
|
|
10984
11196
|
}), (l.status === 429 || l.status >= 500) && c + 1 < n) {
|
|
10985
|
-
let e = a ??
|
|
11197
|
+
let e = a ?? X(c, r, i);
|
|
10986
11198
|
t({
|
|
10987
11199
|
state: "retrying",
|
|
10988
11200
|
retryInMs: e,
|
|
10989
11201
|
attempt: c + 1,
|
|
10990
11202
|
maxAttempts: n
|
|
10991
|
-
}), await
|
|
11203
|
+
}), await wt(e);
|
|
10992
11204
|
continue;
|
|
10993
11205
|
}
|
|
10994
11206
|
break;
|
|
10995
11207
|
}
|
|
10996
|
-
return t({ state: "streaming" }),
|
|
11208
|
+
return t({ state: "streaming" }), Ct(Z(l, e.format), t);
|
|
10997
11209
|
}
|
|
10998
11210
|
throw s ?? /* @__PURE__ */ Error("Chat transport failed");
|
|
10999
11211
|
} };
|
|
@@ -11001,7 +11213,7 @@ function Tt(e) {
|
|
|
11001
11213
|
/**
|
|
11002
11214
|
* Wraps an async generator to emit `ready` state when the stream finishes.
|
|
11003
11215
|
*/
|
|
11004
|
-
async function*
|
|
11216
|
+
async function* Ct(e, t) {
|
|
11005
11217
|
try {
|
|
11006
11218
|
yield* e, t({ state: "ready" });
|
|
11007
11219
|
} catch (e) {
|
|
@@ -11011,7 +11223,7 @@ async function* Et(e, t) {
|
|
|
11011
11223
|
}), e;
|
|
11012
11224
|
}
|
|
11013
11225
|
}
|
|
11014
|
-
function
|
|
11226
|
+
function wt(e) {
|
|
11015
11227
|
return new Promise((t) => setTimeout(t, e));
|
|
11016
11228
|
}
|
|
11017
11229
|
const Q = {
|
|
@@ -11021,7 +11233,7 @@ const Q = {
|
|
|
11021
11233
|
GENERATION_STOP: "native:generation-stop",
|
|
11022
11234
|
GENERATION_ERROR: "native:generation-error",
|
|
11023
11235
|
WARNING: "native:chat-warning"
|
|
11024
|
-
},
|
|
11236
|
+
}, Tt = [
|
|
11025
11237
|
"requestId",
|
|
11026
11238
|
"sessionId",
|
|
11027
11239
|
"conversationId",
|
|
@@ -11034,7 +11246,7 @@ const Q = {
|
|
|
11034
11246
|
"attempt",
|
|
11035
11247
|
"maxAttempts",
|
|
11036
11248
|
"chunkIndex"
|
|
11037
|
-
],
|
|
11249
|
+
], Et = [
|
|
11038
11250
|
"query",
|
|
11039
11251
|
"message",
|
|
11040
11252
|
"delta",
|
|
@@ -11044,17 +11256,17 @@ const Q = {
|
|
|
11044
11256
|
"prompt",
|
|
11045
11257
|
"response"
|
|
11046
11258
|
];
|
|
11047
|
-
var
|
|
11259
|
+
var Dt = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g, Ot = /\b(?:\+?\d{1,3}[-.\s]?)?\(?\d{2,4}\)?[-.\s]?\d{3,4}[-.\s]?\d{3,4}\b/g, kt = /\b(?:\d{4}[-\s]?){3}\d{4}\b/g;
|
|
11048
11260
|
/**
|
|
11049
11261
|
* Scrub common PII patterns from a string.
|
|
11050
11262
|
*
|
|
11051
11263
|
* Replaces email addresses, phone-like numbers, and credit-card-like
|
|
11052
11264
|
* number sequences with `[redacted]` placeholders.
|
|
11053
11265
|
*/
|
|
11054
|
-
function
|
|
11055
|
-
return e.replace(
|
|
11266
|
+
function At(e) {
|
|
11267
|
+
return e.replace(Dt, "[redacted:email]").replace(kt, "[redacted:card]").replace(Ot, "[redacted:phone]");
|
|
11056
11268
|
}
|
|
11057
|
-
var
|
|
11269
|
+
var jt = new Set(Et);
|
|
11058
11270
|
/**
|
|
11059
11271
|
* Create a default redactor for the given telemetry level.
|
|
11060
11272
|
*
|
|
@@ -11066,7 +11278,7 @@ function $(e) {
|
|
|
11066
11278
|
return e === "debug" ? (e) => e : (e) => {
|
|
11067
11279
|
if (!e.detail) return e;
|
|
11068
11280
|
let t = {};
|
|
11069
|
-
for (let [n, r] of Object.entries(e.detail))
|
|
11281
|
+
for (let [n, r] of Object.entries(e.detail)) jt.has(n) && typeof r == "string" ? t[n] = `[redacted:${r.length}chars]` : t[n] = r;
|
|
11070
11282
|
return {
|
|
11071
11283
|
...e,
|
|
11072
11284
|
detail: t
|
|
@@ -11077,7 +11289,7 @@ function $(e) {
|
|
|
11077
11289
|
* Dispatches telemetry events as `CustomEvent` instances on a given
|
|
11078
11290
|
* `EventTarget`, applying a configurable redactor before emission.
|
|
11079
11291
|
*/
|
|
11080
|
-
var
|
|
11292
|
+
var Mt = class {
|
|
11081
11293
|
#e;
|
|
11082
11294
|
#t;
|
|
11083
11295
|
constructor(e, t = "minimal") {
|
|
@@ -11137,4 +11349,4 @@ var Ft = class {
|
|
|
11137
11349
|
});
|
|
11138
11350
|
}
|
|
11139
11351
|
};
|
|
11140
|
-
export {
|
|
11352
|
+
export { Ke as A2AAdapter, V as A2UIAdapter, et as ACTION_REGISTRY, qe as AGUIAdapter, Q as CHAT_EVENTS, ie as COMPONENT_MAP, Ge as DirectAdapter, Ie as NA2UI, ze as NAgentSession, He as NCatalog, Qe as NChatAvatar, Ze as NChatFeed, Je as NChatInput, ht as NChatInputStructured, nt as NChatMessage, ct as NChatMessageActivity, pt as NChatMessageGenUI, dt as NChatMessageSeed, at as NChatMessageText, it as NChatMessages, Ye as NChatPanel, Re as NEventEmitter, We as NSessionManager, Ve as NSurfaceRegistry, tt as ROLE_DEFAULTS, Tt as SAFE_FIELDS, Et as SENSITIVE_FIELDS, Ce as SSETransport, z as SurfaceManager, Mt as TelemetryEmitter, Se as WebSocketTransport, N as a2uiToUINode, X as backoffDelay, G as buildCatalogFromRegistry, bt as classifyHttpError, yt as classifyStreamEnd, me as conversionToPlan, xe as createA2UIAdapter, Z as createChatStream, St as createChatTransport, $ as createDefaultRedactor, Te as createSSETransport, be as createSurfaceManager, we as createWebSocketTransport, se as dateTimeInputType, xt as detectFormat, M as getSupportedTypes, Ee as installA2UI, ee as isActionMessage, D as isCatalogRequest, ne as isCatalogResponse, C as isCreateSurface, S as isDataBinding, E as isDeleteSurface, te as isErrorMessage, w as isUpdateComponents, T as isUpdateDataModel, vt as parseJSON, _t as parseNDJSON, gt as parseSSE, O as parseServerMessage, q as renderInline, J as renderMarkdown, j as resolveA2UIType, I as resolveJsonPointer, A as resolveNativeTag, st as sanitizeHtml, At as scrubPII, L as setJsonPointer, le as textFieldInputType, oe as textVariantTag, fe as uiNodeToA2UI };
|