@vite-hub/comments 0.7.0 → 0.8.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.
Files changed (60) hide show
  1. package/README.md +4 -10
  2. package/dist/anchor.d.ts +1 -1
  3. package/dist/client-request-B1DCz3a9.js +29 -0
  4. package/dist/client.d.ts +20 -240
  5. package/dist/client.js +3 -421
  6. package/dist/database.d.ts +1 -2
  7. package/dist/database.js +1 -1
  8. package/dist/{define-BqPcuDhf.js → define-C-LUOouq.js} +1 -1
  9. package/dist/{errors-C0VwRHiy.js → errors-C5utwZ5H.js} +0 -24
  10. package/dist/{errors-CBvIpwbo.js → errors-DeSEHzRf.js} +0 -12
  11. package/dist/hosted/hosted-comments/frame.js +4 -1
  12. package/dist/hosted/hosted-comments/tools.js +65 -74
  13. package/dist/hosted/hosted-comments.js +1 -1
  14. package/dist/{index-D1T7RJ4R.d.ts → index-d6NsDxu9.d.ts} +4 -112
  15. package/dist/index.d.ts +4 -5
  16. package/dist/index.js +6 -20
  17. package/dist/{install-CqBWFmU7.js → install-BueV_fJY.js} +7 -771
  18. package/dist/{install-9L4ASzUC.d.ts → install-F-_O7zDr.d.ts} +5 -11
  19. package/dist/{installed-wUYjqk_k.js → installed-BqQKo6WC.js} +2 -7
  20. package/dist/{database-BuSNVwTx.js → migrate-oseJAYbm.js} +2 -46
  21. package/dist/{operations-kMPw-Cyb.js → operations-0llC5kKO.js} +46 -47
  22. package/dist/{operations-Qt8ASQqW.d.ts → operations-jaihyWw2.d.ts} +35 -3
  23. package/dist/operations.d.ts +3 -3
  24. package/dist/operations.js +2 -2
  25. package/dist/overlay/client-ZBsUybIe.js +4 -0
  26. package/dist/overlay/overlay.js +47 -43
  27. package/dist/page/loader.js +31 -27
  28. package/dist/page-BgvzzsJb.d.ts +32 -0
  29. package/dist/{page-2NzFladc.js → page-CDhmXO-y.js} +24 -1
  30. package/dist/{page-tools-shared-BNw-aWEH.js → page-tools-shared-BCdvqA4S.js} +40 -2
  31. package/dist/{plugin-ChOHe7vq.js → plugin-DGUqlc3C.js} +9 -9
  32. package/dist/realtime.d.ts +6 -8
  33. package/dist/realtime.js +2 -4
  34. package/dist/runtime/auth.d.ts +1 -2
  35. package/dist/runtime/auth.js +1 -1
  36. package/dist/runtime/client-request-plugin.d.ts +2 -0
  37. package/dist/runtime/client-request-plugin.js +21 -0
  38. package/dist/runtime/console.js +2 -2
  39. package/dist/runtime/index.d.ts +5 -8
  40. package/dist/runtime/index.js +23 -151
  41. package/dist/{server-8o9u8leM.js → server-CAMs6viR.js} +1 -1
  42. package/dist/server.d.ts +11 -7
  43. package/dist/server.js +7 -6
  44. package/dist/{store-DvNTDNgn.d.ts → service-CMVA_Ryv.d.ts} +67 -1
  45. package/dist/{service-XT2A8YEF.js → service-DaMq8TBw.js} +35 -33
  46. package/dist/{session-DGdFKWDB.js → session-B7GDrqsK.js} +204 -39
  47. package/dist/{session-CN4irEqf.d.ts → session-EzQqBeE8.d.ts} +2 -3
  48. package/dist/{table-names-BIHjuEFK.js → table-names-DUmWROM4.js} +1 -3
  49. package/dist/testing.js +1 -1
  50. package/dist/{define-B1jLSPe9.d.ts → types-qzJKgWYS.d.ts} +157 -4
  51. package/dist/vite.d.ts +2 -19
  52. package/dist/vite.js +15 -51
  53. package/package.json +8 -8
  54. package/dist/database-CPua6Q6_.d.ts +0 -573
  55. package/dist/overlay/client-CrnKCZXc.js +0 -4
  56. package/dist/overlay/dist-yIZmvSaU.js +0 -1
  57. package/dist/page-DE71P_gQ.d.ts +0 -11
  58. package/dist/request-origin-B-CPVAVk.js +0 -53
  59. package/dist/service-IvgrI4XM.d.ts +0 -71
  60. package/dist/types-l6GOb_yc.d.ts +0 -206
