@vite-hub/comments 0.6.1 → 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.
- package/README.md +8 -12
- package/dist/anchor.d.ts +1 -1
- package/dist/{client-diagnostics-D987sEK7.js → client-diagnostics-DoXqdnBd.js} +8 -0
- package/dist/client-request-B1DCz3a9.js +29 -0
- package/dist/client.d.ts +48 -223
- package/dist/client.js +232 -569
- package/dist/database.d.ts +1 -2
- package/dist/database.js +1 -1
- package/dist/{define-C2tnAtBU.js → define-C-LUOouq.js} +1 -1
- package/dist/{errors-C0VwRHiy.js → errors-C5utwZ5H.js} +0 -24
- package/dist/{errors-ByCRdInk.js → errors-DeSEHzRf.js} +1 -13
- package/dist/hosted/hosted-comments/frame.js +4 -1
- package/dist/hosted/hosted-comments/tools.js +362 -0
- package/dist/hosted/hosted-comments.js +1 -19
- package/dist/{index-D1T7RJ4R.d.ts → index-d6NsDxu9.d.ts} +4 -112
- package/dist/index.d.ts +4 -5
- package/dist/index.js +6 -20
- package/dist/{install-D6hXZaSN.js → install-BueV_fJY.js} +22 -780
- package/dist/{install-9L4ASzUC.d.ts → install-F-_O7zDr.d.ts} +5 -11
- package/dist/{installed-bPUnazFf.js → installed-BqQKo6WC.js} +2 -7
- package/dist/{database-Cguz3hZL.js → migrate-oseJAYbm.js} +2 -46
- package/dist/{operations-B1ALn4VS.js → operations-0llC5kKO.js} +49 -51
- package/dist/{operations-8hqTi0DH.d.ts → operations-DFLer1fR.d.ts} +1 -0
- package/dist/{operations-BkkrI8a3.d.ts → operations-jaihyWw2.d.ts} +36 -4
- package/dist/operations.d.ts +3 -3
- package/dist/operations.js +2 -2
- package/dist/overlay/client-ZBsUybIe.js +4 -0
- package/dist/overlay/overlay.js +68 -37
- package/dist/page/loader.js +36 -30
- package/dist/page-BgvzzsJb.d.ts +32 -0
- package/dist/{page-2NzFladc.js → page-CDhmXO-y.js} +24 -1
- package/dist/{page-tools-shared-fvmJQCrP.js → page-tools-shared-BCdvqA4S.js} +41 -6
- package/dist/{plugin-l4sPt5-n.js → plugin-DGUqlc3C.js} +9 -9
- package/dist/realtime.d.ts +10 -9
- package/dist/realtime.js +2 -4
- package/dist/{rpc-BYmbVkr8.js → rpc-kkxzQ3Qy.js} +1 -1
- package/dist/rpc.js +1 -1
- package/dist/runtime/auth.d.ts +1 -2
- package/dist/runtime/auth.js +1 -1
- package/dist/runtime/client-request-plugin.d.ts +2 -0
- package/dist/runtime/client-request-plugin.js +21 -0
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/index.d.ts +6 -8
- package/dist/runtime/index.js +25 -153
- package/dist/{server-DvSehkPP.js → server-CAMs6viR.js} +1 -1
- package/dist/server.d.ts +11 -7
- package/dist/server.js +8 -7
- package/dist/{store-DvNTDNgn.d.ts → service-CMVA_Ryv.d.ts} +67 -1
- package/dist/{service-BIGe1Hpo.js → service-DaMq8TBw.js} +35 -33
- package/dist/{session-CCRLR9bf.js → session-B7GDrqsK.js} +207 -41
- package/dist/{session-CN4irEqf.d.ts → session-EzQqBeE8.d.ts} +2 -3
- package/dist/{table-names-BIHjuEFK.js → table-names-DUmWROM4.js} +1 -3
- package/dist/testing.js +1 -1
- package/dist/{define-B1jLSPe9.d.ts → types-qzJKgWYS.d.ts} +157 -4
- package/dist/vite.d.ts +3 -20
- package/dist/vite.js +20 -52
- package/package.json +9 -8
- package/dist/database-CPua6Q6_.d.ts +0 -573
- package/dist/hosted/hosted-comments/client-Czl2zu9P.js +0 -4
- package/dist/hosted/hosted-comments/dist-DyVmH21U.js +0 -14
- package/dist/hosted/hosted-comments/overlay-DpS0P-nd.js +0 -186
- package/dist/hosted/hosted-comments/protocol-DuB0Zhs-.js +0 -1
- package/dist/hosted/hosted-comments/rest-transport-CKZG_jZ4.js +0 -1
- package/dist/hosted/hosted-comments/tools-D8xg-kDW.js +0 -126
- package/dist/overlay/client-C7ftI-CB.js +0 -4
- package/dist/overlay/dist-yIZmvSaU.js +0 -1
- package/dist/page-DE71P_gQ.d.ts +0 -11
- package/dist/request-origin-YPzfE2eh.js +0 -48
- package/dist/service-IvgrI4XM.d.ts +0 -71
- 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
|
-
/**
|
|
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
|
-
|
|
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
|
-
import { n as OperationContributions } from "./operations-
|
|
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-
|
|
5
|
-
import {
|
|
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-
|
|
3
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
4
|
-
import { a as
|
|
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 {
|
|
7
|
-
import {
|
|
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
|
|
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 =
|
|
328
|
-
const viteBase =
|
|
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(
|
|
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(
|
|
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
|
-
}
|
|
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",
|
|
@@ -1313,6 +1281,10 @@ function hubComments$1(options = {}) {
|
|
|
1313
1281
|
});
|
|
1314
1282
|
return;
|
|
1315
1283
|
}
|
|
1284
|
+
config.define = {
|
|
1285
|
+
...config.define,
|
|
1286
|
+
__VITEHUB_APP_BASE_URL__: JSON.stringify(`${base}/`)
|
|
1287
|
+
};
|
|
1316
1288
|
await mkdir(directory, { recursive: true });
|
|
1317
1289
|
const definition = discover() ?? await writeDefaultDefinition(directory, imports);
|
|
1318
1290
|
const handler = join(directory, "handler.mjs");
|
|
@@ -1328,8 +1300,7 @@ function hubComments$1(options = {}) {
|
|
|
1328
1300
|
build,
|
|
1329
1301
|
base,
|
|
1330
1302
|
development,
|
|
1331
|
-
realtime
|
|
1332
|
-
send: !options.standalone && await readCommentsSend(definition)
|
|
1303
|
+
realtime
|
|
1333
1304
|
};
|
|
1334
1305
|
await Promise.all([
|
|
1335
1306
|
writeFile(handler, renderCommentsHandler({
|
|
@@ -1352,6 +1323,7 @@ function hubComments$1(options = {}) {
|
|
|
1352
1323
|
meta: { ...ownAccessRouteMeta },
|
|
1353
1324
|
route: `${mount}${commentsRoute}/**`
|
|
1354
1325
|
});
|
|
1326
|
+
kit.addPlugin(ownModule(import.meta.url, "runtime/client-request-plugin"), "start");
|
|
1355
1327
|
kit.addPlugin(plugin);
|
|
1356
1328
|
addViteHubPageToolRoutes(kit, {
|
|
1357
1329
|
handler: pageToolsRoute,
|
|
@@ -1459,7 +1431,7 @@ const commentsConsoleSection$1 = {
|
|
|
1459
1431
|
],
|
|
1460
1432
|
kind: "operation-view",
|
|
1461
1433
|
link: {
|
|
1462
|
-
label: "Open page",
|
|
1434
|
+
label: "Open on page",
|
|
1463
1435
|
template: "{subject.id:path}?comment={n}",
|
|
1464
1436
|
when: {
|
|
1465
1437
|
equals: "page",
|
|
@@ -1799,10 +1771,6 @@ function hubComments(options = {}) {
|
|
|
1799
1771
|
logLevel: "silent"
|
|
1800
1772
|
});
|
|
1801
1773
|
validateCommentsDefinition(module.comments ?? module.default, display);
|
|
1802
|
-
if (await readCommentsSend(entry)) {
|
|
1803
|
-
if (liveOptions.dialect === "postgresql") throw commentsErrorDiagnostics.COMMENTS_SEND_POSTGRES();
|
|
1804
|
-
if (!resolved.plugins.some((plugin) => plugin.name === "@vite-hub/webhooks/vite")) throw commentsErrorDiagnostics.COMMENTS_SEND_WEBHOOKS_OFF({ file: display });
|
|
1805
|
-
}
|
|
1806
1774
|
},
|
|
1807
1775
|
vitehub: {
|
|
1808
1776
|
...live.vitehub,
|
|
@@ -1817,4 +1785,4 @@ function hubComments(options = {}) {
|
|
|
1817
1785
|
}
|
|
1818
1786
|
};
|
|
1819
1787
|
}
|
|
1820
|
-
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,
|
|
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.
|
|
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.
|
|
110
|
-
"@vite-hub/forge": "0.
|
|
111
|
-
"@vite-hub/realtime": "0.
|
|
112
|
-
"@vite-hub/runtime": "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"
|
|
@@ -117,6 +117,7 @@
|
|
|
117
117
|
"devDependencies": {
|
|
118
118
|
"@types/node": "^24.19.2",
|
|
119
119
|
"@vite-hub/internal": "0.0.1",
|
|
120
|
+
"@vitejs/plugin-vue": "^6.0.11",
|
|
120
121
|
"happy-dom": "21.0.4",
|
|
121
122
|
"marked": "17.0.6",
|
|
122
123
|
"modern-screenshot": "4.7.0",
|
|
@@ -128,12 +129,12 @@
|
|
|
128
129
|
"vitest": "5.1.0",
|
|
129
130
|
"vue": "3.5.46",
|
|
130
131
|
"@libsql/client": "^0.18.0",
|
|
131
|
-
"@vite-hub/database": "0.
|
|
132
|
+
"@vite-hub/database": "0.8.0",
|
|
132
133
|
"vite": "^8.3.8",
|
|
133
134
|
"drizzle-orm": "1.0.0-rc.6"
|
|
134
135
|
},
|
|
135
136
|
"peerDependencies": {
|
|
136
|
-
"@vite-hub/database": "0.
|
|
137
|
+
"@vite-hub/database": "0.8.0",
|
|
137
138
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
138
139
|
"vite": ">=8.0.0",
|
|
139
140
|
"drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0"
|
|
@@ -151,6 +152,6 @@
|
|
|
151
152
|
"dev": "vp pack && vp build --config overlay.vite.config.ts && vp pack --watch --no-clean",
|
|
152
153
|
"typecheck": "vp run --cache -t @vite-hub/comments#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
|
|
153
154
|
"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/hosted.browser.mjs test/browser/presence.browser.mjs test/browser/outbox.browser.mjs test/browser/
|
|
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"
|
|
155
156
|
}
|
|
156
157
|
}
|