@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.
Files changed (92) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +18 -62
  3. package/README.zh-CN.md +25 -69
  4. package/dist/cli.js +466 -188
  5. package/package.json +11 -5
  6. package/packages/chat-room-channeld/README.md +25 -3
  7. package/packages/chat-room-channeld/dist/mock-adapter.js +5 -5
  8. package/packages/chat-room-channeld/src/adapter.ts +5 -0
  9. package/packages/chat-room-channeld/src/cli.ts +72 -5
  10. package/packages/chat-room-channeld/src/host.ts +17 -2
  11. package/packages/chat-room-channeld/src/pg/database.ts +187 -0
  12. package/packages/chat-room-channeld/src/pg/migrate.ts +150 -0
  13. package/packages/chat-room-channeld/src/pg/schema.ts +60 -0
  14. package/packages/chat-room-channeld/src/pg/sql.mjs +175 -0
  15. package/packages/chat-room-channeld/src/pg/sqlite.ts +100 -0
  16. package/packages/chat-room-channeld/src/pg/worker.mjs +133 -0
  17. package/packages/chat-room-channeld/src/protocol.ts +1 -0
  18. package/packages/chat-room-channeld/src/state.ts +73 -97
  19. package/packages/chat-room-channeld/src/stats.ts +140 -109
  20. package/server/assets/base.css +3 -1
  21. package/server/assets/chat/admin-badge.js +32 -30
  22. package/server/assets/chat/admin.js +201 -161
  23. package/server/assets/chat/announcements.js +302 -208
  24. package/server/assets/chat/attachment-store.js +116 -76
  25. package/server/assets/chat/attachments.js +701 -441
  26. package/server/assets/chat/chat-background.js +179 -156
  27. package/server/assets/chat/clipboard.js +45 -25
  28. package/server/assets/chat/confirm-dialog.js +38 -35
  29. package/server/assets/chat/copy-action.js +40 -41
  30. package/server/assets/chat/create-room-dialog.js +50 -47
  31. package/server/assets/chat/diagram-viewer.js +293 -236
  32. package/server/assets/chat/doc-preview.js +516 -443
  33. package/server/assets/chat/editor.js +446 -336
  34. package/server/assets/chat/events.js +650 -510
  35. package/server/assets/chat/files.js +505 -431
  36. package/server/assets/chat/history-loader.js +81 -73
  37. package/server/assets/chat/icons.js +9 -11
  38. package/server/assets/chat/image-zoom.js +246 -179
  39. package/server/assets/chat/index.js +2 -3
  40. package/server/assets/chat/install-prompt.js +90 -69
  41. package/server/assets/chat/integration-account-schema.js +91 -87
  42. package/server/assets/chat/integration-editor.js +162 -155
  43. package/server/assets/chat/integration-values.js +116 -101
  44. package/server/assets/chat/integrations.js +750 -626
  45. package/server/assets/chat/join-requests.js +415 -358
  46. package/server/assets/chat/locales/de.js +193 -194
  47. package/server/assets/chat/locales/es.js +193 -194
  48. package/server/assets/chat/locales/fr.js +193 -194
  49. package/server/assets/chat/locales/index.js +1 -2
  50. package/server/assets/chat/locales/it.js +193 -194
  51. package/server/assets/chat/locales/ja.js +193 -193
  52. package/server/assets/chat/locales/ko.js +193 -193
  53. package/server/assets/chat/markdown-footnotes.js +134 -103
  54. package/server/assets/chat/markdown.js +557 -404
  55. package/server/assets/chat/members.js +259 -197
  56. package/server/assets/chat/mentions.js +181 -133
  57. package/server/assets/chat/message-cache.js +40 -33
  58. package/server/assets/chat/message-polling.js +299 -227
  59. package/server/assets/chat/message-window.js +78 -55
  60. package/server/assets/chat/messages.js +562 -480
  61. package/server/assets/chat/office-preview.js +46 -45
  62. package/server/assets/chat/palette.js +464 -417
  63. package/server/assets/chat/panels.js +94 -79
  64. package/server/assets/chat/pwa.js +147 -75
  65. package/server/assets/chat/questions.js +374 -302
  66. package/server/assets/chat/recall.js +338 -273
  67. package/server/assets/chat/receipts.js +151 -121
  68. package/server/assets/chat/reminders.js +345 -214
  69. package/server/assets/chat/replies.js +181 -130
  70. package/server/assets/chat/resource-format.js +59 -62
  71. package/server/assets/chat/room-list.js +58 -55
  72. package/server/assets/chat/room-watcher.js +76 -50
  73. package/server/assets/chat/rooms.js +631 -500
  74. package/server/assets/chat/search.js +138 -114
  75. package/server/assets/chat/settings.js +225 -201
  76. package/server/assets/chat/shiki.js +62 -63
  77. package/server/assets/chat/shortcuts.js +212 -189
  78. package/server/assets/chat/side-pane.js +161 -150
  79. package/server/assets/chat/state.js +860 -737
  80. package/server/assets/chat/system-events.js +46 -44
  81. package/server/assets/chat/system-messages.js +57 -56
  82. package/server/assets/chat/task-form.js +179 -183
  83. package/server/assets/chat/task-row.js +158 -155
  84. package/server/assets/chat/tasks.js +665 -587
  85. package/server/assets/chat/viewport.js +32 -29
  86. package/server/assets/chat/window-controls.js +32 -32
  87. package/server/assets/conversation.css +10 -4
  88. package/server/chat-server.ts +9 -1
  89. package/server/chat.html +3 -1
  90. package/server/routes/pages.ts +7 -5
  91. package/server/sw.js +346 -268
  92. package/src/web/integration-rules-editor.ts +2 -0
