@vite-hub/workspace 0.6.1 → 0.7.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 +5 -5
- package/dist/{asset-registry-0CdRAjIV.js → asset-registry-DJyE42kr.js} +1 -1
- package/dist/blob-database.d.ts +1 -1
- package/dist/blob-database.js +6 -6
- package/dist/checkout.js +2 -2
- package/dist/cloudflare.d.ts +1 -1
- package/dist/cloudflare.js +1 -1
- package/dist/{config-jo5QgE1w.js → config--ZzAvhMp.js} +14 -9
- package/dist/{config-DeA287c0.d.ts → config-DF6sqKXB.d.ts} +1 -1
- package/dist/durability.d.ts +1 -1
- package/dist/durability.js +2 -2
- package/dist/{error-diagnostics-B4me-ouV.js → error-diagnostics-CHgE8TQM.js} +16 -0
- package/dist/{error-diagnostics-kKXseq8d.js → error-diagnostics-CsiNo_oI.js} +3 -3
- package/dist/{file-BrNAXQgY.js → file-DQ5-TBTD.js} +1 -1
- package/dist/{file-metadata-Bpsvjw_X.js → file-metadata-Dqpldj0h.js} +7 -2
- package/dist/{files--z2dLC5z.js → files-D1UkSjzX.js} +2 -2
- package/dist/files.d.ts +5 -5
- package/dist/files.js +5 -5
- package/dist/{github-k--_LCrX.js → github-BECfOMaw.js} +4 -4
- package/dist/{glob-BreFjNAV.js → glob-BIg9O4yY.js} +2 -2
- package/dist/{glob-BEutagp1.js → glob-BIsxLusH.js} +1 -1
- package/dist/{host-C8yZizfk.js → host-BYBRcSnh.js} +7 -7
- package/dist/hosted-vercel-blob.d.ts +1 -1
- package/dist/hosted-vercel-blob.js +464 -1
- package/dist/hosted.d.ts +1 -1
- package/dist/hosted.js +917 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +13 -13
- package/dist/internal/path.js +108 -1
- package/dist/internal/workspace.d.ts +2 -3
- package/dist/internal/workspace.js +2 -2
- package/dist/{lifecycle-IReZfi0b.js → lifecycle-BK7WNfcP.js} +8 -8
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +2 -2
- package/dist/{mcp-resources-DeJnbOaw.js → mcp-resources-F4SJF4_P.js} +2 -2
- package/dist/{memory-BlSRrBH1.js → memory-BCZl_ZsJ.js} +26 -4
- package/dist/{metadata-target-CaGLY4ay.js → metadata-target-DPGF6L68.js} +59 -24
- package/dist/{operation-definition-CqZkx1Rm.d.ts → operations-BALFFdKj.d.ts} +1 -0
- package/dist/{operations-BIaK_uYG.js → operations-DJ_7W0gs.js} +8 -7
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +1327 -2
- package/dist/{path-Bb9OIc_F.js → path-DYHw5KNk.js} +11 -3
- package/dist/plugins-BYxsPDBH.d.ts +12 -0
- package/dist/{provider-CN14ewvx.js → provider-fcI7kJ5k.js} +256 -70
- package/dist/providers/github/store.d.ts +1 -1
- package/dist/providers/github/store.js +1994 -1
- package/dist/{registry-BbUg9vJB.js → registry-CFeUQsja.js} +3 -3
- package/dist/{registry-B0g19sdy.d.ts → registry-h1-cT-cE.d.ts} +1 -1
- package/dist/{registry-s2Ob9PeX.d.ts → registry-hnARUKNF.d.ts} +2 -2
- package/dist/replacement-CVZVsflC.js +76 -0
- package/dist/{request-scope-CXCI_wCb.js → request-scope-jH4H0Sbm.js} +3 -1
- package/dist/{rule-keys-BLEbi1h5.js → rule-keys-xMpiTLq1.js} +1 -1
- package/dist/{rules-BPDXypZV.js → rules-DYQCKYdt.js} +4 -4
- package/dist/runtime/assets.d.ts +1 -1
- package/dist/runtime/assets.js +4 -4
- package/dist/runtime/empty-assets-registry.d.ts +1 -1
- package/dist/runtime/empty-registry.d.ts +2 -2
- package/dist/runtime/registry.d.ts +1 -1
- package/dist/runtime/request.js +1 -1
- package/dist/runtime/state.d.ts +17 -6
- package/dist/runtime/state.js +7 -7
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +8 -8
- package/dist/runtime.js +38 -23
- package/dist/{search-C_nVorq7.js → search-CG6UNOtn.js} +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +301 -1
- package/dist/{shared-C20Wh1mp.js → shared-PFnkYidS.js} +59 -21
- package/dist/source-metadata.d.ts +2 -2
- package/dist/source-metadata.js +3 -3
- package/dist/{sync-BBfR4g5y.js → sync-CUkCuP_g.js} +5 -5
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-Bel5IDmF.d.ts → types-BnSUug2v.d.ts} +13 -1
- package/dist/{use-D0DyTMxM.js → use-BCMkT-kC.js} +15 -51
- package/dist/{use-CpphIBof.d.ts → use-CJ5rdIrW.d.ts} +1 -1
- package/dist/{use-tools-CHduR5k6.js → use-tools-CcXs2hFA.js} +4 -4
- package/dist/{use-tools-CAK10LTc.d.ts → use-tools-DFVqZwgc.d.ts} +2 -2
- package/dist/{utils-DXP9xfXo.js → utils-Bv1NBg8r.js} +5 -5
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +368 -62
- package/dist/{workspace-BOuxrZrP.d.ts → workspace-B6QreLJd.d.ts} +1 -1
- package/dist/{workspace-CLuPkyZR.js → workspace-D1m00MCM.js} +340 -104
- package/dist/workspace-inspection-scanner-BlJ8bCAB.js +140 -0
- package/package.json +12 -12
- package/dist/errors-CnFDXxeJ.d.ts +0 -4
- package/dist/hosted-8BTKAtMX.js +0 -883
- package/dist/hosted-vercel-blob-B6kygYqn.js +0 -408
- package/dist/operations-DS1C4uXd.js +0 -1308
- package/dist/path-CuYE8-X6.js +0 -57
- package/dist/plugins-CLc32jvL.d.ts +0 -8
- package/dist/server-aa1a4rkV.js +0 -301
- package/dist/state-BdDfBtOR.d.ts +0 -17
- package/dist/store-cx3OqNTi.js +0 -1971
package/dist/vite.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { n as __exportAll$1, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-DnNXxpGL.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as internalErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
+
import { C as resolve$1, S as relative$1, _ as requireViteHubDevServerUrl, a as createNativePackageLoading, b as dirname$1, c as generatedViteHubWatchIgnoredAddition, d as publishViteHubDevServer, f as resolveViteHubProjectRoot, g as readViteHubDevTargetOption, h as fetchViteHubDevEndpoint, l as isProductionBuild, m as discoverViteHubDevServer, o as createNoExternalAddition, p as shouldSkipViteProviderBuild, r as VITEHUB_PROJECT_ROOT, s as createViteHubEnvImportAliases, t as callOperationFromCli, u as isServerEnvironment, v as redactInspectionText, workspaceOperations, x as isAbsolute$1, y as relativeDefinitionFile } from "./operations.js";
|
|
3
|
+
import { t as internalErrorDiagnostics } from "./error-diagnostics-CsiNo_oI.js";
|
|
4
4
|
import { n as isRecordOrFunction, t as isRecord$1 } from "./object-CAK6UYR5.js";
|
|
5
|
-
import {
|
|
6
|
-
import { n as syncWorkspaceDefinition } from "./lifecycle-
|
|
7
|
-
import { a as normalizeWorkspaceSources, n as createSourceContext } from "./config
|
|
8
|
-
import {
|
|
9
|
-
import { t as createMemoryWorkspaceStore } from "./memory-
|
|
10
|
-
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-
|
|
5
|
+
import { ensureWorkspaceDevToken, readWorkspaceDevToken, refreshWorkspaceDevToken, runWorkspaceDevCommand, t as isViteHubSecretEqual, validateWorkspaceDevToken, workspaceDevHeader, workspaceDevRoute, workspaceDevTokenHeader, workspaceDevTokenServerId } from "./server.js";
|
|
6
|
+
import { n as syncWorkspaceDefinition } from "./lifecycle-BK7WNfcP.js";
|
|
7
|
+
import { a as normalizeWorkspaceSources, n as createSourceContext } from "./config--ZzAvhMp.js";
|
|
8
|
+
import { normalizeSafeWorkspacePath } from "./internal/path.js";
|
|
9
|
+
import { t as createMemoryWorkspaceStore } from "./memory-BCZl_ZsJ.js";
|
|
10
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CHgE8TQM.js";
|
|
11
11
|
import { assertNoSymlinks, checkoutFailure, conflictMarkerPatterns, folderOf, formatWorkspaceStatus, ignoredName, localCheckoutStatus, pullWorkspaces, pushWorkspaces, resolveWorkspaceConflicts, workspaceLockFile, workspaceStatus } from "./checkout.js";
|
|
12
|
-
import { n as isWorkspaceStore, r as normalizeWorkspaceStoreOptions } from "./provider-
|
|
13
|
-
import { c as workspaceRegistryLoadError, n as normalizeWorkspaceDefinition } from "./registry-
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
12
|
+
import { n as isWorkspaceStore, r as normalizeWorkspaceStoreOptions } from "./provider-fcI7kJ5k.js";
|
|
13
|
+
import { c as workspaceRegistryLoadError, n as normalizeWorkspaceDefinition } from "./registry-CFeUQsja.js";
|
|
14
|
+
import { installHostedWorkspaceRuntime } from "./hosted.js";
|
|
15
|
+
import { installHostedVercelBlobWorkspaceRuntime } from "./hosted-vercel-blob.js";
|
|
16
16
|
import { createRequire, isBuiltin } from "node:module";
|
|
17
17
|
import { formatRuntimeDiagnosticError } from "@vite-hub/runtime";
|
|
18
|
+
import { defineDiagnostics, formatDiagnostic } from "nostics";
|
|
18
19
|
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
19
20
|
import { createHash } from "node:crypto";
|
|
20
21
|
import { Minimatch } from "minimatch";
|
|
21
|
-
import { defineDiagnostics } from "nostics";
|
|
22
22
|
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
23
23
|
import { access, chmod, copyFile, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
24
24
|
import { tmpdir } from "node:os";
|
|
@@ -190,12 +190,32 @@ function mergeOwnedArrays(existing, value, arrays) {
|
|
|
190
190
|
const next = { ...value };
|
|
191
191
|
for (const [field, ownership] of Object.entries(arrays ?? {})) {
|
|
192
192
|
const incoming = Array.isArray(value[field]) ? value[field] : [];
|
|
193
|
-
const
|
|
193
|
+
const unowned = preserveUnownedKeyedArrayEntries(existing[field], ownership, incoming);
|
|
194
|
+
const merged = ownership.key !== void 0 && ownership.preserveOrder && Array.isArray(existing[field]) ? mergeOrderedEntries(existing[field], unowned, incoming, ownership.key) : [...unowned, ...incoming];
|
|
194
195
|
if (merged.length) next[field] = merged;
|
|
195
196
|
else delete next[field];
|
|
196
197
|
}
|
|
197
198
|
return next;
|
|
198
199
|
}
|
|
200
|
+
function mergeOrderedEntries(current, unowned, incoming, key) {
|
|
201
|
+
const preserved = new Set(unowned);
|
|
202
|
+
const replacements = new Map(incoming.flatMap((entry) => {
|
|
203
|
+
const identity = getKeyedArrayEntryValue(entry, key);
|
|
204
|
+
return identity === void 0 ? [] : [[identity, entry]];
|
|
205
|
+
}));
|
|
206
|
+
return [...current.flatMap((entry) => {
|
|
207
|
+
if (preserved.has(entry)) return [entry];
|
|
208
|
+
const identity = getKeyedArrayEntryValue(entry, key);
|
|
209
|
+
if (identity === void 0) return [];
|
|
210
|
+
const replacement = replacements.get(identity);
|
|
211
|
+
if (replacement === void 0) return [];
|
|
212
|
+
replacements.delete(identity);
|
|
213
|
+
return [replacement];
|
|
214
|
+
}), ...incoming.filter((entry) => {
|
|
215
|
+
const identity = getKeyedArrayEntryValue(entry, key);
|
|
216
|
+
return identity === void 0 || replacements.has(identity);
|
|
217
|
+
})];
|
|
218
|
+
}
|
|
199
219
|
async function persistProviderJsonRecord(file, value, removeIfEmpty) {
|
|
200
220
|
if (removeIfEmpty && !Object.keys(value).length) {
|
|
201
221
|
await rm(file, { force: true });
|
|
@@ -215,19 +235,31 @@ async function writeProviderOutputConfig(file, value, ownership = {}, options =
|
|
|
215
235
|
function mergeProviderOutputConfig(existing, value, ownership = {}) {
|
|
216
236
|
assertProviderJsonRecord(existing);
|
|
217
237
|
assertProviderJsonRecord(value);
|
|
218
|
-
|
|
238
|
+
const next = {
|
|
219
239
|
...deleteOwnedFields(existing, ownership),
|
|
220
240
|
...mergeOwnedArrays(existing, value, ownership.arrays)
|
|
221
241
|
};
|
|
242
|
+
for (const [field, childOwnership] of Object.entries(ownership.objects ?? {})) {
|
|
243
|
+
const current = existing[field];
|
|
244
|
+
const incoming = value[field];
|
|
245
|
+
const merged = mergeProviderOutputConfig(isProviderJsonRecord(current) ? current : {}, isProviderJsonRecord(incoming) ? incoming : {}, childOwnership);
|
|
246
|
+
if (Object.keys(merged).length) next[field] = merged;
|
|
247
|
+
else delete next[field];
|
|
248
|
+
}
|
|
249
|
+
return next;
|
|
222
250
|
}
|
|
223
251
|
function stringifyProviderOutputConfig(value) {
|
|
224
252
|
assertProviderJsonRecord(value);
|
|
225
253
|
return JSON.stringify(value, null, 2);
|
|
226
254
|
}
|
|
227
255
|
async function cleanProviderOutputConfig(file, ownership) {
|
|
228
|
-
if (!ownership.keys?.length && !Object.keys(ownership.arrays ?? {}).length) return;
|
|
256
|
+
if (!ownership.keys?.length && !Object.keys(ownership.arrays ?? {}).length && !Object.keys(ownership.objects ?? {}).length) return;
|
|
229
257
|
const existing = await readProviderJsonRecord(file);
|
|
230
258
|
if (!existing) return;
|
|
259
|
+
const next = cleanOwnedFields(existing, ownership);
|
|
260
|
+
if (next) await persistProviderJsonRecord(file, next, true);
|
|
261
|
+
}
|
|
262
|
+
function cleanOwnedFields(existing, ownership) {
|
|
231
263
|
const next = deleteOwnedFields(existing, ownership, true);
|
|
232
264
|
let changed = (ownership.keys ?? []).some((key) => key in existing);
|
|
233
265
|
for (const [field, arrayOwnership] of Object.entries(ownership.arrays ?? {})) {
|
|
@@ -239,8 +271,16 @@ async function cleanProviderOutputConfig(file, ownership) {
|
|
|
239
271
|
changed ||= retained.length > 0 || !Array.isArray(current) || preserved.length !== current.length || preserved.length === 0;
|
|
240
272
|
if (preserved.length) next[field] = preserved;
|
|
241
273
|
}
|
|
242
|
-
|
|
243
|
-
|
|
274
|
+
for (const [field, childOwnership] of Object.entries(ownership.objects ?? {})) {
|
|
275
|
+
const current = existing[field];
|
|
276
|
+
if (!isProviderJsonRecord(current)) continue;
|
|
277
|
+
const cleaned = cleanOwnedFields(current, childOwnership);
|
|
278
|
+
if (!cleaned) continue;
|
|
279
|
+
changed = true;
|
|
280
|
+
if (Object.keys(cleaned).length) next[field] = cleaned;
|
|
281
|
+
else delete next[field];
|
|
282
|
+
}
|
|
283
|
+
if (changed) return next;
|
|
244
284
|
}
|
|
245
285
|
// ../internal/src/build/user-entry.ts
|
|
246
286
|
function toSafeAppName(rootDir) {
|
|
@@ -1099,8 +1139,26 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
|
|
|
1099
1139
|
}
|
|
1100
1140
|
}
|
|
1101
1141
|
// ../internal/src/build/provider-output-sources.ts
|
|
1102
|
-
|
|
1103
|
-
|
|
1142
|
+
const keptFailedProviderOutputArtifactDirs = /* @__PURE__ */ new Set();
|
|
1143
|
+
function failureText(failure) {
|
|
1144
|
+
return failure instanceof Error ? `${failure.message}\n${failure.stack ?? ""}` : String(failure);
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Removes retained provider output after readers release it, tolerating transient filesystem contention. Pass the
|
|
1148
|
+
* build failure when a failed build discards its generation: with `VITEHUB_KEEP_FAILED_BUILD=1` the folder stays
|
|
1149
|
+
* for inspection.
|
|
1150
|
+
*/
|
|
1151
|
+
async function removeProviderOutputArtifactDir(path, failure) {
|
|
1152
|
+
if (failure !== void 0) {
|
|
1153
|
+
const shown = relative(process.cwd(), path) || path;
|
|
1154
|
+
if (/^(?:1|true)$/i.test(process.env.VITEHUB_KEEP_FAILED_BUILD ?? "")) {
|
|
1155
|
+
if (!existsSync(path)) return;
|
|
1156
|
+
if (!keptFailedProviderOutputArtifactDirs.has(path)) console.warn(`[vitehub] The build failed. ViteHub kept its provider sources in ${shown} so you can inspect them. Remove the folder when you are done.`);
|
|
1157
|
+
keptFailedProviderOutputArtifactDirs.add(path);
|
|
1158
|
+
return;
|
|
1159
|
+
}
|
|
1160
|
+
if (failureText(failure).includes(basename(path))) console.warn(`[vitehub] The build error names files in ${shown}, which ViteHub removes after a failed build. Set VITEHUB_KEEP_FAILED_BUILD=1 to keep them.`);
|
|
1161
|
+
}
|
|
1104
1162
|
await rm(path, {
|
|
1105
1163
|
force: true,
|
|
1106
1164
|
maxRetries: 5,
|
|
@@ -1512,17 +1570,17 @@ var ProviderOutputCatalog = class {
|
|
|
1512
1570
|
}
|
|
1513
1571
|
this.#restoreDeploymentContribution(entry);
|
|
1514
1572
|
}
|
|
1515
|
-
resetDeploymentContributions(generation) {
|
|
1573
|
+
resetDeploymentContributions(generation, failure) {
|
|
1516
1574
|
if (!generation) {
|
|
1517
1575
|
for (const reference of this.#deploymentGenerations) {
|
|
1518
1576
|
const current = reference.deref();
|
|
1519
1577
|
if (current) current.valid = false;
|
|
1520
1578
|
}
|
|
1521
1579
|
this.#deploymentGenerations.clear();
|
|
1522
|
-
for (const entries of this.#deploymentContributions.values()) for (const entry of entries) this.#queueDeploymentDiscard(entry);
|
|
1580
|
+
for (const entries of this.#deploymentContributions.values()) for (const entry of entries) this.#queueDeploymentDiscard(entry, failure);
|
|
1523
1581
|
for (const taken of this.#takenDeploymentContributions.values()) {
|
|
1524
|
-
if (!taken.entryDiscarded) this.#queueDeploymentDiscard(taken.entry);
|
|
1525
|
-
for (const fallback of taken.fallbacks) this.#queueDeploymentDiscard(fallback);
|
|
1582
|
+
if (!taken.entryDiscarded) this.#queueDeploymentDiscard(taken.entry, failure);
|
|
1583
|
+
for (const fallback of taken.fallbacks) this.#queueDeploymentDiscard(fallback, failure);
|
|
1526
1584
|
}
|
|
1527
1585
|
this.#deploymentContributions.clear();
|
|
1528
1586
|
this.#takenDeploymentContributions.clear();
|
|
@@ -1531,7 +1589,7 @@ var ProviderOutputCatalog = class {
|
|
|
1531
1589
|
generation.valid = false;
|
|
1532
1590
|
this.#deleteDeploymentGeneration(generation);
|
|
1533
1591
|
for (const [owner, entries] of this.#deploymentContributions) {
|
|
1534
|
-
for (const entry of entries) if (entry.generation === generation) this.#queueDeploymentDiscard(entry);
|
|
1592
|
+
for (const entry of entries) if (entry.generation === generation) this.#queueDeploymentDiscard(entry, failure);
|
|
1535
1593
|
const remaining = entries.filter((entry) => entry.generation !== generation);
|
|
1536
1594
|
if (remaining.length) this.#deploymentContributions.set(owner, remaining);
|
|
1537
1595
|
else this.#deploymentContributions.delete(owner);
|
|
@@ -1539,10 +1597,10 @@ var ProviderOutputCatalog = class {
|
|
|
1539
1597
|
for (const [contribution, taken] of this.#takenDeploymentContributions) {
|
|
1540
1598
|
const invalidatedFallbacks = taken.fallbacks.filter((entry) => entry.generation === generation);
|
|
1541
1599
|
taken.fallbacks = taken.fallbacks.filter((entry) => entry.generation !== generation);
|
|
1542
|
-
for (const fallback of invalidatedFallbacks) this.#queueDeploymentDiscard(fallback);
|
|
1600
|
+
for (const fallback of invalidatedFallbacks) this.#queueDeploymentDiscard(fallback, failure);
|
|
1543
1601
|
if (taken.entry.generation !== generation) continue;
|
|
1544
1602
|
this.#takenDeploymentContributions.delete(contribution);
|
|
1545
|
-
if (!taken.entryDiscarded) this.#queueDeploymentDiscard(taken.entry);
|
|
1603
|
+
if (!taken.entryDiscarded) this.#queueDeploymentDiscard(taken.entry, failure);
|
|
1546
1604
|
for (const fallback of taken.fallbacks) if (taken.committed) this.#queueDeploymentDiscard(fallback);
|
|
1547
1605
|
else this.#restoreDeploymentContribution(fallback);
|
|
1548
1606
|
}
|
|
@@ -1585,7 +1643,7 @@ var ProviderOutputCatalog = class {
|
|
|
1585
1643
|
const failure = (await Promise.allSettled(discarded)).find((result) => result.status === "rejected");
|
|
1586
1644
|
if (failure) throw failure.reason;
|
|
1587
1645
|
}
|
|
1588
|
-
async completeDeploymentContributions(contributions) {
|
|
1646
|
+
async completeDeploymentContributions(contributions, buildFailure) {
|
|
1589
1647
|
const discarded = this.#pendingDeploymentDiscards.splice(0);
|
|
1590
1648
|
const completedGenerations = /* @__PURE__ */ new Set();
|
|
1591
1649
|
for (const contribution of contributions) {
|
|
@@ -1595,7 +1653,7 @@ var ProviderOutputCatalog = class {
|
|
|
1595
1653
|
const entries = taken.entryDiscarded ? taken.fallbacks : [...taken.fallbacks, taken.entry];
|
|
1596
1654
|
for (const entry of entries) {
|
|
1597
1655
|
if (entry.generation) completedGenerations.add(entry.generation);
|
|
1598
|
-
if (entry.contribution.discard) discarded.push(entry.contribution.discard());
|
|
1656
|
+
if (entry.contribution.discard) discarded.push(entry.contribution.discard(entry === taken.entry ? buildFailure : void 0));
|
|
1599
1657
|
}
|
|
1600
1658
|
}
|
|
1601
1659
|
for (const generation of completedGenerations) this.#retireDeploymentGeneration(generation);
|
|
@@ -1639,9 +1697,9 @@ var ProviderOutputCatalog = class {
|
|
|
1639
1697
|
if (reference) this.#deploymentGenerations.delete(reference);
|
|
1640
1698
|
this.#deploymentGenerationRefs.delete(generation);
|
|
1641
1699
|
}
|
|
1642
|
-
#queueDeploymentDiscard(entry) {
|
|
1700
|
+
#queueDeploymentDiscard(entry, failure) {
|
|
1643
1701
|
if (!entry.contribution.discard) return;
|
|
1644
|
-
const discard = Promise.resolve().then(entry.contribution.discard);
|
|
1702
|
+
const discard = Promise.resolve().then(async () => await entry.contribution.discard?.(failure));
|
|
1645
1703
|
discard.catch(() => {});
|
|
1646
1704
|
this.#pendingDeploymentDiscards.push(discard);
|
|
1647
1705
|
}
|
|
@@ -2486,23 +2544,23 @@ async function resetProviderDeploymentOutputs(catalog, failure, generation) {
|
|
|
2486
2544
|
if (!catalog) return;
|
|
2487
2545
|
const completedReset = providerDeploymentOutputCompletedResets.get(catalog);
|
|
2488
2546
|
if (completedReset && failure !== void 0 && completedReset.failures.has(failure)) {
|
|
2489
|
-
if (generation) catalog.resetDeploymentContributions(generation);
|
|
2547
|
+
if (generation) catalog.resetDeploymentContributions(generation, failure);
|
|
2490
2548
|
await completedReset.promise;
|
|
2491
2549
|
return;
|
|
2492
2550
|
}
|
|
2493
2551
|
if (completedReset) providerDeploymentOutputCompletedResets.delete(catalog);
|
|
2494
|
-
if (generation) catalog.resetDeploymentContributions(generation);
|
|
2552
|
+
if (generation) catalog.resetDeploymentContributions(generation, failure);
|
|
2495
2553
|
const active = providerDeploymentOutputFinalizations.get(catalog);
|
|
2496
2554
|
if (active?.reset) {
|
|
2497
2555
|
if (failure !== void 0 && !active.reset.failures.has(failure)) {
|
|
2498
2556
|
active.reset.failures.add(failure);
|
|
2499
|
-
if (!generation) catalog.resetDeploymentContributions();
|
|
2557
|
+
if (!generation) catalog.resetDeploymentContributions(void 0, failure);
|
|
2500
2558
|
}
|
|
2501
2559
|
providerDeploymentOutputCompletedResets.set(catalog, active.reset);
|
|
2502
2560
|
await active.reset.promise;
|
|
2503
2561
|
return;
|
|
2504
2562
|
}
|
|
2505
|
-
if (!generation) catalog.resetDeploymentContributions();
|
|
2563
|
+
if (!generation) catalog.resetDeploymentContributions(void 0, failure);
|
|
2506
2564
|
if (active && (!generation || active.state.generations.has(generation))) {
|
|
2507
2565
|
active.state.rollback = true;
|
|
2508
2566
|
active.controller.abort(internalErrorDiagnostics.INTERNAL_B0039({ message: "Provider Output finalization reset" }));
|
|
@@ -2651,7 +2709,7 @@ async function finalizeProviderDeploymentOutputs(catalog, options = {}) {
|
|
|
2651
2709
|
await catalog.completeDeploymentContributions(contributions);
|
|
2652
2710
|
} catch (error) {
|
|
2653
2711
|
if (state.rollback) catalog.rollbackDeploymentContributions(contributions);
|
|
2654
|
-
else await catalog.completeDeploymentContributions(contributions);
|
|
2712
|
+
else await catalog.completeDeploymentContributions(contributions, error);
|
|
2655
2713
|
throw error;
|
|
2656
2714
|
} finally {
|
|
2657
2715
|
state.generations.clear();
|
|
@@ -3049,6 +3107,84 @@ function mergeNitroExternal(value, addition) {
|
|
|
3049
3107
|
if (typeof value === "function") return (source, importer, isResolved) => source === addition || Boolean(value(source, importer, isResolved));
|
|
3050
3108
|
return value;
|
|
3051
3109
|
}
|
|
3110
|
+
// ../internal/src/hints.ts
|
|
3111
|
+
/**
|
|
3112
|
+
* The file that lists the hints of the last build or dev server, relative to the project root. A hint is a warning
|
|
3113
|
+
* about something that works now and fails later, such as counts that stay in one server's memory. Agents and CI read
|
|
3114
|
+
* the file instead of the terminal.
|
|
3115
|
+
*/
|
|
3116
|
+
const viteHubHintsFile = ".vitehub/hints.json";
|
|
3117
|
+
const VITEHUB_NUXT_HINTS = "__vitehubNuxtHints";
|
|
3118
|
+
const runsKey = Symbol.for("vitehub.hints.runs");
|
|
3119
|
+
const shared = globalThis;
|
|
3120
|
+
const runs = shared[runsKey] ??= /* @__PURE__ */ new Map();
|
|
3121
|
+
const startedKey = Symbol.for("vitehub.hints.started");
|
|
3122
|
+
const startedShared = globalThis;
|
|
3123
|
+
const started = startedShared[startedKey] ??= /* @__PURE__ */ new WeakSet();
|
|
3124
|
+
/**
|
|
3125
|
+
* The report of the ViteHub project root, where the other generated files go. A Nuxt app with `srcDir: "app"` has its
|
|
3126
|
+
* Vite root in `app/`, one folder below.
|
|
3127
|
+
*/
|
|
3128
|
+
function hintsFile(config) {
|
|
3129
|
+
const projectRoot = Reflect.get(config, VITEHUB_PROJECT_ROOT);
|
|
3130
|
+
return resolve(typeof projectRoot === "string" ? projectRoot : resolveViteHubProjectRoot(config.root), viteHubHintsFile);
|
|
3131
|
+
}
|
|
3132
|
+
function startRun(config) {
|
|
3133
|
+
const file = hintsFile(config);
|
|
3134
|
+
const run = {
|
|
3135
|
+
file,
|
|
3136
|
+
report: {
|
|
3137
|
+
version: 1,
|
|
3138
|
+
command: config.command,
|
|
3139
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3140
|
+
hints: []
|
|
3141
|
+
},
|
|
3142
|
+
keys: /* @__PURE__ */ new Set()
|
|
3143
|
+
};
|
|
3144
|
+
runs.set(file, run);
|
|
3145
|
+
return run;
|
|
3146
|
+
}
|
|
3147
|
+
function write(run) {
|
|
3148
|
+
mkdirSync(dirname(run.file), { recursive: true });
|
|
3149
|
+
writeFileSync(run.file, `${JSON.stringify(run.report, null, 2)}\n`);
|
|
3150
|
+
}
|
|
3151
|
+
/**
|
|
3152
|
+
* 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
|
|
3153
|
+
* {@link viteHubHintsFile}. Build the diagnostic from the package's nostics catalog, so its code has a docs page.
|
|
3154
|
+
*/
|
|
3155
|
+
function reportViteHubHint(config, diagnostic) {
|
|
3156
|
+
if (skipHints(config)) return;
|
|
3157
|
+
const nuxt = config[VITEHUB_NUXT_HINTS];
|
|
3158
|
+
if (typeof nuxt === "function") return nuxt(diagnostic);
|
|
3159
|
+
const run = runs.get(hintsFile(config)) ?? startRun(config);
|
|
3160
|
+
const hint = {
|
|
3161
|
+
code: diagnostic.code,
|
|
3162
|
+
why: diagnostic.why,
|
|
3163
|
+
...diagnostic.fix ? { fix: diagnostic.fix } : {},
|
|
3164
|
+
...diagnostic.docs ? { docs: diagnostic.docs } : {},
|
|
3165
|
+
...diagnostic.sources?.length ? { sources: diagnostic.sources } : {}
|
|
3166
|
+
};
|
|
3167
|
+
const key = JSON.stringify([hint.code, hint.sources ?? []]);
|
|
3168
|
+
if (run.keys.has(key)) return;
|
|
3169
|
+
run.keys.add(key);
|
|
3170
|
+
run.report.hints.push(hint);
|
|
3171
|
+
write(run);
|
|
3172
|
+
(config.logger ?? console).warn(formatDiagnostic(diagnostic));
|
|
3173
|
+
}
|
|
3174
|
+
function skipHints(config) {
|
|
3175
|
+
return !config.command || Reflect.get(config, "__vitehubPrepare") === true || Reflect.get(config, "vitehubCliDiscovery") === true;
|
|
3176
|
+
}
|
|
3177
|
+
/**
|
|
3178
|
+
* Starts the hints of a build or dev server: writes an empty {@link viteHubHintsFile}, so a run without hints does not
|
|
3179
|
+
* leave the hints of an earlier run in place. Every plugin that reports hints calls it from `configResolved`, so a
|
|
3180
|
+
* package used without `vitehub()` starts its own run. Nuxt uses the app instance as owner so its Vite builds and
|
|
3181
|
+
* separate Nitro build share one report; replay, prepare and discovery never reset it.
|
|
3182
|
+
*/
|
|
3183
|
+
function startViteHubHints(config, owner = config) {
|
|
3184
|
+
if (skipHints(config) || config["__vitehubNuxtHints"] || started.has(owner)) return;
|
|
3185
|
+
started.add(owner);
|
|
3186
|
+
write(startRun(config));
|
|
3187
|
+
}
|
|
3052
3188
|
/** Maps a host name or a Nitro preset name, such as `cloudflare-module` or `node-server`, to its ViteHub host. */
|
|
3053
3189
|
function hostFromNitroPreset(value) {
|
|
3054
3190
|
const normalized = value?.trim().toLowerCase().replaceAll("_", "-");
|
|
@@ -18337,7 +18473,7 @@ var binding_default = defineComarkPlugin((opts = {}) => {
|
|
|
18337
18473
|
markdownItPlugins: [((md) => markdownItInlineBinding(md, opts))]
|
|
18338
18474
|
};
|
|
18339
18475
|
});
|
|
18340
|
-
// ../markdown-template/dist/prepare-
|
|
18476
|
+
// ../markdown-template/dist/prepare-CBQsr2Jb.js
|
|
18341
18477
|
const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
|
|
18342
18478
|
const markdownTemplateErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
18343
18479
|
docsBase: "https://vitehub.dev/docs/markdown-template/diagnostics",
|
|
@@ -18360,7 +18496,15 @@ const markdownTemplateErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
|
18360
18496
|
},
|
|
18361
18497
|
MARKDOWN_TEMPLATE_BINDING_OUTSIDE_DATA: {
|
|
18362
18498
|
why: ({ path }) => `The binding "${path}" does not start with \`data.\`. A template reads each value from \`data\`, so "${path}" is never defined.`,
|
|
18363
|
-
fix: "Start each binding with `data.`: write `{{ data.name }}` in place of `{{ name }}`, and `:href=\"data.url\"` in place of `:href=\"url\"`. Pass the same values in `data`."
|
|
18499
|
+
fix: "Start each binding with `data.`: write `{{ data.name }}` in place of `{{ name }}`, and `:href=\"data.url\"` in place of `:href=\"url\"`. Pass the same values in `data`. Inside `::each`, a binding can also start with the item name, such as `{{ file.name }}`."
|
|
18500
|
+
},
|
|
18501
|
+
MARKDOWN_TEMPLATE_EACH_ITEMS: {
|
|
18502
|
+
why: ({ path, found }) => `The \`::each\` items "${path}" ${found}, so the block has no list to repeat.`,
|
|
18503
|
+
fix: "Bind `:items` to a `data.<path>` that holds an array, such as `::each{:items=\"data.files\" as=\"file\"}`. Pass an empty array to render nothing."
|
|
18504
|
+
},
|
|
18505
|
+
MARKDOWN_TEMPLATE_EACH_PROPS: {
|
|
18506
|
+
why: ({ detail }) => detail,
|
|
18507
|
+
fix: "Give `::each` a bound `:items` prop and an optional `as` name, such as `::each{:items=\"data.files\" as=\"file\"}`. The name is a plain identifier other than `data`, `frontmatter`, `meta`, and `props`. Without `as`, the name is `item`. To repeat table rows, put the whole table, with its header, inside `::each`."
|
|
18364
18508
|
},
|
|
18365
18509
|
MARKDOWN_TEMPLATE_R0011: {
|
|
18366
18510
|
...dynamicError,
|
|
@@ -18471,10 +18615,16 @@ const bindingRoots = /* @__PURE__ */ new Set([
|
|
|
18471
18615
|
"meta",
|
|
18472
18616
|
"props"
|
|
18473
18617
|
]);
|
|
18474
|
-
/** Rejects a bound path that starts with no known name, such as `{{ name }}` from templates before `data.` paths. */
|
|
18475
|
-
function assertBindingRoot(value) {
|
|
18618
|
+
/** Rejects a bound path that starts with no known name, such as `{{ name }}` from templates before `data.` paths. `inScope` accepts the item names of the enclosing `::each` blocks. */
|
|
18619
|
+
function assertBindingRoot(value, inScope = () => false) {
|
|
18476
18620
|
const root = bindingRoot(value);
|
|
18477
|
-
if (root !== void 0 && !bindingRoots.has(root)) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_BINDING_OUTSIDE_DATA({ path: value });
|
|
18621
|
+
if (root !== void 0 && !bindingRoots.has(root) && !inScope(root)) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_BINDING_OUTSIDE_DATA({ path: value });
|
|
18622
|
+
}
|
|
18623
|
+
function isBindingRoot(name) {
|
|
18624
|
+
return bindingRoots.has(name);
|
|
18625
|
+
}
|
|
18626
|
+
function renderDataScope(renderData) {
|
|
18627
|
+
return (root) => Object.hasOwn(renderData, root);
|
|
18478
18628
|
}
|
|
18479
18629
|
function resolveTemplateAttributes(attributes, renderData) {
|
|
18480
18630
|
const values = Object.create(null);
|
|
@@ -18482,7 +18632,7 @@ function resolveTemplateAttributes(attributes, renderData) {
|
|
|
18482
18632
|
for (const [key, value] of Object.entries(attributes)) {
|
|
18483
18633
|
if (!key.startsWith(":") || typeof value !== "string") continue;
|
|
18484
18634
|
if (isJsonLiteral(value)) continue;
|
|
18485
|
-
assertBindingRoot(value);
|
|
18635
|
+
assertBindingRoot(value, renderDataScope(renderData));
|
|
18486
18636
|
const alias = `binding${Object.keys(values).length}`;
|
|
18487
18637
|
values[alias] = pathValue(renderData, value.split("."))?.value;
|
|
18488
18638
|
rewritten[key] = `props.${alias}`;
|
|
@@ -18652,7 +18802,7 @@ function validateBranches(template) {
|
|
|
18652
18802
|
}
|
|
18653
18803
|
if (stack.some((entry) => entry.tag === "if" || entry.tag === "else-if" || entry.tag === "else")) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0029({ message: "[vitehub] Markdown template if block is missing a closing :: line." });
|
|
18654
18804
|
}
|
|
18655
|
-
// ../markdown-template/dist/render-
|
|
18805
|
+
// ../markdown-template/dist/render-DF2Uc0-H.js
|
|
18656
18806
|
const ordered = (compare) => (value, expected) => (typeof value === "number" && typeof expected === "number" || typeof value === "string" && typeof expected === "string") && compare(value, expected);
|
|
18657
18807
|
const comparisons = {
|
|
18658
18808
|
eq: (value, expected) => value === expected,
|
|
@@ -18746,13 +18896,28 @@ const svgUrlAttributes = /* @__PURE__ */ new Set([
|
|
|
18746
18896
|
"image",
|
|
18747
18897
|
"use"
|
|
18748
18898
|
]);
|
|
18899
|
+
const rejectSplitEachTable = {
|
|
18900
|
+
name: "vitehub:each-table",
|
|
18901
|
+
markdownItPost({ tokens }) {
|
|
18902
|
+
for (const [index, token] of tokens.entries()) {
|
|
18903
|
+
if (token.type !== "table_open" || !token.map) continue;
|
|
18904
|
+
let close = index + 1;
|
|
18905
|
+
while (close < tokens.length && tokens[close]?.type !== "table_close") close++;
|
|
18906
|
+
if (tokens[close - 1]?.type !== "thead_close") continue;
|
|
18907
|
+
const each = tokens[close + 1];
|
|
18908
|
+
const paragraph = tokens[close + 2];
|
|
18909
|
+
const row = tokens[close + 3];
|
|
18910
|
+
if (each?.type === "mdc_block_open" && each.tag === "each" && each.map?.[0] === token.map[1] && paragraph?.type === "paragraph_open" && paragraph.map?.[0] === token.map[1] + 1 && row?.type === "inline" && /^\|(?:[^\\|\n]|\\.)*\|/.test(row.content.trimStart())) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_EACH_PROPS({ detail: "A table row inside `::each` cannot join a table header outside it. Put the whole table, with its header, inside `::each`." });
|
|
18911
|
+
}
|
|
18912
|
+
}
|
|
18913
|
+
};
|
|
18749
18914
|
async function renderMarkdownTemplate(template, options = {}) {
|
|
18750
18915
|
return await renderMarkdownTemplateInternal(template, options);
|
|
18751
18916
|
}
|
|
18752
18917
|
async function renderMarkdownTemplateInternal(template, options = {}) {
|
|
18753
18918
|
if (typeof template !== "string") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0014({ message: "[vitehub] Markdown template must be a string." });
|
|
18754
18919
|
const prepared = await prepareTemplate(template);
|
|
18755
|
-
const parseOptions = templateParserOptions(options.plugins);
|
|
18920
|
+
const parseOptions = templateParserOptions([...options.plugins ?? [], rejectSplitEachTable]);
|
|
18756
18921
|
const tree = await parseMarkdown(prepared.template, parseOptions);
|
|
18757
18922
|
const bindingPositions = /* @__PURE__ */ new WeakMap();
|
|
18758
18923
|
const data = snapshotTemplateData(options.data ?? {});
|
|
@@ -18781,14 +18946,50 @@ async function renderMarkdownTemplateInternal(template, options = {}) {
|
|
|
18781
18946
|
};
|
|
18782
18947
|
return prepared.restore((await renderMarkdown(tree, { components: {
|
|
18783
18948
|
Binding: async (node, state, parent) => {
|
|
18784
|
-
if (typeof node[1][":value"] === "string") assertBindingRoot(node[1][":value"]);
|
|
18785
|
-
|
|
18786
|
-
|
|
18949
|
+
if (typeof node[1][":value"] === "string") assertBindingRoot(node[1][":value"], renderDataScope(renderData(state)));
|
|
18950
|
+
const index = parent && bindingIndex(node, parent, bindingPositions);
|
|
18951
|
+
rejectLinkDestinationBinding(node, parent, index);
|
|
18952
|
+
const value = resolveScalarTemplateBinding(node[1], renderData(state));
|
|
18953
|
+
if (state.context.link !== true && !(parent?.[1].$?.html === 1 && parent[1].$?.block === 1) && isAutolinkUrl(value) && isStandaloneBinding(parent, index)) return `<${value}>`;
|
|
18954
|
+
return state.one(value, state, parent, true);
|
|
18787
18955
|
},
|
|
18788
18956
|
If: async (node, state, parent) => {
|
|
18789
18957
|
const { branches, after } = conditionalBranches(node);
|
|
18790
18958
|
return await renderNodes([...branches.find((branch) => branch[0] === "else" || matchesCondition(branch[1], renderData(state), options.validateConditionPath))?.slice(2) ?? [], ...after], state, parent);
|
|
18791
18959
|
},
|
|
18960
|
+
Each: async (node, state, parent) => {
|
|
18961
|
+
if (node[1].$?.html === 1) return await renderAuthoredHtml(node, state, parent, "markdown");
|
|
18962
|
+
const name = eachItemName(node[1]);
|
|
18963
|
+
const path = String(node[1][":items"]);
|
|
18964
|
+
const items = resolveTemplateAttributes({ ":items": node[1][":items"] }, renderData(state)).items;
|
|
18965
|
+
if (!Array.isArray(items)) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_EACH_ITEMS({
|
|
18966
|
+
path,
|
|
18967
|
+
found: items === void 0 || items === null ? "is not defined" : "is not an array"
|
|
18968
|
+
});
|
|
18969
|
+
const children = node.slice(2);
|
|
18970
|
+
const [first] = children;
|
|
18971
|
+
const singleTable = children.length === 1 && Array.isArray(first) && first[0] === "table" && first[1].$?.html !== 1;
|
|
18972
|
+
let rendered = "";
|
|
18973
|
+
let end = "";
|
|
18974
|
+
for (let index = 0; index < items.length; index++) {
|
|
18975
|
+
const raw = await renderNodes(children, {
|
|
18976
|
+
...state,
|
|
18977
|
+
renderData: {
|
|
18978
|
+
...state.renderData,
|
|
18979
|
+
[name]: items[index]
|
|
18980
|
+
}
|
|
18981
|
+
}, parent);
|
|
18982
|
+
const block = raw.replace(/^\n+|\n+$/g, "");
|
|
18983
|
+
if (!block) continue;
|
|
18984
|
+
end = /\n*$/.exec(raw)[0];
|
|
18985
|
+
if (!rendered) rendered = block;
|
|
18986
|
+
else if (singleTable) {
|
|
18987
|
+
const rows = block.split("\n").slice(2).join("\n");
|
|
18988
|
+
if (rows) rendered += `\n${rows}`;
|
|
18989
|
+
} else rendered = joinRepeatedBlocks(rendered, block);
|
|
18990
|
+
}
|
|
18991
|
+
return rendered + end;
|
|
18992
|
+
},
|
|
18792
18993
|
Else: unexpectedBranch,
|
|
18793
18994
|
ElseIf: unexpectedBranch,
|
|
18794
18995
|
Insert: async (node, state, parent) => {
|
|
@@ -18815,8 +19016,8 @@ async function renderMarkdownTemplateInternal(template, options = {}) {
|
|
|
18815
19016
|
rejectBoundEventHandlers(node[1]);
|
|
18816
19017
|
const sanitized = authoredHtml ? await sanitizeUrlAttributes("a", props, node[1]) : props;
|
|
18817
19018
|
const href = Object.hasOwn(node[1], ":href") ? await safeLinkDestination(resolveScalarTemplateBinding({ ":value": node[1][":href"] }, renderData(state)), String(node[1][":href"])) : authoredHtml ? sanitized.href : void 0;
|
|
18818
|
-
if (href === void 0) return await
|
|
18819
|
-
return await
|
|
19019
|
+
if (href === void 0) return await renderLink(node, state, parent);
|
|
19020
|
+
return await renderLink([
|
|
18820
19021
|
node[0],
|
|
18821
19022
|
{
|
|
18822
19023
|
...sanitized,
|
|
@@ -18836,8 +19037,18 @@ async function renderMarkdownTemplateInternal(template, options = {}) {
|
|
|
18836
19037
|
}
|
|
18837
19038
|
} })).trim());
|
|
18838
19039
|
}
|
|
18839
|
-
function
|
|
18840
|
-
|
|
19040
|
+
function isAutolinkUrl(value) {
|
|
19041
|
+
return /^(?:(?:https?|ftp):\/\/|mailto:)[^\s<>\\|]+$/i.test(value) && URL.canParse(value);
|
|
19042
|
+
}
|
|
19043
|
+
async function renderLink(node, state, parent) {
|
|
19044
|
+
const revert = state.applyContext({ link: true });
|
|
19045
|
+
try {
|
|
19046
|
+
return await state.handlers.a(node, state, parent);
|
|
19047
|
+
} finally {
|
|
19048
|
+
state.applyContext(revert);
|
|
19049
|
+
}
|
|
19050
|
+
}
|
|
19051
|
+
function bindingIndex(node, parent, positions) {
|
|
18841
19052
|
let indexes = positions.get(parent);
|
|
18842
19053
|
if (!indexes) {
|
|
18843
19054
|
indexes = /* @__PURE__ */ new Map();
|
|
@@ -18847,8 +19058,22 @@ function rejectLinkDestinationBinding(node, parent, positions) {
|
|
|
18847
19058
|
}
|
|
18848
19059
|
positions.set(parent, indexes);
|
|
18849
19060
|
}
|
|
18850
|
-
|
|
18851
|
-
|
|
19061
|
+
return indexes.get(node);
|
|
19062
|
+
}
|
|
19063
|
+
function isStandaloneBinding(parent, index) {
|
|
19064
|
+
if (!parent) return true;
|
|
19065
|
+
if (index === void 0) return false;
|
|
19066
|
+
const before = index > 2 ? parent[index - 1] : void 0;
|
|
19067
|
+
if (before !== void 0 && !(typeof before === "string" && /[\s([{"'“‘]$/.test(before)) && !(Array.isArray(before) && before[0] === "br")) return false;
|
|
19068
|
+
const after = parent[index + 1];
|
|
19069
|
+
if (after === void 0 || Array.isArray(after) && after[0] === "br") return true;
|
|
19070
|
+
if (typeof after !== "string") return false;
|
|
19071
|
+
const boundary = /^[.,!?;:)\]}'"”’]*(\s|$)/.exec(after);
|
|
19072
|
+
const next = parent[index + 2];
|
|
19073
|
+
return boundary !== null && (boundary[1] !== "" || next === void 0 || Array.isArray(next) && next[0] === "br");
|
|
19074
|
+
}
|
|
19075
|
+
function rejectLinkDestinationBinding(node, parent, index) {
|
|
19076
|
+
if (!parent || index === void 0 || index < 3) return;
|
|
18852
19077
|
const before = parent[index - 1];
|
|
18853
19078
|
const after = parent[index + 1];
|
|
18854
19079
|
if (typeof before !== "string" || typeof after !== "string") return;
|
|
@@ -18920,6 +19145,18 @@ async function renderNodes(nodes, state, parent) {
|
|
|
18920
19145
|
for (const node of nodes) rendered += await state.one(node, state, parent, !rendered || rendered.endsWith("\n"));
|
|
18921
19146
|
return rendered;
|
|
18922
19147
|
}
|
|
19148
|
+
const listStart = /^(?:[-*+]|\d+[.)])[\t ]/;
|
|
19149
|
+
function joinRepeatedBlocks(before, block) {
|
|
19150
|
+
const lastBlock = before.split(/\n{2,}/).filter((chunk) => !/^[\t ]/.test(chunk)).at(-1) ?? "";
|
|
19151
|
+
return `${before}${listStart.test(lastBlock) && listStart.test(block) ? "\n" : "\n\n"}${block}`;
|
|
19152
|
+
}
|
|
19153
|
+
function eachItemName(attributes) {
|
|
19154
|
+
if (typeof attributes[":items"] !== "string") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_EACH_PROPS({ detail: Object.hasOwn(attributes, "items") ? "The `::each` items prop must be bound: write `:items` in place of `items`." : "`::each` needs a bound `:items` prop." });
|
|
19155
|
+
for (const key of Object.keys(attributes)) if (key !== "$" && key !== ":items" && key !== "as") throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_EACH_PROPS({ detail: `\`::each\` does not accept the "${key}" prop.` });
|
|
19156
|
+
const name = attributes.as ?? "item";
|
|
19157
|
+
if (typeof name !== "string" || !/^[A-Za-z_]\w*$/.test(name) || isBindingRoot(name)) throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_EACH_PROPS({ detail: `The \`::each\` name "${String(name)}" is not a plain identifier, or it is a reserved name.` });
|
|
19158
|
+
return name;
|
|
19159
|
+
}
|
|
18923
19160
|
const unexpectedBranch = (node) => {
|
|
18924
19161
|
throw markdownTemplateErrorDiagnostics.MARKDOWN_TEMPLATE_R0015({ message: `[vitehub] Markdown template ${node[0]} block must follow an if block.` });
|
|
18925
19162
|
};
|
|
@@ -20425,6 +20662,48 @@ function workspaceDefinitionKind(definition) {
|
|
|
20425
20662
|
if (definition.source === "vite-plugin-contribution") return "Contributed Workspace Definition";
|
|
20426
20663
|
return "Workspace Definition";
|
|
20427
20664
|
}
|
|
20665
|
+
function namedWorkspaceExport(module, name) {
|
|
20666
|
+
for (const statement of module.program.body) {
|
|
20667
|
+
if (statement.type !== "ExportNamedDeclaration") continue;
|
|
20668
|
+
const declaration = statement.declaration;
|
|
20669
|
+
if (declaration?.type !== "VariableDeclaration" || declaration.kind !== "const") continue;
|
|
20670
|
+
for (const binding of declaration.declarations) if (binding.id.type === "Identifier" && binding.id.name === name) return binding.init ?? void 0;
|
|
20671
|
+
}
|
|
20672
|
+
}
|
|
20673
|
+
async function declaredSources(file, exportName = "default") {
|
|
20674
|
+
if (!isAbsolute(file)) return;
|
|
20675
|
+
let source;
|
|
20676
|
+
try {
|
|
20677
|
+
source = readFileSync(file, "utf8");
|
|
20678
|
+
} catch {
|
|
20679
|
+
return;
|
|
20680
|
+
}
|
|
20681
|
+
const { argumentExpression, defaultExportExpression, objectProperties, scanModule, unwrapExpression } = await import("./workspace-inspection-scanner-BlJ8bCAB.js").then((n) => n.t);
|
|
20682
|
+
const module = scanModule(source, file);
|
|
20683
|
+
if (module.errors.length) return;
|
|
20684
|
+
const exported = exportName === "default" ? defaultExportExpression(module) : namedWorkspaceExport(module, exportName);
|
|
20685
|
+
const call = exported && unwrapExpression(exported);
|
|
20686
|
+
if (call?.type !== "CallExpression" || call.callee.type !== "Identifier" || call.callee.name !== "defineWorkspace") return;
|
|
20687
|
+
const options = argumentExpression(call.arguments[0]);
|
|
20688
|
+
if (options?.type !== "ObjectExpression") return "set at runtime";
|
|
20689
|
+
const property = objectProperties(options).findLast(({ key }) => key === "sources" || key === void 0);
|
|
20690
|
+
if (!property) return;
|
|
20691
|
+
if (property.key === void 0 || property.value?.type !== "ObjectExpression") return "set at runtime";
|
|
20692
|
+
const names = /* @__PURE__ */ new Map();
|
|
20693
|
+
for (const { key, value } of objectProperties(property.value)) {
|
|
20694
|
+
if (key === void 0) return "set at runtime";
|
|
20695
|
+
const loader = value?.type === "CallExpression" && value.callee.type === "Identifier" ? value.callee.name : void 0;
|
|
20696
|
+
names.set(key, loader ? `${key} (${loader})` : key);
|
|
20697
|
+
}
|
|
20698
|
+
return names.size ? [...names.values()].join(", ") : "none";
|
|
20699
|
+
}
|
|
20700
|
+
async function sourcesField(definition) {
|
|
20701
|
+
const value = await declaredSources(definition.handler, definition.export);
|
|
20702
|
+
return value ? [{
|
|
20703
|
+
label: "Sources",
|
|
20704
|
+
value
|
|
20705
|
+
}] : [];
|
|
20706
|
+
}
|
|
20428
20707
|
/** Lists Workspace Definitions, Agent workspaces, and contributed Workspaces as serializable inspection summaries. */
|
|
20429
20708
|
async function inspectWorkspaceDefinitions(options) {
|
|
20430
20709
|
const contributions = await collectWorkspaceContributions(options.plugins, {
|
|
@@ -20433,11 +20712,12 @@ async function inspectWorkspaceDefinitions(options) {
|
|
|
20433
20712
|
root: options.rootDir,
|
|
20434
20713
|
serverDirs: options.serverDirs
|
|
20435
20714
|
});
|
|
20436
|
-
|
|
20715
|
+
const definitions = discoverViteWorkspaceDefinitions(options.rootDir, {
|
|
20437
20716
|
contributions,
|
|
20438
20717
|
serverDirs: options.serverDirs,
|
|
20439
20718
|
serverRootDir: options.serverRootDir
|
|
20440
|
-
})
|
|
20719
|
+
});
|
|
20720
|
+
return Promise.all(definitions.map(async (definition) => ({
|
|
20441
20721
|
fields: [
|
|
20442
20722
|
{
|
|
20443
20723
|
label: "Kind",
|
|
@@ -20457,13 +20737,14 @@ async function inspectWorkspaceDefinitions(options) {
|
|
|
20457
20737
|
}] : [],
|
|
20458
20738
|
...definition.sourceRootDir ? [{
|
|
20459
20739
|
label: "Source root",
|
|
20460
|
-
value: relativeDefinitionFile(options.projectRoot, definition.sourceRootDir)
|
|
20461
|
-
}] : []
|
|
20740
|
+
value: relativeDefinitionFile(options.projectRoot, definition.sourceRootDir) || "."
|
|
20741
|
+
}] : [],
|
|
20742
|
+
...await sourcesField(definition)
|
|
20462
20743
|
],
|
|
20463
20744
|
file: isAbsolute(definition.handler) ? relativeDefinitionFile(options.projectRoot, definition.handler) : definition.handler,
|
|
20464
20745
|
name: definition.name,
|
|
20465
20746
|
source: definition.source || "workspace"
|
|
20466
|
-
}));
|
|
20747
|
+
})));
|
|
20467
20748
|
}
|
|
20468
20749
|
/** Console section that lists discovered Workspace Definitions. `vitehub inspect definitions` reads the same data. */
|
|
20469
20750
|
const workspaceConsoleSection = {
|
|
@@ -20605,7 +20886,7 @@ async function readStaticWorkspaceStore(file, loader, exportedName = "default")
|
|
|
20605
20886
|
if (!properties) return;
|
|
20606
20887
|
const storeProperty = properties.findLast((property) => (property.key?.name ?? property.key?.value) === "store");
|
|
20607
20888
|
if (!storeProperty) {
|
|
20608
|
-
staticStore = {};
|
|
20889
|
+
staticStore = { usage: "default" };
|
|
20609
20890
|
return;
|
|
20610
20891
|
}
|
|
20611
20892
|
if (storeProperty.type !== "ObjectProperty") return;
|
|
@@ -20616,6 +20897,10 @@ async function readStaticWorkspaceStore(file, loader, exportedName = "default")
|
|
|
20616
20897
|
}
|
|
20617
20898
|
const storeProperties = babelStaticObjectProperties(store);
|
|
20618
20899
|
if (!storeProperties) return;
|
|
20900
|
+
if (storeProperties.length === 0) {
|
|
20901
|
+
staticStore = { usage: "implicit" };
|
|
20902
|
+
return;
|
|
20903
|
+
}
|
|
20619
20904
|
const readFile = storeProperties.findLast((property) => (property.key?.name ?? property.key?.value) === "readFile");
|
|
20620
20905
|
if (readFile) {
|
|
20621
20906
|
if (readFile.type === "ObjectMethod" && readFile.kind === "method") staticStore = {};
|
|
@@ -20649,6 +20934,7 @@ async function resolveDefinitionCloudflareArtifactsConfigs(definitions, rootDir,
|
|
|
20649
20934
|
message: `[vitehub] Workspace "${definition.name}" sets a store that may need a Cloudflare Artifacts binding, but the build cannot load ${definitionFile} to read it: ${error instanceof Error ? error.message : String(error)}`
|
|
20650
20935
|
});
|
|
20651
20936
|
options.storeUsage?.add("unknown");
|
|
20937
|
+
if (store.usage) options.storeUsage?.add(store.usage);
|
|
20652
20938
|
if (store.driver === "github") options.storeUsage?.add("github");
|
|
20653
20939
|
continue;
|
|
20654
20940
|
}
|
|
@@ -20656,6 +20942,7 @@ async function resolveDefinitionCloudflareArtifactsConfigs(definitions, rootDir,
|
|
|
20656
20942
|
const workspace = normalizeWorkspaceDefinition(definition.name, loaded);
|
|
20657
20943
|
if (!workspace.store) options.storeUsage?.add("default");
|
|
20658
20944
|
if (!workspace.store || isWorkspaceStore(workspace.store)) continue;
|
|
20945
|
+
if (isImplicitWorkspaceStore(workspace.store)) options.storeUsage?.add("implicit");
|
|
20659
20946
|
const config = normalizeWorkspaceOptions({ store: workspace.store }, {
|
|
20660
20947
|
dev: false,
|
|
20661
20948
|
env: options.env || process.env,
|
|
@@ -20679,6 +20966,9 @@ async function resolveDefinitionCloudflareArtifactsConfigs(definitions, rootDir,
|
|
|
20679
20966
|
function definitionsToLoad(definitions, command, hosting) {
|
|
20680
20967
|
return command !== "serve" || getHostingProvider(hosting) === "cloudflare" ? definitions : [];
|
|
20681
20968
|
}
|
|
20969
|
+
function isImplicitWorkspaceStore(store) {
|
|
20970
|
+
return !store || !isWorkspaceStore(store) && store.driver === void 0 && !store.root;
|
|
20971
|
+
}
|
|
20682
20972
|
async function resolveCloudflareArtifactsConfigs(config, definitions, rootDir, options = {}) {
|
|
20683
20973
|
return [...config.store.driver === "cloudflare" ? [config] : [], ...await resolveDefinitionCloudflareArtifactsConfigs(definitions, rootDir, options)];
|
|
20684
20974
|
}
|
|
@@ -20772,7 +21062,7 @@ function resolveNitroHostedStoreProviders(config, definitionCount, storeUsage) {
|
|
|
20772
21062
|
if (storeUsage.has("unknown")) return new Set(hostedWorkspaceStoreDrivers);
|
|
20773
21063
|
const providers = new Set(configProvider ? [configProvider] : []);
|
|
20774
21064
|
for (const usage of storeUsage) {
|
|
20775
|
-
if (usage === "unknown") continue;
|
|
21065
|
+
if (usage === "unknown" || usage === "implicit") continue;
|
|
20776
21066
|
if (usage === "default") {
|
|
20777
21067
|
if (!config) providers.add("vercel");
|
|
20778
21068
|
continue;
|
|
@@ -21143,6 +21433,8 @@ function hubWorkspace(options) {
|
|
|
21143
21433
|
let serverDirs;
|
|
21144
21434
|
let contributions = [];
|
|
21145
21435
|
let hasArtifacts = false;
|
|
21436
|
+
let workerMemoryNotice = false;
|
|
21437
|
+
let nitroPreset;
|
|
21146
21438
|
async function refreshManifest(roots) {
|
|
21147
21439
|
const definitions = discoverDefinitions(roots, serverDirs, contributions);
|
|
21148
21440
|
const state = await refreshWorkspaceBuildState(roots.projectRoot, definitions);
|
|
@@ -21168,7 +21460,10 @@ function hubWorkspace(options) {
|
|
|
21168
21460
|
}
|
|
21169
21461
|
return {
|
|
21170
21462
|
name: "@vite-hub/workspace/vite",
|
|
21171
|
-
nitro:
|
|
21463
|
+
nitro: { setup(nitro) {
|
|
21464
|
+
if (nitro.options.preset !== "nitro-prerender") nitroPreset = nitro.options.preset;
|
|
21465
|
+
packageLoading.nitro.setup(nitro);
|
|
21466
|
+
} },
|
|
21172
21467
|
enforce: "pre",
|
|
21173
21468
|
[setWorkspacePluginHosting](value) {
|
|
21174
21469
|
hosting = value;
|
|
@@ -21176,6 +21471,8 @@ function hubWorkspace(options) {
|
|
|
21176
21471
|
api: { getWorkspaces: () => manifest.workspaces },
|
|
21177
21472
|
async config(config, env) {
|
|
21178
21473
|
hasArtifacts = false;
|
|
21474
|
+
workerMemoryNotice = false;
|
|
21475
|
+
nitroPreset = void 0;
|
|
21179
21476
|
serverDirs = config["__vitehubServerDirs"] ?? serverDirs;
|
|
21180
21477
|
const workspaceOptions = publicOptions;
|
|
21181
21478
|
const roots = resolveWorkspacePluginRoots(config.root || process.cwd(), workspaceOptions);
|
|
@@ -21211,6 +21508,13 @@ function hubWorkspace(options) {
|
|
|
21211
21508
|
});
|
|
21212
21509
|
if (normalized.store.driver !== "github" && storeUsage?.has("github")) assertGitHubStoreAvailable?.();
|
|
21213
21510
|
hasArtifacts = artifacts.length > 0;
|
|
21511
|
+
const implicitModuleStore = isImplicitWorkspaceStore(workspaceOptions ? workspaceOptions.store : void 0) && (!runtimeConfig || runtimeConfig.store.driver === "memory");
|
|
21512
|
+
workerMemoryNotice = env?.command === "build" && (Boolean(storeUsage?.has("implicit")) || implicitModuleStore && (definitions.length === 0 || Boolean(storeUsage?.has("default"))));
|
|
21513
|
+
if (workerMemoryNotice && getHostingProvider(resolvedHosting) === "cloudflare" && typeof Reflect.get(config, "__vitehubNuxtHints") === "function") reportViteHubHint({
|
|
21514
|
+
...config,
|
|
21515
|
+
command: "build",
|
|
21516
|
+
root: roots.viteRoot
|
|
21517
|
+
}, workspaceErrorDiagnostics.WORKSPACE_STORE_IN_WORKER_MEMORY());
|
|
21214
21518
|
const usesCloudflareRuntime = hasArtifacts || getHostingProvider(resolvedHosting) === "cloudflare";
|
|
21215
21519
|
await writeNitroWorkspacePlugin(roots.projectRoot, runtimeConfig, runtimeOptions, definitions, usesCloudflareRuntime, definitionOverrides, storeUsage);
|
|
21216
21520
|
const nitro = mergeNitroWorkspaceConfig(config.nitro, roots.projectRoot, env?.command === "serve");
|
|
@@ -21234,6 +21538,7 @@ function hubWorkspace(options) {
|
|
|
21234
21538
|
return viteConfig;
|
|
21235
21539
|
},
|
|
21236
21540
|
async configResolved(config) {
|
|
21541
|
+
startViteHubHints(config);
|
|
21237
21542
|
resolved = config;
|
|
21238
21543
|
providerOutput = useProviderOutputCatalog(config);
|
|
21239
21544
|
const workspaceOptions = publicOptions;
|
|
@@ -21253,6 +21558,7 @@ function hubWorkspace(options) {
|
|
|
21253
21558
|
rootDir: roots.projectRoot
|
|
21254
21559
|
});
|
|
21255
21560
|
if (resolvedOptions) contributions = await collectPluginWorkspaceContributions(config.plugins, roots, serverDirs);
|
|
21561
|
+
if (workerMemoryNotice && config.command === "build" && getHostingProvider(nitroPreset ?? resolvedHosting) === "cloudflare" && !Reflect.get(config, "__vitehubNuxtHints")) reportViteHubHint(config, workspaceErrorDiagnostics.WORKSPACE_STORE_IN_WORKER_MEMORY());
|
|
21256
21562
|
assetsRegistryFile = resolve(roots.projectRoot, workspaceAssetsRegistryPath);
|
|
21257
21563
|
await initializeWorkspaceAssetRegistry(assetsRegistryFile);
|
|
21258
21564
|
await refreshManifest(roots);
|
|
@@ -21440,4 +21746,4 @@ function hubWorkspace(options) {
|
|
|
21440
21746
|
}
|
|
21441
21747
|
};
|
|
21442
21748
|
}
|
|
21443
|
-
export { collectWorkspaceContributions, createWorkspaceNitroConfig, discoverViteWorkspaceDefinitions, hubWorkspace, inspectWorkspaceDefinitions, workspaceConsoleSection };
|
|
21749
|
+
export { collectWorkspaceContributions, createWorkspaceNitroConfig, discoverViteWorkspaceDefinitions, hubWorkspace, inspectWorkspaceDefinitions, moduleLanguage as t, workspaceConsoleSection };
|