@vite-hub/comments 0.4.1 → 0.5.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 +23 -7
- package/dist/anchor.d.ts +3 -5
- package/dist/anchor.js +1 -2
- package/dist/{client-diagnostics-Bubm7Shd.js → client-diagnostics-CvfTW5d4.js} +1 -2
- package/dist/{client-files-CJZl5Kc4.js → client-files-lC6X7XyS.js} +1 -2
- package/dist/client.d.ts +430 -24
- package/dist/client.js +413 -20
- package/dist/{console-h4KlhIik.d.ts → console-CK2F53QP.d.ts} +2 -4
- package/dist/{context-BqIsmYP1.js → context-DbkBjITZ.js} +1 -2
- package/dist/database/postgres.d.ts +1 -3
- package/dist/database/postgres.js +1 -2
- package/dist/{migrate-Bpw3xL5e.js → database-BkPoOdZr.js} +116 -59
- package/dist/database-CPua6Q6_.d.ts +573 -0
- package/dist/{database-CA1aHKN7.d.ts → database-DUs3c2al.d.ts} +625 -73
- package/dist/database.d.ts +4 -5
- package/dist/database.js +1 -2
- package/dist/{define-CX_Yr_hz.js → define-9uMM3Ewc.js} +2 -3
- package/dist/{define-CHTWfHPo.d.ts → define-B1jLSPe9.d.ts} +8 -6
- package/dist/{errors-4gelGVmK.js → errors-C0VwRHiy.js} +25 -2
- package/dist/{errors-BHsVXlpd.js → errors-DFNiJg67.js} +26 -3
- package/dist/{fold-name-B7Zb3-MF.js → fold-name-g-xg0mQk.js} +1 -2
- package/dist/hosted/hosted-comments/client-B3dlmmQd.js +4 -0
- package/dist/{overlay/dist-BoHMOFax.js → hosted/hosted-comments/dist-DyVmH21U.js} +1 -1
- package/dist/hosted/hosted-comments/frame.js +1 -0
- package/dist/hosted/hosted-comments/overlay-4-mWX4Uz.js +170 -0
- package/dist/hosted/hosted-comments/protocol-BHvtQKte.js +1 -0
- package/dist/hosted/hosted-comments/rest-transport-D-9_pNqZ.js +1 -0
- package/dist/hosted/hosted-comments/tools-CdwnUCOr.js +126 -0
- package/dist/hosted/hosted-comments.js +9 -0
- package/dist/{identity-CBOzgxSf.js → identity-CT7-UGmS.js} +1 -2
- package/dist/{index-iPGlSAgj.d.ts → index-BEnHTj2Z.d.ts} +109 -15
- package/dist/index.d.ts +6 -7
- package/dist/index.js +23 -10
- package/dist/{install-96NXWnrw.d.ts → install-B-FQpi47.d.ts} +24 -7
- package/dist/{install-jRKmuLHK.js → install-BUXxryut.js} +950 -55
- package/dist/{installed-g6nDr5ac.js → installed-C9SkldMi.js} +8 -8
- package/dist/{invariant-D8_xBqmZ.js → invariant-CmdvZ3vp.js} +1 -2
- package/dist/{migrate-B0k_0swk.d.ts → migrate-XjFeQppf.d.ts} +2 -2
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/{operations-7ycAhDCw.d.ts → operations-8hqTi0DH.d.ts} +8 -4
- package/dist/{operations-9tskoLsk.js → operations-CKC_lMG_.js} +309 -229
- package/dist/{operations-D93EV10O.d.ts → operations-Cic9A9e_.d.ts} +9 -7
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +2 -2
- package/dist/overlay/{client-lZesR40x.js → client-CerbVjTz.js} +3 -3
- package/dist/overlay/dist-DyVmH21U.js +14 -0
- package/dist/overlay/overlay.js +36 -40
- package/dist/page/loader.js +45 -52
- package/dist/page-DE71P_gQ.d.ts +11 -0
- package/dist/{page-tools-shared-NHUjKI8E.js → page-tools-shared-fvmJQCrP.js} +8 -5
- package/dist/{page-DRz_sDY4.js → page-xzgZ6DGm.js} +2 -3
- package/dist/{path--zk6PEMz.js → path-8yqMd8zR.js} +0 -1
- package/dist/{plugin-BNFd1zGz.js → plugin-B2hETRii.js} +16 -13
- package/dist/realtime.d.ts +3 -5
- package/dist/realtime.js +4 -5
- package/dist/{reply-id-P_bSuEng.js → reply-id-Cm9FGOBs.js} +1 -2
- package/dist/request-log-DllKQXj7.js +104 -0
- package/dist/request-origin-YPzfE2eh.js +48 -0
- package/dist/{rpc-BQqYx8kb.js → rpc-BKY7XRlR.js} +5 -7
- package/dist/{rpc-BZ1QNkCC.d.ts → rpc-D-eqtyfh.d.ts} +1 -3
- package/dist/rpc.d.ts +1 -1
- package/dist/rpc.js +1 -2
- package/dist/runtime/auth.d.ts +3 -5
- package/dist/runtime/auth.js +2 -3
- package/dist/runtime/console.d.ts +2 -4
- package/dist/runtime/console.js +4 -5
- package/dist/runtime/index.d.ts +12 -27
- package/dist/runtime/index.js +160 -31
- package/dist/{server-CqyzrqTI.js → server-BGbD7H5s.js} +2 -3
- package/dist/server.d.ts +6 -7
- package/dist/server.js +6 -6
- package/dist/service-CPiWPoiY.d.ts +69 -0
- package/dist/{service-C8ZgFWvy.js → service-DDD4Ubxd.js} +44 -18
- package/dist/{session-ByjMyTak.js → session-BGN6Vlm6.js} +31 -37
- package/dist/{session-CKfW6DGE.d.ts → session-CTh9nisq.d.ts} +3 -5
- package/dist/{service-wC9kx9EX.d.ts → store-DvNTDNgn.d.ts} +3 -73
- package/dist/{table-names-DfiKUlOV.js → table-names-BIHjuEFK.js} +4 -3
- package/dist/testing.d.ts +2 -4
- package/dist/testing.js +4 -5
- package/dist/{tokens-DSbwkVSy.js → tokens-Bx4lZ0yt.js} +3 -6
- package/dist/{types-C7LzhgRb.d.ts → types-BX3vH18p.d.ts} +1 -3
- package/dist/{types-C1qzObs2.d.ts → types-l6GOb_yc.d.ts} +79 -6
- package/dist/vite.d.ts +22 -21
- package/dist/vite.js +161 -104
- package/package.json +19 -19
- package/dist/errors-BEChnUo7.d.ts +0 -197
- package/dist/page-CWwnmF3K.d.ts +0 -22
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { o as
|
|
2
|
-
import {
|
|
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
|
+
import { r as matchesPublicOrigin, t as forwardedRequestOrigin } from "./request-origin-YPzfE2eh.js";
|
|
3
|
+
import { o as normalizeCommentPage } from "./page-xzgZ6DGm.js";
|
|
3
4
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
4
|
-
|
|
5
|
+
// ../internal/src/runtime/page-tools-html.ts
|
|
5
6
|
/** The effective script-element directive is shared by HTTP and HTML meta policies. */
|
|
6
7
|
function scriptPolicyNonce(policy) {
|
|
7
8
|
const directives = policy.split(";").map((part) => part.trim());
|
|
@@ -29,7 +30,7 @@ function isGeneratedCheck(inline) {
|
|
|
29
30
|
try {
|
|
30
31
|
const path = JSON.parse(inline.slice(at + 7, -1));
|
|
31
32
|
const nonce = tagNonce(inline);
|
|
32
|
-
return typeof path === "string" && path.endsWith("/_vitehub/page/assets/loader.js?v=
|
|
33
|
+
return typeof path === "string" && path.endsWith("/_vitehub/page/assets/loader.js?v=22") && viteHubPageToolsInlineScript(path.slice(0, -36), nonce) === `${inline}<\/script>`;
|
|
33
34
|
} catch {
|
|
34
35
|
return false;
|
|
35
36
|
}
|
|
@@ -143,7 +144,7 @@ function pageToolsHtmlTransform(loader) {
|
|
|
143
144
|
}
|
|
144
145
|
if (!closing && name && /^(script|style|textarea|title|xmp|iframe|noembed|noframes|noscript|plaintext)$/.test(name)) {
|
|
145
146
|
rawText = name;
|
|
146
|
-
if (!templates && token.replace(/ nonce="[\w+/=-]+"/, "") ===
|
|
147
|
+
if (!templates && token.replace(/ nonce="[\w+/=-]+"/, "") === "<script type=\"module\" data-vitehub-page-tools>") {
|
|
147
148
|
inline = token;
|
|
148
149
|
present = true;
|
|
149
150
|
continue;
|
|
@@ -162,30 +163,7 @@ function pageToolsHtmlTransform(loader) {
|
|
|
162
163
|
}
|
|
163
164
|
});
|
|
164
165
|
}
|
|
165
|
-
|
|
166
|
-
//#region ../internal/src/runtime/request-origin.ts
|
|
167
|
-
function firstHeaderValue(headers, name) {
|
|
168
|
-
return headers.get(name)?.split(",", 1)[0]?.trim() || void 0;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* The origin that the client used for `request`. A TLS-terminating proxy sends the client scheme in
|
|
172
|
-
* `X-Forwarded-Proto` and the client host in `X-Forwarded-Host`. Each proxy appends its value, so the first value wins.
|
|
173
|
-
* Without these headers, or with values that are not valid, the result is the origin of `request.url`.
|
|
174
|
-
*/
|
|
175
|
-
function forwardedRequestOrigin(request) {
|
|
176
|
-
const url = new URL(request.url);
|
|
177
|
-
const forwardedProtocol = firstHeaderValue(request.headers, "x-forwarded-proto")?.toLowerCase();
|
|
178
|
-
const protocol = forwardedProtocol === "http" || forwardedProtocol === "https" ? forwardedProtocol : url.protocol.slice(0, -1);
|
|
179
|
-
const host = firstHeaderValue(request.headers, "x-forwarded-host") ?? url.host;
|
|
180
|
-
if (/[\u0000-\u001F\s/\\?#@]/.test(host)) return url.origin;
|
|
181
|
-
try {
|
|
182
|
-
return new URL(`${protocol}://${host}`).origin;
|
|
183
|
-
} catch {
|
|
184
|
-
return url.origin;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region ../internal/src/runtime/page-tools.ts
|
|
166
|
+
// ../internal/src/runtime/page-tools.ts
|
|
189
167
|
const stateKey = Symbol.for("vitehub.page-tools");
|
|
190
168
|
const scope = globalThis;
|
|
191
169
|
function state() {
|
|
@@ -224,6 +202,10 @@ async function readAccount(nitroApp, request) {
|
|
|
224
202
|
function viteHubSiteVisitorReader() {
|
|
225
203
|
return state().siteVisitor;
|
|
226
204
|
}
|
|
205
|
+
/** Whether the app serves its page tools on the origin of the request. Every origin counts for an app without `origins`. */
|
|
206
|
+
function servesOrigin(nitroApp, request) {
|
|
207
|
+
return matchesPublicOrigin(request, state().origins?.get(nitroApp) ?? []);
|
|
208
|
+
}
|
|
227
209
|
/** The path of a URL below the app base. A path outside the base stays as it is. */
|
|
228
210
|
function pathBelow(base, pathname) {
|
|
229
211
|
return base && (pathname === base || pathname.startsWith(`${base}/`)) ? pathname.slice(base.length) || "/" : pathname;
|
|
@@ -241,6 +223,7 @@ function isPagePath(url, base) {
|
|
|
241
223
|
function pageAddition(nitroApp, request, base) {
|
|
242
224
|
const url = new URL(request.url);
|
|
243
225
|
if ((state().tools.get(nitroApp)?.size ?? 0) === 0 || !isPagePath(url, base)) return void 0;
|
|
226
|
+
if (!request.headers.has("x-nitro-prerender") && !servesOrigin(nitroApp, request)) return void 0;
|
|
244
227
|
return viteHubPageToolsWanted(url.search, request.headers.get("cookie") ?? "") ? "loader" : "bootstrap";
|
|
245
228
|
}
|
|
246
229
|
function loaderTag(base, nonce) {
|
|
@@ -258,12 +241,13 @@ function sessionResponse(value, init = {}) {
|
|
|
258
241
|
});
|
|
259
242
|
}
|
|
260
243
|
/**
|
|
261
|
-
* Answers `GET <base>/_vitehub/page/
|
|
244
|
+
* Answers `GET <base>/_vitehub/page/tools`: the tools whose `allowed` check passes for this visitor, in registration
|
|
262
245
|
* order. The app base is the part of the request path before the session path, as the Console finds its own base, and
|
|
263
246
|
* each tool `script` path gets it. When at least one tool is allowed, the answer also has the `account` of a signed-in
|
|
264
247
|
* visitor, from the reader of `registerViteHubPageAccount()`. An anonymous visitor never gets one. It sets the hint cookie to `1` when at least one tool is allowed, and to `0` when
|
|
265
248
|
* none is, so a signed-in person without access does not ask again on each page. A tool whose check throws is not
|
|
266
|
-
* allowed. Requests from other sites get 403 and run no check.
|
|
249
|
+
* allowed. Requests from other sites get 403 and run no check. An origin that the app does not serve its page tools on
|
|
250
|
+
* gets 404.
|
|
267
251
|
*/
|
|
268
252
|
async function respondViteHubPageSession(nitroApp, request) {
|
|
269
253
|
if (request.method !== "GET" && request.method !== "HEAD") return sessionResponse({ error: {
|
|
@@ -275,6 +259,10 @@ async function respondViteHubPageSession(nitroApp, request) {
|
|
|
275
259
|
code: "VITEHUB_PAGE_TOOLS_CROSS_ORIGIN",
|
|
276
260
|
why: "The page tools session answers the site's own pages only."
|
|
277
261
|
} }, { status: 403 });
|
|
262
|
+
if (!servesOrigin(nitroApp, request)) return sessionResponse({ error: {
|
|
263
|
+
code: "VITEHUB_PAGE_TOOLS_ORIGIN",
|
|
264
|
+
why: "The page tools answer only on the public URL of the app."
|
|
265
|
+
} }, { status: 404 });
|
|
278
266
|
const registered = [...state().tools.get(nitroApp)?.values() ?? []];
|
|
279
267
|
const checks = await Promise.all(registered.map(async (tool) => {
|
|
280
268
|
try {
|
|
@@ -299,8 +287,8 @@ async function respondViteHubPageSession(nitroApp, request) {
|
|
|
299
287
|
} : { tools }, { cookie: viteHubPageToolsHintCookie(tools.length > 0) });
|
|
300
288
|
}
|
|
301
289
|
/**
|
|
302
|
-
* The route of `GET /_vitehub/page/
|
|
303
|
-
* app in `
|
|
290
|
+
* The route of `GET /_vitehub/page/tools`: a Fetchable (https://fetchable.org). `installViteHubPageTools()` binds
|
|
291
|
+
* each Request to its app in Nitro's `request` hook, so the route finds the tools of that app.
|
|
304
292
|
*/
|
|
305
293
|
const viteHubPageSessionHandler = { async fetch(request) {
|
|
306
294
|
const nitroApp = state().apps.get(request);
|
|
@@ -412,13 +400,21 @@ function transformPage(response, tag, personal) {
|
|
|
412
400
|
* static assets, still shows the pill. Call it from each owner's Nitro plugin: it installs once per app, whatever the
|
|
413
401
|
* number of calls. It reads that app's registry and configured base on each request, so plugin order does not matter.
|
|
414
402
|
* It wraps `nitroApp.fetch`, the Web entry that every preset and the prerenderer call. The tag uses `options.base`.
|
|
403
|
+
* It binds each request to the app in Nitro's `request` hook too, since another wrapper of `fetch` may pass a copy of
|
|
404
|
+
* the request inward, such as the `security` policy of `vite-hub` on Node.js.
|
|
415
405
|
*/
|
|
416
406
|
function installViteHubPageTools(nitroApp, options = {}) {
|
|
417
407
|
if (nitroApp === null || typeof nitroApp !== "object") return;
|
|
418
408
|
const { installed, bases } = state();
|
|
419
409
|
if (options.base !== void 0) bases.set(nitroApp, viteHubBasePath(options.base));
|
|
410
|
+
if (options.origins !== void 0) (state().origins ??= /* @__PURE__ */ new WeakMap()).set(nitroApp, options.origins);
|
|
420
411
|
if (installed.has(nitroApp)) return;
|
|
421
412
|
installed.add(nitroApp);
|
|
413
|
+
const hooks = Reflect.get(nitroApp, "hooks");
|
|
414
|
+
const hook = hooks && typeof hooks === "object" ? Reflect.get(hooks, "hook") : void 0;
|
|
415
|
+
if (hook instanceof Function) Reflect.apply(hook, hooks, ["request", (event) => {
|
|
416
|
+
if (event?.req instanceof Request) state().apps.set(event.req, nitroApp);
|
|
417
|
+
}]);
|
|
422
418
|
const fetch = Reflect.get(nitroApp, "fetch");
|
|
423
419
|
if (fetch instanceof Function) {
|
|
424
420
|
Reflect.set(nitroApp, "fetch", async (request, ...rest) => {
|
|
@@ -436,8 +432,7 @@ function installViteHubPageTools(nitroApp, options = {}) {
|
|
|
436
432
|
return;
|
|
437
433
|
}
|
|
438
434
|
}
|
|
439
|
-
|
|
440
|
-
//#region src/runtime/session.ts
|
|
435
|
+
// src/runtime/session.ts
|
|
441
436
|
/**
|
|
442
437
|
* The person that Site access in the Console signed in to an app without Auth, with their roles in `role`, as
|
|
443
438
|
* `commentsRoleAllows()` reads them. A Console member has `comments-*` roles, a guest the roles of the invite.
|
|
@@ -499,5 +494,4 @@ async function resolveCommentsPage(comments, event, request, path) {
|
|
|
499
494
|
...mapped.revision === void 0 ? {} : { revision: mapped.revision }
|
|
500
495
|
};
|
|
501
496
|
}
|
|
502
|
-
|
|
503
|
-
export { viteHubPageSessionHandler as a, registerViteHubPageTool as i, resolveCommentsPage as n, forwardedRequestOrigin as o, installViteHubPageTools as r, resolveCommentsIdentity as t };
|
|
497
|
+
export { viteHubPageSessionHandler as a, registerViteHubPageTool as i, resolveCommentsPage as n, installViteHubPageTools as r, resolveCommentsIdentity as t };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import "./
|
|
4
|
-
//#region src/runtime/session.d.ts
|
|
1
|
+
import "./index-BEnHTj2Z.js";
|
|
2
|
+
import { g as CommentsUser } from "./define-B1jLSPe9.js";
|
|
3
|
+
import { f as CommentsRequestEvent } from "./types-l6GOb_yc.js";
|
|
5
4
|
interface CommentsSessionOptions {
|
|
6
5
|
/** Reads the ViteHub Auth user only when no custom `identify` is configured. */
|
|
7
6
|
session?: (event: CommentsRequestEvent) => Promise<CommentsUser | null | undefined>;
|
|
@@ -10,5 +9,4 @@ interface CommentsSessionOptions {
|
|
|
10
9
|
user: (event: CommentsRequestEvent) => Promise<CommentsUser | null>;
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
|
-
//#endregion
|
|
14
12
|
export { CommentsSessionOptions as t };
|
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { i as commentThreads, r as commentMessages, t as commentCounters } from "./database-CA1aHKN7.js";
|
|
4
|
-
import "valibot";
|
|
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";
|
|
5
3
|
import { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
6
|
-
//#region ../internal/src/runtime/client-rate-limit.d.ts
|
|
7
|
-
/** The part of `checkRateLimit()` from `vite-hub/rate-limit` that a public write calls. */
|
|
8
|
-
type SharedRateLimit = (request: Request, name: string, options: {
|
|
9
|
-
key: string;
|
|
10
|
-
limit: number;
|
|
11
|
-
window: `${number}${"ms" | "s" | "m" | "h" | "d"}`;
|
|
12
|
-
}) => Promise<[unknown, {
|
|
13
|
-
allowed: boolean;
|
|
14
|
-
reason?: string;
|
|
15
|
-
retryAfter?: number;
|
|
16
|
-
cause?: unknown;
|
|
17
|
-
} | undefined]>;
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/operations-core/store.d.ts
|
|
20
4
|
/**
|
|
21
5
|
* The Drizzle database that the store uses. The store calls `select`, `insert`, `update`, and `delete` (with
|
|
22
6
|
* `onConflictDoNothing()` and `returning()`), which SQLite, libSQL, D1, and Postgres Drizzle databases all offer, and
|
|
@@ -108,58 +92,4 @@ interface CommentsStore {
|
|
|
108
92
|
knownUsersByIds: (ids: readonly string[], canRead: (thread: CommentThread) => Promise<boolean>) => Promise<CommentUser[]>;
|
|
109
93
|
}
|
|
110
94
|
declare function createCommentsStore(database: CommentsDatabase, tables?: CommentsTables): CommentsStore;
|
|
111
|
-
|
|
112
|
-
//#region src/operations-core/service.d.ts
|
|
113
|
-
/** Longest message, in characters. */
|
|
114
|
-
declare const maximumCommentBodyLength = 10000;
|
|
115
|
-
/** The parts of a Blob store that attachments use: `blob` of `@vite-hub/blob`. */
|
|
116
|
-
interface CommentsAttachmentStore {
|
|
117
|
-
put: (pathname: string, body: Uint8Array, options: {
|
|
118
|
-
contentType: string;
|
|
119
|
-
}) => Promise<readonly [unknown, unknown]>;
|
|
120
|
-
get?: (pathname: string) => Promise<readonly [unknown, Blob | null | undefined]>;
|
|
121
|
-
}
|
|
122
|
-
/** A file to answer, with the headers that keep a browser from running it. */
|
|
123
|
-
interface CommentsAttachmentBody {
|
|
124
|
-
key: string;
|
|
125
|
-
name: string;
|
|
126
|
-
/** The stored media type when Comments attaches that type, else `application/octet-stream`. */
|
|
127
|
-
type: string;
|
|
128
|
-
size: number;
|
|
129
|
-
/** Whether a browser may show it in the page: images other than SVG. */
|
|
130
|
-
inline: boolean;
|
|
131
|
-
data: Blob;
|
|
132
|
-
}
|
|
133
|
-
/** The pull request sync of `defineComments({ forge })`. */
|
|
134
|
-
interface CommentsForgeHooks {
|
|
135
|
-
/** Starts the sync of a thread after a change. */
|
|
136
|
-
changed: (threadId: string) => void;
|
|
137
|
-
/** The threads with their `forge` link. */
|
|
138
|
-
attach: (threads: CommentThread[]) => Promise<CommentThread[]>;
|
|
139
|
-
}
|
|
140
|
-
/** Everything that the comment operations, the server API, and the overlay API share. */
|
|
141
|
-
interface CommentsRuntime {
|
|
142
|
-
definition: CommentsDefinition;
|
|
143
|
-
/**
|
|
144
|
-
* The app's `identify`, given the server event of a call. With it, the comment operations ask it for the user, as
|
|
145
|
-
* the overlay API does, instead of taking the Console's user.
|
|
146
|
-
*/
|
|
147
|
-
identify?: (event: unknown) => Promise<CommentsUser | null>;
|
|
148
|
-
store: CommentsStore;
|
|
149
|
-
/** The Auth adapter. `people` wins over it. Without both, `@` finds the authors that the store knows. */
|
|
150
|
-
users?: CommentsPeople;
|
|
151
|
-
/** Vite's serve command, for the default guest policy. */
|
|
152
|
-
development?: boolean;
|
|
153
|
-
/** The Blob store for attachments, when the app has one and no `storeAttachment`. */
|
|
154
|
-
attachments?: CommentsAttachmentStore;
|
|
155
|
-
forge?: CommentsForgeHooks;
|
|
156
|
-
/**
|
|
157
|
-
* `checkRateLimit` of ViteHub Rate Limit, when it counts in a KV store that every server process shares. Guest writes
|
|
158
|
-
* then count under the Rate Limit name `comments`. Without it, they count in the memory of this process.
|
|
159
|
-
*/
|
|
160
|
-
rateLimit?: SharedRateLimit;
|
|
161
|
-
/** Work that runs after the answer, such as `onMention`. `flush()` of the server API waits for it. */
|
|
162
|
-
background?: (task: Promise<unknown>) => void;
|
|
163
|
-
}
|
|
164
|
-
//#endregion
|
|
165
|
-
export { maximumCommentBodyLength as a, CommentsTables as c, CommentsRuntime as i, createCommentsStore as l, CommentsAttachmentStore as n, CommentsDatabase as o, CommentsForgeHooks as r, CommentsStore as s, CommentsAttachmentBody as t, SharedRateLimit as u };
|
|
95
|
+
export { createCommentsStore as i, CommentsStore as n, CommentsTables as r, CommentsDatabase as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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
|
|
@@ -10,5 +10,6 @@ const commentsTableNames = {
|
|
|
10
10
|
vitehubCommentCounters: "vitehub_comment_counters",
|
|
11
11
|
vitehubCommentForge: "vitehub_comment_forge"
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/** The tables of `commentSendsSchema`: each schema key and its SQL name. Comments adds them when `send` is on. */
|
|
14
|
+
const commentSendsTableNames = { commentSends: "vitehub_comment_sends" };
|
|
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-
|
|
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-
|
|
2
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
3
|
-
|
|
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
|
}
|
|
@@ -98,7 +98,7 @@ function view(store, user) {
|
|
|
98
98
|
return threads.sort((a, b) => a.n - b.n).map(copy);
|
|
99
99
|
},
|
|
100
100
|
async get(input) {
|
|
101
|
-
const found = "
|
|
101
|
+
const found = "threadId" in input ? store.threads.get(input.threadId) : [...store.threads.values()].find((item) => item.n === input.n && item.scope === input.scope);
|
|
102
102
|
return found ? copy(found) : null;
|
|
103
103
|
},
|
|
104
104
|
async create(input) {
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -249,7 +248,7 @@ interface CommentListCursor {
|
|
|
249
248
|
}
|
|
250
249
|
/** By id, or by number inside its scope, as `?comment=<n>` names it. */
|
|
251
250
|
type CommentGetInput = {
|
|
252
|
-
|
|
251
|
+
threadId: string;
|
|
253
252
|
} | {
|
|
254
253
|
scope: string;
|
|
255
254
|
n: number;
|
|
@@ -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 {
|
|
2
|
-
import {
|
|
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;
|
|
@@ -52,7 +51,80 @@ interface CommentsPageContext {
|
|
|
52
51
|
interface CommentsPageSubject extends CommentSubject {
|
|
53
52
|
revision?: number;
|
|
54
53
|
}
|
|
54
|
+
/** What `send.address` gets: the member who presses Send, and the subject of their page. */
|
|
55
|
+
interface CommentSendAddressContext {
|
|
56
|
+
user: CommentsUser;
|
|
57
|
+
subject: CommentSubject;
|
|
58
|
+
}
|
|
59
|
+
/** What `send.payload` gets: one send, before Comments delivers it. */
|
|
60
|
+
interface CommentSendPayloadContext {
|
|
61
|
+
/** The id of the send, as `send` of the delivered body. */
|
|
62
|
+
send: string;
|
|
63
|
+
/** The member who pressed Send. */
|
|
64
|
+
user: CommentsUser;
|
|
65
|
+
/** The subject of the page that the member sent from. */
|
|
66
|
+
subject: CommentSubject;
|
|
67
|
+
/** The threads of the send. `asks` and `quotes` split their ids. */
|
|
68
|
+
threads: readonly CommentThread[];
|
|
69
|
+
asks: readonly string[];
|
|
70
|
+
quotes: readonly string[];
|
|
71
|
+
}
|
|
72
|
+
/** What `send.prompt` gets: the values of one setup code, and the default prompt. */
|
|
73
|
+
interface CommentSendPromptContext {
|
|
74
|
+
/** The member who pressed Send. */
|
|
75
|
+
user: CommentsUser;
|
|
76
|
+
/** The subject of the page that the member pairs from. */
|
|
77
|
+
subject: CommentSubject;
|
|
78
|
+
/** The public origin of the app, such as `https://joyandmaxi.com`. */
|
|
79
|
+
origin: string;
|
|
80
|
+
/** The URL that the agent posts the code to: `{ code, url, thread }` for a T3 task, or `{ code, inbox }` for an inbox. */
|
|
81
|
+
pairUrl: string;
|
|
82
|
+
/** The setup code. It works once, for 10 minutes. */
|
|
83
|
+
code: string;
|
|
84
|
+
/** The secret that signs each delivery to a T3 webhook task. */
|
|
85
|
+
secret: string;
|
|
86
|
+
/** Whether each send carries a read token. `false` when `grant` is `false`. */
|
|
87
|
+
grant: boolean;
|
|
88
|
+
/** The default prompt: the steps that connect a T3 Code thread. */
|
|
89
|
+
prompt: string;
|
|
90
|
+
}
|
|
91
|
+
/** A JSON value, as the delivered body holds it. */
|
|
92
|
+
type CommentSendData = string | number | boolean | null | CommentSendData[] | {
|
|
93
|
+
[key: string]: CommentSendData;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Send: a member hands the threads that wait for an answer to their own agent, such as a T3 Code thread. Each member
|
|
97
|
+
* pairs their agent once, in the comment pill.
|
|
98
|
+
*/
|
|
99
|
+
interface CommentSendOptions {
|
|
100
|
+
/** Adds `data` to the delivered body, such as the id of a document that your own MCP reads. Default: `null`. */
|
|
101
|
+
payload?: (context: CommentSendPayloadContext) => CommentSendData | Promise<CommentSendData>;
|
|
102
|
+
/**
|
|
103
|
+
* The address of the agent that should get a send from this subject, such as the T3 thread link that wrote the
|
|
104
|
+
* document. A member who paired an agent from that thread sends there; otherwise to the agent they paired last.
|
|
105
|
+
* Default: none, so every send goes to the agent the member paired last.
|
|
106
|
+
*/
|
|
107
|
+
address?: (context: CommentSendAddressContext) => string | null | undefined | Promise<string | null | undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* `false` sends no read token: the agent reads the threads through your own MCP server, as the member. Default: each
|
|
110
|
+
* send carries a token that reads its threads, as the member, for 24 hours.
|
|
111
|
+
*/
|
|
112
|
+
grant?: false;
|
|
113
|
+
/** The hosts that a paired agent URL may use. Default: `["relay.t3.codes"]`, the T3 Code relay. */
|
|
114
|
+
hosts?: readonly string[];
|
|
115
|
+
/**
|
|
116
|
+
* The setup prompt that Send copies, such as to add the steps of a Claude Code or Codex inbox, or to name the tools of
|
|
117
|
+
* your own MCP server. Default: `context.prompt`, the steps that connect a T3 Code thread.
|
|
118
|
+
*/
|
|
119
|
+
prompt?: (context: CommentSendPromptContext) => string | Promise<string>;
|
|
120
|
+
}
|
|
55
121
|
interface DefineCommentsOptions extends CommentsDefinition {
|
|
122
|
+
/**
|
|
123
|
+
* `true` turns on **Send** in the comment pill, for signed-in people who may write. It needs Webhooks and a SQLite
|
|
124
|
+
* Database: ViteHub adds the `vitehub_comment_sends` tables and the member endpoints of Webhooks. See
|
|
125
|
+
* https://vitehub.dev/docs/comments/send
|
|
126
|
+
*/
|
|
127
|
+
send?: boolean | CommentSendOptions;
|
|
56
128
|
/** Resolves the user of a request. Without it, Comments reads the ViteHub Auth session. Return `null` for anonymous. */
|
|
57
129
|
identify?: (context: CommentsIdentifyContext) => CommentsUser | null | undefined | Promise<CommentsUser | null | undefined>;
|
|
58
130
|
/** Name of the Database that stores comments. Defaults to the `default` Database, or the only one. */
|
|
@@ -111,6 +183,8 @@ interface EditCommentInput {
|
|
|
111
183
|
interface ReplyInput {
|
|
112
184
|
body: string;
|
|
113
185
|
author: CommentUser;
|
|
186
|
+
/** The agent replying on behalf of the author. */
|
|
187
|
+
actor?: CommentActor;
|
|
114
188
|
mentions?: string[];
|
|
115
189
|
attachments?: string[];
|
|
116
190
|
/** A retry key. A second reply with the same key and author in the same thread returns the first message. */
|
|
@@ -128,6 +202,5 @@ interface ReplyOptions {
|
|
|
128
202
|
allowResolved?: boolean;
|
|
129
203
|
}
|
|
130
204
|
/** Codes of the errors that Comments methods return in the `[error, data]` tuple. */
|
|
131
|
-
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";
|
|
132
|
-
|
|
133
|
-
export { CommentsPageContext as a, CreateCommentThreadInput as c, FindCommentThreadInput as d, ListCommentThreadsOptions as f, CommentsIdentifyContext as i, 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 };
|
|
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";
|
|
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-
|
|
2
|
-
import "./
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
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-CK2F53QP.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,8 +47,6 @@ 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`. */
|
|
@@ -74,6 +67,8 @@ interface CommentsImports {
|
|
|
74
67
|
blob: string;
|
|
75
68
|
/** Exports `checkRateLimit`, which counts guest writes when Rate Limit counts in a shared KV store. */
|
|
76
69
|
rateLimit: string;
|
|
70
|
+
/** `@vite-hub/webhooks`: the member endpoints that `defineComments({ send })` delivers to. */
|
|
71
|
+
webhooks: string;
|
|
77
72
|
}
|
|
78
73
|
/** Options of `comments()`, for apps that use Comments without `vite-hub`. */
|
|
79
74
|
interface CommentsOptions {
|
|
@@ -161,6 +156,15 @@ type CommentsVitePlugin$1 = Plugin & {
|
|
|
161
156
|
};
|
|
162
157
|
vitehub: ViteHubInspectionPluginMetadata & {
|
|
163
158
|
databases: (context: DatabaseContributionContext) => Promise<DatabaseContributionEntry[]>;
|
|
159
|
+
/** Turns on the member endpoints of Webhooks while `defineComments({ send })` is on. */
|
|
160
|
+
webhooks: (context: {
|
|
161
|
+
root?: string;
|
|
162
|
+
projectRoot?: string;
|
|
163
|
+
serverDirs?: readonly string[];
|
|
164
|
+
}) => Promise<{
|
|
165
|
+
memberEndpoints: true;
|
|
166
|
+
reason: string;
|
|
167
|
+
} | undefined>;
|
|
164
168
|
};
|
|
165
169
|
};
|
|
166
170
|
/**
|
|
@@ -168,6 +172,11 @@ type CommentsVitePlugin$1 = Plugin & {
|
|
|
168
172
|
* default or only Database.
|
|
169
173
|
*/
|
|
170
174
|
export declare function readCommentsDatabase(file: string): Promise<string | undefined>;
|
|
175
|
+
/**
|
|
176
|
+
* Whether `defineComments({ send })` turns Send on, read without running the file: Send is on unless `send` is missing
|
|
177
|
+
* or `false`. A value known only at runtime counts as on, so the build adds the tables and the member endpoints.
|
|
178
|
+
*/
|
|
179
|
+
export declare function readCommentsSend(file: string): Promise<boolean>;
|
|
171
180
|
/** The directory of the prebuilt overlay script in this package. */
|
|
172
181
|
export declare function commentsOverlayDirectory(): string;
|
|
173
182
|
/**
|
|
@@ -204,6 +213,7 @@ export declare function renderCommentsPlugin(input: {
|
|
|
204
213
|
development?: boolean;
|
|
205
214
|
build?: CommentBuild;
|
|
206
215
|
base?: string;
|
|
216
|
+
send?: boolean;
|
|
207
217
|
}): string;
|
|
208
218
|
/**
|
|
209
219
|
* Comments for any Vite app, without `vite-hub`: the comment overlay on every page with `?vitehub`, threads in a
|
|
@@ -211,8 +221,6 @@ export declare function renderCommentsPlugin(input: {
|
|
|
211
221
|
* with `COMMENTS_B0003`, because `vitehub({ comments })` and `server/comments.ts` turn Comments on there.
|
|
212
222
|
*/
|
|
213
223
|
export declare function comments(options?: CommentsOptions): PluginOption[];
|
|
214
|
-
//#endregion
|
|
215
|
-
//#region src/overlay.d.ts
|
|
216
224
|
/** Which pages get the overlay. Globs are relative to the app base: `*` is one path segment and `**` any depth. */
|
|
217
225
|
interface CommentsOverlayOptions {
|
|
218
226
|
/** Pages that get the overlay. Default: every page. */
|
|
@@ -265,23 +273,17 @@ export declare function injectLoader(html: string, tag: string, found?: {
|
|
|
265
273
|
* A stream is piped through a transform that holds back a short tail, so a tag split across chunks is still found.
|
|
266
274
|
*/
|
|
267
275
|
export declare function renderOverlayMiddleware(url: string): string;
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/operations-core/console.d.ts
|
|
270
276
|
/**
|
|
271
277
|
* Console section for the comment inbox. It lists the result of `comments.list`, called with the Console user, so
|
|
272
278
|
* `authorize` applies to each thread. A page thread links to `<page>?comment=<n>`.
|
|
273
279
|
*/
|
|
274
280
|
declare const commentsConsoleSection$1: ViteHubConsoleOperationSection;
|
|
275
|
-
//#endregion
|
|
276
|
-
//#region src/operations-core/vite.d.ts
|
|
277
281
|
export declare const COMMENTS_VITE_PLUGIN_NAME = "@vite-hub/comments/vite";
|
|
278
282
|
/** Whether the project has a `server/comments.ts`. `vitehub()` reads it while Vite filters plugins. */
|
|
279
283
|
export declare function usesComments(options: {
|
|
280
284
|
projectRoot: string;
|
|
281
285
|
serverDirs?: readonly string[];
|
|
282
286
|
}): boolean;
|
|
283
|
-
//#endregion
|
|
284
|
-
//#region src/vite.d.ts
|
|
285
287
|
export type HubCommentsOptions = CommentsVitePluginOptions & {
|
|
286
288
|
/** Import paths of the comment operations. `vite-hub` passes its own subpaths. */
|
|
287
289
|
operationsImports?: {
|
|
@@ -304,5 +306,4 @@ export declare function findCommentsEntry(options: {
|
|
|
304
306
|
* or as its default export; both run every surface on the same tables.
|
|
305
307
|
*/
|
|
306
308
|
export declare function hubComments(options?: HubCommentsOptions): CommentsVitePlugin;
|
|
307
|
-
//#endregion
|
|
308
309
|
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 };
|