@vite-hub/comments 0.5.0 → 0.6.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 (85) hide show
  1. package/README.md +7 -1
  2. package/dist/anchor.d.ts +3 -5
  3. package/dist/anchor.js +1 -2
  4. package/dist/{client-diagnostics-Bubm7Shd.js → client-diagnostics-CvfTW5d4.js} +1 -2
  5. package/dist/{client-files-CJZl5Kc4.js → client-files-lC6X7XyS.js} +1 -2
  6. package/dist/client.d.ts +44 -25
  7. package/dist/client.js +64 -43
  8. package/dist/{console-D1lwNMZn.d.ts → console-CCLX_eIk.d.ts} +1 -5
  9. package/dist/{context-BqIsmYP1.js → context-DbkBjITZ.js} +1 -2
  10. package/dist/database/postgres.d.ts +1 -3
  11. package/dist/database/postgres.js +1 -2
  12. package/dist/{database-6hXRnqDE.js → database-BkPoOdZr.js} +73 -61
  13. package/dist/{database-CTo7mx6t.d.ts → database-CPua6Q6_.d.ts} +0 -2
  14. package/dist/{database-CA1aHKN7.d.ts → database-DUs3c2al.d.ts} +625 -73
  15. package/dist/database.d.ts +4 -6
  16. package/dist/database.js +1 -2
  17. package/dist/{define-CmIFU96x.d.ts → define-B1jLSPe9.d.ts} +1 -3
  18. package/dist/{define-BMBSVbD9.js → define-BCxNaSZv.js} +3 -4
  19. package/dist/{errors-BJTZ9iyv.js → errors-C0VwRHiy.js} +1 -2
  20. package/dist/{errors-Dq4AHjza.js → errors-DFNiJg67.js} +10 -3
  21. package/dist/{fold-name-B7Zb3-MF.js → fold-name-g-xg0mQk.js} +1 -2
  22. package/dist/hosted/hosted-comments/client-B3dlmmQd.js +4 -0
  23. package/dist/{overlay/dist-BoHMOFax.js → hosted/hosted-comments/dist-DyVmH21U.js} +1 -1
  24. package/dist/hosted/hosted-comments/frame.js +1 -0
  25. package/dist/hosted/hosted-comments/overlay-CFuq5QAH.js +182 -0
  26. package/dist/hosted/hosted-comments/protocol-BHvtQKte.js +1 -0
  27. package/dist/hosted/hosted-comments/rest-transport-D-9_pNqZ.js +1 -0
  28. package/dist/hosted/hosted-comments/tools-Bz--joZw.js +126 -0
  29. package/dist/hosted/hosted-comments.js +9 -0
  30. package/dist/{identity-CBOzgxSf.js → identity-CT7-UGmS.js} +1 -2
  31. package/dist/{index-RiHzmV16.d.ts → index-D1T7RJ4R.d.ts} +10 -15
  32. package/dist/index.d.ts +5 -5
  33. package/dist/index.js +8 -9
  34. package/dist/{install-BGGQKbQ4.d.ts → install-NehuMNhG.d.ts} +19 -8
  35. package/dist/{install-DrAse1Fa.js → install-w6CCgGFV.js} +158 -45
  36. package/dist/{installed-C3EoqJEY.js → installed-C9SkldMi.js} +2 -3
  37. package/dist/{invariant-D8_xBqmZ.js → invariant-CmdvZ3vp.js} +1 -2
  38. package/dist/{migrate-B0k_0swk.d.ts → migrate-XjFeQppf.d.ts} +2 -2
  39. package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
  40. package/dist/{operations-VyyNZusz.d.ts → operations-8hqTi0DH.d.ts} +0 -2
  41. package/dist/{operations-lsVKE0GH.js → operations-B8IMhRmY.js} +18 -20
  42. package/dist/{operations-BKhUWYkb.d.ts → operations-Cic9A9e_.d.ts} +4 -6
  43. package/dist/operations.d.ts +2 -2
  44. package/dist/operations.js +2 -2
  45. package/dist/overlay/{client-DBmJ4C1M.js → client-CerbVjTz.js} +3 -3
  46. package/dist/overlay/dist-DyVmH21U.js +14 -0
  47. package/dist/overlay/overlay.js +28 -16
  48. package/dist/page/loader.js +22 -21
  49. package/dist/{page-Bzj0CszG.d.ts → page-DE71P_gQ.d.ts} +0 -2
  50. package/dist/{page-tools-shared-BNnuPK93.js → page-tools-shared-fvmJQCrP.js} +2 -2
  51. package/dist/{page-DRz_sDY4.js → page-xzgZ6DGm.js} +2 -3
  52. package/dist/{path--zk6PEMz.js → path-8yqMd8zR.js} +0 -1
  53. package/dist/{plugin-DRsNaJaK.js → plugin-DbCYT7Ac.js} +14 -11
  54. package/dist/realtime.d.ts +3 -5
  55. package/dist/realtime.js +4 -5
  56. package/dist/{reply-id-P_bSuEng.js → reply-id-Cm9FGOBs.js} +1 -2
  57. package/dist/{request-log-Dj9Vw7qG.js → request-log-DllKQXj7.js} +1 -2
  58. package/dist/{request-origin-CFU0TQ7E.js → request-origin-YPzfE2eh.js} +1 -2
  59. package/dist/{rpc-BQqYx8kb.js → rpc-BKY7XRlR.js} +5 -7
  60. package/dist/{rpc-CuJ5GLIz.d.ts → rpc-D-eqtyfh.d.ts} +1 -3
  61. package/dist/rpc.d.ts +1 -1
  62. package/dist/rpc.js +1 -2
  63. package/dist/runtime/auth.d.ts +3 -5
  64. package/dist/runtime/auth.js +2 -3
  65. package/dist/runtime/console.d.ts +2 -4
  66. package/dist/runtime/console.js +4 -5
  67. package/dist/runtime/index.d.ts +45 -32
  68. package/dist/runtime/index.js +27 -26
  69. package/dist/{server-Yk610niJ.js → server-BGbD7H5s.js} +2 -3
  70. package/dist/server.d.ts +6 -8
  71. package/dist/server.js +6 -6
  72. package/dist/{service-Bj-Mg63c.d.ts → service-CPiWPoiY.d.ts} +3 -7
  73. package/dist/{service-DA5BwfPQ.js → service-DUh2uGd2.js} +9 -11
  74. package/dist/{session-DUcEor2W.d.ts → session-CN4irEqf.d.ts} +3 -5
  75. package/dist/{session-X_g9dnU5.js → session-_1GY5gaG.js} +30 -18
  76. package/dist/{store-CsUNfC1w.d.ts → store-DvNTDNgn.d.ts} +2 -4
  77. package/dist/{table-names-B9LlRC0B.js → table-names-BIHjuEFK.js} +1 -2
  78. package/dist/testing.d.ts +2 -4
  79. package/dist/testing.js +3 -4
  80. package/dist/{tokens-DSbwkVSy.js → tokens-Bx4lZ0yt.js} +3 -6
  81. package/dist/{types-BLaYh0_f.d.ts → types-BX3vH18p.d.ts} +0 -2
  82. package/dist/{types-C35INXIs.d.ts → types-l6GOb_yc.d.ts} +2 -4
  83. package/dist/vite.d.ts +22 -22
  84. package/dist/vite.js +40 -45
  85. package/package.json +19 -19
