@vite-hub/workspace 0.0.4 → 0.3.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 +339 -115
- package/dist/abort-BCwpdrN0.js +32 -0
- package/dist/{asset-registry-8QI3ML3K.js → asset-registry-DfBV5kmw.js} +3 -2
- package/dist/blob-database.d.ts +474 -0
- package/dist/blob-database.js +608 -0
- package/dist/checkout.d.ts +128 -0
- package/dist/checkout.js +849 -0
- package/dist/cloudflare.d.ts +6 -7
- package/dist/cloudflare.js +1 -1
- package/dist/config-B-863EgC.js +15 -0
- package/dist/config-BAgL2dtB.js +1076 -0
- package/dist/{config-DE9xlaIw.d.ts → config-BQKcPawI.d.ts} +1 -2
- package/dist/discard-CNNtCozM.js +8 -0
- package/dist/durability.d.ts +22 -0
- package/dist/durability.js +70 -0
- package/dist/error-diagnostics-CtKjGtGb.js +188 -0
- package/dist/error-diagnostics-DSkCJC_L.js +266 -0
- package/dist/file-2pFYNtsU.js +22 -0
- package/dist/{files-Q6xZjDHA.js → files-BOo4SbwE.js} +3 -3
- package/dist/files.d.ts +38 -0
- package/dist/files.js +6 -0
- package/dist/{github-DHnjxQIX.js → github-CrYp4v8k.js} +44 -24
- package/dist/glob-B8YGvTrZ.js +21 -0
- package/dist/glob-Cjxms1t7.js +30 -0
- package/dist/{host-DJH8cuoU.js → host-BFBpXn0N.js} +144 -77
- package/dist/{hosted-RPeJOCFz.js → hosted-KcUR_jPv.js} +303 -97
- package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
- package/dist/hosted-vercel-blob.d.ts +6 -7
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +10 -9
- package/dist/hosted.js +2 -2
- package/dist/index.d.ts +26 -47
- package/dist/index.js +30 -100
- package/dist/internal/path.d.ts +2 -0
- package/dist/internal/path.js +2 -0
- package/dist/lifecycle-B-enk_4A.js +596 -0
- package/dist/lineage.d.ts +26 -0
- package/dist/lineage.js +76 -0
- package/dist/loader.d.ts +5 -6
- package/dist/loader.js +3 -2
- package/dist/mcp-resources-DF0F5rcL.js +39 -0
- package/dist/memory-BOexthyW.js +247 -0
- package/dist/metadata-target-CWz6KHKq.js +1589 -0
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
- package/dist/operations-C6FpR8Rr.js +389 -0
- package/dist/operations-CE2drFih.js +1234 -0
- package/dist/operations.d.ts +90 -0
- package/dist/operations.js +3 -0
- package/dist/path--wrT_Azm.js +113 -0
- package/dist/path-AxMho1wo.d.ts +7 -0
- package/dist/path-DrSIenjj.js +59 -0
- package/dist/path-zHxQUbqa.d.ts +9 -0
- package/dist/plugins-C8C0auoW.d.ts +10 -0
- package/dist/provider-9s4Ufkm5.js +1479 -0
- package/dist/providers/github/store.d.ts +3 -5
- package/dist/providers/github/store.js +1 -1
- package/dist/registry-B3BBm4Ts.d.ts +19 -0
- package/dist/{registry-D3yzt8HQ.js → registry-CNphafBx.js} +60 -23
- package/dist/registry-CYNN623b.d.ts +9 -0
- package/dist/request-scope-Dw5n8bMC.js +83 -0
- package/dist/results-DgkZUmTL.js +8 -0
- package/dist/{chunk-2rV9d50f.js → rolldown-runtime-rQ84J-ij.js} +3 -4
- package/dist/runtime/assets.d.ts +3 -5
- package/dist/runtime/assets.js +7 -6
- package/dist/runtime/empty-assets-registry.d.ts +1 -2
- package/dist/runtime/empty-registry.d.ts +2 -2
- package/dist/runtime/registry.d.ts +2 -0
- package/dist/runtime/registry.js +23 -0
- package/dist/runtime/request.d.ts +4 -0
- package/dist/runtime/request.js +8 -0
- package/dist/runtime/state.d.ts +5 -4
- package/dist/runtime/state.js +8 -18
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime.d.ts +52 -17
- package/dist/runtime.js +324 -67
- package/dist/{search-BpiCF2Tw.js → search-C_RfoM2j.js} +10 -9
- package/dist/server-8tGltlGz.js +303 -0
- package/dist/server.d.ts +36 -39
- package/dist/server.js +2 -328
- package/dist/shared-B3_EUk89.js +848 -0
- package/dist/source-metadata.d.ts +10 -7
- package/dist/source-metadata.js +12 -12
- package/dist/state-BISnUf1s.d.ts +35 -0
- package/dist/{ai-BqCC8BpY.js → state-DbrW-njQ.js} +237 -114
- package/dist/store-ybhyD38Z.js +1873 -0
- package/dist/{sync-DnTQwt8r.js → sync-CCD_VYC8.js} +61 -41
- package/dist/target-jWhTdIuF.js +89 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/{types-CYuwjJ4V.d.ts → types-BbtwmBZ5.d.ts} +321 -35
- package/dist/use-C6lV3-wC.d.ts +321 -0
- package/dist/{use-BTNDR5Rd.js → use-CSpT5W87.js} +141 -107
- package/dist/utils-CgMZCHsX.js +616 -0
- package/dist/vite.d.ts +585 -2
- package/dist/vite.js +21369 -2
- package/dist/workspace-CYB2xZ1T.d.ts +7 -0
- package/dist/{workspace-Dq08Yn72.js → workspace-sPWn2Jxj.js} +441 -225
- package/package.json +97 -72
- package/dist/ai-CjxvGqM0.d.ts +0 -162
- package/dist/ai.d.ts +0 -3
- package/dist/ai.js +0 -2
- package/dist/collections/client.d.ts +0 -39
- package/dist/collections/client.js +0 -137
- package/dist/collections.d.ts +0 -59
- package/dist/collections.js +0 -159
- package/dist/config-Bc3c4Su1.js +0 -7904
- package/dist/config-CHLLWklZ.js +0 -36
- package/dist/file-Bc1X7pco.js +0 -23
- package/dist/glob-CEZKeZFC.js +0 -18
- package/dist/hosted-vercel-blob-d6C8ND5j.js +0 -23580
- package/dist/lifecycle-LrL3sA4n.js +0 -316
- package/dist/metadata-target-B0tOmVW7.js +0 -717
- package/dist/mountx.d.ts +0 -10
- package/dist/mountx.js +0 -143
- package/dist/nitro.d.ts +0 -2
- package/dist/nitro.js +0 -2
- package/dist/nuxt.d.ts +0 -26
- package/dist/nuxt.js +0 -42
- package/dist/path-Cp59koVz.js +0 -139
- package/dist/provider-B1yLjCJJ.js +0 -746
- package/dist/publish.d.ts +0 -35
- package/dist/publish.js +0 -112
- package/dist/registry-Uj6IVxes.d.ts +0 -11
- package/dist/request-execution-B-dSFlGB.js +0 -84
- package/dist/runtime-options-BsPSv5O7.js +0 -13
- package/dist/runtime-type-iEE6BjQJ.js +0 -34
- package/dist/shared-DTR1Hhma.js +0 -331
- package/dist/state-tYcRWEh2.d.ts +0 -26
- package/dist/store-Dt_Jyys3.js +0 -608
- package/dist/target-D4Bqb1eH.js +0 -11
- package/dist/token-CVzURBxC.js +0 -61
- package/dist/use-BiHzt0xA.d.ts +0 -103
- package/dist/vite-BptCrpv2.js +0 -4526
- package/dist/vite-CtA9guIM.d.ts +0 -66
- package/dist/workspace-Xddf4G1B.d.ts +0 -6
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { s as workspaceError } from "./path-DrSIenjj.js";
|
|
2
|
+
import { f as sha256, n as contentStreamToBytes } from "./path--wrT_Azm.js";
|
|
3
|
+
import { d as sourceSyncPathClaims, f as workspaceSourceSyncStateEquals, l as readWorkspaceSourceSyncState, u as sourceSyncMetaKey } from "./workspace-sPWn2Jxj.js";
|
|
4
|
+
import { a as normalizeWorkspaceSources, f as prepareWorkspaceSource, n as createSourceContext, s as sourceMountContainsPath } from "./config-BAgL2dtB.js";
|
|
5
|
+
import { C as withWorkspaceStoreMutation, E as normalizeSourceFileMetadata, S as sourceMountOwnsPath, T as normalizeMetadataValue, w as normalizeSourceItemPath, x as createWorkspaceSourceMountAuthority } from "./metadata-target-CWz6KHKq.js";
|
|
5
6
|
//#region src/sources/sync.ts
|
|
6
7
|
const sourceSyncLocks = /* @__PURE__ */ new Map();
|
|
8
|
+
const sourceSyncGrants = createWorkspaceSourceMountAuthority("Source Sync");
|
|
7
9
|
function zeroCounts() {
|
|
8
10
|
return {
|
|
9
11
|
added: 0,
|
|
@@ -51,7 +53,10 @@ function selectedSyncSources(definition, options) {
|
|
|
51
53
|
if (options.sources === "all") return sources;
|
|
52
54
|
return [...new Set(options.sources)].map((key) => {
|
|
53
55
|
const source = sources.find((item) => item.key === key);
|
|
54
|
-
if (!source)
|
|
56
|
+
if (!source) {
|
|
57
|
+
const defined = normalizeWorkspaceSources(definition.sources).some((item) => item.key === key);
|
|
58
|
+
throw workspaceError(defined ? `[vitehub] Workspace source ${JSON.stringify(key)} is not configured for Source Sync. Add sync: true to the source binding.` : `[vitehub] Workspace source ${JSON.stringify(key)} does not exist.`);
|
|
59
|
+
}
|
|
55
60
|
return source;
|
|
56
61
|
});
|
|
57
62
|
}
|
|
@@ -68,7 +73,7 @@ async function shouldRemoveStalePath(store, path, metadata) {
|
|
|
68
73
|
async function planSourceSync(definition, store, source) {
|
|
69
74
|
const ctx = createSourceContext(definition, source);
|
|
70
75
|
const [previousState, configHash, items] = await Promise.all([
|
|
71
|
-
store.getMeta?.(sourceSyncMetaKey(source.key)).then(readWorkspaceSourceSyncState),
|
|
76
|
+
store.getMeta?.(sourceSyncMetaKey(source.key, definition.name)).then(readWorkspaceSourceSyncState),
|
|
72
77
|
sourceConfigHash(source),
|
|
73
78
|
getSourceItems(source, ctx)
|
|
74
79
|
]);
|
|
@@ -81,9 +86,14 @@ async function planSourceSync(definition, store, source) {
|
|
|
81
86
|
if (nextPaths[path]) throw workspaceError(`[vitehub] Workspace Source Sync produced duplicate path: ${path}.`);
|
|
82
87
|
const content = await contentFromItem(item);
|
|
83
88
|
const digest = await sha256(content);
|
|
89
|
+
const metadata = normalizeSourceFileMetadata({
|
|
90
|
+
...normalizeSourceFileMetadata(item.metadata || {}),
|
|
91
|
+
source: source.key,
|
|
92
|
+
sourcePath
|
|
93
|
+
});
|
|
84
94
|
const existing = await store.readFile(path);
|
|
85
|
-
const
|
|
86
|
-
const status = existing ?
|
|
95
|
+
const unchanged = (existing ? await sha256(existing.content) : void 0) === digest && existing?.mediaType === item.mediaType && JSON.stringify(normalizeMetadataValue(existing?.metadata)) === JSON.stringify(normalizeMetadataValue(metadata));
|
|
96
|
+
const status = existing ? unchanged ? "unchanged" : "updated" : "added";
|
|
87
97
|
countPath(counts, status);
|
|
88
98
|
paths.push({
|
|
89
99
|
path,
|
|
@@ -93,22 +103,23 @@ async function planSourceSync(definition, store, source) {
|
|
|
93
103
|
nextPaths[path] = {
|
|
94
104
|
digest,
|
|
95
105
|
mediaType: item.mediaType,
|
|
106
|
+
mountPath: source.mountPath,
|
|
96
107
|
sourcePath
|
|
97
108
|
};
|
|
98
109
|
files.push({
|
|
99
110
|
path,
|
|
100
111
|
content,
|
|
101
112
|
mediaType: item.mediaType,
|
|
102
|
-
metadata
|
|
103
|
-
...item.metadata,
|
|
104
|
-
source: source.key,
|
|
105
|
-
sourcePath
|
|
106
|
-
}
|
|
113
|
+
metadata
|
|
107
114
|
});
|
|
108
115
|
}
|
|
109
116
|
const removals = [];
|
|
110
|
-
if (source.sync && source.sync.stale === "remove" && previousState) for (const
|
|
117
|
+
if (source.sync && source.sync.stale === "remove" && previousState) for (const path of Object.keys(previousState.paths)) {
|
|
111
118
|
if (nextPaths[path]) continue;
|
|
119
|
+
const claims = sourceSyncPathClaims(previousState, path);
|
|
120
|
+
const metadata = claims.find((claim) => claim.mountPath === source.mountPath);
|
|
121
|
+
if (!metadata || claims.length > 1) continue;
|
|
122
|
+
if (!sourceMountOwnsPath(source, path)) continue;
|
|
112
123
|
if (!await shouldRemoveStalePath(store, path, metadata)) continue;
|
|
113
124
|
const removal = {
|
|
114
125
|
path,
|
|
@@ -119,28 +130,46 @@ async function planSourceSync(definition, store, source) {
|
|
|
119
130
|
paths.push(removal);
|
|
120
131
|
countPath(counts, "removed");
|
|
121
132
|
}
|
|
122
|
-
const nextState = {
|
|
123
|
-
configHash,
|
|
124
|
-
mountPath: source.mountPath,
|
|
125
|
-
paths: nextPaths,
|
|
126
|
-
source: source.key
|
|
127
|
-
};
|
|
128
133
|
return {
|
|
129
134
|
counts,
|
|
130
135
|
files,
|
|
131
|
-
nextState
|
|
136
|
+
nextState: {
|
|
137
|
+
configHash,
|
|
138
|
+
mountPath: source.mountPath,
|
|
139
|
+
paths: nextPaths,
|
|
140
|
+
source: source.key
|
|
141
|
+
},
|
|
132
142
|
paths,
|
|
133
143
|
removals,
|
|
134
144
|
source,
|
|
135
|
-
|
|
145
|
+
definitionName: definition.name
|
|
136
146
|
};
|
|
137
147
|
}
|
|
138
148
|
async function applySourceSyncPlan(store, plan) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
const sourceStore = sourceSyncGrants.store(sourceSyncGrants.grant(plan.source), store);
|
|
150
|
+
const current = await store.getMeta?.(sourceSyncMetaKey(plan.source.key, plan.definitionName)).then(readWorkspaceSourceSyncState);
|
|
151
|
+
if (plan.source.mountPath) await sourceStore.mkdir(plan.source.mountPath, { recursive: true });
|
|
152
|
+
for (const file of plan.files) await sourceStore.writeFile(file.path, file);
|
|
153
|
+
for (const removal of plan.removals) await sourceStore.rm(removal.path, { force: true });
|
|
154
|
+
await pruneEmptySourceDirectories(sourceStore, plan.source, plan.removals);
|
|
155
|
+
const paths = {};
|
|
156
|
+
const claims = {};
|
|
157
|
+
for (const path of /* @__PURE__ */ new Set([...Object.keys(current?.paths ?? {}), ...Object.keys(plan.nextState.paths)])) {
|
|
158
|
+
const retained = current?.paths[path] ? sourceSyncPathClaims(current, path).filter((claim) => claim.mountPath !== plan.source.mountPath).map((claim) => ({ ...claim })) : [];
|
|
159
|
+
const next = plan.nextState.paths[path];
|
|
160
|
+
if (next) retained.push(next);
|
|
161
|
+
if (retained.length === 0) continue;
|
|
162
|
+
const digest = next?.digest ?? current.paths[path].digest;
|
|
163
|
+
for (const claim of retained) claim.digest = digest;
|
|
164
|
+
paths[path] = retained[retained.length - 1];
|
|
165
|
+
if (retained.length > 1) claims[path] = retained.sort((left, right) => left.mountPath.localeCompare(right.mountPath));
|
|
166
|
+
}
|
|
167
|
+
const nextState = {
|
|
168
|
+
...plan.nextState,
|
|
169
|
+
paths
|
|
170
|
+
};
|
|
171
|
+
if (Object.keys(claims).length) nextState.claims = claims;
|
|
172
|
+
if (!workspaceSourceSyncStateEquals(current, nextState)) await store.setMeta?.(sourceSyncMetaKey(plan.source.key, plan.definitionName), nextState);
|
|
144
173
|
}
|
|
145
174
|
async function pruneEmptySourceDirectories(store, source, removals) {
|
|
146
175
|
const directories = /* @__PURE__ */ new Set();
|
|
@@ -173,15 +202,10 @@ function statusFromPlan(plan, details) {
|
|
|
173
202
|
status: "ready"
|
|
174
203
|
};
|
|
175
204
|
}
|
|
176
|
-
async function snapshotSyncedWorkspace(
|
|
177
|
-
if (!
|
|
205
|
+
async function snapshotSyncedWorkspace(store, options) {
|
|
206
|
+
if (!options.snapshot) return;
|
|
178
207
|
const snapshotOptions = typeof options.snapshot === "object" ? options.snapshot : {};
|
|
179
|
-
|
|
180
|
-
if (options.publish) {
|
|
181
|
-
const { publishWorkspaceSnapshot } = await import("./lifecycle-LrL3sA4n.js").then((n) => n.t);
|
|
182
|
-
await publishWorkspaceSnapshot(definition, store, snapshot);
|
|
183
|
-
}
|
|
184
|
-
return snapshot;
|
|
208
|
+
return await store.snapshot(normalizeSnapshotOptions(snapshotOptions));
|
|
185
209
|
}
|
|
186
210
|
function normalizeSnapshotOptions(options) {
|
|
187
211
|
if (!options || typeof options !== "object") return { name: "source-sync" };
|
|
@@ -203,7 +227,6 @@ async function syncWorkspaceSourcesUnlocked(definition, store, options, sources,
|
|
|
203
227
|
}
|
|
204
228
|
if (statuses.some((status) => status.status === "error") && !options.publishPartial) return {
|
|
205
229
|
durationMs: Date.now() - started,
|
|
206
|
-
published: false,
|
|
207
230
|
sources: [...statuses, ...plans.map((plan) => ({
|
|
208
231
|
counts: plan.counts,
|
|
209
232
|
mountPath: plan.source.mountPath,
|
|
@@ -216,10 +239,9 @@ async function syncWorkspaceSourcesUnlocked(definition, store, options, sources,
|
|
|
216
239
|
for (const plan of plans) await applySourceSyncPlan(store, plan);
|
|
217
240
|
const planStatuses = plans.map((plan) => statusFromPlan(plan, options.details));
|
|
218
241
|
const resultSources = [...statuses, ...planStatuses];
|
|
219
|
-
const snapshot = resultStatus(resultSources) === "ready" || options.publishPartial && planStatuses.length > 0 ? await snapshotSyncedWorkspace(
|
|
242
|
+
const snapshot = resultStatus(resultSources) === "ready" || options.publishPartial && planStatuses.length > 0 ? await snapshotSyncedWorkspace(store, options) : void 0;
|
|
220
243
|
return {
|
|
221
244
|
durationMs: Date.now() - started,
|
|
222
|
-
published: !!options.publish && !!snapshot,
|
|
223
245
|
snapshot,
|
|
224
246
|
sources: resultSources,
|
|
225
247
|
status: resultStatus(resultSources)
|
|
@@ -232,7 +254,6 @@ async function syncWorkspaceSources(definition, store, options) {
|
|
|
232
254
|
const sources = selectedSyncSources(definition, options);
|
|
233
255
|
if (sources.length === 0) return {
|
|
234
256
|
durationMs: 0,
|
|
235
|
-
published: false,
|
|
236
257
|
sources: [],
|
|
237
258
|
status: "skipped"
|
|
238
259
|
};
|
|
@@ -253,12 +274,11 @@ async function syncWorkspaceSources(definition, store, options) {
|
|
|
253
274
|
}
|
|
254
275
|
if (runnableSources.length === 0) return {
|
|
255
276
|
durationMs: Date.now() - started,
|
|
256
|
-
published: false,
|
|
257
277
|
sources: statuses,
|
|
258
278
|
status: resultStatus(statuses)
|
|
259
279
|
};
|
|
260
280
|
const lockKeys = runnableSources.map((source) => sourceLockKey(definition, source)).sort();
|
|
261
|
-
const promise = syncWorkspaceSourcesUnlocked(definition, store, options, runnableSources, statuses, started);
|
|
281
|
+
const promise = withWorkspaceStoreMutation(store, () => syncWorkspaceSourcesUnlocked(definition, store, options, runnableSources, statuses, started));
|
|
262
282
|
for (const key of lockKeys) sourceSyncLocks.set(key, promise);
|
|
263
283
|
try {
|
|
264
284
|
return await promise;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { s as workspaceError } from "./path-DrSIenjj.js";
|
|
2
|
+
import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
|
|
3
|
+
//#region src/core/file-metadata.ts
|
|
4
|
+
function invalidMetadata(path) {
|
|
5
|
+
return workspaceError(`[vitehub] Invalid Workspace metadata for ${path}. Metadata must contain only JSON-safe plain objects, dense arrays, strings, booleans, null, and finite numbers other than negative zero.`);
|
|
6
|
+
}
|
|
7
|
+
function copyJsonValue(path, value, ancestors, normalizeOptional = false) {
|
|
8
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
9
|
+
if (typeof value === "number" && Number.isFinite(value) && !Object.is(value, -0)) return value;
|
|
10
|
+
if (typeof value !== "object" || ancestors.has(value)) throw invalidMetadata(path);
|
|
11
|
+
const array = Array.isArray(value);
|
|
12
|
+
const prototype = Object.getPrototypeOf(value);
|
|
13
|
+
if (!array && prototype !== Object.prototype && prototype !== null) throw invalidMetadata(path);
|
|
14
|
+
ancestors.add(value);
|
|
15
|
+
try {
|
|
16
|
+
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
17
|
+
const keys = Reflect.ownKeys(descriptors).filter((key) => !array || key !== "length");
|
|
18
|
+
if (array && !normalizeOptional && keys.length !== descriptors.length?.value) throw invalidMetadata(path);
|
|
19
|
+
const copy = array ? [] : {};
|
|
20
|
+
for (const [index, key] of keys.entries()) {
|
|
21
|
+
if (typeof key !== "string" || array && (normalizeOptional ? !/^(0|[1-9]\d*)$/.test(key) || Number(key) >= descriptors.length?.value : key !== String(index))) throw invalidMetadata(path);
|
|
22
|
+
const descriptor = descriptors[key];
|
|
23
|
+
if (!descriptor.enumerable || !("value" in descriptor)) throw invalidMetadata(path);
|
|
24
|
+
if (normalizeOptional && descriptor.value === void 0 && !array) continue;
|
|
25
|
+
Object.defineProperty(copy, key, {
|
|
26
|
+
value: normalizeOptional && descriptor.value === void 0 ? null : copyJsonValue(path, descriptor.value, ancestors, normalizeOptional),
|
|
27
|
+
enumerable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
configurable: true
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (array && normalizeOptional) {
|
|
33
|
+
for (let index = 0; index < descriptors.length?.value; index++) if (!Object.hasOwn(copy, index)) Object.defineProperty(copy, index, {
|
|
34
|
+
value: null,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
configurable: true
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return copy;
|
|
41
|
+
} finally {
|
|
42
|
+
ancestors.delete(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function copyJsonWorkspaceMetadata(path, metadata, normalizeOptional = false) {
|
|
46
|
+
if (metadata === void 0) return;
|
|
47
|
+
let copy;
|
|
48
|
+
try {
|
|
49
|
+
if (typeof metadata === "object" && metadata !== null && !Array.isArray(metadata)) copy = copyJsonValue(path, metadata, /* @__PURE__ */ new Set(), normalizeOptional);
|
|
50
|
+
} catch {}
|
|
51
|
+
if (!copy) throw invalidMetadata(path);
|
|
52
|
+
return copy;
|
|
53
|
+
}
|
|
54
|
+
function copyJsonFileMetadata(path, metadata, normalizeOptional = false) {
|
|
55
|
+
const copy = copyJsonWorkspaceMetadata(path, metadata, normalizeOptional);
|
|
56
|
+
if (!copy) return;
|
|
57
|
+
const source = Object.getOwnPropertyDescriptor(copy, "source");
|
|
58
|
+
if (source && typeof source.value !== "string") throw workspaceError(`[vitehub] Invalid Workspace metadata for ${path}. metadata.source must be a string when provided.`);
|
|
59
|
+
return copy;
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/core/rule-keys.ts
|
|
63
|
+
/** The rule fields that a more specific rule replaces only when it sets them. */
|
|
64
|
+
const cascadingRuleKeys = [
|
|
65
|
+
"commit",
|
|
66
|
+
"maxBytes",
|
|
67
|
+
"mediaType",
|
|
68
|
+
"write"
|
|
69
|
+
];
|
|
70
|
+
const workspaceRuleKeys = /* @__PURE__ */ new Set([...cascadingRuleKeys, "validate"]);
|
|
71
|
+
/** Rejects rule keys that ViteHub does not enforce, such as `read`, so that a rule never looks like a protection it is not. */
|
|
72
|
+
function assertWorkspaceRules(rules) {
|
|
73
|
+
for (const [pattern, rule] of Object.entries(rules ?? {})) for (const key of Object.keys(rule ?? {})) {
|
|
74
|
+
if (key === "read") throw workspaceErrorDiagnostics.WORKSPACE_R0075({ message: `[vitehub] Workspace rule "${pattern}" sets read. Workspace rules do not limit reads.` });
|
|
75
|
+
if (!workspaceRuleKeys.has(key)) throw workspaceErrorDiagnostics.WORKSPACE_R0076({ message: `[vitehub] Workspace rule "${pattern}" does not support option "${key}".` });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/storage/target.ts
|
|
80
|
+
const workspaceStoreTarget = Symbol.for("vitehub.workspace.storeTarget");
|
|
81
|
+
function forwardWorkspaceStoreTarget(source, target) {
|
|
82
|
+
const resolveTarget = source[workspaceStoreTarget];
|
|
83
|
+
if (resolveTarget) target[workspaceStoreTarget] = resolveTarget.bind(source);
|
|
84
|
+
}
|
|
85
|
+
async function resolveWorkspaceStoreTarget(source) {
|
|
86
|
+
return await source[workspaceStoreTarget]?.();
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { cascadingRuleKeys as a, assertWorkspaceRules as i, resolveWorkspaceStoreTarget as n, copyJsonFileMetadata as o, workspaceStoreTarget as r, copyJsonWorkspaceMetadata as s, forwardWorkspaceStoreTarget as t };
|
package/dist/test.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as registerWorkspace } from "./registry-CYNN623b.js";
|
|
2
2
|
export { registerWorkspace };
|
package/dist/test.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as registerWorkspace } from "./registry-
|
|
1
|
+
import { n as registerWorkspace } from "./registry-CNphafBx.js";
|
|
2
2
|
export { registerWorkspace };
|