@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.
Files changed (94) hide show
  1. package/README.md +190 -17
  2. package/dist/{ai-Bk3LLnit.js → ai-Cztw4eLk.js} +149 -29
  3. package/dist/ai-hFdsvDHC.d.ts +162 -0
  4. package/dist/ai.d.ts +2 -85
  5. package/dist/ai.js +1 -1
  6. package/dist/artifacts-store-BAV9jZpd.js +555 -0
  7. package/dist/asset-registry-CaG9b7tf.js +19 -0
  8. package/dist/cli.d.ts +31 -0
  9. package/dist/cli.js +303 -0
  10. package/dist/cloudflare-env-CKxUs2fa.js +20 -0
  11. package/dist/cloudflare.d.ts +16 -0
  12. package/dist/cloudflare.js +3 -0
  13. package/dist/collections/client.d.ts +39 -0
  14. package/dist/collections/client.js +137 -0
  15. package/dist/collections.d.ts +59 -0
  16. package/dist/collections.js +159 -0
  17. package/dist/config--r5unwPc.js +7811 -0
  18. package/dist/config-Ca5DM8fF.d.ts +28 -0
  19. package/dist/config-DCQ6y30R.js +30 -0
  20. package/dist/file-B2q9NE18.js +24 -0
  21. package/dist/{files-DbsIjBya.js → files-xy0le-_U.js} +6 -5
  22. package/dist/github-lIO6-2sH.js +194 -0
  23. package/dist/glob-DeH0dzZX.js +23 -0
  24. package/dist/host-I-_vDs05.js +370 -0
  25. package/dist/hosted-vercel-blob.d.ts +15 -0
  26. package/dist/hosted-vercel-blob.js +26 -0
  27. package/dist/hosted.d.ts +18 -0
  28. package/dist/hosted.js +30 -0
  29. package/dist/index.d.ts +137 -102
  30. package/dist/index.js +479 -594
  31. package/dist/lifecycle-Lhk3dAMt.js +176 -0
  32. package/dist/loader.d.ts +1 -1
  33. package/dist/loader.js +1 -1
  34. package/dist/nitro.d.ts +2 -31
  35. package/dist/nitro.js +2 -2
  36. package/dist/nuxt.d.ts +26 -0
  37. package/dist/nuxt.js +36 -0
  38. package/dist/path-CNI6wKIU.js +115 -0
  39. package/dist/{provider-BZuKAV4e.js → provider-CeQciesl.js} +142 -37
  40. package/dist/providers/cloudflare/artifacts-store.d.ts +1 -1
  41. package/dist/providers/cloudflare/artifacts-store.js +1 -383
  42. package/dist/providers/github/store.d.ts +6 -0
  43. package/dist/providers/github/store.js +362 -0
  44. package/dist/providers/vercel/blob-store.d.ts +1 -1
  45. package/dist/providers/vercel/blob-store.js +77 -18
  46. package/dist/publish.d.ts +3 -2
  47. package/dist/publish.js +48 -142
  48. package/dist/registry-C7DMdBXN.js +74 -0
  49. package/dist/{registry-D4Qzq26I.d.ts → registry-CoC9JxVt.d.ts} +3 -2
  50. package/dist/request-execution-C8qRcReq.js +80 -0
  51. package/dist/runtime/assets.d.ts +2 -1
  52. package/dist/runtime/assets.js +5 -5
  53. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  54. package/dist/runtime/empty-registry.d.ts +1 -1
  55. package/dist/runtime/state.d.ts +4 -21
  56. package/dist/runtime/state.js +7 -4
  57. package/dist/runtime/workspace.d.ts +2 -0
  58. package/dist/runtime/workspace.js +2 -0
  59. package/dist/runtime.d.ts +38 -0
  60. package/dist/runtime.js +643 -0
  61. package/dist/{search-DtaEyjpO.js → search-C4REyHj9.js} +2 -2
  62. package/dist/server.d.ts +65 -0
  63. package/dist/server.js +355 -0
  64. package/dist/shared-BRycRSbo.js +255 -0
  65. package/dist/source-metadata.d.ts +2 -0
  66. package/dist/source-metadata.js +2 -0
  67. package/dist/state-DSAHEsq6.d.ts +25 -0
  68. package/dist/sync-DO42ypji.js +269 -0
  69. package/dist/target-D4Bqb1eH.js +11 -0
  70. package/dist/test.d.ts +1 -1
  71. package/dist/test.js +1 -1
  72. package/dist/types-DHkae7Cb.d.ts +628 -0
  73. package/dist/use-D16tf8Ph.d.ts +86 -0
  74. package/dist/use-d_PlAdOu.js +353 -0
  75. package/dist/{utils-BtAm_K5P.js → utils-BPdaCyI6.js} +7 -3
  76. package/dist/vite-NWC9mFjI.js +1882 -0
  77. package/dist/vite.d.ts +33 -5
  78. package/dist/vite.js +2 -131
  79. package/dist/workspace-f2DBLmPZ.d.ts +6 -0
  80. package/dist/workspace-n4wBmdaM.js +1476 -0
  81. package/package.json +158 -62
  82. package/dist/asset-registry-CMuQbyvl.js +0 -14
  83. package/dist/cloudflare-env-DL94Uvpz.js +0 -12
  84. package/dist/config-CvS-7sre.js +0 -49
  85. package/dist/errors-BUL8SoFS.js +0 -21
  86. package/dist/lifecycle-uD82JeGh.js +0 -92
  87. package/dist/module-8LZUMEXC.js +0 -922
  88. package/dist/path-BVv9OXhg.js +0 -63
  89. package/dist/registry-Cnr0NoKv.js +0 -932
  90. package/dist/runtime/nitro-plugin.d.ts +0 -6
  91. package/dist/runtime/nitro-plugin.js +0 -14
  92. package/dist/sandbox-DtGXCWRq.js +0 -198
  93. package/dist/types-CwNcWTdt.d.ts +0 -378
  94. /package/dist/{chunk-DrSxFLj_.js → chunk-8H4AJuhK.js} +0 -0
package/dist/vite.d.ts CHANGED
@@ -1,16 +1,44 @@
1
- import { V as WorkspaceModuleOptions } from "./types-CwNcWTdt.js";
2
- import { NitroModule } from "nitro/types";
1
+ import { nt as WorkspaceModuleOptions } from "./types-DHkae7Cb.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
- type WorkspaceVitePlugin = Plugin & {
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 { a as refreshWorkspaceBuildState, c as workspaceSuffixPattern, i as initializeWorkspaceAssetRegistry, n as workspaceNitroModule, o as syncWorkspaceBuildAssets, r as normalizeWorkspaceOptions, s as discoverViteWorkspaceDefinitions } from "./module-8LZUMEXC.js";
2
- import { resolve } from "node:path";
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-NWC9mFjI.js";
2
+ export { createWorkspaceNitroConfig, hubWorkspace };
@@ -0,0 +1,6 @@
1
+ import { P as WorkspaceDefinition, T as Workspace } from "./types-DHkae7Cb.js";
2
+
3
+ //#region src/core/workspace.d.ts
4
+ declare function createWorkspace(definition: WorkspaceDefinition): Workspace;
5
+ //#endregion
6
+ export { createWorkspace as t };