@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,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/reply-id.ts
|
|
2
2
|
/**
|
|
3
3
|
* The id of the message that a reply with `requestId` stores in a thread. Every retry gets the same id, so the primary
|
|
4
4
|
* key of the messages refuses a second message, and the client's outbox finds the server copy of its waiting reply.
|
|
@@ -8,5 +8,4 @@ async function replyMessageId(threadId, requestId) {
|
|
|
8
8
|
const digest = new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify([threadId, requestId]))));
|
|
9
9
|
return `message_${Array.from(digest.subarray(0, 16), (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
10
10
|
}
|
|
11
|
-
//#endregion
|
|
12
11
|
export { replyMessageId as t };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// ../internal/src/runtime/request-log.ts
|
|
2
|
+
function isRequestLog(value) {
|
|
3
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, "set") === "function" && typeof Reflect.get(value, "warn") === "function" && typeof Reflect.get(value, "error") === "function";
|
|
4
|
+
}
|
|
5
|
+
function contextLog(value) {
|
|
6
|
+
const context = value !== null && typeof value === "object" ? Reflect.get(value, "context") : void 0;
|
|
7
|
+
return context !== null && typeof context === "object" ? Reflect.get(context, "log") : void 0;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The evlog request logger of a request, or `undefined` when the app does not register evlog. Pass a Nitro v3 event
|
|
11
|
+
* (evlog sets `event.req.context.log`) or its `Request` (`request.context.log`).
|
|
12
|
+
*/
|
|
13
|
+
function requestLog(input) {
|
|
14
|
+
const log = contextLog(input !== null && typeof input === "object" ? Reflect.get(input, "req") : void 0) ?? contextLog(input);
|
|
15
|
+
return isRequestLog(log) ? log : void 0;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `Symbol.for()` key of the bridge on `globalThis`. Every bundled copy of this module and the Nitro plugin that
|
|
19
|
+
* `vitehub()` generates use the same key.
|
|
20
|
+
*/
|
|
21
|
+
const evlogBridgeKey = "vitehub.evlog";
|
|
22
|
+
function isEvlogBridge(value) {
|
|
23
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, "createLogger") === "function";
|
|
24
|
+
}
|
|
25
|
+
/** The evlog bridge of this process, or `undefined` when the app does not register evlog. */
|
|
26
|
+
function evlogBridge() {
|
|
27
|
+
const bridge = globalThis[Symbol.for(evlogBridgeKey)];
|
|
28
|
+
return isEvlogBridge(bridge) ? bridge : void 0;
|
|
29
|
+
}
|
|
30
|
+
function activeBridge() {
|
|
31
|
+
const bridge = evlogBridge();
|
|
32
|
+
try {
|
|
33
|
+
return bridge && bridge.isEnabled?.() !== false ? bridge : void 0;
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A short name for the cause of a failure, safe to put in a log field: the string `code` of the error, such as
|
|
40
|
+
* `ENOSPC` or a ViteHub diagnostic code, else its class name. Never the message, which can hold paths or values.
|
|
41
|
+
*/
|
|
42
|
+
function errorCode(error) {
|
|
43
|
+
if (error === null || typeof error !== "object") return void 0;
|
|
44
|
+
const code = Reflect.get(error, "code");
|
|
45
|
+
if (typeof code === "string" && code) return code;
|
|
46
|
+
const name = Reflect.get(error, "name");
|
|
47
|
+
return typeof name === "string" && name && name !== "Error" ? name : void 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Emits one evlog event of its own, outside a request's wide event. The event also reaches the app's `evlog:drain`
|
|
51
|
+
* hooks. Returns `false` when the app does not register evlog or turned it off, and never throws.
|
|
52
|
+
*/
|
|
53
|
+
function emitLogEvent(event) {
|
|
54
|
+
const bridge = activeBridge();
|
|
55
|
+
if (!bridge) return false;
|
|
56
|
+
try {
|
|
57
|
+
const log = bridge.createLogger({
|
|
58
|
+
action: event.field,
|
|
59
|
+
message: event.message,
|
|
60
|
+
[event.field]: event.fields
|
|
61
|
+
}, event.waitUntil ? { waitUntil: event.waitUntil } : void 0);
|
|
62
|
+
if (event.level === "error") log.error(event.withError && event.error instanceof Error ? event.error : event.message);
|
|
63
|
+
else log[event.level](event.message);
|
|
64
|
+
const emitted = log.emit();
|
|
65
|
+
if (emitted && bridge.drain) {
|
|
66
|
+
const drained = Promise.resolve().then(() => bridge.drain?.(emitted)).catch((error) => {
|
|
67
|
+
console.error("[evlog] drain failed:", error);
|
|
68
|
+
});
|
|
69
|
+
event.waitUntil?.(drained);
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Logs a failure that the caller survives, with a fixed message and the `code` of the error. With the evlog request
|
|
78
|
+
* logger of `request`, it replaces `[field]` on the request's wide event and adds a warning. Pass `request` only when the
|
|
79
|
+
* request has not answered yet: evlog drops fields after it emits the wide event. Otherwise it emits an event of its
|
|
80
|
+
* own. Without evlog, or with evlog off, it calls `fallback`, which prints to the server console as before. It never
|
|
81
|
+
* throws.
|
|
82
|
+
*/
|
|
83
|
+
function logFailure(failure, fallback) {
|
|
84
|
+
const code = errorCode(failure.error);
|
|
85
|
+
const fields = {
|
|
86
|
+
...failure.fields,
|
|
87
|
+
...code ? { code } : {}
|
|
88
|
+
};
|
|
89
|
+
const log = failure.request !== void 0 && activeBridge() ? requestLog(failure.request) : void 0;
|
|
90
|
+
if (log) try {
|
|
91
|
+
log.set({ [failure.field]: false });
|
|
92
|
+
log.warn(failure.message, { [failure.field]: fields });
|
|
93
|
+
return;
|
|
94
|
+
} catch {}
|
|
95
|
+
if (emitLogEvent({
|
|
96
|
+
...failure,
|
|
97
|
+
fields,
|
|
98
|
+
level: failure.level ?? "warn"
|
|
99
|
+
})) return;
|
|
100
|
+
try {
|
|
101
|
+
fallback();
|
|
102
|
+
} catch {}
|
|
103
|
+
}
|
|
104
|
+
export { logFailure as t };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// ../internal/src/runtime/request-origin.ts
|
|
2
|
+
function firstHeaderValue(headers, name) {
|
|
3
|
+
return headers.get(name)?.split(",", 1)[0]?.trim() || void 0;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The origin that the client used for `request`. A TLS-terminating proxy sends the client scheme in
|
|
7
|
+
* `X-Forwarded-Proto` and the client host in `X-Forwarded-Host`. Each proxy appends its value, so the first value wins.
|
|
8
|
+
* Without these headers, or with values that are not valid, the result is the origin of `request.url`.
|
|
9
|
+
*/
|
|
10
|
+
function forwardedRequestOrigin(request) {
|
|
11
|
+
const url = new URL(request.url);
|
|
12
|
+
const forwardedProtocol = firstHeaderValue(request.headers, "x-forwarded-proto")?.toLowerCase();
|
|
13
|
+
const protocol = forwardedProtocol === "http" || forwardedProtocol === "https" ? forwardedProtocol : url.protocol.slice(0, -1);
|
|
14
|
+
const host = firstHeaderValue(request.headers, "x-forwarded-host") ?? url.host;
|
|
15
|
+
if (/[\u0000-\u001F\s/\\?#@]/.test(host)) return url.origin;
|
|
16
|
+
try {
|
|
17
|
+
return new URL(`${protocol}://${host}`).origin;
|
|
18
|
+
} catch {
|
|
19
|
+
return url.origin;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether a request came in on one of the public `origins` of the app, such as the origin of `vitehub({ publicUrl })`.
|
|
24
|
+
* It compares the host that the client used, so a proxy that does not forward the scheme still matches. A loopback
|
|
25
|
+
* host, such as `localhost:3000` for a preview or a proxy that does not forward the host, also matches: it cannot be a
|
|
26
|
+
* second public hostname. Every request matches when `origins` is empty.
|
|
27
|
+
*/
|
|
28
|
+
function matchesPublicOrigin(request, origins) {
|
|
29
|
+
if (origins.length === 0) return true;
|
|
30
|
+
const { host, hostname } = new URL(forwardedRequestOrigin(request));
|
|
31
|
+
return isLoopbackHostname(hostname) || origins.some((origin) => new URL(origin).host === host);
|
|
32
|
+
}
|
|
33
|
+
/** `localhost`, `[::1]`, or an IPv4 address in `127.0.0.0/8`. URL parsing writes IPv4 addresses as four decimal parts. */
|
|
34
|
+
function isLoopbackHostname(hostname) {
|
|
35
|
+
return hostname === "localhost" || hostname === "[::1]" || /^127(?:\.\d{1,3}){3}$/.test(hostname);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a browser treats `origin` as secure: `https:`, or `http:` on a loopback host (`localhost`, `*.localhost`,
|
|
39
|
+
* `127.0.0.0/8`, or `[::1]`). A route that answers with a secret, or builds a URL that carries one, needs this.
|
|
40
|
+
*/
|
|
41
|
+
function isSecureOrigin(origin) {
|
|
42
|
+
if (!URL.canParse(origin)) return false;
|
|
43
|
+
const { protocol, hostname } = new URL(origin);
|
|
44
|
+
if (protocol === "https:") return true;
|
|
45
|
+
if (protocol !== "http:") return false;
|
|
46
|
+
return isLoopbackHostname(hostname) || hostname.endsWith(".localhost");
|
|
47
|
+
}
|
|
48
|
+
export { isSecureOrigin as n, matchesPublicOrigin as r, forwardedRequestOrigin as t };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import { n as
|
|
1
|
+
import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
|
|
2
|
+
import { i as commentsUnansweredError, t as commentsAnswerError } from "./client-diagnostics-CvfTW5d4.js";
|
|
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
|
|
6
6
|
/** Path of the operation RPC under the app. Dev servers and deployed apps serve it the same way, one birpc call per POST. */
|
|
7
7
|
const operationRpcPath = "/_vitehub/rpc";
|
|
8
8
|
function text(value) {
|
|
@@ -87,8 +87,7 @@ async function callOperationRpc(name, input, send) {
|
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
|
-
|
|
91
|
-
//#region src/operations-core/rpc.ts
|
|
90
|
+
// src/operations-core/rpc.ts
|
|
92
91
|
/**
|
|
93
92
|
* A transport over the operations RPC at `POST /_vitehub/rpc`, one birpc call for each request, for development only.
|
|
94
93
|
* A browser cannot sign Console calls, so it works on a development server with `console: { auth: false }` or without
|
|
@@ -165,5 +164,4 @@ function createRpcTransport(options = {}) {
|
|
|
165
164
|
users: (input) => call("comments.users", input)
|
|
166
165
|
};
|
|
167
166
|
}
|
|
168
|
-
//#endregion
|
|
169
167
|
export { createRpcTransport as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { k as CommentsTransport } from "./types-
|
|
2
|
-
//#region src/operations-core/rpc.d.ts
|
|
1
|
+
import { k as CommentsTransport } from "./types-BX3vH18p.js";
|
|
3
2
|
interface RpcTransportOptions {
|
|
4
3
|
/** The app origin and mount, such as `https://app.example.com` or `/portal`. Defaults to the page origin. */
|
|
5
4
|
base?: string;
|
|
@@ -13,5 +12,4 @@ interface RpcTransportOptions {
|
|
|
13
12
|
* no `subscribe`: the client refreshes when the window gets focus.
|
|
14
13
|
*/
|
|
15
14
|
declare function createRpcTransport(options?: RpcTransportOptions): CommentsTransport;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { createRpcTransport as n, RpcTransportOptions as t };
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createRpcTransport, t as RpcTransportOptions } from "./rpc-
|
|
1
|
+
import { n as createRpcTransport, t as RpcTransportOptions } from "./rpc-D-eqtyfh.js";
|
|
2
2
|
export { RpcTransportOptions, createRpcTransport };
|
package/dist/rpc.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createRpcTransport };
|
|
1
|
+
export { t as createRpcTransport } from "./rpc-BKY7XRlR.js";
|
package/dist/runtime/auth.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { d as CommentsPeople, g as CommentsUser } from "../define-
|
|
2
|
-
import {
|
|
3
|
-
//#region src/runtime/auth.d.ts
|
|
1
|
+
import { d as CommentsPeople, g as CommentsUser } from "../define-B1jLSPe9.js";
|
|
2
|
+
import { f as CommentsRequestEvent } from "../types-l6GOb_yc.js";
|
|
4
3
|
/** The ViteHub Auth user of a request, or null. Generated Comments files pass it as `session` when the app has Auth. */
|
|
5
4
|
export declare function commentsAuthSession(event: CommentsRequestEvent): Promise<CommentsUser | null>;
|
|
6
5
|
/** The users of ViteHub Auth, for `@` suggestions. Generated Comments files pass it as `users` when the app has Auth. */
|
|
7
|
-
export declare const commentsAuthUsers: CommentsPeople;
|
|
8
|
-
//#endregion
|
|
6
|
+
export declare const commentsAuthUsers: CommentsPeople;
|
package/dist/runtime/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as createAuthUsers } from "../server-
|
|
1
|
+
import { n as createAuthUsers } from "../server-BGbD7H5s.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");
|
|
5
5
|
/** The ViteHub Auth user of a request, or null. Generated Comments files pass it as `session` when the app has Auth. */
|
|
6
6
|
async function commentsAuthSession(event) {
|
|
@@ -14,5 +14,4 @@ async function commentsAuthSession(event) {
|
|
|
14
14
|
}
|
|
15
15
|
/** The users of ViteHub Auth, for `@` suggestions. Generated Comments files pass it as `users` when the app has Auth. */
|
|
16
16
|
const commentsAuthUsers = createAuthUsers(async () => (await authServer()).getAuth());
|
|
17
|
-
//#endregion
|
|
18
17
|
export { commentsAuthSession, commentsAuthUsers };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { n as ViteHubConsoleRecord } from "../console-
|
|
2
|
-
//#region src/runtime/console.d.ts
|
|
1
|
+
import { n as ViteHubConsoleRecord } from "../console-CK2F53QP.js";
|
|
3
2
|
/** The threads of the app as Console records: open threads first, each group newest activity first. It runs on each Console request. */
|
|
4
|
-
export declare function readCommentsConsoleRecords(): Promise<ViteHubConsoleRecord[]>;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare function readCommentsConsoleRecords(): Promise<ViteHubConsoleRecord[]>;
|
package/dist/runtime/console.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as installedComments } from "../plugin-
|
|
4
|
-
|
|
1
|
+
import { t as describeCommentContext } from "../context-DbkBjITZ.js";
|
|
2
|
+
import { n as commentsPageScope } from "../page-xzgZ6DGm.js";
|
|
3
|
+
import { n as installedComments } from "../plugin-B2hETRii.js";
|
|
4
|
+
// src/runtime/console.ts
|
|
5
5
|
function excerpt(text) {
|
|
6
6
|
const line = text.replace(/\s+/g, " ").trim();
|
|
7
7
|
return line.length > 80 ? `${line.slice(0, 79)}…` : line;
|
|
@@ -60,5 +60,4 @@ async function readCommentsConsoleRecords() {
|
|
|
60
60
|
};
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
//#endregion
|
|
64
63
|
export { readCommentsConsoleRecords };
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { s as CommentContext } from "../types-
|
|
2
|
-
import { g as CommentsUser } from "../define-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
8
|
-
//#region src/runtime/github-login.d.ts
|
|
1
|
+
import { s as CommentContext } from "../types-BX3vH18p.js";
|
|
2
|
+
import { g as CommentsUser } from "../define-B1jLSPe9.js";
|
|
3
|
+
import { t as Comments } from "../index-BEnHTj2Z.js";
|
|
4
|
+
import { f as CommentsRequestEvent } from "../types-l6GOb_yc.js";
|
|
5
|
+
import { t as CommentsSessionOptions } from "../session-CTh9nisq.js";
|
|
6
|
+
import { t as InstallCommentsOptions } from "../install-B-FQpi47.js";
|
|
7
|
+
import { t as CommentsDatabase } from "../store-DvNTDNgn.js";
|
|
9
8
|
/** The Server Env names of the OAuth client that people sign in to Comments with: a GitHub App's, or an OAuth App's. */
|
|
10
9
|
export declare const githubLoginEnv: {
|
|
11
10
|
readonly clientId: "VITEHUB_GITHUB_CLIENT_ID";
|
|
@@ -30,8 +29,6 @@ export declare function createCommentsGitHubLogin(options?: {
|
|
|
30
29
|
fetch?: typeof fetch;
|
|
31
30
|
basePath?: string;
|
|
32
31
|
}): CommentsGitHubLogin;
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/runtime/handler.d.ts
|
|
35
32
|
/** One field address, as `parseContentField()` from `@vite-hub/content/client` reads it. */
|
|
36
33
|
interface CommentsContentField {
|
|
37
34
|
collection: string;
|
|
@@ -85,6 +82,7 @@ interface CommentsHandlerOptions extends CommentsSessionOptions {
|
|
|
85
82
|
};
|
|
86
83
|
/** Whether the page presence rooms run, because the host has a Realtime authority. */
|
|
87
84
|
realtime: boolean;
|
|
85
|
+
attachments?: false;
|
|
88
86
|
/** `false` hides the overlay's faces and cursors, for an app that shows its own presence. Threads still update live. */
|
|
89
87
|
presence?: false;
|
|
90
88
|
/** The commit and branch of this build. New threads keep them in `context.build`. */
|
|
@@ -103,8 +101,6 @@ interface CommentsHandlerOptions extends CommentsSessionOptions {
|
|
|
103
101
|
export declare function createCommentsHandler(options: CommentsHandlerOptions): {
|
|
104
102
|
fetch(request: Request): Promise<Response>;
|
|
105
103
|
};
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/runtime/plugin.d.ts
|
|
108
104
|
interface CommentsPluginOptions extends CommentsSessionOptions {
|
|
109
105
|
comments: Comments;
|
|
110
106
|
/** Offers GitHub sign-in or account switching through the overlay, even before read access is granted. */
|
|
@@ -133,6 +129,8 @@ interface CommentsPluginOptions extends CommentsSessionOptions {
|
|
|
133
129
|
/** The tables of a Postgres Database. Default: the SQLite tables. */
|
|
134
130
|
tables?: InstallCommentsOptions["tables"];
|
|
135
131
|
dialect?: InstallCommentsOptions["dialect"];
|
|
132
|
+
/** Loads `@vite-hub/webhooks`, when `defineComments({ send })` is on. */
|
|
133
|
+
webhooks?: InstallCommentsOptions["webhooks"];
|
|
136
134
|
}
|
|
137
135
|
/** The Comments definition that the Nitro plugin installed, for the Console reader. */
|
|
138
136
|
export declare function installedComments(): Comments | undefined;
|
|
@@ -141,8 +139,6 @@ export declare function installedComments(): Comments | undefined;
|
|
|
141
139
|
* `comments` page tool: a visitor may load it when `authorize` allows `read` or GitHub sign-in is available.
|
|
142
140
|
*/
|
|
143
141
|
export declare function defineCommentsPlugin(options: CommentsPluginOptions): (nitroApp: unknown) => void;
|
|
144
|
-
//#endregion
|
|
145
|
-
//#region src/runtime/database.d.ts
|
|
146
142
|
/** The runtime Database registry of `@vite-hub/database/runtime/registry`, as the generated Nitro plugin passes it. */
|
|
147
143
|
type CommentsDatabaseRegistry = Record<string, {
|
|
148
144
|
db: CommentsDatabase;
|
|
@@ -154,8 +150,6 @@ type CommentsDatabaseRegistry = Record<string, {
|
|
|
154
150
|
* `DATABASE_DISABLED` or `DATABASE_NOT_FOUND`. The store reads the db per query, by which time the binding is there.
|
|
155
151
|
*/
|
|
156
152
|
export declare function selectCommentsDatabase(databases: CommentsDatabaseRegistry, name?: string): CommentsDatabase | undefined;
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/runtime/definition.d.ts
|
|
159
153
|
/**
|
|
160
154
|
* The Comments definition of `server/comments.ts`: its `comments` export, else its default export. Both forms run the
|
|
161
155
|
* same surfaces. The generated files call it, so a file without `defineComments()` fails with `COMMENTS_B0002`.
|
|
@@ -164,8 +158,6 @@ export declare function commentsDefinitionOf(module: {
|
|
|
164
158
|
comments?: unknown;
|
|
165
159
|
default?: unknown;
|
|
166
160
|
}, file: string): Comments;
|
|
167
|
-
//#endregion
|
|
168
|
-
//#region ../internal/src/runtime/mcp-tools.d.ts
|
|
169
161
|
/**
|
|
170
162
|
* The JSON Schema of one argument. A tool lists only these keywords, plus
|
|
171
163
|
* `description` and `title` for the Agent.
|
|
@@ -251,8 +243,6 @@ interface ViteHubMcpTool {
|
|
|
251
243
|
section: string;
|
|
252
244
|
call(input: Record<string, unknown>, context: ViteHubMcpToolContext): Promise<ViteHubMcpToolResult>;
|
|
253
245
|
}
|
|
254
|
-
//#endregion
|
|
255
|
-
//#region src/runtime/mcp.d.ts
|
|
256
246
|
interface CommentsMcpToolsOptions {
|
|
257
247
|
/**
|
|
258
248
|
* The caller passed the Console access check of the `comments` section, as the comment operations do. `authorize`
|
|
@@ -268,8 +258,6 @@ interface CommentsMcpToolsOptions {
|
|
|
268
258
|
* checked `context.user`. Replies and resolves show that user as the author.
|
|
269
259
|
*/
|
|
270
260
|
export declare function commentsMcpTools(comments: Comments, options?: CommentsMcpToolsOptions): ViteHubMcpTool[];
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region ../internal/src/runtime/mcp-server.d.ts
|
|
273
261
|
type ToolResultContent = ({
|
|
274
262
|
type: "text";
|
|
275
263
|
text: string;
|
|
@@ -284,14 +272,11 @@ export declare function mcpToolResult(result: ViteHubMcpToolResult): {
|
|
|
284
272
|
structuredContent?: Record<string, unknown>;
|
|
285
273
|
isError: boolean;
|
|
286
274
|
};
|
|
287
|
-
//#endregion
|
|
288
|
-
//#region ../internal/src/runtime/page-tools.d.ts
|
|
289
275
|
/**
|
|
290
|
-
* The route of `GET /_vitehub/page/
|
|
291
|
-
* app in `
|
|
276
|
+
* The route of `GET /_vitehub/page/tools`: a Fetchable (https://fetchable.org). `installViteHubPageTools()` binds
|
|
277
|
+
* each Request to its app in Nitro's `request` hook, so the route finds the tools of that app.
|
|
292
278
|
*/
|
|
293
279
|
export declare const viteHubPageSessionHandler: {
|
|
294
280
|
fetch(request: Request): Promise<Response>;
|
|
295
281
|
};
|
|
296
|
-
//#endregion
|
|
297
282
|
export type { CommentsContent, CommentsContentField, CommentsDatabaseRegistry, CommentsGitHubLogin, CommentsHandlerOptions, CommentsMcpToolsOptions, CommentsPluginOptions };
|