@vite-hub/workspace 0.1.0 → 0.3.0

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 (134) hide show
  1. package/README.md +164 -107
  2. package/dist/abort-BCwpdrN0.js +32 -0
  3. package/dist/blob-database.d.ts +70 -117
  4. package/dist/blob-database.js +48 -41
  5. package/dist/checkout.d.ts +128 -0
  6. package/dist/checkout.js +849 -0
  7. package/dist/cloudflare.d.ts +2 -2
  8. package/dist/cloudflare.js +1 -1
  9. package/dist/config-B-863EgC.js +15 -0
  10. package/dist/{config-B7dmzDX3.js → config-BAgL2dtB.js} +48 -84
  11. package/dist/{config-DLKdaFWN.d.ts → config-BQKcPawI.d.ts} +1 -1
  12. package/dist/discard-CNNtCozM.js +8 -0
  13. package/dist/durability.d.ts +22 -0
  14. package/dist/durability.js +70 -0
  15. package/dist/error-diagnostics-CtKjGtGb.js +188 -0
  16. package/dist/error-diagnostics-DSkCJC_L.js +266 -0
  17. package/dist/file-2pFYNtsU.js +22 -0
  18. package/dist/{files-C7Px8uaC.js → files-BOo4SbwE.js} +2 -2
  19. package/dist/files.d.ts +38 -0
  20. package/dist/files.js +6 -0
  21. package/dist/{github-CPxHtFB7.js → github-CrYp4v8k.js} +32 -5
  22. package/dist/{glob--XcLlcml.js → glob-B8YGvTrZ.js} +4 -5
  23. package/dist/{glob--kNYDbfU.js → glob-Cjxms1t7.js} +1 -1
  24. package/dist/{host-CFnrTXTK.js → host-BFBpXn0N.js} +58 -47
  25. package/dist/{hosted-acMA5XyL.js → hosted-KcUR_jPv.js} +216 -93
  26. package/dist/hosted-vercel-blob-B3-wRdUm.js +410 -0
  27. package/dist/hosted-vercel-blob.d.ts +2 -2
  28. package/dist/hosted-vercel-blob.js +1 -1
  29. package/dist/hosted.d.ts +5 -3
  30. package/dist/hosted.js +2 -2
  31. package/dist/index.d.ts +9 -51
  32. package/dist/index.js +21 -91
  33. package/dist/{lifecycle-BwZ7c9hb.js → lifecycle-B-enk_4A.js} +8 -8
  34. package/dist/lineage.d.ts +26 -0
  35. package/dist/lineage.js +76 -0
  36. package/dist/loader.d.ts +1 -1
  37. package/dist/loader.js +2 -2
  38. package/dist/{mcp-resources-BREFCmtn.js → mcp-resources-DF0F5rcL.js} +2 -2
  39. package/dist/{memory-BbwOqDXl.js → memory-BOexthyW.js} +3 -4
  40. package/dist/{metadata-target-DZEZQGHA.js → metadata-target-CWz6KHKq.js} +17 -16
  41. package/dist/object-Da1zyPCR.js +11 -0
  42. package/dist/operation-definition-8gOe-ubD.d.ts +234 -0
  43. package/dist/operations-C6FpR8Rr.js +389 -0
  44. package/dist/operations-CE2drFih.js +1234 -0
  45. package/dist/operations.d.ts +41 -4
  46. package/dist/operations.js +3 -2
  47. package/dist/{path-CNAwN7pw.js → path--wrT_Azm.js} +2 -3
  48. package/dist/path-AxMho1wo.d.ts +7 -0
  49. package/dist/{plugins-DqQ8b4T5.d.ts → plugins-C8C0auoW.d.ts} +1 -1
  50. package/dist/{provider-kXjfli9u.js → provider-9s4Ufkm5.js} +104 -82
  51. package/dist/providers/github/store.d.ts +1 -1
  52. package/dist/providers/github/store.js +1 -1
  53. package/dist/registry-B3BBm4Ts.d.ts +19 -0
  54. package/dist/{registry-Bp-8UUfG.js → registry-CNphafBx.js} +55 -20
  55. package/dist/registry-CYNN623b.d.ts +9 -0
  56. package/dist/request-scope-Dw5n8bMC.js +83 -0
  57. package/dist/results-DgkZUmTL.js +8 -0
  58. package/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-rQ84J-ij.js} +2 -3
  59. package/dist/runtime/assets.d.ts +1 -1
  60. package/dist/runtime/assets.js +3 -3
  61. package/dist/runtime/empty-assets-registry.d.ts +1 -1
  62. package/dist/runtime/empty-registry.d.ts +2 -1
  63. package/dist/runtime/registry.d.ts +2 -0
  64. package/dist/runtime/registry.js +23 -0
  65. package/dist/runtime/request.d.ts +4 -0
  66. package/dist/runtime/request.js +8 -0
  67. package/dist/runtime/state.d.ts +5 -4
  68. package/dist/runtime/state.js +8 -18
  69. package/dist/runtime/workspace.d.ts +1 -1
  70. package/dist/runtime/workspace.js +1 -1
  71. package/dist/runtime.d.ts +9 -8
  72. package/dist/runtime.js +23 -26
  73. package/dist/{search-CrTmXj5h.js → search-C_RfoM2j.js} +2 -2
  74. package/dist/{server-BNQ-Nbjj.js → server-8tGltlGz.js} +53 -40
  75. package/dist/server.d.ts +17 -8
  76. package/dist/server.js +1 -1
  77. package/dist/shared-B3_EUk89.js +848 -0
  78. package/dist/source-metadata.d.ts +6 -2
  79. package/dist/source-metadata.js +8 -8
  80. package/dist/state-BISnUf1s.d.ts +35 -0
  81. package/dist/{ai-BZyLwULx.js → state-DbrW-njQ.js} +96 -54
  82. package/dist/{store-CXgmu-uw.js → store-ybhyD38Z.js} +250 -106
  83. package/dist/{sync-CN6ec-5M.js → sync-CCD_VYC8.js} +4 -4
  84. package/dist/target-jWhTdIuF.js +89 -0
  85. package/dist/test.d.ts +1 -1
  86. package/dist/test.js +1 -1
  87. package/dist/{types-DeK9GIxy.d.ts → types-BbtwmBZ5.d.ts} +68 -14
  88. package/dist/use-C6lV3-wC.d.ts +321 -0
  89. package/dist/{use-BQj7nSz6.js → use-CSpT5W87.js} +75 -82
  90. package/dist/{utils-Blrh4N2n.js → utils-CgMZCHsX.js} +112 -41
  91. package/dist/vite.d.ts +585 -2
  92. package/dist/vite.js +21368 -1
  93. package/dist/{workspace-BWJQBK1u.d.ts → workspace-CYB2xZ1T.d.ts} +1 -1
  94. package/dist/{workspace-6pxkOuxr.js → workspace-sPWn2Jxj.js} +125 -40
  95. package/package.json +46 -55
  96. package/dist/ai-BW2ZhizI.d.ts +0 -177
  97. package/dist/ai.d.ts +0 -3
  98. package/dist/ai.js +0 -2
  99. package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +0 -19
  100. package/dist/error-diagnostics-A_8Kp-48.js +0 -116
  101. package/dist/error-diagnostics-DY5GP47p.js +0 -96
  102. package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +0 -354
  103. package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +0 -214
  104. package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +0 -527
  105. package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +0 -248
  106. package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +0 -179
  107. package/dist/file-C0_aPWSS.js +0 -26
  108. package/dist/file-metadata-CxDy-E2H.js +0 -58
  109. package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +0 -2278
  110. package/dist/github-DtncTfmv-Du2S8lGF.js +0 -4159
  111. package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +0 -2530
  112. package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +0 -489
  113. package/dist/hosted-vercel-blob-DKntsHaf.js +0 -12603
  114. package/dist/inspect-BoObD2cJ.js +0 -167
  115. package/dist/mountx.d.ts +0 -8
  116. package/dist/mountx.js +0 -145
  117. package/dist/nitro.d.ts +0 -2
  118. package/dist/nitro.js +0 -2
  119. package/dist/nuxt.d.ts +0 -27
  120. package/dist/nuxt.js +0 -38
  121. package/dist/operations-BcpWr41m.js +0 -159
  122. package/dist/operations-CGqY1XeG.js +0 -965
  123. package/dist/operations-DnOwKsJT.d.ts +0 -136
  124. package/dist/registry-Cg1TJVVZ.d.ts +0 -10
  125. package/dist/request-execution-Dk9rY-Yh.js +0 -84
  126. package/dist/shared-DalXdP0i.js +0 -2158
  127. package/dist/state-B8zbLi5t.d.ts +0 -26
  128. package/dist/target-D4Bqb1eH.js +0 -11
  129. package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +0 -125
  130. package/dist/token-CO62GglH.js +0 -61
  131. package/dist/use-DhwhbAVV.d.ts +0 -108
  132. package/dist/vite-BEvgU2GY.js +0 -20909
  133. package/dist/vite-CcZmMQ7S.d.ts +0 -476
  134. package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +0 -1565
