@vite-hub/workspace 0.0.3 → 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 (86) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +13 -2
  3. package/dist/{ai-Ce3PtWFW.js → ai-BqCC8BpY.js} +2 -2
  4. package/dist/{ai-nmHdzjCM.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 +1 -1
  10. package/dist/cloudflare.js +1 -1
  11. package/dist/collections.d.ts +2 -2
  12. package/dist/collections.js +1 -1
  13. package/dist/{config-CZLO0m9h.js → config-Bc3c4Su1.js} +213 -120
  14. package/dist/{config-CDoyls2X.js → config-CHLLWklZ.js} +9 -3
  15. package/dist/{config-3I1BnsdO.d.ts → config-DE9xlaIw.d.ts} +1 -1
  16. package/dist/{file-CHfsZpso.js → file-Bc1X7pco.js} +3 -3
  17. package/dist/{files-QRV55OCx.js → files-Q6xZjDHA.js} +20 -9
  18. package/dist/{github-CfA5vpJ5.js → github-DHnjxQIX.js} +24 -15
  19. package/dist/{glob-D0vD_wRY.js → glob-CEZKeZFC.js} +5 -4
  20. package/dist/host-DJH8cuoU.js +1030 -0
  21. package/dist/{hosted-C1-tTTTf.js → hosted-RPeJOCFz.js} +121 -31
  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 -1
  25. package/dist/hosted.d.ts +1 -1
  26. package/dist/hosted.js +1 -1
  27. package/dist/index.d.ts +42 -51
  28. package/dist/index.js +124 -419
  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 +1 -1
  34. package/dist/nitro.d.ts +1 -1
  35. package/dist/nitro.js +1 -1
  36. package/dist/nuxt.d.ts +1 -1
  37. package/dist/nuxt.js +8 -2
  38. package/dist/{path-CNI6wKIU.js → path-Cp59koVz.js} +28 -4
  39. package/dist/{provider-C3_elpEh.js → provider-B1yLjCJJ.js} +194 -47
  40. package/dist/providers/github/store.d.ts +1 -1
  41. package/dist/providers/github/store.js +1 -1
  42. package/dist/publish.d.ts +1 -1
  43. package/dist/publish.js +2 -2
  44. package/dist/registry-D3yzt8HQ.js +127 -0
  45. package/dist/{registry-BIQVCBWI.d.ts → registry-Uj6IVxes.d.ts} +3 -3
  46. package/dist/{request-execution-u9mgUXKX.js → request-execution-B-dSFlGB.js} +8 -4
  47. package/dist/runtime/assets.d.ts +1 -1
  48. package/dist/runtime/assets.js +4 -2
  49. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  50. package/dist/runtime/empty-registry.d.ts +1 -1
  51. package/dist/runtime/state.d.ts +4 -4
  52. package/dist/runtime/state.js +10 -7
  53. package/dist/runtime/workspace.d.ts +1 -1
  54. package/dist/runtime/workspace.js +1 -1
  55. package/dist/runtime-type-iEE6BjQJ.js +34 -0
  56. package/dist/runtime.d.ts +42 -7
  57. package/dist/runtime.js +275 -82
  58. package/dist/{search-C4REyHj9.js → search-BpiCF2Tw.js} +2 -2
  59. package/dist/server.d.ts +2 -2
  60. package/dist/server.js +23 -50
  61. package/dist/{shared-jfogBrd5.js → shared-DTR1Hhma.js} +97 -39
  62. package/dist/source-metadata.d.ts +9 -2
  63. package/dist/source-metadata.js +34 -2
  64. package/dist/{state-TTqa3x3Y.d.ts → state-tYcRWEh2.d.ts} +13 -12
  65. package/dist/store-Dt_Jyys3.js +608 -0
  66. package/dist/{sync-DiuDmSGk.js → sync-DnTQwt8r.js} +6 -5
  67. package/dist/test.d.ts +1 -1
  68. package/dist/test.js +1 -1
  69. package/dist/token-CVzURBxC.js +61 -0
  70. package/dist/{types-60Yn149G.d.ts → types-CYuwjJ4V.d.ts} +94 -27
  71. package/dist/{use-CsV3oIxH.js → use-BTNDR5Rd.js} +145 -31
  72. package/dist/{use-CUFSnFCS.d.ts → use-BiHzt0xA.d.ts} +21 -4
  73. package/dist/vite-BptCrpv2.js +4526 -0
  74. package/dist/vite-CtA9guIM.d.ts +66 -0
  75. package/dist/vite.d.ts +2 -50
  76. package/dist/vite.js +2 -2
  77. package/dist/{workspace-C4k92Ow8.js → workspace-Dq08Yn72.js} +224 -529
  78. package/dist/{workspace-66SKyiec.d.ts → workspace-Xddf4G1B.d.ts} +1 -1
  79. package/package.json +15 -18
  80. package/dist/chunk-8H4AJuhK.js +0 -14
  81. package/dist/host-CAnbugpI.js +0 -370
  82. package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
  83. package/dist/lifecycle-BYoa9hVb.js +0 -176
  84. package/dist/registry-CqyDTW9Y.js +0 -74
  85. package/dist/store-Bs1SLh55.js +0 -414
  86. package/dist/vite-tbfDxtlu.js +0 -2191
@@ -1,8 +1,14 @@
1
- import { n as normalizeWorkspaceStoreOptions } from "./provider-C3_elpEh.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, P as WorkspaceDefinition, Wt as WorkspaceSourceSyncPolicy, Z as WorkspaceMaterializeMode, en as WorkspaceValidateMode, kt as WorkspaceSourceRequestDescriptor, wt as WorkspaceSourceInput, xt as WorkspaceSource } from "./types-60Yn149G.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,7 +1,7 @@
1
- import { t as __exportAll } from "./chunk-8H4AJuhK.js";
2
- import { o as normalizeSafeWorkspacePath } from "./path-CNI6wKIU.js";
1
+ import { n as __exportAll } from "./chunk-2rV9d50f.js";
2
+ import { s as normalizeSafeWorkspacePath } from "./path-Cp59koVz.js";
3
3
  import { t as withWorkspaceRuntimeOptions } from "./runtime-options-BsPSv5O7.js";
4
- import { file } from "@vite-hub/source";
4
+ import { file } from "@vite-hub/source/file";
5
5
  //#region src/sources/file.ts
6
6
  var file_exports = /* @__PURE__ */ __exportAll({ file: () => file$1 });
7
7
  function file$1(input) {
@@ -1,5 +1,5 @@
1
- import { a as matchesAny, c as normalizeWorkspacePath } from "./path-CNI6wKIU.js";
2
- import { n as createSourceContext } from "./config-CZLO0m9h.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 { g as getActiveCloudflareBinding, h as resolveGitHubTokenOption, s as processEnv } from "./shared-jfogBrd5.js";
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";
3
4
  import { t as withWorkspaceRuntimeOptions } from "./runtime-options-BsPSv5O7.js";
4
- import { github } from "@vite-hub/source";
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)
@@ -55,14 +67,17 @@ function github$1(input) {
55
67
  return withWorkspaceRuntimeOptions({
56
68
  ...baseSource,
57
69
  fingerprint: {
58
- exclude: resolvedOptions.exclude,
70
+ ignore: resolvedOptions.ignore,
59
71
  include: resolvedOptions.include,
60
72
  ref: resolvedOptions.ref,
61
73
  repo: resolvedOptions.repo,
62
74
  root: resolvedOptions.root
63
75
  },
76
+ async resolveRevision(ctx) {
77
+ return await (await getSourceForRoot(ctx.rootDir)).resolveRevision?.(ctx);
78
+ },
64
79
  async prepare(ctx) {
65
- await (await getSourceForRoot(ctx.rootDir)).prepare?.(ctx);
80
+ await prepareWorkspaceSource(await getSourceForRoot(ctx.rootDir), ctx);
66
81
  },
67
82
  async getKeys(ctx) {
68
83
  return await (await getSourceForRoot(ctx.rootDir)).getKeys(ctx);
@@ -76,9 +91,6 @@ function github$1(input) {
76
91
  },
77
92
  async getMeta(key, ctx) {
78
93
  return await (await getSourceForRoot(ctx.rootDir)).getMeta?.(key, ctx);
79
- },
80
- async search(query, ctx) {
81
- return await (await getSourceForRoot(ctx.rootDir)).search?.(query, ctx) ?? [];
82
94
  }
83
95
  }, resolvedOptions);
84
96
  }
@@ -95,9 +107,6 @@ function resolvableGitHubSource(resolve) {
95
107
  async getItems() {
96
108
  return [];
97
109
  },
98
- async search() {
99
- return [];
100
- },
101
110
  async resolve(ctx) {
102
111
  const options = await resolve(ctx);
103
112
  return options ? github$1(githubResolutionDefaults(options, ctx)) : false;
@@ -1,6 +1,7 @@
1
- import { t as __exportAll } from "./chunk-8H4AJuhK.js";
1
+ import { n as __exportAll } from "./chunk-2rV9d50f.js";
2
+ import { t as hasRuntimeType } from "./runtime-type-iEE6BjQJ.js";
2
3
  import { t as withWorkspaceRuntimeOptions } from "./runtime-options-BsPSv5O7.js";
3
- import { glob } from "@vite-hub/source";
4
+ import { glob } from "@vite-hub/source/glob";
4
5
  //#region src/sources/glob.ts
5
6
  var glob_exports = /* @__PURE__ */ __exportAll({ glob: () => glob$1 });
6
7
  function glob$1(options) {
@@ -10,8 +11,8 @@ function glob$1(options) {
10
11
  }), options);
11
12
  }
12
13
  function isLazySource(options) {
13
- if (options.materialize === "lazy") return true;
14
- return typeof options.mount === "object" && options.mount?.materialize === "lazy";
14
+ if (options.materialize === "lazy" || options.materialize === "startup") return true;
15
+ return hasRuntimeType(options.mount, "object") && (options.mount?.materialize === "lazy" || options.mount?.materialize === "startup");
15
16
  }
16
17
  //#endregion
17
18
  export { glob_exports as n, glob$1 as t };