package/dist/client.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { i as commentsUnansweredError, r as commentsClientDiagnostics, t as commentsAnswerError } from "./client-diagnostics-DoXqdnBd.js";
2
2
  import { i as withCommentFiles, n as outboxAccountHeader, r as retryAfterOf, t as failedCommentPreparation } from "./client-files-lC6X7XyS.js";
3
3
  import { t as replyMessageId } from "./reply-id-Cm9FGOBs.js";
4
- import { o as commentsRoute } from "./page-2NzFladc.js";
4
+ import { s as commentsRoute } from "./page-CDhmXO-y.js";
5
5
  import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
6
- import { t as commentsErrorDiagnostics } from "./errors-CBvIpwbo.js";
6
+ import { t as commentsErrorDiagnostics } from "./errors-DeSEHzRf.js";
7
7
  import { t as foldName } from "./fold-name-g-xg0mQk.js";
8
8
  // ../internal/src/browser-environment.ts
9
9
  /** The real browser: window events, Web Locks, and a BroadcastChannel, each only when the browser has it. */
@@ -1751,424 +1751,6 @@ function resolveAnchor(anchor, root = document) {
1751
1751
  element
1752
1752
  };
1753
1753
  }
1754
- // src/client-send.ts
1755
- const reasonOf = (error) => error instanceof Error ? error.message : String(error);
1756
- /**
1757
- * The Send segment of a comment pill, without a framework: it hands the member's waiting threads to their agent, and
1758
- * pairs one in place first when there is none. `CommentSend` of `@vite-hub/ui` renders it.
1759
- */
1760
- function createCommentSend(transport, options = {}) {
1761
- const pairingInterval = options.pairingInterval ?? 1500;
1762
- const statusInterval = options.statusInterval ?? 5e3;
1763
- const sentFor = options.sentFor ?? 2e3;
1764
- const listeners = /* @__PURE__ */ new Set();
1765
- let state = {
1766
- status: "idle",
1767
- count: 0,
1768
- inbox: false
1769
- };
1770
- let agent;
1771
- let count = 0;
1772
- let countRevision = 0;
1773
- let selection = "";
1774
- let selections = 0;
1775
- let code;
1776
- let fetching = false;
1777
- let sendId;
1778
- let thread;
1779
- let sentInbox = false;
1780
- let pushed;
1781
- let step = 0;
1782
- let sentUntil = 0;
1783
- let timer;
1784
- let run = 0;
1785
- let lastStep = "send";
1786
- const notify = () => {
1787
- for (const listener of listeners) listener();
1788
- };
1789
- const set = (next) => {
1790
- step++;
1791
- clearTimeout(timer);
1792
- timer = void 0;
1793
- state = next;
1794
- notify();
1795
- };
1796
- const later = (ms, then) => {
1797
- const at = step;
1798
- clearTimeout(timer);
1799
- timer = setTimeout(() => at === step && then(), ms);
1800
- };
1801
- const inbox = () => Boolean(agent && !agent.host);
1802
- const needsStatus = () => state.status === "failed" && lastStep === "allow";
1803
- const idleState = () => ({
1804
- status: "idle",
1805
- count,
1806
- inbox: inbox(),
1807
- ...agent && count > 0 ? { canPairAnother: true } : {}
1808
- });
1809
- const idle = () => set(idleState());
1810
- const sentState = () => ({
1811
- status: "sent",
1812
- count,
1813
- inbox: sentInbox,
1814
- ...agent ? { agent } : {}
1815
- });
1816
- const finish = () => {
1817
- sendId = void 0;
1818
- thread = void 0;
1819
- idle();
1820
- };
1821
- const working = () => {
1822
- set({
1823
- status: "working",
1824
- count,
1825
- ...agent ? { agent } : {},
1826
- ...thread ? { thread } : {}
1827
- });
1828
- if (!transport.subscribe) later(statusInterval, () => void refresh(working));
1829
- };
1830
- const sent = () => {
1831
- set(sentState());
1832
- if (!transport.subscribe) later(statusInterval, () => void refresh(sent));
1833
- };
1834
- const holdingSent = () => state.status === "sent" && Date.now() < sentUntil;
1835
- const limited = (retryAt) => {
1836
- set({
1837
- status: "limited",
1838
- count,
1839
- retryAt
1840
- });
1841
- later(Math.max(0, retryAt - Date.now()), () => void refresh(idle));
1842
- };
1843
- const pending = () => {
1844
- set({
1845
- status: "sending",
1846
- count
1847
- });
1848
- later(statusInterval, () => void refresh(pending, true));
1849
- };
1850
- const apply = (status) => {
1851
- agent = status.agent;
1852
- if (status.pending) return pending();
1853
- const last = status.working ?? status.sent;
1854
- if (last) {
1855
- if (status.sent) sentInbox = status.sent.inbox ?? inbox();
1856
- const hold = holdingSent() && sendId === last.id;
1857
- sendId = last.id;
1858
- thread = hold ? thread ?? last.thread : last.thread;
1859
- if (hold) {
1860
- state = sentState();
1861
- return notify();
1862
- }
1863
- return status.working ? working() : sent();
1864
- }
1865
- sendId = void 0;
1866
- thread = void 0;
1867
- if (status.retryAt !== void 0 && status.retryAt > Date.now()) return limited(status.retryAt);
1868
- idle();
1869
- };
1870
- const refresh = async (onError, deliveryPending = false) => {
1871
- const at = step;
1872
- const canApply = () => at === step && !fetching && state.status !== "pairing" && state.status !== "confirm" && (state.status !== "sending" || deliveryPending);
1873
- if (!canApply()) return;
1874
- const revision = countRevision;
1875
- try {
1876
- const status = await transport.status();
1877
- if (!canApply()) return;
1878
- if (revision === countRevision) count = status.count;
1879
- selection = status.selection ?? "";
1880
- apply(status);
1881
- } catch (error) {
1882
- if (!onError) throw error;
1883
- if (canApply()) onError();
1884
- }
1885
- };
1886
- const settle = (result, revision, paired) => {
1887
- const updates = pushed;
1888
- pushed = void 0;
1889
- if (result.status === "changed") {
1890
- count = result.count;
1891
- selection = result.selection;
1892
- if (!paired) return set({
1893
- status: "failed",
1894
- count,
1895
- reason: "The waiting comments changed."
1896
- });
1897
- code = paired.code;
1898
- return set({
1899
- status: "confirm",
1900
- count,
1901
- agent: paired.agent
1902
- });
1903
- }
1904
- if (result.status === "failed") return set({
1905
- status: "failed",
1906
- count,
1907
- reason: result.reason
1908
- });
1909
- if (paired) agent = paired.agent;
1910
- if (result.status === "limited") return limited(result.retryAt);
1911
- if (result.status === "pending") return pending();
1912
- sendId = result.id;
1913
- const update = updates?.get(result.id);
1914
- thread = update?.thread ?? result.thread;
1915
- if (revision === countRevision) count = 0;
1916
- sentInbox = result.inbox ?? inbox();
1917
- set(sentState());
1918
- sentUntil = Date.now() + sentFor;
1919
- later(sentFor, update?.done ? finish : update ? working : () => void refresh(sent));
1920
- };
1921
- const drop = (dropped) => void transport.cancel(dropped).catch(() => void 0);
1922
- const deliver = async (request, paired) => {
1923
- const revision = countRevision;
1924
- pushed = transport.subscribe ? /* @__PURE__ */ new Map() : void 0;
1925
- set({
1926
- status: "sending",
1927
- count
1928
- });
1929
- const at = step;
1930
- let result;
1931
- try {
1932
- result = await request();
1933
- } catch (error) {
1934
- result = {
1935
- status: "failed",
1936
- reason: reasonOf(error)
1937
- };
1938
- }
1939
- const current = at === step;
1940
- if (current) settle(result, revision, paired);
1941
- if (paired && (result.status === "failed" || result.status === "limited" || !current && result.status === "changed")) drop(paired.code);
1942
- };
1943
- const poll = () => {
1944
- later(pairingInterval, async () => {
1945
- if (state.status !== "pairing" || !code) return;
1946
- if (Date.now() >= state.expiresAt) return set({
1947
- ...state,
1948
- reason: "expired"
1949
- });
1950
- const at = step;
1951
- const check = await transport.pollPairing(code).catch(() => ({ status: "waiting" }));
1952
- if (at !== step || state.status !== "pairing") return;
1953
- if (check.status === "waiting") return poll();
1954
- if (check.status === "paired") return set({
1955
- status: "confirm",
1956
- count,
1957
- agent: check.agent
1958
- });
1959
- set({
1960
- ...state,
1961
- reason: check.status
1962
- });
1963
- });
1964
- };
1965
- const pair = async (copy) => {
1966
- if (fetching) return;
1967
- fetching = true;
1968
- lastStep = "pair";
1969
- const at = ++step;
1970
- try {
1971
- const pairing = transport.startPairing();
1972
- const prompt = pairing.then((next) => next.prompt);
1973
- prompt.catch(() => void 0);
1974
- const copied = (async () => copy ? copy(prompt) : true)().then((ok) => ({ ok }), (error) => ({
1975
- ok: false,
1976
- error
1977
- }));
1978
- const next = await pairing;
1979
- const outcome = await copied;
1980
- if (at !== step) return drop(next.code);
1981
- fetching = false;
1982
- if (!outcome.ok) {
1983
- drop(next.code);
1984
- const reason = "error" in outcome ? reasonOf(outcome.error) : "The browser did not let the page copy the setup prompt.";
1985
- return set({
1986
- status: "failed",
1987
- count,
1988
- reason
1989
- });
1990
- }
1991
- if (code) drop(code);
1992
- code = next.code;
1993
- count = next.count;
1994
- selection = next.selection;
1995
- set({
1996
- status: "pairing",
1997
- count,
1998
- prompt: next.prompt,
1999
- expiresAt: next.expiresAt,
2000
- agent: next.agent
2001
- });
2002
- poll();
2003
- } catch (error) {
2004
- if (at === step) {
2005
- fetching = false;
2006
- set({
2007
- status: "failed",
2008
- count,
2009
- reason: reasonOf(error)
2010
- });
2011
- }
2012
- }
2013
- };
2014
- const reselect = async () => {
2015
- const at = ++selections;
2016
- const pairing = code;
2017
- const status = await transport.status().catch(() => void 0);
2018
- if (!status || at !== selections || !pairing || pairing !== code || state.status !== "pairing" && state.status !== "confirm") return;
2019
- count = status.count;
2020
- selection = status.selection ?? "";
2021
- state = {
2022
- ...state,
2023
- count
2024
- };
2025
- notify();
2026
- };
2027
- return {
2028
- get state() {
2029
- return state;
2030
- },
2031
- onChange(listener) {
2032
- listeners.add(listener);
2033
- return () => {
2034
- listeners.delete(listener);
2035
- };
2036
- },
2037
- start() {
2038
- const current = ++run;
2039
- const stop = transport.subscribe?.((event) => {
2040
- if (current !== run) return;
2041
- if (event.type === "count") {
2042
- countRevision++;
2043
- if (state.status === "pairing" || state.status === "confirm") return void reselect();
2044
- count = event.count;
2045
- if (state.status !== "sending") {
2046
- state = state.status === "idle" ? idleState() : {
2047
- ...state,
2048
- count
2049
- };
2050
- notify();
2051
- }
2052
- return;
2053
- }
2054
- if (state.status === "sending") {
2055
- const update = pushed?.get(event.id);
2056
- pushed?.set(event.id, event.type === "done" ? {
2057
- ...update,
2058
- done: true
2059
- } : {
2060
- ...update,
2061
- thread: event.thread ?? update?.thread
2062
- });
2063
- return;
2064
- }
2065
- if (fetching || state.status === "pairing" || state.status === "confirm" || needsStatus()) return;
2066
- if ((state.status === "working" || state.status === "sent") && sendId !== event.id) return;
2067
- if (event.type === "working") {
2068
- thread = event.thread ?? (event.id === sendId ? thread : void 0);
2069
- sendId = event.id;
2070
- if (holdingSent()) later(sentUntil - Date.now(), working);
2071
- else working();
2072
- return;
2073
- }
2074
- if (event.id === sendId) finish();
2075
- });
2076
- refresh(() => void 0);
2077
- return () => {
2078
- stop?.();
2079
- if (current !== run) return;
2080
- run++;
2081
- if (code) drop(code);
2082
- code = void 0;
2083
- fetching = false;
2084
- pushed = void 0;
2085
- agent = void 0;
2086
- count = 0;
2087
- finish();
2088
- };
2089
- },
2090
- refresh: () => refresh(),
2091
- async send(copy) {
2092
- if (fetching || state.status !== "idle" && state.status !== "failed" && state.status !== "sent" && state.status !== "working") return;
2093
- if (state.status !== "failed" && count === 0) return;
2094
- if (state.status === "failed" && lastStep === "pair") return pair(copy);
2095
- if (needsStatus()) return refresh(() => void 0);
2096
- if (!agent) return pair(copy);
2097
- lastStep = "send";
2098
- return deliver(() => transport.send());
2099
- },
2100
- async pairAnother(copy) {
2101
- if (state.status !== "idle" || !state.canPairAnother) return;
2102
- return pair(copy);
2103
- },
2104
- async allow() {
2105
- if (state.status !== "confirm" || !code) return;
2106
- const used = code;
2107
- code = void 0;
2108
- lastStep = "allow";
2109
- return deliver(() => transport.allow(used, selection), {
2110
- code: used,
2111
- agent: state.agent
2112
- });
2113
- },
2114
- async copyAgain(copy) {
2115
- if (state.status !== "pairing" || !state.reason) return;
2116
- return pair(copy);
2117
- },
2118
- cancel() {
2119
- if (state.status !== "pairing" && state.status !== "confirm") return;
2120
- if (code) drop(code);
2121
- code = void 0;
2122
- fetching = false;
2123
- idle();
2124
- }
2125
- };
2126
- }
2127
- // src/send-transport.ts
2128
- /**
2129
- * The transport of `createCommentSend()` over the Send routes of Comments, `<base>/_vitehub/comments/send/**`. The
2130
- * ViteHub pill uses it, and an app renders `CommentSend` of `@vite-hub/ui` with it in its own pill:
2131
- *
2132
- * ```ts
2133
- * import { createCommentSend, createCommentSendTransport } from "@vite-hub/comments/client"
2134
- *
2135
- * const send = createCommentSend(createCommentSendTransport({ page: () => location.pathname }))
2136
- * ```
2137
- */
2138
- function createCommentSendTransport(options = {}) {
2139
- const request = createCommentsRestRequest(options);
2140
- const page = () => encodeURIComponent(typeof options.page === "function" ? options.page() : options.page ?? location.pathname);
2141
- const post = (body) => ({
2142
- method: "POST",
2143
- ...body === void 0 ? {} : { body: JSON.stringify(body) }
2144
- });
2145
- const code = (value) => encodeURIComponent(value);
2146
- const pairingPages = /* @__PURE__ */ new Map();
2147
- return {
2148
- status: async () => (await request(`/send/status?page=${page()}`)).data,
2149
- startPairing: async () => {
2150
- const path = page();
2151
- const pairing = (await request(`/send/start?page=${path}`, post())).data;
2152
- pairingPages.set(pairing.code, path);
2153
- return pairing;
2154
- },
2155
- pollPairing: async (value) => (await request(`/send/pair/${code(value)}`)).data,
2156
- allow: async (value, selection) => {
2157
- const path = pairingPages.get(value) ?? page();
2158
- const result = (await request(`/send/allow?page=${path}`, post({
2159
- code: value,
2160
- selection
2161
- }))).data;
2162
- if (result.status !== "changed") pairingPages.delete(value);
2163
- return result;
2164
- },
2165
- cancel: async (value) => {
2166
- pairingPages.delete(value);
2167
- await request(`/send/pair/${code(value)}`, { method: "DELETE" });
2168
- },
2169
- send: async () => (await request(`/send?page=${page()}`, post())).data
2170
- };
2171
- }
2172
1754
  // src/client.ts
