@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
@@ -1,4 +1,5 @@
1
- import { D as CommentUser, T as CommentThread, b as CommentMetadata, n as CommentActor, w as CommentSubject, y as CommentMessage } from "./types-BX3vH18p.js";
1
+ import { D as CommentUser, S as CommentStatus, T as CommentThread, _ as CommentListCursor, b as CommentMetadata, n as CommentActor, r as CommentAnchor, s as CommentContext, w as CommentSubject, y as CommentMessage } from "./types-BX3vH18p.js";
2
+ import { ViteHubContext } from "@vite-hub/runtime";
2
3
  /**
3
4
  * - `read`: see threads, join the presence room of a page, and get `@` suggestions.
4
5
  * - `write`: start threads and reply. Signed-in authors also edit and delete their own messages.
@@ -78,10 +79,19 @@ interface CommentsPeople {
78
79
  * People whose name contains `query`, with the fields that `canMention` reads. Comments returns only their `id`,
79
80
  * `name`, and `image`.
80
81
  */
81
- search: (query: string, limit: number) => Promise<CommentUser[]> | CommentUser[];
82
+ search: (query: string, limit: number, context: CommentsPeopleSearchContext) => Promise<CommentUser[]> | CommentUser[];
82
83
  /** The people with these ids, including fields that `authorize` reads. An id that is not a person is left out. */
83
84
  byIds: (ids: readonly string[]) => Promise<CommentUser[]> | CommentUser[];
84
85
  }