@@ -1,7 +1,6 @@
1
- import { D as CommentUser, S as CommentStatus, T as CommentThread, b as CommentMetadata, n as CommentActor, r as CommentAnchor, s as CommentContext, v as CommentListQuery, w as CommentSubject } from "./types-BLaYh0_f.js";
2
- import { i as commentThreads, r as commentMessages, t as commentCounters } from "./database-CA1aHKN7.js";
1
+ import { a as commentThreads, i as commentMessages, n as commentCounters } from "./database-DUs3c2al.js";
2
+ import { D as CommentUser, S as CommentStatus, T as CommentThread, b as CommentMetadata, n as CommentActor, r as CommentAnchor, s as CommentContext, v as CommentListQuery, w as CommentSubject } from "./types-BX3vH18p.js";
3
3
  import { LibSQLDatabase } from "drizzle-orm/libsql";
4
- //#region src/operations-core/store.d.ts
5
4
  /**
6
5
  * The Drizzle database that the store uses. The store calls `select`, `insert`, `update`, and `delete` (with
7
6
  * `onConflictDoNothing()` and `returning()`), which SQLite, libSQL, D1, and Postgres Drizzle databases all offer, and
@@ -93,5 +92,4 @@ interface CommentsStore {
93
92
  knownUsersByIds: (ids: readonly string[], canRead: (thread: CommentThread) => Promise<boolean>) => Promise<CommentUser[]>;
94
93
  }
95
94
  declare function createCommentsStore(database: CommentsDatabase, tables?: CommentsTables): CommentsStore;
96
- //#endregion
97
95
  export { createCommentsStore as i, CommentsStore as n, CommentsTables as r, CommentsDatabase as t };
@@ -1,4 +1,4 @@
1
- //#region src/table-names.ts
1
+ // src/table-names.ts
2
2
  /**
3
3
  * The tables of `commentsSchema` and `commentsPostgresSchema`: each schema key and its SQL name. The Comments
4
4
  * contribution gives them to the Database, so resolving the Vite config loads neither the schema nor drizzle-orm. A
@@ -12,5 +12,4 @@ const commentsTableNames = {
12
12
  };
13
13
  /** The tables of `commentSendsSchema`: each schema key and its SQL name. Comments adds them when `send` is on. */
14
14
  const commentSendsTableNames = { commentSends: "vitehub_comment_sends" };
15
- //#endregion
16
15
  export { commentsTableNames as n, commentSendsTableNames as t };
