@vite-hub/workspace 0.0.2 → 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.
Files changed (95) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +48 -2
  3. package/dist/{ai-Cztw4eLk.js → ai-BqCC8BpY.js} +15 -4
  4. package/dist/{ai-hFdsvDHC.d.ts → ai-CjxvGqM0.d.ts} +1 -1
  5. package/dist/ai.d.ts +2 -2
  6. package/dist/ai.js +1 -1
  7. package/dist/{asset-registry-CaG9b7tf.js → asset-registry-8QI3ML3K.js} +1 -1
  8. package/dist/chunk-2rV9d50f.js +35 -0
  9. package/dist/cloudflare.d.ts +4 -2
  10. package/dist/cloudflare.js +1 -2
  11. package/dist/collections.d.ts +2 -2
  12. package/dist/collections.js +1 -1
  13. package/dist/{config--r5unwPc.js → config-Bc3c4Su1.js} +213 -120
  14. package/dist/{config-DCQ6y30R.js → config-CHLLWklZ.js} +9 -3
  15. package/dist/{config-Ca5DM8fF.d.ts → config-DE9xlaIw.d.ts} +1 -1
  16. package/dist/{file-B2q9NE18.js → file-Bc1X7pco.js} +9 -10
  17. package/dist/{files-xy0le-_U.js → files-Q6xZjDHA.js} +20 -9
  18. package/dist/{github-lIO6-2sH.js → github-DHnjxQIX.js} +27 -23
  19. package/dist/glob-CEZKeZFC.js +18 -0
  20. package/dist/host-DJH8cuoU.js +1030 -0
  21. package/dist/{artifacts-store-BAV9jZpd.js → hosted-RPeJOCFz.js} +146 -30
  22. package/dist/hosted-vercel-blob-d6C8ND5j.js +23580 -0
  23. package/dist/hosted-vercel-blob.d.ts +1 -1
  24. package/dist/hosted-vercel-blob.js +1 -25
  25. package/dist/hosted.d.ts +1 -1
  26. package/dist/hosted.js +1 -29
  27. package/dist/index.d.ts +61 -78
  28. package/dist/index.js +133 -435
  29. package/dist/lifecycle-LrL3sA4n.js +316 -0
  30. package/dist/loader.d.ts +1 -1
  31. package/dist/loader.js +1 -1
  32. package/dist/metadata-target-B0tOmVW7.js +717 -0
  33. package/dist/mountx.d.ts +10 -0
  34. package/dist/mountx.js +143 -0
  35. package/dist/nitro.d.ts +1 -1
  36. package/dist/nitro.js +1 -1
  37. package/dist/nuxt.d.ts +1 -1
  38. package/dist/nuxt.js +8 -2
  39. package/dist/{path-CNI6wKIU.js → path-Cp59koVz.js} +28 -4
  40. package/dist/{provider-CeQciesl.js → provider-B1yLjCJJ.js} +194 -47
  41. package/dist/providers/github/store.d.ts +1 -1
  42. package/dist/providers/github/store.js +1 -361
  43. package/dist/publish.d.ts +1 -1
  44. package/dist/publish.js +2 -2
  45. package/dist/registry-D3yzt8HQ.js +127 -0
  46. package/dist/{registry-CoC9JxVt.d.ts → registry-Uj6IVxes.d.ts} +3 -3
  47. package/dist/{request-execution-C8qRcReq.js → request-execution-B-dSFlGB.js} +8 -4
  48. package/dist/runtime/assets.d.ts +1 -1
  49. package/dist/runtime/assets.js +4 -2
  50. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  51. package/dist/runtime/empty-registry.d.ts +1 -1
  52. package/dist/runtime/state.d.ts +4 -4
  53. package/dist/runtime/state.js +10 -7
  54. package/dist/runtime/workspace.d.ts +1 -1
  55. package/dist/runtime/workspace.js +1 -1
  56. package/dist/runtime-options-BsPSv5O7.js +13 -0
  57. package/dist/runtime-type-iEE6BjQJ.js +34 -0
  58. package/dist/runtime.d.ts +42 -7
  59. package/dist/runtime.js +276 -100
  60. package/dist/{search-C4REyHj9.js → search-BpiCF2Tw.js} +2 -2
  61. package/dist/server.d.ts +2 -2
  62. package/dist/server.js +24 -51
  63. package/dist/{shared-BRycRSbo.js → shared-DTR1Hhma.js} +115 -39
  64. package/dist/source-metadata.d.ts +9 -2
  65. package/dist/source-metadata.js +34 -2
  66. package/dist/{state-DSAHEsq6.d.ts → state-tYcRWEh2.d.ts} +13 -12
  67. package/dist/store-Dt_Jyys3.js +608 -0
  68. package/dist/{sync-DO42ypji.js → sync-DnTQwt8r.js} +6 -5
  69. package/dist/test.d.ts +1 -1
  70. package/dist/test.js +1 -1
  71. package/dist/token-CVzURBxC.js +61 -0
  72. package/dist/{types-DHkae7Cb.d.ts → types-CYuwjJ4V.d.ts} +94 -43
  73. package/dist/{use-d_PlAdOu.js → use-BTNDR5Rd.js} +147 -50
  74. package/dist/{use-D16tf8Ph.d.ts → use-BiHzt0xA.d.ts} +21 -4
  75. package/dist/vite-BptCrpv2.js +4526 -0
  76. package/dist/vite-CtA9guIM.d.ts +66 -0
  77. package/dist/vite.d.ts +2 -50
  78. package/dist/vite.js +2 -2
  79. package/dist/{workspace-n4wBmdaM.js → workspace-Dq08Yn72.js} +224 -545
  80. package/dist/{workspace-f2DBLmPZ.d.ts → workspace-Xddf4G1B.d.ts} +1 -1
  81. package/package.json +20 -38
  82. package/dist/chunk-8H4AJuhK.js +0 -14
  83. package/dist/cli.d.ts +0 -31
  84. package/dist/cli.js +0 -303
  85. package/dist/cloudflare-env-CKxUs2fa.js +0 -20
  86. package/dist/glob-DeH0dzZX.js +0 -23
  87. package/dist/host-I-_vDs05.js +0 -370
  88. package/dist/lifecycle-Lhk3dAMt.js +0 -176
  89. package/dist/providers/cloudflare/artifacts-store.d.ts +0 -6
  90. package/dist/providers/cloudflare/artifacts-store.js +0 -2
  91. package/dist/providers/vercel/blob-store.d.ts +0 -6
  92. package/dist/providers/vercel/blob-store.js +0 -235
  93. package/dist/registry-C7DMdBXN.js +0 -74
  94. package/dist/utils-BPdaCyI6.js +0 -55
  95. package/dist/vite-NWC9mFjI.js +0 -1882