86
+ /** Where the person who types `@` writes, so `people.search` can look first among the people of that thread or subject. */
87
+ interface CommentsPeopleSearchContext {
88
+ /** The person who writes the message. */
89
+ user: CommentsUser | null;
90
+ /** The thread of the message. Not set for a new thread. */
91
+ thread?: CommentThread;
92
+ /** The subject of the thread, or of the new thread. */
93
+ subject?: CommentSubject;
94
+ }
85
95
  interface CommentsCanMentionContext {
86
96
  /** The person who writes the message. */
87
97
  user: CommentsUser | null;
@@ -105,6 +115,11 @@ interface CommentMessageEvent {
105
115
  message: CommentMessage;
106
116
  /** The people that the message mentions. */
107
117
  mentions: CommentUser[];
118
+ /**
119
+ * Keeps `promise` running after the answer, so slow work such as a webhook does not make the writer wait. It uses
120
+ * the host's `waitUntil` where there is one. A rejection is logged and never fails the comment.
121
+ */
122
+ waitUntil: (promise: Promise<unknown>) => void;
108
123
  }
109
124
  /** A file to attach, after Comments checked its size and type. */
110
125
  interface CommentsAttachmentFile {
@@ -153,7 +168,10 @@ interface CommentsDefinition {
153
168
  * answer, through `waitUntil` where the host has it. A failure is logged and never fails the comment.
154
169
  */
155
170
  onMention?: (event: CommentMentionEvent) => void | Promise<void>;
156
- /** Runs after each new thread and each reply saves, before the answer. Errors are logged, not returned. */
171
+ /**
172
+ * Runs after each new thread and each reply saves, before the answer. Give slow work to `event.waitUntil()` so the
173
+ * answer does not wait for it. Errors are logged, not returned.
174
+ */
157
175
  onComment?: (event: CommentMessageEvent) => void | Promise<void>;
158
176
  /**
159
177
  * Stores an uploaded file and returns its key, which messages keep in `attachments`. Without it, Comments stores the
@@ -203,4 +221,139 @@ declare function commentsRoleAllows(user: CommentsUser | null, action: CommentAc
203
221
  * who may, because any visitor may be able to sign up. On the page, only people signed in with GitHub get in.
204
222
  */
205
223
  declare function defaultPolicy(user: CommentsUser | null, gate?: CommentsPolicyGate, action?: CommentAction): boolean;
206
- export { commentsRoleAllows as _, CommentsAttachmentFile as a, validateCommentsDefinition as b, CommentsCanMentionContext as c, CommentsPeople as d, CommentsPolicyGate as f, CommentsUser as g, CommentsStoreAttachmentContext as h, CommentSubjectDefinition as i, CommentsDefinition as l, CommentsReadAttachmentContext as m, CommentMentionEvent as n, CommentsAuthorize as o, CommentsRateLimit as p, CommentMessageEvent as r, CommentsAuthorizeContext as s, CommentAction as t, CommentsGitHubAccess as u, defaultPolicy as v, defineCommentSubject as y };
224
+ interface CommentsForgeTarget {
225
+ repository: string;
226
+ pullRequest: number;
227
+ }
228
+ /**
229
+ * Posts each thread to the pull request of the build that served its page: one comment per message, and one summary
230
+ * comment that lists every thread. Credentials come from Server Env: a GitHub App (`VITEHUB_GITHUB_APP_ID` with
231
+ * `VITEHUB_GITHUB_PRIVATE_KEY`), else `VITEHUB_GITHUB_TOKEN`.
232
+ */
233
+ interface CommentsForgeOptions {
234
+ /** Only GitHub for now. */
235
+ provider: "github";
236
+ /** `owner/name`. Default: the repository of the build that served the thread's page. */
237
+ repository?: string;
238
+ /**
239
+ * The pull request of a thread. Default: the one the build names, else the open pull request whose head is the
240
+ * build's branch. Return `undefined` to keep the thread off GitHub.
241
+ */
242
+ pullRequest?: (thread: CommentThread) => number | undefined | Promise<number | undefined>;
243
+ /**
244
+ * The GitHub token of the person who wrote a message, such as the user token of their GitHub sign-in, so the
245
+ * comment posts as them. Without one, the GitHub App posts it with their name.
246
+ */
247
+ token?: (author: CommentUser) => string | undefined | Promise<string | undefined>;
248
+ /** The heading of the summary comment. Default `"Preview comments"`. */
249
+ title?: string;
250
+ /** GitHub Enterprise API base. Default `https://api.github.com`. */
251
+ apiUrl?: string;
252
+ fetch?: typeof fetch;
253
+ }
254
+ /**
255
+ * The request event of a Comments call: the Request of the Comments API, or the server event of an operation call.
256
+ * Read the request, its cookies, and the platform bindings from `event["~standard"]`. `context` is the H3 event
257
+ * context, when the call came through an H3 event.
258
+ */
259
+ type CommentsRequestEvent = ViteHubContext<{
260
+ context?: Record<string, unknown>;
261
+ }>;
262
+ interface CommentsIdentifyContext {
263
+ event: CommentsRequestEvent;
264
+ }
265
+ interface CommentsPageContext {
266
+ /** The page URL: the origin of the request and the normalized path, without query and hash. */
267
+ url: URL;
268
+ event: CommentsRequestEvent;
269
+ }
270
+ /** The subject of a page, and the version of the subject that new threads start on. */
271
+ interface CommentsPageSubject extends CommentSubject {
272
+ revision?: number;
273
+ }
274
+ interface DefineCommentsOptions extends CommentsDefinition {
275
+ /**
276
+ * Race the page tools session against rendering. Enable only if all tools and the account reader get equivalent
277
+ * inputs on the navigation and browser session request, and the host never caches the personalized HTML publicly.
278
+ * Default: false.
279
+ */
280
+ pageToolsSessionHandoff?: boolean;
281
+ /** Resolves the user of a request. Without it, Comments reads the ViteHub Auth session. Return `null` for anonymous. */
282
+ identify?: (context: CommentsIdentifyContext) => CommentsUser | null | undefined | Promise<CommentsUser | null | undefined>;
283
+ /** Name of the Database that stores comments. Defaults to the `default` Database, or the only one. */
284
+ database?: string;
285
+ /** Posts threads to the pull request that the page previews. */
286
+ forge?: CommentsForgeOptions;
287
+ /**
288
+ * The subject that the overlay comments on for a page, such as `{ kind: "drop", id, revision }`. The server decides:
289
+ * the overlay reads the subject from `/session`, and a new thread from the overlay must be on it. `authorize` still
290
+ * runs on the subject. Return `null` or `undefined` for the default, `{ kind: "page", id: url.pathname }`.
291
+ */
292
+ page?: (context: CommentsPageContext) => CommentsPageSubject | null | undefined | Promise<CommentsPageSubject | null | undefined>;
293
+ }
294
+ interface ListCommentThreadsOptions {
295
+ subject?: CommentSubject;
296
+ /** Only threads about this kind of subject, across all its ids. */
297
+ subjectKind?: string;
298
+ /** An app path. The same as a `page` subject. */
299
+ page?: string;
300
+ /** Only the threads of this numbering scope, such as `site`. */
301
+ scope?: string;
302
+ status?: CommentStatus;
303
+ /** Only threads started on this version of the subject or an earlier one. */
304
+ revision?: {
305
+ lte: number;
306
+ };
307
+ /** Newest activity first. Default 200, at most 500. */
308
+ limit?: number;
309
+ /** Where the next page starts: the `updatedAt` and `id` of the last thread of the page before. */
310
+ before?: CommentListCursor;
311
+ }
312
+ interface CreateCommentThreadInput {
313
+ /** What the thread is about. Or set `page`. */
314
+ subject?: CommentSubject;
315
+ /** An app path, for a thread on a page. The same as `subject: { kind: "page", id: page }`. */
316
+ page?: string;
317
+ /** Default `{ kind: "page" }`. */
318
+ anchor?: CommentAnchor;
319
+ context?: CommentContext;
320
+ metadata?: CommentMetadata;
321
+ /** The version of the subject, such as a document version. */
322
+ revision?: number;
323
+ /** A retry key. A second create with the same key and author in the same scope returns the first thread. */
324
+ requestId?: string;
325
+ body: string;
326
+ author: CommentUser;
327
+ /** Ids of the people that `body` names with `@`. */
328
+ mentions?: string[];
329
+ attachments?: string[];
330
+ }
331
+ interface EditCommentInput {
332
+ body: string;
333
+ /** Replaces the mentions. Default: none. */
334
+ mentions?: string[];
335
+ }
336
+ interface ReplyInput {
337
+ body: string;
338
+ author: CommentUser;
339
+ /** The agent replying on behalf of the author. */
340
+ actor?: CommentActor;
341
+ mentions?: string[];
342
+ attachments?: string[];
343
+ /** A retry key. A second reply with the same key and author in the same thread returns the first message. */
344
+ requestId?: string;
345
+ }
346
+ interface FindCommentThreadInput {
347
+ /** The subject that the create named. Or set `page`. */
348
+ subject?: CommentSubject;
349
+ /** An app path, for a thread on a page. */
350
+ page?: string;
351
+ requestId: string;
352
+ }
353
+ interface ReplyOptions {
354
+ /** Reply to a resolved thread, and keep it resolved. Default `false`: the reply fails with `COMMENTS_RESOLVED`. */
355
+ allowResolved?: boolean;
356
+ }
357
+ /** Codes of the errors that Comments methods return in the `[error, data]` tuple. */
358
+ type CommentsErrorCode = "COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND" | "COMMENTS_INVALID_INPUT" | "COMMENTS_FORBIDDEN" | "COMMENTS_POLICY_MISSING" | "COMMENTS_RESOLVED" | "COMMENTS_CONTENT_MISSING" | "COMMENTS_FIELD_INVALID" | "COMMENTS_FIELD_NOT_EDITABLE" | "COMMENTS_FIELD_FORBIDDEN" | "COMMENTS_FIELD_CONFLICT" | "COMMENTS_FIELD_LOCKED";
359
+ export { CommentsStoreAttachmentContext as A, CommentsDefinition as C, CommentsPolicyGate as D, CommentsPeopleSearchContext as E, validateCommentsDefinition as F, commentsRoleAllows as M, defaultPolicy as N, CommentsRateLimit as O, defineCommentSubject as P, CommentsCanMentionContext as S, CommentsPeople as T, CommentMessageEvent as _, CommentsPageContext as a, CommentsAuthorize as b, CreateCommentThreadInput as c, FindCommentThreadInput as d, ListCommentThreadsOptions as f, CommentMentionEvent as g, CommentAction as h, CommentsIdentifyContext as i, CommentsUser as j, CommentsReadAttachmentContext as k, DefineCommentsOptions as l, ReplyOptions as m, CommentsForgeOptions as n, CommentsPageSubject as o, ReplyInput as p, CommentsForgeTarget as r, CommentsRequestEvent as s, CommentsErrorCode as t, EditCommentInput as u, CommentSubjectDefinition as v, CommentsGitHubAccess as w, CommentsAuthorizeContext as x, CommentsAttachmentFile as y };
package/dist/vite.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { a as CommentBuild } from "./types-BX3vH18p.js";
2
2
  import { n as OperationContributions } from "./operations-DFLer1fR.js";
3
3
  import { i as ViteHubInspectionPluginMetadata, r as ViteHubConsoleRuntimeRecordTableSection, t as ViteHubConsoleOperationSection } from "./console-CCLX_eIk.js";
4
- import "./types-l6GOb_yc.js";
5
- import { n as mountedCommentsRoute } from "./page-DE71P_gQ.js";
4
+ import "./types-qzJKgWYS.js";
5
+ import { s as mountedCommentsRoute } from "./page-BgvzzsJb.js";
6
6
  import { Plugin, PluginOption } from "vite";
7
7
  import { githubRepository } from "@vite-hub/forge/build/node";
8
8
  import { DatabaseContributionContext, DatabaseContributionEntry } from "@vite-hub/database/vite";
@@ -68,8 +68,6 @@ interface CommentsImports {
68
68
  blob: string;
69
69
  /** Exports `checkRateLimit`, which counts guest writes when Rate Limit counts in a shared KV store. */
70
70
  rateLimit: string;
71
- /** `@vite-hub/webhooks`: the member endpoints that `defineComments({ send })` delivers to. */
72
- webhooks: string;
73
71
  }
74
72
  /** Options of `comments()`, for apps that use Comments without `vite-hub`. */
75
73
  interface CommentsOptions {
@@ -172,15 +170,6 @@ type CommentsVitePlugin$1 = Plugin & {
172
170
  };
173
171
  vitehub: ViteHubInspectionPluginMetadata & {
174
172
  databases: (context: DatabaseContributionContext) => Promise<DatabaseContributionEntry[]>;
175
- /** Turns on the member endpoints of Webhooks while `defineComments({ send })` is on. */
176
- webhooks: (context: {
177
- root?: string;
178
- projectRoot?: string;
179
- serverDirs?: readonly string[];
180
- }) => Promise<{
181
- memberEndpoints: true;
182
- reason: string;
183
- } | undefined>;
184
173
  };
185
174
  };
186
175
  /**
@@ -188,11 +177,6 @@ type CommentsVitePlugin$1 = Plugin & {
188
177
  * default or only Database.
189
178
  */
190
179
  export declare function readCommentsDatabase(file: string): Promise<string | undefined>;
191
- /**
192
- * Whether `defineComments({ send })` turns Send on, read without running the file: Send is on unless `send` is missing
193
- * or `false`. A value known only at runtime counts as on, so the build adds the tables and the member endpoints.
194
- */
195
- export declare function readCommentsSend(file: string): Promise<boolean>;
196
180
  /** The directory of the prebuilt overlay script in this package. */
197
181
  export declare function commentsOverlayDirectory(): string;
198
182
  /**
@@ -229,7 +213,6 @@ export declare function renderCommentsPlugin(input: {
229
213
  development?: boolean;
230
214
  build?: CommentBuild;
231
215
  base?: string;
232
- send?: boolean;
233
216
  realtime?: boolean;
234
217
  }): string;
235
218
  /**
package/dist/vite.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { t as invariant } from "./invariant-CmdvZ3vp.js";
2
- import { c as validateCommentsDefinition } from "./define-BqPcuDhf.js";
3
- import { t as commentsErrorDiagnostics } from "./errors-CBvIpwbo.js";
4
- import { a as viteHubPageToolsCookie, d as viteHubPageToolsQuery, i as viteHubPageToolsAssets, n as viteHubBasePath, r as viteHubPageSessionPath, s as viteHubPageToolsInlineScript } from "./page-tools-shared-BNw-aWEH.js";
2
+ import { c as validateCommentsDefinition } from "./define-C-LUOouq.js";
3
+ import { t as commentsErrorDiagnostics } from "./errors-DeSEHzRf.js";
4
+ import { a as viteHubPageSessionPath, l as viteHubPageToolsInlineScript, o as viteHubPageToolsAssets, p as viteHubPageToolsQuery, r as viteHubBasePath, s as viteHubPageToolsCookie } from "./page-tools-shared-BCdvqA4S.js";
5
5
  import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
6
- import { a as commentsRealtimeDefinition, o as commentsRoute, r as commentsNoticeDefinition, s as mountedCommentsRoute } from "./page-2NzFladc.js";
7
- import { n as commentsTableNames, t as commentSendsTableNames } from "./table-names-BIHjuEFK.js";
6
+ import { f as mountedCommentsRoute, i as commentsNoticeDefinition, o as commentsRealtimeDefinition, s as commentsRoute } from "./page-CDhmXO-y.js";
7
+ import { t as commentsTableNames } from "./table-names-DUmWROM4.js";
8
8
  import { formatDiagnostic } from "nostics";
9
9
  import { existsSync, mkdirSync, statSync, writeFileSync } from "node:fs";
10
10
  import { tmpdir } from "node:os";
@@ -313,7 +313,7 @@ function addViteHubPageToolRoutes(kit, options) {
313
313
  });
314
314
  kit.config.publicAssets = assets;
315
315
  }
316
- function readString(value, key) {
316
+ function readStringField(value, key) {
317
317
  const field = value !== null && typeof value === "object" ? Reflect.get(value, key) : void 0;
318
318
  return typeof field === "string" ? field : void 0;
319
319
  }
@@ -324,16 +324,16 @@ function readString(value, key) {
324
324
  * `nitro.baseURL`, else `NITRO_APP_BASE_URL`.
325
325
  */
326
326
  function viteHubPageToolsBase(config, env = process.env) {
327
- const defined = readString(config !== null && typeof config === "object" ? Reflect.get(config, "define") : void 0, "__VITEHUB_APP_BASE_URL__");
328
- const viteBase = readString(config, "base");
327
+ const defined = readStringField(config !== null && typeof config === "object" ? Reflect.get(config, "define") : void 0, "__VITEHUB_APP_BASE_URL__");
328
+ const viteBase = readStringField(config, "base");
329
329
  let appBase = viteBase?.startsWith("/") && !viteBase.startsWith("//") ? viteBase : void 0;
330
330
  if (defined) try {
331
331
  const value = JSON.parse(defined);
332
332
  if (typeof value === "string") appBase = value;
333
333
  } catch {}
334
- const base = viteHubBasePath(readString(config, "__vitehubAppBaseURL") ?? appBase);
334
+ const base = viteHubBasePath(readStringField(config, "__vitehubAppBaseURL") ?? appBase);
335
335
  const nitro = config !== null && typeof config === "object" ? Reflect.get(config, "nitro") : void 0;
336
- const nitroBase = viteHubBasePath(readString(nitro, "baseURL") ?? env.NITRO_APP_BASE_URL);
336
+ const nitroBase = viteHubBasePath(readStringField(nitro, "baseURL") ?? env.NITRO_APP_BASE_URL);
337
337
  return {
338
338
  base,
339
339
  mount: nitroBase && (base === nitroBase || base.startsWith(`${nitroBase}/`)) ? base.slice(nitroBase.length) : base
@@ -733,8 +733,7 @@ const defaultImports = {
733
733
  contentClient: "@vite-hub/content/client",
734
734
  connect: "@vite-hub/comments/runtime/connect",
735
735
  blob: "@vite-hub/blob",
736
- rateLimit: "@vite-hub/rate-limit",
737
- webhooks: "@vite-hub/webhooks"
736
+ rateLimit: "@vite-hub/rate-limit"
738
737
  };
739
738
  function literalProperties(options) {
740
739
  return objectProperties(options).flatMap((property) => {
@@ -810,17 +809,6 @@ async function readCommentsDatabase(file) {
810
809
  if (found === null || found.value !== void 0 && typeof found.value !== "string") throw commentsErrorDiagnostics.COMMENTS_B0004({ file });
811
810
  return typeof found.value === "string" ? found.value : void 0;
812
811
  }
813
- /**
814
- * Whether `defineComments({ send })` turns Send on, read without running the file: Send is on unless `send` is missing
815
- * or `false`. A value known only at runtime counts as on, so the build adds the tables and the member endpoints.
816
- */
817
- async function readCommentsSend(file) {
818
- const properties = await readDefinitionProperties(file);
819
- if (!properties) return true;
820
- const found = lastProperty(properties, "send");
821
- if (found === void 0) return properties.some((property) => property.key === void 0);
822
- return found === null || found.value !== false && found.value !== void 0 && found.value !== null;
823
- }
824
812
  /** A directory of prebuilt browser scripts in this package. */
825
813
  function builtDirectory(name) {
826
814
  const here = dirname(fileURLToPath(import.meta.url));
@@ -996,7 +984,6 @@ function renderCommentsPlugin(input) {
996
984
  ...input.session?.blob ? ["attachments: blob"] : [],
997
985
  ...input.session?.rateLimit ? ["rateLimit: checkRateLimit"] : [],
998
986
  ...postgres ? ["dialect: \"postgresql\"", "tables: { commentCounters: schema.vitehubCommentCounters, commentMessages: schema.vitehubCommentMessages, commentThreads: schema.vitehubCommentThreads, commentForge: schema.vitehubCommentForge }"] : [],
999
- ...input.send ? [`webhooks: () => import(${JSON.stringify(input.imports.webhooks)})`] : [],
1000
987
  ...realtime ? [realtime] : [],
1001
988
  `development: ${input.development === true}`,
1002
989
  `overlay: ${overlay}`,
@@ -1260,7 +1247,6 @@ function hubComments$1(options = {}) {
1260
1247
  if (!definition && !options.enabled) return [];
1261
1248
  const database = options.database ?? (definition ? await readCommentsDatabase(definition) : void 0);
1262
1249
  const postgres = options.dialect === "postgresql";
1263
- const send = !postgres && definition !== void 0 && await readCommentsSend(definition);
1264
1250
  return [{
1265
1251
  ...database ? { database } : {},
1266
1252
  definition: postgres ? {
@@ -1274,25 +1260,7 @@ function hubComments$1(options = {}) {
1274
1260
  tables: commentsTableNames,
1275
1261
  name: "comments",
1276
1262
  reason: definition ? "Stores the comment threads of `server/comments.ts`." : "Stores the comment threads of `vitehub({ comments })`."
1277
- }, ...send ? [{
1278
- ...database ? { database } : {},
1279
- definition: {
1280
- export: "commentSendsSchema",
1281
- module: imports.database
1282
- },
1283
- dialect: "sqlite",
1284
- tables: commentSendsTableNames,
1285
- name: "comment-sends",
1286
- reason: "Keeps the sends and setup codes of `defineComments({ send })`."
1287
- }] : []];
1288
- },
1289
- async webhooks(context) {
1290
- if (options.standalone) return void 0;
1291
- const definition = findCommentsEntry$2(projectRoot ?? context.projectRoot ?? context.root ?? process.cwd(), serverDirs ?? context.serverDirs?.slice());
1292
- return definition && await readCommentsSend(definition) ? {
1293
- memberEndpoints: true,
1294
- reason: "Send hands each member's waiting comments to their own agent."
1295
- } : void 0;
1263
+ }];
1296
1264
  }
1297
1265
  },
1298
1266
  enforce: "pre",
@@ -1332,8 +1300,7 @@ function hubComments$1(options = {}) {
1332
1300
  build,
1333
1301
  base,
1334
1302
  development,
1335
- realtime,
1336
- send: !options.standalone && await readCommentsSend(definition)
1303
+ realtime
1337
1304
  };
1338
1305
  await Promise.all([
1339
1306
  writeFile(handler, renderCommentsHandler({
@@ -1356,6 +1323,7 @@ function hubComments$1(options = {}) {
1356
1323
  meta: { ...ownAccessRouteMeta },
1357
1324
  route: `${mount}${commentsRoute}/**`
1358
1325
  });
1326
+ kit.addPlugin(ownModule(import.meta.url, "runtime/client-request-plugin"), "start");
1359
1327
  kit.addPlugin(plugin);
1360
1328
  addViteHubPageToolRoutes(kit, {
1361
1329
  handler: pageToolsRoute,
@@ -1803,10 +1771,6 @@ function hubComments(options = {}) {
1803
1771
  logLevel: "silent"
1804
1772
  });
1805
1773
  validateCommentsDefinition(module.comments ?? module.default, display);
1806
- if (await readCommentsSend(entry)) {
1807
- if (liveOptions.dialect === "postgresql") throw commentsErrorDiagnostics.COMMENTS_SEND_POSTGRES();
1808
- if (!resolved.plugins.some((plugin) => plugin.name === "@vite-hub/webhooks/vite")) throw commentsErrorDiagnostics.COMMENTS_SEND_WEBHOOKS_OFF({ file: display });
1809
- }
1810
1774
  },
1811
1775
  vitehub: {
1812
1776
  ...live.vitehub,
@@ -1821,4 +1785,4 @@ function hubComments(options = {}) {
1821
1785
  }
1822
1786
  };
1823
1787
  }
1824
- export { COMMENTS_VITE_PLUGIN_NAME, comments, comments as default, commentsConsoleSection, commentsConsoleSection$1 as commentsOperationsConsoleSection, commentsOverlayDirectory, componentNames, findCommentsEntry, githubRepository, hubComments, injectLoader, loaderTag, loaderUrl, mountPath, mountedCommentsRoute, overlayRoute, readCommentsBuild, readCommentsComponents, readCommentsDatabase, readCommentsSend, renderCommentsHandler, renderCommentsPlugin, renderOverlayMiddleware, scriptNonce, usesComments };
1788
+ export { COMMENTS_VITE_PLUGIN_NAME, comments, comments as default, commentsConsoleSection, commentsConsoleSection$1 as commentsOperationsConsoleSection, commentsOverlayDirectory, componentNames, findCommentsEntry, githubRepository, hubComments, injectLoader, loaderTag, loaderUrl, mountPath, mountedCommentsRoute, overlayRoute, readCommentsBuild, readCommentsComponents, readCommentsDatabase, renderCommentsHandler, renderCommentsPlugin, renderOverlayMiddleware, scriptNonce, usesComments };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/comments",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Comments and in-place edits on live ViteHub sites, with presence and Content drafts.",
5
5
  "keywords": [
6
6
  "annotations",
@@ -106,10 +106,10 @@
106
106
  "@valibot/to-json-schema": "^1.8.0",
107
107
  "nostics": "1.4.0",
108
108
  "valibot": "^1.5.0",
109
- "@vite-hub/auth": "0.7.0",
110
- "@vite-hub/forge": "0.7.0",
111
- "@vite-hub/realtime": "0.7.0",
112
- "@vite-hub/runtime": "0.7.0",
109
+ "@vite-hub/auth": "0.8.0",
110
+ "@vite-hub/forge": "0.8.0",
111
+ "@vite-hub/realtime": "0.8.0",
112
+ "@vite-hub/runtime": "0.8.0",
113
113
  "birpc": "^4.2.0",
114
114
  "confbox": "^0.3.2",
115
115
  "h3": "^2.0.8"
@@ -129,12 +129,12 @@
129
129
  "vitest": "5.1.0",
130
130
  "vue": "3.5.46",
131
131
  "@libsql/client": "^0.18.0",
132
- "@vite-hub/database": "0.7.0",
132
+ "@vite-hub/database": "0.8.0",
133
133
  "vite": "^8.3.8",
134
134
  "drizzle-orm": "1.0.0-rc.6"
135
135
  },
136
136
  "peerDependencies": {
137
- "@vite-hub/database": "0.7.0",
137
+ "@vite-hub/database": "0.8.0",
138
138
  "nitro": "3.0.261102-rc || ^3.0.261103-rc",
139
139
  "vite": ">=8.0.0",
140
140
  "drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0"
@@ -152,6 +152,6 @@
152
152
  "dev": "vp pack && vp build --config overlay.vite.config.ts && vp pack --watch --no-clean",
153
153
  "typecheck": "vp run --cache -t @vite-hub/comments#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
154
154
  "test": "vp run --cache -t @vite-hub/comments#build && vp test",
155
- "test:browser": "vp run --cache -t @vite-hub/comments#build && node --test test/browser/overlay.browser.mjs test/browser/hosted.browser.mjs test/browser/presence.browser.mjs test/browser/outbox.browser.mjs test/browser/send.browser.mjs test/browser/controls.browser.mjs"
155
+ "test:browser": "vp run --cache -t @vite-hub/comments#build && node --test test/browser/overlay.browser.mjs test/browser/hosted.browser.mjs test/browser/presence.browser.mjs test/browser/outbox.browser.mjs test/browser/controls.browser.mjs"
156
156
  }
157
157
  }