2173
1755
  function observed(input) {
2174
1756
  for (const files of [input.files, input.deferredFiles]) if (files && !Array.isArray(files)) files.catch(() => {});
@@ -2430,4 +2012,4 @@ function createCommentsClient(options = {}) {
2430
2012
  }
2431
2013
  };
2432
2014
  }
2433
- export { anchorRange, appCommentsBase, commentAttachmentUrl, commentsAgentPrompt, commentsApiCan, commentsErrorDiagnostics, commentsGuestUser, commentsPagePrompt, commentsT3CodeLink, createAnchor, createCommentSend, createCommentSendTransport, createCommentsClient, createCommentsRestRequest, createIndexedDBOutboxStore, createMemoryOutboxStore, createRestTransport, foldName, onCommentsGuestSaved, readCommentsGuest, replyMessageId, resolveAnchor, saveCommentsGuest, selectorFor, t3CodeLinkLimit };
2015
+ export { anchorRange, appCommentsBase, commentAttachmentUrl, commentsAgentPrompt, commentsApiCan, commentsErrorDiagnostics, commentsGuestUser, commentsPagePrompt, commentsT3CodeLink, createAnchor, createCommentsClient, createCommentsRestRequest, createIndexedDBOutboxStore, createMemoryOutboxStore, createRestTransport, foldName, onCommentsGuestSaved, readCommentsGuest, replyMessageId, resolveAnchor, saveCommentsGuest, selectorFor, t3CodeLinkLimit };
@@ -1,5 +1,4 @@
1
1
  import { a as commentThreads, i as commentMessages, n as commentCounters, o as commentsSchema, r as commentForge, s as commentsSqliteTables, t as CommentsSqliteTablesOptions } from "./database-DUs3c2al.js";