@@ -1,73 +1,96 @@
1
1
  export function pruneMessageRows(list, messages) {
2
- const ids = new Set(messages.map((message) => message.id));
3
- for (const row of list.querySelectorAll("[data-msg-id]")) if (!ids.has(row.dataset.msgId)) row.remove();
4
- const days = new Set([...list.querySelectorAll("[data-msg-id]")].map((row) => row.dataset.day));
5
- for (const separator of list.querySelectorAll(".day-sep")) if (!days.has(separator.dataset.day)) separator.remove();
6
- if (!days.size) list.querySelectorAll(".gap").forEach((gap) => gap.remove());
2
+ const ids = new Set(messages.map((message) => message.id));
3
+ for (const row of list.querySelectorAll("[data-msg-id]"))
4
+ if (!row.dataset.msgId || !ids.has(row.dataset.msgId))
5
+ row.remove();
6
+ const days = new Set([...list.querySelectorAll("[data-msg-id]")].map((row) => row.dataset.day ?? ""));
7
+ for (const separator of list.querySelectorAll(".day-sep"))
8
+ if (!days.has(separator.dataset.day ?? ""))
9
+ separator.remove();
10
+ if (!days.size)
11
+ list.querySelectorAll(".gap").forEach((gap) => gap.remove());
7
12
  }
8
-
9
13
  export function hasMessageSelection(list) {
10
- const selection = getSelection();
11
- return Boolean(selection && !selection.isCollapsed
12
- && (list.contains(selection.anchorNode) || list.contains(selection.focusNode)));
14
+ const selection = getSelection();
15
+ return Boolean(selection && !selection.isCollapsed
16
+ && (list.contains(selection.anchorNode) || list.contains(selection.focusNode)));
13
17
  }
14
-
15
18
  // A held pointer or a live selection owns the viewport. Layout writes may only
16
19
  // follow the bottom when neither gesture is active.
17
20
  export function pointerOrSelectionActive(app) {
18
- if (app.state.threadPointerDown) return true;
19
- const list = document.querySelector("#msgList");
20
- return Boolean(list && hasMessageSelection(list));
21
+ if (app.state.threadPointerDown)
22
+ return true;
23
+ const list = document.querySelector("#msgList");
24
+ return Boolean(list && hasMessageSelection(list));
21
25
  }
22
-
23
26
  export function followsBottom(app, threshold = -1) {
24
- if (pointerOrSelectionActive(app)) return false;
25
- const thread = document.querySelector("#thread");
26
- return Boolean(app.state.followBottom || (thread && thread.scrollHeight - thread.scrollTop - thread.clientHeight <= threshold));
27
+ if (pointerOrSelectionActive(app))
28
+ return false;
29
+ const thread = document.querySelector("#thread");
30
+ return Boolean(app.state.followBottom || (thread && thread.scrollHeight - thread.scrollTop - thread.clientHeight <= threshold));
27
31
  }
28
-
29
32
  // A search jump parks one row near the top of the thread and flashes it briefly.
30
33
  export function flashMessageRow(app, row) {
31
- const thread = document.querySelector("#thread");
32
- thread.scrollTop += row.getBoundingClientRect().top - (thread.getBoundingClientRect().top + thread.clientTop) - 12;
33
- app.state.followBottom = false;
34
- // Keep a programmatic search jump from being mistaken for the reader returning to the tail.
35
- app.state.focusHoldUntil = performance.now() + 900;
36
- clearTimeout(row._jumpFlashTimer);
37
- row.classList.remove("jump-flash");
38
- void row.offsetWidth;
39
- row.classList.add("jump-flash");
40
- row._jumpFlashTimer = setTimeout(() => row.classList.remove("jump-flash"), 900);
41
- app.updateJump?.();
34
+ const thread = document.querySelector("#thread");
35
+ if (!thread)
36
+ return;
37
+ thread.scrollTop += row.getBoundingClientRect().top - (thread.getBoundingClientRect().top + thread.clientTop) - 12;
38
+ app.state.followBottom = false;
39
+ // Keep a programmatic search jump from being mistaken for the reader returning to the tail.
40
+ app.state.focusHoldUntil = performance.now() + 900;
41
+ clearTimeout(row._jumpFlashTimer);
42
+ row.classList.remove("jump-flash");
43
+ void row.offsetWidth;
44
+ row.classList.add("jump-flash");
45
+ row._jumpFlashTimer = setTimeout(() => row.classList.remove("jump-flash"), 900);
46
+ app.updateJump?.();
42
47
  }