@@ -1,8 +1,14 @@
1
- import { n as normalizeWorkspaceStoreOptions } from "./provider-CeQciesl.js";
1
+ import { n as normalizeWorkspaceStoreOptions } from "./provider-B1yLjCJJ.js";
2
2
  import { resolve } from "node:path";
3
3
  //#region ../internal/src/object.ts
4
4
  function isPlainObject(value) {
5
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5
+ if (value === null || Object(value) !== value || Array.isArray(value)) return false;
6
+ try {
7
+ Function.prototype.toString.call(value);
8
+ return false;
9
+ } catch {
10
+ return true;
11
+ }
6
12
  }
7
13
  //#endregion
8
14
  //#region src/config.ts
@@ -27,4 +33,4 @@ function normalizeWorkspaceOptions(options, input = {}) {
27
33
  };
28
34
  }
29
35
  //#endregion
30
- export { normalizeWorkspaceOptions as t };
36
+ export { isPlainObject as n, normalizeWorkspaceOptions as t };
@@ -1,4 +1,4 @@
1
- import { A as WorkspaceCacheOptions, Dt as WorkspaceSourceInput, Mt as WorkspaceSourceRequestDescriptor, P as WorkspaceDefinition, Z as WorkspaceMaterializeMode, qt as WorkspaceSourceSyncPolicy, rn as WorkspaceValidateMode, wt as WorkspaceSource } from "./types-DHkae7Cb.js";
1
+ import { A as WorkspaceCacheOptions, Dt as WorkspaceSourceInput, F as WorkspaceDefinition, Pt as WorkspaceSourceRequestDescriptor, Q as WorkspaceMaterializeMode, Yt as WorkspaceSourceSyncPolicy, an as WorkspaceValidateMode, wt as WorkspaceSource } from "./types-CYuwjJ4V.js";
2
2
 