2
- import { i as commentSendsTables, n as commentSends, r as commentSendsSchema, t as CommentSendState } from "./database-CPua6Q6_.js";
3
2
  import { a as commentsMigrationSql, c as migrateComments, i as CommentsSchemaState, n as CommentsMigrationOptions, o as commentsSchemaState, s as liveThreadsBackup, t as CommentsMigration } from "./migrate-XjFeQppf.js";
4
3
  /**
5
4
  * The tables of `commentsSchema` as SQLite statements that are safe to run on every start. A database that Comments
@@ -8,4 +7,4 @@ import { a as commentsMigrationSql, c as migrateComments, i as CommentsSchemaSta
8
7
  * runs it with `schema: "comments"`.
9
8
  */
10
9
  export declare const commentsTables: readonly string[];
11
- export { type CommentSendState, type CommentsMigration, type CommentsMigrationOptions, type CommentsSchemaState, type CommentsSqliteTablesOptions, commentCounters, commentForge, commentMessages, commentSends, commentSendsSchema, commentSendsTables, commentThreads, commentsMigrationSql, commentsSchema, commentsSchemaState, commentsSqliteTables, liveThreadsBackup, migrateComments };
10
+ export { type CommentsMigration, type CommentsMigrationOptions, type CommentsSchemaState, type CommentsSqliteTablesOptions, commentCounters, commentForge, commentMessages, commentThreads, commentsMigrationSql, commentsSchema, commentsSchemaState, commentsSqliteTables, liveThreadsBackup, migrateComments };
package/dist/database.js CHANGED
@@ -1 +1 @@
1
- export { u as commentCounters, d as commentForge, f as commentMessages, t as commentSends, n as commentSendsSchema, r as commentSendsTables, p as commentThreads, i as commentsMigrationSql, m as commentsSchema, o as commentsSchemaState, h as commentsSqliteTables, l as commentsTables, s as liveThreadsBackup, c as migrateComments } from "./database-BuSNVwTx.js";
1
+ export { s as commentCounters, c as commentForge, l as commentMessages, u as commentThreads, t as commentsMigrationSql, d as commentsSchema, r as commentsSchemaState, f as commentsSqliteTables, o as commentsTables, i as liveThreadsBackup, a as migrateComments } from "./migrate-oseJAYbm.js";
@@ -1,4 +1,4 @@
1
- import { t as commentsErrorDiagnostics } from "./errors-CBvIpwbo.js";
1
+ import { t as commentsErrorDiagnostics } from "./errors-DeSEHzRf.js";
2
2
  // src/operations-core/define.ts