43
-
44
48
  // Resolve app.state.focusMessageId against the loaded state and rendered rows.
45
49
  export function focusedMessage(app, list, messages) {
46
- const id = app.state.focusMessageId;
47
- if (!id) return null;
48
- const index = messages.findIndex((message) => message.id === id);
49
- if (index < 0) { app.state.focusMessageId = null; return null; }
50
- return { id, index, existing: list.querySelector(`[data-msg-id="${CSS.escape(id)}"]`) };
50
+ const id = app.state.focusMessageId;
51
+ if (!id)
52
+ return null;
53
+ const index = messages.findIndex((message) => message.id === id);
54
+ if (index < 0) {
55
+ app.state.focusMessageId = null;
56
+ return null;
57
+ }
58
+ return { id, index, existing: list.querySelector(`[data-msg-id="${CSS.escape(id)}"]`) };
51
59
  }
52
-
53
60
  export function trimMessages(list, app) {
54
- if (list.children.length <= 400 || hasMessageSelection(list)) return;
55
- // Trimming removes content above the reader. While they are browsing older
56
- // history that would shift the viewport, so only trim near the newest tail.
57
- const thread = document.querySelector("#thread");
58
- if (thread && thread.scrollHeight - thread.scrollTop - thread.clientHeight > 80) return;
59
- const saved = app.state.positions.get(app.state.room?.id), rows = [...list.querySelectorAll("[data-msg-id]")];
60
- const anchor = saved?.messageId && rows.find((row) => row.dataset.msgId === saved.messageId);
61
- if (anchor && rows.indexOf(anchor) < rows.length - 280) {
62
- const recent = rows.at(-300);
63
- while (list.firstElementChild && list.firstElementChild !== anchor) list.firstElementChild.remove();
64
- let next = anchor.nextElementSibling;
65
- while (next && next !== recent) { const after = next.nextElementSibling; next.remove(); next = after; }
66
- const gap = document.createElement("li"); gap.className = "gap"; app.setText(gap, "messagesBetweenOmitted"); anchor.after(gap);
67
- return;
68
- }
69
- while (list.children.length > 300) list.removeChild(list.firstChild);
70
- if (list.firstElementChild && !list.firstElementChild.classList.contains("gap")) {
71
- const gap = document.createElement("li"); gap.className = "gap"; app.setText(gap, "earlierMessages"); list.insertBefore(gap, list.firstChild);
72
- }
61
+ if (list.children.length <= 400 || hasMessageSelection(list))
62
+ return;
63
+ // Trimming removes content above the reader. While they are browsing older
64
+ // history that would shift the viewport, so only trim near the newest tail.
65
+ const thread = document.querySelector("#thread");
66
+ if (thread && thread.scrollHeight - thread.scrollTop - thread.clientHeight > 80)
67
+ return;
68
+ const position = app.state.positions.get(app.state.room?.id ?? "");
69
+ const saved = position && typeof position === "object" ? position : undefined;
70
+ const rows = [...list.querySelectorAll("[data-msg-id]")];
71
+ const anchor = saved?.messageId && rows.find((row) => row.dataset.msgId === saved.messageId);
72
+ if (anchor && rows.indexOf(anchor) < rows.length - 280) {
73
+ const recent = rows.at(-300);
74
+ while (list.firstElementChild && list.firstElementChild !== anchor)
75
+ list.firstElementChild.remove();
76
+ let next = anchor.nextElementSibling;
77
+ while (next && next !== recent) {
78
+ const after = next.nextElementSibling;
79
+ next.remove();
80
+ next = after;
81
+ }
82
+ const gap = document.createElement("li");
83
+ gap.className = "gap";
84
+ app.setText(gap, "messagesBetweenOmitted");
85
+ anchor.after(gap);
86
+ return;
87
+ }
88
+ while (list.children.length > 300 && list.firstChild)
89
+ list.removeChild(list.firstChild);
90
+ if (list.firstElementChild && !list.firstElementChild.classList.contains("gap")) {
91
+ const gap = document.createElement("li");
92
+ gap.className = "gap";
93
+ app.setText(gap, "earlierMessages");
94
+ list.insertBefore(gap, list.firstChild);
95
+ }
73
96
  }