@vite-hub/comments 0.6.0 → 0.6.1
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 +20 -5
- package/dist/{client-diagnostics-CvfTW5d4.js → client-diagnostics-D987sEK7.js} +4 -0
- package/dist/client.d.ts +72 -21
- package/dist/client.js +480 -62
- package/dist/{database-BkPoOdZr.js → database-Cguz3hZL.js} +1 -1
- package/dist/database.js +1 -1
- package/dist/{define-BCxNaSZv.js → define-C2tnAtBU.js} +1 -1
- package/dist/{errors-DFNiJg67.js → errors-ByCRdInk.js} +1 -1
- package/dist/hosted/hosted-comments/{client-B3dlmmQd.js → client-Czl2zu9P.js} +3 -3
- package/dist/hosted/hosted-comments/frame.js +1 -1
- package/dist/hosted/hosted-comments/overlay-DpS0P-nd.js +186 -0
- package/dist/hosted/hosted-comments/protocol-DuB0Zhs-.js +1 -0
- package/dist/hosted/hosted-comments/rest-transport-CKZG_jZ4.js +1 -0
- package/dist/hosted/hosted-comments/tools-D8xg-kDW.js +126 -0
- package/dist/hosted/hosted-comments.js +13 -3
- package/dist/index.js +11 -10
- package/dist/{install-NehuMNhG.d.ts → install-9L4ASzUC.d.ts} +10 -1
- package/dist/{install-w6CCgGFV.js → install-D6hXZaSN.js} +6 -4
- package/dist/{installed-C9SkldMi.js → installed-bPUnazFf.js} +1 -1
- package/dist/{operations-B8IMhRmY.js → operations-B1ALn4VS.js} +7 -7
- package/dist/{operations-Cic9A9e_.d.ts → operations-BkkrI8a3.d.ts} +1 -1
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +2 -2
- package/dist/overlay/{client-CerbVjTz.js → client-C7ftI-CB.js} +3 -3
- package/dist/overlay/overlay.js +30 -16
- package/dist/{page-xzgZ6DGm.js → page-2NzFladc.js} +5 -1
- package/dist/{plugin-DbCYT7Ac.js → plugin-l4sPt5-n.js} +8 -7
- package/dist/realtime.d.ts +9 -1
- package/dist/realtime.js +14 -6
- package/dist/{rpc-BKY7XRlR.js → rpc-BYmbVkr8.js} +1 -1
- package/dist/rpc.js +1 -1
- package/dist/runtime/auth.js +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.js +10 -8
- package/dist/{server-BGbD7H5s.js → server-DvSehkPP.js} +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/server.js +6 -6
- package/dist/{service-DUh2uGd2.js → service-BIGe1Hpo.js} +11 -6
- package/dist/{service-CPiWPoiY.d.ts → service-IvgrI4XM.d.ts} +2 -0
- package/dist/{session-_1GY5gaG.js → session-CCRLR9bf.js} +1 -1
- package/dist/testing.js +1 -1
- package/dist/vite.d.ts +1 -0
- package/dist/vite.js +25 -9
- package/package.json +7 -7
- package/dist/hosted/hosted-comments/overlay-CFuq5QAH.js +0 -182
- package/dist/hosted/hosted-comments/protocol-BHvtQKte.js +0 -1
- package/dist/hosted/hosted-comments/rest-transport-D-9_pNqZ.js +0 -1
- package/dist/hosted/hosted-comments/tools-Bz--joZw.js +0 -126
|
@@ -7,6 +7,7 @@ import { n as pagePathOf } from "./path-8yqMd8zR.js";
|
|
|
7
7
|
const commentsPageScope = "site";
|
|
8
8
|
/** Name of the Realtime Definition that holds one presence room per page. */
|
|
9
9
|
const commentsRealtimeDefinition = "comments";
|
|
10
|
+
const commentsNoticeDefinition = "comments-notices";
|
|
10
11
|
/** The route prefix of the Comments API, below the app base. */
|
|
11
12
|
const commentsRoute = "/_vitehub/comments";
|
|
12
13
|
/** Mount Comments under the application path, ignoring Vite asset URLs such as a CDN origin. */
|
|
@@ -36,4 +37,7 @@ function commentRoom(page) {
|
|
|
36
37
|
}
|
|
37
38
|
return `pages/${a.toString(16).padStart(8, "0")}${b.toString(16).padStart(8, "0")}`;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
function commentNoticeRoom(subject) {
|
|
41
|
+
return `subjects/${encodeURIComponent(JSON.stringify([subject.kind, subject.id]))}`;
|
|
42
|
+
}
|
|
43
|
+
export { commentsRealtimeDefinition as a, normalizeCommentPage as c, commentsPageScope as i, commentRoom as n, commentsRoute as o, commentsNoticeDefinition as r, mountedCommentsRoute as s, commentNoticeRoom as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as registerViteHubPageTool, i as installViteHubSiteVisitor, n as resolveCommentsPage, r as installViteHubPageTools, t as resolveCommentsIdentity } from "./session-
|
|
2
|
-
import { r as commentsRoleGrants } from "./define-
|
|
3
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
4
|
-
import { i as installCommentsRuntime } from "./server-
|
|
5
|
-
import { i as runtimeBuilds } from "./installed-
|
|
1
|
+
import { a as registerViteHubPageTool, i as installViteHubSiteVisitor, n as resolveCommentsPage, r as installViteHubPageTools, t as resolveCommentsIdentity } from "./session-CCRLR9bf.js";
|
|
2
|
+
import { r as commentsRoleGrants } from "./define-C2tnAtBU.js";
|
|
3
|
+
import { t as commentsErrorDiagnostics } from "./errors-ByCRdInk.js";
|
|
4
|
+
import { i as installCommentsRuntime } from "./server-DvSehkPP.js";
|
|
5
|
+
import { i as runtimeBuilds } from "./installed-bPUnazFf.js";
|
|
6
6
|
import { n as commentsTableNames } from "./table-names-BIHjuEFK.js";
|
|
7
7
|
import { installRequestStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
8
8
|
import { configuredPublicOrigins } from "@vite-hub/runtime/internal/public-url";
|
|
@@ -38,7 +38,7 @@ function defineCommentsPlugin(options) {
|
|
|
38
38
|
warned = true;
|
|
39
39
|
throw Object.assign(commentsErrorDiagnostics.COMMENTS_R0010(), { status: 503 });
|
|
40
40
|
}
|
|
41
|
-
const { installComments } = await import("./install-
|
|
41
|
+
const { installComments } = await import("./install-D6hXZaSN.js").then((n) => n.n);
|
|
42
42
|
return installComments(options.comments, {
|
|
43
43
|
database,
|
|
44
44
|
development: options.development === true,
|
|
@@ -48,7 +48,8 @@ function defineCommentsPlugin(options) {
|
|
|
48
48
|
...options.users ? { users: options.users } : {},
|
|
49
49
|
...options.attachments ? { attachments: options.attachments } : {},
|
|
50
50
|
...options.rateLimit ? { rateLimit: options.rateLimit } : {},
|
|
51
|
-
...options.webhooks ? { webhooks: options.webhooks } : {}
|
|
51
|
+
...options.webhooks ? { webhooks: options.webhooks } : {},
|
|
52
|
+
...options.realtime ? { realtime: options.realtime } : {}
|
|
52
53
|
});
|
|
53
54
|
})().catch((error) => {
|
|
54
55
|
building = void 0;
|
package/dist/realtime.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { T as CommentThread } from "./types-BX3vH18p.js";
|
|
1
2
|
import { t as Comments } from "./index-D1T7RJ4R.js";
|
|
2
3
|
import { t as CommentsSessionOptions } from "./session-CN4irEqf.js";
|
|
4
|
+
import "./types-l6GOb_yc.js";
|
|
3
5
|
import { RealtimeDefinition } from "@vite-hub/realtime";
|
|
4
6
|
/**
|
|
5
7
|
* The Realtime Definition of the page presence rooms: who is on a page and where their cursor is. Rooms hold no
|
|
@@ -7,4 +9,10 @@ import { RealtimeDefinition } from "@vite-hub/realtime";
|
|
|
7
9
|
* Guests name themselves in the browser. ViteHub adds it as the `comments` definition when the host has a room
|
|
8
10
|
* authority.
|
|
9
11
|
*/
|
|
10
|
-
export declare function commentsRealtime(comments: Comments, options?: CommentsSessionOptions): RealtimeDefinition;
|
|
12
|
+
export declare function commentsRealtime(comments: Comments, options?: CommentsSessionOptions, purpose?: "presence" | "notices"): RealtimeDefinition;
|
|
13
|
+
/** The notice that tells the open pages of a thread to load their threads again. */
|
|
14
|
+
export declare const commentsChangeNotice: {
|
|
15
|
+
readonly type: "comments";
|
|
16
|
+
};
|
|
17
|
+
/** Tells the browsers on the page of a thread that it changed, so they load their threads again. It never throws. */
|
|
18
|
+
export declare function notifyCommentsChange(thread: Pick<CommentThread, "subject">): Promise<void>;
|
package/dist/realtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as text } from "./identity-CT7-UGmS.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as resolveCommentsPage, t as resolveCommentsIdentity } from "./session-
|
|
2
|
+
import { c as normalizeCommentPage, n as commentRoom, r as commentsNoticeDefinition, t as commentNoticeRoom } from "./page-2NzFladc.js";
|
|
3
|
+
import { n as resolveCommentsPage, t as resolveCommentsIdentity } from "./session-CCRLR9bf.js";
|
|
4
4
|
// src/realtime.ts
|
|
5
5
|
function toRealtimeUser(user) {
|
|
6
6
|
const result = { id: user.id };
|
|
@@ -18,7 +18,7 @@ function toRealtimeUser(user) {
|
|
|
18
18
|
* Guests name themselves in the browser. ViteHub adds it as the `comments` definition when the host has a room
|
|
19
19
|
* authority.
|
|
20
20
|
*/
|
|
21
|
-
function commentsRealtime(comments, options = {}) {
|
|
21
|
+
function commentsRealtime(comments, options = {}, purpose = "presence") {
|
|
22
22
|
const readers = /* @__PURE__ */ new WeakMap();
|
|
23
23
|
return {
|
|
24
24
|
async identify({ event }) {
|
|
@@ -32,15 +32,23 @@ function commentsRealtime(comments, options = {}) {
|
|
|
32
32
|
if (mode !== "read" || identity === void 0) return false;
|
|
33
33
|
const page = new URL(request.url).searchParams.get("page");
|
|
34
34
|
if (!page) return false;
|
|
35
|
-
if (documentId !== commentRoom(normalizeCommentPage(page))) return false;
|
|
35
|
+
if (purpose === "presence" && documentId !== commentRoom(normalizeCommentPage(page))) return false;
|
|
36
36
|
const { subject } = await resolveCommentsPage(comments, event, request, page);
|
|
37
|
+
if (purpose === "notices" && documentId !== commentNoticeRoom(subject)) return false;
|
|
37
38
|
return await comments.can({
|
|
38
39
|
user: identity.user,
|
|
39
40
|
action: "read",
|
|
40
41
|
subject
|
|
41
42
|
}, identity.gate);
|
|
42
43
|
},
|
|
43
|
-
document: false
|
|
44
|
+
document: false,
|
|
45
|
+
...purpose === "notices" ? { awareness: false } : {}
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
|
|
48
|
+
/** The notice that tells the open pages of a thread to load their threads again. */
|
|
49
|
+
const commentsChangeNotice = { type: "comments" };
|
|
50
|
+
/** Tells the browsers on the page of a thread that it changed, so they load their threads again. It never throws. */
|
|
51
|
+
async function notifyCommentsChange(thread) {
|
|
52
|
+
await (await import("@vite-hub/realtime/server").catch(() => void 0))?.notifyRealtimeRoom(commentsNoticeDefinition, commentNoticeRoom(thread.subject), commentsChangeNotice);
|
|
53
|
+
}
|
|
54
|
+
export { commentsChangeNotice, commentsRealtime, notifyCommentsChange };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
|
|
2
|
-
import { i as commentsUnansweredError, t as commentsAnswerError } from "./client-diagnostics-
|
|
2
|
+
import { i as commentsUnansweredError, t as commentsAnswerError } from "./client-diagnostics-D987sEK7.js";
|
|
3
3
|
import { i as withCommentFiles, n as outboxAccountHeader, r as retryAfterOf } from "./client-files-lC6X7XyS.js";
|
|
4
4
|
import { createBirpc } from "birpc";
|
|
5
5
|
// ../internal/src/operation-rpc.ts
|
package/dist/rpc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as createRpcTransport } from "./rpc-
|
|
1
|
+
export { t as createRpcTransport } from "./rpc-BYmbVkr8.js";
|
package/dist/runtime/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createAuthUsers } from "../server-
|
|
1
|
+
import { n as createAuthUsers } from "../server-DvSehkPP.js";
|
|
2
2
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
3
3
|
// src/runtime/auth.ts
|
|
4
4
|
const authServer = () => import("@vite-hub/auth/internal/server");
|
package/dist/runtime/console.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as describeCommentContext } from "../context-DbkBjITZ.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as installedComments } from "../plugin-
|
|
2
|
+
import { i as commentsPageScope } from "../page-2NzFladc.js";
|
|
3
|
+
import { n as installedComments } from "../plugin-l4sPt5-n.js";
|
|
4
4
|
// src/runtime/console.ts
|
|
5
5
|
function excerpt(text) {
|
|
6
6
|
const line = text.replace(/\s+/g, " ").trim();
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { g as CommentsUser } from "../define-B1jLSPe9.js";
|
|
|
3
3
|
import { t as Comments } from "../index-D1T7RJ4R.js";
|
|
4
4
|
import { f as CommentsRequestEvent } from "../types-l6GOb_yc.js";
|
|
5
5
|
import { t as CommentsSessionOptions } from "../session-CN4irEqf.js";
|
|
6
|
-
import { t as InstallCommentsOptions } from "../install-
|
|
6
|
+
import { t as InstallCommentsOptions } from "../install-9L4ASzUC.js";
|
|
7
7
|
import { t as CommentsDatabase } from "../store-DvNTDNgn.js";
|
|
8
8
|
/**
|
|
9
9
|
* A person that Site access in the ViteHub Console signed in to the app: a Console member, or a guest, with their roles,
|
|
@@ -163,6 +163,8 @@ interface CommentsPluginOptions extends CommentsSessionOptions {
|
|
|
163
163
|
dialect?: InstallCommentsOptions["dialect"];
|
|
164
164
|
/** Loads `@vite-hub/webhooks`, when `defineComments({ send })` is on. */
|
|
165
165
|
webhooks?: InstallCommentsOptions["webhooks"];
|
|
166
|
+
/** Loads `@vite-hub/comments/realtime`, when the app has the page presence rooms. */
|
|
167
|
+
realtime?: InstallCommentsOptions["realtime"];
|
|
166
168
|
/** Install more segments of the pill, such as the **Console** segment of `vite-hub`. Only with the overlay on. */
|
|
167
169
|
pillSegments?: ReadonlyArray<(nitroApp: unknown, context: {
|
|
168
170
|
base?: string;
|
package/dist/runtime/index.js
CHANGED
|
@@ -3,15 +3,15 @@ import { t as forwardedRequestOrigin } from "../request-origin-YPzfE2eh.js";
|
|
|
3
3
|
import "../client-files-lC6X7XyS.js";
|
|
4
4
|
import { t as commentsErrors } from "../errors-C0VwRHiy.js";
|
|
5
5
|
import { i as text, n as guestFromHeaders, t as authorOf } from "../identity-CT7-UGmS.js";
|
|
6
|
-
import { a as runtimeOf, r as resolveCommentsRuntime, t as commentSendOf } from "../installed-
|
|
7
|
-
import { a as commentThreadSummary, c as hiddenThreadsNote, n as commentAnchorSchema, o as commentThreadsText, r as commentInputSchemas, s as describeCommentThread, t as commentActions } from "../operations-
|
|
8
|
-
import { c as validateCommentsDefinition, o as deniedForMissingPolicy } from "../define-
|
|
9
|
-
import { h as readAttachment, i as contextSchema, n as base64, o as deniedError, p as mentionedPeople, r as can } from "../service-
|
|
10
|
-
import {
|
|
11
|
-
import { n as resolveCommentsPage, o as viteHubPageSessionHandler, t as resolveCommentsIdentity } from "../session-
|
|
12
|
-
import { n as installedComments, t as defineCommentsPlugin } from "../plugin-
|
|
6
|
+
import { a as runtimeOf, r as resolveCommentsRuntime, t as commentSendOf } from "../installed-bPUnazFf.js";
|
|
7
|
+
import { a as commentThreadSummary, c as hiddenThreadsNote, n as commentAnchorSchema, o as commentThreadsText, r as commentInputSchemas, s as describeCommentThread, t as commentActions } from "../operations-B1ALn4VS.js";
|
|
8
|
+
import { c as validateCommentsDefinition, o as deniedForMissingPolicy } from "../define-C2tnAtBU.js";
|
|
9
|
+
import { h as readAttachment, i as contextSchema, n as base64, o as deniedError, p as mentionedPeople, r as can } from "../service-BIGe1Hpo.js";
|
|
10
|
+
import { c as normalizeCommentPage, i as commentsPageScope, o as commentsRoute } from "../page-2NzFladc.js";
|
|
11
|
+
import { n as resolveCommentsPage, o as viteHubPageSessionHandler, t as resolveCommentsIdentity } from "../session-CCRLR9bf.js";
|
|
12
|
+
import { n as installedComments, t as defineCommentsPlugin } from "../plugin-l4sPt5-n.js";
|
|
13
13
|
import { t as invariant } from "../invariant-CmdvZ3vp.js";
|
|
14
|
-
import { t as commentsErrorDiagnostics } from "../errors-
|
|
14
|
+
import { t as commentsErrorDiagnostics } from "../errors-ByCRdInk.js";
|
|
15
15
|
import { getStandardContext, installRequestStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { configuredConsoleOrigin } from "@vite-hub/runtime/internal/console";
|
|
@@ -287,6 +287,7 @@ function createCommentsHandler(options) {
|
|
|
287
287
|
...identity.commentsAgent,
|
|
288
288
|
mcp: `${configuredConsoleOrigin()}/mcp/account`
|
|
289
289
|
} : void 0;
|
|
290
|
+
const repository = read ? comments.options.forge?.repository ?? options.build?.repository : void 0;
|
|
290
291
|
return json({ data: {
|
|
291
292
|
user: user ? authorOf(user) : null,
|
|
292
293
|
...user && user.github ? { github: user.github } : {},
|
|
@@ -304,6 +305,7 @@ function createCommentsHandler(options) {
|
|
|
304
305
|
content: Boolean(options.content),
|
|
305
306
|
...send ? { send: true } : {},
|
|
306
307
|
...agent ? { agent } : {},
|
|
308
|
+
...repository ? { repository } : {},
|
|
307
309
|
...subject ? { subject } : {},
|
|
308
310
|
...revision === void 0 ? {} : { revision }
|
|
309
311
|
} });
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { b as validateCommentsDefinition, d as CommentsPeople } from "./define-B1jLSPe9.js";
|
|
2
|
-
import { a as maximumCommentBodyLength, i as CommentsRuntime, n as CommentsAttachmentStore, r as CommentsForgeHooks } from "./service-
|
|
2
|
+
import { a as maximumCommentBodyLength, i as CommentsRuntime, n as CommentsAttachmentStore, r as CommentsForgeHooks } from "./service-IvgrI4XM.js";
|
|
3
3
|
import { i as createCommentsStore, n as CommentsStore, r as CommentsTables, t as CommentsDatabase } from "./store-DvNTDNgn.js";
|
|
4
|
-
import { a as commentsOperations, i as commentInputSchemas, n as commentActions, r as commentAnchorSchema, t as CommentsCaller } from "./operations-
|
|
4
|
+
import { a as commentsOperations, i as commentInputSchemas, n as commentActions, r as commentAnchorSchema, t as CommentsCaller } from "./operations-BkkrI8a3.js";
|
|
5
5
|
import { n as createRpcTransport, t as RpcTransportOptions } from "./rpc-D-eqtyfh.js";
|
|
6
|
-
import { n as installComments, t as InstallCommentsOptions } from "./install-
|
|
6
|
+
import { n as installComments, t as InstallCommentsOptions } from "./install-9L4ASzUC.js";
|
|
7
7
|
/** Where mentions find people. The same shape as `defineComments({ people })`. */
|
|
8
8
|
export type CommentsUsers = CommentsPeople;
|
|
9
9
|
/**
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as installCommentsRuntime, n as createAuthUsers, r as hasCommentsRuntime, t as commentsRuntime } from "./server-
|
|
2
|
-
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-
|
|
3
|
-
import { t as createRpcTransport } from "./rpc-
|
|
4
|
-
import { f as maximumCommentBodyLength } from "./service-
|
|
5
|
-
import { r as createCommentsStore, t as installComments } from "./install-
|
|
6
|
-
import { c as validateCommentsDefinition } from "./define-
|
|
1
|
+
import { i as installCommentsRuntime, n as createAuthUsers, r as hasCommentsRuntime, t as commentsRuntime } from "./server-DvSehkPP.js";
|
|
2
|
+
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-B1ALn4VS.js";
|
|
3
|
+
import { t as createRpcTransport } from "./rpc-BYmbVkr8.js";
|
|
4
|
+
import { f as maximumCommentBodyLength } from "./service-BIGe1Hpo.js";
|
|
5
|
+
import { r as createCommentsStore, t as installComments } from "./install-D6hXZaSN.js";
|
|
6
|
+
import { c as validateCommentsDefinition } from "./define-C2tnAtBU.js";
|
|
7
7
|
export { commentActions, commentAnchorSchema, commentInputSchemas, commentsOperations, commentsRuntime, createAuthUsers, createCommentsStore, createRpcTransport, hasCommentsRuntime, installComments, installCommentsRuntime, maximumCommentBodyLength, validateCommentsDefinition };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as replyMessageId } from "./reply-id-Cm9FGOBs.js";
|
|
2
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
2
|
+
import { t as commentsErrorDiagnostics } from "./errors-ByCRdInk.js";
|
|
3
3
|
import { t as isPagePath } from "./path-8yqMd8zR.js";
|
|
4
4
|
import { t as foldName } from "./fold-name-g-xg0mQk.js";
|
|
5
5
|
import { r as guestIdPrefix } from "./identity-CT7-UGmS.js";
|
|
6
|
-
import { i as defaultPolicy, o as deniedForMissingPolicy, t as builtinCommentSubjects } from "./define-
|
|
6
|
+
import { i as defaultPolicy, o as deniedForMissingPolicy, t as builtinCommentSubjects } from "./define-C2tnAtBU.js";
|
|
7
7
|
import { t as logFailure } from "./request-log-DllKQXj7.js";
|
|
8
8
|
import * as v from "valibot";
|
|
9
9
|
// ../internal/src/runtime/client-rate-limit.ts
|
|
@@ -113,6 +113,11 @@ const inlineTypes = [
|
|
|
113
113
|
"image/webp",
|
|
114
114
|
"image/avif"
|
|
115
115
|
];
|
|
116
|
+
/** Runs the hooks that follow a change of a thread: the pull request sync and the notice to its open pages. */
|
|
117
|
+
async function threadChanged(runtime, thread) {
|
|
118
|
+
runtime.forge?.changed(thread.id);
|
|
119
|
+
await runtime.changed?.(thread).catch(() => void 0);
|
|
120
|
+
}
|
|
116
121
|
/** An error with the HTTP status that the operation RPC answers. */
|
|
117
122
|
function fail(error, status) {
|
|
118
123
|
return Object.assign(error, { status });
|
|
@@ -447,7 +452,7 @@ async function createThread(runtime, input, options = {}) {
|
|
|
447
452
|
...options.request ? { request: options.request } : {},
|
|
448
453
|
...options.waitUntil ? { waitUntil: options.waitUntil } : {}
|
|
449
454
|
});
|
|
450
|
-
runtime
|
|
455
|
+
await threadChanged(runtime, created);
|
|
451
456
|
return created;
|
|
452
457
|
}
|
|
453
458
|
/** The message that an earlier reply with this `requestId` stored in the thread. A retry gets it back before the reply checks. */
|
|
@@ -514,7 +519,7 @@ async function replyToThread(runtime, thread, input, options = {}) {
|
|
|
514
519
|
...options.request ? { request: options.request } : {},
|
|
515
520
|
...options.waitUntil ? { waitUntil: options.waitUntil } : {}
|
|
516
521
|
});
|
|
517
|
-
runtime
|
|
522
|
+
await threadChanged(runtime, next);
|
|
518
523
|
return {
|
|
519
524
|
message,
|
|
520
525
|
thread: next
|
|
@@ -548,7 +553,7 @@ async function editMessage(runtime, thread, messageId, input, options) {
|
|
|
548
553
|
comment: false,
|
|
549
554
|
...options.waitUntil ? { waitUntil: options.waitUntil } : {}
|
|
550
555
|
});
|
|
551
|
-
runtime
|
|
556
|
+
await threadChanged(runtime, next);
|
|
552
557
|
return next;
|
|
553
558
|
}
|
|
554
559
|
function safeName(name) {
|
|
@@ -661,4 +666,4 @@ async function readAttachment(runtime, key, context) {
|
|
|
661
666
|
type
|
|
662
667
|
};
|
|
663
668
|
}
|
|
664
|
-
export {
|
|
669
|
+
export { threadChanged as C, createClientRateLimit as E, suggest as S, clientRateLimitIssue as T, requestIdSchema as _, createThread as a, scopeOf as b, earlierThread as c, maximumAttachmentBytes as d, maximumCommentBodyLength as f, replyToThread as g, readAttachment as h, contextSchema as i, editMessage as l, personOf as m, base64 as n, deniedError as o, mentionedPeople as p, can as r, earlierReply as s, attachmentThread as t, fail as u, retried as v, clientAddressKey as w, storeAttachment as x, retriedReply as y };
|
|
@@ -65,5 +65,7 @@ interface CommentsRuntime {
|
|
|
65
65
|
background?: (task: Promise<unknown>) => void;
|
|
66
66
|
/** Runs after someone opens a thread again. With Send, it puts back the sends that carried the thread. */
|
|
67
67
|
reopened?: (thread: CommentThread) => Promise<unknown>;
|
|
68
|
+
/** Tells the open pages of a thread that it changed, such as through a Realtime notice to its page room. */
|
|
69
|
+
changed?: (thread: CommentThread) => Promise<void>;
|
|
68
70
|
}
|
|
69
71
|
export { maximumCommentBodyLength as a, CommentsRuntime as i, CommentsAttachmentStore as n, SharedRateLimit as o, CommentsForgeHooks as r, CommentsAttachmentBody as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { f as viteHubPageToolsWanted, l as viteHubPageToolsLoader, n as viteHubBasePath, o as viteHubPageToolsHintCookie, p as withViteHubBase, r as viteHubPageSessionPath, s as viteHubPageToolsInlineScript, t as readViteHubPageAccount, u as viteHubPageToolsMarker } from "./page-tools-shared-fvmJQCrP.js";
|
|
2
2
|
import { r as matchesPublicOrigin, t as forwardedRequestOrigin } from "./request-origin-YPzfE2eh.js";
|
|
3
|
-
import {
|
|
3
|
+
import { c as normalizeCommentPage } from "./page-2NzFladc.js";
|
|
4
4
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
5
5
|
// ../internal/src/runtime/page-tools-html.ts
|
|
6
6
|
/** The effective script-element directive is shared by HTTP and HTML meta policies. */
|
package/dist/testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as replyMessageId } from "./reply-id-Cm9FGOBs.js";
|
|
2
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
2
|
+
import { t as commentsErrorDiagnostics } from "./errors-ByCRdInk.js";
|
|
3
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 });
|
package/dist/vite.d.ts
CHANGED
|
@@ -230,6 +230,7 @@ export declare function renderCommentsPlugin(input: {
|
|
|
230
230
|
build?: CommentBuild;
|
|
231
231
|
base?: string;
|
|
232
232
|
send?: boolean;
|
|
233
|
+
realtime?: boolean;
|
|
233
234
|
}): string;
|
|
234
235
|
/**
|
|
235
236
|
* Comments for any Vite app, without `vite-hub`: the comment overlay on every page with `?vitehub`, threads in a
|
package/dist/vite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as invariant } from "./invariant-CmdvZ3vp.js";
|
|
2
|
-
import { c as validateCommentsDefinition } from "./define-
|
|
3
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
2
|
+
import { c as validateCommentsDefinition } from "./define-C2tnAtBU.js";
|
|
3
|
+
import { t as commentsErrorDiagnostics } from "./errors-ByCRdInk.js";
|
|
4
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
5
|
import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
|
|
6
|
-
import { a as
|
|
6
|
+
import { a as commentsRealtimeDefinition, o as commentsRoute, r as commentsNoticeDefinition, s as mountedCommentsRoute } from "./page-2NzFladc.js";
|
|
7
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";
|
|
@@ -957,6 +957,7 @@ function renderCommentsPlugin(input) {
|
|
|
957
957
|
const postgres = input.session?.dialect === "postgresql";
|
|
958
958
|
const overlay = input.session?.overlay === false ? "false" : JSON.stringify(`${commentsRoute}/assets/overlay.js?v=${version}`);
|
|
959
959
|
const segments = pillSegmentLines(input.session?.overlay === false ? [] : input.session?.pillSegments ?? []);
|
|
960
|
+
const realtime = input.realtime ? `realtime: () => import(${JSON.stringify(input.imports.realtime)})` : void 0;
|
|
960
961
|
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;
|
|
961
962
|
if (input.standalone) {
|
|
962
963
|
const { where, fallback, node } = input.standalone;
|
|
@@ -970,7 +971,7 @@ function renderCommentsPlugin(input) {
|
|
|
970
971
|
"",
|
|
971
972
|
`const database = () => connectDatabase(${where === void 0 ? "undefined" : JSON.stringify(where)}, { ${options.join(", ")} })`,
|
|
972
973
|
"",
|
|
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}` : ""} })`,
|
|
974
|
+
`export default defineCommentsPlugin({ comments, database, schema: "comments", session: ${session.value}, ${session.githubLogin ? "githubLogin, " : ""}development: ${input.development === true}, overlay: ${overlay}, base: ${JSON.stringify(input.base ?? "")}${realtime ? `, ${realtime}` : ""}${segments.value ? `, pillSegments: ${segments.value}` : ""} })`,
|
|
974
975
|
""
|
|
975
976
|
].join("\n");
|
|
976
977
|
}
|
|
@@ -996,6 +997,7 @@ function renderCommentsPlugin(input) {
|
|
|
996
997
|
...input.session?.rateLimit ? ["rateLimit: checkRateLimit"] : [],
|
|
997
998
|
...postgres ? ["dialect: \"postgresql\"", "tables: { commentCounters: schema.vitehubCommentCounters, commentMessages: schema.vitehubCommentMessages, commentThreads: schema.vitehubCommentThreads, commentForge: schema.vitehubCommentForge }"] : [],
|
|
998
999
|
...input.send ? [`webhooks: () => import(${JSON.stringify(input.imports.webhooks)})`] : [],
|
|
1000
|
+
...realtime ? [realtime] : [],
|
|
999
1001
|
`development: ${input.development === true}`,
|
|
1000
1002
|
`overlay: ${overlay}`,
|
|
1001
1003
|
`base: ${JSON.stringify(input.base ?? "")}`,
|
|
@@ -1178,7 +1180,8 @@ function hubComments$1(options = {}) {
|
|
|
1178
1180
|
build,
|
|
1179
1181
|
base: appBase,
|
|
1180
1182
|
standalone,
|
|
1181
|
-
development
|
|
1183
|
+
development,
|
|
1184
|
+
realtime
|
|
1182
1185
|
}));
|
|
1183
1186
|
await addD1Binding(projectRoot, nitro.options, standalone.where);
|
|
1184
1187
|
await addD1Binding(projectRoot, nitro.options, standalone.fallback);
|
|
@@ -1194,20 +1197,32 @@ function hubComments$1(options = {}) {
|
|
|
1194
1197
|
if (!definition) return;
|
|
1195
1198
|
realtime = true;
|
|
1196
1199
|
const file = join(context.directory, "comments.mjs");
|
|
1200
|
+
const notices = join(context.directory, "comments-notices.mjs");
|
|
1197
1201
|
const { repository } = await readCommentsBuild(context.projectRoot);
|
|
1198
1202
|
const session = sessionWithGitHubLines(options, imports, repository, appBase);
|
|
1199
1203
|
await mkdir(context.directory, { recursive: true });
|
|
1200
|
-
|
|
1204
|
+
const importsAndDefinition = [
|
|
1201
1205
|
`import { commentsRealtime } from ${JSON.stringify(imports.realtime)}`,
|
|
1202
1206
|
...definitionLines(definition, imports.runtime),
|
|
1203
1207
|
...session.imports,
|
|
1204
|
-
"",
|
|
1205
|
-
`export default commentsRealtime(comments, { session: ${session.value}${session.githubLogin ? ", githubLogin" : ""} })`,
|
|
1206
1208
|
""
|
|
1207
|
-
]
|
|
1209
|
+
];
|
|
1210
|
+
const sessionOptions = `{ session: ${session.value}${session.githubLogin ? ", githubLogin" : ""} }`;
|
|
1211
|
+
await Promise.all([writeFile(file, [
|
|
1212
|
+
...importsAndDefinition,
|
|
1213
|
+
`export default commentsRealtime(comments, ${sessionOptions})`,
|
|
1214
|
+
""
|
|
1215
|
+
].join("\n")), writeFile(notices, [
|
|
1216
|
+
...importsAndDefinition,
|
|
1217
|
+
`export default commentsRealtime(comments, ${sessionOptions}, "notices")`,
|
|
1218
|
+
""
|
|
1219
|
+
].join("\n"))]);
|
|
1208
1220
|
return { definitions: [{
|
|
1209
1221
|
handler: file,
|
|
1210
1222
|
name: commentsRealtimeDefinition
|
|
1223
|
+
}, {
|
|
1224
|
+
handler: notices,
|
|
1225
|
+
name: commentsNoticeDefinition
|
|
1211
1226
|
}] };
|
|
1212
1227
|
}
|
|
1213
1228
|
},
|
|
@@ -1313,6 +1328,7 @@ function hubComments$1(options = {}) {
|
|
|
1313
1328
|
build,
|
|
1314
1329
|
base,
|
|
1315
1330
|
development,
|
|
1331
|
+
realtime,
|
|
1316
1332
|
send: !options.standalone && await readCommentsSend(definition)
|
|
1317
1333
|
};
|
|
1318
1334
|
await Promise.all([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/comments",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
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.6.
|
|
110
|
-
"@vite-hub/forge": "0.6.
|
|
111
|
-
"@vite-hub/realtime": "0.6.
|
|
112
|
-
"@vite-hub/runtime": "0.6.
|
|
109
|
+
"@vite-hub/auth": "0.6.1",
|
|
110
|
+
"@vite-hub/forge": "0.6.1",
|
|
111
|
+
"@vite-hub/realtime": "0.6.1",
|
|
112
|
+
"@vite-hub/runtime": "0.6.1",
|
|
113
113
|
"birpc": "^4.2.0",
|
|
114
114
|
"confbox": "^0.3.2",
|
|
115
115
|
"h3": "^2.0.8"
|
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
"vitest": "5.1.0",
|
|
129
129
|
"vue": "3.5.46",
|
|
130
130
|
"@libsql/client": "^0.18.0",
|
|
131
|
-
"@vite-hub/database": "0.6.
|
|
131
|
+
"@vite-hub/database": "0.6.1",
|
|
132
132
|
"vite": "^8.3.8",
|
|
133
133
|
"drizzle-orm": "1.0.0-rc.6"
|
|
134
134
|
},
|
|
135
135
|
"peerDependencies": {
|
|
136
|
-
"@vite-hub/database": "0.6.
|
|
136
|
+
"@vite-hub/database": "0.6.1",
|
|
137
137
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
138
138
|
"vite": ">=8.0.0",
|
|
139
139
|
"drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0"
|