@vite-hub/workspace 0.0.1 → 0.0.2
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 +190 -17
- package/dist/{ai-Bk3LLnit.js → ai-Cztw4eLk.js} +149 -29
- package/dist/ai-hFdsvDHC.d.ts +162 -0
- package/dist/ai.d.ts +2 -85
- package/dist/ai.js +1 -1
- package/dist/artifacts-store-BAV9jZpd.js +555 -0
- package/dist/asset-registry-CaG9b7tf.js +19 -0
- package/dist/cli.d.ts +31 -0
- package/dist/cli.js +303 -0
- package/dist/cloudflare-env-CKxUs2fa.js +20 -0
- package/dist/cloudflare.d.ts +16 -0
- package/dist/cloudflare.js +3 -0
- package/dist/collections/client.d.ts +39 -0
- package/dist/collections/client.js +137 -0
- package/dist/collections.d.ts +59 -0
- package/dist/collections.js +159 -0
- package/dist/config--r5unwPc.js +7811 -0
- package/dist/config-Ca5DM8fF.d.ts +28 -0
- package/dist/config-DCQ6y30R.js +30 -0
- package/dist/file-B2q9NE18.js +24 -0
- package/dist/{files-DbsIjBya.js → files-xy0le-_U.js} +6 -5
- package/dist/github-lIO6-2sH.js +194 -0
- package/dist/glob-DeH0dzZX.js +23 -0
- package/dist/host-I-_vDs05.js +370 -0
- package/dist/hosted-vercel-blob.d.ts +15 -0
- package/dist/hosted-vercel-blob.js +26 -0
- package/dist/hosted.d.ts +18 -0
- package/dist/hosted.js +30 -0
- package/dist/index.d.ts +137 -102
- package/dist/index.js +479 -594
- package/dist/lifecycle-Lhk3dAMt.js +176 -0
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +1 -1
- package/dist/nitro.d.ts +2 -31
- package/dist/nitro.js +2 -2
- package/dist/nuxt.d.ts +26 -0
- package/dist/nuxt.js +36 -0
- package/dist/path-CNI6wKIU.js +115 -0
- package/dist/{provider-BZuKAV4e.js → provider-CeQciesl.js} +142 -37
- package/dist/providers/cloudflare/artifacts-store.d.ts +1 -1
- package/dist/providers/cloudflare/artifacts-store.js +1 -383
- package/dist/providers/github/store.d.ts +6 -0
- package/dist/providers/github/store.js +362 -0
- package/dist/providers/vercel/blob-store.d.ts +1 -1
- package/dist/providers/vercel/blob-store.js +77 -18
- package/dist/publish.d.ts +3 -2
- package/dist/publish.js +48 -142
- package/dist/registry-C7DMdBXN.js +74 -0
- package/dist/{registry-D4Qzq26I.d.ts → registry-CoC9JxVt.d.ts} +3 -2
- package/dist/request-execution-C8qRcReq.js +80 -0
- package/dist/runtime/assets.d.ts +2 -1
- package/dist/runtime/assets.js +5 -5
- 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 -21
- package/dist/runtime/state.js +7 -4
- package/dist/runtime/workspace.d.ts +2 -0
- package/dist/runtime/workspace.js +2 -0
- package/dist/runtime.d.ts +38 -0
- package/dist/runtime.js +643 -0
- package/dist/{search-DtaEyjpO.js → search-C4REyHj9.js} +2 -2
- package/dist/server.d.ts +65 -0
- package/dist/server.js +355 -0
- package/dist/shared-BRycRSbo.js +255 -0
- package/dist/source-metadata.d.ts +2 -0
- package/dist/source-metadata.js +2 -0
- package/dist/state-DSAHEsq6.d.ts +25 -0
- package/dist/sync-DO42ypji.js +269 -0
- package/dist/target-D4Bqb1eH.js +11 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +1 -1
- package/dist/types-DHkae7Cb.d.ts +628 -0
- package/dist/use-D16tf8Ph.d.ts +86 -0
- package/dist/use-d_PlAdOu.js +353 -0
- package/dist/{utils-BtAm_K5P.js → utils-BPdaCyI6.js} +7 -3
- package/dist/vite-NWC9mFjI.js +1882 -0
- package/dist/vite.d.ts +33 -5
- package/dist/vite.js +2 -131
- package/dist/workspace-f2DBLmPZ.d.ts +6 -0
- package/dist/workspace-n4wBmdaM.js +1476 -0
- package/package.json +158 -62
- package/dist/asset-registry-CMuQbyvl.js +0 -14
- package/dist/cloudflare-env-DL94Uvpz.js +0 -12
- package/dist/config-CvS-7sre.js +0 -49
- package/dist/errors-BUL8SoFS.js +0 -21
- package/dist/lifecycle-uD82JeGh.js +0 -92
- package/dist/module-8LZUMEXC.js +0 -922
- package/dist/path-BVv9OXhg.js +0 -63
- package/dist/registry-Cnr0NoKv.js +0 -932
- package/dist/runtime/nitro-plugin.d.ts +0 -6
- package/dist/runtime/nitro-plugin.js +0 -14
- package/dist/sandbox-DtGXCWRq.js +0 -198
- package/dist/types-CwNcWTdt.d.ts +0 -378
- /package/dist/{chunk-DrSxFLj_.js → chunk-8H4AJuhK.js} +0 -0
package/package.json
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/workspace",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Agent-oriented filesystem state and Vite
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Agent-oriented filesystem state and Vite integration for ViteHub.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cloudflare",
|
|
7
|
+
"vercel",
|
|
8
|
+
"vite",
|
|
9
|
+
"vitehub",
|
|
10
|
+
"workspace"
|
|
11
|
+
],
|
|
7
12
|
"homepage": "https://github.com/vite-hub/vitehub#readme",
|
|
13
|
+
"bugs": "https://github.com/vite-hub/vitehub/issues",
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"author": "onmax <maximogarciamtnez@gmail.com>",
|
|
8
16
|
"repository": {
|
|
9
17
|
"type": "git",
|
|
10
18
|
"url": "git+https://github.com/vite-hub/vitehub.git",
|
|
11
19
|
"directory": "packages/workspace"
|
|
12
20
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"vite",
|
|
17
|
-
"nitro",
|
|
18
|
-
"workspace",
|
|
19
|
-
"cloudflare",
|
|
20
|
-
"vercel"
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"package.json"
|
|
21
24
|
],
|
|
22
|
-
"sideEffects": false,
|
|
23
25
|
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
24
27
|
"types": "./dist/index.d.ts",
|
|
25
28
|
"imports": {
|
|
26
29
|
"#vitehub-workspace-assets-registry": {
|
|
@@ -33,73 +36,166 @@
|
|
|
33
36
|
}
|
|
34
37
|
},
|
|
35
38
|
"exports": {
|
|
36
|
-
".":
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"./
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./dist/index.d.ts",
|
|
41
|
+
"import": "./dist/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./ai": {
|
|
44
|
+
"types": "./dist/ai.d.ts",
|
|
45
|
+
"import": "./dist/ai.js"
|
|
46
|
+
},
|
|
47
|
+
"./cli": {
|
|
48
|
+
"types": "./dist/cli.d.ts",
|
|
49
|
+
"import": "./dist/cli.js"
|
|
50
|
+
},
|
|
51
|
+
"./cloudflare": {
|
|
52
|
+
"types": "./dist/cloudflare.d.ts",
|
|
53
|
+
"import": "./dist/cloudflare.js"
|
|
54
|
+
},
|
|
55
|
+
"./collections": {
|
|
56
|
+
"types": "./dist/collections.d.ts",
|
|
57
|
+
"import": "./dist/collections.js"
|
|
58
|
+
},
|
|
59
|
+
"./collections/client": {
|
|
60
|
+
"types": "./dist/collections/client.d.ts",
|
|
61
|
+
"import": "./dist/collections/client.js"
|
|
62
|
+
},
|
|
63
|
+
"./loader": {
|
|
64
|
+
"types": "./dist/loader.d.ts",
|
|
65
|
+
"import": "./dist/loader.js"
|
|
66
|
+
},
|
|
67
|
+
"./nitro": {
|
|
68
|
+
"types": "./dist/nitro.d.ts",
|
|
69
|
+
"import": "./dist/nitro.js"
|
|
70
|
+
},
|
|
71
|
+
"./nuxt": {
|
|
72
|
+
"types": "./dist/nuxt.d.ts",
|
|
73
|
+
"import": "./dist/nuxt.js"
|
|
74
|
+
},
|
|
75
|
+
"./publish": {
|
|
76
|
+
"types": "./dist/publish.d.ts",
|
|
77
|
+
"import": "./dist/publish.js"
|
|
78
|
+
},
|
|
79
|
+
"./runtime": {
|
|
80
|
+
"types": "./dist/runtime.d.ts",
|
|
81
|
+
"import": "./dist/runtime.js"
|
|
82
|
+
},
|
|
83
|
+
"./server": {
|
|
84
|
+
"types": "./dist/server.d.ts",
|
|
85
|
+
"import": "./dist/server.js"
|
|
86
|
+
},
|
|
87
|
+
"./source-metadata": {
|
|
88
|
+
"types": "./dist/source-metadata.d.ts",
|
|
89
|
+
"import": "./dist/source-metadata.js"
|
|
90
|
+
},
|
|
91
|
+
"./test": {
|
|
92
|
+
"types": "./dist/test.d.ts",
|
|
93
|
+
"import": "./dist/test.js"
|
|
94
|
+
},
|
|
95
|
+
"./vite": {
|
|
96
|
+
"types": "./dist/vite.d.ts",
|
|
97
|
+
"import": "./dist/vite.js"
|
|
98
|
+
},
|
|
43
99
|
"./package.json": "./package.json",
|
|
44
|
-
"./internal/runtime/assets":
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"./internal/runtime/
|
|
49
|
-
|
|
50
|
-
|
|
100
|
+
"./internal/runtime/assets": {
|
|
101
|
+
"types": "./dist/runtime/assets.d.ts",
|
|
102
|
+
"import": "./dist/runtime/assets.js"
|
|
103
|
+
},
|
|
104
|
+
"./internal/runtime/empty-assets-registry": {
|
|
105
|
+
"types": "./dist/runtime/empty-assets-registry.d.ts",
|
|
106
|
+
"import": "./dist/runtime/empty-assets-registry.js"
|
|
107
|
+
},
|
|
108
|
+
"./internal/runtime/empty-registry": {
|
|
109
|
+
"types": "./dist/runtime/empty-registry.d.ts",
|
|
110
|
+
"import": "./dist/runtime/empty-registry.js"
|
|
111
|
+
},
|
|
112
|
+
"./internal/runtime/hosted": {
|
|
113
|
+
"types": "./dist/hosted.d.ts",
|
|
114
|
+
"import": "./dist/hosted.js"
|
|
115
|
+
},
|
|
116
|
+
"./internal/runtime/hosted-vercel-blob": {
|
|
117
|
+
"types": "./dist/hosted-vercel-blob.d.ts",
|
|
118
|
+
"import": "./dist/hosted-vercel-blob.js"
|
|
119
|
+
},
|
|
120
|
+
"./internal/runtime/state": {
|
|
121
|
+
"types": "./dist/runtime/state.d.ts",
|
|
122
|
+
"import": "./dist/runtime/state.js"
|
|
123
|
+
},
|
|
124
|
+
"./internal/runtime/workspace": {
|
|
125
|
+
"types": "./dist/runtime/workspace.d.ts",
|
|
126
|
+
"import": "./dist/runtime/workspace.js"
|
|
127
|
+
},
|
|
128
|
+
"./internal/stores/cloudflare-artifacts": {
|
|
129
|
+
"types": "./dist/providers/cloudflare/artifacts-store.d.ts",
|
|
130
|
+
"import": "./dist/providers/cloudflare/artifacts-store.js"
|
|
131
|
+
},
|
|
132
|
+
"./internal/stores/github": {
|
|
133
|
+
"types": "./dist/providers/github/store.d.ts",
|
|
134
|
+
"import": "./dist/providers/github/store.js"
|
|
135
|
+
},
|
|
136
|
+
"./internal/stores/vercel-blob": {
|
|
137
|
+
"types": "./dist/providers/vercel/blob-store.d.ts",
|
|
138
|
+
"import": "./dist/providers/vercel/blob-store.js"
|
|
139
|
+
}
|
|
51
140
|
},
|
|
52
|
-
"files": [
|
|
53
|
-
"dist",
|
|
54
|
-
"package.json"
|
|
55
|
-
],
|
|
56
141
|
"dependencies": {
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
142
|
+
"@vercel/nft": "^1.10.2",
|
|
143
|
+
"defu": "^6.1.7",
|
|
144
|
+
"exsolve": "^1.1.0",
|
|
145
|
+
"h3": "2.0.1-rc.25",
|
|
146
|
+
"isomorphic-git": "^1.38.7",
|
|
147
|
+
"jiti": "^2.7.0",
|
|
148
|
+
"minimatch": "^10.2.5",
|
|
149
|
+
"mrmime": "^2.0.1",
|
|
150
|
+
"ofetch": "^1.5.1",
|
|
151
|
+
"@vite-hub/runtime": "0.0.2",
|
|
152
|
+
"@vite-hub/source": "0.0.2",
|
|
153
|
+
"@vite-hub/markdown-template": "0.0.2",
|
|
154
|
+
"@vite-hub/box": "0.0.2"
|
|
155
|
+
},
|
|
156
|
+
"devDependencies": {
|
|
157
|
+
"@types/node": "^24.13.3",
|
|
158
|
+
"@vercel/blob": "^2.6.1",
|
|
159
|
+
"ai": "7.0.19",
|
|
160
|
+
"ocache": "^0.1.5",
|
|
161
|
+
"publint": "^0.3.21",
|
|
162
|
+
"typescript": "^6.0.3",
|
|
163
|
+
"vite": "^8.0.8",
|
|
164
|
+
"vite-plus": "^0.1.24",
|
|
165
|
+
"vitest": "^4.1.4",
|
|
166
|
+
"vue": "^3.5.0",
|
|
167
|
+
"@vite-hub/internal": "0.0.1",
|
|
168
|
+
"@vite-hub/shell": "0.0.2",
|
|
169
|
+
"@vite-hub/env": "0.0.2"
|
|
65
170
|
},
|
|
66
171
|
"peerDependencies": {
|
|
67
|
-
"
|
|
68
|
-
"
|
|
172
|
+
"@vercel/blob": "^2.6.1",
|
|
173
|
+
"ai": "^6.0.0 || ^7.0.0-0",
|
|
69
174
|
"vite": ">=8.0.0",
|
|
70
|
-
"
|
|
175
|
+
"vue": "^3.5.0",
|
|
176
|
+
"@vite-hub/shell": "0.0.2"
|
|
71
177
|
},
|
|
72
178
|
"peerDependenciesMeta": {
|
|
73
|
-
"@
|
|
179
|
+
"@vercel/blob": {
|
|
74
180
|
"optional": true
|
|
75
181
|
},
|
|
76
|
-
"
|
|
182
|
+
"@vite-hub/shell": {
|
|
77
183
|
"optional": true
|
|
78
184
|
},
|
|
79
185
|
"vite": {
|
|
80
186
|
"optional": true
|
|
187
|
+
},
|
|
188
|
+
"vue": {
|
|
189
|
+
"optional": true
|
|
81
190
|
}
|
|
82
191
|
},
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"ai": "^6.0.172",
|
|
86
|
-
"nitro": "3.0.260311-beta",
|
|
87
|
-
"ocache": "^0.1.4",
|
|
88
|
-
"ofetch": "^1.5.1",
|
|
89
|
-
"publint": "^0.3.15",
|
|
90
|
-
"tsdown": "^0.21.8",
|
|
91
|
-
"tsx": "^4.21.0",
|
|
92
|
-
"typescript": "^6.0.2",
|
|
93
|
-
"vite": "^8.0.8",
|
|
94
|
-
"vitest": "^4.1.4",
|
|
95
|
-
"@vite-hub/internal": "0.0.1",
|
|
96
|
-
"@vite-hub/sandbox": "0.0.1"
|
|
192
|
+
"engines": {
|
|
193
|
+
"node": ">=24.0.0"
|
|
97
194
|
},
|
|
98
195
|
"scripts": {
|
|
99
|
-
"build": "
|
|
100
|
-
"dev": "
|
|
101
|
-
"test:e2e": "tsx ./test/e2e.ts",
|
|
196
|
+
"build": "vp pack",
|
|
197
|
+
"dev": "vp pack --watch",
|
|
102
198
|
"typecheck": "tsc --noEmit -p ./tsconfig.json",
|
|
103
|
-
"test": "
|
|
199
|
+
"test": "vp run -t @vite-hub/workspace#build && vp test"
|
|
104
200
|
}
|
|
105
201
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { n as WorkspaceNotFoundError } from "./errors-BUL8SoFS.js";
|
|
2
|
-
import workspaceAssetsRegistry from "#vitehub-workspace-assets-registry";
|
|
3
|
-
//#region src/asset-registry.ts
|
|
4
|
-
let assetsRegistry = workspaceAssetsRegistry;
|
|
5
|
-
function setWorkspaceAssetsRegistry(registry) {
|
|
6
|
-
assetsRegistry = registry;
|
|
7
|
-
}
|
|
8
|
-
function useWorkspaceAssets(name) {
|
|
9
|
-
const assets = assetsRegistry[name];
|
|
10
|
-
if (!assets) throw new WorkspaceNotFoundError(name);
|
|
11
|
-
return assets;
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { useWorkspaceAssets as n, setWorkspaceAssetsRegistry as t };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
//#region ../internal/src/runtime/cloudflare-env.ts
|
|
3
|
-
let activeEnv;
|
|
4
|
-
const activeEnvStorage = new AsyncLocalStorage();
|
|
5
|
-
function getActiveCloudflareEnv() {
|
|
6
|
-
return activeEnvStorage.getStore() ?? activeEnv ?? globalThis.__env__;
|
|
7
|
-
}
|
|
8
|
-
function getActiveCloudflareBinding(name) {
|
|
9
|
-
return getActiveCloudflareEnv()?.[name];
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { getActiveCloudflareBinding as t };
|
package/dist/config-CvS-7sre.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { i as normalizeSafeWorkspacePath } from "./path-BVv9OXhg.js";
|
|
2
|
-
import { defu } from "defu";
|
|
3
|
-
//#region src/sources/config.ts
|
|
4
|
-
const liveSourcePaths = /* @__PURE__ */ new WeakMap();
|
|
5
|
-
function markLiveWorkspaceSource(source, paths) {
|
|
6
|
-
liveSourcePaths.set(source, paths);
|
|
7
|
-
return source;
|
|
8
|
-
}
|
|
9
|
-
function createSourceContext(definition) {
|
|
10
|
-
return {
|
|
11
|
-
rootDir: definition.rootDir || process.cwd(),
|
|
12
|
-
sourceRootDir: definition.sourceRootDir,
|
|
13
|
-
workspace: definition.name
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function normalizeWorkspaceSources(sources) {
|
|
17
|
-
if (!sources) return [];
|
|
18
|
-
return Object.entries(sources).map(([key, source]) => normalizeWorkspaceSource(key, source)).sort((left, right) => right.mountPath.length - left.mountPath.length || left.key.localeCompare(right.key));
|
|
19
|
-
}
|
|
20
|
-
function normalizeWorkspaceSource(key, source) {
|
|
21
|
-
const mount = normalizeSourceMount(source);
|
|
22
|
-
const cache = mount.cache ?? normalizeSourceCache(source) ?? false;
|
|
23
|
-
return {
|
|
24
|
-
key,
|
|
25
|
-
source,
|
|
26
|
-
mountPath: normalizeSafeWorkspacePath(typeof mount.path === "string" ? mount.path : key, { allowEmpty: true }),
|
|
27
|
-
materialize: mount.materialize || source.materialize || (cache ? "lazy" : "build"),
|
|
28
|
-
cache,
|
|
29
|
-
validate: mount.validate ?? source.validate ?? false,
|
|
30
|
-
livePaths: liveSourcePaths.get(source),
|
|
31
|
-
readonly: true
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function sourceMountContainsPath(source, workspacePath) {
|
|
35
|
-
return workspacePath === source.mountPath || !!source.mountPath && workspacePath.startsWith(`${source.mountPath}/`);
|
|
36
|
-
}
|
|
37
|
-
function sourceMountIntersectsPath(source, workspacePath) {
|
|
38
|
-
return !workspacePath || !source.mountPath || sourceMountContainsPath(source, workspacePath) || source.mountPath.startsWith(`${workspacePath}/`);
|
|
39
|
-
}
|
|
40
|
-
function normalizeSourceMount(source) {
|
|
41
|
-
if (typeof source.mount === "string") return { path: source.mount };
|
|
42
|
-
return source.mount || {};
|
|
43
|
-
}
|
|
44
|
-
function normalizeSourceCache(source) {
|
|
45
|
-
if (source.cache === false) return false;
|
|
46
|
-
if (source.cache) return defu(source.cache, {});
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
export { sourceMountIntersectsPath as a, sourceMountContainsPath as i, markLiveWorkspaceSource as n, normalizeWorkspaceSources as r, createSourceContext as t };
|
package/dist/errors-BUL8SoFS.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//#region src/core/errors.ts
|
|
2
|
-
var WorkspaceError = class extends Error {
|
|
3
|
-
constructor(message, options) {
|
|
4
|
-
super(message, options);
|
|
5
|
-
this.name = "WorkspaceError";
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
var WorkspaceNotFoundError = class extends WorkspaceError {
|
|
9
|
-
constructor(name) {
|
|
10
|
-
super(`[vitehub] Workspace "${name}" is not registered.`);
|
|
11
|
-
this.name = "WorkspaceNotFoundError";
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
var WorkspacePathError = class extends WorkspaceError {
|
|
15
|
-
constructor(path) {
|
|
16
|
-
super(`[vitehub] Workspace path escapes the workspace root: ${JSON.stringify(path)}.`);
|
|
17
|
-
this.name = "WorkspacePathError";
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
//#endregion
|
|
21
|
-
export { WorkspaceNotFoundError as n, WorkspacePathError as r, WorkspaceError as t };
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-DrSxFLj_.js";
|
|
2
|
-
import { o as normalizeWorkspacePath } from "./path-BVv9OXhg.js";
|
|
3
|
-
import { r as normalizeWorkspaceSources, t as createSourceContext } from "./config-CvS-7sre.js";
|
|
4
|
-
import { t as files } from "./files-DbsIjBya.js";
|
|
5
|
-
//#region src/lifecycle.ts
|
|
6
|
-
var lifecycle_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
-
publishWorkspaceSnapshot: () => publishWorkspaceSnapshot,
|
|
8
|
-
syncWorkspaceDefinition: () => syncWorkspaceDefinition
|
|
9
|
-
});
|
|
10
|
-
const buildSourcesMetaKey = "workspace:build-sources";
|
|
11
|
-
async function publishWorkspaceSnapshot(definition, store, snapshot) {
|
|
12
|
-
for (const publisher of definition.publish || []) await publisher.publish({
|
|
13
|
-
workspace: definition,
|
|
14
|
-
store,
|
|
15
|
-
rootDir: definition.rootDir || process.cwd(),
|
|
16
|
-
snapshot
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async function syncWorkspaceDefinition(definition, store) {
|
|
20
|
-
const loaders = definition.loaders?.length ? definition.loaders : [files()];
|
|
21
|
-
const hasExplicitLoaders = !!definition.loaders?.length;
|
|
22
|
-
const ctxSource = createSourceContext(definition);
|
|
23
|
-
const buildSources = normalizeWorkspaceSources(definition.sources).filter((source) => source.materialize === "build");
|
|
24
|
-
if (!await reconcileBuildSourceMounts(store, buildSources) && !hasExplicitLoaders) return;
|
|
25
|
-
const normalizedSources = buildSources.map((source) => createMountedBuildSource(source));
|
|
26
|
-
const ctx = {
|
|
27
|
-
workspace: definition.name,
|
|
28
|
-
rootDir: ctxSource.rootDir,
|
|
29
|
-
sourceRootDir: ctxSource.sourceRootDir,
|
|
30
|
-
sources: normalizedSources,
|
|
31
|
-
store,
|
|
32
|
-
parseData: async (input) => input.data,
|
|
33
|
-
generateDigest: (input) => JSON.stringify(input),
|
|
34
|
-
logger: console
|
|
35
|
-
};
|
|
36
|
-
for (const loader of loaders) await loader.load(ctx);
|
|
37
|
-
await publishWorkspaceSnapshot(definition, store, await store.snapshot({ name: "sync" }));
|
|
38
|
-
}
|
|
39
|
-
async function reconcileBuildSourceMounts(store, currentSources) {
|
|
40
|
-
const previousSources = await readSyncedBuildSources(store);
|
|
41
|
-
const hasBuildSourceState = previousSources.length > 0 || currentSources.length > 0;
|
|
42
|
-
const resetPaths = [...new Set([...previousSources.map((source) => source.mountPath), ...currentSources.map((source) => source.mountPath)])];
|
|
43
|
-
for (const mountPath of resetPaths.filter(Boolean).sort((a, b) => b.length - a.length)) await store.rm(mountPath, {
|
|
44
|
-
recursive: true,
|
|
45
|
-
force: true
|
|
46
|
-
});
|
|
47
|
-
for (const source of [...previousSources, ...currentSources].filter((source) => !source.mountPath)) await removeRootBuildSourceFiles(store, source);
|
|
48
|
-
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 });
|
|
49
|
-
await store.setMeta?.(buildSourcesMetaKey, currentSources.map(({ key, mountPath }) => ({
|
|
50
|
-
key,
|
|
51
|
-
mountPath
|
|
52
|
-
})));
|
|
53
|
-
return hasBuildSourceState;
|
|
54
|
-
}
|
|
55
|
-
async function readSyncedBuildSources(store) {
|
|
56
|
-
const value = await store.getMeta?.(buildSourcesMetaKey);
|
|
57
|
-
if (!Array.isArray(value)) return [];
|
|
58
|
-
return value.filter(isSyncedBuildSource);
|
|
59
|
-
}
|
|
60
|
-
async function removeRootBuildSourceFiles(store, source) {
|
|
61
|
-
const entries = await store.list("", { recursive: true });
|
|
62
|
-
await Promise.all(entries.map(async (entry) => {
|
|
63
|
-
if (entry.type !== "file") return;
|
|
64
|
-
if ((await store.readFile(entry.path))?.metadata?.source === source.key) await store.rm(entry.path, { force: true });
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
function isSyncedBuildSource(value) {
|
|
68
|
-
return !!value && typeof value === "object" && typeof value.key === "string" && typeof value.mountPath === "string";
|
|
69
|
-
}
|
|
70
|
-
function createMountedBuildSource(source) {
|
|
71
|
-
return {
|
|
72
|
-
...source.source,
|
|
73
|
-
key: source.key,
|
|
74
|
-
async getKeys(ctx) {
|
|
75
|
-
return await source.source.getKeys(ctx);
|
|
76
|
-
},
|
|
77
|
-
async getItem(key, ctx) {
|
|
78
|
-
const item = await source.source.getItem(key, ctx);
|
|
79
|
-
const path = normalizeWorkspacePath(`${source.mountPath}/${item.path || item.key}`);
|
|
80
|
-
return {
|
|
81
|
-
...item,
|
|
82
|
-
path,
|
|
83
|
-
metadata: {
|
|
84
|
-
...item.metadata,
|
|
85
|
-
source: source.key
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
//#endregion
|
|
92
|
-
export { syncWorkspaceDefinition as n, lifecycle_exports as t };
|