@@ -0,0 +1,266 @@
1
+ import { defineDiagnostics } from "nostics";
2
+ //#region ../internal/src/error-diagnostics.ts
3
+ const dynamicError = { why: ({ message }) => message === void 0 ? "" : String(message) };
4
+ const internalErrorDiagnostics = /*#__PURE__*/ defineDiagnostics({
5
+ docsBase: "https://vitehub.dev/docs/development/diagnostics",
6
+ codes: {
7
+ INTERNAL_R0012: {
8
+ ...dynamicError,
9
+ fix: "Check the URL, the headers, and the credentials of the HTTP request. `error.status` holds the status that the server sent."
10
+ },
11
+ INTERNAL_R0013: {
12
+ ...dynamicError,
13
+ fix: "Check that the provider token can manage the resource in the path that the message names. `error.kind` and `error.codes` hold the provider failure."
14
+ },
15
+ INTERNAL_R0014: {
16
+ why: ({ path }) => `Cannot read Provision State from "${path}".`,
17
+ fix: "Check file access and restore valid JSON while preserving existing resource IDs."
18
+ },
19
+ INTERNAL_R0020: {
20
+ fix: "Give the operation a name like `content.publish`, a description, a section, a kind, an input schema, and a run function.",
21
+ why: ({ message }) => message === void 0 ? "" : String(message)
22
+ },
23
+ INTERNAL_R0021: {
24
+ fix: "Run `vitehub inspect definitions --kind operation` to list the operations of this app.",
25
+ why: ({ message }) => message === void 0 ? "" : String(message)
26
+ },
27
+ INTERNAL_R0022: {
28
+ fix: "Send input that matches the schema of the operation. `vitehub <namespace> <command> --help` shows the fields.",
29
+ why: ({ message }) => message === void 0 ? "" : String(message)
30
+ },
31
+ INTERNAL_R0024: {
32
+ fix: "Start the dev server with `vite dev`, or pass `--url <origin>` of a deployed app and set VITEHUB_CONSOLE_PRIVATE_KEY_<NAME> to a private key whose public key the app has in VITEHUB_CONSOLE_KEY_<NAME>.",
33
+ why: ({ message }) => message === void 0 ? "" : String(message)
34
+ },
35
+ INTERNAL_R0023: {
36
+ fix: "Ask for access to the section of this operation.",
37
+ why: ({ message }) => message === void 0 ? "" : String(message)
38
+ },
39
+ INTERNAL_B0001: {
40
+ ...dynamicError,
41
+ fix: "Give the resource that the message names another name or binding in the `vitehub()` options of its feature, so that two different Cloudflare resources do not share one name."
42
+ },
43
+ INTERNAL_B0015: {
44
+ ...dynamicError,
45
+ fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`."
46
+ },
47
+ INTERNAL_B0016: {
48
+ ...dynamicError,
49
+ fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
50
+ },
51
+ INTERNAL_B0017: {
52
+ ...dynamicError,
53
+ fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
54
+ },
55
+ INTERNAL_B0018: {
56
+ ...dynamicError,
57
+ fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
58
+ },
59
+ INTERNAL_B0019: {
60
+ ...dynamicError,
61
+ fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
62
+ },
63
+ INTERNAL_B0020: {
64
+ ...dynamicError,
65
+ fix: "Correct the field that the message names in the `package.json` of a runtime dependency of the app, such as a workspace package, or run `pnpm install` again to restore an installed package."
66
+ },
67
+ INTERNAL_B0021: {
68
+ ...dynamicError,
69
+ fix: "Install the package that the message names in the app, for example with `pnpm add <name>`, then build again."
70
+ },
71
+ INTERNAL_B0022: {
72
+ ...dynamicError,
73
+ fix: "Install one version of the package that the message names, for example with `pnpm dedupe` or an `overrides` entry in `package.json`."
74
+ },
75
+ INTERNAL_B0025: {
76
+ ...dynamicError,
77
+ fix: "Replace the `new URL(\"./...\", import.meta.url)` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import` of that file."
78
+ },
79
+ INTERNAL_B0026: {
80
+ ...dynamicError,
81
+ fix: "Replace the computed `import()` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import` or with `import(\"<literal path>\")`."
82
+ },
83
+ INTERNAL_B0027: {
84
+ ...dynamicError,
85
+ fix: "Replace the computed `require()` in the project-root `main.ts`, or in a Schedule file of `server/schedules/` and the files it imports, with a static `import`."
86
+ },
87
+ INTERNAL_B0028: {
88
+ ...dynamicError,
89
+ fix: "Wait for the other build of this app to finish, or stop the process that the message names, then build again."
90
+ },
91
+ INTERNAL_B0029: {
92
+ ...dynamicError,
93
+ fix: "Stop the other builds that write the same Deno output folder, delete the `.vitehub-lock` folder next to that output folder, such as `.output.vitehub-lock`, then build again."
94
+ },
95
+ INTERNAL_B0031: {
96
+ ...dynamicError,
97
+ fix: "Import `./schedule/deno-cron.mjs` at the top level of the project-root `main.ts`, for example with `await import(new URL(\"./schedule/deno-cron.mjs\", import.meta.url).href)` outside any condition."
98
+ },
99
+ INTERNAL_B0032: {
100
+ ...dynamicError,
101
+ fix: "Import `./server/index.mjs` at the top level of the project-root `main.ts`, for example with `await import(new URL(\"./server/index.mjs\", import.meta.url).href)` outside any condition."
102
+ },
103
+ INTERNAL_B0035: {
104
+ ...dynamicError,
105
+ fix: "Delete the provider output folder that holds the file that the message names, such as `dist/<app>` for Cloudflare, and build again."
106
+ },
107
+ INTERNAL_B0039: {
108
+ ...dynamicError,
109
+ fix: "Fix the build error that ViteHub showed before this one. ViteHub stops writing the provider output when another part of the build fails."
110
+ },
111
+ INTERNAL_B0040: {
112
+ ...dynamicError,
113
+ fix: "Remove the custom Nitro `output.serverDir`, so that the Nitro preset of the host writes the server entry that the message names."
114
+ },
115
+ INTERNAL_B0043: {
116
+ ...dynamicError,
117
+ fix: "Delete the build output folder, such as `.output` or `.vercel/output`, and build again."
118
+ },
119
+ INTERNAL_B0046: {
120
+ ...dynamicError,
121
+ fix: "Install the package that the message names in the app, for example with `pnpm add <name>`, then build again."
122
+ },
123
+ INTERNAL_B0047: {
124
+ ...dynamicError,
125
+ fix: "Correct the `package.json` file that the message names so that it holds one JSON object, or run `pnpm install` again to restore an installed package."
126
+ },
127
+ INTERNAL_B0048: {
128
+ fix: "Rename one of the two operations. A name is `<section>.<verb>` and is unique in the app.",
129
+ why: ({ message }) => message === void 0 ? "" : String(message)
130
+ },
131
+ INTERNAL_B0049: {
132
+ fix: "Set `cli: { namespace, command }` on one of the two operations.",
133
+ why: ({ message }) => message === void 0 ? "" : String(message)
134
+ },
135
+ INTERNAL_B0050: {
136
+ fix: "Rename one of the two operations, or set `mcp: false` on it. MCP tool names replace every character outside letters, digits, `_`, and `-` with `_`.",
137
+ why: ({ message }) => message === void 0 ? "" : String(message)
138
+ },
139
+ INTERNAL_B0051: {
140
+ why: ({ field, generated, name, path, project, scope }) => `The Cloudflare ${path} entry "${name}"${scope} is written by ViteHub and by the project's Wrangler config with a different ${field}: ${generated} and ${project}.`,
141
+ fix: "Remove the entry from the project's Wrangler config, since ViteHub writes it, or give one of them another name."
142
+ },
143
+ INTERNAL_B0052: {
144
+ why: ({ column, section }) => `The column "${column}" of the Console section "${section}" needs both \`format: "switch"\` and a \`switch\` operation name such as "skills.set".`,
145
+ fix: "Give a switch column `format: \"switch\"` and `switch: { operation, input }` with a registered operation name, or remove both."
146
+ },
147
+ INTERNAL_R0025: {
148
+ fix: "Start `vite dev` in the project that you run the command from, or pass `--url` of that server.",
149
+ why: ({ message }) => message === void 0 ? "" : String(message)
150
+ },
151
+ INTERNAL_R0026: {
152
+ why: "The server parsed a destructive operation that the CLI did not confirm.",
153
+ fix: "Review the operation, then run it again with --yes to confirm the change."
154
+ },
155
+ INTERNAL_C0001: {
156
+ ...dynamicError,
157
+ fix: "Rename or remove one of the two files that the message lists. ViteHub takes the Definition name from the file path."
158
+ },
159
+ INTERNAL_C0002: {
160
+ ...dynamicError,
161
+ fix: "Rename or remove one of the two files that the message lists. ViteHub takes the Definition name from the file path."
162
+ },
163
+ INTERNAL_R0001: {
164
+ ...dynamicError,
165
+ fix: "Set `host` in `vitehub()`, or in the `vitehub` options of `nuxt.config.ts`, to `cloudflare`, `deno`, `netlify`, `node`, or `vercel`. Or remove `host` so that ViteHub finds the host from the environment."
166
+ },
167
+ INTERNAL_R0002: {
168
+ ...dynamicError,
169
+ fix: "Stop using the feature that the message names, or set `host` in `vitehub()` to a host that provides it. For Blob, you can also set `blob: { driver: \"s3\" }` with a remote store."
170
+ },
171
+ INTERNAL_R0004: {
172
+ ...dynamicError,
173
+ fix: "Set a larger `maxResponseBytes` on the HTTP request, such as the `fetch()` Source options, or ask the server for a smaller response."
174
+ },
175
+ INTERNAL_R0005: {
176
+ ...dynamicError,
177
+ fix: "Set `method` of the HTTP request to `GET`, `HEAD`, or `POST`."
178
+ },
179
+ INTERNAL_R0006: {
180
+ ...dynamicError,
181
+ fix: "Set `timeout` of the HTTP request to a number of milliseconds from 1 to 2147483647, or remove it to use the default."
182
+ },
183
+ INTERNAL_R0007: {
184
+ ...dynamicError,
185
+ fix: "Set `maxResponseBytes` of the HTTP request to a positive integer no greater than the limit that the message names, or remove it to use the default."
186
+ },
187
+ INTERNAL_R0008: {
188
+ ...dynamicError,
189
+ fix: "Make the value that the message names match its schema: the input, query, or body that you send, or the response schema that you declare for the request."
190
+ },
191
+ INTERNAL_R0009: {
192
+ ...dynamicError,
193
+ fix: "Use a Standard Schema whose `validate()` returns `{ value }` or `{ issues }` for the value that the message names."
194
+ },
195
+ INTERNAL_R0010: {
196
+ ...dynamicError,
197
+ fix: "Run the command again. If the error stays, check the Cloudflare API status, because Cloudflare sent a response that ViteHub cannot read."
198
+ },
199
+ INTERNAL_R0011: {
200
+ ...dynamicError,
201
+ fix: "Pass an h3 app, an object with a `fetch(request)` method, or a fetch function as `app`."
202
+ },
203
+ INTERNAL_CONSOLE_KEY_NAME_INVALID: {
204
+ why: ({ name }) => `[vitehub] The Console key name ${JSON.stringify(name)} must be 1 to 64 of A-Z, 0-9, and _.`,
205
+ fix: "Name the Console key with 1 to 64 characters from A-Z, 0-9, and _, such as `CI`. The app reads its public key from `VITEHUB_CONSOLE_KEY_<NAME>`."
206
+ },
207
+ INTERNAL_CONSOLE_PRIVATE_KEY_INVALID: {
208
+ why: "[vitehub] A Console private key is the 32-byte Ed25519 seed as base64url (43 characters). `vitehub secret console-key` makes one.",
209
+ fix: "Run `vitehub secret console-key` and use the 43-character private key that it prints, without spaces or quotes."
210
+ },
211
+ INTERNAL_CONSOLE_PRIVATE_KEY_VARIABLES_MULTIPLE: {
212
+ why: ({ prefix, variables }) => `[vitehub] Set one ${prefix}<NAME> variable. This environment has ${variables}.`,
213
+ fix: "Keep one `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` variable in the environment of the command, and unset the others that the message names."
214
+ },
215
+ INTERNAL_CONSOLE_PRIVATE_KEY_VARIABLE_INVALID: {
216
+ why: ({ variable }) => `[vitehub] ${variable} must be the 43-character private key that \`vitehub secret console-key\` prints, and its name 1 to 64 of A-Z, 0-9, and _.`,
217
+ fix: "Set the variable that the message names to the private key that `vitehub secret console-key` prints, and name it `VITEHUB_CONSOLE_PRIVATE_KEY_<NAME>` with A-Z, 0-9, and _ in `<NAME>`."
218
+ },
219
+ INTERNAL_FORGE_NOT_INSTALLED: {
220
+ why: ({ feature }) => `${feature} needs @vite-hub/forge, and the app did not install it.`,
221
+ fix: "Install Forge in your app with `pnpm add @vite-hub/forge`, then build again."
222
+ },
223
+ INTERNAL_MCP_ARGUMENTS_INVALID: {
224
+ why: ({ detail }) => detail,
225
+ fix: "Pass the prompt or resource the arguments that `prompts/list` or `resources/templates/list` describes for it."
226
+ },
227
+ INTERNAL_MCP_METHOD_FAILED: {
228
+ why: ({ name }) => `${name} failed on the server.`,
229
+ fix: "Read the server log for the error of the MCP prompt or resource that the message names, and fix its handler."
230
+ },
231
+ INTERNAL_MCP_RESOURCE_NOT_FOUND: {
232
+ why: ({ uri }) => `Resource not found: ${uri}. Call resources/list or resources/templates/list for the resources of this server.`,
233
+ fix: "Call `resources/list` or `resources/templates/list`, and read a URI that one of them returns."
234
+ },
235
+ INTERNAL_PRESET_OPTION_UNKNOWN: {
236
+ why: ({ key, label }) => `[vitehub] Unknown ${label} option "${key}".`,
237
+ fix: "Remove the option that the message names from the preset options, or correct its spelling to an option that the preset declares."
238
+ },
239
+ INTERNAL_PRESET_TUPLE_INVALID: {
240
+ why: ({ owner }) => `[vitehub] ${owner} extends tuple requires [preset, options] with an options object.`,
241
+ fix: "Set `extends` to a preset, or to a two-item tuple `[preset, { ...options }]` whose second item is a plain object."
242
+ },
243
+ INTERNAL_SECRET_PURPOSE_MISSING: {
244
+ why: "[vitehub] A derived secret requires a purpose.",
245
+ fix: "Pass a non-empty purpose to `deriveSecret()`, such as `deriveSecret(\"my-module:session\")`."
246
+ },
247
+ INTERNAL_SECRET_TOO_SHORT: {
248
+ why: ({ minimum }) => `[vitehub] VITEHUB_SECRET must be at least ${minimum} characters. Generate one with \`openssl rand -base64 32\`.`,
249
+ fix: "Set `VITEHUB_SECRET` to the output of `openssl rand -base64 32`, which has 44 characters."
250
+ },
251
+ INTERNAL_SQLITE_ARGUMENT_INVALID: {
252
+ why: ({ value }) => value === "undefined" ? "undefined cannot be passed as argument to the database" : "Only finite numbers (not Infinity or NaN) can be passed as arguments",
253
+ fix: "Pass query arguments as finite numbers, strings, booleans, bigints, dates, byte arrays, or null. Replace undefined with null, and check numbers with `Number.isFinite()` before the query."
254
+ },
255
+ INTERNAL_SQLITE_INTEGER_UNSAFE: {
256
+ why: "Received integer which cannot be safely represented as a JavaScript number",
257
+ fix: "Create the client with `intMode: \"bigint\"` or `intMode: \"string\"`, or read the column with `CAST(column AS TEXT)` in the query."
258
+ },
259
+ INTERNAL_VALIBOT_JSON_SCHEMA_TARGET_UNSUPPORTED: {
260
+ why: ({ target }) => `[vitehub] Valibot cannot convert a schema to the ${target} JSON Schema target.`,
261
+ fix: "Ask for the `draft-07`, `draft-2020-12`, or `openapi-3.0` JSON Schema target, or pass one of them as `withValibotJsonSchema(schema, { target })`."
262
+ }
263
+ }
264
+ });
265
+ //#endregion
266
+ export { internalErrorDiagnostics as t };
@@ -0,0 +1,22 @@
1
+ import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
2
+ import { d as withWorkspaceRuntimeOptions, u as ownSourceOption } from "./config-BAgL2dtB.js";
3
+ import { file } from "@vite-hub/source";
4
+ //#region src/sources/file.ts
5
+ var file_exports = /* @__PURE__ */ __exportAll({
6
+ file: () => file$1,
7
+ withFileSourceOptions: () => withFileSourceOptions
8
+ });
9
+ function file$1(input) {
10
+ const options = typeof input === "string" ? { path: input } : input;
11
+ return withFileSourceOptions(file(options), options);
12
+ }
13
+ /** Adds Workspace binding options to a file Source. Workspace normalization picks the default mount and probe keys. */
14
+ function withFileSourceOptions(source, options) {
15
+ const probeKeys = ownSourceOption(options, "probeKeys");
16
+ return {
17
+ ...withWorkspaceRuntimeOptions(source, options),
18
+ ...probeKeys ? { probeKeys } : {}
19
+ };
20
+ }
21
+ //#endregion
22
+ export { file_exports as n, withFileSourceOptions as r, file$1 as t };
@@ -1,5 +1,5 @@
1
- import { l as normalizeWorkspacePath, o as isWorkspaceBytes, s as matchesAny } from "./path-CNAwN7pw.js";
2
- import { f as prepareWorkspaceSource, n as createSourceContext } from "./config-B7dmzDX3.js";
1
+ import { l as normalizeWorkspacePath, o as isWorkspaceBytes, s as matchesAny } from "./path--wrT_Azm.js";
2
+ import { f as prepareWorkspaceSource, n as createSourceContext } from "./config-BAgL2dtB.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;
@@ -0,0 +1,38 @@
1
+ import { $ as WorkspaceHistoryFileInput, $t as WorkspaceSourceMaterializationStatus, A as WorkspaceAutoCommitPlan, An as WorkspaceWriteCommit, At as WorkspaceRetainedHistory, B as WorkspaceEntry, Bt as WorkspaceSessionHost, C as SourceContextWorkspaceFiles, Cn as WorkspaceStoreHistoryCommitOptions, Ct as WorkspaceNameMap, D as WorkspaceAssets, Dn as WorkspaceSyncResultDetails, Dt as WorkspacePrepareSessionProgressEvent, E as WorkspaceAssetPath, En as WorkspaceSyncOptions, Et as WorkspacePlugin, F as WorkspaceCustomSourceInput, Fn as WorkspaceWriteOperation, Ft as WorkspaceScopeName, G as WorkspaceGitHubSourceInput, Gt as WorkspaceSnapshot, H as WorkspaceFetchSourceRequestOptions, Ht as WorkspaceSessionHostFiles, I as WorkspaceDefinition, In as WorkspaceWriteValidator, It as WorkspaceSearchHit, J as WorkspaceHistoryChangesCommitOptions, Jt as WorkspaceSourceDefinition, K as WorkspaceGlobSourceInput, Kt as WorkspaceSource, L as WorkspaceDefinitionInput, Ln as WorkspaceWriteValidatorResult, Lt as WorkspaceSearchQuery, M as WorkspaceCapabilities, Mn as WorkspaceWriteHook, Mt as WorkspaceRevisionView, N as WorkspaceContent, Nn as WorkspaceWriteInput, Nt as WorkspaceRule, O as WorkspaceAssetsRegistry, On as WorkspaceSyncSnapshotOptions, Ot as WorkspacePullRequest, P as WorkspaceContentStream, Pn as WorkspaceWriteMode, Pt as WorkspaceRules, Q as WorkspaceHistoryFile, Qt as WorkspaceSourceMaterializationPathResult, R as WorkspaceDiff, Rn as WriteFileOptions, Rt as WorkspaceSelectedScope, S as SourceContext, Sn as WorkspaceStoreHistory, St as WorkspaceName, T as Workspace, Tn as WorkspaceStreamFile, Tt as WorkspaceOptions, U as WorkspaceFile, Ut as WorkspaceSessionOptions, V as WorkspaceFetchSourceInput, Vt as WorkspaceSessionHostFileEntry, W as WorkspaceFileSourceInput, Wt as WorkspaceSessionWriteFileOptions, X as WorkspaceHistoryCommitOptions, Xt as WorkspaceSourceItem, Y as WorkspaceHistoryCommitBase, Yt as WorkspaceSourceInput, Z as WorkspaceHistoryExtensions, Zt as WorkspaceSourceMaterializationCounts, _ as ReadFileResult, _n as WorkspaceSourceSyncPolicy, _t as WorkspaceMergeCommit, a as GitHubWorkspaceOption, an as WorkspaceSourceRequestExecutor, at as WorkspaceHistoryRefOptions, b as RmOptions, bn as WorkspaceStat, bt as WorkspaceMergeOptions, c as GlobOptions, cn as WorkspaceSourceResolutionContextMap, ct as WorkspaceInstructionBinding, d as LocalWorkspaceStoreOptions, dn as WorkspaceSourceResolutionResult, dt as WorkspaceLoaderSource, en as WorkspaceSourceMount, et as WorkspaceHistoryFilesCommitOptions, f as Logger, fn as WorkspaceSourceResolver, ft as WorkspaceMaterializeMode, g as ReadFileOptions, gn as WorkspaceSourceSyncPathResult, gt as WorkspaceMcpResourcesSourceInput, h as MkdirOptions, hn as WorkspaceSourceSyncCounts, ht as WorkspaceMaterializeSourcesResult, i as ExecResult, in as WorkspaceSourceRequestExecutionResult, it as WorkspaceHistoryRef, j as WorkspaceCacheOptions, jn as WorkspaceWriteErrorHook, jt as WorkspaceRevision, k as WorkspaceAuthor, kn as WorkspaceValidateMode, kt as WorkspaceRebaseOptions, l as ListOptions, ln as WorkspaceSourceResolutionContextValueReader, lt as WorkspaceInstructionBindingValue, m as MemoryWorkspaceStoreOptions, mn as WorkspaceSourceSyncConfig, mt as WorkspaceMaterializeSourcesProgressEvent, n as DiffOptions, nn as WorkspaceSourceRequestDescriptor, nt as WorkspaceHistoryListResult, o as GitHubWorkspaceRefs, on as WorkspaceSourceRequestMethod, ot as WorkspaceHookContext, p as MaybePromise, pn as WorkspaceSourceSelection, pt as WorkspaceMaterializeSourcesOptions, q as WorkspaceHistoryChanges, qt as WorkspaceSourceBindingInput, r as ExecOptions, rn as WorkspaceSourceRequestExecutionInput, rt as WorkspaceHistoryReader, s as GitHubWorkspaceStoreOptions, sn as WorkspaceSourceResolutionContext, st as WorkspaceHooks, t as CloudflareArtifactsWorkspaceStoreOptions, tn as WorkspaceSourceMountOptions, tt as WorkspaceHistoryListOptions, u as LoaderContext, un as WorkspaceSourceResolutionInvocation, ut as WorkspaceLoader, v as ResolvedWorkspaceModuleOptions, vn as WorkspaceSourceSyncResult, vt as WorkspaceMergeConflict, w as VercelBlobWorkspaceStoreOptions, wn as WorkspaceStoreOptions, wt as WorkspaceOpenPullRequestOptions, x as SnapshotOptions, xn as WorkspaceStore, xt as WorkspaceMergeResolution, y as ResolvedWorkspaceRule, yn as WorkspaceSourceSyncStatus, yt as WorkspaceMergeConflictContext, z as WorkspaceDiffEntry, zt as WorkspaceSession } from "./types-BbtwmBZ5.js";
2
+ import { C as resolveWorkspaceStoreTarget, S as WorkspaceStoreTarget, _ as WritableWorkspaceFiles, a as ReadonlyWorkspaceFiles, o as ReadonlyWorkspaceFs, s as UseWorkspaceOptions, u as WorkspaceHistory, v as WritableWorkspaceFs, x as useWorkspaceFiles } from "./use-C6lV3-wC.js";
3
+ import { n as isWorkspaceConflict } from "./path-AxMho1wo.js";
4
+ import { n as normalizeSafeWorkspacePath } from "./path-zHxQUbqa.js";
5
+ import { t as registerWorkspacePlugin } from "./plugins-C8C0auoW.js";
6
+ //#region src/providers/github/cache.d.ts
7
+ /**
8
+ * The GitHub answers that the GitHub Store keeps. An answer for a URL that names a commit or tree sha never
9
+ * changes, so it goes to the shared KV store when the app has one: another server instance reads it there and sends no
10
+ * request. Other answers stay in memory with their ETag. The next read of the same URL asks GitHub with
11
+ * `If-None-Match`, and a `304 Not Modified` does not count against the GitHub rate limit.
12
+ */
13
+ /** The part of a ViteHub KV store that the GitHub Store uses, such as `kv` from `@vite-hub/kv`. */
14
+ interface WorkspaceKV {
15
+ get<T>(key: string): Promise<readonly [unknown, T | null | undefined]>;
16
+ set<T>(key: string, value: T, options?: {
17
+ ttl?: number;
18
+ }): Promise<readonly [unknown, unknown]>;
19
+ }
20
+ /** How the GitHub Store answered its reads in this server instance. */
21
+ interface GitHubReadStats {
22
+ /** Requests that reached GitHub, including the conditional ones. */
23
+ requests: number;
24
+ /** Conditional requests that GitHub answered with `304 Not Modified`. They do not count against the rate limit. */
25
+ notModified: number;
26
+ /** Answers that came from memory or from the shared KV store, with no request. */
27
+ memory: number;
28
+ kv: number;
29
+ }
30
+ /**
31
+ * Give the GitHub Store a shared KV store for the GitHub answers that never change. The Content build calls it with
32
+ * ViteHub KV when the app enables KV; without it, each server instance asks GitHub again after it starts.
33
+ */
34
+ export declare function registerWorkspaceKV(store: WorkspaceKV | undefined): void;
35
+ /** The reads of the GitHub Store in this server instance, for tests and inspection. */
36
+ export declare function readGitHubReadStats(): GitHubReadStats;
37
+ //#endregion
38
+ export { type CloudflareArtifactsWorkspaceStoreOptions, type DiffOptions, type ExecOptions, type ExecResult, type GitHubReadStats, type GitHubWorkspaceOption, type GitHubWorkspaceRefs, type GitHubWorkspaceStoreOptions, type GlobOptions, type ListOptions, type LoaderContext, type LocalWorkspaceStoreOptions, type Logger, type MaybePromise, type MemoryWorkspaceStoreOptions, type MkdirOptions, type ReadFileOptions, type ReadFileResult, type ReadonlyWorkspaceFiles, type ReadonlyWorkspaceFs, type ResolvedWorkspaceModuleOptions, type ResolvedWorkspaceRule, type RmOptions, type SnapshotOptions, type SourceContext, type SourceContextWorkspaceFiles, type UseWorkspaceOptions, type VercelBlobWorkspaceStoreOptions, type Workspace, type WorkspaceAssetPath, type WorkspaceAssets, type WorkspaceAssetsRegistry, type WorkspaceAuthor, type WorkspaceAutoCommitPlan, type WorkspaceCacheOptions, type WorkspaceCapabilities, type WorkspaceContent, type WorkspaceContentStream, type WorkspaceCustomSourceInput, type WorkspaceDefinition, type WorkspaceDefinitionInput, type WorkspaceDiff, type WorkspaceDiffEntry, type WorkspaceEntry, type WorkspaceFetchSourceInput, type WorkspaceFetchSourceRequestOptions, type WorkspaceFile, type WorkspaceFileSourceInput, type WorkspaceGitHubSourceInput, type WorkspaceGlobSourceInput, type WorkspaceHistory, type WorkspaceHistoryChanges, type WorkspaceHistoryChangesCommitOptions, type WorkspaceHistoryCommitBase, type WorkspaceHistoryCommitOptions, type WorkspaceHistoryExtensions, type WorkspaceHistoryFile, type WorkspaceHistoryFileInput, type WorkspaceHistoryFilesCommitOptions, type WorkspaceHistoryListOptions, type WorkspaceHistoryListResult, type WorkspaceHistoryReader, type WorkspaceHistoryRef, type WorkspaceHistoryRefOptions, type WorkspaceHookContext, type WorkspaceHooks, type WorkspaceInstructionBinding, type WorkspaceInstructionBindingValue, type WorkspaceKV, type WorkspaceLoader, type WorkspaceLoaderSource, type WorkspaceMaterializeMode, type WorkspaceMaterializeSourcesOptions, type WorkspaceMaterializeSourcesProgressEvent, type WorkspaceMaterializeSourcesResult, type WorkspaceMcpResourcesSourceInput, type WorkspaceMergeCommit, type WorkspaceMergeConflict, type WorkspaceMergeConflictContext, type WorkspaceMergeOptions, type WorkspaceMergeResolution, type WorkspaceName, type WorkspaceNameMap, type WorkspaceOpenPullRequestOptions, type WorkspaceOptions, type WorkspacePlugin, type WorkspacePrepareSessionProgressEvent, type WorkspacePullRequest, type WorkspaceRebaseOptions, type WorkspaceRetainedHistory, type WorkspaceRevision, type WorkspaceRevisionView, type WorkspaceRule, type WorkspaceRules, type WorkspaceScopeName, type WorkspaceSearchHit, type WorkspaceSearchQuery, type WorkspaceSelectedScope, type WorkspaceSession, type WorkspaceSessionHost, type WorkspaceSessionHostFileEntry, type WorkspaceSessionHostFiles, type WorkspaceSessionOptions, type WorkspaceSessionWriteFileOptions, type WorkspaceSnapshot, type WorkspaceSource, type WorkspaceSourceBindingInput, type WorkspaceSourceDefinition, type WorkspaceSourceInput, type WorkspaceSourceItem, type WorkspaceSourceMaterializationCounts, type WorkspaceSourceMaterializationPathResult, type WorkspaceSourceMaterializationStatus, type WorkspaceSourceMount, type WorkspaceSourceMountOptions, type WorkspaceSourceRequestDescriptor, type WorkspaceSourceRequestExecutionInput, type WorkspaceSourceRequestExecutionResult, type WorkspaceSourceRequestExecutor, type WorkspaceSourceRequestMethod, type WorkspaceSourceResolutionContext, type WorkspaceSourceResolutionContextMap, type WorkspaceSourceResolutionContextValueReader, type WorkspaceSourceResolutionInvocation, type WorkspaceSourceResolutionResult, type WorkspaceSourceResolver, type WorkspaceSourceSelection, type WorkspaceSourceSyncConfig, type WorkspaceSourceSyncCounts, type WorkspaceSourceSyncPathResult, type WorkspaceSourceSyncPolicy, type WorkspaceSourceSyncResult, type WorkspaceSourceSyncStatus, type WorkspaceStat, type WorkspaceStore, type WorkspaceStoreHistory, type WorkspaceStoreHistoryCommitOptions, type WorkspaceStoreOptions, type WorkspaceStoreTarget, type WorkspaceStreamFile, type WorkspaceSyncOptions, type WorkspaceSyncResultDetails, type WorkspaceSyncSnapshotOptions, type WorkspaceValidateMode, type WorkspaceWriteCommit, type WorkspaceWriteErrorHook, type WorkspaceWriteHook, type WorkspaceWriteInput, type WorkspaceWriteMode, type WorkspaceWriteOperation, type WorkspaceWriteValidator, type WorkspaceWriteValidatorResult, type WritableWorkspaceFiles, type WritableWorkspaceFs, type WriteFileOptions, isWorkspaceConflict, normalizeSafeWorkspacePath, registerWorkspacePlugin, resolveWorkspaceStoreTarget, useWorkspaceFiles };
package/dist/files.js ADDED
@@ -0,0 +1,6 @@
1
+ import { r as isWorkspaceConflict, t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
2
+ import { n as resolveWorkspaceStoreTarget } from "./target-jWhTdIuF.js";
3
+ import { g as registerWorkspacePlugin } from "./utils-CgMZCHsX.js";
4
+ import { C as registerWorkspaceKV, S as readGitHubReadStats } from "./shared-B3_EUk89.js";
5
+ import { r as useWorkspaceFiles } from "./use-CSpT5W87.js";
6
+ export { isWorkspaceConflict, normalizeSafeWorkspacePath, readGitHubReadStats, registerWorkspaceKV, registerWorkspacePlugin, resolveWorkspaceStoreTarget, useWorkspaceFiles };
@@ -1,8 +1,9 @@
1
- import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { d as withWorkspaceRuntimeOptions, f as prepareWorkspaceSource, p as resolveGitHubIgnore } from "./config-B7dmzDX3.js";
3
- import { t as workspaceErrorDiagnostics } from "./error-diagnostics-DY5GP47p.js";
4
- import { C as forgeEnv, f as readGitHubEnvToken, w as readForgeEnv } from "./shared-DalXdP0i.js";
5
- import { github } from "@vite-hub/source/github";
1
+ import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
2
+ import { s as matchesAny } from "./path--wrT_Azm.js";
3
+ import { t as workspaceErrorDiagnostics } from "./error-diagnostics-CtKjGtGb.js";
4
+ import { D as forgeEnv, O as readForgeEnv, m as readGitHubEnvToken } from "./shared-B3_EUk89.js";
5
+ import { d as withWorkspaceRuntimeOptions, f as prepareWorkspaceSource, p as resolveGitHubIgnore } from "./config-BAgL2dtB.js";
6
+ import { github } from "@vite-hub/source";
6
7
  //#region src/env.ts
7
8
  let viteLoadEnv;
8
9
  const viteModuleId = "vite";
@@ -71,6 +72,10 @@ function github$1(input) {
71
72
  const source = await getSourceForRoot(ctx.rootDir);
72
73
  await prepareWorkspaceSource(source, ctx);
73
74
  },
75
+ async checkAccess(ctx) {
76
+ if (!await resolveGitHubAuth(resolvedOptions.auth, ctx.rootDir)) return;
77
+ await (await getSourceForRoot(ctx.rootDir)).resolveRevision?.(ctx);
78
+ },
74
79
  async getKeys(ctx) {
75
80
  return await (await getSourceForRoot(ctx.rootDir)).getKeys(ctx);
76
81
  },
@@ -83,6 +88,28 @@ function github$1(input) {
83
88
  },
84
89
  async getMeta(key, ctx) {
85
90
  return await (await getSourceForRoot(ctx.rootDir)).getMeta?.(key, ctx);
91
+ },
92
+ subset(include) {
93
+ const { cache, ignore, include: sourceInclude, ref, repo, root } = options;
94
+ const subset = github$1({
95
+ auth: options.auth,
96
+ cache,
97
+ ignore,
98
+ include: [...include],
99
+ ref,
100
+ repo,
101
+ root
102
+ });
103
+ if (!sourceInclude) return subset;
104
+ const holds = (key) => matchesAny(key, typeof sourceInclude === "string" ? sourceInclude : [...sourceInclude]);
105
+ const getKeys = async (ctx) => (await subset.getKeys(ctx)).filter(holds);
106
+ return {
107
+ ...subset,
108
+ getKeys,
109
+ async getItems(ctx) {
110
+ return await Promise.all((await getKeys(ctx)).map((key) => subset.getItem(key, ctx)));
111
+ }
112
+ };
86
113
  }
87
114
  }, resolvedOptions);
