@vite-hub/comments 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/anchor.d.ts +2 -2
- package/dist/anchor.js +0 -1
- package/dist/{client-files-lC6X7XyS.js → client-files-CMPJEd21.js} +0 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +2 -5
- package/dist/database.js +1 -1
- package/dist/{define-C-LUOouq.js → define-hs9Z38io.js} +0 -1
- package/dist/hosted/hosted-comments/frame.js +4 -4
- package/dist/hosted/hosted-comments/tools.js +59 -56
- package/dist/{index-d6NsDxu9.d.ts → index-CbXek64X.d.ts} +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -6
- package/dist/{install-BueV_fJY.js → install--HecUN5c.js} +2 -19
- package/dist/{install-F-_O7zDr.d.ts → install-C3CW6Vvw.d.ts} +4 -4
- package/dist/{migrate-oseJAYbm.js → migrate-cxoJK4JQ.js} +0 -18
- package/dist/{operations-jaihyWw2.d.ts → operations-D0EO1pzL.d.ts} +3 -7
- package/dist/{operations-0llC5kKO.js → operations-DHXmbtb3.js} +3 -30
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +2 -2
- package/dist/overlay/client-BszZKIf8.js +4 -0
- package/dist/overlay/overlay.js +38 -35
- package/dist/page/loader.js +14 -11
- package/dist/{page-CDhmXO-y.js → page-CJz1K67L.js} +1 -1
- package/dist/{page-BgvzzsJb.d.ts → page-DRM1j84-.d.ts} +1 -1
- package/dist/{path-8yqMd8zR.js → path-sv8kjq3i.js} +0 -4
- package/dist/{plugin-DGUqlc3C.js → plugin-DczA2K-y.js} +3 -3
- package/dist/realtime.d.ts +5 -5
- package/dist/realtime.js +2 -2
- package/dist/{rpc-kkxzQ3Qy.js → rpc-51X1TWKb.js} +1 -1
- package/dist/{rpc-D-eqtyfh.d.ts → rpc-DZB3yU0z.d.ts} +1 -1
- package/dist/rpc.d.ts +1 -1
- package/dist/rpc.js +1 -1
- package/dist/runtime/auth.d.ts +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +8 -30
- package/dist/server.d.ts +7 -7
- package/dist/server.js +6 -6
- package/dist/{service-DaMq8TBw.js → service-DFMwCr60.js} +2 -12
- package/dist/{service-CMVA_Ryv.d.ts → service-qaMuJ7UX.d.ts} +2 -2
- package/dist/{session-B7GDrqsK.js → session-1SI3_wLJ.js} +11 -30
- package/dist/{session-EzQqBeE8.d.ts → session-CK3Rnjto.d.ts} +2 -2
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +0 -1
- package/dist/{tokens-Bx4lZ0yt.js → tokens-WRh__ppm.js} +0 -1
- package/dist/{types-BX3vH18p.d.ts → types-BmzTyGt-.d.ts} +4 -0
- package/dist/{types-qzJKgWYS.d.ts → types-VSVs4jIw.d.ts} +1 -1
- package/dist/vite.d.ts +3 -3
- package/dist/vite.js +2 -33
- package/package.json +7 -7
- package/dist/overlay/client-ZBsUybIe.js +0 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as viteHubPageSessionPath, c as viteHubPageToolsHintCookie, d as viteHubPageToolsLoader, f as viteHubPageToolsMarker, h as withViteHubBase, i as viteHubPageSessionHandoffScript, l as viteHubPageToolsInlineScript, m as viteHubPageToolsWanted, n as readViteHubPageSession, p as viteHubPageToolsQuery, r as viteHubBasePath, t as readViteHubPageAccount } from "./page-tools-shared-BCdvqA4S.js";
|
|
2
2
|
import { t as clientRequest } from "./client-request-B1DCz3a9.js";
|
|
3
|
-
import { p as normalizeCommentPage } from "./page-
|
|
3
|
+
import { p as normalizeCommentPage } from "./page-CJz1K67L.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. */
|
|
@@ -35,7 +35,6 @@ function isGeneratedCheck(inline) {
|
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
/** A tag ends at an unquoted `>`, so markup quoted in an attribute stays untouched. */
|
|
39
38
|
function tagEnd(text) {
|
|
40
39
|
let quote = "";
|
|
41
40
|
for (let index = 1; index < text.length; index++) {
|
|
@@ -209,7 +208,6 @@ function matchesPublicOrigin(request, origins) {
|
|
|
209
208
|
const { host, hostname } = new URL(forwardedRequestOrigin(request));
|
|
210
209
|
return isLoopbackHostname(hostname) || origins.some((origin) => new URL(origin).host === host);
|
|
211
210
|
}
|
|
212
|
-
/** `localhost`, `[::1]`, or an IPv4 address in `127.0.0.0/8`. URL parsing writes IPv4 addresses as four decimal parts. */
|
|
213
211
|
function isLoopbackHostname(hostname) {
|
|
214
212
|
return hostname === "localhost" || hostname === "[::1]" || /^127(?:\.\d{1,3}){3}$/.test(hostname);
|
|
215
213
|
}
|
|
@@ -237,7 +235,6 @@ function registerViteHubPageTool(nitroApp, tool) {
|
|
|
237
235
|
const grants = state().grants ??= /* @__PURE__ */ new Map();
|
|
238
236
|
for (const grant of tool.grants ?? []) grants.set(grant.id, grant);
|
|
239
237
|
}
|
|
240
|
-
/** The account of a visitor, none without a reader or a session, and `failed` when the reader throws. */
|
|
241
238
|
async function readAccount(nitroApp, request) {
|
|
242
239
|
const read = state().accounts?.get(nitroApp);
|
|
243
240
|
if (!read) return {};
|
|
@@ -260,25 +257,18 @@ function installViteHubSiteVisitor(reader) {
|
|
|
260
257
|
function viteHubSiteVisitorReader() {
|
|
261
258
|
return state().siteVisitor;
|
|
262
259
|
}
|
|
263
|
-
/** Whether the app serves its page tools on the origin of the request. Every origin counts for an app without `origins`. */
|
|
264
260
|
function servesOrigin(nitroApp, request) {
|
|
265
261
|
const origins = state().origins?.get(nitroApp) ?? [];
|
|
266
262
|
return matchesPublicOrigin(request, typeof origins === "function" ? origins() : origins);
|
|
267
263
|
}
|
|
268
|
-
/** The path of a URL below the app base. A path outside the base stays as it is. */
|
|
269
264
|
function pathBelow(base, pathname) {
|
|
270
265
|
return base && (pathname === base || pathname.startsWith(`${base}/`)) ? pathname.slice(base.length) || "/" : pathname;
|
|
271
266
|
}
|
|
272
|
-
/** Whether a URL is an app page that can get the page tools: inside the app base, and not under `/_vitehub` or `/api`. */
|
|
273
267
|
function isPagePath(url, base) {
|
|
274
268
|
if (base && url.pathname !== base && !url.pathname.startsWith(`${base}/`)) return false;
|
|
275
269
|
const path = pathBelow(base, url.pathname);
|
|
276
270
|
return !(path.startsWith("/_vitehub") || path === "/api" || path.startsWith("/api/"));
|
|
277
271
|
}
|
|
278
|
-
/**
|
|
279
|
-
* What ViteHub adds to the page of this request: the loader for a request with the hint, the bootstrap for any other
|
|
280
|
-
* page, or nothing when no tool is registered or the path is not a page.
|
|
281
|
-
*/
|
|
282
272
|
function pageAddition(nitroApp, request, base) {
|
|
283
273
|
const url = new URL(request.url);
|
|
284
274
|
if ((state().tools.get(nitroApp)?.size ?? 0) === 0 || !isPagePath(url, base)) return void 0;
|
|
@@ -337,11 +327,16 @@ async function respondViteHubPageSession(nitroApp, request) {
|
|
|
337
327
|
const pathname = new URL(request.url).pathname;
|
|
338
328
|
const at = pathname.lastIndexOf(viteHubPageSessionPath);
|
|
339
329
|
const base = at > 0 ? pathname.slice(0, at) : "";
|
|
340
|
-
const tools = registered.flatMap((
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
330
|
+
const tools = registered.flatMap((registeredTool, index) => {
|
|
331
|
+
const check = checks[index];
|
|
332
|
+
if (check !== true && check !== "lazy") return [];
|
|
333
|
+
const { allowed: _allowed, grants: _grants, ...tool } = registeredTool;
|
|
334
|
+
return [{
|
|
335
|
+
...tool,
|
|
336
|
+
...check === "lazy" ? { lazy: true } : {},
|
|
337
|
+
script: withViteHubBase(base, tool.script)
|
|
338
|
+
}];
|
|
339
|
+
});
|
|
345
340
|
const { account, failed } = tools.length > 0 ? await readAccount(nitroApp, request) : {};
|
|
346
341
|
return sessionResponse(account ? {
|
|
347
342
|
tools,
|
|
@@ -474,13 +469,6 @@ function startHandoff(send, request, base) {
|
|
|
474
469
|
})();
|
|
475
470
|
return pending;
|
|
476
471
|
}
|
|
477
|
-
/**
|
|
478
|
-
* Inserts the page tools bootstrap, `viteHubPageToolsInlineScript()`, before `</body>` of an HTML page for a request
|
|
479
|
-
* without the hint, with the response policy's nonce when present. The bootstrap is the same for every visitor, so the
|
|
480
|
-
* page keeps its cache policy. Body validators are removed because they describe the upstream HTML. A page that
|
|
481
|
-
* already has a page tools script, such as a prerendered page, gets no second one. Other responses return unchanged,
|
|
482
|
-
* including compressed HTML and pages without an explicit UTF-8 charset.
|
|
483
|
-
*/
|
|
484
472
|
function injectPageToolsBootstrap(response, base = "", policyHeaders) {
|
|
485
473
|
return transformPage(response, () => viteHubPageToolsInlineScript(base, scriptNonce(policyHeaders ?? response.headers)), false);
|
|
486
474
|
}
|
|
@@ -493,12 +481,10 @@ const pageConditions = ["if-none-match", "if-modified-since"];
|
|
|
493
481
|
function hasPageConditions(request) {
|
|
494
482
|
return pageConditions.some((name) => request.headers.has(name));
|
|
495
483
|
}
|
|
496
|
-
/** Whether a request is a page navigation with validators, which must reach the app without them. */
|
|
497
484
|
function revalidatesPage(request) {
|
|
498
485
|
if (request.method !== "GET" && request.method !== "HEAD") return false;
|
|
499
486
|
return acceptsHtml(request) && hasPageConditions(request);
|
|
500
487
|
}
|
|
501
|
-
/** The headers of the Node.js request that srvx keeps under `runtime.node.req`, when there is one. */
|
|
502
488
|
function nodeRequestHeaders(request) {
|
|
503
489
|
const runtime = Reflect.get(request, "runtime");
|
|
504
490
|
if (typeof runtime !== "object" || runtime === null) return void 0;
|
|
@@ -524,7 +510,6 @@ function withoutPageConditions(request) {
|
|
|
524
510
|
function htmlCharset(type) {
|
|
525
511
|
return /;\s*charset\s*=\s*"?([^";]*)/i.exec(type)?.[1]?.trim();
|
|
526
512
|
}
|
|
527
|
-
/** Whether a response is an HTML page that can get a page tools script. It reads the status and type, not the body. */
|
|
528
513
|
function isHtmlPage(response) {
|
|
529
514
|
return response.status === 200 && (response.headers.get("content-type") ?? "").toLowerCase().startsWith("text/html");
|
|
530
515
|
}
|
|
@@ -606,10 +591,6 @@ function installViteHubPageTools(nitroApp, options = {}) {
|
|
|
606
591
|
}
|
|
607
592
|
}
|
|
608
593
|
// src/runtime/session.ts
|
|
609
|
-
/**
|
|
610
|
-
* The person that Site access in the ViteHub Console signed in to the app, with their roles in `role`, as
|
|
611
|
-
* `commentsRoleAllows()` reads them. A Console member has `comments-*` roles, a guest the roles of the invite.
|
|
612
|
-
*/
|
|
613
594
|
async function siteUser(event) {
|
|
614
595
|
const read = viteHubSiteVisitorReader();
|
|
615
596
|
if (!read) return null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { j as CommentsUser, s as CommentsRequestEvent } from "./types-
|
|
1
|
+
import "./index-CbXek64X.js";
|
|
2
|
+
import { j as CommentsUser, s as CommentsRequestEvent } from "./types-VSVs4jIw.js";
|
|
3
3
|
interface CommentsSessionOptions {
|
|
4
4
|
/** Reads the ViteHub Auth user only when no custom `identify` is configured. */
|
|
5
5
|
session?: (event: CommentsRequestEvent) => Promise<CommentsUser | null | undefined>;
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as CommentUser, T as CommentThread, k as CommentsTransport, w as CommentSubject } from "./types-
|
|
1
|
+
import { D as CommentUser, T as CommentThread, k as CommentsTransport, w as CommentSubject } from "./types-BmzTyGt-.js";
|
|
2
2
|
export interface MemoryTransportOptions {
|
|
3
3
|
/** The signed-in user. Every call acts as this user. */
|
|
4
4
|
user: CommentUser;
|
package/dist/testing.js
CHANGED
|
@@ -7,7 +7,6 @@ function checkOutboxAccount(input, user) {
|
|
|
7
7
|
function copy(value) {
|
|
8
8
|
return JSON.parse(JSON.stringify(value));
|
|
9
9
|
}
|
|
10
|
-
/** The attachment keys of a message: the keys that it names, then one made-up key for each file that it brings. */
|
|
11
10
|
function attachmentsOf(input) {
|
|
12
11
|
const files = (input.files ?? []).map((file) => `memory/${crypto.randomUUID()}/${file instanceof File ? file.name : "file"}`);
|
|
13
12
|
return [...input.attachments ?? [], ...files];
|
|
@@ -24,7 +24,6 @@ function getActiveCloudflareBinding(name) {
|
|
|
24
24
|
return env && Object.hasOwn(env, name) ? env[name] : void 0;
|
|
25
25
|
}
|
|
26
26
|
// src/forge/tokens.ts
|
|
27
|
-
/** How long the GitHub token of a person's last request stays usable for the pull request sync that it started. */
|
|
28
27
|
const tokenLifetime = 6e5;
|
|
29
28
|
const tokens = /* @__PURE__ */ new Map();
|
|
30
29
|
/**
|
|
@@ -16,6 +16,10 @@ interface CommentActor {
|
|
|
16
16
|
name?: string;
|
|
17
17
|
/** The agent's logo. */
|
|
18
18
|
image?: string;
|
|
19
|
+
/** The client the agent signed in through, such as `Executor` for Claude Code that replies through Executor. */
|
|
20
|
+
via?: string;
|
|
21
|
+
/** A link to the agent's session. Interfaces link it only when it is `http:` or `https:`. */
|
|
22
|
+
url?: string;
|
|
19
23
|
}
|
|
20
24
|
type CommentStatus = "open" | "resolved";
|
|
21
25
|
/** What a thread is about. `page` takes an app path as `id`. Other kinds, such as `content`, name their own ids. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as CommentUser, S as CommentStatus, T as CommentThread, _ as CommentListCursor, b as CommentMetadata, n as CommentActor, r as CommentAnchor, s as CommentContext, w as CommentSubject, y as CommentMessage } from "./types-
|
|
1
|
+
import { D as CommentUser, S as CommentStatus, T as CommentThread, _ as CommentListCursor, b as CommentMetadata, n as CommentActor, r as CommentAnchor, s as CommentContext, w as CommentSubject, y as CommentMessage } from "./types-BmzTyGt-.js";
|
|
2
2
|
import { ViteHubContext } from "@vite-hub/runtime";
|
|
3
3
|
/**
|
|
4
4
|
* - `read`: see threads, join the presence room of a page, and get `@` suggestions.
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as CommentBuild } from "./types-
|
|
1
|
+
import { a as CommentBuild } from "./types-BmzTyGt-.js";
|
|
2
2
|
import { n as OperationContributions } from "./operations-DFLer1fR.js";
|
|
3
3
|
import { i as ViteHubInspectionPluginMetadata, r as ViteHubConsoleRuntimeRecordTableSection, t as ViteHubConsoleOperationSection } from "./console-CCLX_eIk.js";
|
|
4
|
-
import "./types-
|
|
5
|
-
import { s as mountedCommentsRoute } from "./page-
|
|
4
|
+
import "./types-VSVs4jIw.js";
|
|
5
|
+
import { s as mountedCommentsRoute } from "./page-DRM1j84-.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";
|
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-
|
|
2
|
+
import { c as validateCommentsDefinition } from "./define-hs9Z38io.js";
|
|
3
3
|
import { t as commentsErrorDiagnostics } from "./errors-DeSEHzRf.js";
|
|
4
4
|
import { a as viteHubPageSessionPath, l as viteHubPageToolsInlineScript, o as viteHubPageToolsAssets, p as viteHubPageToolsQuery, r as viteHubBasePath, s as viteHubPageToolsCookie } from "./page-tools-shared-BCdvqA4S.js";
|
|
5
5
|
import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
|
|
6
|
-
import { f as mountedCommentsRoute, i as commentsNoticeDefinition, o as commentsRealtimeDefinition, s as commentsRoute } from "./page-
|
|
6
|
+
import { f as mountedCommentsRoute, i as commentsNoticeDefinition, o as commentsRealtimeDefinition, s as commentsRoute } from "./page-CJz1K67L.js";
|
|
7
7
|
import { t as commentsTableNames } from "./table-names-DUmWROM4.js";
|
|
8
8
|
import { formatDiagnostic } from "nostics";
|
|
9
9
|
import { existsSync, mkdirSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -413,16 +413,11 @@ function objectProperties(object) {
|
|
|
413
413
|
value: unwrapExpression(node.value)
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
|
-
/** The value of a template literal without substitutions. */
|
|
417
416
|
function staticTemplate(node) {
|
|
418
417
|
if (node.expressions.length) return dynamic;
|
|
419
418
|
return node.quasis[0]?.value.cooked ?? dynamic;
|
|
420
419
|
}
|
|
421
420
|
const escapePattern = /\\(u\{[^}]*\}?|u[\s\S]{0,4}|x[\s\S]{0,2}|0\d|[\s\S])/g;
|
|
422
|
-
/**
|
|
423
|
-
* True when a string literal has an escape that strict mode code rejects. The parser recovers from some bad escapes
|
|
424
|
-
* and accepts legacy octal escapes, so the scanner checks them again.
|
|
425
|
-
*/
|
|
426
421
|
function hasInvalidEscape(raw) {
|
|
427
422
|
for (const [, escape = ""] of raw.matchAll(escapePattern)) if (escape.startsWith("u{")) {
|
|
428
423
|
const code = escape.slice(2, -1);
|
|
@@ -494,10 +489,6 @@ const runs = shared[runsKey] ??= /* @__PURE__ */ new Map();
|
|
|
494
489
|
const startedKey = Symbol.for("vitehub.hints.started");
|
|
495
490
|
const startedShared = globalThis;
|
|
496
491
|
const started = startedShared[startedKey] ??= /* @__PURE__ */ new WeakSet();
|
|
497
|
-
/**
|
|
498
|
-
* The report of the ViteHub project root, where the other generated files go. A Nuxt app with `srcDir: "app"` has its
|
|
499
|
-
* Vite root in `app/`, one folder below.
|
|
500
|
-
*/
|
|
501
492
|
function hintsFile(config) {
|
|
502
493
|
const projectRoot = Reflect.get(config, VITEHUB_PROJECT_ROOT);
|
|
503
494
|
return resolve(typeof projectRoot === "string" ? projectRoot : resolveViteHubProjectRoot(config.root), viteHubHintsFile);
|
|
@@ -578,7 +569,6 @@ function flattenPlugins(option) {
|
|
|
578
569
|
if (Array.isArray(option)) return option.flatMap(flattenPlugins);
|
|
579
570
|
return option && typeof option === "object" && "name" in option ? [option] : [];
|
|
580
571
|
}
|
|
581
|
-
/** Whether the app added `nitro()` itself. Nitro plugins that a ViteHub package included do not count. */
|
|
582
572
|
function findAppNitro(value) {
|
|
583
573
|
if (Array.isArray(value)) return value.some(findAppNitro);
|
|
584
574
|
return value !== null && typeof value === "object" && !isIncludedNitroPlugin(value) && Reflect.get(value, "name") === "nitro:main";
|
|
@@ -637,7 +627,6 @@ const forgeNames = [
|
|
|
637
627
|
}
|
|
638
628
|
];
|
|
639
629
|
const defaultDatabaseUrls = ["DATABASE_URL", "TURSO_DATABASE_URL"];
|
|
640
|
-
/** `TURSO_DATABASE_URL` → `TURSO_AUTH_TOKEN`, as `authTokenVariable()` in `@vite-hub/database/connect`. */
|
|
641
630
|
function databaseAuthTokenVariable(urlVariable) {
|
|
642
631
|
const name = urlVariable.replace(/(?:_DATABASE)?_URL$/, "_AUTH_TOKEN");
|
|
643
632
|
return name === urlVariable ? `${urlVariable}_AUTH_TOKEN` : name;
|
|
@@ -651,7 +640,6 @@ function entry(names, required, secret) {
|
|
|
651
640
|
owners
|
|
652
641
|
};
|
|
653
642
|
}
|
|
654
|
-
/** The database of `comments({ database })`: an `env:` variable and its token, or the default URL variables. */
|
|
655
643
|
function standaloneDatabaseEntries(where, host) {
|
|
656
644
|
const location = parseDatabaseLocation(where, "comments");
|
|
657
645
|
if (location.kind === "env") return [entry([location.name], true, true), entry([databaseAuthTokenVariable(location.name)], false, true)];
|
|
@@ -809,7 +797,6 @@ async function readCommentsDatabase(file) {
|
|
|
809
797
|
if (found === null || found.value !== void 0 && typeof found.value !== "string") throw commentsErrorDiagnostics.COMMENTS_B0004({ file });
|
|
810
798
|
return typeof found.value === "string" ? found.value : void 0;
|
|
811
799
|
}
|
|
812
|
-
/** A directory of prebuilt browser scripts in this package. */
|
|
813
800
|
function builtDirectory(name) {
|
|
814
801
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
815
802
|
return here.endsWith("src") ? resolve(here, `../dist/${name}`) : resolve(here, name);
|
|
@@ -882,7 +869,6 @@ async function readCommentsComponents(root, limit = 5e3, resolvedComponents = []
|
|
|
882
869
|
return components;
|
|
883
870
|
}
|
|
884
871
|
const version = "4";
|
|
885
|
-
/** Generated lines that read the definition of `server/comments.ts`: its `comments` export, else its default export. */
|
|
886
872
|
function definitionLines(definition, runtime) {
|
|
887
873
|
return [
|
|
888
874
|
`import * as definitionModule from ${JSON.stringify(pathToFileURL(definition).href)}`,
|
|
@@ -890,7 +876,6 @@ function definitionLines(definition, runtime) {
|
|
|
890
876
|
`const comments = commentsDefinitionOf(definitionModule, ${JSON.stringify(definition)})`
|
|
891
877
|
];
|
|
892
878
|
}
|
|
893
|
-
/** Generated session reader: the ViteHub Auth user of a request. */
|
|
894
879
|
function sessionLines(options, imports) {
|
|
895
880
|
return options.auth ? {
|
|
896
881
|
imports: [`import { commentsAuthSession } from ${JSON.stringify(imports.auth)}`],
|
|
@@ -900,7 +885,6 @@ function sessionLines(options, imports) {
|
|
|
900
885
|
value: "undefined"
|
|
901
886
|
};
|
|
902
887
|
}
|
|
903
|
-
/** The session reader of presence and MCP: the Auth user, else `githubLogin`, the person signed in with GitHub. */
|
|
904
888
|
function sessionWithGitHubLines(options, imports, repository, base) {
|
|
905
889
|
if (options.auth) return sessionLines(options, imports);
|
|
906
890
|
const route = mountedCommentsRoute(base);
|
|
@@ -1001,11 +985,9 @@ function pillSegmentLines(segments) {
|
|
|
1001
985
|
value: `[${segments.map((segment, index) => `(nitroApp, context) => pillSegment${index}(nitroApp, { ...context, ...${JSON.stringify(segment.options ?? {})} })`).join(", ")}]`
|
|
1002
986
|
};
|
|
1003
987
|
}
|
|
1004
|
-
/** The generated directory of Comments in a project. */
|
|
1005
988
|
function generatedDirectory(projectRoot) {
|
|
1006
989
|
return resolve(projectRoot, ".vitehub/nitro/comments");
|
|
1007
990
|
}
|
|
1008
|
-
/** `server/comments.ts` for an app without one: Comments with its defaults. */
|
|
1009
991
|
async function writeDefaultDefinition(directory, imports) {
|
|
1010
992
|
const file = join(directory, "definition.mjs");
|
|
1011
993
|
const index = imports.runtime.replace(/\/runtime$/, "");
|
|
@@ -1019,11 +1001,6 @@ async function writeDefaultDefinition(directory, imports) {
|
|
|
1019
1001
|
].join("\n"));
|
|
1020
1002
|
return file;
|
|
1021
1003
|
}
|
|
1022
|
-
/**
|
|
1023
|
-
* The storage of `comments()`. A build connects to the `database` option, else to what it finds at runtime. The
|
|
1024
|
-
* development server uses `.vitehub/data/comments.sqlite`, unless the option is a file, or a variable that is set. In
|
|
1025
|
-
* workerd, which cannot open files, it uses the option, else a D1 binding that Miniflare keeps in `.wrangler/state`.
|
|
1026
|
-
*/
|
|
1027
1004
|
async function standaloneDatabase(projectRoot, options, command, workerd) {
|
|
1028
1005
|
const where = options.database || void 0;
|
|
1029
1006
|
const location = parseDatabaseLocation(where, "comments", { node: command !== "serve" || !workerd });
|
|
@@ -1053,10 +1030,6 @@ async function standaloneDatabase(projectRoot, options, command, workerd) {
|
|
|
1053
1030
|
node: true
|
|
1054
1031
|
};
|
|
1055
1032
|
}
|
|
1056
|
-
/**
|
|
1057
|
-
* Adds the D1 binding of `database: "d1:NAME"` to the Wrangler config of the build, unless the app's Wrangler file has
|
|
1058
|
-
* it. Without an id, `wrangler deploy` creates the database.
|
|
1059
|
-
*/
|
|
1060
1033
|
async function addD1Binding(projectRoot, nitro, where) {
|
|
1061
1034
|
if (!where?.startsWith("d1:")) return;
|
|
1062
1035
|
const binding = where.slice(3);
|
|
@@ -1087,7 +1060,6 @@ async function addD1Binding(projectRoot, nitro, where) {
|
|
|
1087
1060
|
}
|
|
1088
1061
|
};
|
|
1089
1062
|
}
|
|
1090
|
-
/** Whether `vite-hub` is in the app, so Comments runs through `vitehub()` and not `comments()`. */
|
|
1091
1063
|
function hasViteHubComments(config) {
|
|
1092
1064
|
const find = (value) => {
|
|
1093
1065
|
if (Array.isArray(value)) return value.some(find);
|
|
@@ -1490,7 +1462,6 @@ function loaderUrl(mount, assets, options = {}) {
|
|
|
1490
1462
|
}))}` : "";
|
|
1491
1463
|
return `${mount}${overlayRoute}/${assets.loader}?f=${encodeURIComponent(assets.overlay)}${options.edit ? "&e=1" : ""}${options.session ? `&s=${options.session}` : ""}${filter}`;
|
|
1492
1464
|
}
|
|
1493
|
-
/** A nonce is base64 or base64url. Anything else is not put in a tag. */
|
|
1494
1465
|
const safeNonce = /^[\w+/=-]+$/;
|
|
1495
1466
|
function loaderTag(url, nonce) {
|
|
1496
1467
|
return `<script type="module"${nonce && safeNonce.test(nonce) ? ` nonce="${nonce}"` : ""} src="${url.replaceAll("&", "&").replaceAll("\"", """)}"><\/script>`;
|
|
@@ -1502,7 +1473,6 @@ function scriptNonce(policy) {
|
|
|
1502
1473
|
const nonce = (directives.find(([name]) => name?.toLowerCase() === "script-src-elem") ?? directives.find(([name]) => name?.toLowerCase() === "script-src") ?? directives.find(([name]) => name?.toLowerCase() === "default-src"))?.map((source) => /^'nonce-([^']+)'$/.exec(source)?.[1]).find(Boolean);
|
|
1503
1474
|
return nonce && safeNonce.test(nonce) ? nonce : void 0;
|
|
1504
1475
|
}
|
|
1505
|
-
/** Attribute values and their offsets in a complete tag, including unquoted values. Also serialized below. */
|
|
1506
1476
|
function htmlAttributes(tag) {
|
|
1507
1477
|
const start = /^<\/?[a-z][\w:-]*/i.exec(tag)?.[0].length ?? tag.length;
|
|
1508
1478
|
const pattern = /([^\s"'<>/=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
|
|
@@ -1517,7 +1487,6 @@ function htmlAttributes(tag) {
|
|
|
1517
1487
|
});
|
|
1518
1488
|
return attributes;
|
|
1519
1489
|
}
|
|
1520
|
-
/** Self-contained apart from htmlAttributes, so both can be serialized into the generated middleware. */
|
|
1521
1490
|
function createHtmlScanner() {
|
|
1522
1491
|
let raw = "";
|
|
1523
1492
|
let comment = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/comments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Comments and in-place edits on live ViteHub sites, with presence and Content drafts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
"@valibot/to-json-schema": "^1.8.0",
|
|
107
107
|
"nostics": "1.4.0",
|
|
108
108
|
"valibot": "^1.5.0",
|
|
109
|
-
"@vite-hub/auth": "0.
|
|
110
|
-
"@vite-hub/forge": "0.
|
|
111
|
-
"@vite-hub/realtime": "0.
|
|
112
|
-
"@vite-hub/runtime": "0.
|
|
109
|
+
"@vite-hub/auth": "0.9.0",
|
|
110
|
+
"@vite-hub/forge": "0.9.0",
|
|
111
|
+
"@vite-hub/realtime": "0.9.0",
|
|
112
|
+
"@vite-hub/runtime": "0.9.0",
|
|
113
113
|
"birpc": "^4.2.0",
|
|
114
114
|
"confbox": "^0.3.2",
|
|
115
115
|
"h3": "^2.0.8"
|
|
@@ -129,12 +129,12 @@
|
|
|
129
129
|
"vitest": "5.1.0",
|
|
130
130
|
"vue": "3.5.46",
|
|
131
131
|
"@libsql/client": "^0.18.0",
|
|
132
|
-
"@vite-hub/database": "0.
|
|
132
|
+
"@vite-hub/database": "0.9.0",
|
|
133
133
|
"vite": "^8.3.8",
|
|
134
134
|
"drizzle-orm": "1.0.0-rc.6"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
|
-
"@vite-hub/database": "0.
|
|
137
|
+
"@vite-hub/database": "0.9.0",
|
|
138
138
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
139
139
|
"vite": ">=8.0.0",
|
|
140
140
|
"drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0"
|