@vite-hub/workflow 0.7.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/README.md +1 -1
- package/dist/{client-CPxPxsl5.js → client-EqfVxh7z.js} +14 -25
- package/dist/{cloudflare-concurrency-counter-CDHHiMfn.js → cloudflare-concurrency-counter-ClJbAi_S.js} +1 -1
- package/dist/{cloudflare-env-DHhzRZOs.js → cloudflare-env-CiI2UtWD.js} +0 -4
- package/dist/{config-CwCwuZqv.js → config-BmCUU0cM.js} +6 -6
- package/dist/definition.d.ts +1 -1
- package/dist/definition.js +1 -1
- package/dist/{delay-JrpW40UF.js → delay-p5EJWtCp.js} +4 -4
- package/dist/durability.d.ts +1 -1
- package/dist/{error-diagnostics-35AEmfve.js → error-diagnostics-BDtBsCLZ.js} +1 -1
- package/dist/{execute-CLmIXnON.js → execute-B47oa9GC.js} +5 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/{openworkflow-BiwPTYEz.js → openworkflow-B-Mkb0RK.js} +11 -14
- package/dist/{openworkflow-C65AWQSJ.d.ts → openworkflow-DHuxMJQB.d.ts} +2 -2
- package/dist/{operations-DyaGK9zW.js → operations-DfcC--r7.js} +4 -4
- package/dist/operations.d.ts +1 -1
- package/dist/operations.js +1 -2
- package/dist/{results-DBp_bmUP.d.ts → results-DqbEUMCH.d.ts} +1 -1
- package/dist/{run-error-8p4BtTMv.js → run-error-zZh1_IBo.js} +5 -21
- package/dist/runtime/cloudflare-concurrency.d.ts +1 -1
- package/dist/runtime/cloudflare-concurrency.js +1 -1
- package/dist/runtime/cloudflare-runner.d.ts +1 -1
- package/dist/runtime/cloudflare-runner.js +5 -5
- package/dist/runtime/cloudflare-shared.js +1 -1
- package/dist/runtime/cloudflare-vite.d.ts +1 -1
- package/dist/runtime/cloudflare-vite.js +2 -2
- package/dist/runtime/execute.d.ts +1 -1
- package/dist/runtime/execute.js +1 -1
- package/dist/runtime/openworkflow-worker.d.ts +2 -2
- package/dist/runtime/openworkflow-worker.js +5 -6
- package/dist/runtime/openworkflow.d.ts +1 -1
- package/dist/runtime/openworkflow.js +1 -1
- package/dist/runtime/state.d.ts +1 -1
- package/dist/runtime/state.js +2 -2
- package/dist/runtime/vercel-vite.d.ts +1 -1
- package/dist/runtime/vercel-vite.js +1 -1
- package/dist/{signals-CdaxRNjN.js → signals-DpdrHuD3.js} +1 -1
- package/dist/{types-CvyOEp0V.d.ts → types-DrhUXMsE.d.ts} +1 -0
- package/dist/{vercel-ADMH2MK8.js → vercel-5t11Q1sg.js} +6 -6
- package/dist/vite.d.ts +2 -1
- package/dist/vite.js +427 -140
- package/package.json +4 -3
package/dist/vite.js
CHANGED
|
@@ -3,12 +3,12 @@ import { n as invariantError, t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
|
3
3
|
import { workflowDurabilityUrl } from "./durability.js";
|
|
4
4
|
import { t as internalErrorDiagnostics } from "./error-diagnostics-CsiNo_oI.js";
|
|
5
5
|
import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
|
|
6
|
-
import { n as getHostingProvider, r as normalizeHosting, t as normalizeWorkflowOptions } from "./config-
|
|
6
|
+
import { n as getHostingProvider, r as normalizeHosting, t as normalizeWorkflowOptions } from "./config-BmCUU0cM.js";
|
|
7
7
|
import { r as relativeDefinitionFile } from "./inspect-NBCAwsxi.js";
|
|
8
|
-
import { c as getCloudflareWorkflowClassName, l as getLegacyCloudflareWorkflowClassName, n as cloudflareConcurrencyClassName, o as createCloudflareWorkflowBindings, r as cloudflareConcurrencyMigrationTag, t as cloudflareConcurrencyBinding } from "./cloudflare-concurrency-counter-
|
|
9
|
-
import { t as workflowErrorDiagnostics } from "./error-diagnostics-
|
|
10
|
-
import { f as toStepPropertyName, i as resolveWorkflowStepOptions } from "./execute-
|
|
11
|
-
import { n as generatedNativeEntryKey, o as vercelNativeRegistryKey, r as generatedNativeRootStepKey, s as workflowStartAtKey } from "./delay-
|
|
8
|
+
import { c as getCloudflareWorkflowClassName, l as getLegacyCloudflareWorkflowClassName, n as cloudflareConcurrencyClassName, o as createCloudflareWorkflowBindings, r as cloudflareConcurrencyMigrationTag, t as cloudflareConcurrencyBinding } from "./cloudflare-concurrency-counter-ClJbAi_S.js";
|
|
9
|
+
import { t as workflowErrorDiagnostics } from "./error-diagnostics-BDtBsCLZ.js";
|
|
10
|
+
import { f as toStepPropertyName, i as resolveWorkflowStepOptions } from "./execute-B47oa9GC.js";
|
|
11
|
+
import { n as generatedNativeEntryKey, o as vercelNativeRegistryKey, r as generatedNativeRootStepKey, s as workflowStartAtKey } from "./delay-p5EJWtCp.js";
|
|
12
12
|
import { t as defaultOpenWorkflowSqlitePath } from "./openworkflow-defaults-1n0DbLdb.js";
|
|
13
13
|
import { builtinModules, createRequire, isBuiltin } from "node:module";
|
|
14
14
|
import { dirname, normalize, relative, resolve } from "pathe";
|
|
@@ -419,11 +419,9 @@ function isRelativeSpecifier(path) {
|
|
|
419
419
|
function isBareSpecifier(id) {
|
|
420
420
|
return !/^(?:\.{1,2}(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/]|\0|#|[a-z][a-z0-9+.-]*:)/i.test(id);
|
|
421
421
|
}
|
|
422
|
-
/** The folder that a relative import of `importer` resolves from, as esbuild's `resolveDir`. */
|
|
423
422
|
function importerDir(importer, workingDir) {
|
|
424
423
|
return importer && isAbsolute(importer) ? dirname$1(importer) : workingDir;
|
|
425
424
|
}
|
|
426
|
-
/** Rolldown resolves a specifier from an importer file. A bundle entry has none, so use a file in the working folder. */
|
|
427
425
|
function importerFor(importer, workingDir) {
|
|
428
426
|
return importer ?? join(workingDir, "__vitehub_entry__.js");
|
|
429
427
|
}
|
|
@@ -456,11 +454,6 @@ function collectPackageExportCandidates(packageName, exportsValue, packageRelati
|
|
|
456
454
|
}
|
|
457
455
|
return candidates;
|
|
458
456
|
}
|
|
459
|
-
/**
|
|
460
|
-
* Resolves `specifier` from a resolveId hook without running that hook again. `flag` in `custom` also skips the hook in
|
|
461
|
-
* resolutions that other plugins start from this one. `skipSelf` is still needed: when two equal resolutions run at the
|
|
462
|
-
* same time, Rolldown 1.2 can give one of them no `custom`, and the hook would then wait on its own resolution.
|
|
463
|
-
*/
|
|
464
457
|
function resolveFrom(context, specifier, request, workingDir, flag) {
|
|
465
458
|
return context.resolve(specifier, importerFor(request.importer, workingDir), {
|
|
466
459
|
custom: {
|
|
@@ -777,9 +770,6 @@ function createWasmModulePlugin(outdir, workingDir, copy) {
|
|
|
777
770
|
}
|
|
778
771
|
};
|
|
779
772
|
}
|
|
780
|
-
/**
|
|
781
|
-
* Leaves package imports external. Resolve package.json import mappings first, and preserve unmapped host imports.
|
|
782
|
-
*/
|
|
783
773
|
function createExternalPackagesPlugin() {
|
|
784
774
|
return {
|
|
785
775
|
name: "vitehub-external-packages",
|
|
@@ -865,7 +855,6 @@ function createOptionalImportPlugin() {
|
|
|
865
855
|
}
|
|
866
856
|
};
|
|
867
857
|
}
|
|
868
|
-
/** Matches import paths as esbuild's `external` does: `*` is a wildcard, and a package name also matches its subpaths. */
|
|
869
858
|
function createExternalMatcher(patterns) {
|
|
870
859
|
if (!patterns?.length) return;
|
|
871
860
|
const matchers = patterns.map((pattern) => {
|
|
@@ -877,7 +866,6 @@ function createExternalMatcher(patterns) {
|
|
|
877
866
|
});
|
|
878
867
|
return (id) => matchers.some((matches) => matches(id));
|
|
879
868
|
}
|
|
880
|
-
/** Returns the modules of the chunks that no chunk loaded from the entry chunk imports. */
|
|
881
869
|
function findUnusedChunkModules(chunks) {
|
|
882
870
|
const used = new Set(chunks.filter((chunk) => chunk.isEntry));
|
|
883
871
|
for (const chunk of used) for (const other of chunks) if (!used.has(other) && chunk.code.includes(other.fileName)) used.add(other);
|
|
@@ -3230,7 +3218,6 @@ async function copyRetainedSourceTree(source, target, filter) {
|
|
|
3230
3218
|
}
|
|
3231
3219
|
await copyEntry(source, target, false);
|
|
3232
3220
|
}
|
|
3233
|
-
/** Copies a file or folder and follows links. `node_modules` folders and paths that disappear during the copy are skipped. */
|
|
3234
3221
|
async function copyTree(source, target) {
|
|
3235
3222
|
const info = await unlessGone(() => stat(source));
|
|
3236
3223
|
if (!info) return;
|
|
@@ -3264,6 +3251,150 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
|
|
|
3264
3251
|
await unlessGone(() => copyFile(join(packageDir, path), target));
|
|
3265
3252
|
}
|
|
3266
3253
|
}
|
|
3254
|
+
// ../internal/src/source-files.ts
|
|
3255
|
+
const ignoredDirs = /* @__PURE__ */ new Set([
|
|
3256
|
+
"node_modules",
|
|
3257
|
+
"dist",
|
|
3258
|
+
".output",
|
|
3259
|
+
".nuxt",
|
|
3260
|
+
".vercel",
|
|
3261
|
+
".git",
|
|
3262
|
+
".vitehub"
|
|
3263
|
+
]);
|
|
3264
|
+
const racyWindowNs = 2000000000n;
|
|
3265
|
+
const storeKey = Symbol.for("vite-hub.source-files.v1");
|
|
3266
|
+
function store() {
|
|
3267
|
+
const existing = Reflect.get(globalThis, storeKey);
|
|
3268
|
+
if (isStore(existing)) return existing;
|
|
3269
|
+
const created = {
|
|
3270
|
+
derived: /* @__PURE__ */ new Map(),
|
|
3271
|
+
texts: /* @__PURE__ */ new Map(),
|
|
3272
|
+
trees: /* @__PURE__ */ new Map()
|
|
3273
|
+
};
|
|
3274
|
+
Reflect.set(globalThis, storeKey, created);
|
|
3275
|
+
return created;
|
|
3276
|
+
}
|
|
3277
|
+
function isStore(value) {
|
|
3278
|
+
return typeof value === "object" && value !== null && "texts" in value && "trees" in value && "derived" in value;
|
|
3279
|
+
}
|
|
3280
|
+
function errorCode$1(error) {
|
|
3281
|
+
return typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
3282
|
+
}
|
|
3283
|
+
function statOrMissing(path) {
|
|
3284
|
+
try {
|
|
3285
|
+
return statSync(path, { bigint: true });
|
|
3286
|
+
} catch (error) {
|
|
3287
|
+
if (errorCode$1(error) === "ENOENT" || errorCode$1(error) === "ENOTDIR") return;
|
|
3288
|
+
throw error;
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
function signature(stats) {
|
|
3292
|
+
return `${stats.ino}:${stats.size}:${stats.mtimeNs}:${stats.ctimeNs}`;
|
|
3293
|
+
}
|
|
3294
|
+
function isSettled(stats) {
|
|
3295
|
+
const changed = stats.mtimeNs > stats.ctimeNs ? stats.mtimeNs : stats.ctimeNs;
|
|
3296
|
+
return BigInt(Date.now()) * 1000000n - changed > racyWindowNs;
|
|
3297
|
+
}
|
|
3298
|
+
function readDirEntries$1(root) {
|
|
3299
|
+
try {
|
|
3300
|
+
return readdirSync(root, { withFileTypes: true });
|
|
3301
|
+
} catch (error) {
|
|
3302
|
+
if (errorCode$1(error) === "ENOENT") return [];
|
|
3303
|
+
throw error;
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
function walkTree(root, directories, files, nested = false) {
|
|
3307
|
+
const before = statOrMissing(root);
|
|
3308
|
+
let trusted = before !== void 0 && isSettled(before);
|
|
3309
|
+
if (before) directories.set(root, signature(before));
|
|
3310
|
+
if (nested && existsSync(resolve(root, ".git"))) return trusted;
|
|
3311
|
+
for (const entry of readDirEntries$1(root)) {
|
|
3312
|
+
const path = resolve(root, entry.name);
|
|
3313
|
+
if (entry.isDirectory() && !entry.isSymbolicLink()) {
|
|
3314
|
+
if (entry.name.startsWith(".") || ignoredDirs.has(entry.name)) continue;
|
|
3315
|
+
if (!walkTree(path, directories, files, true)) trusted = false;
|
|
3316
|
+
continue;
|
|
3317
|
+
}
|
|
3318
|
+
if (entry.isFile()) files.push({
|
|
3319
|
+
hidden: entry.name.startsWith("."),
|
|
3320
|
+
name: entry.name,
|
|
3321
|
+
path
|
|
3322
|
+
});
|
|
3323
|
+
}
|
|
3324
|
+
return trusted;
|
|
3325
|
+
}
|
|
3326
|
+
function isCurrent(tree) {
|
|
3327
|
+
for (const [directory, stored] of tree.directories) {
|
|
3328
|
+
const stats = statOrMissing(directory);
|
|
3329
|
+
if (!stats || signature(stats) !== stored) return false;
|
|
3330
|
+
}
|
|
3331
|
+
return true;
|
|
3332
|
+
}
|
|
3333
|
+
function sourceTree(root) {
|
|
3334
|
+
const trees = store().trees;
|
|
3335
|
+
const cached = trees.get(root);
|
|
3336
|
+
if (cached && isCurrent(cached)) return cached;
|
|
3337
|
+
const directories = /* @__PURE__ */ new Map();
|
|
3338
|
+
const files = [];
|
|
3339
|
+
const trusted = walkTree(root, directories, files);
|
|
3340
|
+
files.sort((left, right) => left.path < right.path ? -1 : left.path > right.path ? 1 : 0);
|
|
3341
|
+
const tree = {
|
|
3342
|
+
directories,
|
|
3343
|
+
files
|
|
3344
|
+
};
|
|
3345
|
+
if (trusted) trees.set(root, tree);
|
|
3346
|
+
else trees.delete(root);
|
|
3347
|
+
return tree;
|
|
3348
|
+
}
|
|
3349
|
+
/**
|
|
3350
|
+
* The files below `root` whose name matches `predicate`, sorted by path. The walk skips hidden folders, Git
|
|
3351
|
+
* repositories, and build output folders such as `node_modules`, `dist`, and `.vitehub`. Hidden files need
|
|
3352
|
+
* `includeHidden`. Symbolic links are skipped.
|
|
3353
|
+
*/
|
|
3354
|
+
function listSourceTreeFiles(root, predicate, options = {}) {
|
|
3355
|
+
const files = [];
|
|
3356
|
+
for (const file of sourceTree(resolve(root)).files) {
|
|
3357
|
+
if (file.hidden && !options.includeHidden) continue;
|
|
3358
|
+
if (predicate(file.name)) files.push(file.path);
|
|
3359
|
+
}
|
|
3360
|
+
return files;
|
|
3361
|
+
}
|
|
3362
|
+
/** The UTF-8 text of a source file. A file that did not change since the last read is not read again. */
|
|
3363
|
+
function readSourceText(file) {
|
|
3364
|
+
const path = resolve(file);
|
|
3365
|
+
const texts = store().texts;
|
|
3366
|
+
const stats = statOrMissing(path);
|
|
3367
|
+
if (!stats) return readFileSync(path, "utf8");
|
|
3368
|
+
const current = signature(stats);
|
|
3369
|
+
const cached = texts.get(path);
|
|
3370
|
+
if (cached?.trusted && cached.signature === current) return cached.text;
|
|
3371
|
+
const read = readFileSync(path, "utf8");
|
|
3372
|
+
const text = cached?.text === read ? cached.text : read;
|
|
3373
|
+
texts.set(path, {
|
|
3374
|
+
signature: current,
|
|
3375
|
+
text,
|
|
3376
|
+
trusted: isSettled(stats)
|
|
3377
|
+
});
|
|
3378
|
+
return text;
|
|
3379
|
+
}
|
|
3380
|
+
/**
|
|
3381
|
+
* A value that `compute` derives from the text of a source file, such as its syntax tree. The value is computed again
|
|
3382
|
+
* only when the text changes. `kind` separates the values of different callers for one file. The last two texts of a
|
|
3383
|
+
* file are kept, because some callers read both the file and its transformed code.
|
|
3384
|
+
*/
|
|
3385
|
+
function deriveFromSource(kind, file, source, compute) {
|
|
3386
|
+
const derived = store().derived;
|
|
3387
|
+
const key = `${kind}\0${file}`;
|
|
3388
|
+
const entries = derived.get(key) ?? [];
|
|
3389
|
+
const cached = entries.find((entry) => entry.source === source);
|
|
3390
|
+
if (cached) return cached.value;
|
|
3391
|
+
const value = compute();
|
|
3392
|
+
derived.set(key, [{
|
|
3393
|
+
source,
|
|
3394
|
+
value
|
|
3395
|
+
}, ...entries.slice(0, 1)]);
|
|
3396
|
+
return value;
|
|
3397
|
+
}
|
|
3267
3398
|
// ../internal/src/build/scan-module.ts
|
|
3268
3399
|
/**
|
|
3269
3400
|
* Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
|
|
@@ -3293,8 +3424,15 @@ function scanModule(source, file = "module.ts") {
|
|
|
3293
3424
|
source
|
|
3294
3425
|
};
|
|
3295
3426
|
}
|
|
3427
|
+
/** `scanModule` with a result that is shared while `source` stays the same for `file`. */
|
|
3428
|
+
function scanModuleText(source, file) {
|
|
3429
|
+
return deriveFromSource("scan-module", file, source, () => scanModule(source, file));
|
|
3430
|
+
}
|
|
3296
3431
|
/** Lists the names that a module exports. A default export reads as `default`. Type-only exports are left out. */
|
|
3297
3432
|
function exportNames(source, file = "module.ts") {
|
|
3433
|
+
return [...deriveFromSource("export-names", file, source, () => readExportNames(source, file))];
|
|
3434
|
+
}
|
|
3435
|
+
function readExportNames(source, file) {
|
|
3298
3436
|
const { module } = parseSync(file, source, {
|
|
3299
3437
|
lang: moduleLanguage(file),
|
|
3300
3438
|
sourceType: "module"
|
|
@@ -3314,6 +3452,15 @@ function unwrapExpression(node) {
|
|
|
3314
3452
|
function argumentExpression(argument) {
|
|
3315
3453
|
return argument === void 0 || argument.type === "SpreadElement" ? void 0 : unwrapExpression(argument);
|
|
3316
3454
|
}
|
|
3455
|
+
/** Calls whose callee is a plain identifier in `names`, such as `defineCollection(...)`, in source order. */
|
|
3456
|
+
function findCalls(module, names) {
|
|
3457
|
+
const wanted = new Set(names);
|
|
3458
|
+
const calls = [];
|
|
3459
|
+
walk(module.program, (node) => {
|
|
3460
|
+
if (node.type === "CallExpression" && node.callee.type === "Identifier" && wanted.has(node.callee.name)) calls.push(node);
|
|
3461
|
+
});
|
|
3462
|
+
return calls.sort((left, right) => left.start - right.start);
|
|
3463
|
+
}
|
|
3317
3464
|
/** The expression of `export default <expression>`, without assertions. Declarations return undefined. */
|
|
3318
3465
|
function defaultExportExpression(module) {
|
|
3319
3466
|
for (const statement of module.program.body) {
|
|
@@ -3348,16 +3495,11 @@ function objectProperties(object) {
|
|
|
3348
3495
|
function findProperty(object, name) {
|
|
3349
3496
|
return objectProperties(object).findLast((property) => property.key === name);
|
|
3350
3497
|
}
|
|
3351
|
-
/** The value of a template literal without substitutions. */
|
|
3352
3498
|
function staticTemplate(node) {
|
|
3353
3499
|
if (node.expressions.length) return dynamic;
|
|
3354
3500
|
return node.quasis[0]?.value.cooked ?? dynamic;
|
|
3355
3501
|
}
|
|
3356
3502
|
const escapePattern = /\\(u\{[^}]*\}?|u[\s\S]{0,4}|x[\s\S]{0,2}|0\d|[\s\S])/g;
|
|
3357
|
-
/**
|
|
3358
|
-
* True when a string literal has an escape that strict mode code rejects. The parser recovers from some bad escapes
|
|
3359
|
-
* and accepts legacy octal escapes, so the scanner checks them again.
|
|
3360
|
-
*/
|
|
3361
3503
|
function hasInvalidEscape(raw) {
|
|
3362
3504
|
for (const [, escape = ""] of raw.matchAll(escapePattern)) if (escape.startsWith("u{")) {
|
|
3363
3505
|
const code = escape.slice(2, -1);
|
|
@@ -3418,7 +3560,6 @@ function staticValue(node) {
|
|
|
3418
3560
|
function isLineTerminator(char) {
|
|
3419
3561
|
return char === "\n" || char === "\r" || char === "\u2028" || char === "\u2029";
|
|
3420
3562
|
}
|
|
3421
|
-
/** Comments, JSX text, and string, template, and regular expression literals, sorted by position. Templates are not split. */
|
|
3422
3563
|
function literalSpans(module) {
|
|
3423
3564
|
const spans = module.comments.map((comment) => ({
|
|
3424
3565
|
end: comment.end,
|
|
@@ -3508,7 +3649,6 @@ async function rebasePublishedProviderSourceLinks(stagedSourcesDir, retainedSour
|
|
|
3508
3649
|
};
|
|
3509
3650
|
await visit(stagedSourcesDir);
|
|
3510
3651
|
}
|
|
3511
|
-
/** Lists the existing published source paths that `contents` names, in every form that the rewrite reads. */
|
|
3512
3652
|
function referencedProviderSourcePaths(contents, publishedSourcesDir) {
|
|
3513
3653
|
const prefixes = [{
|
|
3514
3654
|
decode: (path) => path,
|
|
@@ -3534,11 +3674,9 @@ function referencedProviderSourcePaths(contents, publishedSourcesDir) {
|
|
|
3534
3674
|
}
|
|
3535
3675
|
return [...references].filter((reference) => ![...references].some((parent) => parent !== reference && pathContains$1(parent, reference)));
|
|
3536
3676
|
}
|
|
3537
|
-
|
|
3538
|
-
const localSecretFile = /^(?:\.env|\.dev\.vars)(?:\..*)?$|^\.(?:netrc|npmrc|wrangler)$/;
|
|
3539
|
-
/** A retained snapshot and a deployment never receive local secret files, even inside a directory that the code names. */
|
|
3677
|
+
const localSecretFile$1 = /^(?:\.env|\.dev\.vars)(?:\..*)?$|^\.(?:netrc|npmrc|wrangler)$/;
|
|
3540
3678
|
function isLocalSecretFile(path) {
|
|
3541
|
-
return localSecretFile.test(basename(path));
|
|
3679
|
+
return localSecretFile$1.test(basename(path));
|
|
3542
3680
|
}
|
|
3543
3681
|
/**
|
|
3544
3682
|
* Copies the durable generated sources that deployment files name into deployment artifacts and rewrites their
|
|
@@ -3644,10 +3782,6 @@ function pathContains$1(parent, child) {
|
|
|
3644
3782
|
const nested = relative$1(parent, child);
|
|
3645
3783
|
return !nested || !nested.startsWith(`..${sep}`) && nested !== ".." && !isAbsolute(nested);
|
|
3646
3784
|
}
|
|
3647
|
-
/**
|
|
3648
|
-
* Creates a check that tells whether a path belongs to a dependency: a named package installed under `node_modules`,
|
|
3649
|
-
* or a named package outside the configured roots, such as a linked workspace package.
|
|
3650
|
-
*/
|
|
3651
3785
|
function createDependencySourceCheck(roots) {
|
|
3652
3786
|
const namedPackages = /* @__PURE__ */ new Map();
|
|
3653
3787
|
const isNamedPackage = (directory) => {
|
|
@@ -3795,7 +3929,6 @@ function resolveComputedModuleSource(file, specifier, resolveFrom = file) {
|
|
|
3795
3929
|
return;
|
|
3796
3930
|
}
|
|
3797
3931
|
}
|
|
3798
|
-
/** The index of the delimiter that closes the one at `open`. `masked` has no literals or comments. */
|
|
3799
3932
|
function matchingDelimiter(masked, open) {
|
|
3800
3933
|
let depth = 0;
|
|
3801
3934
|
for (let index = open; index < masked.length; index++) {
|
|
@@ -3804,7 +3937,6 @@ function matchingDelimiter(masked, open) {
|
|
|
3804
3937
|
else if ((char === ")" || char === "]" || char === "}") && --depth === 0) return index;
|
|
3805
3938
|
}
|
|
3806
3939
|
}
|
|
3807
|
-
/** Splits `source.slice(start, end)` at top-level commas. */
|
|
3808
3940
|
function splitTopLevel(source, masked, start, end) {
|
|
3809
3941
|
const parts = [];
|
|
3810
3942
|
let depth = 0;
|
|
@@ -4208,12 +4340,6 @@ function packageMetadataSourcesForPath(root, path) {
|
|
|
4208
4340
|
}
|
|
4209
4341
|
return sources;
|
|
4210
4342
|
}
|
|
4211
|
-
/**
|
|
4212
|
-
* Generated Provider Output can import a package by the physical pnpm store path
|
|
4213
|
-
* that Vite resolved during the source build. Retained source trees do not copy
|
|
4214
|
-
* `node_modules/.pnpm`, so keep only the store package directories that the
|
|
4215
|
-
* traced source graph actually references.
|
|
4216
|
-
*/
|
|
4217
4343
|
function pnpmStorePackageRoot(root, source) {
|
|
4218
4344
|
const segments = relative$1(root, source).split(sep);
|
|
4219
4345
|
let nodeModulesIndex = -1;
|
|
@@ -5307,6 +5433,24 @@ function isMissingProjectMarker(error) {
|
|
|
5307
5433
|
const code = error.code;
|
|
5308
5434
|
return code === "ENOENT" || code === "ENOTDIR";
|
|
5309
5435
|
}
|
|
5436
|
+
/** The owner of the generated code that a Vite or Nuxt config writes, from the CLI discovery and Node test markers. */
|
|
5437
|
+
function viteHubGeneratedOwner(config) {
|
|
5438
|
+
if (Reflect.get(config, "vitehubNodeTest") === true) return "node-test";
|
|
5439
|
+
return Reflect.get(config, "vitehubCliDiscovery") === true ? "cli" : "app";
|
|
5440
|
+
}
|
|
5441
|
+
/**
|
|
5442
|
+
* The generated-code folder of an owner, relative to the project root: `.vitehub` for the app, `.vitehub/cli` and
|
|
5443
|
+
* `.vitehub/node-test` for the others. State that the processes share, such as the Email outbox or the Env secret,
|
|
5444
|
+
* stays in `.vitehub`, and so do the declaration files that TypeScript reads, because their contents follow only the
|
|
5445
|
+
* Definitions.
|
|
5446
|
+
*/
|
|
5447
|
+
function viteHubGeneratedCodeDir(owner = "app") {
|
|
5448
|
+
return owner === "app" ? ".vitehub" : `.vitehub/${owner}`;
|
|
5449
|
+
}
|
|
5450
|
+
/** The absolute generated-code folder of an owner. See {@link viteHubGeneratedCodeDir}. */
|
|
5451
|
+
function viteHubGeneratedCodeRoot(projectRoot, owner = "app") {
|
|
5452
|
+
return resolve$1(projectRoot, viteHubGeneratedCodeDir(owner));
|
|
5453
|
+
}
|
|
5310
5454
|
// ../internal/src/build/deployment-output.ts
|
|
5311
5455
|
const providerDeploymentOutputRegistry = globalThis;
|
|
5312
5456
|
const providerDeploymentOutputWrites = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputWrites ??= /* @__PURE__ */ new Map();
|
|
@@ -6460,19 +6604,193 @@ function workflowServerEnv(workflow) {
|
|
|
6460
6604
|
};
|
|
6461
6605
|
return Object.fromEntries(Object.entries(fields).filter((entry) => entry[1] !== void 0));
|
|
6462
6606
|
}
|
|
6607
|
+
// ../internal/src/build/colocated-agent-files.ts
|
|
6608
|
+
function flatAgentProjectSourceRoot(handler, serverDir, projectRoot) {
|
|
6609
|
+
if (!serverDir || !projectRoot) return;
|
|
6610
|
+
const path = relative$1(resolve$1(serverDir, "agents"), handler);
|
|
6611
|
+
if (!isAbsolute(path) && path !== ".." && !path.startsWith(`..${sep}`)) return resolve$1(projectRoot);
|
|
6612
|
+
}
|
|
6613
|
+
function resolveColocatedAgentWorkspaceRoot(handler) {
|
|
6614
|
+
const directory = join(dirname$1(handler), "workspace");
|
|
6615
|
+
return existsSync(directory) && statSync(directory).isDirectory() ? directory : void 0;
|
|
6616
|
+
}
|
|
6617
|
+
function resolveDiscoveredAgentSourceRoot(definition) {
|
|
6618
|
+
const colocatedRoot = resolveColocatedAgentWorkspaceRoot(definition.handler);
|
|
6619
|
+
return {
|
|
6620
|
+
sourceRootDir: colocatedRoot ?? definition.sourceRootDir ?? dirname$1(definition.handler),
|
|
6621
|
+
projectSourceRoot: !colocatedRoot && definition.sourceRootDir !== void 0
|
|
6622
|
+
};
|
|
6623
|
+
}
|
|
6624
|
+
const localSourceModule = /^(?:@vite-hub|vite-hub)\/source$/;
|
|
6625
|
+
function stringList(value) {
|
|
6626
|
+
if (typeof value === "string") return [value];
|
|
6627
|
+
if (Array.isArray(value) && value.every((item) => typeof item === "string")) return value;
|
|
6628
|
+
}
|
|
6629
|
+
function literalLocalSource(input, kind) {
|
|
6630
|
+
if (isRecord(input) && !kind && "source" in input) return literalLocalSource(input.source);
|
|
6631
|
+
if (isRecord(input) && ("repo" in input || "url" in input || "server" in input || "content" in input)) return;
|
|
6632
|
+
if (typeof input === "string" && kind === "glob") {
|
|
6633
|
+
const parts = input.replaceAll("\\", "/").replace(/^\.\//, "").split("/").filter(Boolean);
|
|
6634
|
+
const wild = parts.findIndex((part) => /[*?[\]{}()!]/.test(part));
|
|
6635
|
+
return wild === -1 ? {
|
|
6636
|
+
include: ["**/*"],
|
|
6637
|
+
path: parts.join("/") || "."
|
|
6638
|
+
} : {
|
|
6639
|
+
include: [parts.slice(wild).join("/")],
|
|
6640
|
+
path: parts.slice(0, wild).join("/") || "."
|
|
6641
|
+
};
|
|
6642
|
+
}
|
|
6643
|
+
if (typeof input === "string") return { path: input };
|
|
6644
|
+
if (!isRecord(input)) return;
|
|
6645
|
+
const include = stringList(input.include);
|
|
6646
|
+
if (include && kind !== "file") return {
|
|
6647
|
+
dot: input.dot === true,
|
|
6648
|
+
ignore: stringList(input.ignore),
|
|
6649
|
+
include,
|
|
6650
|
+
path: typeof input.cwd === "string" ? input.cwd : "."
|
|
6651
|
+
};
|
|
6652
|
+
if (typeof input.path === "string" && kind !== "glob") return { path: input.path };
|
|
6653
|
+
}
|
|
6654
|
+
function literalLocalSources(handler) {
|
|
6655
|
+
const module = scanModule(readFileSync(handler, "utf8"), handler);
|
|
6656
|
+
const helpers = /* @__PURE__ */ new Map();
|
|
6657
|
+
for (const statement of module.program.body) {
|
|
6658
|
+
if (statement.type !== "ImportDeclaration" || statement.importKind === "type" || !localSourceModule.test(String(statement.source.value))) continue;
|
|
6659
|
+
for (const specifier of statement.specifiers) {
|
|
6660
|
+
if (specifier.type !== "ImportSpecifier" || specifier.importKind === "type") continue;
|
|
6661
|
+
const name = specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
|
|
6662
|
+
if (name === "file" || name === "glob") helpers.set(specifier.local.name, name);
|
|
6663
|
+
}
|
|
6664
|
+
}
|
|
6665
|
+
const sources = [];
|
|
6666
|
+
for (const call of findCalls(module, helpers.keys())) {
|
|
6667
|
+
const argument = argumentExpression(call.arguments[0]);
|
|
6668
|
+
const input = argument ? staticValue(argument) : void 0;
|
|
6669
|
+
const kind = call.callee.type === "Identifier" ? helpers.get(call.callee.name) : void 0;
|
|
6670
|
+
const source = input === dynamic ? void 0 : literalLocalSource(input, kind);
|
|
6671
|
+
if (source) sources.push(source);
|
|
6672
|
+
}
|
|
6673
|
+
walk(module.program, (node) => {
|
|
6674
|
+
if (node.type !== "ObjectExpression") return;
|
|
6675
|
+
const entries = findProperty(node, "sources")?.value;
|
|
6676
|
+
if (entries?.type !== "ObjectExpression") return;
|
|
6677
|
+
for (const entry of objectProperties(entries)) {
|
|
6678
|
+
const input = entry.value ? staticValue(entry.value) : dynamic;
|
|
6679
|
+
const source = input === dynamic ? void 0 : literalLocalSource(input);
|
|
6680
|
+
if (source) sources.push(source);
|
|
6681
|
+
}
|
|
6682
|
+
});
|
|
6683
|
+
return sources;
|
|
6684
|
+
}
|
|
6685
|
+
function contains(root, path) {
|
|
6686
|
+
const nested = relative$1(root, path);
|
|
6687
|
+
return !isAbsolute(nested) && nested !== ".." && !nested.startsWith(`..${sep}`);
|
|
6688
|
+
}
|
|
6689
|
+
/**
|
|
6690
|
+
* The folder that holds the snapshot of a flat Agent's local Sources in a retained sources folder. It sits beside the
|
|
6691
|
+
* numbered source trees and has no dot folder, so globs such as Netlify's `includedFiles` package it.
|
|
6692
|
+
*/
|
|
6693
|
+
function flatAgentSourceSnapshotDir(sourcesDir, handler, projectRoot) {
|
|
6694
|
+
const name = contains(projectRoot, handler) ? relative$1(projectRoot, handler) : basename(handler);
|
|
6695
|
+
return join(sourcesDir, "agent-sources", name.replace(/\.(?:c|m)?[jt]s$/i, ""));
|
|
6696
|
+
}
|
|
6697
|
+
const localSecretFile = /^(?:\.env|\.dev\.vars)(?:\..*)?$/i;
|
|
6698
|
+
function skippedSourceEntry(name) {
|
|
6699
|
+
const lower = name.toLowerCase();
|
|
6700
|
+
return lower === "node_modules" || lower === ".git" || localSecretFile.test(name);
|
|
6701
|
+
}
|
|
6702
|
+
function allowedSnapshotPath(root, path) {
|
|
6703
|
+
return contains(root, path) && !relative$1(root, path).split(sep).some(skippedSourceEntry);
|
|
6704
|
+
}
|
|
6705
|
+
function matchedGlobFiles(folder, source) {
|
|
6706
|
+
const include = source.include.map((pattern) => new Minimatch(pattern.replaceAll("\\", "/"), { dot: source.dot }));
|
|
6707
|
+
const ignore = (source.ignore ?? []).map((pattern) => new Minimatch(pattern.replaceAll("\\", "/"), { dot: true }));
|
|
6708
|
+
const files = [];
|
|
6709
|
+
const visit = (directory) => {
|
|
6710
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
6711
|
+
if (skippedSourceEntry(entry.name)) continue;
|
|
6712
|
+
const path = join(directory, entry.name);
|
|
6713
|
+
if (entry.isDirectory()) visit(path);
|
|
6714
|
+
if (!entry.isFile()) continue;
|
|
6715
|
+
const key = relative$1(folder, path).split(sep).join("/");
|
|
6716
|
+
if (include.some((pattern) => pattern.match(key)) && !ignore.some((pattern) => pattern.match(key))) files.push(path);
|
|
6717
|
+
}
|
|
6718
|
+
};
|
|
6719
|
+
visit(folder);
|
|
6720
|
+
return files;
|
|
6721
|
+
}
|
|
6722
|
+
/**
|
|
6723
|
+
* Copies the local Sources that a flat Agent names with literal `file()` and `glob()` options into `targetDir`, at
|
|
6724
|
+
* their paths under `projectRoot`. A deployment uses this folder as the Agent's Source root, so it ships these files
|
|
6725
|
+
* and not the whole project. A Source with computed options is not copied: it cannot read local files after deploy.
|
|
6726
|
+
*/
|
|
6727
|
+
async function snapshotFlatAgentSources(handler, projectRoot, targetDir) {
|
|
6728
|
+
await mkdir(targetDir, { recursive: true });
|
|
6729
|
+
const root = realpathSync(projectRoot);
|
|
6730
|
+
for (const source of literalLocalSources(handler)) {
|
|
6731
|
+
const from = resolve$1(root, source.path);
|
|
6732
|
+
if (!allowedSnapshotPath(root, from) || !existsSync(from)) continue;
|
|
6733
|
+
const realFrom = realpathSync(from);
|
|
6734
|
+
if (!allowedSnapshotPath(root, realFrom)) continue;
|
|
6735
|
+
const target = resolve$1(targetDir, relative$1(root, from));
|
|
6736
|
+
if (source.include) {
|
|
6737
|
+
if (!statSync(realFrom).isDirectory()) continue;
|
|
6738
|
+
await mkdir(target, { recursive: true });
|
|
6739
|
+
for (const path of matchedGlobFiles(realFrom, {
|
|
6740
|
+
...source,
|
|
6741
|
+
include: source.include
|
|
6742
|
+
})) {
|
|
6743
|
+
const destination = resolve$1(target, relative$1(realFrom, path));
|
|
6744
|
+
await mkdir(dirname$1(destination), { recursive: true });
|
|
6745
|
+
await copyFile(path, destination);
|
|
6746
|
+
}
|
|
6747
|
+
} else if (statSync(realFrom).isFile()) {
|
|
6748
|
+
await mkdir(dirname$1(target), { recursive: true });
|
|
6749
|
+
await copyFile(realFrom, target);
|
|
6750
|
+
}
|
|
6751
|
+
}
|
|
6752
|
+
}
|
|
6753
|
+
function isFolderAgentEntry(file) {
|
|
6754
|
+
if (!/^(?:agent|index)\.(?:c|m)?[jt]s$/i.test(basename(file))) return false;
|
|
6755
|
+
return !(basename(file).toLowerCase().startsWith("agent.") && basename(dirname$1(file)) === "agents" && basename(dirname$1(dirname$1(file))) === "server");
|
|
6756
|
+
}
|
|
6757
|
+
function colocatedAgentFilesRoot(handler, directoryName) {
|
|
6758
|
+
if (!isFolderAgentEntry(handler)) return;
|
|
6759
|
+
const root = join(dirname$1(handler), directoryName);
|
|
6760
|
+
return existsSync(root) ? root : void 0;
|
|
6761
|
+
}
|
|
6762
|
+
function resolveColocatedAgentFilesRoot(handler, directoryName) {
|
|
6763
|
+
const root = colocatedAgentFilesRoot(handler, directoryName);
|
|
6764
|
+
return root && statSync(root).isDirectory() ? root : void 0;
|
|
6765
|
+
}
|
|
6766
|
+
function readColocatedAgentFiles(handler, directoryName) {
|
|
6767
|
+
const root = colocatedAgentFilesRoot(handler, directoryName);
|
|
6768
|
+
if (!root) return;
|
|
6769
|
+
if (!statSync(root).isDirectory()) return;
|
|
6770
|
+
const files = {};
|
|
6771
|
+
const visit = (directory) => {
|
|
6772
|
+
for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
6773
|
+
const file = join(directory, entry.name);
|
|
6774
|
+
const target = relative$1(root, file).replace(/\\/g, "/");
|
|
6775
|
+
if (entry.isDirectory()) {
|
|
6776
|
+
visit(file);
|
|
6777
|
+
continue;
|
|
6778
|
+
}
|
|
6779
|
+
if (!entry.isFile()) continue;
|
|
6780
|
+
const content = readFileSync(file);
|
|
6781
|
+
files[target] = {
|
|
6782
|
+
content: content.toString("base64"),
|
|
6783
|
+
encoding: "base64"
|
|
6784
|
+
};
|
|
6785
|
+
}
|
|
6786
|
+
};
|
|
6787
|
+
visit(root);
|
|
6788
|
+
return Object.keys(files).length ? files : void 0;
|
|
6789
|
+
}
|
|
6463
6790
|
// ../internal/src/definition-catalog.ts
|
|
6464
6791
|
const sourceFilePattern$2 = /\.(?:c|m)?[jt]sx?$/i;
|
|
6465
6792
|
const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
|
|
6466
6793
|
const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
|
|
6467
|
-
const ignoredDirs = /* @__PURE__ */ new Set([
|
|
6468
|
-
"node_modules",
|
|
6469
|
-
"dist",
|
|
6470
|
-
".output",
|
|
6471
|
-
".nuxt",
|
|
6472
|
-
".vercel",
|
|
6473
|
-
".git",
|
|
6474
|
-
".vitehub"
|
|
6475
|
-
]);
|
|
6476
6794
|
function resolveDefinitionScanRoots(rootDir, scanDirs = []) {
|
|
6477
6795
|
return [...new Set([rootDir, ...scanDirs].filter(Boolean))];
|
|
6478
6796
|
}
|
|
@@ -6495,32 +6813,11 @@ function createSuffixDefinitionSource(source, roots, pattern, normalizeName, opt
|
|
|
6495
6813
|
source
|
|
6496
6814
|
};
|
|
6497
6815
|
}
|
|
6498
|
-
function readDirEntries$1(root) {
|
|
6499
|
-
try {
|
|
6500
|
-
return readdirSync(root, { withFileTypes: true });
|
|
6501
|
-
} catch (error) {
|
|
6502
|
-
if (error.code === "ENOENT") return [];
|
|
6503
|
-
throw error;
|
|
6504
|
-
}
|
|
6505
|
-
}
|
|
6506
6816
|
function isGitRepositoryDirectory(directory) {
|
|
6507
6817
|
return existsSync(resolve(directory, ".git"));
|
|
6508
6818
|
}
|
|
6509
6819
|
function listMatchingFiles(root, predicate, options = {}) {
|
|
6510
|
-
|
|
6511
|
-
for (const entry of readDirEntries$1(root)) {
|
|
6512
|
-
const absolute = resolve(root, entry.name);
|
|
6513
|
-
if (entry.isDirectory() && !entry.isSymbolicLink()) {
|
|
6514
|
-
if (isGitRepositoryDirectory(absolute)) continue;
|
|
6515
|
-
if (entry.name.startsWith(".")) continue;
|
|
6516
|
-
if (ignoredDirs.has(entry.name)) continue;
|
|
6517
|
-
files.push(...listMatchingFiles(absolute, predicate, options));
|
|
6518
|
-
continue;
|
|
6519
|
-
}
|
|
6520
|
-
if (entry.name.startsWith(".") && !options.includeHidden) continue;
|
|
6521
|
-
if (entry.isFile() && predicate(entry.name)) files.push(absolute);
|
|
6522
|
-
}
|
|
6523
|
-
return files.sort();
|
|
6820
|
+
return listSourceTreeFiles(root, predicate, options);
|
|
6524
6821
|
}
|
|
6525
6822
|
/** A module that a Definitions folder can hold: JavaScript or TypeScript, and not a declaration, test, or spec file. */
|
|
6526
6823
|
function isDefinitionSourceFile(name) {
|
|
@@ -6694,7 +6991,7 @@ function resolveAgentReExport(file, source, masked) {
|
|
|
6694
6991
|
]) if (existsSync(candidate) && statSync(candidate).isFile()) return candidate;
|
|
6695
6992
|
}
|
|
6696
6993
|
function maskSourceLiterals(source, file) {
|
|
6697
|
-
return maskLiterals(
|
|
6994
|
+
return deriveFromSource("masked-literals", file, source, () => maskLiterals(scanModuleText(source, file)));
|
|
6698
6995
|
}
|
|
6699
6996
|
function isFolderAgentImplementationTarget(file) {
|
|
6700
6997
|
const fileName = normalize(file).split("/").pop();
|
|
@@ -6704,7 +7001,7 @@ function isFolderAgentImplementationTarget(file) {
|
|
|
6704
7001
|
function extractAgentRuntime(file, seen = /* @__PURE__ */ new Set()) {
|
|
6705
7002
|
if (seen.has(file)) return void 0;
|
|
6706
7003
|
seen.add(file);
|
|
6707
|
-
const source =
|
|
7004
|
+
const source = readSourceText(file);
|
|
6708
7005
|
const masked = maskSourceLiterals(source, file);
|
|
6709
7006
|
const start = findAgentObjectStart(source, masked);
|
|
6710
7007
|
if (start === void 0) {
|
|
@@ -6751,7 +7048,7 @@ function extractAgentWorkflowName(file, fallbackName) {
|
|
|
6751
7048
|
if (/^false(?:\s+as\s+const)?$/.test(runtime.masked || "")) return void 0;
|
|
6752
7049
|
const shorthand = /^([A-Za-z_$][\w$]*)$/.exec(runtime.masked || "")?.[1];
|
|
6753
7050
|
if (shorthand) {
|
|
6754
|
-
const source =
|
|
7051
|
+
const source = readSourceText(file);
|
|
6755
7052
|
const masked = maskSourceLiterals(source, file);
|
|
6756
7053
|
const declaration = new RegExp(`\\b(?:const|let|var)\\s+${shorthand}\\s*(?::(?:=>|[^=])*?)?=\\s*`).exec(masked);
|
|
6757
7054
|
if (declaration) {
|
|
@@ -6823,11 +7120,11 @@ function discoverSuffixAgentWorkflowDefinitions(roots) {
|
|
|
6823
7120
|
return workflowDefinition ? [workflowDefinition] : [];
|
|
6824
7121
|
});
|
|
6825
7122
|
}
|
|
6826
|
-
function discoverFlatServerAgentWorkflowDefinitions(scanDirs) {
|
|
7123
|
+
function discoverFlatServerAgentWorkflowDefinitions(scanDirs, projectRoot) {
|
|
6827
7124
|
const folderAgentFiles = scanDirs.flatMap((scanDir) => findFolderAgentFiles(resolve(scanDir, "agents")));
|
|
6828
7125
|
const folderAgentDirs = new Set(folderAgentFiles.map((file) => normalize(resolve(file, ".."))));
|
|
6829
7126
|
const folderAgentTargets = new Set(folderAgentFiles.flatMap((file) => {
|
|
6830
|
-
const source =
|
|
7127
|
+
const source = readSourceText(file);
|
|
6831
7128
|
const target = resolveAgentReExport(file, source, maskSourceLiterals(source, file));
|
|
6832
7129
|
const relativeTarget = target && normalize(relative$1(resolve(file, ".."), target));
|
|
6833
7130
|
return target && relativeTarget && relativeTarget !== ".." && !relativeTarget.startsWith("../") && isFolderAgentImplementationTarget(target) ? [normalize(target)] : [];
|
|
@@ -6854,7 +7151,12 @@ function discoverFlatServerAgentWorkflowDefinitions(scanDirs) {
|
|
|
6854
7151
|
})
|
|
6855
7152
|
})]).flatMap((definition) => {
|
|
6856
7153
|
const workflowDefinition = toAgentWorkflowDefinition(definition.handler, definition.name);
|
|
6857
|
-
|
|
7154
|
+
if (!workflowDefinition) return [];
|
|
7155
|
+
const sourceRootDir = flatAgentProjectSourceRoot(definition.handler, scanDirs[0], projectRoot);
|
|
7156
|
+
return [{
|
|
7157
|
+
...workflowDefinition,
|
|
7158
|
+
...sourceRootDir ? { sourceRootDir } : {}
|
|
7159
|
+
}];
|
|
6858
7160
|
});
|
|
6859
7161
|
}
|
|
6860
7162
|
function discoverConfiguredServerAgentWorkflowDefinitions(scanDirs) {
|
|
@@ -6863,7 +7165,7 @@ function discoverConfiguredServerAgentWorkflowDefinitions(scanDirs) {
|
|
|
6863
7165
|
const agentsDir = resolve(scanDir, "agents");
|
|
6864
7166
|
const files = findFolderAgentFiles(agentsDir);
|
|
6865
7167
|
const targets = new Set(files.flatMap((file) => {
|
|
6866
|
-
const source =
|
|
7168
|
+
const source = readSourceText(file);
|
|
6867
7169
|
const target = resolveAgentReExport(file, source, maskSourceLiterals(source, file));
|
|
6868
7170
|
const relativeTarget = target && normalize(relative$1(resolve(file, ".."), target));
|
|
6869
7171
|
return target && relativeTarget && relativeTarget !== ".." && !relativeTarget.startsWith("../") ? [normalize(target)] : [];
|
|
@@ -6878,8 +7180,8 @@ function discoverConfiguredServerAgentWorkflowDefinitions(scanDirs) {
|
|
|
6878
7180
|
}
|
|
6879
7181
|
return sortDefinitions(definitions);
|
|
6880
7182
|
}
|
|
6881
|
-
function discoverAgentWorkflowDefinitions(roots, serverScanDirs) {
|
|
6882
|
-
return mergeDefinitions("agent workflow", discoverSuffixAgentWorkflowDefinitions(roots), discoverFlatServerAgentWorkflowDefinitions(serverScanDirs), discoverConfiguredServerAgentWorkflowDefinitions(serverScanDirs));
|
|
7183
|
+
function discoverAgentWorkflowDefinitions(roots, serverScanDirs, projectRoot) {
|
|
7184
|
+
return mergeDefinitions("agent workflow", discoverSuffixAgentWorkflowDefinitions(roots), discoverFlatServerAgentWorkflowDefinitions(serverScanDirs, projectRoot), discoverConfiguredServerAgentWorkflowDefinitions(serverScanDirs));
|
|
6883
7185
|
}
|
|
6884
7186
|
function discoverWorkflowFolders(scanDirs, source) {
|
|
6885
7187
|
const definitions = /* @__PURE__ */ new Map();
|
|
@@ -6927,7 +7229,7 @@ function discoverWorkflowDefinitions(options) {
|
|
|
6927
7229
|
handler: file,
|
|
6928
7230
|
name,
|
|
6929
7231
|
source: "vite-suffix"
|
|
6930
|
-
}) })]), discoverFlatServerWorkflowDefinitions(serverScanDirs, "server-workflows"), folderDefinitions, options.mode === "standalone" ? [] : discoverAgentWorkflowDefinitions(roots, serverScanDirs));
|
|
7232
|
+
}) })]), discoverFlatServerWorkflowDefinitions(serverScanDirs, "server-workflows"), folderDefinitions, options.mode === "standalone" ? [] : discoverAgentWorkflowDefinitions(roots, serverScanDirs, options.projectRoot ?? options.rootDir));
|
|
6931
7233
|
}
|
|
6932
7234
|
// src/internal/runtime-type.ts
|
|
6933
7235
|
function isRuntimeRecord(value) {
|
|
@@ -6937,44 +7239,6 @@ function isRuntimeRecord(value) {
|
|
|
6937
7239
|
function getAgentInvocationRecoveryWorkflowName(agentWorkflowName) {
|
|
6938
7240
|
return `vitehub-agent-invocation-recovery-${agentWorkflowName}`;
|
|
6939
7241
|
}
|
|
6940
|
-
// ../internal/src/build/colocated-agent-files.ts
|
|
6941
|
-
function isFolderAgentEntry(file) {
|
|
6942
|
-
if (!/^(?:agent|index)\.(?:c|m)?[jt]s$/i.test(basename(file))) return false;
|
|
6943
|
-
return !(basename(file).toLowerCase().startsWith("agent.") && basename(dirname$1(file)) === "agents" && basename(dirname$1(dirname$1(file))) === "server");
|
|
6944
|
-
}
|
|
6945
|
-
function colocatedAgentFilesRoot(handler, directoryName) {
|
|
6946
|
-
if (!isFolderAgentEntry(handler)) return;
|
|
6947
|
-
const root = join(dirname$1(handler), directoryName);
|
|
6948
|
-
return existsSync(root) ? root : void 0;
|
|
6949
|
-
}
|
|
6950
|
-
function resolveColocatedAgentFilesRoot(handler, directoryName) {
|
|
6951
|
-
const root = colocatedAgentFilesRoot(handler, directoryName);
|
|
6952
|
-
return root && statSync(root).isDirectory() ? root : void 0;
|
|
6953
|
-
}
|
|
6954
|
-
function readColocatedAgentFiles(handler, directoryName) {
|
|
6955
|
-
const root = colocatedAgentFilesRoot(handler, directoryName);
|
|
6956
|
-
if (!root) return;
|
|
6957
|
-
if (!statSync(root).isDirectory()) return;
|
|
6958
|
-
const files = {};
|
|
6959
|
-
const visit = (directory) => {
|
|
6960
|
-
for (const entry of readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
6961
|
-
const file = join(directory, entry.name);
|
|
6962
|
-
const target = relative$1(root, file).replace(/\\/g, "/");
|
|
6963
|
-
if (entry.isDirectory()) {
|
|
6964
|
-
visit(file);
|
|
6965
|
-
continue;
|
|
6966
|
-
}
|
|
6967
|
-
if (!entry.isFile()) continue;
|
|
6968
|
-
const content = readFileSync(file);
|
|
6969
|
-
files[target] = {
|
|
6970
|
-
content: content.toString("base64"),
|
|
6971
|
-
encoding: "base64"
|
|
6972
|
-
};
|
|
6973
|
-
}
|
|
6974
|
-
};
|
|
6975
|
-
visit(root);
|
|
6976
|
-
return Object.keys(files).length ? files : void 0;
|
|
6977
|
-
}
|
|
6978
7242
|
// ../internal/src/build/esbuild.ts
|
|
6979
7243
|
const viteRawNamespace = "vitehub-vite-raw";
|
|
6980
7244
|
const viteMarkdownTemplateNamespace = "vitehub-markdown-template";
|
|
@@ -8128,10 +8392,6 @@ async function createCloudflareWorkflowNitroConfig(options) {
|
|
|
8128
8392
|
function renderRegistryImport(registryFile, file) {
|
|
8129
8393
|
return `import(${JSON.stringify(pathToFileURL(file).href)})`;
|
|
8130
8394
|
}
|
|
8131
|
-
function resolveAgentWorkspaceSourceRoot(file) {
|
|
8132
|
-
const workspaceDirectory = join(dirname$1(file), "workspace");
|
|
8133
|
-
return existsSync(workspaceDirectory) && statSync(workspaceDirectory).isDirectory() ? workspaceDirectory : dirname$1(file);
|
|
8134
|
-
}
|
|
8135
8395
|
function readAgentInstructions(file, dependencies) {
|
|
8136
8396
|
const instructions = join(dirname$1(file), "instructions.md");
|
|
8137
8397
|
if (!existsSync(instructions) || !statSync(instructions).isFile()) return;
|
|
@@ -8152,13 +8412,14 @@ function readAgentSkills(file) {
|
|
|
8152
8412
|
}));
|
|
8153
8413
|
}
|
|
8154
8414
|
function renderAgentWorkflowRegistryEntry(registryFile, definition, retainedAgentInstructions) {
|
|
8415
|
+
const { sourceRootDir, projectSourceRoot } = resolveDiscoveredAgentSourceRoot(definition);
|
|
8155
8416
|
const instructions = retainedAgentInstructions?.has(definition.handler) ? retainedAgentInstructions.get(definition.handler) : readAgentInstructions(definition.handler);
|
|
8156
8417
|
return [
|
|
8157
8418
|
` [${JSON.stringify(definition.name)}]: Object.assign(async () => {`,
|
|
8158
8419
|
` const cached = registryEntryCache.get(${JSON.stringify(definition.name)})`,
|
|
8159
8420
|
" if (cached) return cached",
|
|
8160
8421
|
` const loaded = await ${renderRegistryImport(registryFile, definition.handler)}`,
|
|
8161
|
-
` const agent = workspaceAgentWithSourceRoot(agentWithColocatedSkills(agentWithColocatedInstructions("default" in loaded ? loaded.default : loaded, ${JSON.stringify(instructions)}), ${JSON.stringify(readAgentSkills(definition.handler))}), ${JSON.stringify(
|
|
8422
|
+
` const agent = workspaceAgentWithSourceRoot(agentWithColocatedSkills(agentWithColocatedInstructions("default" in loaded ? loaded.default : loaded, ${JSON.stringify(instructions)}), ${JSON.stringify(readAgentSkills(definition.handler))}), ${JSON.stringify(sourceRootDir)}, ${JSON.stringify(instructions)}, ${projectSourceRoot})`,
|
|
8162
8423
|
` const entry = { rootStep: false, handler: async (context) => await runAgentWorkflowDefinition(agent, { ...context, payload: { ...context.payload, agentIdentity: context.payload?.agentIdentity || { name: ${JSON.stringify(definition.agentIdentity || definition.name)} } } }, runAgentInline)${definition.source === "agent-workflow-recovery" ? ", internalAgentInvocationRecovery: true" : ""} }`,
|
|
8163
8424
|
` registryEntryCache.set(${JSON.stringify(definition.name)}, entry)`,
|
|
8164
8425
|
" return entry",
|
|
@@ -8440,13 +8701,23 @@ async function writeVercelNativeWorkflowFiles(generatedDir, definitions) {
|
|
|
8440
8701
|
}));
|
|
8441
8702
|
return vercelNativeFiles;
|
|
8442
8703
|
}
|
|
8443
|
-
async function writeProviderEntries(rootDir, workflow, importBases = {}, serverDirs, includeUserAppEntry = true, transformRegistry, definitionRootDir = rootDir, generatedDir = ensureGeneratedDir(rootDir, productName), retainedAgentInstructions, requireVercelNative = false) {
|
|
8704
|
+
async function writeProviderEntries(rootDir, workflow, importBases = {}, serverDirs, includeUserAppEntry = true, transformRegistry, definitionRootDir = rootDir, generatedDir = ensureGeneratedDir(rootDir, productName), retainedAgentInstructions, requireVercelNative = false, projectRoot = definitionRootDir, flatAgentSources) {
|
|
8444
8705
|
await mkdir(generatedDir, { recursive: true });
|
|
8445
8706
|
const registryFile = resolve$1(generatedDir, generatedRegistryFileName);
|
|
8446
|
-
const
|
|
8707
|
+
const discovered = discoverWorkflowDefinitions({
|
|
8708
|
+
projectRoot,
|
|
8447
8709
|
rootDir: definitionRootDir,
|
|
8448
8710
|
serverDirs
|
|
8449
8711
|
});
|
|
8712
|
+
const definitions = flatAgentSources ? await Promise.all(discovered.map(async (definition) => {
|
|
8713
|
+
if (definition.source !== "agent-workflow" || !definition.sourceRootDir || resolveColocatedAgentWorkspaceRoot(definition.handler)) return definition;
|
|
8714
|
+
const sourceRootDir = flatAgentSourceSnapshotDir(flatAgentSources.sourcesDir, definition.handler, projectRoot);
|
|
8715
|
+
await snapshotFlatAgentSources(definition.handler, flatAgentSources.projectRoot, sourceRootDir);
|
|
8716
|
+
return {
|
|
8717
|
+
...definition,
|
|
8718
|
+
sourceRootDir
|
|
8719
|
+
};
|
|
8720
|
+
})) : discovered;
|
|
8450
8721
|
const providerDefinitions = withAgentInvocationRecoveryDefinitions(definitions);
|
|
8451
8722
|
const userAppEntry = includeUserAppEntry ? resolveWorkflowUserAppEntry(definitionRootDir, includeUserAppEntry) : void 0;
|
|
8452
8723
|
const cloudflareWorkflowConfig = resolveWorkflowConfig(workflow, "cloudflare");
|
|
@@ -9001,8 +9272,10 @@ const workflowConsoleSection = {
|
|
|
9001
9272
|
}
|
|
9002
9273
|
};
|
|
9003
9274
|
// src/internal/dev-registry.ts
|
|
9004
|
-
const workflowDevGeneratedDir = ".vitehub/nitro/workflow";
|
|
9005
9275
|
const workflowTestSetupFile = "test-setup.mjs";
|
|
9276
|
+
function workflowDevGeneratedDirectory(projectRoot, owner) {
|
|
9277
|
+
return resolve$1(viteHubGeneratedCodeRoot(projectRoot, owner), "nitro", "workflow");
|
|
9278
|
+
}
|
|
9006
9279
|
const generatedFilesSeparatePerCommand = {
|
|
9007
9280
|
build: {
|
|
9008
9281
|
plugin: "build-plugin.mjs",
|
|
@@ -9106,7 +9379,7 @@ async function writeIfChanged(file, contents) {
|
|
|
9106
9379
|
* not change are not written again.
|
|
9107
9380
|
*/
|
|
9108
9381
|
async function writeWorkflowDevRegistryFiles(options) {
|
|
9109
|
-
const directory =
|
|
9382
|
+
const directory = workflowDevGeneratedDirectory(options.projectRoot, options.owner);
|
|
9110
9383
|
await mkdir(directory, { recursive: true });
|
|
9111
9384
|
const names = generatedFilesSeparatePerCommand[options.dev ? "dev" : "build"];
|
|
9112
9385
|
const registry = resolve$1(directory, names.registry);
|
|
@@ -9212,6 +9485,10 @@ function agentWorkflowRegistryTransform(plugins) {
|
|
|
9212
9485
|
const noExternalAddition = createNoExternalAddition(workflowPackageName);
|
|
9213
9486
|
const workflowBuildAssociation = Symbol("vitehubWorkflowBuildAssociation");
|
|
9214
9487
|
const workflowEnvironmentAssociation = Symbol("vitehubWorkflowEnvironmentAssociation");
|
|
9488
|
+
function workflowProjectRoot(config) {
|
|
9489
|
+
const configured = Reflect.get(config, VITEHUB_PROJECT_ROOT);
|
|
9490
|
+
return resolveViteHubProjectRoot(config.root, { projectRoot: typeof configured === "string" ? configured : void 0 });
|
|
9491
|
+
}
|
|
9215
9492
|
function resolveStringAliases(config) {
|
|
9216
9493
|
return encodeProviderOutputAliases(config.resolve.alias);
|
|
9217
9494
|
}
|
|
@@ -9305,7 +9582,7 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9305
9582
|
const build = scheduledBuildConfig(config);
|
|
9306
9583
|
const workflowOptions = build?.workflow ?? workflow;
|
|
9307
9584
|
if (resolveWorkflow(workflowOptions)?.driver !== "vercel") return;
|
|
9308
|
-
const rootDir =
|
|
9585
|
+
const rootDir = workflowProjectRoot(config);
|
|
9309
9586
|
const aliases = await providerImportAliases(config);
|
|
9310
9587
|
const workflowServerDirs = config["__vitehubServerDirs"] ?? build?.serverDirs;
|
|
9311
9588
|
const providerSources = discoverWorkflowProviderSources(config.root, workflowServerDirs);
|
|
@@ -9323,7 +9600,10 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9323
9600
|
workflow: internalOptions?.importBase,
|
|
9324
9601
|
workspaceRuntime: internalOptions?.workspaceRuntimeModule,
|
|
9325
9602
|
workspaceDependencies: internalOptions?.workspaceDependencyRuntimeImports
|
|
9326
|
-
}, retainedServerDirs, internalOptions?.includeUserAppEntry, config.plugins.find((plugin) => plugin.vitehub?.agent?.transformWorkflowRegistry)?.vitehub?.agent?.transformWorkflowRegistry, definitionRootDir, artifactDir ? resolve$1(artifactDir, "output") : void 0, retainedAgentInstructions, true)
|
|
9603
|
+
}, retainedServerDirs, internalOptions?.includeUserAppEntry, config.plugins.find((plugin) => plugin.vitehub?.agent?.transformWorkflowRegistry)?.vitehub?.agent?.transformWorkflowRegistry, definitionRootDir, artifactDir ? resolve$1(artifactDir, "output") : void 0, retainedAgentInstructions, true, retainedSources?.resolve(rootDir) ?? rootDir, artifactDir ? {
|
|
9604
|
+
projectRoot: rootDir,
|
|
9605
|
+
sourcesDir: resolve$1(artifactDir, ".vitehub", "workflow", "sources")
|
|
9606
|
+
} : void 0);
|
|
9327
9607
|
assertVercelWorkflowsRunNatively(artifacts.providerDefinitions);
|
|
9328
9608
|
const retainedAliases = retainedSources ? retainProviderOutputAliases(aliases, retainedSources) : aliases;
|
|
9329
9609
|
const native = hasVercelNativeWorkflowEntry(rootDir, artifacts.providerDefinitions, retainedAliases, artifacts.vercelNativeFiles);
|
|
@@ -9389,6 +9669,7 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9389
9669
|
console.warn(`[vitehub:workflow] ${report} The dev server runs without Workflows until you fix the Workflow configuration.`);
|
|
9390
9670
|
}
|
|
9391
9671
|
let configPlugins;
|
|
9672
|
+
let generatedOwner = "app";
|
|
9392
9673
|
async function writeDevRegistry(rootDir, workflow, vercel) {
|
|
9393
9674
|
return await writeWorkflowDevRegistryFiles({
|
|
9394
9675
|
agentModules: agentWorkflowModules(configPlugins),
|
|
@@ -9399,6 +9680,7 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9399
9680
|
importBase: internalOptions.importBase,
|
|
9400
9681
|
projectRoot: rootDir,
|
|
9401
9682
|
pluginPath: devStartupPlugin,
|
|
9683
|
+
owner: generatedOwner,
|
|
9402
9684
|
vercel,
|
|
9403
9685
|
workflow
|
|
9404
9686
|
});
|
|
@@ -9408,13 +9690,13 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9408
9690
|
}
|
|
9409
9691
|
let vercelModuleTransform;
|
|
9410
9692
|
async function prepareVercelNitroRegistry(config) {
|
|
9411
|
-
const rootDir =
|
|
9693
|
+
const rootDir = workflowProjectRoot(config);
|
|
9412
9694
|
const artifacts = await writeProviderEntries(rootDir, workflow, {
|
|
9413
9695
|
agent: agentWorkflowModules(config.plugins),
|
|
9414
9696
|
workflow: internalOptions.importBase,
|
|
9415
9697
|
workspaceRuntime: internalOptions.workspaceRuntimeModule,
|
|
9416
9698
|
workspaceDependencies: internalOptions.workspaceDependencyRuntimeImports
|
|
9417
|
-
}, serverDirs, internalOptions.includeUserAppEntry, config.plugins.find((plugin) => plugin.vitehub?.agent?.transformWorkflowRegistry)?.vitehub?.agent?.transformWorkflowRegistry, config.root, void 0, void 0, true);
|
|
9699
|
+
}, serverDirs, internalOptions.includeUserAppEntry, config.plugins.find((plugin) => plugin.vitehub?.agent?.transformWorkflowRegistry)?.vitehub?.agent?.transformWorkflowRegistry, config.root, void 0, void 0, true, rootDir);
|
|
9418
9700
|
assertVercelWorkflowsRunNatively(artifacts.providerDefinitions);
|
|
9419
9701
|
const native = hasVercelNativeWorkflowEntry(rootDir, artifacts.providerDefinitions, await providerImportAliases(config), artifacts.vercelNativeFiles);
|
|
9420
9702
|
vercelModuleTransform = native ? await createVercelWorkflowModuleTransform(rootDir) : void 0;
|
|
@@ -9437,6 +9719,7 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9437
9719
|
const buildConfig = config;
|
|
9438
9720
|
buildConfig.__vitehubWorkflowServerDirs = serverDirs;
|
|
9439
9721
|
startupBuild = env.command === "build";
|
|
9722
|
+
generatedOwner = viteHubGeneratedOwner(config);
|
|
9440
9723
|
configPlugins = config.plugins;
|
|
9441
9724
|
if (startupBuild && internalOptions.hosting) resolveWorkflow(workflow);
|
|
9442
9725
|
devWorkflow = resolveDevWorkflow();
|
|
@@ -9449,7 +9732,7 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9449
9732
|
const kit = createNitroServerKit(Reflect.get(config, "nitro"));
|
|
9450
9733
|
kit.addPlugin(plugin, "start");
|
|
9451
9734
|
Reflect.set(config, "nitro", kit.config);
|
|
9452
|
-
if (process.env.VITEST) return { test: { setupFiles: [resolve$1(devRootDir,
|
|
9735
|
+
if (process.env.VITEST) return { test: { setupFiles: [resolve$1(workflowDevGeneratedDirectory(devRootDir, generatedOwner), workflowTestSetupFile)] } };
|
|
9453
9736
|
}
|
|
9454
9737
|
},
|
|
9455
9738
|
configureServer(server) {
|
|
@@ -9460,9 +9743,9 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9460
9743
|
server.watcher.add([...watchedDirectories, rootDir]);
|
|
9461
9744
|
const refresh = async (path) => {
|
|
9462
9745
|
const file = path.replace(/\\/g, "/");
|
|
9463
|
-
if (file.
|
|
9746
|
+
if (file.startsWith(`${workflowDevGeneratedDirectory(rootDir, generatedOwner).replace(/\\/g, "/")}/`)) return;
|
|
9464
9747
|
const environment = server.environments.nitro ?? server.environments.ssr;
|
|
9465
|
-
const registryPath = resolve$1(rootDir,
|
|
9748
|
+
const registryPath = resolve$1(workflowDevGeneratedDirectory(rootDir, generatedOwner), "dev-registry.mjs").replace(/\\/g, "/");
|
|
9466
9749
|
const modules = [...environment?.moduleGraph.getModulesByFile(file) ?? []];
|
|
9467
9750
|
const visited = /* @__PURE__ */ new Set();
|
|
9468
9751
|
let registryDependency = false;
|
|
@@ -9480,7 +9763,7 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9480
9763
|
if (!(/\.(?:c|m)?[jt]s$/i.test(file) && /(?:\/workflows\/|\.workflow\.|\/agents\/|\.agent\.)/i.test(file)) && !registryDependency) return;
|
|
9481
9764
|
const { changed } = await writeDevRegistry(rootDir, workflowConfig);
|
|
9482
9765
|
await writeWorkflowTypes(rootDir, discoverWorkflowDevDefinitions(rootDir, serverDirs, registersAgentWorkflows(workflowConfig)), internalOptions.importBase);
|
|
9483
|
-
const filesToInvalidate = new Set([...changed, resolve$1(rootDir,
|
|
9766
|
+
const filesToInvalidate = new Set([...changed, resolve$1(workflowDevGeneratedDirectory(rootDir, generatedOwner), "dev-registry.mjs")].map((file) => file.replace(/\\/g, "/")));
|
|
9484
9767
|
let invalidated = false;
|
|
9485
9768
|
for (const changedFile of filesToInvalidate) for (const module of environment?.moduleGraph.getModulesByFile(changedFile) ?? []) {
|
|
9486
9769
|
environment.moduleGraph.invalidateModule(module);
|
|
@@ -9754,7 +10037,7 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9754
10037
|
const config = build?.config ?? resolved;
|
|
9755
10038
|
const buildProviderOutput = build?.providerOutput ?? providerOutput;
|
|
9756
10039
|
if (!config || shouldSkipViteProviderBuild(config.command)) return;
|
|
9757
|
-
const rootDir =
|
|
10040
|
+
const rootDir = workflowProjectRoot(config);
|
|
9758
10041
|
const plugins = config.plugins;
|
|
9759
10042
|
const generation = providerOutputGenerations.get(this);
|
|
9760
10043
|
const environment = generation ?? buildEnvironment(this);
|
|
@@ -9773,7 +10056,8 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9773
10056
|
const nativeOutputInNitro = Boolean(separateNitroConfig && outputs.vercel);
|
|
9774
10057
|
const nitroServer = nitroOwnsVercelServer(config, workflowOptions) || nativeOutputInNitro;
|
|
9775
10058
|
const cloudflareInNitro = Reflect.get(config, "nitro")?.rollupConfig?.plugins?.some((plugin) => plugin?.name === "vitehub-workflow-cloudflare-exports") ?? false;
|
|
9776
|
-
const
|
|
10059
|
+
const retainsSources = Boolean(outputs.cloudflare || outputs.vercel) && !nitroServer;
|
|
10060
|
+
const retainedSources = !retainsSources ? { resolve: (path) => path } : await retainProviderOutputSources({
|
|
9777
10061
|
aliases: importAliases,
|
|
9778
10062
|
artifactDir: resolve$1(artifactDir, "sources"),
|
|
9779
10063
|
paths: [
|
|
@@ -9797,7 +10081,10 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
9797
10081
|
workflow: internalOptions?.importBase,
|
|
9798
10082
|
workspaceRuntime: internalOptions?.workspaceRuntimeModule,
|
|
9799
10083
|
workspaceDependencies: internalOptions?.workspaceDependencyRuntimeImports
|
|
9800
|
-
}, retainedServerDirs, internalOptions?.includeUserAppEntry, transformRegistry, retainedDefinitionRoot, resolve$1(artifactDir, "output"), retainedAgentInstructions, Boolean(outputs.vercel && outputs.vercel.driver === "vercel"))
|
|
10084
|
+
}, retainedServerDirs, internalOptions?.includeUserAppEntry, transformRegistry, retainedDefinitionRoot, resolve$1(artifactDir, "output"), retainedAgentInstructions, Boolean(outputs.vercel && outputs.vercel.driver === "vercel"), retainedSources.resolve(rootDir), retainsSources ? {
|
|
10085
|
+
projectRoot: rootDir,
|
|
10086
|
+
sourcesDir: resolve$1(artifactDir, "sources")
|
|
10087
|
+
} : void 0);
|
|
9801
10088
|
stagedArtifactDirs.set(environment, artifactDir);
|
|
9802
10089
|
contributeProviderDeploymentOutput(buildProviderOutput, {
|
|
9803
10090
|
discard: async (failure) => {
|