88
115
  }
@@ -1,7 +1,6 @@
1
- import { n as __exportAll } from "./rolldown-runtime-B4iAMlE-.js";
2
- import { d as withWorkspaceRuntimeOptions, u as ownSourceOption } from "./config-B7dmzDX3.js";
3
- import { hasRuntimeType } from "@vite-hub/runtime/internal/runtime-type";
4
- import { glob } from "@vite-hub/source/glob";
1
+ import { n as __exportAll } from "./rolldown-runtime-rQ84J-ij.js";
2
+ import { d as withWorkspaceRuntimeOptions, u as ownSourceOption } from "./config-BAgL2dtB.js";
3
+ import { glob } from "@vite-hub/source";
5
4
  //#region src/sources/glob.ts
6
5
  var glob_exports = /* @__PURE__ */ __exportAll({ glob: () => glob$1 });
7
6
  function glob$1(options) {
@@ -15,7 +14,7 @@ function isLazySource(options) {
15
14
  const materialize = ownSourceOption(options, "materialize");
16
15
  if (materialize === "lazy" || materialize === "startup") return true;
17
16
  const mount = ownSourceOption(options, "mount");
18
- const mountMaterialize = hasRuntimeType(mount, "object") ? ownSourceOption(mount, "materialize") : void 0;
17
+ const mountMaterialize = typeof mount === "object" ? ownSourceOption(mount, "materialize") : void 0;
19
18
  return mountMaterialize === "lazy" || mountMaterialize === "startup";
20
19
  }
21
20
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { t as normalizeSafeWorkspacePath } from "./path-DrSIenjj.js";
2
- import { l as normalizeWorkspacePath } from "./path-CNAwN7pw.js";
2
+ import { l as normalizeWorkspacePath } from "./path--wrT_Azm.js";
3
3
  import { Minimatch } from "minimatch";
4
4
  //#region src/core/glob.ts
5
5
  function createWorkspaceGlobMatcher(pattern, options = {}) {