@vite-hub/workspace 0.0.3 → 0.1.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.
Files changed (129) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +236 -58
  3. package/dist/{ai-nmHdzjCM.d.ts → ai-BW2ZhizI.d.ts} +22 -7
  4. package/dist/{ai-Ce3PtWFW.js → ai-BZyLwULx.js} +147 -66
  5. package/dist/ai.d.ts +2 -2
  6. package/dist/ai.js +1 -1
  7. package/dist/{asset-registry-CaG9b7tf.js → asset-registry-DfBV5kmw.js} +3 -2
  8. package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +19 -0
  9. package/dist/blob-database.d.ts +521 -0
  10. package/dist/blob-database.js +601 -0
  11. package/dist/cloudflare.d.ts +5 -6
  12. package/dist/cloudflare.js +1 -1
  13. package/dist/config-B7dmzDX3.js +1112 -0
  14. package/dist/{config-3I1BnsdO.d.ts → config-DLKdaFWN.d.ts} +1 -2
  15. package/dist/error-diagnostics-A_8Kp-48.js +116 -0
  16. package/dist/error-diagnostics-DY5GP47p.js +96 -0
  17. package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +354 -0
  18. package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +214 -0
  19. package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +527 -0
  20. package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +248 -0
  21. package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +179 -0
  22. package/dist/file-C0_aPWSS.js +26 -0
  23. package/dist/file-metadata-CxDy-E2H.js +58 -0
  24. package/dist/{files-QRV55OCx.js → files-C7Px8uaC.js} +21 -10
  25. package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +2278 -0
  26. package/dist/{github-CfA5vpJ5.js → github-CPxHtFB7.js} +36 -34
  27. package/dist/github-DtncTfmv-Du2S8lGF.js +4159 -0
  28. package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +2530 -0
  29. package/dist/glob--XcLlcml.js +22 -0
  30. package/dist/glob--kNYDbfU.js +30 -0
  31. package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +489 -0
  32. package/dist/host-CFnrTXTK.js +1086 -0
  33. package/dist/{hosted-C1-tTTTf.js → hosted-acMA5XyL.js} +216 -43
  34. package/dist/hosted-vercel-blob-DKntsHaf.js +12603 -0
  35. package/dist/hosted-vercel-blob.d.ts +5 -6
  36. package/dist/hosted-vercel-blob.js +1 -1
  37. package/dist/hosted.d.ts +6 -7
  38. package/dist/hosted.js +1 -1
  39. package/dist/index.d.ts +76 -64
  40. package/dist/index.js +162 -457
  41. package/dist/inspect-BoObD2cJ.js +167 -0
  42. package/dist/internal/path.d.ts +2 -0
  43. package/dist/internal/path.js +2 -0
  44. package/dist/lifecycle-BwZ7c9hb.js +596 -0
  45. package/dist/loader.d.ts +5 -6
  46. package/dist/loader.js +3 -2
  47. package/dist/mcp-resources-BREFCmtn.js +39 -0
  48. package/dist/memory-BbwOqDXl.js +248 -0
  49. package/dist/metadata-target-DZEZQGHA.js +1588 -0
  50. package/dist/mountx.d.ts +4 -6
  51. package/dist/mountx.js +10 -8
  52. package/dist/nitro.d.ts +1 -1
  53. package/dist/nitro.js +1 -1
  54. package/dist/nuxt.d.ts +13 -12
  55. package/dist/nuxt.js +10 -8
  56. package/dist/operations-BcpWr41m.js +159 -0
  57. package/dist/operations-CGqY1XeG.js +965 -0
  58. package/dist/operations-DnOwKsJT.d.ts +136 -0
  59. package/dist/operations.d.ts +53 -0
  60. package/dist/operations.js +2 -0
  61. package/dist/{path-CNI6wKIU.js → path-CNAwN7pw.js} +34 -35
  62. package/dist/path-DrSIenjj.js +59 -0
  63. package/dist/path-zHxQUbqa.d.ts +9 -0
  64. package/dist/plugins-DqQ8b4T5.d.ts +10 -0
  65. package/dist/provider-kXjfli9u.js +1457 -0
  66. package/dist/providers/github/store.d.ts +3 -5
  67. package/dist/providers/github/store.js +1 -1
  68. package/dist/registry-Bp-8UUfG.js +129 -0
  69. package/dist/{registry-BIQVCBWI.d.ts → registry-Cg1TJVVZ.d.ts} +3 -4
  70. package/dist/{request-execution-u9mgUXKX.js → request-execution-Dk9rY-Yh.js} +24 -20
  71. package/dist/rolldown-runtime-B4iAMlE-.js +35 -0
  72. package/dist/runtime/assets.d.ts +3 -5
  73. package/dist/runtime/assets.js +9 -6
  74. package/dist/runtime/empty-assets-registry.d.ts +1 -2
  75. package/dist/runtime/empty-registry.d.ts +1 -2
  76. package/dist/runtime/state.d.ts +4 -4
  77. package/dist/runtime/state.js +10 -7
  78. package/dist/runtime/workspace.d.ts +1 -1
  79. package/dist/runtime/workspace.js +1 -1
  80. package/dist/runtime.d.ts +84 -15
  81. package/dist/runtime.js +561 -108
  82. package/dist/{search-C4REyHj9.js → search-CrTmXj5h.js} +10 -9
  83. package/dist/server-BNQ-Nbjj.js +290 -0
  84. package/dist/server.d.ts +22 -34
  85. package/dist/server.js +2 -355
  86. package/dist/shared-DalXdP0i.js +2158 -0
  87. package/dist/source-metadata.d.ts +7 -1
  88. package/dist/source-metadata.js +34 -2
  89. package/dist/{state-TTqa3x3Y.d.ts → state-B8zbLi5t.d.ts} +14 -13
  90. package/dist/store-CXgmu-uw.js +1729 -0
  91. package/dist/{sync-DiuDmSGk.js → sync-CN6ec-5M.js} +62 -41
  92. package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +125 -0
  93. package/dist/test.d.ts +1 -1
  94. package/dist/test.js +1 -1
  95. package/dist/token-CO62GglH.js +61 -0
  96. package/dist/{types-60Yn149G.d.ts → types-DeK9GIxy.d.ts} +348 -49
  97. package/dist/{use-CsV3oIxH.js → use-BQj7nSz6.js} +200 -45
  98. package/dist/{use-CUFSnFCS.d.ts → use-DhwhbAVV.d.ts} +34 -12
  99. package/dist/utils-Blrh4N2n.js +545 -0
  100. package/dist/vite-BEvgU2GY.js +20909 -0
  101. package/dist/vite-CcZmMQ7S.d.ts +476 -0
  102. package/dist/vite.d.ts +2 -50
  103. package/dist/vite.js +2 -2
  104. package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +1565 -0
  105. package/dist/workspace-6pxkOuxr.js +1286 -0
  106. package/dist/workspace-BWJQBK1u.d.ts +7 -0
  107. package/package.json +90 -59
  108. package/dist/chunk-8H4AJuhK.js +0 -14
  109. package/dist/collections/client.d.ts +0 -39
  110. package/dist/collections/client.js +0 -137
  111. package/dist/collections.d.ts +0 -59
  112. package/dist/collections.js +0 -159
  113. package/dist/config-CDoyls2X.js +0 -30
  114. package/dist/config-CZLO0m9h.js +0 -7811
  115. package/dist/file-CHfsZpso.js +0 -23
  116. package/dist/glob-D0vD_wRY.js +0 -17
  117. package/dist/host-CAnbugpI.js +0 -370
  118. package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
  119. package/dist/lifecycle-BYoa9hVb.js +0 -176
  120. package/dist/provider-C3_elpEh.js +0 -599
  121. package/dist/publish.d.ts +0 -35
  122. package/dist/publish.js +0 -112
  123. package/dist/registry-CqyDTW9Y.js +0 -74
  124. package/dist/runtime-options-BsPSv5O7.js +0 -13
  125. package/dist/shared-jfogBrd5.js +0 -273
  126. package/dist/store-Bs1SLh55.js +0 -414
  127. package/dist/vite-tbfDxtlu.js +0 -2191
  128. package/dist/workspace-66SKyiec.d.ts +0 -6
  129. package/dist/workspace-C4k92Ow8.js +0 -1460
