@vite-hub/workspace 0.0.1 → 0.0.3
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 +225 -17
- package/dist/{ai-Bk3LLnit.js → ai-Ce3PtWFW.js} +160 -29
- package/dist/ai-nmHdzjCM.d.ts +162 -0
- package/dist/ai.d.ts +2 -85
- package/dist/ai.js +1 -1
- package/dist/asset-registry-CaG9b7tf.js +19 -0
- package/dist/cloudflare.d.ts +18 -0
- package/dist/cloudflare.js +2 -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-3I1BnsdO.d.ts +28 -0
- package/dist/config-CDoyls2X.js +30 -0
- package/dist/config-CZLO0m9h.js +7811 -0
- package/dist/file-CHfsZpso.js +23 -0
- package/dist/{files-DbsIjBya.js → files-QRV55OCx.js} +6 -5
- package/dist/github-CfA5vpJ5.js +189 -0
- package/dist/glob-D0vD_wRY.js +17 -0
- package/dist/host-CAnbugpI.js +370 -0
- package/dist/hosted-C1-tTTTf.js +581 -0
- package/dist/{providers/vercel/blob-store.js → hosted-vercel-blob-CWBILDVo.js} +100 -19
- package/dist/hosted-vercel-blob.d.ts +15 -0
- package/dist/hosted-vercel-blob.js +2 -0
- package/dist/hosted.d.ts +18 -0
- package/dist/hosted.js +2 -0
- package/dist/index.d.ts +129 -102
- package/dist/index.js +477 -599
- package/dist/lifecycle-BYoa9hVb.js +176 -0
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js +1 -1
- package/dist/mountx.d.ts +10 -0
- package/dist/mountx.js +143 -0
- 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-C3_elpEh.js} +142 -37
- package/dist/providers/github/store.d.ts +6 -0
- package/dist/providers/github/store.js +2 -0
- package/dist/publish.d.ts +3 -2
- package/dist/publish.js +48 -142
- package/dist/{registry-D4Qzq26I.d.ts → registry-BIQVCBWI.d.ts} +3 -2
- package/dist/registry-CqyDTW9Y.js +74 -0
- package/dist/request-execution-u9mgUXKX.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-options-BsPSv5O7.js +13 -0
- package/dist/runtime.d.ts +38 -0
- package/dist/runtime.js +626 -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-jfogBrd5.js +273 -0
- package/dist/source-metadata.d.ts +2 -0
- package/dist/source-metadata.js +2 -0
- package/dist/state-TTqa3x3Y.d.ts +25 -0
- package/dist/store-Bs1SLh55.js +414 -0
- package/dist/sync-DiuDmSGk.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-60Yn149G.d.ts +612 -0
- package/dist/use-CUFSnFCS.d.ts +86 -0
- package/dist/use-CsV3oIxH.js +336 -0
- package/dist/vite-tbfDxtlu.js +2191 -0
- package/dist/vite.d.ts +33 -5
- package/dist/vite.js +2 -131
- package/dist/workspace-66SKyiec.d.ts +6 -0
- package/dist/workspace-C4k92Ow8.js +1460 -0
- package/package.json +143 -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/providers/cloudflare/artifacts-store.d.ts +0 -6
- package/dist/providers/cloudflare/artifacts-store.js +0 -384
- package/dist/providers/vercel/blob-store.d.ts +0 -6
- 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/utils-BtAm_K5P.js +0 -51
- /package/dist/{chunk-DrSxFLj_.js → chunk-8H4AJuhK.js} +0 -0
package/dist/vite.d.ts
CHANGED
|
@@ -1,16 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NitroModule } from "nitro/types";
|
|
1
|
+
import { nt as WorkspaceModuleOptions } from "./types-60Yn149G.js";
|
|
3
2
|
import { Plugin } from "vite";
|
|
4
3
|
|
|
5
4
|
//#region src/hosts/vite/plugin.d.ts
|
|
5
|
+
interface WorkspaceNitroConfigOptions {
|
|
6
|
+
aliases?: Record<string, string>;
|
|
7
|
+
command?: "build" | "serve";
|
|
8
|
+
env?: Record<string, string | undefined>;
|
|
9
|
+
hosting?: string;
|
|
10
|
+
nitro?: unknown;
|
|
11
|
+
viteRoot?: string;
|
|
12
|
+
workspace?: false | WorkspaceModuleOptions;
|
|
13
|
+
}
|
|
14
|
+
type NitroConfig = {
|
|
15
|
+
cloudflare?: {
|
|
16
|
+
wrangler?: {
|
|
17
|
+
artifacts?: Array<{
|
|
18
|
+
binding: string;
|
|
19
|
+
namespace: string;
|
|
20
|
+
}>;
|
|
21
|
+
compatibility_flags?: string[];
|
|
22
|
+
} & Record<string, unknown>;
|
|
23
|
+
} & Record<string, unknown>;
|
|
24
|
+
plugins?: unknown[];
|
|
25
|
+
rollupConfig?: {
|
|
26
|
+
external?: unknown;
|
|
27
|
+
} & Record<string, unknown>;
|
|
28
|
+
} & Record<string, unknown>;
|
|
29
|
+
declare function createWorkspaceNitroConfig(options?: WorkspaceNitroConfigOptions): Promise<NitroConfig | null>;
|
|
6
30
|
interface WorkspaceVitePluginAPI {
|
|
7
31
|
getWorkspaces: () => Array<{
|
|
8
32
|
name: string;
|
|
9
33
|
}>;
|
|
10
34
|
}
|
|
11
|
-
|
|
35
|
+
interface WorkspaceCliContributingPlugin {
|
|
36
|
+
vitehub?: {
|
|
37
|
+
cli?: () => unknown | Promise<unknown>;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
type WorkspaceVitePlugin = Plugin & WorkspaceCliContributingPlugin & {
|
|
12
41
|
api: WorkspaceVitePluginAPI;
|
|
13
|
-
nitro: NitroModule;
|
|
14
42
|
};
|
|
15
43
|
declare function hubWorkspace(options?: WorkspaceModuleOptions): WorkspaceVitePlugin;
|
|
16
44
|
declare module "vite" {
|
|
@@ -19,4 +47,4 @@ declare module "vite" {
|
|
|
19
47
|
}
|
|
20
48
|
}
|
|
21
49
|
//#endregion
|
|
22
|
-
export { WorkspaceVitePlugin, WorkspaceVitePluginAPI, hubWorkspace };
|
|
50
|
+
export { NitroConfig, WorkspaceNitroConfigOptions, WorkspaceVitePlugin, WorkspaceVitePluginAPI, createWorkspaceNitroConfig, hubWorkspace };
|
package/dist/vite.js
CHANGED
|
@@ -1,131 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region ../internal/src/build/vite.ts
|
|
4
|
-
const generatedViteHubFilesPattern = "**/.vitehub/**";
|
|
5
|
-
function createNoExternalMerger(packageName) {
|
|
6
|
-
return (current) => {
|
|
7
|
-
if (current === true) return true;
|
|
8
|
-
if (!current) return [packageName];
|
|
9
|
-
const values = Array.isArray(current) ? current : [current];
|
|
10
|
-
return values.includes(packageName) ? values : [...values, packageName];
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function isServerEnvironment(name, config) {
|
|
14
|
-
return name === "ssr" || config.consumer === "server";
|
|
15
|
-
}
|
|
16
|
-
function mergeGeneratedViteHubWatchIgnored(ignored) {
|
|
17
|
-
if (!ignored) return [generatedViteHubFilesPattern];
|
|
18
|
-
if (Array.isArray(ignored)) return ignored.includes(generatedViteHubFilesPattern) ? ignored : [...ignored, generatedViteHubFilesPattern];
|
|
19
|
-
return [ignored, generatedViteHubFilesPattern];
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/hosts/vite/plugin.ts
|
|
23
|
-
const WORKSPACE_PACKAGE_NAME = "@vite-hub/workspace";
|
|
24
|
-
const WORKSPACES_ID = "#vitehub/workspaces";
|
|
25
|
-
const WORKSPACE_PREFIX = "#vitehub/workspaces/";
|
|
26
|
-
const WORKSPACE_ASSETS_REGISTRY_ID = "#vitehub-workspace-assets-registry";
|
|
27
|
-
const WORKSPACE_REGISTRY_ID = "#vitehub-workspace-registry";
|
|
28
|
-
const RESOLVED_WORKSPACES_ID = `\0${WORKSPACES_ID}`;
|
|
29
|
-
const RESOLVED_WORKSPACE_PREFIX = `\0${WORKSPACE_PREFIX}`;
|
|
30
|
-
const RESOLVED_WORKSPACE_REGISTRY_ID = `\0${WORKSPACE_REGISTRY_ID}`;
|
|
31
|
-
const mergeNoExternal = createNoExternalMerger(WORKSPACE_PACKAGE_NAME);
|
|
32
|
-
const workspacesDirSegment = /[\\/](?:server[\\/])?workspaces(?:[\\/]|$)/;
|
|
33
|
-
function isWorkspaceFile(file) {
|
|
34
|
-
return workspaceSuffixPattern.test(file) || workspacesDirSegment.test(file);
|
|
35
|
-
}
|
|
36
|
-
function hubWorkspace(options) {
|
|
37
|
-
let resolved;
|
|
38
|
-
let resolvedOptions = false;
|
|
39
|
-
let assetsRegistryFile;
|
|
40
|
-
let manifest = { workspaces: [] };
|
|
41
|
-
let registryContents = "export default {}\n";
|
|
42
|
-
let server;
|
|
43
|
-
async function refreshManifest(root) {
|
|
44
|
-
const state = await refreshWorkspaceBuildState(root, discoverViteWorkspaceDefinitions(root));
|
|
45
|
-
manifest = state.manifest;
|
|
46
|
-
registryContents = state.registryContents;
|
|
47
|
-
}
|
|
48
|
-
function invalidateVirtualWorkspaceModules() {
|
|
49
|
-
if (!server) return;
|
|
50
|
-
const moduleGraph = server.moduleGraph;
|
|
51
|
-
const ids = [
|
|
52
|
-
RESOLVED_WORKSPACE_REGISTRY_ID,
|
|
53
|
-
RESOLVED_WORKSPACES_ID,
|
|
54
|
-
...manifest.workspaces.map((w) => `${RESOLVED_WORKSPACE_PREFIX}${w.name}`)
|
|
55
|
-
];
|
|
56
|
-
for (const id of ids) {
|
|
57
|
-
const mod = moduleGraph.getModuleById(id);
|
|
58
|
-
if (mod) moduleGraph.invalidateModule(mod);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function maybeRefreshTypesForFile(root, file) {
|
|
62
|
-
if (!isWorkspaceFile(file)) return;
|
|
63
|
-
await refreshManifest(root);
|
|
64
|
-
invalidateVirtualWorkspaceModules();
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
name: "@vite-hub/workspace/vite",
|
|
68
|
-
api: { getWorkspaces: () => manifest.workspaces },
|
|
69
|
-
nitro: workspaceNitroModule,
|
|
70
|
-
config(config) {
|
|
71
|
-
return { server: { watch: { ignored: mergeGeneratedViteHubWatchIgnored(config.server?.watch?.ignored) } } };
|
|
72
|
-
},
|
|
73
|
-
async configResolved(config) {
|
|
74
|
-
resolved = config;
|
|
75
|
-
if (config.command !== "build") process.env.VITEHUB_WORKSPACE_DEV = "true";
|
|
76
|
-
else delete process.env.VITEHUB_WORKSPACE_DEV;
|
|
77
|
-
resolvedOptions = normalizeWorkspaceOptions(config.workspace ?? options, {
|
|
78
|
-
dev: config.command !== "build",
|
|
79
|
-
env: process.env,
|
|
80
|
-
hosting: process.env.VITEHUB_HOSTING,
|
|
81
|
-
rootDir: config.root
|
|
82
|
-
});
|
|
83
|
-
assetsRegistryFile = resolve(config.root, ".vitehub/vite-runtime/workspace/assets/registry.mjs");
|
|
84
|
-
await initializeWorkspaceAssetRegistry(assetsRegistryFile);
|
|
85
|
-
await refreshManifest(config.root);
|
|
86
|
-
},
|
|
87
|
-
configEnvironment(name, config) {
|
|
88
|
-
if (!isServerEnvironment(name, config)) return;
|
|
89
|
-
return { resolve: { noExternal: mergeNoExternal(config.resolve?.noExternal) } };
|
|
90
|
-
},
|
|
91
|
-
async buildStart() {
|
|
92
|
-
if (!resolved) return;
|
|
93
|
-
await refreshManifest(resolved.root);
|
|
94
|
-
if (resolved.command !== "build" || !assetsRegistryFile) return;
|
|
95
|
-
await syncWorkspaceBuildAssets(discoverViteWorkspaceDefinitions(resolved.root), resolved.root, resolvedOptions, assetsRegistryFile);
|
|
96
|
-
},
|
|
97
|
-
configureServer(devServer) {
|
|
98
|
-
server = devServer;
|
|
99
|
-
const refresh = async (file) => await maybeRefreshTypesForFile(devServer.config.root, file);
|
|
100
|
-
devServer.watcher.on("add", refresh);
|
|
101
|
-
devServer.watcher.on("unlink", refresh);
|
|
102
|
-
},
|
|
103
|
-
async handleHotUpdate(ctx) {
|
|
104
|
-
if (!resolved) return;
|
|
105
|
-
await maybeRefreshTypesForFile(resolved.root, ctx.file);
|
|
106
|
-
},
|
|
107
|
-
resolveId(id) {
|
|
108
|
-
if (id === WORKSPACE_ASSETS_REGISTRY_ID) return assetsRegistryFile;
|
|
109
|
-
if (id === WORKSPACE_REGISTRY_ID) return RESOLVED_WORKSPACE_REGISTRY_ID;
|
|
110
|
-
if (id === WORKSPACES_ID) return RESOLVED_WORKSPACES_ID;
|
|
111
|
-
if (id.startsWith(WORKSPACE_PREFIX)) return `${RESOLVED_WORKSPACE_PREFIX}${id.slice(20)}`;
|
|
112
|
-
},
|
|
113
|
-
load(id) {
|
|
114
|
-
if (id === RESOLVED_WORKSPACE_REGISTRY_ID) return registryContents;
|
|
115
|
-
if (id === RESOLVED_WORKSPACES_ID) return `export const workspaces = ${JSON.stringify(manifest.workspaces)};\nexport default { workspaces };\n`;
|
|
116
|
-
if (id.startsWith(RESOLVED_WORKSPACE_PREFIX)) {
|
|
117
|
-
const name = id.slice(RESOLVED_WORKSPACE_PREFIX.length);
|
|
118
|
-
const workspace = manifest.workspaces.find((item) => item.name === name);
|
|
119
|
-
return `const manifest = ${JSON.stringify(workspace ? {
|
|
120
|
-
...workspace,
|
|
121
|
-
entries: []
|
|
122
|
-
} : {
|
|
123
|
-
name,
|
|
124
|
-
entries: []
|
|
125
|
-
})};\nexport default manifest;\n`;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
export { hubWorkspace };
|
|
1
|
+
import { n as hubWorkspace, t as createWorkspaceNitroConfig } from "./vite-tbfDxtlu.js";
|
|
2
|
+
export { createWorkspaceNitroConfig, hubWorkspace };
|