@vite-hub/source 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 +9 -6
- package/dist/client.d.ts +2 -3
- package/dist/client.js +3 -5
- package/dist/{collection-C1TZnrRP.js → collection-BNG6XUBS.js} +5 -9
- package/dist/{collection-B8sgxw5-.d.ts → collection-DXi2zyTi.d.ts} +0 -18
- package/dist/{collection-route-BplWPxHR.js → collection-route-DhDZBuGk.js} +1 -2
- package/dist/drizzle.d.ts +2 -3
- package/dist/drizzle.js +2 -3
- package/dist/{error-diagnostics-DZdhDQpU.js → error-diagnostics-TunlTPXq.js} +1 -2
- package/dist/{github-509beZOn.js → github-DfF_3WEy.js} +57 -54
- package/dist/{glob-DT9HlkyK.js → glob-BphSHshh.js} +5 -8
- package/dist/index.d.ts +3 -26
- package/dist/index.js +26 -28
- package/dist/internal/registry.d.ts +1 -1
- package/dist/internal/registry.js +1 -2
- package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
- package/dist/mcp.d.ts +1 -3
- package/dist/mcp.js +5 -7
- package/dist/{object-CtSHeGQO.js → object-D8cOtgW3.js} +1 -2
- package/dist/{path-Q-KcGmAN.js → path-8MJ_XVEB.js} +10 -18
- package/dist/{path-Cm7wV1Dk.js → path-ZomRTEWV.js} +2 -4
- package/dist/{registry-BSyFEr9r.js → registry-BNY8hxZp.js} +3 -5
- package/dist/{registry-CUv12y8b.d.ts → registry-CDV7weMm.d.ts} +1 -3
- package/dist/{root-0Ef8tgF5.js → root-gdkJ8uqd.js} +2 -3
- package/dist/server.d.ts +1 -5
- package/dist/server.js +5 -9
- package/dist/{types-Ln-FxVFn.d.ts → types-CYDwACKn.d.ts} +0 -2
- package/dist/vite.d.ts +6 -8
- package/dist/vite.js +67 -85
- package/package.json +14 -14
package/dist/vite.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
1
|
+
import { n as isRecord, r as isRecordOrFunction } from "./object-D8cOtgW3.js";
|
|
2
|
+
import { t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
3
|
+
import { t as sourceErrorDiagnostics } from "./error-diagnostics-TunlTPXq.js";
|
|
4
|
+
import { t as collectionRoutePath } from "./collection-route-DhDZBuGk.js";
|
|
5
|
+
import { i as resolveGlobInput, r as globFilePath, t as collectGlobFiles } from "./glob-BphSHshh.js";
|
|
6
6
|
import { formatDiagnostic } from "nostics";
|
|
7
7
|
import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
|
8
8
|
import { basename, dirname, extname, isAbsolute, join, parse, relative, resolve } from "node:path";
|
|
@@ -14,7 +14,7 @@ import { randomUUID } from "node:crypto";
|
|
|
14
14
|
import { once } from "node:events";
|
|
15
15
|
import { createServer } from "node:http";
|
|
16
16
|
import { gzipSync } from "node:zlib";
|
|
17
|
-
|
|
17
|
+
// ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
18
18
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
19
19
|
function normalizeWindowsPath(input = "") {
|
|
20
20
|
if (!input) return input;
|
|
@@ -111,16 +111,14 @@ const dirname$1 = function(p) {
|
|
|
111
111
|
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
112
112
|
return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
|
|
113
113
|
};
|
|
114
|
-
|
|
115
|
-
//#region ../internal/src/inspect.ts
|
|
114
|
+
// ../internal/src/inspect.ts
|
|
116
115
|
function relativeDefinitionFile(projectRoot, file) {
|
|
117
116
|
return relative$1(projectRoot, file).replaceAll("\\", "/");
|
|
118
117
|
}
|
|
119
118
|
const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|private[-_\s]?key|authorization|cookie|signature|dsn|connection[-_\s]?string/i;
|
|
120
119
|
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");
|
|
121
120
|
new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
|
|
122
|
-
|
|
123
|
-
//#region ../internal/src/build/vite.ts
|
|
121
|
+
// ../internal/src/build/vite.ts
|
|
124
122
|
const projectRootDirectoryMarkers = [
|
|
125
123
|
["server", "agents"],
|
|
126
124
|
["server", "channels"],
|
|
@@ -172,7 +170,7 @@ function hasProjectRootDirectoryMarker(root) {
|
|
|
172
170
|
for (const marker of projectRootDirectoryMarkers) try {
|
|
173
171
|
if (statSync(resolve(root, ...marker)).isDirectory()) return true;
|
|
174
172
|
} catch (error) {
|
|
175
|
-
if (error
|
|
173
|
+
if (!isMissingProjectMarker(error)) throw error;
|
|
176
174
|
}
|
|
177
175
|
return false;
|
|
178
176
|
}
|
|
@@ -186,13 +184,16 @@ function hasProjectRootFileMarker(root, markers) {
|
|
|
186
184
|
try {
|
|
187
185
|
if (statSync(resolve(root, ...path)).isFile()) return true;
|
|
188
186
|
} catch (error) {
|
|
189
|
-
if (error
|
|
187
|
+
if (!isMissingProjectMarker(error)) throw error;
|
|
190
188
|
}
|
|
191
189
|
}
|
|
192
190
|
return false;
|
|
193
191
|
}
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
function isMissingProjectMarker(error) {
|
|
193
|
+
const code = error.code;
|
|
194
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
195
|
+
}
|
|
196
|
+
// ../internal/src/build/ast-walk.ts
|
|
196
197
|
/** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
|
|
197
198
|
function moduleLanguage(file) {
|
|
198
199
|
if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
|
|
@@ -215,8 +216,7 @@ function walk$1(node, visit, parent) {
|
|
|
215
216
|
} else if (isNode$1(child)) walk$1(child, visit, node);
|
|
216
217
|
}
|
|
217
218
|
}
|
|
218
|
-
|
|
219
|
-
//#region ../internal/src/build/scan-module.ts
|
|
219
|
+
// ../internal/src/build/scan-module.ts
|
|
220
220
|
/**
|
|
221
221
|
* Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
|
|
222
222
|
* the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
|
|
@@ -367,8 +367,7 @@ function staticString(node) {
|
|
|
367
367
|
const value = staticValue(node);
|
|
368
368
|
return typeof value === "string" ? value : void 0;
|
|
369
369
|
}
|
|
370
|
-
|
|
371
|
-
//#region ../internal/src/hints.ts
|
|
370
|
+
// ../internal/src/hints.ts
|
|
372
371
|
/**
|
|
373
372
|
* The file that lists the hints of the last build or dev server, relative to the project root. A hint is a warning
|
|
374
373
|
* about something that works now and fails later, such as counts that stay in one server's memory. Agents and CI read
|
|
@@ -446,8 +445,15 @@ function startViteHubHints(config, owner = config) {
|
|
|
446
445
|
started.add(owner);
|
|
447
446
|
write(startRun(config));
|
|
448
447
|
}
|
|
449
|
-
|
|
450
|
-
|
|
448
|
+
Object.freeze({ vitehubAuthAccess: "handler" });
|
|
449
|
+
/**
|
|
450
|
+
* The route meta of a generated handler that checks access on every request, even when the app adds no rule: a required
|
|
451
|
+
* `authorize` policy, an explicit `access` rule, a required access token, or a signature. Auth access routes still apply
|
|
452
|
+
* to it, so an app rule stays in force. `checksOwnAccess(event)` of `vite-hub/auth` reads it, so app middleware can skip
|
|
453
|
+
* the route. A route that can run without a check, such as a browser error sink, an optional `authorize`, or a webhook
|
|
454
|
+
* with `secret: false`, must not use it.
|
|
455
|
+
*/
|
|
456
|
+
const ownAccessRouteMeta = Object.freeze({ vitehubOwnAccess: true });
|
|
451
457
|
function cloneArray(value) {
|
|
452
458
|
return Array.isArray(value) ? [...value] : [];
|
|
453
459
|
}
|
|
@@ -475,8 +481,7 @@ function createNitroServerKit(value = {}) {
|
|
|
475
481
|
}
|
|
476
482
|
};
|
|
477
483
|
}
|
|
478
|
-
|
|
479
|
-
//#region ../internal/src/build/paths.ts
|
|
484
|
+
// ../internal/src/build/paths.ts
|
|
480
485
|
function resolveRuntimeModule(packageDir, modulePath) {
|
|
481
486
|
const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
|
|
482
487
|
return existsSync(distFile) ? distFile : resolve$1(packageDir, "src", `${modulePath}.ts`);
|
|
@@ -503,8 +508,7 @@ function findPackageDir(file) {
|
|
|
503
508
|
function ownModule(importMetaUrl, modulePath) {
|
|
504
509
|
return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
|
|
505
510
|
}
|
|
506
|
-
|
|
507
|
-
//#region src/internal/content-types-writer.ts
|
|
511
|
+
// src/internal/content-types-writer.ts
|
|
508
512
|
const installed = /* @__PURE__ */ new WeakMap();
|
|
509
513
|
/** Keep writes in the Nitro host, including when its runtime runs in workerd. */
|
|
510
514
|
function installContentTypesWriter(host, plugin) {
|
|
@@ -553,8 +557,7 @@ async function startWriter(host, plugin) {
|
|
|
553
557
|
host.options.runtimeConfig ??= {};
|
|
554
558
|
host.options.runtimeConfig.vitehubContentTypesWriter = `http://127.0.0.1:${address.port}${path}`;
|
|
555
559
|
}
|
|
556
|
-
|
|
557
|
-
//#region src/internal/content-types-plugin.injected.ts
|
|
560
|
+
// src/internal/content-types-plugin.injected.ts
|
|
558
561
|
/**
|
|
559
562
|
* Source of the generated Nitro plugin that writes the types of `content.get()`, `content.list()`, and
|
|
560
563
|
* `content.query()` in development. `importBase` and `contentModule` are JSON string literals of import paths. The
|
|
@@ -574,9 +577,7 @@ function renderContentTypesPlugin(importBase, contentModule) {
|
|
|
574
577
|
""
|
|
575
578
|
].join("\n");
|
|
576
579
|
}
|
|
577
|
-
|
|
578
|
-
//#region src/internal/collection-discovery.ts
|
|
579
|
-
/** The initializers of top-level `const`, `let`, and `var` declarations named `name`, with their declaration kind. */
|
|
580
|
+
// src/internal/collection-discovery.ts
|
|
580
581
|
function declarationInitializers(module, name, exportedOnly) {
|
|
581
582
|
return module.program.body.flatMap((statement) => {
|
|
582
583
|
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : exportedOnly ? void 0 : statement;
|
|
@@ -588,7 +589,6 @@ function declarationInitializers(module, name, exportedOnly) {
|
|
|
588
589
|
});
|
|
589
590
|
}
|
|
590
591
|
const viteHubSourceSpecifier = /^(?:@vite-hub\/source|vite-hub\/source)(?:\/|$)/;
|
|
591
|
-
/** Checks binding targets, including nested destructuring, without treating property keys or defaults as bindings. */
|
|
592
592
|
function bindsCollectionFactory(binding) {
|
|
593
593
|
switch (binding.type) {
|
|
594
594
|
case "Identifier": return binding.name === "defineCollection";
|
|
@@ -599,11 +599,6 @@ function bindsCollectionFactory(binding) {
|
|
|
599
599
|
default: return false;
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
/**
|
|
603
|
-
* True when `defineCollection` in this module is ViteHub's factory: imported from a ViteHub Source entry, or not
|
|
604
|
-
* declared in the module at all (an auto-import). A local function or an import from elsewhere with that name can
|
|
605
|
-
* return any Collection, so its options say nothing about the route.
|
|
606
|
-
*/
|
|
607
602
|
function callsViteHubFactory(module) {
|
|
608
603
|
for (const statement of module.program.body) {
|
|
609
604
|
if (statement.type === "ImportDeclaration") {
|
|
@@ -616,17 +611,12 @@ function callsViteHubFactory(module) {
|
|
|
616
611
|
}
|
|
617
612
|
return true;
|
|
618
613
|
}
|
|
619
|
-
/** The local binding that `export { local as exportName }` exports, without a module source. */
|
|
620
614
|
function exportedLocalName(module, exportName) {
|
|
621
615
|
for (const statement of module.program.body) {
|
|
622
616
|
if (statement.type !== "ExportNamedDeclaration" || statement.source || statement.exportKind === "type") continue;
|
|
623
617
|
for (const specifier of statement.specifiers) if ((specifier.exported.type === "Identifier" ? specifier.exported.name : specifier.exported.value) === exportName && specifier.local.type === "Identifier") return specifier.local.name;
|
|
624
618
|
}
|
|
625
619
|
}
|
|
626
|
-
/**
|
|
627
|
-
* Finds the `defineCollection(...)` call that initializes the named export. An initializer with more than one call,
|
|
628
|
-
* such as a conditional, has no known call: the scanner cannot know which branch runs.
|
|
629
|
-
*/
|
|
630
620
|
function findCollectionDefinitionCall(source, exportName, file) {
|
|
631
621
|
const module = scanModule(source, `${file}.ts`);
|
|
632
622
|
const calls = findCalls(module, ["defineCollection"]);
|
|
@@ -650,11 +640,6 @@ function findCollectionDefinitionCall(source, exportName, file) {
|
|
|
650
640
|
if (call) return call;
|
|
651
641
|
}
|
|
652
642
|
}
|
|
653
|
-
/**
|
|
654
|
-
* True only for a literal `route: false` in the options of the exported `defineCollection()` call. A spread or a
|
|
655
|
-
* computed key after it can set `route` again when the module runs, so the route stays. Any other form keeps the route,
|
|
656
|
-
* and `defineCollectionHandler()` answers 404 at request time when the Collection has `route: false`.
|
|
657
|
-
*/
|
|
658
643
|
function collectionRouteDisabled(definition) {
|
|
659
644
|
if (!definition?.exported) return false;
|
|
660
645
|
const options = argumentExpression(definition.call.arguments[1] ?? definition.call.arguments[0]);
|
|
@@ -723,8 +708,7 @@ async function discoverCollections(options) {
|
|
|
723
708
|
}
|
|
724
709
|
return collections;
|
|
725
710
|
}
|
|
726
|
-
|
|
727
|
-
//#region src/inspect.ts
|
|
711
|
+
// src/inspect.ts
|
|
728
712
|
const dynamic = "Dynamic";
|
|
729
713
|
function objectLiteral(value) {
|
|
730
714
|
return value?.type === "ObjectExpression" ? value : void 0;
|
|
@@ -737,7 +721,6 @@ function readMember(object, name) {
|
|
|
737
721
|
value: property.value
|
|
738
722
|
};
|
|
739
723
|
}
|
|
740
|
-
/** An identifier path such as `schema` or `tables.articles`, as written without whitespace. */
|
|
741
724
|
function identifierPath(value, optional) {
|
|
742
725
|
if (value.type === "Identifier") return value.name;
|
|
743
726
|
if (value.type !== "MemberExpression" || value.computed || value.property.type !== "Identifier" || value.optional && !optional) return;
|
|
@@ -768,7 +751,6 @@ function describeStringList(member) {
|
|
|
768
751
|
if (values.some((value) => value === void 0)) return dynamic;
|
|
769
752
|
return values.length ? values.join(", ") : "None";
|
|
770
753
|
}
|
|
771
|
-
/** Shows an identifier path as written and a call as `callee(...)`. Other expressions show as `Inline`. */
|
|
772
754
|
function describeExpression(member) {
|
|
773
755
|
if (member.method) return "Inline";
|
|
774
756
|
const path = identifierPath(member.value, true);
|
|
@@ -872,7 +854,6 @@ function tableFields(options) {
|
|
|
872
854
|
pushLimits(fields, options);
|
|
873
855
|
return fields;
|
|
874
856
|
}
|
|
875
|
-
/** Fields of a custom source object and of the options in `defineCollection(load, options)`. */
|
|
876
857
|
function loaderFields(options) {
|
|
877
858
|
const pagination = readMember(options, "pagination");
|
|
878
859
|
const fields = [{
|
|
@@ -964,13 +945,7 @@ function summarizeCollection(projectRoot, collection) {
|
|
|
964
945
|
async function inspectCollectionDefinitions(options) {
|
|
965
946
|
return (await discoverCollections(options)).map((collection) => summarizeCollection(options.projectRoot, collection));
|
|
966
947
|
}
|
|
967
|
-
|
|
968
|
-
//#region src/internal/bundle-glob.ts
|
|
969
|
-
/**
|
|
970
|
-
* Bundling glob(): a ViteHub server build swaps each `glob()` call whose options are literals for a module that holds
|
|
971
|
-
* the files it matches, through files(). Hosts without a file system, such as Cloudflare Workers, then serve the same
|
|
972
|
-
* keys and bytes that glob() reads from disk. `vite dev` keeps glob() as it is.
|
|
973
|
-
*/
|
|
948
|
+
// src/internal/bundle-glob.ts
|
|
974
949
|
/** Prefix of the generated modules' ids. `\0` keeps other plugins from resolving or transforming them. */
|
|
975
950
|
const BUNDLED_GLOB_ID = "\0vitehub-source-glob:";
|
|
976
951
|
/** Matches those ids, for Rolldown's hook filters. */
|
|
@@ -993,7 +968,6 @@ function walk(node, visit) {
|
|
|
993
968
|
for (const value of Object.values(node)) if (Array.isArray(value)) value.forEach((child) => isNode(child) && walk(child, visit));
|
|
994
969
|
else if (isNode(value)) walk(value, visit);
|
|
995
970
|
}
|
|
996
|
-
/** A literal's value, or undefined for anything that is not one. */
|
|
997
971
|
function literal(node) {
|
|
998
972
|
if (!node) return void 0;
|
|
999
973
|
if (node.type === "Literal") return node.value;
|
|
@@ -1127,8 +1101,7 @@ async function loadBundledGlob(id, rootDir) {
|
|
|
1127
1101
|
watched
|
|
1128
1102
|
};
|
|
1129
1103
|
}
|
|
1130
|
-
|
|
1131
|
-
//#region src/internal/source-discovery.ts
|
|
1104
|
+
// src/internal/source-discovery.ts
|
|
1132
1105
|
/** Lists the Source files under `<serverDir>/sources`. Each default export is one Source. It reads the files and does not import them. */
|
|
1133
1106
|
async function discoverSources(options) {
|
|
1134
1107
|
const serverDirs = options.serverDirs === void 0 ? [resolve(options.projectRoot, "server")] : options.serverDirs.map((directory) => resolve(options.projectRoot, directory));
|
|
@@ -1154,8 +1127,7 @@ async function discoverSources(options) {
|
|
|
1154
1127
|
}
|
|
1155
1128
|
return sources;
|
|
1156
1129
|
}
|
|
1157
|
-
|
|
1158
|
-
//#region src/vite.ts
|
|
1130
|
+
// src/vite.ts
|
|
1159
1131
|
const collectionTypesEntry = ".vitehub/types/source/collections.d.ts";
|
|
1160
1132
|
const sourceTypesEntry = ".vitehub/types/source/sources.d.ts";
|
|
1161
1133
|
const sourceRegistryEntry = ".vitehub/source/registry.mjs";
|
|
@@ -1368,10 +1340,6 @@ async function writeCollectionArtifacts(options, collections) {
|
|
|
1368
1340
|
};
|
|
1369
1341
|
}));
|
|
1370
1342
|
}
|
|
1371
|
-
/**
|
|
1372
|
-
* Writes the `ViteHubSourceMap` types and a Nitro plugin that registers a loader for each file in `server/sources/`
|
|
1373
|
-
* by its name, so `useSource("docs")` opens the default export of `server/sources/docs.ts`.
|
|
1374
|
-
*/
|
|
1375
1343
|
async function writeSourceArtifacts(options, sources) {
|
|
1376
1344
|
const types = resolve(options.projectRoot, sourceTypesEntry);
|
|
1377
1345
|
const registry = resolve(options.projectRoot, sourceRegistryEntry);
|
|
@@ -1446,7 +1414,6 @@ function astName(node) {
|
|
|
1446
1414
|
if (node.type === "Identifier" && String(node.name) === node.name) return node.name;
|
|
1447
1415
|
if (node.type === "Literal" && String(node.value) === node.value) return node.value;
|
|
1448
1416
|
}
|
|
1449
|
-
/** Drops `as`, `satisfies`, `!`, and parentheses around an expression. */
|
|
1450
1417
|
function unwrapAst(node) {
|
|
1451
1418
|
let current = node;
|
|
1452
1419
|
while (isAstNode(current) && [
|
|
@@ -1626,23 +1593,27 @@ function inspectContentOptions(program, contentImportBase) {
|
|
|
1626
1593
|
}
|
|
1627
1594
|
return features;
|
|
1628
1595
|
}
|
|
1596
|
+
async function inspectContentEntryForGeneration(file, contentImportBase) {
|
|
1597
|
+
const { parseAst } = await import("vite");
|
|
1598
|
+
return inspectContentModule(parseAst(await readFile(file, "utf8"), { lang: /\.[cm]?ts$/.test(file) ? "ts" : "js" }), contentImportBase);
|
|
1599
|
+
}
|
|
1629
1600
|
/** Read what the Content module defines without running it. A file that does not parse counts as defining everything. */
|
|
1630
1601
|
async function inspectContentEntry(file, contentImportBase) {
|
|
1631
|
-
const { parseAst } = await import("vite");
|
|
1632
1602
|
try {
|
|
1633
|
-
return
|
|
1634
|
-
} catch {
|
|
1603
|
+
return await inspectContentEntryForGeneration(file, contentImportBase);
|
|
1604
|
+
} catch (error) {
|
|
1605
|
+
if (!isRecord(error) || error.code !== "PARSE_ERROR") throw error;
|
|
1635
1606
|
return {
|
|
1636
1607
|
route: true,
|
|
1637
1608
|
collections: true,
|
|
1638
|
-
sitemap:
|
|
1639
|
-
robots:
|
|
1640
|
-
markdown:
|
|
1641
|
-
rss:
|
|
1642
|
-
mcp:
|
|
1643
|
-
llms:
|
|
1609
|
+
sitemap: true,
|
|
1610
|
+
robots: true,
|
|
1611
|
+
markdown: true,
|
|
1612
|
+
rss: true,
|
|
1613
|
+
mcp: "unknown",
|
|
1614
|
+
llms: true,
|
|
1644
1615
|
live: true,
|
|
1645
|
-
previews:
|
|
1616
|
+
previews: true,
|
|
1646
1617
|
sqlite: false,
|
|
1647
1618
|
github: false
|
|
1648
1619
|
};
|
|
@@ -1685,7 +1656,7 @@ async function writeContentArtifact(options, file) {
|
|
|
1685
1656
|
const importBase = JSON.stringify(options.contentImportBase ?? "@vite-hub/content");
|
|
1686
1657
|
const contentModule = JSON.stringify(toRuntimeModuleSpecifier(file));
|
|
1687
1658
|
const features = {
|
|
1688
|
-
...await
|
|
1659
|
+
...await inspectContentEntryForGeneration(file, options.contentImportBase ?? "@vite-hub/content"),
|
|
1689
1660
|
...options.appSeo?.sitemap ? { sitemap: false } : {},
|
|
1690
1661
|
...options.appSeo?.robots ? { robots: false } : {}
|
|
1691
1662
|
};
|
|
@@ -1754,6 +1725,7 @@ async function writeContentArtifact(options, file) {
|
|
|
1754
1725
|
].join("\n"));
|
|
1755
1726
|
handlers.push({
|
|
1756
1727
|
handler: githubWebhook,
|
|
1728
|
+
meta: { ...ownAccessRouteMeta },
|
|
1757
1729
|
method: "post",
|
|
1758
1730
|
route: "/_vitehub/content/github"
|
|
1759
1731
|
});
|
|
@@ -1878,7 +1850,6 @@ async function prepareSourceArtifacts(options) {
|
|
|
1878
1850
|
async function prepareSourceGeneration(options) {
|
|
1879
1851
|
return (await prepareSourceArtifacts(options)).handlers;
|
|
1880
1852
|
}
|
|
1881
|
-
/** Nuxt serves Vite assets from `/_nuxt/`, so its Vite `base` is not the app base. `vite-hub/nuxt` passes the app base. */
|
|
1882
1853
|
function applicationBaseURL(config) {
|
|
1883
1854
|
const configured = Reflect.get(config, VITEHUB_APP_BASE_URL);
|
|
1884
1855
|
const base = typeof configured === "string" ? configured : config.base;
|
|
@@ -1930,6 +1901,7 @@ function hubSource(options = {}) {
|
|
|
1930
1901
|
};
|
|
1931
1902
|
const configurationTransitionByRoot = /* @__PURE__ */ new Map();
|
|
1932
1903
|
let legacyServerBuild = false;
|
|
1904
|
+
let nitroBuildHints;
|
|
1933
1905
|
let resolvedConfig;
|
|
1934
1906
|
const generatedHandlersListeners = /* @__PURE__ */ new Set();
|
|
1935
1907
|
const prepareSources = (input) => {
|
|
@@ -2023,11 +1995,14 @@ function hubSource(options = {}) {
|
|
|
2023
1995
|
},
|
|
2024
1996
|
handler(code, id, options) {
|
|
2025
1997
|
const environment = this.environment?.config;
|
|
2026
|
-
|
|
2027
|
-
|
|
1998
|
+
const nitroBuild = environment ? void 0 : nitroBuildHints;
|
|
1999
|
+
if (!(environment ? environment.consumer === "server" : options?.ssr === true && (legacyServerBuild || nitroBuild)) || environment && environment.command !== "build") return;
|
|
2000
|
+
const file = id.split(/[?#]/, 1)[0] ?? id;
|
|
2001
|
+
const lang = /\.[cm]?tsx$/.test(file) ? "tsx" : /\.[cm]?jsx$/.test(file) ? "jsx" : /\.[cm]?ts$/.test(file) ? "ts" : "js";
|
|
2002
|
+
const calls = findGlobCalls(this.parse(code, nitroBuild ? { lang } : void 0));
|
|
2028
2003
|
for (const call of calls.filter((call) => call.input === void 0)) {
|
|
2029
2004
|
const hint = sourceErrorDiagnostics.SOURCE_GLOB_OPTIONS_NOT_LITERAL();
|
|
2030
|
-
const config = environment ?? resolvedConfig;
|
|
2005
|
+
const config = environment ?? nitroBuild ?? resolvedConfig;
|
|
2031
2006
|
if (!config) {
|
|
2032
2007
|
this.warn({
|
|
2033
2008
|
message: `[vitehub] ${hint.why}`,
|
|
@@ -2036,7 +2011,7 @@ function hubSource(options = {}) {
|
|
|
2036
2011
|
continue;
|
|
2037
2012
|
}
|
|
2038
2013
|
const lines = code.slice(0, call.start).split("\n");
|
|
2039
|
-
hint.sources = [`${relative(config.root,
|
|
2014
|
+
hint.sources = [`${relative(config.root, file)}:${lines.length}:${lines.at(-1).length + 1}`];
|
|
2040
2015
|
reportViteHubHint(config, hint);
|
|
2041
2016
|
}
|
|
2042
2017
|
if (calls.some((call) => call.input !== void 0)) return {
|
|
@@ -2091,7 +2066,15 @@ function hubSource(options = {}) {
|
|
|
2091
2066
|
},
|
|
2092
2067
|
async config(config, env) {
|
|
2093
2068
|
const viteConfig = config;
|
|
2094
|
-
if (viteConfig["__vitehubNitroConfigContext"])
|
|
2069
|
+
if (viteConfig["__vitehubNitroConfigContext"]) {
|
|
2070
|
+
nitroBuildHints = env.command === "build" ? {
|
|
2071
|
+
...config,
|
|
2072
|
+
command: env.command,
|
|
2073
|
+
root: viteConfig["__vitehubProjectRoot"] ?? config.root ?? process.cwd(),
|
|
2074
|
+
[VITEHUB_NUXT_HINTS]: true
|
|
2075
|
+
} : void 0;
|
|
2076
|
+
return;
|
|
2077
|
+
}
|
|
2095
2078
|
legacyServerBuild = env.command === "build" && config.build?.ssr === true;
|
|
2096
2079
|
const projectRoot = viteConfig["__vitehubProjectRoot"] ? resolve(viteConfig[VITEHUB_PROJECT_ROOT]) : resolveViteHubProjectRoot(viteConfig.root || process.cwd());
|
|
2097
2080
|
latestProjectRoot = projectRoot;
|
|
@@ -2350,5 +2333,4 @@ function hubSource(options = {}) {
|
|
|
2350
2333
|
}
|
|
2351
2334
|
};
|
|
2352
2335
|
}
|
|
2353
|
-
//#endregion
|
|
2354
2336
|
export { findContentEntry, hubSource, inspectCollectionDefinitions, inspectCollectionModule, inspectContentEntry, inspectContentModule, mergeGeneratedSourceNitroConfig, prepareSourceGeneration, toRuntimeModuleSpecifier, toTypeModuleSpecifier };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/source",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Typed source retrieval primitives for ViteHub.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"content",
|
|
@@ -67,37 +67,37 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@standard-schema/spec": "^1.1.0",
|
|
70
|
-
"@vite-hub/runtime": "0.
|
|
70
|
+
"@vite-hub/runtime": "0.5.1",
|
|
71
71
|
"mrmime": "^2.0.1",
|
|
72
72
|
"nostics": "1.4.0",
|
|
73
|
-
"ocache": "^0.3.
|
|
73
|
+
"ocache": "^0.3.2"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@modelcontextprotocol/sdk": "^1.32.
|
|
77
|
-
"@types/node": "^24.19.
|
|
76
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
77
|
+
"@types/node": "^24.19.2",
|
|
78
78
|
"@types/picomatch": "^4.0.3",
|
|
79
|
-
"@vite-hub/forge": "0.
|
|
79
|
+
"@vite-hub/forge": "0.5.1",
|
|
80
80
|
"@vite-hub/internal": "0.0.1",
|
|
81
|
-
"drizzle-orm": "1.0.0-rc.
|
|
81
|
+
"drizzle-orm": "1.0.0-rc.6",
|
|
82
82
|
"h3": "^2.0.8",
|
|
83
83
|
"nitro": "^3.0.261103-rc",
|
|
84
84
|
"picomatch": "^4.0.7",
|
|
85
85
|
"publint": "^0.3.25",
|
|
86
86
|
"tinyglobby": "^0.2.17",
|
|
87
87
|
"typescript": "^6.0.3",
|
|
88
|
-
"vite": "^8.
|
|
88
|
+
"vite": "^8.3.8",
|
|
89
89
|
"valibot": "^1.5.0",
|
|
90
|
-
"vite-plus": "^
|
|
91
|
-
"vitest": "
|
|
92
|
-
"vue": "3.5.
|
|
90
|
+
"vite-plus": "^1.7.0",
|
|
91
|
+
"vitest": "5.1.0",
|
|
92
|
+
"vue": "3.5.46"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@modelcontextprotocol/sdk": "^1.32.
|
|
96
|
-
"drizzle-orm": "1.0.0-rc.5 || ^1.0.0",
|
|
95
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
96
|
+
"drizzle-orm": "1.0.0-rc.5 || 1.0.0-rc.6 || ^1.0.0",
|
|
97
97
|
"nitro": "3.0.261102-rc || ^3.0.261103-rc",
|
|
98
98
|
"vite": ">=8.0.0",
|
|
99
99
|
"vue": "^3.5.0",
|
|
100
|
-
"@vite-hub/forge": "0.
|
|
100
|
+
"@vite-hub/forge": "0.5.1"
|
|
101
101
|
},
|
|
102
102
|
"peerDependenciesMeta": {
|
|
103
103
|
"@modelcontextprotocol/sdk": {
|