@vite-hub/comments 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -10
- package/dist/anchor.d.ts +2 -2
- package/dist/{client-diagnostics-CcFpkbAk.js → client-diagnostics-Bubm7Shd.js} +20 -5
- package/dist/client-files-CJZl5Kc4.js +53 -0
- package/dist/client.d.ts +151 -10
- package/dist/client.js +807 -32
- package/dist/database.js +1 -1
- package/dist/{define-B3TF9zzn.d.ts → define-CHTWfHPo.d.ts} +1 -1
- package/dist/{define-43mMR39K.js → define-CX_Yr_hz.js} +1 -1
- package/dist/{errors-CyQyKAvy.d.ts → errors-BEChnUo7.d.ts} +14 -2
- package/dist/{errors-C6qptPoG.js → errors-BHsVXlpd.js} +7 -3
- package/dist/{index-DNhy69Wt.d.ts → index-iPGlSAgj.d.ts} +13 -4
- package/dist/index.d.ts +7 -7
- package/dist/index.js +41 -7
- package/dist/{install-W9ghhGoh.d.ts → install-96NXWnrw.d.ts} +3 -3
- package/dist/{install-BcMPgPk_.js → install-jRKmuLHK.js} +72 -26
- package/dist/{installed-B-PfERBU.js → installed-g6nDr5ac.js} +1 -1
- package/dist/{migrate-BDQ8xqUs.js → migrate-Bpw3xL5e.js} +1 -1
- package/dist/{operations-D4A1Fcgf.d.ts → operations-7ycAhDCw.d.ts} +5 -0
- package/dist/{operations-DMMIfYPW.js → operations-9tskoLsk.js} +22 -11
- package/dist/{operations-GLeOqgMt.d.ts → operations-D93EV10O.d.ts} +5 -4
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +2 -2
- package/dist/overlay/client-lZesR40x.js +4 -0
- package/dist/overlay/overlay.js +20 -40
- package/dist/{page-DtbMOEMd.d.ts → page-CWwnmF3K.d.ts} +1 -1
- package/dist/{page-B41ozN63.js → page-DRz_sDY4.js} +1 -1
- package/dist/{plugin-PS8PMYus.js → plugin-BNFd1zGz.js} +27 -6
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js +2 -2
- package/dist/reply-id-P_bSuEng.js +12 -0
- package/dist/{rpc-RKPAusHp.js → rpc-BQqYx8kb.js} +23 -7
- package/dist/{rpc-HBcWtg0T.d.ts → rpc-BZ1QNkCC.d.ts} +1 -1
- package/dist/rpc.d.ts +1 -1
- package/dist/rpc.js +1 -1
- package/dist/runtime/auth.d.ts +2 -2
- package/dist/runtime/auth.js +2 -2
- package/dist/runtime/console.js +3 -3
- package/dist/runtime/index.d.ts +38 -11
- package/dist/runtime/index.js +83 -15
- package/dist/{server-D8k-0GXe.js → server-CqyzrqTI.js} +1 -1
- package/dist/server.d.ts +5 -5
- package/dist/server.js +6 -6
- package/dist/{service-GHhhyQj4.js → service-C8ZgFWvy.js} +34 -5
- package/dist/{service-CFVm23k7.d.ts → service-wC9kx9EX.d.ts} +11 -4
- package/dist/{session-EkudzUmm.js → session-ByjMyTak.js} +1 -1
- package/dist/{session-DVx-1Tym.d.ts → session-CKfW6DGE.d.ts} +3 -3
- package/dist/table-names-DfiKUlOV.js +14 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +37 -4
- package/dist/{types-BIS0hCEl.d.ts → types-C1qzObs2.d.ts} +12 -3
- package/dist/{types-CZujrMFd.d.ts → types-C7LzhgRb.d.ts} +47 -3
- package/dist/vite.d.ts +6 -6
- package/dist/vite.js +187 -113
- package/package.json +9 -9
- package/dist/overlay/client-DmsSMOzi.js +0 -4
package/dist/vite.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
2
|
-
import { a as mountedCommentsRoute, i as commentsRoute, r as commentsRealtimeDefinition } from "./page-
|
|
1
|
+
import { t as commentsErrorDiagnostics } from "./errors-BHsVXlpd.js";
|
|
2
|
+
import { a as mountedCommentsRoute, i as commentsRoute, r as commentsRealtimeDefinition } from "./page-DRz_sDY4.js";
|
|
3
3
|
import { n as isRecordOrFunction } from "./object-Da1zyPCR.js";
|
|
4
4
|
import { t as invariant } from "./invariant-D8_xBqmZ.js";
|
|
5
|
-
import { c as validateCommentsDefinition } from "./define-
|
|
5
|
+
import { c as validateCommentsDefinition } from "./define-CX_Yr_hz.js";
|
|
6
6
|
import { a as viteHubPageToolsCookie, d as viteHubPageToolsQuery, i as viteHubPageToolsAssets, n as viteHubBasePath, r as viteHubPageSessionPath, s as viteHubPageToolsInlineScript } from "./page-tools-shared-NHUjKI8E.js";
|
|
7
|
-
import {
|
|
7
|
+
import { t as commentsTableNames } from "./table-names-DfiKUlOV.js";
|
|
8
|
+
import { formatDiagnostic } from "nostics";
|
|
9
|
+
import { existsSync, mkdirSync, statSync, writeFileSync } from "node:fs";
|
|
8
10
|
import { tmpdir } from "node:os";
|
|
9
11
|
import { basename, dirname, join, parse, relative, resolve, sep } from "node:path";
|
|
10
12
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -14,88 +16,6 @@ import { nitro } from "nitro/vite";
|
|
|
14
16
|
import { parseDatabaseLocation } from "@vite-hub/database/config";
|
|
15
17
|
import { githubRepository, readForgeBuild } from "@vite-hub/forge/build/node";
|
|
16
18
|
import { parseJSONC, parseTOML } from "confbox";
|
|
17
|
-
//#region ../internal/src/build/vite.ts
|
|
18
|
-
const projectRootDirectoryMarkers = [
|
|
19
|
-
["server", "agents"],
|
|
20
|
-
["server", "channels"],
|
|
21
|
-
["server", "connections"],
|
|
22
|
-
["server", "browsers"],
|
|
23
|
-
["server", "emails"],
|
|
24
|
-
["server", "schedules"],
|
|
25
|
-
["server", "workspaces"]
|
|
26
|
-
];
|
|
27
|
-
const projectRootFileMarkers = [
|
|
28
|
-
["package.json"],
|
|
29
|
-
["nuxt.config.ts"],
|
|
30
|
-
["nuxt.config.mts"],
|
|
31
|
-
["nuxt.config.js"],
|
|
32
|
-
["nuxt.config.mjs"]
|
|
33
|
-
];
|
|
34
|
-
function isServerEnvironment(name, config) {
|
|
35
|
-
return name === "ssr" || config.consumer === "server";
|
|
36
|
-
}
|
|
37
|
-
/** Nitro RC externalizes dependencies by default; explicit inlining still needs CommonJS pre-bundling in workerd. */
|
|
38
|
-
function workerdDependencyConfig(name, config, env) {
|
|
39
|
-
if (env.command !== "serve" || !isServerEnvironment(name, config) || config.resolve?.noExternal !== true) return;
|
|
40
|
-
if (!config.resolve.conditions?.some((condition) => condition === "workerd" || condition === "worker")) return;
|
|
41
|
-
return { optimizeDeps: {
|
|
42
|
-
noDiscovery: config.optimizeDeps?.noDiscovery ?? false,
|
|
43
|
-
exclude: ["nitro"]
|
|
44
|
-
} };
|
|
45
|
-
}
|
|
46
|
-
const VITEHUB_PROJECT_ROOT = "__vitehubProjectRoot";
|
|
47
|
-
/**
|
|
48
|
-
* Server directories that ViteHub scans for Definitions. The first entry is the application.
|
|
49
|
-
* Later entries are Nuxt layers in Nuxt priority order.
|
|
50
|
-
*/
|
|
51
|
-
const VITEHUB_SERVER_DIRS = "__vitehubServerDirs";
|
|
52
|
-
function resolveViteHubProjectRoot(root, options = {}) {
|
|
53
|
-
const resolvedRoot = resolve(root);
|
|
54
|
-
const temporaryRoot = resolve(tmpdir());
|
|
55
|
-
const sharedTemporaryRoot = dirname(temporaryRoot) === parse(temporaryRoot).root ? temporaryRoot : void 0;
|
|
56
|
-
if (options.projectRoot) return resolve(resolvedRoot, options.projectRoot);
|
|
57
|
-
if (basename(resolvedRoot) === "app") {
|
|
58
|
-
const parent = dirname(resolvedRoot);
|
|
59
|
-
if (parent !== sharedTemporaryRoot && (hasProjectRootDirectoryMarker(parent) || hasProjectRootFileMarker(parent, [
|
|
60
|
-
"nuxt.config.ts",
|
|
61
|
-
"nuxt.config.mts",
|
|
62
|
-
"nuxt.config.js",
|
|
63
|
-
"nuxt.config.mjs"
|
|
64
|
-
]))) return parent;
|
|
65
|
-
}
|
|
66
|
-
let current = resolvedRoot;
|
|
67
|
-
while (true) {
|
|
68
|
-
if (current === sharedTemporaryRoot && resolvedRoot !== current) return resolvedRoot;
|
|
69
|
-
if (hasProjectRootMarker(current)) return current;
|
|
70
|
-
const parent = dirname(current);
|
|
71
|
-
if (parent === current) return resolvedRoot;
|
|
72
|
-
current = parent;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function hasProjectRootDirectoryMarker(root) {
|
|
76
|
-
for (const marker of projectRootDirectoryMarkers) try {
|
|
77
|
-
if (statSync(resolve(root, ...marker)).isDirectory()) return true;
|
|
78
|
-
} catch (error) {
|
|
79
|
-
if (error.code !== "ENOENT") throw error;
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
function hasProjectRootMarker(root) {
|
|
84
|
-
if (hasProjectRootDirectoryMarker(root)) return true;
|
|
85
|
-
return hasProjectRootFileMarker(root, projectRootFileMarkers.flat());
|
|
86
|
-
}
|
|
87
|
-
function hasProjectRootFileMarker(root, markers) {
|
|
88
|
-
for (const marker of markers) {
|
|
89
|
-
const path = Array.isArray(marker) ? marker : [marker];
|
|
90
|
-
try {
|
|
91
|
-
if (statSync(resolve(root, ...path)).isFile()) return true;
|
|
92
|
-
} catch (error) {
|
|
93
|
-
if (error.code !== "ENOENT") throw error;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
//#endregion
|
|
99
19
|
//#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
100
20
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
101
21
|
function normalizeWindowsPath(input = "") {
|
|
@@ -202,6 +122,88 @@ const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|pr
|
|
|
202
122
|
new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
|
|
203
123
|
new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
|
|
204
124
|
//#endregion
|
|
125
|
+
//#region ../internal/src/build/vite.ts
|
|
126
|
+
const projectRootDirectoryMarkers = [
|
|
127
|
+
["server", "agents"],
|
|
128
|
+
["server", "channels"],
|
|
129
|
+
["server", "connections"],
|
|
130
|
+
["server", "browsers"],
|
|
131
|
+
["server", "emails"],
|
|
132
|
+
["server", "schedules"],
|
|
133
|
+
["server", "workspaces"]
|
|
134
|
+
];
|
|
135
|
+
const projectRootFileMarkers = [
|
|
136
|
+
["package.json"],
|
|
137
|
+
["nuxt.config.ts"],
|
|
138
|
+
["nuxt.config.mts"],
|
|
139
|
+
["nuxt.config.js"],
|
|
140
|
+
["nuxt.config.mjs"]
|
|
141
|
+
];
|
|
142
|
+
function isServerEnvironment(name, config) {
|
|
143
|
+
return name === "ssr" || config.consumer === "server";
|
|
144
|
+
}
|
|
145
|
+
/** Nitro RC externalizes dependencies by default; explicit inlining still needs CommonJS pre-bundling in workerd. */
|
|
146
|
+
function workerdDependencyConfig(name, config, env) {
|
|
147
|
+
if (env.command !== "serve" || !isServerEnvironment(name, config) || config.resolve?.noExternal !== true) return;
|
|
148
|
+
if (!config.resolve.conditions?.some((condition) => condition === "workerd" || condition === "worker")) return;
|
|
149
|
+
return { optimizeDeps: {
|
|
150
|
+
noDiscovery: config.optimizeDeps?.noDiscovery ?? false,
|
|
151
|
+
exclude: ["nitro"]
|
|
152
|
+
} };
|
|
153
|
+
}
|
|
154
|
+
const VITEHUB_PROJECT_ROOT = "__vitehubProjectRoot";
|
|
155
|
+
/**
|
|
156
|
+
* Server directories that ViteHub scans for Definitions. The first entry is the application.
|
|
157
|
+
* Later entries are Nuxt layers in Nuxt priority order.
|
|
158
|
+
*/
|
|
159
|
+
const VITEHUB_SERVER_DIRS = "__vitehubServerDirs";
|
|
160
|
+
function resolveViteHubProjectRoot(root, options = {}) {
|
|
161
|
+
const resolvedRoot = resolve(root);
|
|
162
|
+
const temporaryRoot = resolve(tmpdir());
|
|
163
|
+
const sharedTemporaryRoot = dirname(temporaryRoot) === parse(temporaryRoot).root ? temporaryRoot : void 0;
|
|
164
|
+
if (options.projectRoot) return resolve(resolvedRoot, options.projectRoot);
|
|
165
|
+
if (basename(resolvedRoot) === "app") {
|
|
166
|
+
const parent = dirname(resolvedRoot);
|
|
167
|
+
if (parent !== sharedTemporaryRoot && (hasProjectRootDirectoryMarker(parent) || hasProjectRootFileMarker(parent, [
|
|
168
|
+
"nuxt.config.ts",
|
|
169
|
+
"nuxt.config.mts",
|
|
170
|
+
"nuxt.config.js",
|
|
171
|
+
"nuxt.config.mjs"
|
|
172
|
+
]))) return parent;
|
|
173
|
+
}
|
|
174
|
+
let current = resolvedRoot;
|
|
175
|
+
while (true) {
|
|
176
|
+
if (current === sharedTemporaryRoot && resolvedRoot !== current) return resolvedRoot;
|
|
177
|
+
if (hasProjectRootMarker(current)) return current;
|
|
178
|
+
const parent = dirname(current);
|
|
179
|
+
if (parent === current) return resolvedRoot;
|
|
180
|
+
current = parent;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function hasProjectRootDirectoryMarker(root) {
|
|
184
|
+
for (const marker of projectRootDirectoryMarkers) try {
|
|
185
|
+
if (statSync(resolve(root, ...marker)).isDirectory()) return true;
|
|
186
|
+
} catch (error) {
|
|
187
|
+
if (error.code !== "ENOENT") throw error;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
function hasProjectRootMarker(root) {
|
|
192
|
+
if (hasProjectRootDirectoryMarker(root)) return true;
|
|
193
|
+
return hasProjectRootFileMarker(root, projectRootFileMarkers.flat());
|
|
194
|
+
}
|
|
195
|
+
function hasProjectRootFileMarker(root, markers) {
|
|
196
|
+
for (const marker of markers) {
|
|
197
|
+
const path = Array.isArray(marker) ? marker : [marker];
|
|
198
|
+
try {
|
|
199
|
+
if (statSync(resolve(root, ...path)).isFile()) return true;
|
|
200
|
+
} catch (error) {
|
|
201
|
+
if (error.code !== "ENOENT") throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
//#endregion
|
|
205
207
|
//#region ../internal/src/build/paths.ts
|
|
206
208
|
function resolveRuntimeModule(packageDir, modulePath) {
|
|
207
209
|
const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
|
|
@@ -315,6 +317,15 @@ function viteHubPageToolsIndexHtml(html, base) {
|
|
|
315
317
|
return index === -1 ? `${html}${script}` : `${html.slice(0, index)}${script}${html.slice(index)}`;
|
|
316
318
|
}
|
|
317
319
|
//#endregion
|
|
320
|
+
//#region ../internal/src/build/ast-walk.ts
|
|
321
|
+
/** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
|
|
322
|
+
function moduleLanguage(file) {
|
|
323
|
+
if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
|
|
324
|
+
if (/\.(?:c|m)?jsx$/i.test(file)) return "jsx";
|
|
325
|
+
if (/\.(?:c|m)?js$/i.test(file)) return "js";
|
|
326
|
+
return "ts";
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
318
329
|
//#region ../internal/src/build/scan-module.ts
|
|
319
330
|
/**
|
|
320
331
|
* Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
|
|
@@ -323,16 +334,10 @@ function viteHubPageToolsIndexHtml(html, base) {
|
|
|
323
334
|
*/
|
|
324
335
|
/** The value of an expression that the scanner cannot read without running the module. */
|
|
325
336
|
const dynamic = Symbol("dynamic");
|
|
326
|
-
function languageOf(file) {
|
|
327
|
-
if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
|
|
328
|
-
if (/\.(?:c|m)?jsx$/i.test(file)) return "jsx";
|
|
329
|
-
if (/\.(?:c|m)?js$/i.test(file)) return "js";
|
|
330
|
-
return "ts";
|
|
331
|
-
}
|
|
332
337
|
/** Parses a module once. `file` selects the grammar from its extension and defaults to TypeScript. */
|
|
333
338
|
function scanModule(source, file = "module.ts") {
|
|
334
339
|
const result = parseSync(file, source, {
|
|
335
|
-
lang:
|
|
340
|
+
lang: moduleLanguage(file),
|
|
336
341
|
preserveParens: false,
|
|
337
342
|
sourceType: "module"
|
|
338
343
|
});
|
|
@@ -442,6 +447,85 @@ function staticValue(node) {
|
|
|
442
447
|
}
|
|
443
448
|
}
|
|
444
449
|
//#endregion
|
|
450
|
+
//#region ../internal/src/hints.ts
|
|
451
|
+
/**
|
|
452
|
+
* The file that lists the hints of the last build or dev server, relative to the project root. A hint is a warning
|
|
453
|
+
* about something that works now and fails later, such as counts that stay in one server's memory. Agents and CI read
|
|
454
|
+
* the file instead of the terminal.
|
|
455
|
+
*/
|
|
456
|
+
const viteHubHintsFile = ".vitehub/hints.json";
|
|
457
|
+
const VITEHUB_NUXT_HINTS = "__vitehubNuxtHints";
|
|
458
|
+
const runsKey = Symbol.for("vitehub.hints.runs");
|
|
459
|
+
const shared = globalThis;
|
|
460
|
+
const runs = shared[runsKey] ??= /* @__PURE__ */ new Map();
|
|
461
|
+
const startedKey = Symbol.for("vitehub.hints.started");
|
|
462
|
+
const startedShared = globalThis;
|
|
463
|
+
const started = startedShared[startedKey] ??= /* @__PURE__ */ new WeakSet();
|
|
464
|
+
/**
|
|
465
|
+
* The report of the ViteHub project root, where the other generated files go. A Nuxt app with `srcDir: "app"` has its
|
|
466
|
+
* Vite root in `app/`, one folder below.
|
|
467
|
+
*/
|
|
468
|
+
function hintsFile(config) {
|
|
469
|
+
const projectRoot = Reflect.get(config, VITEHUB_PROJECT_ROOT);
|
|
470
|
+
return resolve(typeof projectRoot === "string" ? projectRoot : resolveViteHubProjectRoot(config.root), viteHubHintsFile);
|
|
471
|
+
}
|
|
472
|
+
function startRun(config) {
|
|
473
|
+
const file = hintsFile(config);
|
|
474
|
+
const run = {
|
|
475
|
+
file,
|
|
476
|
+
report: {
|
|
477
|
+
version: 1,
|
|
478
|
+
command: config.command,
|
|
479
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
480
|
+
hints: []
|
|
481
|
+
},
|
|
482
|
+
keys: /* @__PURE__ */ new Set()
|
|
483
|
+
};
|
|
484
|
+
runs.set(file, run);
|
|
485
|
+
return run;
|
|
486
|
+
}
|
|
487
|
+
function write(run) {
|
|
488
|
+
mkdirSync(dirname(run.file), { recursive: true });
|
|
489
|
+
writeFileSync(run.file, `${JSON.stringify(run.report, null, 2)}\n`);
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Reports a hint from a Vite plugin hook, or from a Nitro or Nuxt hook of the same build: prints it once with its fix and docs link, and adds it to
|
|
493
|
+
* {@link viteHubHintsFile}. Build the diagnostic from the package's nostics catalog, so its code has a docs page.
|
|
494
|
+
*/
|
|
495
|
+
function reportViteHubHint(config, diagnostic) {
|
|
496
|
+
if (skipHints(config)) return;
|
|
497
|
+
const nuxt = config[VITEHUB_NUXT_HINTS];
|
|
498
|
+
if (typeof nuxt === "function") return nuxt(diagnostic);
|
|
499
|
+
const run = runs.get(hintsFile(config)) ?? startRun(config);
|
|
500
|
+
const hint = {
|
|
501
|
+
code: diagnostic.code,
|
|
502
|
+
why: diagnostic.why,
|
|
503
|
+
...diagnostic.fix ? { fix: diagnostic.fix } : {},
|
|
504
|
+
...diagnostic.docs ? { docs: diagnostic.docs } : {},
|
|
505
|
+
...diagnostic.sources?.length ? { sources: diagnostic.sources } : {}
|
|
506
|
+
};
|
|
507
|
+
const key = JSON.stringify([hint.code, hint.sources ?? []]);
|
|
508
|
+
if (run.keys.has(key)) return;
|
|
509
|
+
run.keys.add(key);
|
|
510
|
+
run.report.hints.push(hint);
|
|
511
|
+
write(run);
|
|
512
|
+
(config.logger ?? console).warn(formatDiagnostic(diagnostic));
|
|
513
|
+
}
|
|
514
|
+
function skipHints(config) {
|
|
515
|
+
return !config.command || Reflect.get(config, "__vitehubPrepare") === true || Reflect.get(config, "vitehubCliDiscovery") === true;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Starts the hints of a build or dev server: writes an empty {@link viteHubHintsFile}, so a run without hints does not
|
|
519
|
+
* leave the hints of an earlier run in place. Every plugin that reports hints calls it from `configResolved`, so a
|
|
520
|
+
* package used without `vitehub()` starts its own run. Nuxt uses the app instance as owner so its Vite builds and
|
|
521
|
+
* separate Nitro build share one report; replay, prepare and discovery never reset it.
|
|
522
|
+
*/
|
|
523
|
+
function startViteHubHints(config, owner = config) {
|
|
524
|
+
if (skipHints(config) || config["__vitehubNuxtHints"] || started.has(owner)) return;
|
|
525
|
+
started.add(owner);
|
|
526
|
+
write(startRun(config));
|
|
527
|
+
}
|
|
528
|
+
//#endregion
|
|
445
529
|
//#region ../internal/src/build/included-nitro-registry.ts
|
|
446
530
|
const includedKey = Symbol.for("vitehub.included-nitro");
|
|
447
531
|
const scope = globalThis;
|
|
@@ -640,19 +724,6 @@ const commentsConsoleSection = {
|
|
|
640
724
|
}
|
|
641
725
|
};
|
|
642
726
|
//#endregion
|
|
643
|
-
//#region src/table-names.ts
|
|
644
|
-
/**
|
|
645
|
-
* The tables of `commentsSchema` and `commentsPostgresSchema`: each schema key and its SQL name. The Comments
|
|
646
|
-
* contribution gives them to the Database, so resolving the Vite config loads neither the schema nor drizzle-orm. A
|
|
647
|
-
* test keeps them equal to both schemas.
|
|
648
|
-
*/
|
|
649
|
-
const commentsTableNames = {
|
|
650
|
-
vitehubCommentThreads: "vitehub_comment_threads",
|
|
651
|
-
vitehubCommentMessages: "vitehub_comment_messages",
|
|
652
|
-
vitehubCommentCounters: "vitehub_comment_counters",
|
|
653
|
-
vitehubCommentForge: "vitehub_comment_forge"
|
|
654
|
-
};
|
|
655
|
-
//#endregion
|
|
656
727
|
//#region src/live-vite.ts
|
|
657
728
|
const defaultImports = {
|
|
658
729
|
runtime: "@vite-hub/comments/runtime",
|
|
@@ -812,7 +883,7 @@ function sessionWithGitHubLines(options, imports, repository, base) {
|
|
|
812
883
|
return {
|
|
813
884
|
imports: [`import { createCommentsGitHubLogin } from ${JSON.stringify(imports.runtime)}`, `const githubLogin = createCommentsGitHubLogin(${JSON.stringify({
|
|
814
885
|
...repository ? { repository } : {},
|
|
815
|
-
...route !== "/
|
|
886
|
+
...route !== "/_vitehub/comments" ? { basePath: `${route}/auth` } : {}
|
|
816
887
|
})})`],
|
|
817
888
|
value: "undefined",
|
|
818
889
|
githubLogin: true
|
|
@@ -834,7 +905,7 @@ function renderCommentsHandler(input) {
|
|
|
834
905
|
` session: ${session.value},`,
|
|
835
906
|
...githubLogin ? [` githubLogin: createCommentsGitHubLogin(${JSON.stringify({
|
|
836
907
|
...input.build?.repository ? { repository: input.build.repository } : {},
|
|
837
|
-
...route !== "/
|
|
908
|
+
...route !== "/_vitehub/comments" ? { basePath: `${route}/auth` } : {}
|
|
838
909
|
})}),`] : [],
|
|
839
910
|
...input.content ? [" content: contentModule.default ? { runtime: contentModule.default, parseField: parseContentField } : undefined,"] : [],
|
|
840
911
|
` realtime: ${input.realtime},`,
|
|
@@ -917,7 +988,6 @@ async function writeDefaultDefinition(directory, imports) {
|
|
|
917
988
|
async function standaloneDatabase(projectRoot, options, command, workerd) {
|
|
918
989
|
const where = options.database || void 0;
|
|
919
990
|
const location = parseDatabaseLocation(where, "comments", { node: command !== "serve" || !workerd });
|
|
920
|
-
if (where && /[?&]authToken=/.test(where)) console.warn("[vitehub] The token in `comments({ database })` ends up in the build. Use `env:` with a variable instead.");
|
|
921
991
|
if (command !== "serve") return {
|
|
922
992
|
...where ? { where } : {},
|
|
923
993
|
node: location.kind === "file"
|
|
@@ -1003,7 +1073,7 @@ function comments(options = {}) {
|
|
|
1003
1073
|
}
|
|
1004
1074
|
/**
|
|
1005
1075
|
* Comments build integration. When the app has `server/comments.ts`, it serves the Comments API at
|
|
1006
|
-
* `/
|
|
1076
|
+
* `/_vitehub/comments/**`, installs the runtime with its Database, adds the tables to that Database, serves the
|
|
1007
1077
|
* overlay script, and adds it to pages in comment mode. `enabled: true` does the same without the file, with the default
|
|
1008
1078
|
* `defineComments()`. Other apps without the file are unaffected.
|
|
1009
1079
|
*/
|
|
@@ -1036,6 +1106,10 @@ function hubComments$1(options = {}) {
|
|
|
1036
1106
|
order: "post",
|
|
1037
1107
|
handler: workerdDependencyConfig
|
|
1038
1108
|
} : void 0,
|
|
1109
|
+
configResolved: options.standalone ? (config) => {
|
|
1110
|
+
startViteHubHints(config);
|
|
1111
|
+
if (/[?&]authToken=/.test(options.standalone?.database ?? "")) reportViteHubHint(config, commentsErrorDiagnostics.COMMENTS_DATABASE_TOKEN_IN_BUILD());
|
|
1112
|
+
} : void 0,
|
|
1039
1113
|
nitro: options.standalone ? { async setup(nitro) {
|
|
1040
1114
|
if (!projectRoot || !options.standalone) return;
|
|
1041
1115
|
const runner = nitro.options.devServer.runner || process.env.NITRO_DEV_RUNNER || "node-worker";
|
|
@@ -1338,8 +1412,8 @@ function usesComments(options) {
|
|
|
1338
1412
|
}
|
|
1339
1413
|
//#endregion
|
|
1340
1414
|
//#region src/overlay.ts
|
|
1341
|
-
/** Where the loader and overlay are served, below the app mount. */
|
|
1342
|
-
const overlayRoute = "/_vitehub/comments";
|
|
1415
|
+
/** Where the loader and overlay are served, below the app mount: the assets folder of the Comments API route. */
|
|
1416
|
+
const overlayRoute = "/_vitehub/comments/assets";
|
|
1343
1417
|
/** The path the app is mounted at: `""` for the root, `"/portal"` below it. A relative or empty Vite base is the root. */
|
|
1344
1418
|
function mountPath(base) {
|
|
1345
1419
|
if (!base || base === "./") return "";
|
|
@@ -1448,7 +1522,7 @@ function createHtmlScanner() {
|
|
|
1448
1522
|
else if (element?.[1] === "") {
|
|
1449
1523
|
if (!templates && name === "script") {
|
|
1450
1524
|
const src = htmlAttributes(tag).find((attribute) => attribute.name === "src")?.value;
|
|
1451
|
-
if (src && /\/_vitehub\/comments\/loader\.[\w-]+\.js(?:[?#]|$)/i.test(src)) return {
|
|
1525
|
+
if (src && /\/_vitehub\/comments\/assets\/loader\.[\w-]+\.js(?:[?#]|$)/i.test(src)) return {
|
|
1452
1526
|
loaded: {
|
|
1453
1527
|
start: position,
|
|
1454
1528
|
end: position + tag.length
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/comments",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Comments and in-place edits on live ViteHub sites, with presence and Content drafts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -106,10 +106,10 @@
|
|
|
106
106
|
"@valibot/to-json-schema": "^1.8.0",
|
|
107
107
|
"nostics": "1.4.0",
|
|
108
108
|
"valibot": "^1.5.0",
|
|
109
|
-
"@vite-hub/auth": "0.
|
|
110
|
-
"@vite-hub/forge": "0.
|
|
111
|
-
"@vite-hub/realtime": "0.
|
|
112
|
-
"@vite-hub/runtime": "0.
|
|
109
|
+
"@vite-hub/auth": "0.4.1",
|
|
110
|
+
"@vite-hub/forge": "0.4.1",
|
|
111
|
+
"@vite-hub/realtime": "0.4.1",
|
|
112
|
+
"@vite-hub/runtime": "0.4.1",
|
|
113
113
|
"birpc": "^4.2.0",
|
|
114
114
|
"confbox": "^0.3.1",
|
|
115
115
|
"h3": "^2.0.8"
|
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
"vitest": "^4.1.11",
|
|
129
129
|
"vue": "3.5.44",
|
|
130
130
|
"@libsql/client": "^0.18.0",
|
|
131
|
-
"@vite-hub/database": "0.
|
|
131
|
+
"@vite-hub/database": "0.4.1",
|
|
132
132
|
"vite": "^8.2.2",
|
|
133
133
|
"drizzle-orm": "1.0.0-rc.5"
|
|
134
134
|
},
|
|
135
135
|
"peerDependencies": {
|
|
136
|
-
"@vite-hub/database": "0.
|
|
136
|
+
"@vite-hub/database": "0.4.1",
|
|
137
137
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
138
138
|
"vite": ">=8.0.0",
|
|
139
139
|
"drizzle-orm": "1.0.0-rc.5 || ^1.0.0"
|
|
@@ -144,13 +144,13 @@
|
|
|
144
144
|
}
|
|
145
145
|
},
|
|
146
146
|
"engines": {
|
|
147
|
-
"node": ">=
|
|
147
|
+
"node": ">=24.15.0"
|
|
148
148
|
},
|
|
149
149
|
"scripts": {
|
|
150
150
|
"build": "vp pack && vp build --config overlay.vite.config.ts",
|
|
151
151
|
"dev": "vp pack && vp build --config overlay.vite.config.ts && vp pack --watch --no-clean",
|
|
152
152
|
"typecheck": "vp run --cache -t @vite-hub/comments#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
|
|
153
153
|
"test": "vp run --cache -t @vite-hub/comments#build && vp test",
|
|
154
|
-
"test:browser": "vp run --cache -t @vite-hub/comments#build && node --test test/browser/overlay.browser.mjs test/browser/presence.browser.mjs"
|
|
154
|
+
"test:browser": "vp run --cache -t @vite-hub/comments#build && node --test test/browser/overlay.browser.mjs test/browser/presence.browser.mjs test/browser/outbox.browser.mjs"
|
|
155
155
|
}
|
|
156
156
|
}
|