3
3
  //#region src/sources/request-metadata.d.ts
4
4
  declare function getWorkspaceSourceRequestDescriptor(source: WorkspaceSource): WorkspaceSourceRequestDescriptor | undefined;
@@ -1,6 +1,7 @@
1
- import { t as __exportAll } from "./chunk-8H4AJuhK.js";
2
- import { o as normalizeSafeWorkspacePath } from "./path-CNI6wKIU.js";
3
- import { file } from "@vite-hub/source/sources/file";
1
+ import { n as __exportAll } from "./chunk-2rV9d50f.js";
2
+ import { s as normalizeSafeWorkspacePath } from "./path-Cp59koVz.js";
3
+ import { t as withWorkspaceRuntimeOptions } from "./runtime-options-BsPSv5O7.js";
4
+ import { file } from "@vite-hub/source/file";
4
5
  //#region src/sources/file.ts
5
6
  var file_exports = /* @__PURE__ */ __exportAll({ file: () => file$1 });
6
7
  function file$1(input) {
@@ -11,13 +12,11 @@ function file$1(input) {
11
12
  path: ""
12
13
  } : options.mount ?? "";
13
14
  return {
14
- ...file(options),
15
- cache: options.cache,
16
- materialize: options.materialize,
17
- mount,
18
- probeKeys: options.probeKeys || [key],
19
- sync: options.sync,
20
- validate: options.validate
15
+ ...withWorkspaceRuntimeOptions(file(options), {
16
+ ...options,
17
+ mount
18
+ }),
19
+ probeKeys: options.probeKeys || [key]
21
20
  };
22
21
  }
23
22
  //#endregion
@@ -1,5 +1,5 @@
1
- import { a as matchesAny, c as normalizeWorkspacePath } from "./path-CNI6wKIU.js";
2
- import { n as createSourceContext } from "./config--r5unwPc.js";
1
+ import { l as normalizeWorkspacePath, o as matchesAny } from "./path-Cp59koVz.js";
2
+ import { n as createSourceContext, u as prepareWorkspaceSource } from "./config-Bc3c4Su1.js";
3
3
  //#region src/loaders/files.ts
