@vite-hub/workspace 0.0.3 → 0.0.4
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/LICENSE +201 -0
- package/README.md +13 -2
- package/dist/{ai-Ce3PtWFW.js → ai-BqCC8BpY.js} +2 -2
- package/dist/{ai-nmHdzjCM.d.ts → ai-CjxvGqM0.d.ts} +1 -1
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/{asset-registry-CaG9b7tf.js → asset-registry-8QI3ML3K.js} +1 -1
- package/dist/chunk-2rV9d50f.js +35 -0
- package/dist/cloudflare.d.ts +1 -1
- package/dist/cloudflare.js +1 -1
- package/dist/collections.d.ts +2 -2
- package/dist/collections.js +1 -1
- package/dist/{config-CZLO0m9h.js → config-Bc3c4Su1.js} +213 -120
- package/dist/{config-CDoyls2X.js → config-CHLLWklZ.js} +9 -3
- package/dist/{config-3I1BnsdO.d.ts → config-DE9xlaIw.d.ts} +1 -1
- package/dist/{file-CHfsZpso.js → file-Bc1X7pco.js} +3 -3
- package/dist/{files-QRV55OCx.js → files-Q6xZjDHA.js} +20 -9
- package/dist/{github-CfA5vpJ5.js → github-DHnjxQIX.js} +24 -15
- package/dist/{glob-D0vD_wRY.js → glob-CEZKeZFC.js} +5 -4
- package/dist/host-DJH8cuoU.js +1030 -0
- package/dist/{hosted-C1-tTTTf.js → hosted-RPeJOCFz.js} +121 -31
- package/dist/hosted-vercel-blob-d6C8ND5j.js +23580 -0
- package/dist/hosted-vercel-blob.d.ts +1 -1
- package/dist/hosted-vercel-blob.js +1 -1
- package/dist/hosted.d.ts +1 -1
- package/dist/hosted.js +1 -1
- package/dist/index.d.ts +42 -51
- package/dist/index.js +124 -419
- package/dist/lifecycle-LrL3sA4n.js +316 -0
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +1 -1
- package/dist/metadata-target-B0tOmVW7.js +717 -0
- package/dist/mountx.d.ts +1 -1
- package/dist/nitro.d.ts +1 -1
- package/dist/nitro.js +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +8 -2
- package/dist/{path-CNI6wKIU.js → path-Cp59koVz.js} +28 -4
- package/dist/{provider-C3_elpEh.js → provider-B1yLjCJJ.js} +194 -47
- package/dist/providers/github/store.d.ts +1 -1
- package/dist/providers/github/store.js +1 -1
- package/dist/publish.d.ts +1 -1
- package/dist/publish.js +2 -2
- package/dist/registry-D3yzt8HQ.js +127 -0
- package/dist/{registry-BIQVCBWI.d.ts → registry-Uj6IVxes.d.ts} +3 -3
- package/dist/{request-execution-u9mgUXKX.js → request-execution-B-dSFlGB.js} +8 -4
- package/dist/runtime/assets.d.ts +1 -1
- package/dist/runtime/assets.js +4 -2
- package/dist/runtime/empty-assets-registry.d.ts +1 -1
- package/dist/runtime/empty-registry.d.ts +1 -1
- package/dist/runtime/state.d.ts +4 -4
- package/dist/runtime/state.js +10 -7
- package/dist/runtime/workspace.d.ts +1 -1
- package/dist/runtime/workspace.js +1 -1
- package/dist/runtime-type-iEE6BjQJ.js +34 -0
- package/dist/runtime.d.ts +42 -7
- package/dist/runtime.js +275 -82
- package/dist/{search-C4REyHj9.js → search-BpiCF2Tw.js} +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +23 -50
- package/dist/{shared-jfogBrd5.js → shared-DTR1Hhma.js} +97 -39
- package/dist/source-metadata.d.ts +9 -2
- package/dist/source-metadata.js +34 -2
- package/dist/{state-TTqa3x3Y.d.ts → state-tYcRWEh2.d.ts} +13 -12
- package/dist/store-Dt_Jyys3.js +608 -0
- package/dist/{sync-DiuDmSGk.js → sync-DnTQwt8r.js} +6 -5
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/token-CVzURBxC.js +61 -0
- package/dist/{types-60Yn149G.d.ts → types-CYuwjJ4V.d.ts} +94 -27
- package/dist/{use-CsV3oIxH.js → use-BTNDR5Rd.js} +145 -31
- package/dist/{use-CUFSnFCS.d.ts → use-BiHzt0xA.d.ts} +21 -4
- package/dist/vite-BptCrpv2.js +4526 -0
- package/dist/vite-CtA9guIM.d.ts +66 -0
- package/dist/vite.d.ts +2 -50
- package/dist/vite.js +2 -2
- package/dist/{workspace-C4k92Ow8.js → workspace-Dq08Yn72.js} +224 -529
- package/dist/{workspace-66SKyiec.d.ts → workspace-Xddf4G1B.d.ts} +1 -1
- package/package.json +15 -18
- package/dist/chunk-8H4AJuhK.js +0 -14
- package/dist/host-CAnbugpI.js +0 -370
- package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
- package/dist/lifecycle-BYoa9hVb.js +0 -176
- package/dist/registry-CqyDTW9Y.js +0 -74
- package/dist/store-Bs1SLh55.js +0 -414
- package/dist/vite-tbfDxtlu.js +0 -2191
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { n as __exportAll } from "./chunk-2rV9d50f.js";
|
|
2
|
+
import { l as normalizeWorkspacePath } from "./path-Cp59koVz.js";
|
|
3
|
+
import { a as normalizeWorkspaceSources, c as sourceMountIntersectsPath, n as createSourceContext, u as prepareWorkspaceSource } from "./config-Bc3c4Su1.js";
|
|
4
|
+
import { i as createCurrentSnapshotFromStore } from "./store-Dt_Jyys3.js";
|
|
5
|
+
import { n as useWorkspaceAssets } from "./asset-registry-8QI3ML3K.js";
|
|
6
|
+
import { a as invalidateWorkspaceSourceMaterialization } from "./workspace-Dq08Yn72.js";
|
|
7
|
+
import { d as sourceSnapshotMetaKey, f as sourceSnapshotOwnsAnyPath } from "./metadata-target-B0tOmVW7.js";
|
|
8
|
+
import { t as files } from "./files-Q6xZjDHA.js";
|
|
9
|
+
import { getViteHubErrorShape } from "@vite-hub/runtime";
|
|
10
|
+
//#region src/lifecycle.ts
|
|
11
|
+
var lifecycle_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
publishWorkspace: () => publishWorkspace,
|
|
13
|
+
publishWorkspaceSnapshot: () => publishWorkspaceSnapshot,
|
|
14
|
+
syncWorkspaceDefinition: () => syncWorkspaceDefinition
|
|
15
|
+
});
|
|
16
|
+
const buildSourcesMetaKey = "workspace:build-sources";
|
|
17
|
+
async function publishWorkspace(definition, store, options = {}) {
|
|
18
|
+
if (!definition.publish?.length) return;
|
|
19
|
+
await publishWorkspaceSnapshot(definition, store, await createCurrentSnapshotFromStore(store, options.name), false);
|
|
20
|
+
}
|
|
21
|
+
async function publishWorkspaceSnapshot(definition, store, snapshot, durable = true, abortSignal, trackOperation) {
|
|
22
|
+
for (const publisher of definition.publish || []) {
|
|
23
|
+
abortSignal?.throwIfAborted();
|
|
24
|
+
const operation = publisher.publish({
|
|
25
|
+
abortSignal,
|
|
26
|
+
durable,
|
|
27
|
+
workspace: definition,
|
|
28
|
+
store,
|
|
29
|
+
rootDir: definition.rootDir || process.cwd(),
|
|
30
|
+
snapshot
|
|
31
|
+
});
|
|
32
|
+
await (trackOperation ? trackOperation(operation) : operation);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const STORE_MUTATIONS = new Set([
|
|
36
|
+
"mkdir",
|
|
37
|
+
"rebase",
|
|
38
|
+
"rm",
|
|
39
|
+
"setMeta",
|
|
40
|
+
"snapshot",
|
|
41
|
+
"writeFile",
|
|
42
|
+
"writeFileConditional",
|
|
43
|
+
"writeFileStream"
|
|
44
|
+
]);
|
|
45
|
+
function createAbortFencedStore(store, abortSignal) {
|
|
46
|
+
const active = /* @__PURE__ */ new Set();
|
|
47
|
+
let settleIdle;
|
|
48
|
+
const idle = () => active.size ? new Promise((resolve) => {
|
|
49
|
+
settleIdle = resolve;
|
|
50
|
+
}) : Promise.resolve();
|
|
51
|
+
const track = (operation) => {
|
|
52
|
+
active.add(operation);
|
|
53
|
+
operation.then(() => {
|
|
54
|
+
active.delete(operation);
|
|
55
|
+
if (!active.size) {
|
|
56
|
+
settleIdle?.();
|
|
57
|
+
settleIdle = void 0;
|
|
58
|
+
}
|
|
59
|
+
}, () => {
|
|
60
|
+
active.delete(operation);
|
|
61
|
+
if (!active.size) {
|
|
62
|
+
settleIdle?.();
|
|
63
|
+
settleIdle = void 0;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return operation;
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
fenced: new Proxy(store, { get(target, property) {
|
|
70
|
+
const value = Reflect.get(target, property, target);
|
|
71
|
+
if (!STORE_MUTATIONS.has(String(property))) return value?.bind(target);
|
|
72
|
+
if (value === void 0) return void 0;
|
|
73
|
+
return (...args) => {
|
|
74
|
+
abortSignal.throwIfAborted();
|
|
75
|
+
return track(Promise.resolve(Reflect.apply(value, target, args)));
|
|
76
|
+
};
|
|
77
|
+
} }),
|
|
78
|
+
idle,
|
|
79
|
+
track
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
async function waitForFencedSync(operation, signal, idle) {
|
|
83
|
+
let removeAbortListener = () => {};
|
|
84
|
+
const aborted = new Promise((_resolve, reject) => {
|
|
85
|
+
const onAbort = () => {
|
|
86
|
+
idle().then(() => reject(signal.reason));
|
|
87
|
+
};
|
|
88
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
89
|
+
removeAbortListener = () => signal.removeEventListener("abort", onAbort);
|
|
90
|
+
if (signal.aborted) onAbort();
|
|
91
|
+
});
|
|
92
|
+
try {
|
|
93
|
+
await Promise.race([operation, aborted]);
|
|
94
|
+
} finally {
|
|
95
|
+
removeAbortListener();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function syncWorkspaceDefinition(definition, store, abortSignal) {
|
|
99
|
+
if (!abortSignal) return await syncWorkspaceDefinitionInternal(definition, store);
|
|
100
|
+
const { fenced, idle, track } = createAbortFencedStore(store, abortSignal);
|
|
101
|
+
await waitForFencedSync(syncWorkspaceDefinitionInternal(definition, fenced, abortSignal, store, track), abortSignal, idle);
|
|
102
|
+
}
|
|
103
|
+
async function syncWorkspaceDefinitionInternal(definition, store, abortSignal, materializationStore = store, trackOperation) {
|
|
104
|
+
abortSignal?.throwIfAborted();
|
|
105
|
+
const loaders = definition.loaders?.length ? definition.loaders : [files()];
|
|
106
|
+
const hasExplicitLoaders = !!definition.loaders?.length;
|
|
107
|
+
const ctxSource = createSourceContext(definition, void 0, store);
|
|
108
|
+
const sources = normalizeWorkspaceSources(definition.sources);
|
|
109
|
+
const buildSources = sources.filter((source) => source.materialize === "build");
|
|
110
|
+
const hasBuildSourceState = await reconcileBuildSourceMounts(definition, store, materializationStore, buildSources, sources.filter((source) => source.materialize === "startup"), abortSignal);
|
|
111
|
+
abortSignal?.throwIfAborted();
|
|
112
|
+
const bundledBuildSources = !hasExplicitLoaders ? await syncRuntimeBuildAssets(definition, store, buildSources, abortSignal) : void 0;
|
|
113
|
+
abortSignal?.throwIfAborted();
|
|
114
|
+
if (bundledBuildSources && buildSources.every((source) => bundledBuildSources.has(source.key))) {
|
|
115
|
+
await publishWorkspaceSnapshot(definition, store, await store.snapshot({ name: "sync" }), true, abortSignal, trackOperation);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (!hasBuildSourceState && !hasExplicitLoaders) return;
|
|
119
|
+
const normalizedSources = buildSources.filter((source) => !bundledBuildSources?.has(source.key)).map((source) => createMountedBuildSource(source));
|
|
120
|
+
const ctx = {
|
|
121
|
+
abortSignal,
|
|
122
|
+
workspace: definition.name,
|
|
123
|
+
rootDir: ctxSource.rootDir,
|
|
124
|
+
sourceRootDir: ctxSource.sourceRootDir,
|
|
125
|
+
sources: normalizedSources,
|
|
126
|
+
store,
|
|
127
|
+
parseData: async (input) => input.data,
|
|
128
|
+
generateDigest: (input) => JSON.stringify(input),
|
|
129
|
+
logger: console
|
|
130
|
+
};
|
|
131
|
+
for (const loader of loaders) {
|
|
132
|
+
abortSignal?.throwIfAborted();
|
|
133
|
+
await loader.load(ctx);
|
|
134
|
+
}
|
|
135
|
+
abortSignal?.throwIfAborted();
|
|
136
|
+
await publishWorkspaceSnapshot(definition, store, await store.snapshot({ name: "sync" }), true, abortSignal, trackOperation);
|
|
137
|
+
}
|
|
138
|
+
async function reconcileBuildSourceMounts(definition, store, materializationStore, currentSources, startupSources, abortSignal) {
|
|
139
|
+
abortSignal?.throwIfAborted();
|
|
140
|
+
const previousSources = await readSyncedBuildSources(store);
|
|
141
|
+
abortSignal?.throwIfAborted();
|
|
142
|
+
const hasBuildSourceState = previousSources.length > 0 || currentSources.length > 0;
|
|
143
|
+
const resetPaths = [...new Set([...previousSources.map((source) => source.mountPath), ...currentSources.map((source) => source.mountPath)])];
|
|
144
|
+
for (const mountPath of resetPaths.filter(Boolean).sort((a, b) => b.length - a.length)) {
|
|
145
|
+
abortSignal?.throwIfAborted();
|
|
146
|
+
const removedPaths = (await store.list(mountPath, { recursive: true })).filter((entry) => entry.type === "file").map((entry) => entry.path);
|
|
147
|
+
const affected = [];
|
|
148
|
+
for (const startup of startupSources.filter((source) => sourceMountIntersectsPath(source, mountPath))) {
|
|
149
|
+
if (!(startup.mountPath === mountPath || startup.mountPath.startsWith(`${mountPath}/`)) && await sourceSnapshotOwnsAnyPath(store, startup.key, removedPaths) === false) continue;
|
|
150
|
+
affected.push(startup);
|
|
151
|
+
}
|
|
152
|
+
await invalidateWorkspaceSourceMaterialization(definition, materializationStore, affected.map((source) => source.key));
|
|
153
|
+
for (const source of affected) await store.setMeta?.(sourceSnapshotMetaKey(source.key), {});
|
|
154
|
+
abortSignal?.throwIfAborted();
|
|
155
|
+
await store.rm(mountPath, {
|
|
156
|
+
recursive: true,
|
|
157
|
+
force: true
|
|
158
|
+
});
|
|
159
|
+
abortSignal?.throwIfAborted();
|
|
160
|
+
}
|
|
161
|
+
for (const source of [...previousSources, ...currentSources].filter((source) => !source.mountPath)) {
|
|
162
|
+
abortSignal?.throwIfAborted();
|
|
163
|
+
const removedPaths = await rootBuildSourceFilePaths(store, source);
|
|
164
|
+
const affected = [];
|
|
165
|
+
for (const startup of startupSources) {
|
|
166
|
+
if (!removedPaths.some((path) => sourceMountIntersectsPath(startup, path))) continue;
|
|
167
|
+
if (await sourceSnapshotOwnsAnyPath(store, startup.key, removedPaths) === false) continue;
|
|
168
|
+
affected.push(startup);
|
|
169
|
+
}
|
|
170
|
+
await invalidateWorkspaceSourceMaterialization(definition, materializationStore, affected.map((startup) => startup.key));
|
|
171
|
+
for (const startup of affected) await store.setMeta?.(sourceSnapshotMetaKey(startup.key), {});
|
|
172
|
+
abortSignal?.throwIfAborted();
|
|
173
|
+
await removeRootBuildSourceFiles(store, removedPaths);
|
|
174
|
+
abortSignal?.throwIfAborted();
|
|
175
|
+
}
|
|
176
|
+
for (const mountPath of [...new Set(currentSources.map((source) => source.mountPath))].filter(Boolean).sort((a, b) => a.length - b.length)) {
|
|
177
|
+
abortSignal?.throwIfAborted();
|
|
178
|
+
await store.mkdir(mountPath, { recursive: true });
|
|
179
|
+
abortSignal?.throwIfAborted();
|
|
180
|
+
}
|
|
181
|
+
abortSignal?.throwIfAborted();
|
|
182
|
+
await store.setMeta?.(buildSourcesMetaKey, currentSources.map(({ key, mountPath }) => ({
|
|
183
|
+
key,
|
|
184
|
+
mountPath
|
|
185
|
+
})));
|
|
186
|
+
return hasBuildSourceState;
|
|
187
|
+
}
|
|
188
|
+
async function syncRuntimeBuildAssets(definition, store, currentSources, abortSignal) {
|
|
189
|
+
abortSignal?.throwIfAborted();
|
|
190
|
+
if (!currentSources.length) return void 0;
|
|
191
|
+
let assets;
|
|
192
|
+
try {
|
|
193
|
+
assets = useWorkspaceAssets(definition.name);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
if (getViteHubErrorShape(error)?.code === "WORKSPACE_NOT_FOUND") return void 0;
|
|
196
|
+
throw error;
|
|
197
|
+
}
|
|
198
|
+
const entries = await assets.list("", { recursive: true });
|
|
199
|
+
abortSignal?.throwIfAborted();
|
|
200
|
+
const files = entries.filter((entry) => entry.type === "file");
|
|
201
|
+
const bundledPaths = new Set(files.map((entry) => entry.path));
|
|
202
|
+
const bundledSourceByPath = /* @__PURE__ */ new Map();
|
|
203
|
+
const bundledBuildSources = /* @__PURE__ */ new Set();
|
|
204
|
+
for (const source of currentSources) {
|
|
205
|
+
abortSignal?.throwIfAborted();
|
|
206
|
+
if (await hasCompleteBundledBuildSource(definition, store, source, bundledPaths, files, bundledSourceByPath, abortSignal)) {
|
|
207
|
+
abortSignal?.throwIfAborted();
|
|
208
|
+
bundledBuildSources.add(source.key);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const entry of files) {
|
|
212
|
+
abortSignal?.throwIfAborted();
|
|
213
|
+
const sourceKey = typeof entry.metadata?.source === "string" ? entry.metadata.source : bundledSourceByPath.get(entry.path) || findBuildSourceForPath(entry.path, currentSources)?.key;
|
|
214
|
+
const content = await assets.readFile(entry.path, { encoding: "binary" });
|
|
215
|
+
abortSignal?.throwIfAborted();
|
|
216
|
+
await store.writeFile(entry.path, {
|
|
217
|
+
path: entry.path,
|
|
218
|
+
content,
|
|
219
|
+
mediaType: entry.mediaType,
|
|
220
|
+
metadata: sourceKey ? {
|
|
221
|
+
...entry.metadata,
|
|
222
|
+
source: sourceKey
|
|
223
|
+
} : entry.metadata
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
return bundledBuildSources;
|
|
227
|
+
}
|
|
228
|
+
async function hasCompleteBundledBuildSource(definition, store, source, bundledPaths, bundledFiles, bundledSourceByPath, abortSignal) {
|
|
229
|
+
const probeKeys = source.source.probeKeys;
|
|
230
|
+
if (!probeKeys?.length) {
|
|
231
|
+
const paths = bundledFiles?.filter((file) => file.metadata?.source === source.key).map((file) => file.path) ?? [];
|
|
232
|
+
const sourcePaths = await tryListBuildSourcePaths(definition, store, source, abortSignal);
|
|
233
|
+
if (sourcePaths && !sourcePaths.every((path) => paths.includes(path))) return false;
|
|
234
|
+
for (const path of paths) bundledSourceByPath?.set(path, source.key);
|
|
235
|
+
return paths.length > 0;
|
|
236
|
+
}
|
|
237
|
+
const paths = probeKeys.map((key) => normalizeWorkspacePath(`${source.mountPath}/${key}`));
|
|
238
|
+
if (!paths.every((path) => bundledPaths.has(path))) return false;
|
|
239
|
+
for (const path of paths) bundledSourceByPath?.set(path, source.key);
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
async function tryListBuildSourcePaths(definition, store, source, abortSignal) {
|
|
243
|
+
const ctx = createSourceContext(definition, {
|
|
244
|
+
key: source.key,
|
|
245
|
+
mountPath: source.mountPath
|
|
246
|
+
}, store, { abortSignal });
|
|
247
|
+
try {
|
|
248
|
+
await prepareWorkspaceSource(source.source, ctx);
|
|
249
|
+
return (await source.source.getKeys(ctx)).map((key) => normalizeWorkspacePath(`${source.mountPath}/${key}`));
|
|
250
|
+
} catch {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function findBuildSourceForPath(path, sources) {
|
|
255
|
+
const matches = sources.filter((source) => !source.mountPath || path === source.mountPath || path.startsWith(`${source.mountPath}/`)).sort((left, right) => right.mountPath.length - left.mountPath.length)[0];
|
|
256
|
+
if (!matches?.mountPath && sources.filter((source) => !source.mountPath).length > 1) return void 0;
|
|
257
|
+
return matches;
|
|
258
|
+
}
|
|
259
|
+
async function readSyncedBuildSources(store) {
|
|
260
|
+
const value = await store.getMeta?.(buildSourcesMetaKey);
|
|
261
|
+
if (!Array.isArray(value)) return [];
|
|
262
|
+
return value.filter(isSyncedBuildSource);
|
|
263
|
+
}
|
|
264
|
+
async function rootBuildSourceFilePaths(store, source) {
|
|
265
|
+
return (await store.list("", { recursive: true })).filter((entry) => entry.type === "file" && entry.metadata?.source === source.key).map((entry) => entry.path);
|
|
266
|
+
}
|
|
267
|
+
async function removeRootBuildSourceFiles(store, paths) {
|
|
268
|
+
await Promise.all(paths.map((path) => store.rm(path, { force: true })));
|
|
269
|
+
}
|
|
270
|
+
function isSyncedBuildSource(value) {
|
|
271
|
+
return !!value && typeof value === "object" && typeof value.key === "string" && typeof value.mountPath === "string";
|
|
272
|
+
}
|
|
273
|
+
function createMountedBuildSource(source) {
|
|
274
|
+
const sourceContexts = /* @__PURE__ */ new WeakMap();
|
|
275
|
+
function getSourceContext(ctx) {
|
|
276
|
+
let sourceContext = sourceContexts.get(ctx);
|
|
277
|
+
if (sourceContext) return sourceContext;
|
|
278
|
+
sourceContext = {
|
|
279
|
+
...ctx,
|
|
280
|
+
mountPath: source.mountPath,
|
|
281
|
+
source: source.key
|
|
282
|
+
};
|
|
283
|
+
sourceContexts.set(ctx, sourceContext);
|
|
284
|
+
return sourceContext;
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
...source.source,
|
|
288
|
+
key: source.key,
|
|
289
|
+
async resolveRevision(ctx) {
|
|
290
|
+
const sourceContext = getSourceContext(ctx);
|
|
291
|
+
const revision = await source.source.resolveRevision?.(sourceContext);
|
|
292
|
+
if (revision) sourceContext.revision = revision;
|
|
293
|
+
return revision;
|
|
294
|
+
},
|
|
295
|
+
async prepare(ctx) {
|
|
296
|
+
await prepareWorkspaceSource(source.source, getSourceContext(ctx));
|
|
297
|
+
},
|
|
298
|
+
async getKeys(ctx) {
|
|
299
|
+
return await source.source.getKeys(getSourceContext(ctx));
|
|
300
|
+
},
|
|
301
|
+
async getItem(key, ctx) {
|
|
302
|
+
const item = await source.source.getItem(key, getSourceContext(ctx));
|
|
303
|
+
const path = normalizeWorkspacePath(`${source.mountPath}/${item.path || item.key}`);
|
|
304
|
+
return {
|
|
305
|
+
...item,
|
|
306
|
+
path,
|
|
307
|
+
metadata: {
|
|
308
|
+
...item.metadata,
|
|
309
|
+
source: source.key
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
//#endregion
|
|
316
|
+
export { syncWorkspaceDefinition as n, lifecycle_exports as t };
|
package/dist/loader.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { M as WorkspaceContent, Ot as WorkspaceSourceItem, X as WorkspaceLoader } from "./types-CYuwjJ4V.js";
|
|
2
2
|
|
|
3
3
|
//#region src/loaders/files.d.ts
|
|
4
4
|
interface FilesLoaderOptions {
|
package/dist/loader.js
CHANGED