@celljs/ta-relay 4.10.0 → 4.11.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 +13 -1
- package/README.md +13 -1
- package/esm/common/index.d.ts +9 -0
- package/esm/common/index.js +9 -0
- package/esm/common/relay-blobs.d.ts +54 -0
- package/esm/common/relay-blobs.js +153 -0
- package/esm/common/relay-card.d.ts +23 -0
- package/esm/common/relay-card.js +30 -0
- package/esm/common/relay-content.d.ts +104 -0
- package/esm/common/relay-content.js +316 -0
- package/esm/common/relay-conversation.d.ts +59 -0
- package/esm/common/relay-conversation.js +9 -0
- package/esm/common/relay-hub-util.d.ts +91 -0
- package/esm/common/relay-hub-util.js +164 -0
- package/esm/common/relay-hub.d.ts +125 -0
- package/esm/common/relay-hub.js +438 -0
- package/esm/common/relay-hubs.d.ts +271 -0
- package/esm/common/relay-hubs.js +844 -0
- package/esm/common/relay-identity.d.ts +46 -0
- package/esm/common/relay-identity.js +126 -0
- package/esm/common/relay-protocol.d.ts +211 -2
- package/esm/common/relay-protocol.js +53 -0
- package/esm/common/relay-room-chat.d.ts +80 -0
- package/esm/common/relay-room-chat.js +152 -0
- package/esm/common/relay-socket.d.ts +8 -0
- package/esm/common/relay-socket.js +23 -2
- package/esm/guest/guest-i18n.d.ts +47 -0
- package/esm/guest/guest-i18n.js +97 -0
- package/esm/guest/guest-style.d.ts +1 -0
- package/esm/guest/guest-style.js +78 -0
- package/esm/guest/guest.d.ts +1 -0
- package/esm/guest/guest.js +371 -0
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/node/relay-host.d.ts +25 -3
- package/esm/node/relay-host.js +115 -4
- package/esm/node/relay-hub-files.d.ts +12 -0
- package/esm/node/relay-hub-files.js +39 -0
- package/esm/node/relay-server.d.ts +46 -1
- package/esm/node/relay-server.js +227 -1
- package/esm/node/relay-store.d.ts +72 -0
- package/esm/node/relay-store.js +123 -2
- package/esm/node/relay-viewer.d.ts +7 -0
- package/esm/node/relay-viewer.js +33 -0
- package/esm/viewer/viewer-i18n.d.ts +56 -0
- package/esm/viewer/viewer-i18n.js +117 -0
- package/esm/viewer/viewer-markdown.d.ts +7 -0
- package/esm/viewer/viewer-markdown.js +198 -0
- package/esm/viewer/viewer-style.d.ts +1 -0
- package/esm/viewer/viewer-style.js +72 -0
- package/esm/viewer/viewer.d.ts +8 -0
- package/esm/viewer/viewer.js +378 -0
- package/lib/common/index.d.ts +9 -0
- package/lib/common/index.js +9 -0
- package/lib/common/relay-blobs.d.ts +55 -0
- package/lib/common/relay-blobs.js +157 -0
- package/lib/common/relay-card.d.ts +24 -0
- package/lib/common/relay-card.js +33 -0
- package/lib/common/relay-content.d.ts +105 -0
- package/lib/common/relay-content.js +320 -0
- package/lib/common/relay-conversation.d.ts +60 -0
- package/lib/common/relay-conversation.js +12 -0
- package/lib/common/relay-hub-util.d.ts +92 -0
- package/lib/common/relay-hub-util.js +167 -0
- package/lib/common/relay-hub.d.ts +126 -0
- package/lib/common/relay-hub.js +442 -0
- package/lib/common/relay-hubs.d.ts +272 -0
- package/lib/common/relay-hubs.js +848 -0
- package/lib/common/relay-identity.d.ts +47 -0
- package/lib/common/relay-identity.js +129 -0
- package/lib/common/relay-protocol.d.ts +211 -2
- package/lib/common/relay-protocol.js +54 -1
- package/lib/common/relay-room-chat.d.ts +81 -0
- package/lib/common/relay-room-chat.js +156 -0
- package/lib/common/relay-socket.d.ts +8 -0
- package/lib/common/relay-socket.js +23 -2
- package/lib/guest/guest-i18n.d.ts +48 -0
- package/lib/guest/guest-i18n.js +100 -0
- package/lib/guest/guest-style.d.ts +2 -0
- package/lib/guest/guest-style.js +81 -0
- package/lib/guest/guest.d.ts +2 -0
- package/lib/guest/guest.js +373 -0
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.js +2 -0
- package/lib/node/relay-host.d.ts +25 -3
- package/lib/node/relay-host.js +115 -4
- package/lib/node/relay-hub-files.d.ts +13 -0
- package/lib/node/relay-hub-files.js +43 -0
- package/lib/node/relay-server.d.ts +46 -1
- package/lib/node/relay-server.js +226 -0
- package/lib/node/relay-store.d.ts +72 -0
- package/lib/node/relay-store.js +121 -0
- package/lib/node/relay-viewer.d.ts +8 -0
- package/lib/node/relay-viewer.js +32 -0
- package/lib/viewer/viewer-i18n.d.ts +57 -0
- package/lib/viewer/viewer-i18n.js +120 -0
- package/lib/viewer/viewer-markdown.d.ts +8 -0
- package/lib/viewer/viewer-markdown.js +201 -0
- package/lib/viewer/viewer-style.d.ts +2 -0
- package/lib/viewer/viewer-style.js +75 -0
- package/lib/viewer/viewer.d.ts +9 -0
- package/lib/viewer/viewer.js +381 -0
- package/package.json +5 -4
- package/viewer/frame.html +1 -0
- package/viewer/page.html +80 -0
- package/viewer/room.html +87 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
declare const zh: {
|
|
2
|
+
title: string;
|
|
3
|
+
loading: string;
|
|
4
|
+
conversation: string;
|
|
5
|
+
file: string;
|
|
6
|
+
sharedAt: string;
|
|
7
|
+
messages: string;
|
|
8
|
+
passwordTitle: string;
|
|
9
|
+
passwordHint: string;
|
|
10
|
+
password: string;
|
|
11
|
+
open: string;
|
|
12
|
+
wrong: string;
|
|
13
|
+
busy: string;
|
|
14
|
+
gone: string;
|
|
15
|
+
offline: string;
|
|
16
|
+
self: string;
|
|
17
|
+
people: string;
|
|
18
|
+
invalid: string;
|
|
19
|
+
timeout: string;
|
|
20
|
+
large: string;
|
|
21
|
+
failed: string;
|
|
22
|
+
you: string;
|
|
23
|
+
ta: string;
|
|
24
|
+
outputsOmitted: string;
|
|
25
|
+
imagesOmitted: string;
|
|
26
|
+
redacted: string;
|
|
27
|
+
image: string;
|
|
28
|
+
download: string;
|
|
29
|
+
footer: string;
|
|
30
|
+
agentKind: string;
|
|
31
|
+
agentHint: string;
|
|
32
|
+
copy: string;
|
|
33
|
+
copied: string;
|
|
34
|
+
failedCall: string;
|
|
35
|
+
output: string;
|
|
36
|
+
error: string;
|
|
37
|
+
secure: string;
|
|
38
|
+
run: string;
|
|
39
|
+
read: string;
|
|
40
|
+
write: string;
|
|
41
|
+
edit: string;
|
|
42
|
+
search: string;
|
|
43
|
+
find: string;
|
|
44
|
+
list: string;
|
|
45
|
+
fetch: string;
|
|
46
|
+
webSearch: string;
|
|
47
|
+
script: string;
|
|
48
|
+
use: string;
|
|
49
|
+
};
|
|
50
|
+
export type ViewerText = keyof typeof zh;
|
|
51
|
+
export declare namespace ViewerI18n {
|
|
52
|
+
const chinese: boolean;
|
|
53
|
+
function t(id: ViewerText, values?: Record<string, string | number>): string;
|
|
54
|
+
function date(at: number): string;
|
|
55
|
+
}
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
const zh = {
|
|
2
|
+
title: 'Ta 分享',
|
|
3
|
+
loading: '正在打开…',
|
|
4
|
+
conversation: '对话',
|
|
5
|
+
file: '文件',
|
|
6
|
+
sharedAt: '分享于 {date}',
|
|
7
|
+
messages: '{n} 条消息',
|
|
8
|
+
passwordTitle: '这个分享需要口令',
|
|
9
|
+
passwordHint: '口令不在链接里,请向分享的人要。',
|
|
10
|
+
password: '口令',
|
|
11
|
+
open: '打开',
|
|
12
|
+
wrong: '口令不对,再试一次。',
|
|
13
|
+
busy: '口令错得太多了,请过几分钟再试。',
|
|
14
|
+
gone: '这个链接已经失效:分享已停止或已过期。',
|
|
15
|
+
offline: '分享的人的电脑现在没有运行 Ta,请稍后再试。',
|
|
16
|
+
self: '这是仅自己可见的分享,只有分享的人能在自己的 Ta 里打开。',
|
|
17
|
+
people: '这条链接只给指定的 Ta 好友:请在你自己的 Ta 应用里扫码或粘贴打开。',
|
|
18
|
+
invalid: '这不是一个完整的 Ta 分享链接,请检查是否复制完整。',
|
|
19
|
+
timeout: '等了太久还没收到,请稍后再试。',
|
|
20
|
+
large: '内容太大,打不开。',
|
|
21
|
+
failed: '打不开这个分享。',
|
|
22
|
+
you: '你',
|
|
23
|
+
ta: 'Ta',
|
|
24
|
+
outputsOmitted: '分享时没有附上工具的输出。',
|
|
25
|
+
imagesOmitted: '分享时去掉了 {n} 张图片。',
|
|
26
|
+
redacted: '分享时隐去了 {n} 处疑似密钥。',
|
|
27
|
+
image: '[图片]',
|
|
28
|
+
download: '下载 {name}',
|
|
29
|
+
footer: '在 Ta 应用里扫码或粘贴这个链接,可以把它导入为你自己的对话接着聊。',
|
|
30
|
+
agentKind: '智能体名片',
|
|
31
|
+
agentHint: '在 Ta 里扫码或粘贴这个链接,就能把它加为你的智能体;加进来时,它会先看看你的项目,把职责调整得贴合你那边的情况。',
|
|
32
|
+
copy: '复制链接',
|
|
33
|
+
copied: '已复制',
|
|
34
|
+
failedCall: '失败',
|
|
35
|
+
output: '输出',
|
|
36
|
+
error: '出错了',
|
|
37
|
+
secure: '端到端加密:中继看不到内容',
|
|
38
|
+
run: '运行',
|
|
39
|
+
read: '读取',
|
|
40
|
+
write: '写入',
|
|
41
|
+
edit: '编辑',
|
|
42
|
+
search: '搜索',
|
|
43
|
+
find: '查找',
|
|
44
|
+
list: '列出',
|
|
45
|
+
fetch: '打开网页',
|
|
46
|
+
webSearch: '搜索网页',
|
|
47
|
+
script: '运行脚本',
|
|
48
|
+
use: '使用 {name}',
|
|
49
|
+
};
|
|
50
|
+
const en = {
|
|
51
|
+
title: 'Shared from Ta',
|
|
52
|
+
loading: 'Opening…',
|
|
53
|
+
conversation: 'Conversation',
|
|
54
|
+
file: 'File',
|
|
55
|
+
sharedAt: 'Shared {date}',
|
|
56
|
+
messages: '{n} messages',
|
|
57
|
+
passwordTitle: 'This share needs a password',
|
|
58
|
+
passwordHint: 'The password is not in the link: ask the one who shared it.',
|
|
59
|
+
password: 'Password',
|
|
60
|
+
open: 'Open',
|
|
61
|
+
wrong: 'That password is wrong. Try again.',
|
|
62
|
+
busy: 'Too many wrong passwords. Try again in a few minutes.',
|
|
63
|
+
gone: 'This link no longer works: the share was stopped or ran out.',
|
|
64
|
+
offline: 'The computer that shared it is not running Ta now. Try again later.',
|
|
65
|
+
self: 'Only the one who shared this opens it, in their own Ta.',
|
|
66
|
+
people: 'This link is for chosen Ta friends only: scan or paste it in your own Ta app to open it.',
|
|
67
|
+
invalid: 'This is not a whole link of Ta: check that it was copied in full.',
|
|
68
|
+
timeout: 'It took too long to come. Try again later.',
|
|
69
|
+
large: 'It is too large to open.',
|
|
70
|
+
failed: 'This share cannot be opened.',
|
|
71
|
+
you: 'You',
|
|
72
|
+
ta: 'Ta',
|
|
73
|
+
outputsOmitted: 'The outputs of the tools were not shared.',
|
|
74
|
+
imagesOmitted: '{n} images were left out when it was shared.',
|
|
75
|
+
redacted: '{n} things that looked like secrets were taken out.',
|
|
76
|
+
image: '[image]',
|
|
77
|
+
download: 'Download {name}',
|
|
78
|
+
footer: 'Scan or paste this link in the Ta app to import it as a conversation of your own and go on.',
|
|
79
|
+
agentKind: "An agent's card",
|
|
80
|
+
agentHint: 'Scan or paste this link in Ta to add it as an agent of yours: as it joins, it looks at your project first and fits its role to it.',
|
|
81
|
+
copy: 'Copy link',
|
|
82
|
+
copied: 'Copied',
|
|
83
|
+
failedCall: 'failed',
|
|
84
|
+
output: 'Output',
|
|
85
|
+
error: 'Error',
|
|
86
|
+
secure: 'End-to-end encrypted: the relay cannot read it',
|
|
87
|
+
run: 'Run',
|
|
88
|
+
read: 'Read',
|
|
89
|
+
write: 'Write',
|
|
90
|
+
edit: 'Edit',
|
|
91
|
+
search: 'Search',
|
|
92
|
+
find: 'Find',
|
|
93
|
+
list: 'List',
|
|
94
|
+
fetch: 'Open',
|
|
95
|
+
webSearch: 'Search the web',
|
|
96
|
+
script: 'Run a script',
|
|
97
|
+
use: 'Use {name}',
|
|
98
|
+
};
|
|
99
|
+
export var ViewerI18n;
|
|
100
|
+
(function (ViewerI18n) {
|
|
101
|
+
ViewerI18n.chinese = typeof navigator !== 'undefined' && /^zh\b/i.test(navigator.language);
|
|
102
|
+
function t(id, values = {}) {
|
|
103
|
+
return (ViewerI18n.chinese ? zh : en)[id].replace(/\{(\w+)\}/g, (_, name) => { var _a; return String((_a = values[name]) !== null && _a !== void 0 ? _a : ''); });
|
|
104
|
+
}
|
|
105
|
+
ViewerI18n.t = t;
|
|
106
|
+
function date(at) {
|
|
107
|
+
return new Date(at).toLocaleString(ViewerI18n.chinese ? 'zh-CN' : undefined, {
|
|
108
|
+
year: 'numeric',
|
|
109
|
+
month: 'short',
|
|
110
|
+
day: 'numeric',
|
|
111
|
+
hour: '2-digit',
|
|
112
|
+
minute: '2-digit',
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
ViewerI18n.date = date;
|
|
116
|
+
})(ViewerI18n || (ViewerI18n = {}));
|
|
117
|
+
//# sourceMappingURL=viewer-i18n.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Markdown of a reply, drawn as DOM: what it says is only ever text of nodes, never HTML, and links go only to the web. */
|
|
2
|
+
export declare namespace ViewerMarkdown {
|
|
3
|
+
function render(text: string): DocumentFragment;
|
|
4
|
+
/** Code, links, bold, italic and struck text of a line, into `parent`. */
|
|
5
|
+
function inline(parent: HTMLElement, text: string): HTMLElement;
|
|
6
|
+
function el(tag: string, text?: string): HTMLElement;
|
|
7
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/** Markdown of a reply, drawn as DOM: what it says is only ever text of nodes, never HTML, and links go only to the web. */
|
|
2
|
+
export var ViewerMarkdown;
|
|
3
|
+
(function (ViewerMarkdown) {
|
|
4
|
+
function render(text) {
|
|
5
|
+
const fragment = document.createDocumentFragment();
|
|
6
|
+
const lines = text.replace(/\r\n?/g, '\n').split('\n');
|
|
7
|
+
let index = 0;
|
|
8
|
+
while (index < lines.length) {
|
|
9
|
+
const line = lines[index];
|
|
10
|
+
const fence = /^(\s*)(`{3,}|~{3,})\s*([\w+-]*)/.exec(line);
|
|
11
|
+
if (fence) {
|
|
12
|
+
const body = [];
|
|
13
|
+
index++;
|
|
14
|
+
while (index < lines.length && !lines[index].trimStart().startsWith(fence[2])) {
|
|
15
|
+
body.push(lines[index]);
|
|
16
|
+
index++;
|
|
17
|
+
}
|
|
18
|
+
index++;
|
|
19
|
+
const pre = el('pre');
|
|
20
|
+
const code = el('code', body.join('\n'));
|
|
21
|
+
if (fence[3]) {
|
|
22
|
+
code.dataset.lang = fence[3];
|
|
23
|
+
}
|
|
24
|
+
pre.append(code);
|
|
25
|
+
fragment.append(pre);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (!line.trim()) {
|
|
29
|
+
index++;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const heading = /^(#{1,6})\s+(.*)$/.exec(line);
|
|
33
|
+
if (heading) {
|
|
34
|
+
fragment.append(inline(el(`h${Math.min(heading[1].length + 1, 6)}`), heading[2].replace(/\s+#+\s*$/, '')));
|
|
35
|
+
index++;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(line)) {
|
|
39
|
+
fragment.append(el('hr'));
|
|
40
|
+
index++;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (/^\s*>/.test(line)) {
|
|
44
|
+
const quoted = [];
|
|
45
|
+
while (index < lines.length && /^\s*>/.test(lines[index])) {
|
|
46
|
+
quoted.push(lines[index].replace(/^\s*>\s?/, ''));
|
|
47
|
+
index++;
|
|
48
|
+
}
|
|
49
|
+
const quote = el('blockquote');
|
|
50
|
+
quote.append(render(quoted.join('\n')));
|
|
51
|
+
fragment.append(quote);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (isTableStart(lines, index)) {
|
|
55
|
+
const rows = [];
|
|
56
|
+
rows.push(cells(lines[index]));
|
|
57
|
+
index += 2;
|
|
58
|
+
while (index < lines.length && lines[index].includes('|') && lines[index].trim()) {
|
|
59
|
+
rows.push(cells(lines[index]));
|
|
60
|
+
index++;
|
|
61
|
+
}
|
|
62
|
+
fragment.append(table(rows));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const item = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/.exec(line);
|
|
66
|
+
if (item) {
|
|
67
|
+
const ordered = /\d/.test(item[2]);
|
|
68
|
+
const list = el(ordered ? 'ol' : 'ul');
|
|
69
|
+
while (index < lines.length) {
|
|
70
|
+
const match = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/.exec(lines[index]);
|
|
71
|
+
if (!match || /\d/.test(match[2]) !== ordered) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
const body = [match[3]];
|
|
75
|
+
index++;
|
|
76
|
+
// Its own lines, indented under it: more of it, or a nested list.
|
|
77
|
+
const nested = [];
|
|
78
|
+
while (index < lines.length && lines[index].trim() && lines[index].length - lines[index].trimStart().length > match[1].length) {
|
|
79
|
+
nested.push(lines[index].slice(Math.min(match[1].length + 2, lines[index].length - lines[index].trimStart().length)));
|
|
80
|
+
index++;
|
|
81
|
+
}
|
|
82
|
+
const li = el('li');
|
|
83
|
+
const task = /^\[([ xX])\]\s+(.*)$/.exec(body[0]);
|
|
84
|
+
if (task) {
|
|
85
|
+
const box = el('input');
|
|
86
|
+
box.type = 'checkbox';
|
|
87
|
+
box.disabled = true;
|
|
88
|
+
box.checked = task[1] !== ' ';
|
|
89
|
+
li.append(box, ' ');
|
|
90
|
+
body[0] = task[2];
|
|
91
|
+
}
|
|
92
|
+
inline(li, body.join(' '));
|
|
93
|
+
if (nested.length) {
|
|
94
|
+
li.append(render(nested.join('\n')));
|
|
95
|
+
}
|
|
96
|
+
list.append(li);
|
|
97
|
+
}
|
|
98
|
+
fragment.append(list);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const paragraph = [];
|
|
102
|
+
while (index < lines.length &&
|
|
103
|
+
lines[index].trim() &&
|
|
104
|
+
!/^(\s*)(`{3,}|~{3,})/.test(lines[index]) &&
|
|
105
|
+
!/^#{1,6}\s/.test(lines[index]) &&
|
|
106
|
+
!/^\s*>/.test(lines[index]) &&
|
|
107
|
+
!/^(\s*)([-*+]|\d+[.)])\s+/.test(lines[index]) &&
|
|
108
|
+
!isTableStart(lines, index)) {
|
|
109
|
+
paragraph.push(lines[index]);
|
|
110
|
+
index++;
|
|
111
|
+
}
|
|
112
|
+
const p = el('p');
|
|
113
|
+
paragraph.forEach((part, at) => {
|
|
114
|
+
if (at > 0) {
|
|
115
|
+
p.append(/ {2}$|\\$/.test(paragraph[at - 1]) ? el('br') : ' ');
|
|
116
|
+
}
|
|
117
|
+
inline(p, part.replace(/ {2}$|\\$/, ''));
|
|
118
|
+
});
|
|
119
|
+
fragment.append(p);
|
|
120
|
+
}
|
|
121
|
+
return fragment;
|
|
122
|
+
}
|
|
123
|
+
ViewerMarkdown.render = render;
|
|
124
|
+
/** Code, links, bold, italic and struck text of a line, into `parent`. */
|
|
125
|
+
function inline(parent, text) {
|
|
126
|
+
var _a, _b, _c;
|
|
127
|
+
const pattern = /(`+)([^`]|[^`][\s\S]*?[^`])\1|!?\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?'"])|\*\*([^*]+)\*\*|__([^_]+)__|~~([^~]+)~~|\*([^*\s][^*]*)\*|(?<![\w])_([^_\s][^_]*)_(?![\w])/g;
|
|
128
|
+
let at = 0;
|
|
129
|
+
for (const match of text.matchAll(pattern)) {
|
|
130
|
+
parent.append(text.slice(at, match.index));
|
|
131
|
+
at = ((_a = match.index) !== null && _a !== void 0 ? _a : 0) + match[0].length;
|
|
132
|
+
if (match[1]) {
|
|
133
|
+
parent.append(el('code', match[2]));
|
|
134
|
+
}
|
|
135
|
+
else if (match[4] !== undefined) {
|
|
136
|
+
parent.append(link(match[3] || match[4], match[4]));
|
|
137
|
+
}
|
|
138
|
+
else if (match[5]) {
|
|
139
|
+
parent.append(link(match[5], match[5]));
|
|
140
|
+
}
|
|
141
|
+
else if (match[6] || match[7]) {
|
|
142
|
+
parent.append(inline(el('strong'), (_b = match[6]) !== null && _b !== void 0 ? _b : match[7]));
|
|
143
|
+
}
|
|
144
|
+
else if (match[8]) {
|
|
145
|
+
parent.append(inline(el('del'), match[8]));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
parent.append(inline(el('em'), (_c = match[9]) !== null && _c !== void 0 ? _c : match[10]));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
parent.append(text.slice(at));
|
|
152
|
+
return parent;
|
|
153
|
+
}
|
|
154
|
+
ViewerMarkdown.inline = inline;
|
|
155
|
+
function link(text, href) {
|
|
156
|
+
if (!/^https?:\/\//i.test(href)) {
|
|
157
|
+
return document.createTextNode(text);
|
|
158
|
+
}
|
|
159
|
+
const a = el('a', text);
|
|
160
|
+
a.href = href;
|
|
161
|
+
a.target = '_blank';
|
|
162
|
+
a.rel = 'noopener noreferrer nofollow';
|
|
163
|
+
return a;
|
|
164
|
+
}
|
|
165
|
+
function isTableStart(lines, index) {
|
|
166
|
+
return lines[index].includes('|') && index + 1 < lines.length && /^\s*\|?\s*:?-{2,}:?\s*(\|\s*:?-{2,}:?\s*)*\|?\s*$/.test(lines[index + 1]);
|
|
167
|
+
}
|
|
168
|
+
function cells(line) {
|
|
169
|
+
return line
|
|
170
|
+
.trim()
|
|
171
|
+
.replace(/^\||\|$/g, '')
|
|
172
|
+
.split(/(?<!\\)\|/)
|
|
173
|
+
.map(cell => cell.trim().replace(/\\\|/g, '|'));
|
|
174
|
+
}
|
|
175
|
+
function table(rows) {
|
|
176
|
+
const wrap = el('div');
|
|
177
|
+
wrap.className = 'table';
|
|
178
|
+
const tableEl = el('table');
|
|
179
|
+
rows.forEach((row, at) => {
|
|
180
|
+
const tr = el('tr');
|
|
181
|
+
for (const cell of row) {
|
|
182
|
+
tr.append(inline(el(at === 0 ? 'th' : 'td'), cell));
|
|
183
|
+
}
|
|
184
|
+
tableEl.append(tr);
|
|
185
|
+
});
|
|
186
|
+
wrap.append(tableEl);
|
|
187
|
+
return wrap;
|
|
188
|
+
}
|
|
189
|
+
function el(tag, text) {
|
|
190
|
+
const node = document.createElement(tag);
|
|
191
|
+
if (text !== undefined) {
|
|
192
|
+
node.textContent = text;
|
|
193
|
+
}
|
|
194
|
+
return node;
|
|
195
|
+
}
|
|
196
|
+
ViewerMarkdown.el = el;
|
|
197
|
+
})(ViewerMarkdown || (ViewerMarkdown = {}));
|
|
198
|
+
//# sourceMappingURL=viewer-markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VIEWER_STYLE = "\n:root{color-scheme:light dark;--bg:#fff;--fg:#1f1f1f;--muted:#737373;--faint:#a3a3a3;--line:#ececec;--soft:#f5f5f5;--bubble:#f2f2f2;--code:#f6f6f6;--accent:#16a34a;--warn:#d97706;--radius:14px}\n@media (prefers-color-scheme:dark){:root{--bg:#191919;--fg:#ececec;--muted:#a3a3a3;--faint:#6b6b6b;--line:#2c2c2c;--soft:#222;--bubble:#2a2a2a;--code:#232323;--accent:#4ade80;--warn:#fbbf24}}\n*{box-sizing:border-box}\nhtml,body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.65 -apple-system,BlinkMacSystemFont,\"Segoe UI\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft YaHei\",sans-serif;-webkit-font-smoothing:antialiased}\n.top{position:sticky;top:0;z-index:2;display:flex;align-items:center;gap:10px;padding:10px 16px;background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:saturate(1.6) blur(12px);-webkit-backdrop-filter:saturate(1.6) blur(12px);border-bottom:1px solid var(--line)}\n.logo{width:26px;height:26px;border-radius:8px;background:var(--fg);color:var(--bg);display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}\n.top .name{font-weight:600;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0}\n.top button{flex:none}\nmain{max-width:760px;margin:0 auto;padding:28px 18px 40px}\nmain.wide{max-width:none;padding:0}\nh1.title{font-size:22px;line-height:1.35;margin:0 0 6px;letter-spacing:-.01em;word-break:break-word}\n.meta{color:var(--muted);font-size:13px;margin:0 0 22px;display:flex;flex-wrap:wrap;gap:4px 12px}\n.notes{color:var(--muted);font-size:12.5px;margin:-10px 0 22px;display:flex;flex-direction:column;gap:2px}\n.msg{margin:0 0 18px}\n.msg.user{display:flex;justify-content:flex-end}\n.msg.user .bubble{background:var(--bubble);border-radius:var(--radius) var(--radius) 4px var(--radius);padding:9px 14px;max-width:85%;white-space:pre-wrap;word-break:break-word}\n.msg.ta .text>:first-child{margin-top:0}.msg.ta .text>:last-child{margin-bottom:0}\n.text{word-break:break-word}\n.text p{margin:0 0 .75em}\n.text h2,.text h3,.text h4,.text h5,.text h6{margin:1.2em 0 .5em;line-height:1.35}\n.text h2{font-size:1.25em}.text h3{font-size:1.1em}.text h4,.text h5,.text h6{font-size:1em}\n.text ul,.text ol{margin:0 0 .75em;padding-left:1.4em}.text li{margin:.2em 0}\n.text blockquote{margin:0 0 .75em;padding:2px 0 2px 12px;border-left:3px solid var(--line);color:var(--muted)}\n.text a{color:inherit;text-decoration:underline;text-decoration-color:var(--faint);text-underline-offset:2px}\n.text code{font:12.5px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:var(--code);padding:1px 5px;border-radius:5px}\n.text pre{background:var(--code);border-radius:10px;padding:12px 14px;overflow:auto;margin:0 0 .85em}\n.text pre code{background:none;padding:0;font-size:12.5px;white-space:pre}\n.text hr{border:0;border-top:1px solid var(--line);margin:1.2em 0}\n.text .table{overflow:auto;margin:0 0 .85em}\n.text table{border-collapse:collapse;font-size:14px}\n.text th,.text td{border:1px solid var(--line);padding:5px 10px;text-align:left;vertical-align:top}\n.text th{background:var(--soft);font-weight:600}\n.tools{margin:4px 0 10px;display:flex;flex-direction:column;gap:1px}\n.tool{display:flex;align-items:baseline;gap:8px;color:var(--muted);font-size:13.5px;min-width:0;padding:2px 0}\n.tool .dot{width:6px;height:6px;border-radius:50%;background:var(--accent);flex:none;transform:translateY(-2px)}\n.tool.failed .dot{background:var(--faint)}\n.tool .verb{flex:none}\n.tool .target{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--fg);opacity:.8}\n.tool .target.code{font:12.5px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}\ndetails.out{margin:0 0 6px 14px}\ndetails.out summary{cursor:pointer;color:var(--faint);font-size:12.5px;list-style:none}\ndetails.out summary::-webkit-details-marker{display:none}\ndetails.out pre{margin:6px 0 0;background:var(--code);border-radius:8px;padding:10px 12px;max-height:280px;overflow:auto;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;word-break:break-word}\n.err{color:var(--warn);font-size:13.5px}\n.card{max-width:380px;margin:12vh auto 0;padding:28px 24px;border:1px solid var(--line);border-radius:18px;text-align:center}\n.card h2{font-size:17px;margin:12px 0 6px}\n.card p{color:var(--muted);font-size:13.5px;margin:0 0 16px}\n.card .icon{width:44px;height:44px;border-radius:50%;background:var(--soft);color:var(--muted);display:grid;place-items:center;margin:0 auto}\n.card form{display:flex;gap:8px}\n.card input{flex:1;min-width:0;font:inherit;padding:9px 12px;border-radius:10px;border:1px solid var(--line);background:var(--bg);color:var(--fg);outline:none}\n.card input:focus{border-color:var(--muted)}\n.card .error{color:var(--warn);font-size:13px;margin:10px 0 0;min-height:1em}\nbutton{font:inherit;font-size:13.5px;padding:8px 14px;border-radius:10px;border:1px solid var(--line);background:var(--bg);color:var(--fg);cursor:pointer}\nbutton.primary{background:var(--fg);color:var(--bg);border-color:var(--fg)}\nbutton:disabled{opacity:.5;cursor:default}\n.spin{width:22px;height:22px;border:2px solid var(--line);border-top-color:var(--muted);border-radius:50%;margin:0 auto;animation:spin .8s linear infinite}\n@keyframes spin{to{transform:rotate(360deg)}}\n@media (prefers-reduced-motion:reduce){.spin{animation-duration:3s}}\n.agent-head{display:flex;flex-direction:column;align-items:center;text-align:center;gap:4px;margin:8px 0 22px}\n.agent-face{width:64px;height:64px;border-radius:50%;background:var(--soft);color:#fff;display:grid;place-items:center;font-size:24px;font-weight:700;margin-bottom:8px;box-shadow:0 0 0 1px var(--line)}\n.agent-head h1.title{margin:0}.agent-head .meta{margin:0;justify-content:center}\n.agent-role{border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;background:var(--soft)}\n.agent-role>:first-child{margin-top:0}.agent-role>:last-child{margin-bottom:0}\n.agent .notes{margin:10px 0 0}\n.agent-hint{color:var(--muted);font-size:13.5px;text-align:center;margin:18px 0 0}\n.foot{max-width:760px;margin:0 auto;padding:18px 18px 40px;color:var(--faint);font-size:12.5px;border-top:1px solid var(--line);display:flex;flex-direction:column;gap:4px}\n.page{display:block;width:100%;height:calc(100vh - 48px);height:calc(100dvh - 48px);border:0;background:#fff}\n.file img{max-width:100%;border-radius:10px;display:block;margin:0 auto}\n.file pre{white-space:pre-wrap;word-break:break-word;background:var(--code);border-radius:10px;padding:14px;font:12.5px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace}\n";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const VIEWER_STYLE = `
|
|
2
|
+
:root{color-scheme:light dark;--bg:#fff;--fg:#1f1f1f;--muted:#737373;--faint:#a3a3a3;--line:#ececec;--soft:#f5f5f5;--bubble:#f2f2f2;--code:#f6f6f6;--accent:#16a34a;--warn:#d97706;--radius:14px}
|
|
3
|
+
@media (prefers-color-scheme:dark){:root{--bg:#191919;--fg:#ececec;--muted:#a3a3a3;--faint:#6b6b6b;--line:#2c2c2c;--soft:#222;--bubble:#2a2a2a;--code:#232323;--accent:#4ade80;--warn:#fbbf24}}
|
|
4
|
+
*{box-sizing:border-box}
|
|
5
|
+
html,body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.65 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;-webkit-font-smoothing:antialiased}
|
|
6
|
+
.top{position:sticky;top:0;z-index:2;display:flex;align-items:center;gap:10px;padding:10px 16px;background:color-mix(in srgb,var(--bg) 88%,transparent);backdrop-filter:saturate(1.6) blur(12px);-webkit-backdrop-filter:saturate(1.6) blur(12px);border-bottom:1px solid var(--line)}
|
|
7
|
+
.logo{width:26px;height:26px;border-radius:8px;background:var(--fg);color:var(--bg);display:grid;place-items:center;font-weight:700;font-size:13px;flex:none}
|
|
8
|
+
.top .name{font-weight:600;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0}
|
|
9
|
+
.top button{flex:none}
|
|
10
|
+
main{max-width:760px;margin:0 auto;padding:28px 18px 40px}
|
|
11
|
+
main.wide{max-width:none;padding:0}
|
|
12
|
+
h1.title{font-size:22px;line-height:1.35;margin:0 0 6px;letter-spacing:-.01em;word-break:break-word}
|
|
13
|
+
.meta{color:var(--muted);font-size:13px;margin:0 0 22px;display:flex;flex-wrap:wrap;gap:4px 12px}
|
|
14
|
+
.notes{color:var(--muted);font-size:12.5px;margin:-10px 0 22px;display:flex;flex-direction:column;gap:2px}
|
|
15
|
+
.msg{margin:0 0 18px}
|
|
16
|
+
.msg.user{display:flex;justify-content:flex-end}
|
|
17
|
+
.msg.user .bubble{background:var(--bubble);border-radius:var(--radius) var(--radius) 4px var(--radius);padding:9px 14px;max-width:85%;white-space:pre-wrap;word-break:break-word}
|
|
18
|
+
.msg.ta .text>:first-child{margin-top:0}.msg.ta .text>:last-child{margin-bottom:0}
|
|
19
|
+
.text{word-break:break-word}
|
|
20
|
+
.text p{margin:0 0 .75em}
|
|
21
|
+
.text h2,.text h3,.text h4,.text h5,.text h6{margin:1.2em 0 .5em;line-height:1.35}
|
|
22
|
+
.text h2{font-size:1.25em}.text h3{font-size:1.1em}.text h4,.text h5,.text h6{font-size:1em}
|
|
23
|
+
.text ul,.text ol{margin:0 0 .75em;padding-left:1.4em}.text li{margin:.2em 0}
|
|
24
|
+
.text blockquote{margin:0 0 .75em;padding:2px 0 2px 12px;border-left:3px solid var(--line);color:var(--muted)}
|
|
25
|
+
.text a{color:inherit;text-decoration:underline;text-decoration-color:var(--faint);text-underline-offset:2px}
|
|
26
|
+
.text code{font:12.5px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:var(--code);padding:1px 5px;border-radius:5px}
|
|
27
|
+
.text pre{background:var(--code);border-radius:10px;padding:12px 14px;overflow:auto;margin:0 0 .85em}
|
|
28
|
+
.text pre code{background:none;padding:0;font-size:12.5px;white-space:pre}
|
|
29
|
+
.text hr{border:0;border-top:1px solid var(--line);margin:1.2em 0}
|
|
30
|
+
.text .table{overflow:auto;margin:0 0 .85em}
|
|
31
|
+
.text table{border-collapse:collapse;font-size:14px}
|
|
32
|
+
.text th,.text td{border:1px solid var(--line);padding:5px 10px;text-align:left;vertical-align:top}
|
|
33
|
+
.text th{background:var(--soft);font-weight:600}
|
|
34
|
+
.tools{margin:4px 0 10px;display:flex;flex-direction:column;gap:1px}
|
|
35
|
+
.tool{display:flex;align-items:baseline;gap:8px;color:var(--muted);font-size:13.5px;min-width:0;padding:2px 0}
|
|
36
|
+
.tool .dot{width:6px;height:6px;border-radius:50%;background:var(--accent);flex:none;transform:translateY(-2px)}
|
|
37
|
+
.tool.failed .dot{background:var(--faint)}
|
|
38
|
+
.tool .verb{flex:none}
|
|
39
|
+
.tool .target{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--fg);opacity:.8}
|
|
40
|
+
.tool .target.code{font:12.5px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
41
|
+
details.out{margin:0 0 6px 14px}
|
|
42
|
+
details.out summary{cursor:pointer;color:var(--faint);font-size:12.5px;list-style:none}
|
|
43
|
+
details.out summary::-webkit-details-marker{display:none}
|
|
44
|
+
details.out pre{margin:6px 0 0;background:var(--code);border-radius:8px;padding:10px 12px;max-height:280px;overflow:auto;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre-wrap;word-break:break-word}
|
|
45
|
+
.err{color:var(--warn);font-size:13.5px}
|
|
46
|
+
.card{max-width:380px;margin:12vh auto 0;padding:28px 24px;border:1px solid var(--line);border-radius:18px;text-align:center}
|
|
47
|
+
.card h2{font-size:17px;margin:12px 0 6px}
|
|
48
|
+
.card p{color:var(--muted);font-size:13.5px;margin:0 0 16px}
|
|
49
|
+
.card .icon{width:44px;height:44px;border-radius:50%;background:var(--soft);color:var(--muted);display:grid;place-items:center;margin:0 auto}
|
|
50
|
+
.card form{display:flex;gap:8px}
|
|
51
|
+
.card input{flex:1;min-width:0;font:inherit;padding:9px 12px;border-radius:10px;border:1px solid var(--line);background:var(--bg);color:var(--fg);outline:none}
|
|
52
|
+
.card input:focus{border-color:var(--muted)}
|
|
53
|
+
.card .error{color:var(--warn);font-size:13px;margin:10px 0 0;min-height:1em}
|
|
54
|
+
button{font:inherit;font-size:13.5px;padding:8px 14px;border-radius:10px;border:1px solid var(--line);background:var(--bg);color:var(--fg);cursor:pointer}
|
|
55
|
+
button.primary{background:var(--fg);color:var(--bg);border-color:var(--fg)}
|
|
56
|
+
button:disabled{opacity:.5;cursor:default}
|
|
57
|
+
.spin{width:22px;height:22px;border:2px solid var(--line);border-top-color:var(--muted);border-radius:50%;margin:0 auto;animation:spin .8s linear infinite}
|
|
58
|
+
@keyframes spin{to{transform:rotate(360deg)}}
|
|
59
|
+
@media (prefers-reduced-motion:reduce){.spin{animation-duration:3s}}
|
|
60
|
+
.agent-head{display:flex;flex-direction:column;align-items:center;text-align:center;gap:4px;margin:8px 0 22px}
|
|
61
|
+
.agent-face{width:64px;height:64px;border-radius:50%;background:var(--soft);color:#fff;display:grid;place-items:center;font-size:24px;font-weight:700;margin-bottom:8px;box-shadow:0 0 0 1px var(--line)}
|
|
62
|
+
.agent-head h1.title{margin:0}.agent-head .meta{margin:0;justify-content:center}
|
|
63
|
+
.agent-role{border:1px solid var(--line);border-radius:var(--radius);padding:14px 16px;background:var(--soft)}
|
|
64
|
+
.agent-role>:first-child{margin-top:0}.agent-role>:last-child{margin-bottom:0}
|
|
65
|
+
.agent .notes{margin:10px 0 0}
|
|
66
|
+
.agent-hint{color:var(--muted);font-size:13.5px;text-align:center;margin:18px 0 0}
|
|
67
|
+
.foot{max-width:760px;margin:0 auto;padding:18px 18px 40px;color:var(--faint);font-size:12.5px;border-top:1px solid var(--line);display:flex;flex-direction:column;gap:4px}
|
|
68
|
+
.page{display:block;width:100%;height:calc(100vh - 48px);height:calc(100dvh - 48px);border:0;background:#fff}
|
|
69
|
+
.file img{max-width:100%;border-radius:10px;display:block;margin:0 auto}
|
|
70
|
+
.file pre{white-space:pre-wrap;word-break:break-word;background:var(--code);border-radius:10px;padding:14px;font:12.5px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace}
|
|
71
|
+
`;
|
|
72
|
+
//# sourceMappingURL=viewer-style.js.map
|