package/dist/testing.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { D as CommentUser, T as CommentThread, k as CommentsTransport, w as CommentSubject } from "./types-BLaYh0_f.js";
2
- //#region src/operations-core/testing.d.ts
1
+ import { D as CommentUser, T as CommentThread, k as CommentsTransport, w as CommentSubject } from "./types-BX3vH18p.js";
3
2
  export interface MemoryTransportOptions {
4
3
  /** The signed-in user. Every call acts as this user. */
5
4
  user: CommentUser;
@@ -26,5 +25,4 @@ export interface MemoryTransport extends CommentsTransport {
26
25
  * before the server half exists. It follows the access rules of the real operations: authors edit
27
26
  * and delete their own messages, and everyone can resolve.
28
27
  */
29
- export declare function createMemoryTransport(options: MemoryTransportOptions): MemoryTransport;
30
- //#endregion
28
+ export declare function createMemoryTransport(options: MemoryTransportOptions): MemoryTransport;
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
- import { t as replyMessageId } from "./reply-id-P_bSuEng.js";
2
- import { t as commentsErrorDiagnostics } from "./errors-Dq4AHjza.js";
3
- //#region src/operations-core/testing.ts
1
+ import { t as replyMessageId } from "./reply-id-Cm9FGOBs.js";
2
+ import { t as commentsErrorDiagnostics } from "./errors-DFNiJg67.js";
3
+ // src/operations-core/testing.ts
4
4
  function checkOutboxAccount(input, user) {
5
5
  if (input.outbox && input.outbox.account !== user.id) throw Object.assign(commentsErrorDiagnostics.COMMENTS_OUTBOX_ACCOUNT_CHANGED(), { status: 401 });
6
6
  }
@@ -216,5 +216,4 @@ function view(store, user) {
216
216
  }
217
217
  };
218
218
  }
219
- //#endregion
220
219
  export { createMemoryTransport };
@@ -1,5 +1,5 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- //#region ../internal/src/runtime/cloudflare-env-lookup.ts
2
+ // ../internal/src/runtime/cloudflare-env-lookup.ts
3
3
  /** The key of the AsyncLocalStorage store on `globalThis`. Every bundled copy of this module shares the store. */
4
4
  const activeEnvStorageKey = Symbol.for("vitehub.cloudflare.env-storage");
5
5
  let activeEnv;
@@ -13,8 +13,7 @@ function getActiveCloudflareEnv() {
13
13
  const host = globalThis;
14
14
  return Object.hasOwn(host, "__env__") && host.__env__ !== void 0 ? host.__env__ : activeEnv;
15
15
  }
16
- //#endregion
17
- //#region ../internal/src/runtime/cloudflare-env.ts
16
+ // ../internal/src/runtime/cloudflare-env.ts
18
17
  const runtimeGlobal = globalThis;
19
18
  const activeEnvStorage = runtimeGlobal[activeEnvStorageKey] ||= new AsyncLocalStorage();