4
4
  function shouldLoad(path, options) {
5
5
  if (options.include && !matchesAny(path, options.include)) return false;
@@ -10,18 +10,26 @@ function files(options = {}) {
10
10
  return {
11
11
  name: "files",
12
12
  async load(ctx) {
13
- const sourceContext = createSourceContext({
14
- name: ctx.workspace,
15
- rootDir: ctx.rootDir,
16
- sourceRootDir: ctx.sourceRootDir
17
- }, void 0, ctx.store);
18
13
  for (const source of ctx.sources) {
19
- await source.prepare?.(sourceContext);
14
+ ctx.abortSignal?.throwIfAborted();
15
+ const sourceContext = createSourceContext({
16
+ name: ctx.workspace,
17
+ rootDir: ctx.rootDir,
18
+ sourceRootDir: ctx.sourceRootDir
19
+ }, {
20
+ key: source.key,
21
+ mountPath: ""
22
+ }, ctx.store, { abortSignal: ctx.abortSignal });
23
+ await prepareWorkspaceSource(source, sourceContext);
24
+ ctx.abortSignal?.throwIfAborted();
20
25
  for (const key of await source.getKeys(sourceContext)) {
26
+ ctx.abortSignal?.throwIfAborted();
21
27
  const rawItem = await source.getItem(key, sourceContext);
28
+ ctx.abortSignal?.throwIfAborted();
22
29
  const rawPath = normalizeWorkspacePath(rawItem.path || rawItem.key);
23
30
  if (!shouldLoad(rawPath, options)) continue;
24
31
  const transformed = options.transform ? await options.transform(rawItem) : rawItem;
32
+ ctx.abortSignal?.throwIfAborted();
25
33
  const item = typeof transformed === "string" || transformed instanceof Uint8Array ? {
26
34
  ...rawItem,
27
35
  content: transformed
@@ -34,13 +42,16 @@ function files(options = {}) {
34
42
  mediaType: item.mediaType
35
43
  });
36
44
  const metaKey = `loader:files:${source.key}:${path}:digest`;
37
- if (await ctx.store.getMeta?.(metaKey) === digest && await ctx.store.stat(path)) continue;
45
+ const previousDigest = await ctx.store.getMeta?.(metaKey);
46
+ ctx.abortSignal?.throwIfAborted();
47
+ if (previousDigest === digest && await ctx.store.stat(path)) continue;
38
48
  await ctx.store.writeFile(path, {
39
49
  path,
40
50
  content,
41
51
  mediaType: item.mediaType,
42
52
  metadata: item.metadata
43
53
  });
54
+ ctx.abortSignal?.throwIfAborted();
44
55
  await ctx.store.setMeta?.(metaKey, digest);
45
56
  }
46
57
  }
@@ -1,9 +1,11 @@
1
- import { t as __exportAll } from "./chunk-8H4AJuhK.js";
2
- import { t as getActiveCloudflareBinding } from "./cloudflare-env-CKxUs2fa.js";
3
- import { h as resolveGitHubTokenOption, s as processEnv } from "./shared-BRycRSbo.js";
4
- import { github } from "@vite-hub/source/sources/github";
1
+ import { n as __exportAll } from "./chunk-2rV9d50f.js";
2
+ import { f as resolveGitHubIgnore, u as prepareWorkspaceSource } from "./config-Bc3c4Su1.js";
3
+ import { _ as getActiveCloudflareBinding, g as resolveGitHubTokenOption, s as processEnv } from "./shared-DTR1Hhma.js";
4
+ import { t as withWorkspaceRuntimeOptions } from "./runtime-options-BsPSv5O7.js";
5
+ import { github } from "@vite-hub/source/github";
5
6
  //#region src/env.ts
6
7
  let viteLoadEnv;
8
+ const viteModuleId = "vite";
7
9
  async function resolveWorkspaceEnv(rootDir, name) {
8
10
  return (await loadWorkspaceEnv(rootDir))?.[name];
9
11
  }
@@ -13,15 +15,21 @@ async function loadWorkspaceEnv(rootDir) {
13
15
  async function loadViteEnv(rootDir) {
14
16
  if (viteLoadEnv === null) return;
15
17
  if (!viteLoadEnv) try {
16
- viteLoadEnv = (await import(
18
+ const candidate = (await import(
17
19
  /* @vite-ignore */
18
- "vite"
20
+ viteModuleId
19
21
  )).loadEnv;
22
+ if (typeof candidate !== "function") {
23
+ viteLoadEnv = null;
24
+ return;
25
+ }
26
+ viteLoadEnv = candidate;
20
27
  } catch {
21
28
  viteLoadEnv = null;
22
29
  return;
23
30
  }
24
- return viteLoadEnv("", rootDir, "");
31
+ const loadEnv = viteLoadEnv;
32
+ return loadEnv ? loadEnv("", rootDir, "") : void 0;
25
33
  }
26
34
  //#endregion
27
35
  //#region src/sources/github.ts
@@ -34,7 +42,11 @@ const githubTokenEnvNames = [
34
42
  ];
35
43
  function github$1(input) {
36
44
  if (typeof input === "function") return resolvableGitHubSource(input);
37
- const resolvedOptions = { ...input };
45
+ const options = input;
46
+ const resolvedOptions = {
47
+ ...options,
48
+ ignore: resolveGitHubIgnore(options.ignore)
49
+ };
38
50
  const baseSource = github({
39
51
  ...resolvedOptions,
40
52
  auth: createGitHubAuthResolver(resolvedOptions.auth)
@@ -52,22 +64,20 @@ function github$1(input) {
52
64
  sourceByRootAndToken.set(cacheKey, source);
53
65
  return source;
54
66
  }
55
- return {
67
+ return withWorkspaceRuntimeOptions({
56
68
  ...baseSource,
57
- cache: resolvedOptions.cache,
58
69
  fingerprint: {
59
- exclude: resolvedOptions.exclude,
70
+ ignore: resolvedOptions.ignore,
60
71
  include: resolvedOptions.include,
61
72
  ref: resolvedOptions.ref,
62
73
  repo: resolvedOptions.repo,
63
74
  root: resolvedOptions.root
64
75
  },
65
- materialize: resolvedOptions.materialize,
66
- mount: resolvedOptions.mount,
67
- sync: resolvedOptions.sync,
68
- validate: resolvedOptions.validate,
76
+ async resolveRevision(ctx) {
77
+ return await (await getSourceForRoot(ctx.rootDir)).resolveRevision?.(ctx);
78
+ },
69
79
  async prepare(ctx) {
70
- await (await getSourceForRoot(ctx.rootDir)).prepare?.(ctx);
80
+ await prepareWorkspaceSource(await getSourceForRoot(ctx.rootDir), ctx);
71
81
  },
72
82
  async getKeys(ctx) {
73
83
  return await (await getSourceForRoot(ctx.rootDir)).getKeys(ctx);
@@ -81,11 +91,8 @@ function github$1(input) {
81
91
  },
82
92
  async getMeta(key, ctx) {
83
93
  return await (await getSourceForRoot(ctx.rootDir)).getMeta?.(key, ctx);
84
- },
85
- async search(query, ctx) {
86
- return await (await getSourceForRoot(ctx.rootDir)).search?.(query, ctx) ?? [];
87
94
  }
88
- };
95
+ }, resolvedOptions);
89
96
  }
90
97
  function resolvableGitHubSource(resolve) {
91
98
  return {
@@ -100,9 +107,6 @@ function resolvableGitHubSource(resolve) {
100
107
  async getItems() {
101
108
  return [];
102
109
  },
103
- async search() {
104
- return [];
105
- },
106
110
  async resolve(ctx) {
107
111
  const options = await resolve(ctx);
108
112
  return options ? github$1(githubResolutionDefaults(options, ctx)) : false;
@@ -0,0 +1,18 @@
1
+ import { n as __exportAll } from "./chunk-2rV9d50f.js";
2
+ import { t as hasRuntimeType } from "./runtime-type-iEE6BjQJ.js";
3
+ import { t as withWorkspaceRuntimeOptions } from "./runtime-options-BsPSv5O7.js";
4
+ import { glob } from "@vite-hub/source/glob";
5
+ //#region src/sources/glob.ts
6
+ var glob_exports = /* @__PURE__ */ __exportAll({ glob: () => glob$1 });
7
+ function glob$1(options) {
8
+ return withWorkspaceRuntimeOptions(glob({
9
+ ...options,
10
+ keyCache: options.keyCache ?? !isLazySource(options)
11
+ }), options);
12
+ }
13
+ function isLazySource(options) {
14
+ if (options.materialize === "lazy" || options.materialize === "startup") return true;
15
+ return hasRuntimeType(options.mount, "object") && (options.mount?.materialize === "lazy" || options.mount?.materialize === "startup");
16
+ }
17
+ //#endregion
18
+ export { glob_exports as n, glob$1 as t };