@@ -1,176 +0,0 @@
1
- import { t as __exportAll } from "./chunk-8H4AJuhK.js";
2
- import { c as normalizeWorkspacePath } from "./path-CNI6wKIU.js";
3
- import { a as normalizeWorkspaceSources, n as createSourceContext } from "./config-CZLO0m9h.js";
4
- import { n as createCurrentSnapshotFromStore } from "./store-Bs1SLh55.js";
5
- import { n as useWorkspaceAssets } from "./asset-registry-CaG9b7tf.js";
6
- import { t as files } from "./files-QRV55OCx.js";
7
- import { getViteHubErrorShape } from "@vite-hub/runtime";
8
- //#region src/lifecycle.ts
9
- var lifecycle_exports = /* @__PURE__ */ __exportAll({
10
- publishWorkspace: () => publishWorkspace,
11
- publishWorkspaceSnapshot: () => publishWorkspaceSnapshot,
12
- syncWorkspaceDefinition: () => syncWorkspaceDefinition
13
- });
14
- const buildSourcesMetaKey = "workspace:build-sources";
15
- async function publishWorkspace(definition, store, options = {}) {
16
- if (!definition.publish?.length) return;
17
- await publishWorkspaceSnapshot(definition, store, await createCurrentSnapshotFromStore(store, options.name), false);
18
- }
19
- async function publishWorkspaceSnapshot(definition, store, snapshot, durable = true) {
20
- for (const publisher of definition.publish || []) await publisher.publish({
21
- durable,
22
- workspace: definition,
23
- store,
24
- rootDir: definition.rootDir || process.cwd(),
25
- snapshot
26
- });
27
- }
28
- async function syncWorkspaceDefinition(definition, store) {
29
- const loaders = definition.loaders?.length ? definition.loaders : [files()];
30
- const hasExplicitLoaders = !!definition.loaders?.length;
31
- const ctxSource = createSourceContext(definition, void 0, store);
32
- const buildSources = normalizeWorkspaceSources(definition.sources).filter((source) => source.materialize === "build");
33
- const hasBuildSourceState = await reconcileBuildSourceMounts(store, buildSources);
34
- const bundledBuildSources = !hasExplicitLoaders ? await syncRuntimeBuildAssets(definition, store, buildSources) : void 0;
35
- if (bundledBuildSources && buildSources.every((source) => bundledBuildSources.has(source.key))) {
36
- await publishWorkspaceSnapshot(definition, store, await store.snapshot({ name: "sync" }));
37
- return;
38
- }
39
- if (!hasBuildSourceState && !hasExplicitLoaders) return;
40
- const normalizedSources = buildSources.filter((source) => !bundledBuildSources?.has(source.key)).map((source) => createMountedBuildSource(source));
41
- const ctx = {
42
- workspace: definition.name,
43
- rootDir: ctxSource.rootDir,
44
- sourceRootDir: ctxSource.sourceRootDir,
45
- sources: normalizedSources,
46
- store,
47
- parseData: async (input) => input.data,
48
- generateDigest: (input) => JSON.stringify(input),
49
- logger: console
50
- };
51
- for (const loader of loaders) await loader.load(ctx);
52
- await publishWorkspaceSnapshot(definition, store, await store.snapshot({ name: "sync" }));
53
- }
54
- async function reconcileBuildSourceMounts(store, currentSources) {
55
- const previousSources = await readSyncedBuildSources(store);
56
- const hasBuildSourceState = previousSources.length > 0 || currentSources.length > 0;
57
- const resetPaths = [...new Set([...previousSources.map((source) => source.mountPath), ...currentSources.map((source) => source.mountPath)])];
58
- for (const mountPath of resetPaths.filter(Boolean).sort((a, b) => b.length - a.length)) await store.rm(mountPath, {
59
- recursive: true,
60
- force: true
61
- });
62
- for (const source of [...previousSources, ...currentSources].filter((source) => !source.mountPath)) await removeRootBuildSourceFiles(store, source);
63
- for (const mountPath of [...new Set(currentSources.map((source) => source.mountPath))].filter(Boolean).sort((a, b) => a.length - b.length)) await store.mkdir(mountPath, { recursive: true });
64
- await store.setMeta?.(buildSourcesMetaKey, currentSources.map(({ key, mountPath }) => ({
65
- key,
66
- mountPath
67
- })));
68
- return hasBuildSourceState;
69
- }
70
- async function syncRuntimeBuildAssets(definition, store, currentSources) {
71
- if (!currentSources.length) return void 0;
72
- let assets;
73
- try {
74
- assets = useWorkspaceAssets(definition.name);
75
- } catch (error) {
76
- if (getViteHubErrorShape(error)?.code === "WORKSPACE_NOT_FOUND") return void 0;
77
- throw error;
78
- }
79
- const files = (await assets.list("", { recursive: true })).filter((entry) => entry.type === "file");
80
- const bundledPaths = new Set(files.map((entry) => entry.path));
81
- const bundledSourceByPath = /* @__PURE__ */ new Map();
82
- const bundledBuildSources = /* @__PURE__ */ new Set();
83
- for (const source of currentSources) if (await hasCompleteBundledBuildSource(definition, store, source, bundledPaths, files, bundledSourceByPath)) bundledBuildSources.add(source.key);
84
- for (const entry of files) {
85
- const sourceKey = typeof entry.metadata?.source === "string" ? entry.metadata.source : bundledSourceByPath.get(entry.path) || findBuildSourceForPath(entry.path, currentSources)?.key;
86
- await store.writeFile(entry.path, {
87
- path: entry.path,
88
- content: await assets.readFile(entry.path, { encoding: "binary" }),
89
- mediaType: entry.mediaType,
90
- metadata: sourceKey ? {
91
- ...entry.metadata,
92
- source: sourceKey
93
- } : entry.metadata
94
- });
95
- }
96
- return bundledBuildSources;
97
- }
98
- async function hasCompleteBundledBuildSource(definition, store, source, bundledPaths, bundledFiles, bundledSourceByPath) {
99
- const probeKeys = source.source.probeKeys;
100
- if (!probeKeys?.length) {
101
- const paths = bundledFiles?.filter((file) => file.metadata?.source === source.key).map((file) => file.path) ?? [];
102
- const sourcePaths = await tryListBuildSourcePaths(definition, store, source);
103
- if (sourcePaths && !sourcePaths.every((path) => paths.includes(path))) return false;
104
- for (const path of paths) bundledSourceByPath?.set(path, source.key);
105
- return paths.length > 0;
106
- }
107
- const paths = probeKeys.map((key) => normalizeWorkspacePath(`${source.mountPath}/${key}`));
108
- if (!paths.every((path) => bundledPaths.has(path))) return false;
109
- for (const path of paths) bundledSourceByPath?.set(path, source.key);
110
- return true;
111
- }
112
- async function tryListBuildSourcePaths(definition, store, source) {
113
- const ctx = createSourceContext(definition, {
114
- key: source.key,
115
- mountPath: source.mountPath
116
- }, store);
117
- try {
118
- await source.source.prepare?.(ctx);
119
- return (await source.source.getKeys(ctx)).map((key) => normalizeWorkspacePath(`${source.mountPath}/${key}`));
120
- } catch {
121
- return;
122
- }
123
- }
124
- function findBuildSourceForPath(path, sources) {
125
- const matches = sources.filter((source) => !source.mountPath || path === source.mountPath || path.startsWith(`${source.mountPath}/`)).sort((left, right) => right.mountPath.length - left.mountPath.length)[0];
126
- if (!matches?.mountPath && sources.filter((source) => !source.mountPath).length > 1) return void 0;
127
- return matches;
128
- }
129
- async function readSyncedBuildSources(store) {
130
- const value = await store.getMeta?.(buildSourcesMetaKey);
131
- if (!Array.isArray(value)) return [];
132
- return value.filter(isSyncedBuildSource);
133
- }
134
- async function removeRootBuildSourceFiles(store, source) {
135
- const entries = await store.list("", { recursive: true });
136
- await Promise.all(entries.map(async (entry) => {
137
- if (entry.type !== "file") return;
138
- if ((await store.readFile(entry.path))?.metadata?.source === source.key) await store.rm(entry.path, { force: true });
139
- }));
140
- }
141
- function isSyncedBuildSource(value) {
142
- return !!value && typeof value === "object" && typeof value.key === "string" && typeof value.mountPath === "string";
143
- }
144
- function createMountedBuildSource(source) {
145
- function getSourceContext(ctx) {
146
- return {
147
- ...ctx,
148
- mountPath: source.mountPath,
149
- source: source.key
150
- };
151
- }
152
- return {
153
- ...source.source,
154
- key: source.key,
155
- async prepare(ctx) {
156
- await source.source.prepare?.(getSourceContext(ctx));
157
- },
158
- async getKeys(ctx) {
159
- return await source.source.getKeys(getSourceContext(ctx));
160
- },
161
- async getItem(key, ctx) {
162
- const item = await source.source.getItem(key, getSourceContext(ctx));
163
- const path = normalizeWorkspacePath(`${source.mountPath}/${item.path || item.key}`);
164
- return {
165
- ...item,
166
- path,
167
- metadata: {
168
- ...item.metadata,
169
- source: source.key
170
- }
171
- };
172
- }
173
- };
174
- }
175
- //#endregion
176
- export { syncWorkspaceDefinition as n, lifecycle_exports as t };