3
3
  const marker = Symbol.for("vitehub.comments.definition");
4
4
  /** Marks a definition, so the build can check what `server/comments.ts` exports. */
@@ -50,30 +50,6 @@ const commentsErrors = /*#__PURE__*/ defineErrors({
50
50
  COMMENTS_FIELD_LOCKED: {
51
51
  why: ({ holder }) => `${holder} holds the edit lease of this document in the Console.`,
52
52
  fix: "Wait until they close the document, or edit it together with them in the Console."
53
- },
54
- COMMENTS_SEND_CODE_EXPIRED: {
55
- why: "The setup code of Send is older than 10 minutes, or it does not exist.",
56
- fix: "Press Send in the comment pill again. It copies a setup prompt with a new code."
57
- },
58
- COMMENTS_SEND_CODE_REFUSED: {
59
- why: ({ reason }) => `Send did not pair the agent. ${reason}`,
60
- fix: "Pair with the `webhookUrl` that T3 Code's `schedule_task` returns, on `relay.t3.codes`, or add the host to `defineComments({ send: { hosts } })`. Then press Copy again for a new code."
61
- },
62
- COMMENTS_SEND_CODE_USED: {
63
- why: "An agent already used this setup code. A code pairs one agent, once.",
64
- fix: "Press Send in the comment pill again for a new code."
65
- },
66
- COMMENTS_SEND_GRANT_INVALID: {
67
- why: "The read token does not open this send: it is wrong, older than 24 hours, or the app turned read tokens off.",
68
- fix: "Use the `read.token` of the same delivery within 24 hours. With `send: { grant: false }`, read the threads through the app's MCP tools instead."
69
- },
70
- COMMENTS_SEND_INSECURE: {
71
- why: ({ origin }) => `Send answers with a setup code and a signing secret, and builds links that carry read tokens, so it does not run over plain http. The request came from ${origin}.`,
72
- fix: "Open the site over https. In development, use `localhost`, `*.localhost`, or `127.0.0.1`. With `wrangler dev`, pass `--infer-origin-from-routes=false`, so the request keeps the local origin instead of the production host."
73
- },
74
- COMMENTS_SEND_OFF: {
75
- why: "Send is off: `defineComments()` has no `send` option, or the app has no Webhooks.",
76
- fix: "Set `defineComments({ send: true })` in `server/comments.ts`, in a ViteHub app with `vitehub({ database: true })`."
77
53
  }
78
54
  }
79
55
  });
