@alexsun-top/opencode-chat-room 0.8.2 → 0.8.4
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/CHANGELOG.md +12 -0
- package/README.md +18 -62
- package/README.zh-CN.md +25 -69
- package/dist/cli.js +466 -188
- package/package.json +11 -5
- package/packages/chat-room-channeld/README.md +25 -3
- package/packages/chat-room-channeld/dist/mock-adapter.js +5 -5
- package/packages/chat-room-channeld/src/adapter.ts +5 -0
- package/packages/chat-room-channeld/src/cli.ts +72 -5
- package/packages/chat-room-channeld/src/host.ts +17 -2
- package/packages/chat-room-channeld/src/pg/database.ts +187 -0
- package/packages/chat-room-channeld/src/pg/migrate.ts +150 -0
- package/packages/chat-room-channeld/src/pg/schema.ts +60 -0
- package/packages/chat-room-channeld/src/pg/sql.mjs +175 -0
- package/packages/chat-room-channeld/src/pg/sqlite.ts +100 -0
- package/packages/chat-room-channeld/src/pg/worker.mjs +133 -0
- package/packages/chat-room-channeld/src/protocol.ts +1 -0
- package/packages/chat-room-channeld/src/state.ts +73 -97
- package/packages/chat-room-channeld/src/stats.ts +140 -109
- package/server/assets/base.css +3 -1
- package/server/assets/chat/admin-badge.js +32 -30
- package/server/assets/chat/admin.js +201 -161
- package/server/assets/chat/announcements.js +302 -208
- package/server/assets/chat/attachment-store.js +116 -76
- package/server/assets/chat/attachments.js +701 -441
- package/server/assets/chat/chat-background.js +179 -156
- package/server/assets/chat/clipboard.js +45 -25
- package/server/assets/chat/confirm-dialog.js +38 -35
- package/server/assets/chat/copy-action.js +40 -41
- package/server/assets/chat/create-room-dialog.js +50 -47
- package/server/assets/chat/diagram-viewer.js +293 -236
- package/server/assets/chat/doc-preview.js +516 -443
- package/server/assets/chat/editor.js +446 -336
- package/server/assets/chat/events.js +650 -510
- package/server/assets/chat/files.js +505 -431
- package/server/assets/chat/history-loader.js +81 -73
- package/server/assets/chat/icons.js +9 -11
- package/server/assets/chat/image-zoom.js +246 -179
- package/server/assets/chat/index.js +2 -3
- package/server/assets/chat/install-prompt.js +90 -69
- package/server/assets/chat/integration-account-schema.js +91 -87
- package/server/assets/chat/integration-editor.js +162 -155
- package/server/assets/chat/integration-values.js +116 -101
- package/server/assets/chat/integrations.js +750 -626
- package/server/assets/chat/join-requests.js +415 -358
- package/server/assets/chat/locales/de.js +193 -194
- package/server/assets/chat/locales/es.js +193 -194
- package/server/assets/chat/locales/fr.js +193 -194
- package/server/assets/chat/locales/index.js +1 -2
- package/server/assets/chat/locales/it.js +193 -194
- package/server/assets/chat/locales/ja.js +193 -193
- package/server/assets/chat/locales/ko.js +193 -193
- package/server/assets/chat/markdown-footnotes.js +134 -103
- package/server/assets/chat/markdown.js +557 -404
- package/server/assets/chat/members.js +259 -197
- package/server/assets/chat/mentions.js +181 -133
- package/server/assets/chat/message-cache.js +40 -33
- package/server/assets/chat/message-polling.js +299 -227
- package/server/assets/chat/message-window.js +78 -55
- package/server/assets/chat/messages.js +562 -480
- package/server/assets/chat/office-preview.js +46 -45
- package/server/assets/chat/palette.js +464 -417
- package/server/assets/chat/panels.js +94 -79
- package/server/assets/chat/pwa.js +147 -75
- package/server/assets/chat/questions.js +374 -302
- package/server/assets/chat/recall.js +338 -273
- package/server/assets/chat/receipts.js +151 -121
- package/server/assets/chat/reminders.js +345 -214
- package/server/assets/chat/replies.js +181 -130
- package/server/assets/chat/resource-format.js +59 -62
- package/server/assets/chat/room-list.js +58 -55
- package/server/assets/chat/room-watcher.js +76 -50
- package/server/assets/chat/rooms.js +631 -500
- package/server/assets/chat/search.js +138 -114
- package/server/assets/chat/settings.js +225 -201
- package/server/assets/chat/shiki.js +62 -63
- package/server/assets/chat/shortcuts.js +212 -189
- package/server/assets/chat/side-pane.js +161 -150
- package/server/assets/chat/state.js +860 -737
- package/server/assets/chat/system-events.js +46 -44
- package/server/assets/chat/system-messages.js +57 -56
- package/server/assets/chat/task-form.js +179 -183
- package/server/assets/chat/task-row.js +158 -155
- package/server/assets/chat/tasks.js +665 -587
- package/server/assets/chat/viewport.js +32 -29
- package/server/assets/chat/window-controls.js +32 -32
- package/server/assets/conversation.css +10 -4
- package/server/chat-server.ts +9 -1
- package/server/chat.html +3 -1
- package/server/routes/pages.ts +7 -5
- package/server/sw.js +346 -268
- package/src/web/integration-rules-editor.ts +2 -0
|
@@ -32,9 +32,8 @@ import { initSettings } from "./settings.js";
|
|
|
32
32
|
import { initChatBackground } from "./chat-background.js";
|
|
33
33
|
import { initIntegrations } from "./integrations.js";
|
|
34
34
|
import { initWindowControls } from "./window-controls.js";
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if (isMobileDevice())
|
|
36
|
+
document.documentElement.dataset.mobile = "true";
|
|
38
37
|
initWindowControls();
|
|
39
38
|
initSettings(app);
|
|
40
39
|
initChatBackground(app);
|
|
@@ -1,82 +1,103 @@
|
|
|
1
|
-
// A one-time install recommendation for phones. The browser prompt itself is deferred
|
|
2
|
-
// until the Install button gesture; desktop, standalone, installed, and recent dissent
|
|
3
|
-
// all stay silent. Local storage is optional: blocked storage falls back to this tab.
|
|
4
1
|
const DISMISS_MS = 30 * 24 * 60 * 60 * 1000;
|
|
5
2
|
const DISMISS_KEY = "chat.installDismissedAt";
|
|
6
3
|
const INSTALLED_KEY = "chat.installedApp";
|
|
7
4
|
const memory = new Map();
|
|
8
|
-
|
|
5
|
+
function installPromptEvent(event) {
|
|
6
|
+
return "prompt" in event && typeof event.prompt === "function";
|
|
7
|
+
}
|
|
9
8
|
function read(key) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
try {
|
|
10
|
+
return localStorage.getItem(key);
|
|
11
|
+
}
|
|
12
|
+
catch { /* Try the tab next. */ }
|
|
13
|
+
try {
|
|
14
|
+
return sessionStorage.getItem(key);
|
|
15
|
+
}
|
|
16
|
+
catch { /* Use memory. */ }
|
|
17
|
+
return memory.get(key) ?? null;
|
|
13
18
|
}
|
|
14
|
-
|
|
15
19
|
function write(key, value) {
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
try {
|
|
21
|
+
localStorage.setItem(key, value);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
catch { /* Try the tab next. */ }
|
|
25
|
+
try {
|
|
26
|
+
sessionStorage.setItem(key, value);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
memory.set(key, value);
|
|
30
|
+
}
|
|
18
31
|
}
|
|
19
|
-
|
|
20
32
|
function isIos() {
|
|
21
|
-
|
|
33
|
+
return /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
|
|
22
34
|
}
|
|
23
|
-
|
|
24
35
|
function isStandalone() {
|
|
25
|
-
|
|
36
|
+
return matchMedia("(display-mode: standalone)").matches
|
|
37
|
+
|| navigator.standalone === true;
|
|
26
38
|
}
|
|
27
|
-
|
|
28
39
|
export function initInstallPrompt(app) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
40
|
+
const card = app.$("#installPrompt"), installButton = app.$("#btnInstallApp"), guideButton = app.$("#btnInstallGuide"), guide = app.$("#installGuide"), dismissButton = app.$("#btnDismissInstall");
|
|
41
|
+
const rail = app.$("#railInstall"), railInstall = app.$("#btnRailInstall"), railGuide = app.$("#railInstallGuide");
|
|
42
|
+
if (!card || !installButton || !guideButton || !guide || !dismissButton || !rail || !railInstall || !railGuide)
|
|
43
|
+
return;
|
|
44
|
+
const eligible = () => matchMedia("(max-width: 760px)").matches && window.isSecureContext;
|
|
45
|
+
const suppressed = () => read(INSTALLED_KEY) === "1" || Number(read(DISMISS_KEY) || 0) > Date.now() - DISMISS_MS;
|
|
46
|
+
let deferred = null;
|
|
47
|
+
const hide = () => {
|
|
48
|
+
const fromCard = card.contains(document.activeElement), fromRail = rail.contains(document.activeElement);
|
|
49
|
+
card.hidden = true;
|
|
50
|
+
rail.hidden = true;
|
|
51
|
+
if (fromCard)
|
|
52
|
+
app.$("#inName")?.focus({ preventScroll: true });
|
|
53
|
+
else if (fromRail)
|
|
54
|
+
app.$("#btnSettings")?.focus({ preventScroll: true });
|
|
55
|
+
};
|
|
56
|
+
// The join card explains itself; the room drawer carries the same offer for people
|
|
57
|
+
// who restore straight into a room and never see the join page.
|
|
58
|
+
const render = (mode) => {
|
|
59
|
+
const visible = Boolean(mode) && eligible() && !isStandalone() && !suppressed();
|
|
60
|
+
card.hidden = rail.hidden = !visible;
|
|
61
|
+
if (!visible)
|
|
62
|
+
return;
|
|
63
|
+
installButton.hidden = mode !== "prompt";
|
|
64
|
+
guideButton.hidden = mode !== "ios";
|
|
65
|
+
railInstall.hidden = mode !== "prompt";
|
|
66
|
+
railGuide.hidden = mode !== "ios";
|
|
67
|
+
if (mode !== "ios") {
|
|
68
|
+
guide.hidden = true;
|
|
69
|
+
guideButton.setAttribute("aria-expanded", "false");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
window.addEventListener("beforeinstallprompt", (event) => {
|
|
73
|
+
if (!installPromptEvent(event) || !eligible() || isStandalone() || suppressed())
|
|
74
|
+
return;
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
deferred = event;
|
|
77
|
+
render("prompt");
|
|
78
|
+
});
|
|
79
|
+
window.addEventListener("appinstalled", () => { write(INSTALLED_KEY, "1"); hide(); });
|
|
80
|
+
const promptInstall = async () => {
|
|
81
|
+
const prompt = deferred;
|
|
82
|
+
if (!prompt)
|
|
83
|
+
return;
|
|
84
|
+
deferred = null;
|
|
85
|
+
let accepted = false;
|
|
86
|
+
try {
|
|
87
|
+
accepted = (await prompt.prompt())?.outcome === "accepted";
|
|
88
|
+
}
|
|
89
|
+
catch { /* Count it as declined. */ }
|
|
90
|
+
write(accepted ? INSTALLED_KEY : DISMISS_KEY, accepted ? "1" : String(Date.now()));
|
|
91
|
+
hide();
|
|
92
|
+
};
|
|
93
|
+
installButton.addEventListener("click", promptInstall);
|
|
94
|
+
railInstall.addEventListener("click", promptInstall);
|
|
95
|
+
guideButton.addEventListener("click", () => {
|
|
96
|
+
const open = guide.hidden;
|
|
97
|
+
guide.hidden = !open;
|
|
98
|
+
guideButton.setAttribute("aria-expanded", String(open));
|
|
99
|
+
});
|
|
100
|
+
dismissButton.addEventListener("click", () => { write(DISMISS_KEY, String(Date.now())); hide(); });
|
|
101
|
+
if (isIos())
|
|
102
|
+
render("ios");
|
|
103
|
+
}
|
|
@@ -1,99 +1,103 @@
|
|
|
1
|
-
// Account form generated from the JSON Schema a plugin declares in initialize.
|
|
2
1
|
const CONTROL = { string: "text", secret: "password", number: "number" };
|
|
3
|
-
|
|
4
2
|
function textFor(field, fallback) {
|
|
5
|
-
|
|
3
|
+
return typeof field.label === "string" && field.label.trim() ? field.label : fallback;
|
|
6
4
|
}
|
|
7
|
-
|
|
8
5
|
function addField(container, field, existing, stored, text) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
let control;
|
|
21
|
-
if (field.type === "boolean" || field.type === "select") {
|
|
22
|
-
control = document.createElement("select");
|
|
23
|
-
control.className = "input";
|
|
24
|
-
const blank = document.createElement("option");
|
|
25
|
-
blank.value = "";
|
|
26
|
-
blank.textContent = existing
|
|
27
|
-
? (stored ? text("integrationsKeepStored") : text("integrationsNotSet"))
|
|
28
|
-
: "";
|
|
29
|
-
control.append(blank);
|
|
30
|
-
const options = field.type === "boolean"
|
|
31
|
-
? [{ value: "1", label: "True" }, { value: "0", label: "False" }]
|
|
32
|
-
: Array.isArray(field.options) ? field.options : [];
|
|
33
|
-
for (const option of options) {
|
|
34
|
-
const node = document.createElement("option");
|
|
35
|
-
node.value = String(option.value);
|
|
36
|
-
node.textContent = typeof option.label === "string" && option.label ? option.label : String(option.value);
|
|
37
|
-
control.append(node);
|
|
6
|
+
const label = document.createElement("label");
|
|
7
|
+
label.className = "field integration-schema-field";
|
|
8
|
+
const caption = document.createElement("span");
|
|
9
|
+
caption.className = "field-label";
|
|
10
|
+
caption.textContent = textFor(field, field.key);
|
|
11
|
+
if (field.required) {
|
|
12
|
+
const required = document.createElement("span");
|
|
13
|
+
required.className = "integration-required";
|
|
14
|
+
required.textContent = " *";
|
|
15
|
+
caption.append(required);
|
|
38
16
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
17
|
+
let control;
|
|
18
|
+
if (field.type === "boolean" || field.type === "select") {
|
|
19
|
+
control = document.createElement("select");
|
|
20
|
+
control.className = "input";
|
|
21
|
+
const blank = document.createElement("option");
|
|
22
|
+
blank.value = "";
|
|
23
|
+
blank.textContent = existing
|
|
24
|
+
? (stored ? text("integrationsKeepStored") : text("integrationsNotSet"))
|
|
25
|
+
: "";
|
|
26
|
+
control.append(blank);
|
|
27
|
+
const options = field.type === "boolean"
|
|
28
|
+
? [{ value: "1", label: "True" }, { value: "0", label: "False" }]
|
|
29
|
+
: Array.isArray(field.options) ? field.options : [];
|
|
30
|
+
for (const option of options) {
|
|
31
|
+
const node = document.createElement("option");
|
|
32
|
+
node.value = String(option.value);
|
|
33
|
+
node.textContent = typeof option.label === "string" && option.label ? option.label : String(option.value);
|
|
34
|
+
control.append(node);
|
|
35
|
+
}
|
|
36
|
+
if (!existing && typeof field.default === "string" && field.default !== "") {
|
|
37
|
+
control.value = field.type === "boolean"
|
|
38
|
+
? (["1", "true", "on", "yes"].includes(field.default.toLowerCase()) ? "1" : "0")
|
|
39
|
+
: field.default;
|
|
40
|
+
}
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
42
|
+
else {
|
|
43
|
+
control = document.createElement("input");
|
|
44
|
+
control.className = "input";
|
|
45
|
+
control.type = (field.type && CONTROL[field.type]) || "text";
|
|
46
|
+
control.autocomplete = field.type === "secret" ? "new-password" : "off";
|
|
47
|
+
if (existing)
|
|
48
|
+
control.placeholder = stored ? text("integrationsLeaveBlank") : text("integrationsNotSet");
|
|
49
|
+
else if (typeof field.default === "string")
|
|
50
|
+
control.value = field.default;
|
|
51
|
+
}
|
|
52
|
+
control.dataset.accountKey = field.key;
|
|
53
|
+
control.dataset.accountType = field.type || "string";
|
|
54
|
+
control.dataset.accountRequired = field.required ? "1" : "0";
|
|
55
|
+
control.dataset.accountStored = stored ? "1" : "0";
|
|
56
|
+
label.append(caption, control);
|
|
57
|
+
if (typeof field.description === "string" && field.description.trim()) {
|
|
58
|
+
const hint = document.createElement("span");
|
|
59
|
+
hint.className = "hint";
|
|
60
|
+
hint.textContent = field.description;
|
|
61
|
+
label.append(hint);
|
|
62
|
+
}
|
|
63
|
+
container.append(label);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
65
|
export function renderAccountSchema(container, plugin, account, text) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
66
|
+
container.textContent = "";
|
|
67
|
+
const schema = plugin?.account?.schema;
|
|
68
|
+
const fields = Array.isArray(schema) ? schema : [];
|
|
69
|
+
container.hidden = fields.length === 0;
|
|
70
|
+
if (!fields.length)
|
|
71
|
+
return;
|
|
72
|
+
const existing = Boolean(account);
|
|
73
|
+
const stored = new Set(account?.envKeys || []);
|
|
74
|
+
for (const field of fields) {
|
|
75
|
+
if (!field || typeof field.key !== "string")
|
|
76
|
+
continue;
|
|
77
|
+
addField(container, field, existing, stored.has(field.key), text);
|
|
78
|
+
}
|
|
77
79
|
}
|
|
78
|
-
|
|
79
80
|
/** Values still land in the account env map; blank means "keep stored". */
|
|
80
81
|
export function readAccountSchema(container, text) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
const values = {};
|
|
83
|
+
const keys = new Set();
|
|
84
|
+
const missing = [];
|
|
85
|
+
for (const control of container.querySelectorAll("[data-account-key]")) {
|
|
86
|
+
const key = control.dataset.accountKey;
|
|
87
|
+
if (key === undefined)
|
|
88
|
+
continue;
|
|
89
|
+
keys.add(key);
|
|
90
|
+
const value = String(control.value ?? "").trim();
|
|
91
|
+
if (value !== "") {
|
|
92
|
+
values[key] = value;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (control.dataset.accountRequired === "1" && control.dataset.accountStored !== "1") {
|
|
96
|
+
const label = control.closest(".integration-schema-field")?.querySelector(".field-label")?.textContent || key;
|
|
97
|
+
missing.push(label.replace(/\s*\*$/, ""));
|
|
98
|
+
}
|
|
91
99
|
}
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
if (missing.length) throw new Error(text("integrationsAccountRequired", { fields: missing.join(", ") }));
|
|
98
|
-
return { values, keys };
|
|
99
|
-
}
|
|
100
|
+
if (missing.length)
|
|
101
|
+
throw new Error(text("integrationsAccountRequired", { fields: missing.join(", ") }));
|
|
102
|
+
return { values, keys };
|
|
103
|
+
}
|