@celljs/ta-glance 4.15.2 → 4.17.0
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/README.en.md +2 -0
- package/README.md +2 -0
- package/extension/index.mjs +135 -27
- package/package.json +4 -3
- package/web/index.js +508 -62
package/README.en.md
CHANGED
|
@@ -6,6 +6,8 @@ A pi package that comes with Ta (on by default; Settings → Extensions of the w
|
|
|
6
6
|
- **Results as a card**: when a reply reports work done, results, a comparison, choices to make, or several facts or relations, Ta writes a `ta-glance` block (JSON) after the first line, which the web client draws as a card: key numbers, files changed (opened by a click), steps, before and after, bars, a flow, a Mermaid diagram, a table, choices to tap, risks and to-dos, buttons of what to ask next, folded details. The card grows as the reply streams.
|
|
7
7
|
- **Waiting for you**: a turn whose reply ends with a card of choices (`options`) or `status: "blocked"` is marked in the session with a `ta-ask` entry (`TA_ASK_ENTRY`, which the model never reads): the list of chats, its tab, the double's tasks and Quick open show that the conversation waits for you to decide, until you answer, by a tap or in words. Until then the card is framed in blue with a ?; once answered it shows the choice on every device, after a reload too (`WebCodeRendererProps.answer`).
|
|
8
8
|
- **Elsewhere**: the preview of the list of conversations shows the first line; replies to WeChat and WeCom bots draw no card and stay short paragraphs; `ta` in a terminal replies as before. External agents (ta-agents) get the section too.
|
|
9
|
+
- **Charts**: a key number may have a small line of its values over time (`trend`), and a card may have a line chart (`line`, up to 4 series) and the parts of a whole (`share`), drawn in plain SVG, with no library.
|
|
10
|
+
- **Icons**: a key number, a node of a flow, a choice, a note and a thing to ask next may have a lucide icon (`icon`), to tell items apart at a glance; the prompt gives the model 31 common ones and tells it never to write an emoji. An icon the page does not have is not drawn.
|
|
9
11
|
|
|
10
12
|
The card's format is in `web-src/glance-protocol.ts`, the prompt in `web-src/glance-prompt.ts`. Other packages draw cards for fenced blocks of their own languages with `registerCodeRenderer`.
|
|
11
13
|
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Ta 自带的 pi 包(默认开启,可在 Web 客户端的 设置 → 扩展
|
|
|
6
6
|
- **结果画成卡片**:汇报完成的工作、结果、对比、要你选的方案、多个事实或关系时,Ta 在第一行之后写一个 `ta-glance` 代码块(JSON),Web 把它画成卡片:关键数字、改了的文件(点开)、步骤、前后对比、横条、流程、Mermaid 关系图、表格、可点选的方案、风险与待办、下一步按钮、折叠的细节。卡片随回复流式长出来。
|
|
7
7
|
- **待你决定**:一轮回复以带选项(`options`)或 `status: "blocked"` 的卡片结束时,pi 扩展在会话里记一条 `ta-ask`(`TA_ASK_ENTRY`,模型读不到),对话列表、标签、分身任务和快捷打开就显示这个对话在等你决定,直到你回答(点选或打字都算)。卡片在你回答前用蓝框和问号标出;回答后各设备都显示已选,刷新也保留(`WebCodeRendererProps.answer`)。
|
|
8
8
|
- **别处**:对话列表的预览显示第一行结论;发到微信、企业微信机器人的回复不画卡片,照常是短段落;终端里的 `ta` 回复照旧。外部 Agent(ta-agents)也会拿到这段写法。
|
|
9
|
+
- **图表**:关键数字可以带一条小走势线(`trend`),还有趋势线(`line`,最多 4 条)和占比(`share`),用原生 SVG 画、不加依赖。
|
|
10
|
+
- **图标**:关键数字、流程节点、方案、提示、下一步可以带一个 lucide 图标(`icon`),一眼分清各项说的是什么;提示词给模型 31 个常用图标,并要求不用 emoji。页面没有的图标不画。
|
|
9
11
|
|
|
10
12
|
卡片的格式见 `web-src/glance-protocol.ts`,提示词见 `web-src/glance-prompt.ts`。别的包也能用 `registerCodeRenderer` 为自己的代码块语言画卡片。
|
|
11
13
|
|
package/extension/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// ../ta-protocol/esm/common/ta-extension-host.js
|
|
2
|
+
var TA_WEBHOOK_MAX_BYTES = 256 * 1024;
|
|
2
3
|
var TA_HOST_EVENT = "ta:host";
|
|
3
4
|
var TaHostUtil;
|
|
4
5
|
(function(TaHostUtil2) {
|
|
@@ -95,6 +96,7 @@ var TaAskUtil;
|
|
|
95
96
|
var GlanceJson;
|
|
96
97
|
((GlanceJson) => {
|
|
97
98
|
const TRIES = 40;
|
|
99
|
+
const CONTROLS = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
|
|
98
100
|
function parse(text, partial) {
|
|
99
101
|
const source = text.trim().replace(/,\s*([}\]])/g, "$1");
|
|
100
102
|
if (!source) {
|
|
@@ -157,6 +159,9 @@ var GlanceJson;
|
|
|
157
159
|
escaped = true;
|
|
158
160
|
} else if (char === '"') {
|
|
159
161
|
inString = false;
|
|
162
|
+
} else if (char < " ") {
|
|
163
|
+
out += CONTROLS[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
164
|
+
continue;
|
|
160
165
|
}
|
|
161
166
|
} else if (char === '"') {
|
|
162
167
|
inString = true;
|
|
@@ -177,9 +182,45 @@ var GlanceJson;
|
|
|
177
182
|
// web-src/glance-protocol.ts
|
|
178
183
|
var NAME = "@celljs/ta-glance";
|
|
179
184
|
var LANGUAGE = "ta-glance";
|
|
185
|
+
var GLANCE_ICONS = [
|
|
186
|
+
"Zap",
|
|
187
|
+
"Gauge",
|
|
188
|
+
"Timer",
|
|
189
|
+
"Cpu",
|
|
190
|
+
"MemoryStick",
|
|
191
|
+
"HardDrive",
|
|
192
|
+
"TrendingUp",
|
|
193
|
+
"TrendingDown",
|
|
194
|
+
"Code",
|
|
195
|
+
"GitBranch",
|
|
196
|
+
"Bug",
|
|
197
|
+
"FlaskConical",
|
|
198
|
+
"Package",
|
|
199
|
+
"SquareTerminal",
|
|
200
|
+
"Database",
|
|
201
|
+
"Server",
|
|
202
|
+
"Globe",
|
|
203
|
+
"Shield",
|
|
204
|
+
"Lock",
|
|
205
|
+
"KeyRound",
|
|
206
|
+
"Users",
|
|
207
|
+
"MessageCircle",
|
|
208
|
+
"Smartphone",
|
|
209
|
+
"Laptop",
|
|
210
|
+
"Rocket",
|
|
211
|
+
"Wrench",
|
|
212
|
+
"Lightbulb",
|
|
213
|
+
"Coins",
|
|
214
|
+
"Calendar",
|
|
215
|
+
"FileText",
|
|
216
|
+
"Sparkles"
|
|
217
|
+
];
|
|
180
218
|
|
|
181
219
|
// web-src/glance-spec.ts
|
|
182
220
|
var ITEMS = 12;
|
|
221
|
+
var FOLDED = 40;
|
|
222
|
+
var POINTS = 24;
|
|
223
|
+
var SERIES = 4;
|
|
183
224
|
var BLOCKS = 8;
|
|
184
225
|
var TEXT = 400;
|
|
185
226
|
var MARKDOWN = 8000;
|
|
@@ -208,7 +249,7 @@ function oneOf(value, values) {
|
|
|
208
249
|
const lower = typeof value === "string" ? value.trim().toLowerCase() : undefined;
|
|
209
250
|
return values.find((candidate) => candidate === lower);
|
|
210
251
|
}
|
|
211
|
-
function items(value, read) {
|
|
252
|
+
function items(value, read, max = ITEMS) {
|
|
212
253
|
if (!Array.isArray(value)) {
|
|
213
254
|
return [];
|
|
214
255
|
}
|
|
@@ -218,14 +259,41 @@ function items(value, read) {
|
|
|
218
259
|
if (made !== undefined) {
|
|
219
260
|
out.push(made);
|
|
220
261
|
}
|
|
221
|
-
if (out.length ===
|
|
262
|
+
if (out.length === max) {
|
|
222
263
|
break;
|
|
223
264
|
}
|
|
224
265
|
}
|
|
225
266
|
return out;
|
|
226
267
|
}
|
|
268
|
+
function icon(value) {
|
|
269
|
+
if (typeof value !== "string") {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const words = value.trim().replace(/^lucide[:\-_\s]*/i, "").split(/[-_\s.:]+/).filter(Boolean);
|
|
273
|
+
const name = words.map((word) => word[0].toUpperCase() + word.slice(1)).join("");
|
|
274
|
+
return /^[A-Z][A-Za-z0-9]{0,39}$/.test(name) ? name : undefined;
|
|
275
|
+
}
|
|
276
|
+
function withIcon(value) {
|
|
277
|
+
const name = icon(value?.icon);
|
|
278
|
+
return name ? { icon: name } : {};
|
|
279
|
+
}
|
|
227
280
|
function strings(value, max = ITEMS) {
|
|
228
|
-
return items(value, (item) => text(item) ?? text(object(item)?.label) ?? text(object(item)?.text)
|
|
281
|
+
return items(value, (item) => text(item) ?? text(object(item)?.label) ?? text(object(item)?.text), max);
|
|
282
|
+
}
|
|
283
|
+
function numbers(value, max = POINTS) {
|
|
284
|
+
return items(value, number, max);
|
|
285
|
+
}
|
|
286
|
+
function amount(entry) {
|
|
287
|
+
const value = object(entry);
|
|
288
|
+
const label = text(value?.label);
|
|
289
|
+
const shown = number(value?.value);
|
|
290
|
+
return label && shown !== undefined ? { label, value: shown } : undefined;
|
|
291
|
+
}
|
|
292
|
+
function series(entry) {
|
|
293
|
+
const value = object(entry);
|
|
294
|
+
const values = numbers(Array.isArray(entry) ? entry : value?.values ?? value?.data);
|
|
295
|
+
const label = text(value?.label ?? value?.name);
|
|
296
|
+
return values.length ? { values, ...label ? { label } : {} } : undefined;
|
|
229
297
|
}
|
|
230
298
|
function stat(item) {
|
|
231
299
|
const value = object(item);
|
|
@@ -236,11 +304,12 @@ function stat(item) {
|
|
|
236
304
|
}
|
|
237
305
|
const tone = oneOf(value?.tone, TONES);
|
|
238
306
|
const delta = text(value?.delta);
|
|
239
|
-
|
|
307
|
+
const trend = numbers(value?.trend);
|
|
308
|
+
return { label, value: shown, ...tone ? { tone } : {}, ...delta ? { delta } : {}, ...withIcon(value), ...trend.length > 1 ? { trend } : {} };
|
|
240
309
|
}
|
|
241
310
|
function change(item) {
|
|
242
311
|
const value = object(item);
|
|
243
|
-
const path = text(value?.path ?? item);
|
|
312
|
+
const path = text(value?.path ?? value?.file ?? item);
|
|
244
313
|
if (!path) {
|
|
245
314
|
return;
|
|
246
315
|
}
|
|
@@ -273,19 +342,40 @@ function option(item) {
|
|
|
273
342
|
...detail ? { detail } : {},
|
|
274
343
|
pros: strings(value?.pros, 4),
|
|
275
344
|
cons: strings(value?.cons, 4),
|
|
276
|
-
...value?.recommended === true ? { recommended: true } : {}
|
|
345
|
+
...value?.recommended === true ? { recommended: true } : {},
|
|
346
|
+
...withIcon(value)
|
|
277
347
|
};
|
|
278
348
|
}
|
|
279
349
|
function note(item) {
|
|
280
350
|
const value = object(item);
|
|
281
351
|
const shown = text(value?.text ?? item);
|
|
282
|
-
return shown ? { text: shown, tone: oneOf(value?.tone, NOTES) ?? "info" } : undefined;
|
|
352
|
+
return shown ? { text: shown, tone: oneOf(value?.tone, NOTES) ?? "info", ...withIcon(value) } : undefined;
|
|
353
|
+
}
|
|
354
|
+
function listItem(entry) {
|
|
355
|
+
const value = object(entry);
|
|
356
|
+
const shown = text(entry) ?? text(value?.text) ?? text(value?.label);
|
|
357
|
+
return shown ? { text: shown, ...withIcon(value) } : undefined;
|
|
358
|
+
}
|
|
359
|
+
function point(item) {
|
|
360
|
+
const value = object(item);
|
|
361
|
+
const head = text(value?.title ?? value?.label);
|
|
362
|
+
const body = text(value?.detail ?? value?.note ?? value?.text ?? value?.description);
|
|
363
|
+
if (!value || !head) {
|
|
364
|
+
return note(value ? { text: body } : item);
|
|
365
|
+
}
|
|
366
|
+
return { text: body ? `**${head}** ${body}` : head, tone: "info" };
|
|
283
367
|
}
|
|
284
368
|
function isPath(value) {
|
|
285
369
|
return !/[,。;!?、]/.test(value) && (!/\s/.test(value) || /[\\/]/.test(value));
|
|
286
370
|
}
|
|
287
371
|
var LABELS = { before: "Before", after: "After" };
|
|
288
372
|
function block(item, partial, labels) {
|
|
373
|
+
const made = blockOf(item, partial, labels);
|
|
374
|
+
const fold = object(item)?.fold;
|
|
375
|
+
const words = fold === true ? "" : text(fold, 40);
|
|
376
|
+
return made && words !== undefined ? { ...made, fold: words } : made;
|
|
377
|
+
}
|
|
378
|
+
function blockOf(item, partial, labels) {
|
|
289
379
|
const value = object(item);
|
|
290
380
|
const type = typeof value?.type === "string" ? value.type.trim().toLowerCase() : undefined;
|
|
291
381
|
const unit = text(value?.unit, 16);
|
|
@@ -296,11 +386,12 @@ function block(item, partial, labels) {
|
|
|
296
386
|
}
|
|
297
387
|
case "changes": {
|
|
298
388
|
const raw = Array.isArray(value?.items) ? value.items : [];
|
|
299
|
-
|
|
300
|
-
|
|
389
|
+
const pathless = (entry) => typeof entry === "string" ? !isPath(entry) : !!object(entry) && !text(object(entry)?.path ?? object(entry)?.file);
|
|
390
|
+
if (raw.length && raw.every(pathless)) {
|
|
391
|
+
const list2 = items(raw, point);
|
|
301
392
|
return list2.length ? { type: "notes", items: list2 } : undefined;
|
|
302
393
|
}
|
|
303
|
-
const list = items(value?.items, change);
|
|
394
|
+
const list = items(value?.items, change, FOLDED);
|
|
304
395
|
return list.length ? { type, items: list } : undefined;
|
|
305
396
|
}
|
|
306
397
|
case "steps": {
|
|
@@ -329,16 +420,23 @@ function block(item, partial, labels) {
|
|
|
329
420
|
return rows.length ? { type: "table", columns: ["", labels.before, labels.after], rows } : undefined;
|
|
330
421
|
}
|
|
331
422
|
case "bars": {
|
|
332
|
-
const list = items(value?.items,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
});
|
|
423
|
+
const list = items(value?.items, amount, FOLDED);
|
|
424
|
+
return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
|
|
425
|
+
}
|
|
426
|
+
case "line": {
|
|
427
|
+
const points = items(value?.items, amount, POINTS);
|
|
428
|
+
const lines = points.length ? [{ values: points.map((point2) => point2.value) }] : Array.isArray(value?.series) ? items(value.series, series, SERIES) : [series(value)].filter((line) => !!line);
|
|
429
|
+
const labels2 = points.length ? points.map((point2) => point2.label) : strings(value?.labels, POINTS);
|
|
430
|
+
const better = oneOf(value?.better, ["lower", "higher"]);
|
|
431
|
+
const drawn = lines.filter((line) => partial || line.values.length > 1);
|
|
432
|
+
return drawn.length ? { type, labels: labels2, series: drawn, ...unit ? { unit } : {}, ...better ? { better } : {} } : undefined;
|
|
433
|
+
}
|
|
434
|
+
case "share": {
|
|
435
|
+
const list = items(value?.items, amount, 6).filter((part) => part.value > 0);
|
|
338
436
|
return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
|
|
339
437
|
}
|
|
340
438
|
case "flow": {
|
|
341
|
-
const list =
|
|
439
|
+
const list = items(value?.items, listItem);
|
|
342
440
|
return list.length ? { type, items: list } : undefined;
|
|
343
441
|
}
|
|
344
442
|
case "diagram": {
|
|
@@ -346,8 +444,8 @@ function block(item, partial, labels) {
|
|
|
346
444
|
return mermaid ? { type, mermaid } : undefined;
|
|
347
445
|
}
|
|
348
446
|
case "table": {
|
|
349
|
-
const columns =
|
|
350
|
-
const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined);
|
|
447
|
+
const columns = items(value?.columns, (column) => text(column) ?? (typeof column === "string" ? "" : undefined), 6);
|
|
448
|
+
const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined, FOLDED);
|
|
351
449
|
return columns.length && rows.length ? { type, columns, rows } : undefined;
|
|
352
450
|
}
|
|
353
451
|
case "options": {
|
|
@@ -360,7 +458,7 @@ function block(item, partial, labels) {
|
|
|
360
458
|
return list.length ? { type, items: list } : undefined;
|
|
361
459
|
}
|
|
362
460
|
case "next": {
|
|
363
|
-
const list =
|
|
461
|
+
const list = items(value?.items, listItem).slice(0, 3);
|
|
364
462
|
return list.length ? { type, items: list } : undefined;
|
|
365
463
|
}
|
|
366
464
|
case "details": {
|
|
@@ -383,6 +481,13 @@ function loose(card) {
|
|
|
383
481
|
return out;
|
|
384
482
|
}
|
|
385
483
|
var LISTS = ["stats", "changes", "steps", "flow", "options", "notes", "next"];
|
|
484
|
+
var PLACE = { stats: -1, notes: 1, next: 2, details: 3 };
|
|
485
|
+
function place(block2) {
|
|
486
|
+
return block2.fold !== undefined ? 3 : PLACE[block2.type] ?? 0;
|
|
487
|
+
}
|
|
488
|
+
function placed(blocks) {
|
|
489
|
+
return blocks.map((block2, index) => ({ block: block2, index })).sort((a, b) => place(a.block) - place(b.block) || a.index - b.index).map((entry) => entry.block);
|
|
490
|
+
}
|
|
386
491
|
var GlanceSpec;
|
|
387
492
|
((GlanceSpec) => {
|
|
388
493
|
function read(value, partial = false, labels = LABELS) {
|
|
@@ -392,7 +497,7 @@ var GlanceSpec;
|
|
|
392
497
|
}
|
|
393
498
|
const status = oneOf(card.status, STATUSES);
|
|
394
499
|
const title = text(card.title);
|
|
395
|
-
const blocks = items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS);
|
|
500
|
+
const blocks = placed(items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS));
|
|
396
501
|
if (!blocks.length && !title) {
|
|
397
502
|
return;
|
|
398
503
|
}
|
|
@@ -491,19 +596,22 @@ How to reply:
|
|
|
491
596
|
|
|
492
597
|
The card: {"status": "done" | "partial" | "failed" | "blocked" | "info", "title"?: string, "blocks": [...]}
|
|
493
598
|
status: done = finished, partial = done in part, failed, blocked = waiting for the user, info = an answer, no work. Leave out title: the first line already says it.
|
|
494
|
-
Blocks, 1 to 4 of them, the most important first, each with only the fields shown. Every text a few words, in the user's language; inline Markdown works (**bold**, \`path/to/file\` opens the file).
|
|
495
|
-
- {"type":"stats","items":[{"label":"Tests","value":"128/128","tone":"good"},{"label":"Startup","value":"210 ms","delta":"-34%","tone":"good"}]}: key numbers, at most 6; tone good | bad | warn.
|
|
496
|
-
- {"type":"changes","items":[{"path":"src/a.ts","kind":"edit","add":12,"del":3,"note":"why, in a few words"}]}: files changed, a path each (
|
|
599
|
+
Blocks, 1 to 4 of them, the most important first (Ta puts stats on top and notes, next and details at the bottom), each with only the fields shown. A block few need but some may want (the full list, how it was measured, the rest of a comparison) may have "fold": "a few words": Ta draws it folded under them, opened by a tap; it does not count in the 4. Long lists are folded by Ta after their first items, so give them whole. Every text a few words, in the user's language; inline Markdown works (**bold**, \`path/to/file\` opens the file).
|
|
600
|
+
- {"type":"stats","items":[{"label":"Tests","value":"128/128","tone":"good"},{"label":"Startup","value":"210 ms","delta":"-34%","tone":"good","trend":[320,290,210]}]}: key numbers, at most 6, each value a number with its unit (a fact in words goes in notes); tone good | bad | warn; trend, its values over time when known, draws a small line.
|
|
601
|
+
- {"type":"changes","items":[{"path":"src/a.ts","kind":"edit","add":12,"del":3,"note":"why, in a few words"}]}: files changed, a path each (what changed without a file goes in notes); kind add | edit | delete.
|
|
497
602
|
- {"type":"steps","items":[{"text":"...","status":"done"}]}: progress or a plan; status done | doing | todo | failed | skipped.
|
|
498
603
|
- {"type":"compare","unit":"ms","better":"lower","items":[{"label":"Startup","before":320,"after":210}]}: before and after, numbers only (words go in a table).
|
|
499
604
|
- {"type":"bars","unit":"MB","items":[{"label":"ta","value":66},{"label":"pi","value":129}]}: amounts side by side.
|
|
500
|
-
- {"type":"
|
|
605
|
+
- {"type":"line","unit":"ms","better":"lower","labels":["11-01","11-08","11-15"],"series":[{"label":"Startup","values":[320,260,210]}]}: how values went over time, at most 4 series of 24 points.
|
|
606
|
+
- {"type":"share","unit":"MB","items":[{"label":"pi","value":129},{"label":"ta","value":66}]}: the parts of a whole.
|
|
607
|
+
- {"type":"flow","items":["Request",{"text":"Gateway","icon":"Server"},"Session","Model"]}: a sequence or a path.
|
|
501
608
|
- {"type":"diagram","mermaid":"graph LR; A-->B"}: relations a flow cannot show, under 12 nodes.
|
|
502
|
-
- {"type":"table","columns":["",""],"rows":[["",""]]}: a few rows that compare things on several points.
|
|
609
|
+
- {"type":"table","columns":["",""],"rows":[["",""]]}: a few rows that compare things on several points, the first column naming each row (columns ["", "Before", "After"] for before and after in words).
|
|
503
610
|
- {"type":"options","question":"Which one?","items":[{"label":"A","detail":"one line","pros":["..."],"cons":["..."],"recommended":true}]}: when the user must choose; each is a button that answers with its label.
|
|
504
611
|
- {"type":"notes","items":[{"text":"...","tone":"risk"}]}: risks, caveats, what the user must do; tone risk | info | todo.
|
|
505
612
|
- {"type":"next","items":["Run the e2e tests"]}: at most 3 things the user may well ask next, each a button that sends it.
|
|
506
|
-
- {"type":"details","title":"How","markdown":"..."}: what few will read, folded
|
|
613
|
+
- {"type":"details","title":"How","markdown":"..."}: what few will read, folded.
|
|
614
|
+
An item of stats, flow, options, notes or next may have "icon", where it tells items apart at a glance (an item of flow or next then {"text","icon"}): one of ${GLANCE_ICONS.join(", ")}; else leave it out. Never write an emoji, in a card or out of it.`;
|
|
507
615
|
|
|
508
616
|
// web-src/extension.ts
|
|
509
617
|
function activate(pi) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-glance",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
4
|
"description": "A pi package for Ta: replies lead with the answer, short, and show results as cards (key numbers, files, steps, comparisons, choices) rather than paragraphs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@celljs/ta-protocol": "4.
|
|
30
|
-
"@celljs/ta-web": "4.
|
|
29
|
+
"@celljs/ta-protocol": "4.17.0",
|
|
30
|
+
"@celljs/ta-web": "4.17.0",
|
|
31
31
|
"@types/react": "^19.3.0"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"web": [
|
|
51
51
|
"./web/index.js"
|
|
52
52
|
],
|
|
53
|
+
"shared": true,
|
|
53
54
|
"extensions": [
|
|
54
55
|
"./extension/index.mjs"
|
|
55
56
|
]
|
package/web/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var GlanceJson;
|
|
3
3
|
((GlanceJson) => {
|
|
4
4
|
const TRIES = 40;
|
|
5
|
+
const CONTROLS = { "\n": "\\n", "\r": "\\r", "\t": "\\t" };
|
|
5
6
|
function parse(text, partial) {
|
|
6
7
|
const source = text.trim().replace(/,\s*([}\]])/g, "$1");
|
|
7
8
|
if (!source) {
|
|
@@ -64,6 +65,9 @@ var GlanceJson;
|
|
|
64
65
|
escaped = true;
|
|
65
66
|
} else if (char === '"') {
|
|
66
67
|
inString = false;
|
|
68
|
+
} else if (char < " ") {
|
|
69
|
+
out += CONTROLS[char] ?? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
70
|
+
continue;
|
|
67
71
|
}
|
|
68
72
|
} else if (char === '"') {
|
|
69
73
|
inString = true;
|
|
@@ -83,6 +87,9 @@ var GlanceJson;
|
|
|
83
87
|
|
|
84
88
|
// web-src/glance-spec.ts
|
|
85
89
|
var ITEMS = 12;
|
|
90
|
+
var FOLDED = 40;
|
|
91
|
+
var POINTS = 24;
|
|
92
|
+
var SERIES = 4;
|
|
86
93
|
var BLOCKS = 8;
|
|
87
94
|
var TEXT = 400;
|
|
88
95
|
var MARKDOWN = 8000;
|
|
@@ -111,7 +118,7 @@ function oneOf(value, values) {
|
|
|
111
118
|
const lower = typeof value === "string" ? value.trim().toLowerCase() : undefined;
|
|
112
119
|
return values.find((candidate) => candidate === lower);
|
|
113
120
|
}
|
|
114
|
-
function items(value, read) {
|
|
121
|
+
function items(value, read, max = ITEMS) {
|
|
115
122
|
if (!Array.isArray(value)) {
|
|
116
123
|
return [];
|
|
117
124
|
}
|
|
@@ -121,14 +128,41 @@ function items(value, read) {
|
|
|
121
128
|
if (made !== undefined) {
|
|
122
129
|
out.push(made);
|
|
123
130
|
}
|
|
124
|
-
if (out.length ===
|
|
131
|
+
if (out.length === max) {
|
|
125
132
|
break;
|
|
126
133
|
}
|
|
127
134
|
}
|
|
128
135
|
return out;
|
|
129
136
|
}
|
|
137
|
+
function icon(value) {
|
|
138
|
+
if (typeof value !== "string") {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const words = value.trim().replace(/^lucide[:\-_\s]*/i, "").split(/[-_\s.:]+/).filter(Boolean);
|
|
142
|
+
const name = words.map((word) => word[0].toUpperCase() + word.slice(1)).join("");
|
|
143
|
+
return /^[A-Z][A-Za-z0-9]{0,39}$/.test(name) ? name : undefined;
|
|
144
|
+
}
|
|
145
|
+
function withIcon(value) {
|
|
146
|
+
const name = icon(value?.icon);
|
|
147
|
+
return name ? { icon: name } : {};
|
|
148
|
+
}
|
|
130
149
|
function strings(value, max = ITEMS) {
|
|
131
|
-
return items(value, (item) => text(item) ?? text(object(item)?.label) ?? text(object(item)?.text)
|
|
150
|
+
return items(value, (item) => text(item) ?? text(object(item)?.label) ?? text(object(item)?.text), max);
|
|
151
|
+
}
|
|
152
|
+
function numbers(value, max = POINTS) {
|
|
153
|
+
return items(value, number, max);
|
|
154
|
+
}
|
|
155
|
+
function amount(entry) {
|
|
156
|
+
const value = object(entry);
|
|
157
|
+
const label = text(value?.label);
|
|
158
|
+
const shown = number(value?.value);
|
|
159
|
+
return label && shown !== undefined ? { label, value: shown } : undefined;
|
|
160
|
+
}
|
|
161
|
+
function series(entry) {
|
|
162
|
+
const value = object(entry);
|
|
163
|
+
const values = numbers(Array.isArray(entry) ? entry : value?.values ?? value?.data);
|
|
164
|
+
const label = text(value?.label ?? value?.name);
|
|
165
|
+
return values.length ? { values, ...label ? { label } : {} } : undefined;
|
|
132
166
|
}
|
|
133
167
|
function stat(item) {
|
|
134
168
|
const value = object(item);
|
|
@@ -139,11 +173,12 @@ function stat(item) {
|
|
|
139
173
|
}
|
|
140
174
|
const tone = oneOf(value?.tone, TONES);
|
|
141
175
|
const delta = text(value?.delta);
|
|
142
|
-
|
|
176
|
+
const trend = numbers(value?.trend);
|
|
177
|
+
return { label, value: shown, ...tone ? { tone } : {}, ...delta ? { delta } : {}, ...withIcon(value), ...trend.length > 1 ? { trend } : {} };
|
|
143
178
|
}
|
|
144
179
|
function change(item) {
|
|
145
180
|
const value = object(item);
|
|
146
|
-
const path = text(value?.path ?? item);
|
|
181
|
+
const path = text(value?.path ?? value?.file ?? item);
|
|
147
182
|
if (!path) {
|
|
148
183
|
return;
|
|
149
184
|
}
|
|
@@ -176,19 +211,40 @@ function option(item) {
|
|
|
176
211
|
...detail ? { detail } : {},
|
|
177
212
|
pros: strings(value?.pros, 4),
|
|
178
213
|
cons: strings(value?.cons, 4),
|
|
179
|
-
...value?.recommended === true ? { recommended: true } : {}
|
|
214
|
+
...value?.recommended === true ? { recommended: true } : {},
|
|
215
|
+
...withIcon(value)
|
|
180
216
|
};
|
|
181
217
|
}
|
|
182
218
|
function note(item) {
|
|
183
219
|
const value = object(item);
|
|
184
220
|
const shown = text(value?.text ?? item);
|
|
185
|
-
return shown ? { text: shown, tone: oneOf(value?.tone, NOTES) ?? "info" } : undefined;
|
|
221
|
+
return shown ? { text: shown, tone: oneOf(value?.tone, NOTES) ?? "info", ...withIcon(value) } : undefined;
|
|
222
|
+
}
|
|
223
|
+
function listItem(entry) {
|
|
224
|
+
const value = object(entry);
|
|
225
|
+
const shown = text(entry) ?? text(value?.text) ?? text(value?.label);
|
|
226
|
+
return shown ? { text: shown, ...withIcon(value) } : undefined;
|
|
227
|
+
}
|
|
228
|
+
function point(item) {
|
|
229
|
+
const value = object(item);
|
|
230
|
+
const head = text(value?.title ?? value?.label);
|
|
231
|
+
const body = text(value?.detail ?? value?.note ?? value?.text ?? value?.description);
|
|
232
|
+
if (!value || !head) {
|
|
233
|
+
return note(value ? { text: body } : item);
|
|
234
|
+
}
|
|
235
|
+
return { text: body ? `**${head}** ${body}` : head, tone: "info" };
|
|
186
236
|
}
|
|
187
237
|
function isPath(value) {
|
|
188
238
|
return !/[,。;!?、]/.test(value) && (!/\s/.test(value) || /[\\/]/.test(value));
|
|
189
239
|
}
|
|
190
240
|
var LABELS = { before: "Before", after: "After" };
|
|
191
241
|
function block(item, partial, labels) {
|
|
242
|
+
const made = blockOf(item, partial, labels);
|
|
243
|
+
const fold = object(item)?.fold;
|
|
244
|
+
const words = fold === true ? "" : text(fold, 40);
|
|
245
|
+
return made && words !== undefined ? { ...made, fold: words } : made;
|
|
246
|
+
}
|
|
247
|
+
function blockOf(item, partial, labels) {
|
|
192
248
|
const value = object(item);
|
|
193
249
|
const type = typeof value?.type === "string" ? value.type.trim().toLowerCase() : undefined;
|
|
194
250
|
const unit = text(value?.unit, 16);
|
|
@@ -199,11 +255,12 @@ function block(item, partial, labels) {
|
|
|
199
255
|
}
|
|
200
256
|
case "changes": {
|
|
201
257
|
const raw = Array.isArray(value?.items) ? value.items : [];
|
|
202
|
-
|
|
203
|
-
|
|
258
|
+
const pathless = (entry) => typeof entry === "string" ? !isPath(entry) : !!object(entry) && !text(object(entry)?.path ?? object(entry)?.file);
|
|
259
|
+
if (raw.length && raw.every(pathless)) {
|
|
260
|
+
const list2 = items(raw, point);
|
|
204
261
|
return list2.length ? { type: "notes", items: list2 } : undefined;
|
|
205
262
|
}
|
|
206
|
-
const list = items(value?.items, change);
|
|
263
|
+
const list = items(value?.items, change, FOLDED);
|
|
207
264
|
return list.length ? { type, items: list } : undefined;
|
|
208
265
|
}
|
|
209
266
|
case "steps": {
|
|
@@ -232,16 +289,23 @@ function block(item, partial, labels) {
|
|
|
232
289
|
return rows.length ? { type: "table", columns: ["", labels.before, labels.after], rows } : undefined;
|
|
233
290
|
}
|
|
234
291
|
case "bars": {
|
|
235
|
-
const list = items(value?.items,
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
});
|
|
292
|
+
const list = items(value?.items, amount, FOLDED);
|
|
293
|
+
return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
|
|
294
|
+
}
|
|
295
|
+
case "line": {
|
|
296
|
+
const points = items(value?.items, amount, POINTS);
|
|
297
|
+
const lines = points.length ? [{ values: points.map((point2) => point2.value) }] : Array.isArray(value?.series) ? items(value.series, series, SERIES) : [series(value)].filter((line) => !!line);
|
|
298
|
+
const labels2 = points.length ? points.map((point2) => point2.label) : strings(value?.labels, POINTS);
|
|
299
|
+
const better = oneOf(value?.better, ["lower", "higher"]);
|
|
300
|
+
const drawn = lines.filter((line) => partial || line.values.length > 1);
|
|
301
|
+
return drawn.length ? { type, labels: labels2, series: drawn, ...unit ? { unit } : {}, ...better ? { better } : {} } : undefined;
|
|
302
|
+
}
|
|
303
|
+
case "share": {
|
|
304
|
+
const list = items(value?.items, amount, 6).filter((part) => part.value > 0);
|
|
241
305
|
return list.length ? { type, items: list, ...unit ? { unit } : {} } : undefined;
|
|
242
306
|
}
|
|
243
307
|
case "flow": {
|
|
244
|
-
const list =
|
|
308
|
+
const list = items(value?.items, listItem);
|
|
245
309
|
return list.length ? { type, items: list } : undefined;
|
|
246
310
|
}
|
|
247
311
|
case "diagram": {
|
|
@@ -249,8 +313,8 @@ function block(item, partial, labels) {
|
|
|
249
313
|
return mermaid ? { type, mermaid } : undefined;
|
|
250
314
|
}
|
|
251
315
|
case "table": {
|
|
252
|
-
const columns =
|
|
253
|
-
const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined);
|
|
316
|
+
const columns = items(value?.columns, (column) => text(column) ?? (typeof column === "string" ? "" : undefined), 6);
|
|
317
|
+
const rows = items(value?.rows, (row) => Array.isArray(row) ? columns.map((_, index) => text(row[index]) ?? "") : undefined, FOLDED);
|
|
254
318
|
return columns.length && rows.length ? { type, columns, rows } : undefined;
|
|
255
319
|
}
|
|
256
320
|
case "options": {
|
|
@@ -263,7 +327,7 @@ function block(item, partial, labels) {
|
|
|
263
327
|
return list.length ? { type, items: list } : undefined;
|
|
264
328
|
}
|
|
265
329
|
case "next": {
|
|
266
|
-
const list =
|
|
330
|
+
const list = items(value?.items, listItem).slice(0, 3);
|
|
267
331
|
return list.length ? { type, items: list } : undefined;
|
|
268
332
|
}
|
|
269
333
|
case "details": {
|
|
@@ -286,6 +350,13 @@ function loose(card) {
|
|
|
286
350
|
return out;
|
|
287
351
|
}
|
|
288
352
|
var LISTS = ["stats", "changes", "steps", "flow", "options", "notes", "next"];
|
|
353
|
+
var PLACE = { stats: -1, notes: 1, next: 2, details: 3 };
|
|
354
|
+
function place(block2) {
|
|
355
|
+
return block2.fold !== undefined ? 3 : PLACE[block2.type] ?? 0;
|
|
356
|
+
}
|
|
357
|
+
function placed(blocks) {
|
|
358
|
+
return blocks.map((block2, index) => ({ block: block2, index })).sort((a, b) => place(a.block) - place(b.block) || a.index - b.index).map((entry) => entry.block);
|
|
359
|
+
}
|
|
289
360
|
var GlanceSpec;
|
|
290
361
|
((GlanceSpec) => {
|
|
291
362
|
function read(value, partial = false, labels = LABELS) {
|
|
@@ -295,7 +366,7 @@ var GlanceSpec;
|
|
|
295
366
|
}
|
|
296
367
|
const status = oneOf(card.status, STATUSES);
|
|
297
368
|
const title = text(card.title);
|
|
298
|
-
const blocks = items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS);
|
|
369
|
+
const blocks = placed(items(Array.isArray(card.blocks) ? card.blocks : loose(card), (entry) => block(entry, partial, labels)).slice(0, BLOCKS));
|
|
299
370
|
if (!blocks.length && !title) {
|
|
300
371
|
return;
|
|
301
372
|
}
|
|
@@ -312,6 +383,26 @@ function percent(before, after) {
|
|
|
312
383
|
const change2 = Math.round((after - before) / Math.abs(before) * 100);
|
|
313
384
|
return `${change2 > 0 ? "+" : ""}${change2}%`;
|
|
314
385
|
}
|
|
386
|
+
function range(values) {
|
|
387
|
+
const low = Math.min(...values);
|
|
388
|
+
const high = Math.max(...values);
|
|
389
|
+
if (!values.length) {
|
|
390
|
+
return { low: 0, high: 1 };
|
|
391
|
+
}
|
|
392
|
+
if (low === high) {
|
|
393
|
+
return { low: low - 1, high: high + 1 };
|
|
394
|
+
}
|
|
395
|
+
const margin = (high - low) * 0.08;
|
|
396
|
+
return { low: low - margin, high: high + margin };
|
|
397
|
+
}
|
|
398
|
+
function points(values, count, { low, high }, width, height) {
|
|
399
|
+
const step2 = count > 1 ? width / (count - 1) : 0;
|
|
400
|
+
return values.map((value, index) => [count > 1 ? index * step2 : width / 2, height - (value - low) / (high - low) * height]);
|
|
401
|
+
}
|
|
402
|
+
function share(part, total) {
|
|
403
|
+
const value = total > 0 ? part / total * 100 : 0;
|
|
404
|
+
return value > 0 && value < 1 ? "<1%" : `${Math.round(value)}%`;
|
|
405
|
+
}
|
|
315
406
|
|
|
316
407
|
// ../ta-protocol/esm/common/language.js
|
|
317
408
|
var TaLanguageUtil;
|
|
@@ -363,8 +454,13 @@ var EN = {
|
|
|
363
454
|
pick: "I choose: {label}",
|
|
364
455
|
details: "Details",
|
|
365
456
|
hide: "Hide",
|
|
457
|
+
more: "{count} more",
|
|
366
458
|
files: "{count} files",
|
|
367
|
-
writing: "Drawing the summary…"
|
|
459
|
+
writing: "Drawing the summary…",
|
|
460
|
+
spokenChoices: "You can choose: {labels}.",
|
|
461
|
+
spokenRecommended: "I suggest {label}.",
|
|
462
|
+
spokenFailed: "{text}: failed.",
|
|
463
|
+
spokenJoin: ", "
|
|
368
464
|
};
|
|
369
465
|
var ZH = {
|
|
370
466
|
status: { done: "已完成", partial: "部分完成", failed: "失败", blocked: "需要你", info: "" },
|
|
@@ -376,8 +472,13 @@ var ZH = {
|
|
|
376
472
|
pick: "我选:{label}",
|
|
377
473
|
details: "详情",
|
|
378
474
|
hide: "收起",
|
|
475
|
+
more: "还有 {count} 项",
|
|
379
476
|
files: "{count} 个文件",
|
|
380
|
-
writing: "正在整理摘要…"
|
|
477
|
+
writing: "正在整理摘要…",
|
|
478
|
+
spokenChoices: "可以选:{labels}。",
|
|
479
|
+
spokenRecommended: "推荐{label}。",
|
|
480
|
+
spokenFailed: "{text}失败了。",
|
|
481
|
+
spokenJoin: "、"
|
|
381
482
|
};
|
|
382
483
|
var ZH_TW = {
|
|
383
484
|
status: { done: "已完成", partial: "部分完成", failed: "失敗", blocked: "需要你", info: "" },
|
|
@@ -389,8 +490,13 @@ var ZH_TW = {
|
|
|
389
490
|
pick: "我選:{label}",
|
|
390
491
|
details: "詳情",
|
|
391
492
|
hide: "收起",
|
|
493
|
+
more: "還有 {count} 項",
|
|
392
494
|
files: "{count} 個檔案",
|
|
393
|
-
writing: "正在整理摘要…"
|
|
495
|
+
writing: "正在整理摘要…",
|
|
496
|
+
spokenChoices: "可以選:{labels}。",
|
|
497
|
+
spokenRecommended: "推薦{label}。",
|
|
498
|
+
spokenFailed: "{text}失敗了。",
|
|
499
|
+
spokenJoin: "、"
|
|
394
500
|
};
|
|
395
501
|
var JA = {
|
|
396
502
|
status: { done: "完了", partial: "部分完了", failed: "失敗", blocked: "要対応", info: "" },
|
|
@@ -402,8 +508,13 @@ var JA = {
|
|
|
402
508
|
pick: "私が選んだ:{label}",
|
|
403
509
|
details: "詳細",
|
|
404
510
|
hide: "隠す",
|
|
511
|
+
more: "ほか {count} 件",
|
|
405
512
|
files: "{count} 個のファイル",
|
|
406
|
-
writing: "サマリーを作成中…"
|
|
513
|
+
writing: "サマリーを作成中…",
|
|
514
|
+
spokenChoices: "選択肢:{labels}。",
|
|
515
|
+
spokenRecommended: "オススメは{label}です。",
|
|
516
|
+
spokenFailed: "{text}は失敗しました。",
|
|
517
|
+
spokenJoin: "、"
|
|
407
518
|
};
|
|
408
519
|
var WORDS = { "zh-CN": ZH, "zh-TW": ZH_TW, "en-US": EN, "ja-JP": JA };
|
|
409
520
|
var GlanceWords;
|
|
@@ -433,6 +544,9 @@ function bind(react) {
|
|
|
433
544
|
var MARKS = /[*_`[\]$\\]/;
|
|
434
545
|
var SQUARES = 5;
|
|
435
546
|
var LINES = 20;
|
|
547
|
+
var SHOWN = { changes: 5, rows: 5, bars: 6 };
|
|
548
|
+
var WIDTH = 300;
|
|
549
|
+
var HEIGHT = 100;
|
|
436
550
|
function fileName(path) {
|
|
437
551
|
return path.replace(/\/+$/, "").split("/").pop() || path;
|
|
438
552
|
}
|
|
@@ -455,13 +569,172 @@ function glanceCard(pi) {
|
|
|
455
569
|
text: text2
|
|
456
570
|
})) : text2;
|
|
457
571
|
}
|
|
458
|
-
function Icon({ name, size = 14 }) {
|
|
459
|
-
const Found = icons[name];
|
|
572
|
+
function Icon({ name, fallback, size = 14 }) {
|
|
573
|
+
const Found = name && icons[name] || fallback && icons[fallback];
|
|
460
574
|
return Found ? /* @__PURE__ */ React.createElement(Found, {
|
|
461
575
|
size,
|
|
462
576
|
strokeWidth: 2
|
|
463
577
|
}) : null;
|
|
464
578
|
}
|
|
579
|
+
function Toggle({ open, label, opened, words, onToggle }) {
|
|
580
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
581
|
+
type: "button",
|
|
582
|
+
className: "tag-details-toggle",
|
|
583
|
+
"aria-expanded": open,
|
|
584
|
+
onClick: onToggle
|
|
585
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
586
|
+
name: "ChevronRight",
|
|
587
|
+
size: 14
|
|
588
|
+
}), /* @__PURE__ */ React.createElement("span", null, open ? opened ?? words.hide : label));
|
|
589
|
+
}
|
|
590
|
+
function useMore(count2, shown, words) {
|
|
591
|
+
const [open, setOpen] = React.useState(false);
|
|
592
|
+
if (count2 <= shown + 1) {
|
|
593
|
+
return { limit: count2, toggle: null };
|
|
594
|
+
}
|
|
595
|
+
return {
|
|
596
|
+
limit: open ? count2 : shown,
|
|
597
|
+
toggle: /* @__PURE__ */ React.createElement("div", {
|
|
598
|
+
className: "tag-more"
|
|
599
|
+
}, /* @__PURE__ */ React.createElement(Toggle, {
|
|
600
|
+
open,
|
|
601
|
+
label: GlanceWords.format(words.more, { count: count2 - shown }),
|
|
602
|
+
words,
|
|
603
|
+
onToggle: () => setOpen(!open)
|
|
604
|
+
}))
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
const has = (name) => !!name && !!icons[name];
|
|
608
|
+
function Polyline({
|
|
609
|
+
values,
|
|
610
|
+
count: count2,
|
|
611
|
+
scale,
|
|
612
|
+
area,
|
|
613
|
+
index
|
|
614
|
+
}) {
|
|
615
|
+
const at = points(values, count2, scale, WIDTH, HEIGHT);
|
|
616
|
+
const line = at.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join(" ");
|
|
617
|
+
const last = at[at.length - 1];
|
|
618
|
+
return /* @__PURE__ */ React.createElement("g", {
|
|
619
|
+
className: "tag-series",
|
|
620
|
+
"data-index": index
|
|
621
|
+
}, area && at.length > 1 && /* @__PURE__ */ React.createElement("polygon", {
|
|
622
|
+
className: "tag-series-area",
|
|
623
|
+
points: `0,${HEIGHT} ${line} ${last[0].toFixed(1)},${HEIGHT}`
|
|
624
|
+
}), /* @__PURE__ */ React.createElement("polyline", {
|
|
625
|
+
points: line,
|
|
626
|
+
fill: "none",
|
|
627
|
+
vectorEffect: "non-scaling-stroke"
|
|
628
|
+
}));
|
|
629
|
+
}
|
|
630
|
+
function Sparkline({ values }) {
|
|
631
|
+
return /* @__PURE__ */ React.createElement("svg", {
|
|
632
|
+
className: "tag-spark",
|
|
633
|
+
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
634
|
+
preserveAspectRatio: "none",
|
|
635
|
+
"aria-hidden": "true"
|
|
636
|
+
}, /* @__PURE__ */ React.createElement(Polyline, {
|
|
637
|
+
values,
|
|
638
|
+
count: values.length,
|
|
639
|
+
scale: range(values),
|
|
640
|
+
area: true,
|
|
641
|
+
index: 0
|
|
642
|
+
}));
|
|
643
|
+
}
|
|
644
|
+
function Line({ block: block2 }) {
|
|
645
|
+
const size = Math.max(block2.labels.length, ...block2.series.map((line) => line.values.length));
|
|
646
|
+
const scale = range(block2.series.flatMap((line) => line.values));
|
|
647
|
+
const unit = block2.unit ? ` ${block2.unit}` : "";
|
|
648
|
+
const marks = [...new Set(size >= 5 ? [0, Math.round((size - 1) / 2), size - 1] : [0, size - 1])].filter((index) => block2.labels[index] !== undefined);
|
|
649
|
+
const where = (index) => size > 1 ? index / (size - 1) * 100 : 50;
|
|
650
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
651
|
+
className: "tag-line"
|
|
652
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
653
|
+
className: "tag-section-head tag-legend"
|
|
654
|
+
}, block2.series.map((line, index) => {
|
|
655
|
+
const first = line.values[0];
|
|
656
|
+
const last = line.values[line.values.length - 1];
|
|
657
|
+
const change2 = line.values.length > 1 ? percent(first, last) : "";
|
|
658
|
+
const better = block2.better === "higher" ? last > first : last < first;
|
|
659
|
+
const tone = !block2.better || last === first ? "neutral" : better ? "good" : "bad";
|
|
660
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
661
|
+
key: index,
|
|
662
|
+
className: "tag-line-key",
|
|
663
|
+
"data-index": index
|
|
664
|
+
}, /* @__PURE__ */ React.createElement("i", null), line.label && /* @__PURE__ */ React.createElement(Text, {
|
|
665
|
+
text: line.label
|
|
666
|
+
}), /* @__PURE__ */ React.createElement("b", null, count(last), unit), change2 && /* @__PURE__ */ React.createElement("span", {
|
|
667
|
+
className: "tag-delta",
|
|
668
|
+
"data-tone": tone
|
|
669
|
+
}, change2));
|
|
670
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
671
|
+
className: "tag-plot"
|
|
672
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
673
|
+
className: "tag-plot-area"
|
|
674
|
+
}, /* @__PURE__ */ React.createElement("svg", {
|
|
675
|
+
viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
|
|
676
|
+
preserveAspectRatio: "none",
|
|
677
|
+
"aria-hidden": "true"
|
|
678
|
+
}, [0, HEIGHT / 2, HEIGHT].map((y) => /* @__PURE__ */ React.createElement("line", {
|
|
679
|
+
key: y,
|
|
680
|
+
className: "tag-grid",
|
|
681
|
+
x1: 0,
|
|
682
|
+
x2: WIDTH,
|
|
683
|
+
y1: y,
|
|
684
|
+
y2: y,
|
|
685
|
+
vectorEffect: "non-scaling-stroke"
|
|
686
|
+
})), block2.series.map((line, index) => /* @__PURE__ */ React.createElement(Polyline, {
|
|
687
|
+
key: index,
|
|
688
|
+
values: line.values,
|
|
689
|
+
count: size,
|
|
690
|
+
scale,
|
|
691
|
+
area: index === 0 && block2.series.length === 1,
|
|
692
|
+
index
|
|
693
|
+
}))), block2.series.map((line, index) => {
|
|
694
|
+
const [x, y] = points(line.values, size, scale, WIDTH, HEIGHT)[line.values.length - 1];
|
|
695
|
+
return /* @__PURE__ */ React.createElement("i", {
|
|
696
|
+
key: index,
|
|
697
|
+
className: "tag-plot-dot",
|
|
698
|
+
"data-index": index,
|
|
699
|
+
style: { left: `${x / WIDTH * 100}%`, top: `${y / HEIGHT * 100}%` }
|
|
700
|
+
});
|
|
701
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
702
|
+
className: "tag-plot-axis",
|
|
703
|
+
"aria-hidden": "true"
|
|
704
|
+
}, /* @__PURE__ */ React.createElement("span", null, count(Math.max(...block2.series.flatMap((line) => line.values)))), /* @__PURE__ */ React.createElement("span", null, count(Math.min(...block2.series.flatMap((line) => line.values))))), marks.length > 0 && /* @__PURE__ */ React.createElement("div", {
|
|
705
|
+
className: "tag-plot-labels"
|
|
706
|
+
}, marks.map((index) => /* @__PURE__ */ React.createElement("span", {
|
|
707
|
+
key: index,
|
|
708
|
+
"data-at": index === 0 ? "start" : index === size - 1 ? "end" : "middle",
|
|
709
|
+
style: { left: `${where(index)}%` }
|
|
710
|
+
}, block2.labels[index])))));
|
|
711
|
+
}
|
|
712
|
+
function Share({ block: block2 }) {
|
|
713
|
+
const total = block2.items.reduce((sum, item) => sum + item.value, 0);
|
|
714
|
+
const unit = block2.unit ? ` ${block2.unit}` : "";
|
|
715
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
716
|
+
className: "tag-share"
|
|
717
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
718
|
+
className: "tag-share-bar",
|
|
719
|
+
"aria-hidden": "true"
|
|
720
|
+
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("i", {
|
|
721
|
+
key: index,
|
|
722
|
+
"data-index": index,
|
|
723
|
+
style: { flexGrow: item.value }
|
|
724
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
725
|
+
className: "tag-share-keys"
|
|
726
|
+
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
727
|
+
key: index,
|
|
728
|
+
className: "tag-share-key",
|
|
729
|
+
"data-index": index
|
|
730
|
+
}, /* @__PURE__ */ React.createElement("i", null), /* @__PURE__ */ React.createElement("span", {
|
|
731
|
+
className: "tag-share-label"
|
|
732
|
+
}, /* @__PURE__ */ React.createElement(Text, {
|
|
733
|
+
text: item.label
|
|
734
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
735
|
+
className: "tag-share-value"
|
|
736
|
+
}, count(item.value), unit), /* @__PURE__ */ React.createElement("b", null, share(item.value, total))))));
|
|
737
|
+
}
|
|
465
738
|
function Stats({ block: block2 }) {
|
|
466
739
|
return /* @__PURE__ */ React.createElement("div", {
|
|
467
740
|
className: "tag-stats",
|
|
@@ -469,14 +742,22 @@ function glanceCard(pi) {
|
|
|
469
742
|
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
470
743
|
key: index,
|
|
471
744
|
className: "tag-stat",
|
|
472
|
-
"data-tone": item.tone
|
|
745
|
+
"data-tone": item.tone,
|
|
746
|
+
"data-words": !/\d/.test(item.value) || undefined
|
|
473
747
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
474
748
|
className: "tag-stat-value"
|
|
475
749
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
476
750
|
text: item.value
|
|
477
|
-
})), /* @__PURE__ */ React.createElement(
|
|
751
|
+
})), item.trend && /* @__PURE__ */ React.createElement(Sparkline, {
|
|
752
|
+
values: item.trend
|
|
753
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
478
754
|
className: "tag-stat-label"
|
|
479
|
-
}, item.
|
|
755
|
+
}, has(item.icon) ? /* @__PURE__ */ React.createElement("span", {
|
|
756
|
+
className: "tag-item-icon"
|
|
757
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
758
|
+
name: item.icon,
|
|
759
|
+
size: 12
|
|
760
|
+
})) : item.tone && !item.delta && /* @__PURE__ */ React.createElement("i", {
|
|
480
761
|
className: "tag-tone-dot"
|
|
481
762
|
}), /* @__PURE__ */ React.createElement(Text, {
|
|
482
763
|
text: item.label
|
|
@@ -505,6 +786,7 @@ function glanceCard(pi) {
|
|
|
505
786
|
const add = block2.items.reduce((sum, item) => sum + (item.add ?? 0), 0);
|
|
506
787
|
const del = block2.items.reduce((sum, item) => sum + (item.del ?? 0), 0);
|
|
507
788
|
const largest = Math.max(LINES, ...block2.items.map((item) => (item.add ?? 0) + (item.del ?? 0)));
|
|
789
|
+
const more = useMore(block2.items.length, SHOWN.changes, words);
|
|
508
790
|
return /* @__PURE__ */ React.createElement("div", {
|
|
509
791
|
className: "tag-changes"
|
|
510
792
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
@@ -513,7 +795,7 @@ function glanceCard(pi) {
|
|
|
513
795
|
className: "tag-add"
|
|
514
796
|
}, "+", add), del > 0 && /* @__PURE__ */ React.createElement("span", {
|
|
515
797
|
className: "tag-del"
|
|
516
|
-
}, "−", del)), block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
798
|
+
}, "−", del)), block2.items.slice(0, more.limit).map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
517
799
|
key: index,
|
|
518
800
|
className: "tag-change"
|
|
519
801
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -543,7 +825,7 @@ function glanceCard(pi) {
|
|
|
543
825
|
}, "−", item.del) : null, /* @__PURE__ */ React.createElement(Squares, {
|
|
544
826
|
change: item,
|
|
545
827
|
largest
|
|
546
|
-
})))));
|
|
828
|
+
})))), more.toggle);
|
|
547
829
|
}
|
|
548
830
|
const STEP_ICON = { done: "Check", failed: "X", skipped: "Minus", doing: undefined, todo: undefined };
|
|
549
831
|
function Steps({ block: block2 }) {
|
|
@@ -606,12 +888,13 @@ function glanceCard(pi) {
|
|
|
606
888
|
})));
|
|
607
889
|
}));
|
|
608
890
|
}
|
|
609
|
-
function Bars({ block: block2 }) {
|
|
891
|
+
function Bars({ block: block2, words }) {
|
|
610
892
|
const largest = Math.max(...block2.items.map((item) => Math.abs(item.value)), 0) || 1;
|
|
611
893
|
const unit = block2.unit ? ` ${block2.unit}` : "";
|
|
612
|
-
|
|
894
|
+
const more = useMore(block2.items.length, SHOWN.bars, words);
|
|
895
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
|
|
613
896
|
className: "tag-bars"
|
|
614
|
-
}, block2.items.map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
897
|
+
}, block2.items.slice(0, more.limit).map((item, index) => /* @__PURE__ */ React.createElement("div", {
|
|
615
898
|
key: index,
|
|
616
899
|
className: "tag-bar"
|
|
617
900
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
@@ -624,7 +907,7 @@ function glanceCard(pi) {
|
|
|
624
907
|
style: { width: `${Math.abs(item.value) / largest * 100}%` }
|
|
625
908
|
})), /* @__PURE__ */ React.createElement("span", {
|
|
626
909
|
className: "tag-bar-value"
|
|
627
|
-
}, count(item.value), unit))));
|
|
910
|
+
}, count(item.value), unit)))), more.toggle);
|
|
628
911
|
}
|
|
629
912
|
function Flow({ block: block2 }) {
|
|
630
913
|
return /* @__PURE__ */ React.createElement("div", {
|
|
@@ -640,24 +923,30 @@ function glanceCard(pi) {
|
|
|
640
923
|
size: 13
|
|
641
924
|
})), /* @__PURE__ */ React.createElement("span", {
|
|
642
925
|
className: "tag-flow-node"
|
|
643
|
-
}, /* @__PURE__ */ React.createElement(
|
|
644
|
-
|
|
926
|
+
}, has(item.icon) && /* @__PURE__ */ React.createElement("span", {
|
|
927
|
+
className: "tag-item-icon"
|
|
928
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
929
|
+
name: item.icon,
|
|
930
|
+
size: 13
|
|
931
|
+
})), /* @__PURE__ */ React.createElement(Text, {
|
|
932
|
+
text: item.text
|
|
645
933
|
})))));
|
|
646
934
|
}
|
|
647
|
-
function Table({ block: block2 }) {
|
|
648
|
-
|
|
935
|
+
function Table({ block: block2, words }) {
|
|
936
|
+
const more = useMore(block2.rows.length, SHOWN.rows, words);
|
|
937
|
+
return /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("div", {
|
|
649
938
|
className: "ta-table tag-table"
|
|
650
939
|
}, /* @__PURE__ */ React.createElement("table", null, /* @__PURE__ */ React.createElement("thead", null, /* @__PURE__ */ React.createElement("tr", null, block2.columns.map((column, index) => /* @__PURE__ */ React.createElement("th", {
|
|
651
940
|
key: index
|
|
652
941
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
653
942
|
text: column
|
|
654
|
-
}))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.map((row, index) => /* @__PURE__ */ React.createElement("tr", {
|
|
943
|
+
}))))), /* @__PURE__ */ React.createElement("tbody", null, block2.rows.slice(0, more.limit).map((row, index) => /* @__PURE__ */ React.createElement("tr", {
|
|
655
944
|
key: index
|
|
656
945
|
}, row.map((cell, column) => /* @__PURE__ */ React.createElement("td", {
|
|
657
946
|
key: column
|
|
658
947
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
659
948
|
text: cell
|
|
660
|
-
}))))))));
|
|
949
|
+
})))))))), more.toggle);
|
|
661
950
|
}
|
|
662
951
|
function Options({ block: block2, words, closed }) {
|
|
663
952
|
const [tapped, setChosen] = React.useState();
|
|
@@ -698,7 +987,12 @@ function glanceCard(pi) {
|
|
|
698
987
|
className: "tag-option-main"
|
|
699
988
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
700
989
|
className: "tag-option-head"
|
|
701
|
-
}, /* @__PURE__ */ React.createElement("span", {
|
|
990
|
+
}, has(item.icon) && /* @__PURE__ */ React.createElement("span", {
|
|
991
|
+
className: "tag-item-icon"
|
|
992
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
993
|
+
name: item.icon,
|
|
994
|
+
size: 14
|
|
995
|
+
})), /* @__PURE__ */ React.createElement("span", {
|
|
702
996
|
className: "tag-option-label"
|
|
703
997
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
704
998
|
text: item.label
|
|
@@ -710,16 +1004,16 @@ function glanceCard(pi) {
|
|
|
710
1004
|
text: item.detail
|
|
711
1005
|
})), (item.pros.length > 0 || item.cons.length > 0) && /* @__PURE__ */ React.createElement("div", {
|
|
712
1006
|
className: "tag-points"
|
|
713
|
-
}, item.pros.map((
|
|
1007
|
+
}, item.pros.map((point2, at) => /* @__PURE__ */ React.createElement("span", {
|
|
714
1008
|
key: `p${at}`,
|
|
715
1009
|
"data-tone": "good"
|
|
716
1010
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
717
|
-
text:
|
|
718
|
-
}))), item.cons.map((
|
|
1011
|
+
text: point2
|
|
1012
|
+
}))), item.cons.map((point2, at) => /* @__PURE__ */ React.createElement("span", {
|
|
719
1013
|
key: `c${at}`,
|
|
720
1014
|
"data-tone": "bad"
|
|
721
1015
|
}, /* @__PURE__ */ React.createElement(Text, {
|
|
722
|
-
text:
|
|
1016
|
+
text: point2
|
|
723
1017
|
}))))), /* @__PURE__ */ React.createElement("button", {
|
|
724
1018
|
type: "button",
|
|
725
1019
|
className: `ta-button tag-choose${item.recommended && !done ? " ta-primary" : ""}`,
|
|
@@ -731,7 +1025,7 @@ function glanceCard(pi) {
|
|
|
731
1025
|
}), /* @__PURE__ */ React.createElement("span", null, picked ? words.chosen : words.choose)));
|
|
732
1026
|
})));
|
|
733
1027
|
}
|
|
734
|
-
const NOTE_ICON = { risk: "CircleAlert", info: "Info", todo: "
|
|
1028
|
+
const NOTE_ICON = { risk: "CircleAlert", info: "Info", todo: "CircleArrowRight" };
|
|
735
1029
|
function Notes({ block: block2 }) {
|
|
736
1030
|
return /* @__PURE__ */ React.createElement("ul", {
|
|
737
1031
|
className: "tag-notes"
|
|
@@ -741,7 +1035,8 @@ function glanceCard(pi) {
|
|
|
741
1035
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
742
1036
|
className: "tag-note-mark"
|
|
743
1037
|
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
744
|
-
name:
|
|
1038
|
+
name: item.icon,
|
|
1039
|
+
fallback: NOTE_ICON[item.tone],
|
|
745
1040
|
size: 14
|
|
746
1041
|
})), /* @__PURE__ */ React.createElement("span", null, /* @__PURE__ */ React.createElement(Text, {
|
|
747
1042
|
text: item.text
|
|
@@ -756,11 +1051,12 @@ function glanceCard(pi) {
|
|
|
756
1051
|
type: "button",
|
|
757
1052
|
className: "tag-chip",
|
|
758
1053
|
disabled: !closed || !send,
|
|
759
|
-
onClick: () => void send?.(item).catch((error) => pi.ui.notify(error instanceof Error ? error.message : String(error), "error"))
|
|
1054
|
+
onClick: () => void send?.(item.text).catch((error) => pi.ui.notify(error instanceof Error ? error.message : String(error), "error"))
|
|
760
1055
|
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
761
|
-
name:
|
|
1056
|
+
name: item.icon,
|
|
1057
|
+
fallback: "CornerDownRight",
|
|
762
1058
|
size: 13
|
|
763
|
-
}), /* @__PURE__ */ React.createElement("span", null, item.replace(/\*\*|`/g, "")))));
|
|
1059
|
+
}), /* @__PURE__ */ React.createElement("span", null, item.text.replace(/\*\*|`/g, "")))));
|
|
764
1060
|
}
|
|
765
1061
|
function Details({ block: block2, words }) {
|
|
766
1062
|
const [open, setOpen] = React.useState(false);
|
|
@@ -802,6 +1098,15 @@ function glanceCard(pi) {
|
|
|
802
1098
|
});
|
|
803
1099
|
case "bars":
|
|
804
1100
|
return /* @__PURE__ */ React.createElement(Bars, {
|
|
1101
|
+
block: block2,
|
|
1102
|
+
words
|
|
1103
|
+
});
|
|
1104
|
+
case "line":
|
|
1105
|
+
return /* @__PURE__ */ React.createElement(Line, {
|
|
1106
|
+
block: block2
|
|
1107
|
+
});
|
|
1108
|
+
case "share":
|
|
1109
|
+
return /* @__PURE__ */ React.createElement(Share, {
|
|
805
1110
|
block: block2
|
|
806
1111
|
});
|
|
807
1112
|
case "flow":
|
|
@@ -816,7 +1121,8 @@ ${block2.mermaid}
|
|
|
816
1121
|
}) : null;
|
|
817
1122
|
case "table":
|
|
818
1123
|
return /* @__PURE__ */ React.createElement(Table, {
|
|
819
|
-
block: block2
|
|
1124
|
+
block: block2,
|
|
1125
|
+
words
|
|
820
1126
|
});
|
|
821
1127
|
case "options":
|
|
822
1128
|
return /* @__PURE__ */ React.createElement(Options, {
|
|
@@ -840,8 +1146,26 @@ ${block2.mermaid}
|
|
|
840
1146
|
});
|
|
841
1147
|
}
|
|
842
1148
|
}
|
|
1149
|
+
function Folded({ block: block2, words, closed }) {
|
|
1150
|
+
const [open, setOpen] = React.useState(false);
|
|
1151
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1152
|
+
className: "tag-details"
|
|
1153
|
+
}, /* @__PURE__ */ React.createElement(Toggle, {
|
|
1154
|
+
open,
|
|
1155
|
+
label: block2.fold || words.details,
|
|
1156
|
+
opened: block2.fold || words.details,
|
|
1157
|
+
words,
|
|
1158
|
+
onToggle: () => setOpen(!open)
|
|
1159
|
+
}), open && /* @__PURE__ */ React.createElement("div", {
|
|
1160
|
+
className: "tag-folded-body"
|
|
1161
|
+
}, /* @__PURE__ */ React.createElement(Part, {
|
|
1162
|
+
block: block2,
|
|
1163
|
+
words,
|
|
1164
|
+
closed
|
|
1165
|
+
})));
|
|
1166
|
+
}
|
|
843
1167
|
function Head({ card, words }) {
|
|
844
|
-
const status = card.status && words.status[card.status];
|
|
1168
|
+
const status = card.status && (card.status !== "done" || card.title) ? words.status[card.status] : undefined;
|
|
845
1169
|
if (!status && !card.title) {
|
|
846
1170
|
return null;
|
|
847
1171
|
}
|
|
@@ -880,6 +1204,7 @@ ${code}
|
|
|
880
1204
|
value: answer
|
|
881
1205
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
882
1206
|
className: "tag-card",
|
|
1207
|
+
"data-status": card.status,
|
|
883
1208
|
"data-streaming": !closed || undefined
|
|
884
1209
|
}, /* @__PURE__ */ React.createElement(Head, {
|
|
885
1210
|
card,
|
|
@@ -887,8 +1212,13 @@ ${code}
|
|
|
887
1212
|
}), card.blocks.map((block2, index) => /* @__PURE__ */ React.createElement("div", {
|
|
888
1213
|
key: index,
|
|
889
1214
|
className: "tag-part",
|
|
890
|
-
"data-type": block2.type
|
|
891
|
-
|
|
1215
|
+
"data-type": block2.type,
|
|
1216
|
+
"data-fold": block2.fold !== undefined || undefined
|
|
1217
|
+
}, block2.fold !== undefined ? /* @__PURE__ */ React.createElement(Folded, {
|
|
1218
|
+
block: block2,
|
|
1219
|
+
words,
|
|
1220
|
+
closed
|
|
1221
|
+
}) : /* @__PURE__ */ React.createElement(Part, {
|
|
892
1222
|
block: block2,
|
|
893
1223
|
words,
|
|
894
1224
|
closed
|
|
@@ -900,6 +1230,40 @@ ${code}
|
|
|
900
1230
|
var LANGUAGE = "ta-glance";
|
|
901
1231
|
var ALIASES = ["glance", "glance-choice"];
|
|
902
1232
|
|
|
1233
|
+
// web-src/glance-speech.ts
|
|
1234
|
+
var GlanceSpeech;
|
|
1235
|
+
((GlanceSpeech) => {
|
|
1236
|
+
function of(card, words) {
|
|
1237
|
+
const said = [];
|
|
1238
|
+
for (const block2 of card.blocks) {
|
|
1239
|
+
if (block2.type === "options" && block2.items.length) {
|
|
1240
|
+
if (block2.question) {
|
|
1241
|
+
said.push(sentence(block2.question));
|
|
1242
|
+
}
|
|
1243
|
+
said.push(GlanceWords.format(words.spokenChoices, { labels: block2.items.map((item) => item.label).join(words.spokenJoin) }));
|
|
1244
|
+
const suggested = block2.items.find((item) => item.recommended);
|
|
1245
|
+
if (suggested) {
|
|
1246
|
+
said.push(GlanceWords.format(words.spokenRecommended, { label: suggested.label }));
|
|
1247
|
+
}
|
|
1248
|
+
} else if (block2.type === "steps") {
|
|
1249
|
+
for (const step2 of block2.items.filter((item) => item.status === "failed")) {
|
|
1250
|
+
said.push(GlanceWords.format(words.spokenFailed, { text: step2.text }));
|
|
1251
|
+
}
|
|
1252
|
+
} else if (block2.type === "notes") {
|
|
1253
|
+
for (const note2 of block2.items.filter((item) => item.tone !== "info")) {
|
|
1254
|
+
said.push(sentence(note2.text));
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return said.length ? said.join(" ") : undefined;
|
|
1259
|
+
}
|
|
1260
|
+
GlanceSpeech.of = of;
|
|
1261
|
+
function sentence(text2) {
|
|
1262
|
+
const trimmed = text2.trim();
|
|
1263
|
+
return /[.!?。!?::]$/.test(trimmed) ? trimmed : /[\u3000-\u9fff]/.test(trimmed) ? `${trimmed}。` : `${trimmed}.`;
|
|
1264
|
+
}
|
|
1265
|
+
})(GlanceSpeech ||= {});
|
|
1266
|
+
|
|
903
1267
|
// web-src/style.ts
|
|
904
1268
|
var STYLE = `
|
|
905
1269
|
/*
|
|
@@ -951,7 +1315,7 @@ var STYLE = `
|
|
|
951
1315
|
.tag-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; padding: var(--tag-y) var(--tag-x) 0; }
|
|
952
1316
|
.tag-card > .tag-head + .tag-part { border-top: 0; padding-top: 8px; }
|
|
953
1317
|
/* A table or a diagram reaches the edges: under the head it keeps the hairline, a gap above it */
|
|
954
|
-
.tag-card > .tag-head + .tag-part:is([data-type='table'], [data-type='diagram']) { margin-top: var(--tag-y); padding-top: 0; border-top: 1px solid var(--tag-line); }
|
|
1318
|
+
.tag-card > .tag-head + .tag-part:is([data-type='table'], [data-type='diagram']):not([data-fold]) { margin-top: var(--tag-y); padding-top: 0; border-top: 1px solid var(--tag-line); }
|
|
955
1319
|
.tag-title { flex: 1 1 14em; min-width: 0; font-weight: 600; font-size: calc(14px * var(--tag-s)); line-height: 1.45; color: var(--ta-text); }
|
|
956
1320
|
.tag-status { --tag-tone: var(--ta-muted); flex: none; display: inline-flex; align-items: center; gap: 6px; height: calc(22px * var(--tag-s)); padding: 0 9px; border-radius: 999px; font-size: var(--tag-small); font-weight: 600; line-height: 1; white-space: nowrap; color: var(--tag-tone); background: color-mix(in srgb, var(--tag-tone) 12%, transparent); }
|
|
957
1321
|
.tag-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
|
@@ -960,6 +1324,8 @@ var STYLE = `
|
|
|
960
1324
|
/* Needs you: the blue of what waits for the user, as the ? of the list of chats. */
|
|
961
1325
|
.tag-status[data-status='blocked'] { --tag-tone: var(--ta-blue); }
|
|
962
1326
|
.tag-status[data-status='failed'] { --tag-tone: var(--ta-red); }
|
|
1327
|
+
/* Done without a title has no row of its own: a green edge at the top of the card says it */
|
|
1328
|
+
.tag-card[data-status='done']:not(:has(> .tag-head))::before { content: ''; position: absolute; z-index: 1; inset: 0 0 auto; height: 2px; background: var(--ta-green); pointer-events: none; }
|
|
963
1329
|
|
|
964
1330
|
/* What a part is about, in small muted type above it */
|
|
965
1331
|
.tag-section-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin-bottom: 6px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
|
|
@@ -982,7 +1348,19 @@ var STYLE = `
|
|
|
982
1348
|
.tag-stat { min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--ta-raised); }
|
|
983
1349
|
.tag-stat-value { font-size: calc(20px * var(--tag-s)); font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--ta-text); }
|
|
984
1350
|
@container tag-card (max-width: 400px) { .tag-stat-value { font-size: calc(18px * var(--tag-s)); } }
|
|
985
|
-
|
|
1351
|
+
/* A value in words (Included) is not a number to read from afar: body size, on the line of the numbers beside it */
|
|
1352
|
+
.tag-stat[data-words] > .tag-stat-value { font-size: calc(15px * var(--tag-s)); line-height: calc(25px * var(--tag-s)); letter-spacing: 0; }
|
|
1353
|
+
@container tag-card (max-width: 400px) { .tag-stat[data-words] > .tag-stat-value { font-size: calc(14px * var(--tag-s)); line-height: calc(22.5px * var(--tag-s)); } }
|
|
1354
|
+
/* Its icon, name and change wrap as wholes, so that a narrow box does not break the name */
|
|
1355
|
+
.tag-stat-label { display: flex; flex-wrap: wrap; align-items: center; margin-top: 2px; color: var(--ta-muted); font-size: var(--tag-small); line-height: 1.4; }
|
|
1356
|
+
/* The icon an item names: before its label, in the color of its tone where it has one */
|
|
1357
|
+
.tag-item-icon { flex: none; display: inline-flex; color: var(--ta-secondary); }
|
|
1358
|
+
.tag-item-icon svg { width: calc(var(--tag-icon, 13px) * var(--tag-s)); height: calc(var(--tag-icon, 13px) * var(--tag-s)); }
|
|
1359
|
+
.tag-stat-label > .tag-item-icon { --tag-icon: 12px; margin-right: 5px; }
|
|
1360
|
+
[data-tone='good'] > .tag-stat-label > .tag-item-icon { color: var(--ta-green); }
|
|
1361
|
+
[data-tone='bad'] > .tag-stat-label > .tag-item-icon { color: var(--ta-red); }
|
|
1362
|
+
[data-tone='warn'] > .tag-stat-label > .tag-item-icon { color: var(--ta-yellow); }
|
|
1363
|
+
.tag-option-head > .tag-item-icon { --tag-icon: 14px; }
|
|
986
1364
|
.tag-tone-dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; vertical-align: 0.1em; background: var(--ta-muted); }
|
|
987
1365
|
[data-tone='good'] > .tag-stat-label > .tag-tone-dot { background: var(--ta-green); }
|
|
988
1366
|
[data-tone='bad'] > .tag-stat-label > .tag-tone-dot { background: var(--ta-red); }
|
|
@@ -1059,10 +1437,64 @@ var STYLE = `
|
|
|
1059
1437
|
.tag-bar .tag-track { grid-area: 2 / 1 / 3 / 3; }
|
|
1060
1438
|
}
|
|
1061
1439
|
|
|
1440
|
+
/* Charts: the lines of a chart and the parts of a whole in the color of amounts (blue) first, then amber, grey,
|
|
1441
|
+
faint blue; green and red only for a change that is better or worse. Strokes keep their width as the SVG stretches. */
|
|
1442
|
+
.tag-card { --tag-c0: var(--ta-accent); --tag-c1: var(--ta-yellow); --tag-c2: var(--ta-secondary); --tag-c3: color-mix(in srgb, var(--ta-accent) 45%, transparent); }
|
|
1443
|
+
.tag-series polyline { stroke: var(--tag-c0); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
|
|
1444
|
+
.tag-series[data-index='1'] polyline { stroke: var(--tag-c1); }
|
|
1445
|
+
.tag-series[data-index='2'] polyline { stroke: var(--tag-c2); }
|
|
1446
|
+
.tag-series[data-index='3'] polyline { stroke: var(--tag-c3); }
|
|
1447
|
+
.tag-series-area { fill: color-mix(in srgb, var(--tag-tint, var(--tag-c0)) 12%, transparent); stroke: none; }
|
|
1448
|
+
.tag-grid { stroke: var(--tag-line); stroke-width: 1; }
|
|
1449
|
+
|
|
1450
|
+
/* The small line of a key number, under it, in the color of its tone */
|
|
1451
|
+
.tag-spark { display: block; width: 100%; height: calc(20px * var(--tag-s)); margin: 4px 0 2px; overflow: visible; }
|
|
1452
|
+
.tag-spark polyline { stroke-width: 1.5; }
|
|
1453
|
+
[data-tone='good'] > .tag-spark { --tag-c0: var(--ta-green); }
|
|
1454
|
+
[data-tone='bad'] > .tag-spark { --tag-c0: var(--ta-red); }
|
|
1455
|
+
[data-tone='warn'] > .tag-spark { --tag-c0: var(--ta-yellow); }
|
|
1456
|
+
|
|
1457
|
+
/* A line over time: what each line is now and how it changed above it, its highest and lowest on the right, the first, middle and last labels under it */
|
|
1458
|
+
.tag-line-key { display: inline-flex; align-items: baseline; gap: 5px; }
|
|
1459
|
+
.tag-line-key > i { align-self: center; width: 10px; height: 2px; border-radius: 1px; background: var(--tag-c0); }
|
|
1460
|
+
.tag-line-key[data-index='1'] > i { background: var(--tag-c1); }
|
|
1461
|
+
.tag-line-key[data-index='2'] > i { background: var(--tag-c2); }
|
|
1462
|
+
.tag-line-key[data-index='3'] > i { background: var(--tag-c3); }
|
|
1463
|
+
.tag-line-key > b { color: var(--ta-text); font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
1464
|
+
.tag-line-key > .tag-delta { margin-left: 0; }
|
|
1465
|
+
.tag-plot { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; }
|
|
1466
|
+
.tag-plot-area { position: relative; height: calc(96px * var(--tag-s)); }
|
|
1467
|
+
.tag-plot-area svg { display: block; width: 100%; height: 100%; overflow: visible; }
|
|
1468
|
+
.tag-plot-dot { position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--tag-c0); box-shadow: 0 0 0 2px var(--ta-card); }
|
|
1469
|
+
.tag-plot-dot[data-index='1'] { background: var(--tag-c1); }
|
|
1470
|
+
.tag-plot-dot[data-index='2'] { background: var(--tag-c2); }
|
|
1471
|
+
.tag-plot-dot[data-index='3'] { background: var(--tag-c3); }
|
|
1472
|
+
.tag-plot-axis { display: flex; flex-direction: column; justify-content: space-between; margin: -0.6em 0; color: var(--ta-muted); font-size: var(--tag-tiny); line-height: 1.2; font-variant-numeric: tabular-nums; text-align: right; }
|
|
1473
|
+
.tag-plot-labels { grid-column: 1; position: relative; height: 1.4em; margin-top: 6px; color: var(--ta-muted); font-size: var(--tag-tiny); line-height: 1.4; }
|
|
1474
|
+
.tag-plot-labels span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
|
|
1475
|
+
.tag-plot-labels span[data-at='start'] { transform: none; }
|
|
1476
|
+
.tag-plot-labels span[data-at='end'] { transform: translateX(-100%); }
|
|
1477
|
+
|
|
1478
|
+
/* Parts of a whole: one bar cut in parts, a key of each under it with its amount and share */
|
|
1479
|
+
.tag-share-bar { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; }
|
|
1480
|
+
.tag-share-bar i { flex: 1 1 0; min-width: 3px; background: var(--tag-part); transition: flex-grow 0.4s var(--ta-ease, ease); }
|
|
1481
|
+
.tag-share [data-index='0'] { --tag-part: var(--ta-accent); }
|
|
1482
|
+
.tag-share [data-index='1'] { --tag-part: color-mix(in srgb, var(--ta-accent) 66%, transparent); }
|
|
1483
|
+
.tag-share [data-index='2'] { --tag-part: color-mix(in srgb, var(--ta-accent) 44%, transparent); }
|
|
1484
|
+
.tag-share [data-index='3'] { --tag-part: color-mix(in srgb, var(--ta-accent) 28%, transparent); }
|
|
1485
|
+
.tag-share [data-index='4'] { --tag-part: color-mix(in srgb, var(--ta-accent) 17%, transparent); }
|
|
1486
|
+
.tag-share [data-index='5'] { --tag-part: var(--ta-border-field); }
|
|
1487
|
+
.tag-share-keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(150px * var(--tag-s)), 1fr)); gap: 4px 16px; margin-top: 8px; }
|
|
1488
|
+
.tag-share-key { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--tag-small); line-height: 1.5; }
|
|
1489
|
+
.tag-share-key > i { flex: none; width: 8px; height: 8px; border-radius: 2px; background: var(--tag-part); }
|
|
1490
|
+
.tag-share-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1491
|
+
.tag-share-value { color: var(--ta-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
1492
|
+
.tag-share-key > b { min-width: 2.6em; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
|
|
1493
|
+
|
|
1062
1494
|
/* A path: nodes and arrows; an arrow keeps to the node after it, so that no line ends with one */
|
|
1063
1495
|
.tag-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 6px; }
|
|
1064
1496
|
.tag-flow-step { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
|
|
1065
|
-
.tag-flow-node { min-width: 0; padding: 2px 10px; border: 1px solid var(--ta-border); border-radius: 6px; background: var(--ta-raised); line-height: var(--tag-lh); }
|
|
1497
|
+
.tag-flow-node { display: inline-flex; align-items: center; gap: 5px; min-width: 0; padding: 2px 10px; border: 1px solid var(--ta-border); border-radius: 6px; background: var(--ta-raised); line-height: var(--tag-lh); }
|
|
1066
1498
|
.tag-flow-arrow { flex: none; display: inline-flex; color: var(--ta-muted); }
|
|
1067
1499
|
.tag-flow-arrow svg { width: calc(13px * var(--tag-s)); height: calc(13px * var(--tag-s)); }
|
|
1068
1500
|
|
|
@@ -1074,6 +1506,9 @@ var STYLE = `
|
|
|
1074
1506
|
.tag-card .tag-table th:first-child, .tag-card .tag-table td:first-child { padding-left: var(--tag-x); }
|
|
1075
1507
|
.tag-card .tag-table th:last-child, .tag-card .tag-table td:last-child { padding-right: var(--tag-x); }
|
|
1076
1508
|
.tag-card .tag-table th { font-size: var(--tag-small); color: var(--ta-secondary); }
|
|
1509
|
+
/* The columns before the last keep to what they hold, the names of the rows close to their values; the last takes the rest and wraps */
|
|
1510
|
+
.tag-card .tag-table th:last-child:not(:first-child) { width: 100%; }
|
|
1511
|
+
.tag-card .tag-table td:last-child:not(:first-child) { min-width: 8em; white-space: normal; }
|
|
1077
1512
|
.tag-card .ta-mermaid { margin: 0; border: 0; border-radius: 0; background: transparent; }
|
|
1078
1513
|
.tag-card .ta-mermaid .ta-code-bar { padding-left: var(--tag-x); padding-right: calc(var(--tag-x) - 4px); }
|
|
1079
1514
|
.tag-card .ta-markdown:has(> .ta-mermaid) { margin: 0; }
|
|
@@ -1119,8 +1554,14 @@ var STYLE = `
|
|
|
1119
1554
|
.tag-chip:disabled { opacity: 0.5; cursor: default; }
|
|
1120
1555
|
.tag-part[data-type='next'] { padding-top: calc(var(--tag-y) - 2px); padding-bottom: calc(var(--tag-y) - 2px); }
|
|
1121
1556
|
|
|
1122
|
-
/* Details, folded */
|
|
1123
|
-
.tag-part[data-type='details'] { padding
|
|
1557
|
+
/* Details, folded; a block the model folded, under its words; the rest of a long list */
|
|
1558
|
+
.tag-part[data-type='details'], .tag-card > .tag-part[data-fold] { padding: 8px var(--tag-x); }
|
|
1559
|
+
.tag-folded-body { margin-top: 6px; padding-bottom: 4px; animation: ta-in 180ms var(--ta-ease, ease); }
|
|
1560
|
+
/* A table or a diagram opened in a fold still reaches the edges of the card */
|
|
1561
|
+
.tag-folded-body > :is(div, .ta-markdown):has(> .tag-table, > .ta-mermaid) { margin: 0 calc(-1 * var(--tag-x)) -12px; }
|
|
1562
|
+
.tag-folded-body .tag-table { border-top: 1px solid var(--tag-line); }
|
|
1563
|
+
.tag-more { margin-top: 4px; }
|
|
1564
|
+
.tag-table + .tag-more { padding: 4px var(--tag-x) 6px; border-top: 1px solid var(--tag-line); margin-top: 0; }
|
|
1124
1565
|
.tag-details-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: calc(24px * var(--tag-s)); margin-left: -4px; padding: 0 6px 0 4px; border: 0; border-radius: 6px; background: none; color: var(--ta-muted); font-size: var(--tag-small); cursor: pointer; transition: color 120ms, background 120ms; }
|
|
1125
1566
|
.tag-details-toggle svg { width: calc(14px * var(--tag-s)); height: calc(14px * var(--tag-s)); transition: transform 150ms var(--ta-ease, ease); }
|
|
1126
1567
|
.tag-details-toggle[aria-expanded='true'] svg { transform: rotate(90deg); }
|
|
@@ -1155,8 +1596,13 @@ function activate(pi) {
|
|
|
1155
1596
|
}
|
|
1156
1597
|
const removeStyle = injectStyle();
|
|
1157
1598
|
const card = glanceCard(pi);
|
|
1599
|
+
const spoken = (code) => {
|
|
1600
|
+
const words = GlanceWords.of(pi.ui.language);
|
|
1601
|
+
const glance = GlanceSpec.read(GlanceJson.parse(code, false), false, words);
|
|
1602
|
+
return glance && GlanceSpeech.of(glance, words);
|
|
1603
|
+
};
|
|
1158
1604
|
for (const language of [LANGUAGE, ...ALIASES]) {
|
|
1159
|
-
pi.registerCodeRenderer(language, card);
|
|
1605
|
+
pi.registerCodeRenderer(language, card, { spoken });
|
|
1160
1606
|
}
|
|
1161
1607
|
return removeStyle;
|
|
1162
1608
|
}
|