@@ -137,18 +137,6 @@ const commentsErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
137
137
  why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
138
138
  fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
139
139
  },
140
- COMMENTS_SEND_POSTGRES: {
141
- why: "`defineComments({ send })` keeps its sends in SQLite tables, and this app keeps comments in Postgres.",
142
- fix: "Keep comments in a SQLite, libSQL, or D1 Database, or remove `send` from `defineComments()`."
143
- },
144
- COMMENTS_SEND_TABLES_MISSING: {
145
- why: ({ missing }) => `\`defineComments({ send })\` needs the tables ${missing}, and the Database does not have them yet.`,
146
- fix: "Run `vitehub database generate` and `vitehub database migrate`. `vite dev` applies the migration for you."
147
- },
148
- COMMENTS_SEND_WEBHOOKS_OFF: {
149
- why: ({ file }) => `${file} turns on Send, and Send delivers through the member endpoints of Webhooks, which this app does not have.`,
150
- fix: "Use Comments through `vitehub()`, which adds Webhooks, and install `@vite-hub/webhooks` when you use the packages one by one. `comments()` without `vite-hub` has no Send."
151
- },
152
140
  COMMENTS_TENANT_DELETE_USER: {
153
141
  why: "Deleting a user from shared Comments tables requires access to all projects.",
154
142
  fix: "Delete the user's messages through the project that owns them."