20
19
  function runWithActiveCloudflareEnv(env, callback) {
@@ -24,8 +23,7 @@ function getActiveCloudflareBinding(name) {
24
23
  const env = getActiveCloudflareEnv();
25
24
  return env && Object.hasOwn(env, name) ? env[name] : void 0;
26
25
  }
27
- //#endregion
28
- //#region src/forge/tokens.ts
26
+ // src/forge/tokens.ts
29
27
  /** How long the GitHub token of a person's last request stays usable for the pull request sync that it started. */
30
28
  const tokenLifetime = 6e5;
31
29
  const tokens = /* @__PURE__ */ new Map();
@@ -54,5 +52,4 @@ function recentGitHubToken(authorId) {
54
52
  function forgetGitHubToken(authorId) {
55
53
  tokens.delete(authorId);
56
54
  }
57
- //#endregion
58
55
  export { runWithActiveCloudflareEnv as a, getActiveCloudflareBinding as i, recentGitHubToken as n, rememberGitHubToken as r, forgetGitHubToken as t };
@@ -1,4 +1,3 @@
1
- //#region src/operations-core/types.d.ts
2
1
  /** A person. The signed-in user and every author have this shape. */
3
2
  interface CommentUser {
4
3
  id: string;
@@ -362,5 +361,4 @@ interface CommentsTransport {
362
361
  /** Live updates, such as Realtime. Without it the client refreshes when the window gets focus. */
363
362
  subscribe?: (listener: (event: CommentEvent) => void) => () => void;
364
363
  }
365
- //#endregion
366
364
  export { ElementAnchor as A, CommentStatusInput as C, CommentUser as D, CommentUploadInput as E, PageAnchor as M, TextAnchor as N, CommentUsersInput as O, CommentStatus as S, CommentThread as T, CommentListCursor as _, CommentBuild as a, CommentMetadata as b, CommentCreateInput as c, CommentDeliveryError as d, CommentEditInput as f, CommentGetInput as g, CommentForgeLink as h, CommentAttachment as i, ImageAnchor as j, CommentsTransport as k, CommentDeleteInput as l, CommentFiles as m, CommentActor as n, CommentComponent as o, CommentEvent as p, CommentAnchor as r, CommentContext as s, AreaAnchor as t, CommentDelivery as u, CommentListQuery as v, CommentSubject as w, CommentReplyInput as x, CommentMessage as y };
@@ -1,7 +1,6 @@
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 } from "./types-BLaYh0_f.js";
2
- import { g as CommentsUser, l as CommentsDefinition } from "./define-CmIFU96x.js";
1
+ import { g as CommentsUser, l as CommentsDefinition } from "./define-B1jLSPe9.js";
2
+ 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 } from "./types-BX3vH18p.js";
3
3
  import { ViteHubContext } from "@vite-hub/runtime";
4
- //#region src/types.d.ts
5
4
  interface CommentsForgeTarget {
6
5
  repository: string;
7
6
  pullRequest: number;
@@ -204,5 +203,4 @@ interface ReplyOptions {
204
203
  }
205
204
  /** Codes of the errors that Comments methods return in the `[error, data]` tuple. */
206
205
  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" | "COMMENTS_SEND_OFF";
207
- //#endregion
208
206
  export { ListCommentThreadsOptions as _, CommentSendPromptContext as a, CommentsForgeTarget as c, CommentsPageSubject as d, CommentsRequestEvent as f, FindCommentThreadInput as g, EditCommentInput as h, CommentSendPayloadContext as i, CommentsIdentifyContext as l, DefineCommentsOptions as m, CommentSendData as n, CommentsErrorCode as o, CreateCommentThreadInput as p, CommentSendOptions as r, CommentsForgeOptions as s, CommentSendAddressContext as t, CommentsPageContext as u, ReplyInput as v, ReplyOptions as y };
package/dist/vite.d.ts CHANGED
@@ -1,13 +1,12 @@
1
- import { a as CommentBuild } from "./types-BLaYh0_f.js";
2
- import "./types-C35INXIs.js";
3
- import { n as mountedCommentsRoute } from "./page-Bzj0CszG.js";
4
- import { n as OperationContributions } from "./operations-VyyNZusz.js";
5
- import { i as ViteHubInspectionPluginMetadata, r as ViteHubConsoleRuntimeRecordTableSection, t as ViteHubConsoleOperationSection } from "./console-D1lwNMZn.js";
1
+ import { a as CommentBuild } from "./types-BX3vH18p.js";
2
+ import { n as OperationContributions } from "./operations-8hqTi0DH.js";
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";
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";
9
9
  import { NitroModule } from "nitro/types";
10
- //#region src/console.d.ts
11
10
  /**
12
11
  * Console section for Comments: every thread with its first comment, page, author, replies, and status, open threads
13
12
  * first. People reply and resolve on the page itself, where the context is; each record links there. The
@@ -17,12 +16,8 @@ export declare const commentsConsoleSection: ViteHubConsoleRuntimeRecordTableSec
17
16
  projectRoot: string;
18
17
  serverDirs?: string[];
19
18
  }>;
20
- //#endregion
21
- //#region ../internal/src/deployment.d.ts
22
19
  /** The host that ViteHub builds for: the `host` option of `vitehub()` and the value of `VITEHUB_HOST`. */
23
20
  type ViteHubHost = "cloudflare" | "deno" | "netlify" | "node" | "vercel";
24
- //#endregion
25
- //#region ../internal/src/build/deployment-plan-output.d.ts
26
21
  /**
27
22
  * One set of host variables that the deployed app reads, as `deployment.json` lists it: a Server Env declaration, or
28
23
  * a variable that a primitive reads itself, such as `VITEHUB_SECRET` or `BLOB_READ_WRITE_TOKEN`.
@@ -52,12 +47,11 @@ interface DeploymentEnvContext {
52
47
  * Return names only, never values.
53
48
  */
54
49
  type DeploymentEnvContribution = (context: DeploymentEnvContext) => readonly DeploymentEnvEntry[];
55
- //#endregion
56
- //#region src/live-vite.d.ts
57
50
  /** Module paths that generated files import. The `vite-hub` distribution passes its own subpaths. */
58
51
  interface CommentsImports {
59
52
  /** Exports `defineCommentsPlugin`, `createCommentsHandler`, and `viteHubPageSessionHandler`. */
60
53
  runtime: string;
54
+ siteVisitor?: string;
61
55
  /** Exports `commentsRealtime`. */
62
56
  realtime: string;
63
57
  /** Exports `commentsAuthSession`. */
@@ -131,6 +125,21 @@ interface CommentsVitePluginOptions {
131
125
  * `defineComments({ rateLimit })` there too. Default `false`: each process counts in its memory.
132
126
  */
133
127
  rateLimit?: boolean;
128
+ /**
129
+ * More segments of the Comments pill, such as the **Console** segment of `vite-hub`. The generated Nitro plugin
130
+ * imports `export` from `module` and calls it with the Nitro app and `{ base, development, ...options }`, before it
131
+ * installs the pill. With `overlay: false`, the app has no pill and calls none of them.
132
+ */
133
+ pillSegments?: readonly CommentsPillSegment[];
134
+ }
135
+ /** A segment of the Comments pill that another package adds. See `CommentsVitePluginOptions.pillSegments`. */
136
+ interface CommentsPillSegment {
137
+ /** The file or package path of the module that exports the install function. */
138
+ module: string;
139
+ /** The name of the install function. */
140
+ export: string;
141
+ /** JSON options that the install function gets with `base` and `development`. */
142
+ options?: Readonly<Record<string, string | number | boolean>>;
134
143
  }
135
144
  interface CommentsRealtimeContributionContext {
136
145
  driver: "cloudflare" | "memory";
@@ -228,8 +237,6 @@ export declare function renderCommentsPlugin(input: {
228
237
  * with `COMMENTS_B0003`, because `vitehub({ comments })` and `server/comments.ts` turn Comments on there.
229
238
  */
230
239
  export declare function comments(options?: CommentsOptions): PluginOption[];
231
- //#endregion
232
- //#region src/overlay.d.ts
233
240
  /** Which pages get the overlay. Globs are relative to the app base: `*` is one path segment and `**` any depth. */
234
241
  interface CommentsOverlayOptions {
235
242
  /** Pages that get the overlay. Default: every page. */
@@ -282,23 +289,17 @@ export declare function injectLoader(html: string, tag: string, found?: {
282
289
  * A stream is piped through a transform that holds back a short tail, so a tag split across chunks is still found.
283
290
  */
284
291
  export declare function renderOverlayMiddleware(url: string): string;
285
- //#endregion
286
- //#region src/operations-core/console.d.ts
287
292
  /**
288
293
  * Console section for the comment inbox. It lists the result of `comments.list`, called with the Console user, so
289
294
  * `authorize` applies to each thread. A page thread links to `<page>?comment=<n>`.
290
295
  */
291
296
  declare const commentsConsoleSection$1: ViteHubConsoleOperationSection;
292
- //#endregion
293
- //#region src/operations-core/vite.d.ts
294
297
  export declare const COMMENTS_VITE_PLUGIN_NAME = "@vite-hub/comments/vite";
295
298
  /** Whether the project has a `server/comments.ts`. `vitehub()` reads it while Vite filters plugins. */
296
299
  export declare function usesComments(options: {
297
300
  projectRoot: string;
298
301
  serverDirs?: readonly string[];
299
302
  }): boolean;
300
- //#endregion
301
- //#region src/vite.d.ts
302
303
  export type HubCommentsOptions = CommentsVitePluginOptions & {
303
304
  /** Import paths of the comment operations. `vite-hub` passes its own subpaths. */
304
305
  operationsImports?: {
@@ -321,5 +322,4 @@ export declare function findCommentsEntry(options: {
321
322
  * or as its default export; both run every surface on the same tables.
322
323
  */
323
324
  export declare function hubComments(options?: HubCommentsOptions): CommentsVitePlugin;
324
- //#endregion
325
- export { type CommentsComponent, type CommentsImports, type CommentsOptions, type CommentsOverlayAssets, type CommentsOverlayOptions, type CommentsRealtimeContributionContext, type CommentsVitePluginOptions, type StandaloneDatabase, comments as default, commentsConsoleSection$1 as commentsOperationsConsoleSection, githubRepository, mountedCommentsRoute };
325
+ export { type CommentsComponent, type CommentsImports, type CommentsOptions, type CommentsOverlayAssets, type CommentsOverlayOptions, type CommentsPillSegment, type CommentsRealtimeContributionContext, type CommentsVitePluginOptions, type StandaloneDatabase, comments as default, commentsConsoleSection$1 as commentsOperationsConsoleSection, githubRepository, mountedCommentsRoute };
package/dist/vite.js CHANGED
@@ -1,10 +1,10 @@
1
- import { t as commentsErrorDiagnostics } from "./errors-Dq4AHjza.js";
2
- import { a as mountedCommentsRoute, i as commentsRoute, r as commentsRealtimeDefinition } from "./page-DRz_sDY4.js";
3
- import { n as isRecordOrFunction } from "./object-Da1zyPCR.js";
4
- import { t as invariant } from "./invariant-D8_xBqmZ.js";
5
- import { c as validateCommentsDefinition } from "./define-BMBSVbD9.js";
6
- import { a as viteHubPageToolsCookie, d as viteHubPageToolsQuery, i as viteHubPageToolsAssets, n as viteHubBasePath, r as viteHubPageSessionPath, s as viteHubPageToolsInlineScript } from "./page-tools-shared-BNnuPK93.js";
7
- import { n as commentsTableNames, t as commentSendsTableNames } from "./table-names-B9LlRC0B.js";
1
+ import { t as invariant } from "./invariant-CmdvZ3vp.js";
2
+ import { c as validateCommentsDefinition } from "./define-BCxNaSZv.js";
3
+ import { t as commentsErrorDiagnostics } from "./errors-DFNiJg67.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-fvmJQCrP.js";
5
+ import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
6
+ import { a as mountedCommentsRoute, i as commentsRoute, r as commentsRealtimeDefinition } from "./page-xzgZ6DGm.js";
7
+ import { n as commentsTableNames, t as commentSendsTableNames } from "./table-names-BIHjuEFK.js";
8
8
  import { formatDiagnostic } from "nostics";
9
9
  import { existsSync, mkdirSync, statSync, writeFileSync } from "node:fs";
10
10
  import { tmpdir } from "node:os";
@@ -16,7 +16,7 @@ import { nitro } from "nitro/vite";
16
16
  import { parseDatabaseLocation } from "@vite-hub/database/config";
17
17
  import { githubRepository, readForgeBuild } from "@vite-hub/forge/build/node";
18
18
  import { parseJSONC, parseTOML } from "confbox";
19
- //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
19
+ // ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
20
20
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
21
21
  function normalizeWindowsPath(input = "") {
22
22
  if (!input) return input;
@@ -113,16 +113,14 @@ const dirname$1 = function(p) {
113
113
  if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
114
114
  return segments.join("/") || (isAbsolute(p) ? "/" : ".");
115
115
  };
116
- //#endregion
117
- //#region ../internal/src/inspect.ts
116
+ // ../internal/src/inspect.ts
118
117
  function relativeDefinitionFile(projectRoot, file) {
119
118
  return relative$1(projectRoot, file).replaceAll("\\", "/");
120
119
  }
121
120
  const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
122
121
  new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
123
122
  new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
124
- //#endregion
125
- //#region ../internal/src/build/vite.ts
123
+ // ../internal/src/build/vite.ts
126
124
  const projectRootDirectoryMarkers = [
127
125
  ["server", "agents"],
128
126
  ["server", "channels"],
@@ -207,8 +205,7 @@ function isMissingProjectMarker(error) {
207
205
  const code = error.code;
208
206
  return code === "ENOENT" || code === "ENOTDIR";
209
207
  }
210
- //#endregion
211
- //#region ../internal/src/build/paths.ts
208
+ // ../internal/src/build/paths.ts
212
209
  function resolveRuntimeModule(packageDir, modulePath) {
213
210
  const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
214
211
  return existsSync(distFile) ? distFile : resolve$1(packageDir, "src", `${modulePath}.ts`);
@@ -235,8 +232,7 @@ function findPackageDir(file) {
235
232
  function ownModule(importMetaUrl, modulePath) {
236
233
  return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
237
234
  }
238
- //#endregion
239
- //#region src/entry.ts
235
+ // src/entry.ts
240
236
  const extensions = [
241
237
  ".ts",
242
238
  ".mts",
@@ -293,8 +289,7 @@ function createNitroServerKit(value = {}) {
293
289
  }
294
290
  };
295
291
  }
296
- //#endregion
297
- //#region ../internal/src/build/page-tools.ts
292
+ // ../internal/src/build/page-tools.ts
298
293
  /**
299
294
  * Adds the session route `GET <mount>/_vitehub/page/tools` and the loader script at
300
295
  * `<mount>/_vitehub/page/assets/loader.js` to a Nitro configuration. Each owner package of a page tool calls it from its
@@ -357,8 +352,7 @@ function viteHubPageToolsIndexHtml(html, base) {
357
352
  const index = html.search(/<\/body\s*>/i);
358
353
  return index === -1 ? `${html}${script}` : `${html.slice(0, index)}${script}${html.slice(index)}`;
359
354
  }
360
- //#endregion
361
- //#region ../internal/src/build/ast-walk.ts
355
+ // ../internal/src/build/ast-walk.ts
362
356
  /** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
363
357
  function moduleLanguage(file) {
364
358
  if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
@@ -366,8 +360,7 @@ function moduleLanguage(file) {
366
360
  if (/\.(?:c|m)?js$/i.test(file)) return "js";
367
361
  return "ts";
368
362
  }
369
- //#endregion
370
- //#region ../internal/src/build/scan-module.ts
363
+ // ../internal/src/build/scan-module.ts
371
364
  /**
372
365
  * Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
373
366
  * the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
@@ -487,8 +480,7 @@ function staticValue(node) {
487
480
  default: return dynamic;
488
481
  }
489
482
  }
490
- //#endregion
491
- //#region ../internal/src/hints.ts
483
+ // ../internal/src/hints.ts
492
484
  /**
493
485
  * The file that lists the hints of the last build or dev server, relative to the project root. A hint is a warning
494
486
  * about something that works now and fails later, such as counts that stay in one server's memory. Agents and CI read
@@ -566,8 +558,7 @@ function startViteHubHints(config, owner = config) {
566
558
  started.add(owner);
567
559
  write(startRun(config));
568
560
  }
569
- //#endregion
570
- //#region ../internal/src/build/included-nitro-registry.ts
561
+ // ../internal/src/build/included-nitro-registry.ts
571
562
  const includedKey = Symbol.for("vitehub.included-nitro");
572
563
  const scope = globalThis;
573
564
  const includedNitroPlugins = scope[includedKey] ??= /* @__PURE__ */ new WeakSet();
@@ -582,8 +573,7 @@ function markIncludedNitroPlugin(plugin) {
582
573
  function isIncludedNitroPlugin(plugin) {
583
574
  return includedNitroPlugins.has(plugin);
584
575
  }
585
- //#endregion
586
- //#region ../internal/src/build/included-nitro.ts
576
+ // ../internal/src/build/included-nitro.ts
587
577
  function flattenPlugins(option) {
588
578
  if (Array.isArray(option)) return option.flatMap(flattenPlugins);
589
579
  return option && typeof option === "object" && "name" in option ? [option] : [];
@@ -610,8 +600,7 @@ function includedNitro(options = {}) {
610
600
  }
611
601
  return plugins;
612
602
  }
613
- //#endregion
614
- //#region src/deployment-env.ts
603
+ // src/deployment-env.ts
615
604
  const owners = ["comments"];
616
605
  const githubLoginNames = {
617
606
  clientId: "VITEHUB_GITHUB_CLIENT_ID",
@@ -686,8 +675,7 @@ function commentsDeploymentEnv(options, context) {
686
675
  ...options.standalone ? standaloneDatabaseEntries(options.standalone.database || void 0, context.host) : []
687
676
  ];
688
677
  }
689
- //#endregion
690
- //#region src/console.ts
678
+ // src/console.ts
691
679
  /**
692
680
  * Console section for Comments: every thread with its first comment, page, author, replies, and status, open threads
693
681
  * first. People reply and resolve on the page itself, where the context is; each record links there. The
@@ -735,8 +723,7 @@ const commentsConsoleSection = {
735
723
  notice: "People comment, reply, and resolve on the site's pages. Open threads come first. Server code reads the same threads with `comments.list()`."
736
724
  }
737
725
  };
738
- //#endregion
739
- //#region src/live-vite.ts
726
+ // src/live-vite.ts
740
727
  const defaultImports = {
741
728
  runtime: "@vite-hub/comments/runtime",
742
729
  realtime: "@vite-hub/comments/realtime",
@@ -969,6 +956,8 @@ function renderCommentsPlugin(input) {
969
956
  const session = sessionWithGitHubLines(input.session ?? {}, input.imports, input.build?.repository, input.base);
970
957
  const postgres = input.session?.dialect === "postgresql";
971
958
  const overlay = input.session?.overlay === false ? "false" : JSON.stringify(`${commentsRoute}/assets/overlay.js?v=${version}`);
959
+ const segments = pillSegmentLines(input.session?.overlay === false ? [] : input.session?.pillSegments ?? []);
960
+ const siteVisitor = input.session?.overlay === false && input.imports.siteVisitor ? `siteVisitor: async (request) => (await import(${JSON.stringify(input.imports.siteVisitor)})).readConsoleSiteVisitor(request, ${JSON.stringify(input.base ?? "")}, ${input.development === true})` : void 0;
972
961
  if (input.standalone) {
973
962
  const { where, fallback, node } = input.standalone;
974
963
  const options = [`name: "comments"`, ...fallback ? [`fallback: ${JSON.stringify(fallback)}`] : []];
@@ -977,10 +966,11 @@ function renderCommentsPlugin(input) {
977
966
  `import { connectDatabase } from ${JSON.stringify(node ? `${input.imports.connect}/node` : input.imports.connect)}`,
978
967
  ...definitionLines(input.definition, input.imports.runtime),
979
968
  ...session.imports,
969
+ ...segments.imports,
980
970
  "",
981
971
  `const database = () => connectDatabase(${where === void 0 ? "undefined" : JSON.stringify(where)}, { ${options.join(", ")} })`,
982
972
  "",
983
- `export default defineCommentsPlugin({ comments, database, schema: "comments", session: ${session.value}, ${session.githubLogin ? "githubLogin, " : ""}development: ${input.development === true}, overlay: ${overlay}, base: ${JSON.stringify(input.base ?? "")} })`,
973
+ `export default defineCommentsPlugin({ comments, database, schema: "comments", session: ${session.value}, ${session.githubLogin ? "githubLogin, " : ""}development: ${input.development === true}, overlay: ${overlay}, base: ${JSON.stringify(input.base ?? "")}${segments.value ? `, pillSegments: ${segments.value}` : ""} })`,
984
974
  ""
985
975
  ].join("\n");
986
976
  }
@@ -988,6 +978,7 @@ function renderCommentsPlugin(input) {
988
978
  `import { defineCommentsPlugin, selectCommentsDatabase } from ${JSON.stringify(input.imports.runtime)}`,
989
979
  ...definitionLines(input.definition, input.imports.runtime),
990
980
  ...session.imports,
981
+ ...segments.imports,
991
982
  "",
992
983
  `const database = async () => selectCommentsDatabase((await import(${JSON.stringify(input.imports.databases)})).databases${input.database ? `, ${JSON.stringify(input.database)}` : ""})`,
993
984
  "",
@@ -1007,11 +998,20 @@ function renderCommentsPlugin(input) {
1007
998
  ...input.send ? [`webhooks: () => import(${JSON.stringify(input.imports.webhooks)})`] : [],
1008
999
  `development: ${input.development === true}`,
1009
1000
  `overlay: ${overlay}`,
1010
- `base: ${JSON.stringify(input.base ?? "")}`
1001
+ `base: ${JSON.stringify(input.base ?? "")}`,
1002
+ ...siteVisitor ? [siteVisitor] : [],
1003
+ ...segments.value ? [`pillSegments: ${segments.value}`] : []
1011
1004
  ].join(", ")} })`,
1012
1005
  ""
1013
1006
  ].join("\n");
1014
1007
  }
1008
+ function pillSegmentLines(segments) {
1009
+ if (!segments.length) return { imports: [] };
1010
+ return {
1011
+ imports: segments.map((segment, index) => `import { ${segment.export} as pillSegment${index} } from ${JSON.stringify(segment.module)}`),
1012
+ value: `[${segments.map((segment, index) => `(nitroApp, context) => pillSegment${index}(nitroApp, { ...context, ...${JSON.stringify(segment.options ?? {})} })`).join(", ")}]`
1013
+ };
1014
+ }
1015
1015
  /** The generated directory of Comments in a project. */
1016
1016
  function generatedDirectory(projectRoot) {
1017
1017
  return resolve(projectRoot, ".vitehub/nitro/comments");
@@ -1369,8 +1369,7 @@ function hubComments$1(options = {}) {
1369
1369
  } };
1370
1370
  return integration;
1371
1371
  }
1372
- //#endregion
1373
- //#region src/operations-core/console.ts
1372
+ // src/operations-core/console.ts
1374
1373
  /**
1375
1374
  * Console section for the comment inbox. It lists the result of `comments.list`, called with the Console user, so
1376
1375
  * `authorize` applies to each thread. A page thread links to `<page>?comment=<n>`.
@@ -1462,8 +1461,7 @@ const commentsConsoleSection$1 = {
1462
1461
  }
1463
1462
  }
1464
1463
  };
1465
- //#endregion
1466
- //#region src/operations-core/vite.ts
1464
+ // src/operations-core/vite.ts
1467
1465
  const COMMENTS_VITE_PLUGIN_NAME = "@vite-hub/comments/vite";
1468
1466
  function candidates(projectRoot, serverDirs) {
1469
1467
  return (serverDirs === void 0 ? [resolve(projectRoot, "server")] : serverDirs.map((directory) => resolve(projectRoot, directory))).flatMap((directory) => [
@@ -1481,8 +1479,7 @@ function findCommentsEntry$1(options) {
1481
1479
  function usesComments(options) {
1482
1480
  return findCommentsEntry$1(options) !== void 0;
1483
1481
  }
1484
- //#endregion
1485
- //#region src/overlay.ts
1482
+ // src/overlay.ts
1486
1483
  /** Where the loader and overlay are served, below the app mount: the assets folder of the Comments API route. */
1487
1484
  const overlayRoute = "/_vitehub/comments/assets";
1488
1485
  /** The path the app is mounted at: `""` for the root, `"/portal"` below it. A relative or empty Vite base is the root. */
@@ -1738,8 +1735,7 @@ function renderOverlayMiddleware(url) {
1738
1735
  ""
1739
1736
  ].join("\n");
1740
1737
  }
1741
- //#endregion
1742
- //#region src/vite.ts
1738
+ // src/vite.ts
1743
1739
  function findCommentsEntry(options, serverDirs) {
1744
1740
  return typeof options === "string" ? findCommentsEntry$2(options, serverDirs) : findCommentsEntry$1(options);
1745
1741
  }
@@ -1805,5 +1801,4 @@ function hubComments(options = {}) {
1805
1801
  }
1806
1802
  };
1807
1803
  }
1808
- //#endregion
1809
1804
  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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vite-hub/comments",
3
- "version": "0.5.0",
3
+ "version": "0.6.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,37 +106,37 @@
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.5.0",
110
- "@vite-hub/forge": "0.5.0",
111
- "@vite-hub/realtime": "0.5.0",
112
- "@vite-hub/runtime": "0.5.0",
109
+ "@vite-hub/auth": "0.6.0",
110
+ "@vite-hub/forge": "0.6.0",
111
+ "@vite-hub/realtime": "0.6.0",
112
+ "@vite-hub/runtime": "0.6.0",
113
113
  "birpc": "^4.2.0",
114
- "confbox": "^0.3.1",
114
+ "confbox": "^0.3.2",
115
115
  "h3": "^2.0.8"
116
116
  },
117
117
  "devDependencies": {
118
- "@types/node": "^24.19.1",
118
+ "@types/node": "^24.19.2",
119
119
  "@vite-hub/internal": "0.0.1",
120
- "happy-dom": "21.0.3",
120
+ "happy-dom": "21.0.4",
121
121
  "marked": "17.0.6",
122
122
  "modern-screenshot": "4.7.0",
123
123
  "nitro": "^3.0.261103-rc",
124
- "playwright-core": "^1.63.0",
124
+ "playwright-core": "^1.65.1",
125
125
  "publint": "^0.3.25",
126
126
  "typescript": "^6.0.3",
127
- "vite-plus": "^0.3.3",
128
- "vitest": "^4.1.11",
129
- "vue": "3.5.44",
127
+ "vite-plus": "^1.7.0",
128
+ "vitest": "5.1.0",
129
+ "vue": "3.5.46",
130
130
  "@libsql/client": "^0.18.0",
131
- "@vite-hub/database": "0.5.0",
132
- "vite": "^8.2.2",
133
- "drizzle-orm": "1.0.0-rc.5"
131
+ "@vite-hub/database": "0.6.0",
132
+ "vite": "^8.3.8",
133
+ "drizzle-orm": "1.0.0-rc.6"
134
134
  },
135
135
  "peerDependencies": {
136
- "@vite-hub/database": "0.5.0",
136
+ "@vite-hub/database": "0.6.0",
137
137
  "nitro": "3.0.261102-rc || ^3.0.261103-rc",
138
138
  "vite": ">=8.0.0",
139
- "drizzle-orm": "1.0.0-rc.5 || ^1.0.0"
139
+ "drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0"
140
140
  },
141
141
  "peerDependenciesMeta": {
142
142
  "vite": {
@@ -147,10 +147,10 @@
147
147
  "node": ">=24.15.0"
148
148
  },
149
149
  "scripts": {
150
- "build": "vp pack && vp build --config overlay.vite.config.ts",
150
+ "build": "vp pack && vp build --config overlay.vite.config.ts && vp build --config hosted.vite.config.ts",
151
151
  "dev": "vp pack && vp build --config overlay.vite.config.ts && vp pack --watch --no-clean",
152
152
  "typecheck": "vp run --cache -t @vite-hub/comments#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
153
153
  "test": "vp run --cache -t @vite-hub/comments#build && vp test",
154
- "test:browser": "vp run --cache -t @vite-hub/comments#build && node --test test/browser/overlay.browser.mjs test/browser/presence.browser.mjs test/browser/outbox.browser.mjs test/browser/send.browser.mjs"
154
+ "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"
155
155
  }
156
156
  }