@vite-hub/workspace 0.0.3 → 0.1.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 (129) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +236 -58
  3. package/dist/{ai-nmHdzjCM.d.ts → ai-BW2ZhizI.d.ts} +22 -7
  4. package/dist/{ai-Ce3PtWFW.js → ai-BZyLwULx.js} +147 -66
  5. package/dist/ai.d.ts +2 -2
  6. package/dist/ai.js +1 -1
  7. package/dist/{asset-registry-CaG9b7tf.js → asset-registry-DfBV5kmw.js} +3 -2
  8. package/dist/association-Cm0dUTDU-CDDhJnIh-Cv3bWnVb.js +19 -0
  9. package/dist/blob-database.d.ts +521 -0
  10. package/dist/blob-database.js +601 -0
  11. package/dist/cloudflare.d.ts +5 -6
  12. package/dist/cloudflare.js +1 -1
  13. package/dist/config-B7dmzDX3.js +1112 -0
  14. package/dist/{config-3I1BnsdO.d.ts → config-DLKdaFWN.d.ts} +1 -2
  15. package/dist/error-diagnostics-A_8Kp-48.js +116 -0
  16. package/dist/error-diagnostics-DY5GP47p.js +96 -0
  17. package/dist/events-7EBoeIPd-A2RUkJi5-BxrICQ17.js +354 -0
  18. package/dist/events-CRaLy7U3-3PNNp5WZ-Gv9nd0cH.js +214 -0
  19. package/dist/events-CeChclTf-CX-gD8oy-4aL2j6V-.js +527 -0
  20. package/dist/feed-DsC7Vws1-M_de2nSK-tKc0Pwo8.js +248 -0
  21. package/dist/feed-Dyf730Ys-D0HgBba6-BUnCa5gS.js +179 -0
  22. package/dist/file-C0_aPWSS.js +26 -0
  23. package/dist/file-metadata-CxDy-E2H.js +58 -0
  24. package/dist/{files-QRV55OCx.js → files-C7Px8uaC.js} +21 -10
  25. package/dist/forgejo-BN8ItCfl-Bbn4vhDd.js +2278 -0
  26. package/dist/{github-CfA5vpJ5.js → github-CPxHtFB7.js} +36 -34
  27. package/dist/github-DtncTfmv-Du2S8lGF.js +4159 -0
  28. package/dist/gitlab-BoDm8-BC-xzZsW9eW.js +2530 -0
  29. package/dist/glob--XcLlcml.js +22 -0
  30. package/dist/glob--kNYDbfU.js +30 -0
  31. package/dist/graphql-DG5aJBT3-DceyFYdM-C4saqX37.js +489 -0
  32. package/dist/host-CFnrTXTK.js +1086 -0
  33. package/dist/{hosted-C1-tTTTf.js → hosted-acMA5XyL.js} +216 -43
  34. package/dist/hosted-vercel-blob-DKntsHaf.js +12603 -0
  35. package/dist/hosted-vercel-blob.d.ts +5 -6
  36. package/dist/hosted-vercel-blob.js +1 -1
  37. package/dist/hosted.d.ts +6 -7
  38. package/dist/hosted.js +1 -1
  39. package/dist/index.d.ts +76 -64
  40. package/dist/index.js +162 -457
  41. package/dist/inspect-BoObD2cJ.js +167 -0
  42. package/dist/internal/path.d.ts +2 -0
  43. package/dist/internal/path.js +2 -0
  44. package/dist/lifecycle-BwZ7c9hb.js +596 -0
  45. package/dist/loader.d.ts +5 -6
  46. package/dist/loader.js +3 -2
  47. package/dist/mcp-resources-BREFCmtn.js +39 -0
  48. package/dist/memory-BbwOqDXl.js +248 -0
  49. package/dist/metadata-target-DZEZQGHA.js +1588 -0
  50. package/dist/mountx.d.ts +4 -6
  51. package/dist/mountx.js +10 -8
  52. package/dist/nitro.d.ts +1 -1
  53. package/dist/nitro.js +1 -1
  54. package/dist/nuxt.d.ts +13 -12
  55. package/dist/nuxt.js +10 -8
  56. package/dist/operations-BcpWr41m.js +159 -0
  57. package/dist/operations-CGqY1XeG.js +965 -0
  58. package/dist/operations-DnOwKsJT.d.ts +136 -0
  59. package/dist/operations.d.ts +53 -0
  60. package/dist/operations.js +2 -0
  61. package/dist/{path-CNI6wKIU.js → path-CNAwN7pw.js} +34 -35
  62. package/dist/path-DrSIenjj.js +59 -0
  63. package/dist/path-zHxQUbqa.d.ts +9 -0
  64. package/dist/plugins-DqQ8b4T5.d.ts +10 -0
  65. package/dist/provider-kXjfli9u.js +1457 -0
  66. package/dist/providers/github/store.d.ts +3 -5
  67. package/dist/providers/github/store.js +1 -1
  68. package/dist/registry-Bp-8UUfG.js +129 -0
  69. package/dist/{registry-BIQVCBWI.d.ts → registry-Cg1TJVVZ.d.ts} +3 -4
  70. package/dist/{request-execution-u9mgUXKX.js → request-execution-Dk9rY-Yh.js} +24 -20
  71. package/dist/rolldown-runtime-B4iAMlE-.js +35 -0
  72. package/dist/runtime/assets.d.ts +3 -5
  73. package/dist/runtime/assets.js +9 -6
  74. package/dist/runtime/empty-assets-registry.d.ts +1 -2
  75. package/dist/runtime/empty-registry.d.ts +1 -2
  76. package/dist/runtime/state.d.ts +4 -4
  77. package/dist/runtime/state.js +10 -7
  78. package/dist/runtime/workspace.d.ts +1 -1
  79. package/dist/runtime/workspace.js +1 -1
  80. package/dist/runtime.d.ts +84 -15
  81. package/dist/runtime.js +561 -108
  82. package/dist/{search-C4REyHj9.js → search-CrTmXj5h.js} +10 -9
  83. package/dist/server-BNQ-Nbjj.js +290 -0
  84. package/dist/server.d.ts +22 -34
  85. package/dist/server.js +2 -355
  86. package/dist/shared-DalXdP0i.js +2158 -0
  87. package/dist/source-metadata.d.ts +7 -1
  88. package/dist/source-metadata.js +34 -2
  89. package/dist/{state-TTqa3x3Y.d.ts → state-B8zbLi5t.d.ts} +14 -13
  90. package/dist/store-CXgmu-uw.js +1729 -0
  91. package/dist/{sync-DiuDmSGk.js → sync-CN6ec-5M.js} +62 -41
  92. package/dist/templates-Bn8a-pd2-D9DhJEVD-CBfXNRzz.js +125 -0
  93. package/dist/test.d.ts +1 -1
  94. package/dist/test.js +1 -1
  95. package/dist/token-CO62GglH.js +61 -0
  96. package/dist/{types-60Yn149G.d.ts → types-DeK9GIxy.d.ts} +348 -49
  97. package/dist/{use-CsV3oIxH.js → use-BQj7nSz6.js} +200 -45
  98. package/dist/{use-CUFSnFCS.d.ts → use-DhwhbAVV.d.ts} +34 -12
  99. package/dist/utils-Blrh4N2n.js +545 -0
  100. package/dist/vite-BEvgU2GY.js +20909 -0
  101. package/dist/vite-CcZmMQ7S.d.ts +476 -0
  102. package/dist/vite.d.ts +2 -50
  103. package/dist/vite.js +2 -2
  104. package/dist/webhooks-DgHwxxYz-D1V2LOr1-azofFOiP.js +1565 -0
  105. package/dist/workspace-6pxkOuxr.js +1286 -0
  106. package/dist/workspace-BWJQBK1u.d.ts +7 -0
  107. package/package.json +90 -59
  108. package/dist/chunk-8H4AJuhK.js +0 -14
  109. package/dist/collections/client.d.ts +0 -39
  110. package/dist/collections/client.js +0 -137
  111. package/dist/collections.d.ts +0 -59
  112. package/dist/collections.js +0 -159
  113. package/dist/config-CDoyls2X.js +0 -30
  114. package/dist/config-CZLO0m9h.js +0 -7811
  115. package/dist/file-CHfsZpso.js +0 -23
  116. package/dist/glob-D0vD_wRY.js +0 -17
  117. package/dist/host-CAnbugpI.js +0 -370
  118. package/dist/hosted-vercel-blob-CWBILDVo.js +0 -257
  119. package/dist/lifecycle-BYoa9hVb.js +0 -176
  120. package/dist/provider-C3_elpEh.js +0 -599
  121. package/dist/publish.d.ts +0 -35
  122. package/dist/publish.js +0 -112
  123. package/dist/registry-CqyDTW9Y.js +0 -74
  124. package/dist/runtime-options-BsPSv5O7.js +0 -13
  125. package/dist/shared-jfogBrd5.js +0 -273
  126. package/dist/store-Bs1SLh55.js +0 -414
  127. package/dist/vite-tbfDxtlu.js +0 -2191
  128. package/dist/workspace-66SKyiec.d.ts +0 -6
  129. package/dist/workspace-C4k92Ow8.js +0 -1460
@@ -0,0 +1,476 @@
1
+ import { xt as WorkspaceModuleOptions } from "./types-DeK9GIxy.js";
2
+ import { n as OperationContributionEntry } from "./operations-DnOwKsJT.js";
3
+ import { Plugin } from "vite";
4
+ //#region ../internal/src/inspect.d.ts
5
+ interface ViteHubDefinitionField {
6
+ label: string;
7
+ value: string;
8
+ }
9
+ /** Serializable summary of one discovered Definition. Files are relative to the project root. */
10
+ interface ViteHubDefinitionSummary {
11
+ fields: readonly ViteHubDefinitionField[];
12
+ file: string;
13
+ name: string;
14
+ source: string;
15
+ }
16
+ /** Lists the Definitions that one owner package discovered for the resolved Vite config. */
17
+ interface ViteHubDefinitionInspector {
18
+ /** Stable singular kind, for example `queue` or `rate-limit`. */
19
+ kind: string;
20
+ label: string;
21
+ list: () => Promise<readonly ViteHubDefinitionSummary[]> | readonly ViteHubDefinitionSummary[];
22
+ }
23
+ /** One generated Provider Output file or directory that an owner package can write. */
24
+ interface ViteHubProviderOutputEntry {
25
+ description: string;
26
+ owner: string;
27
+ /** Absolute path. */
28
+ path: string;
29
+ }
30
+ interface ViteHubInspectionContributor {
31
+ definitions?: readonly ViteHubDefinitionInspector[];
32
+ providerOutput?: readonly ViteHubProviderOutputEntry[];
33
+ }
34
+ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor | undefined | Promise<ViteHubInspectionContributor | undefined>;
35
+ interface ViteHubInspectionPluginMetadata {
36
+ inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
37
+ }
38
+ //#endregion
39
+ //#region src/hosts/vite/plugin.d.ts
40
+ interface WorkspaceNitroConfigOptions {
41
+ aliases?: Record<string, string>;
42
+ command?: "build" | "serve";
43
+ env?: Record<string, string | undefined>;
44
+ hosting?: string;
45
+ nitro?: unknown;
46
+ /** Vite plugins that can contribute Workspace Definitions through `vitehub.workspaces`. */
47
+ plugins?: readonly unknown[];
48
+ serverDirs?: string[];
49
+ viteRoot?: string;
50
+ workspace?: false | WorkspaceModuleOptions;
51
+ }
52
+ type NitroConfig = {
53
+ cloudflare?: {
54
+ wrangler?: {
55
+ artifacts?: Array<{
56
+ binding: string;
57
+ namespace: string;
58
+ }>;
59
+ compatibility_flags?: string[];
60
+ } & Record<string, unknown>;
61
+ } & Record<string, unknown>;
62
+ plugins?: unknown[];
63
+ rollupConfig?: {
64
+ external?: unknown;
65
+ } & Record<string, unknown>;
66
+ } & Record<string, unknown>;
67
+ declare function createWorkspaceNitroConfig(options?: WorkspaceNitroConfigOptions): Promise<NitroConfig | null>;
68
+ interface WorkspaceVitePluginAPI {
69
+ getWorkspaces: () => Array<{
70
+ name: string;
71
+ }>;
72
+ }
73
+ interface WorkspaceCliContributingPlugin {
74
+ vitehub?: ViteHubInspectionPluginMetadata & {
75
+ cli?: () => unknown | Promise<unknown>;
76
+ operations?: readonly OperationContributionEntry[];
77
+ };
78
+ }
79
+ declare const setWorkspacePluginHosting: unique symbol;
80
+ type WorkspacePluginHosting = string | (() => string | undefined);
81
+ type WorkspaceVitePlugin = Plugin & WorkspaceCliContributingPlugin & {
82
+ [setWorkspacePluginHosting]?: (hosting: WorkspacePluginHosting) => void;
83
+ api: WorkspaceVitePluginAPI;
84
+ };
85
+ declare function hubWorkspace(options?: WorkspaceModuleOptions): WorkspaceVitePlugin;
86
+ declare module "vite" {
87
+ interface UserConfig {
88
+ workspace?: false | WorkspaceModuleOptions;
89
+ }
90
+ }
91
+ //#endregion
92
+ //#region ../internal/src/contributions.d.ts
93
+ /** Module and export that hold a contributed Definition. */
94
+ interface ContributionDefinition {
95
+ /**
96
+ * Absolute file path, `file:` URL, or package specifier that the application can import. Relative paths are
97
+ * rejected because they have no stable base.
98
+ */
99
+ module: string;
100
+ /** Named export that holds the Definition. Defaults to `default`. */
101
+ export?: string;
102
+ }
103
+ /**
104
+ * One Definition that a Vite plugin adds to a Server Primitive, for example a Workspace, a Schedule, or Database tables.
105
+ * Every owner package reads this shape from `plugin.vitehub.<key>`. Owners can add fields, such as `database`.
106
+ */
107
+ interface Contribution {
108
+ /** Unique name in the owner, for example the Workspace or Schedule name. */
109
+ name: string;
110
+ definition: ContributionDefinition;
111
+ /** Why the plugin adds the Definition. `vitehub inspect` and the Console show it. */
112
+ reason?: string;
113
+ }
114
+ /** Roots that ViteHub passes to every contribution factory. */
115
+ interface ContributionContext {
116
+ /** Vite root. */
117
+ root: string;
118
+ /** ViteHub project root. It can differ from the Vite root, for example in a Nuxt app with a `srcDir`. */
119
+ projectRoot: string;
120
+ /** Server directories that the host forwards, for example Nuxt's `serverDir` and the server directories of layers. */
121
+ serverDirs?: readonly string[];
122
+ }
123
+ /**
124
+ * Returns the contributions of a plugin. It runs once per discovery pass, so it must be idempotent and must not depend
125
+ * on the order of Vite config hooks.
126
+ */
127
+ type ContributionFactory<TEntry extends Contribution = Contribution> = (context: ContributionContext) => readonly TEntry[] | undefined | Promise<readonly TEntry[] | undefined>;
128
+ type ContributionSource<TEntry extends Contribution = Contribution> = readonly TEntry[] | ContributionFactory<TEntry>;
129
+ /** A Vite plugin that contributes Definitions under `vitehub[TKey]`. */
130
+ type ContributingPlugin<TKey extends string, TEntry extends Contribution = Contribution> = {
131
+ name?: string;
132
+ vitehub?: { [K in TKey]?: ContributionSource<TEntry>; };
133
+ };
134
+ /** A validated contribution with its export resolved and the name of the plugin that added it. */
135
+ interface CollectedContribution {
136
+ name: string;
137
+ definition: {
138
+ module: string;
139
+ export: string;
140
+ };
141
+ reason?: string;
142
+ /** Name of the contributing Vite plugin. */
143
+ plugin: string;
144
+ }
145
+ //#endregion
146
+ //#region src/build/contributions.d.ts
147
+ /**
148
+ * A Workspace Definition that another package registers from its Vite plugin. The Workspace plugin adds it to the
149
+ * generated registry next to the discovered files, so `useWorkspace(name)`, typegen, inspection, and the Console
150
+ * treat it like `server/workspaces/<name>.ts`. `definition.export` names the export that holds the `defineWorkspace()`
151
+ * result.
152
+ */
153
+ type WorkspaceContribution = Contribution;
154
+ /**
155
+ * Roots that ViteHub passes to contribution factories. `root` is the Vite root. `plugins` holds the Vite plugins, so a
156
+ * factory can read sibling plugins, for example the Database plugin.
157
+ */
158
+ interface WorkspaceContributionContext extends ContributionContext {
159
+ plugins?: readonly unknown[];
160
+ }
161
+ type WorkspaceContributionFactory = (context: WorkspaceContributionContext) => ReturnType<ContributionFactory<WorkspaceContribution>>;
162
+ /** A Vite plugin that contributes Workspace Definitions through `vitehub.workspaces`. */
163
+ type WorkspaceContributingPlugin = ContributingPlugin<"workspaces", WorkspaceContribution>;
164
+ /** A validated contribution with its export resolved and the name of the plugin that contributed it. */
165
+ type CollectedWorkspaceContribution = CollectedContribution;
166
+ /**
167
+ * Collects `vitehub.workspaces` contributions from Vite plugins. Invalid entries fail with `WORKSPACE_B0004`. Two
168
+ * contributions with one name fail with `WORKSPACE_B0003`.
169
+ */
170
+ declare function collectWorkspaceContributions(plugins: readonly unknown[] | undefined, context: WorkspaceContributionContext): Promise<CollectedWorkspaceContribution[]>;
171
+ //#endregion
172
+ //#region src/build/discovery.d.ts
173
+ interface DiscoveredWorkspaceDefinition {
174
+ /** Plugin that contributed the definition. Only set for contributed definitions. */
175
+ contributor?: string;
176
+ /** Named export that holds the definition. Discovered files always use `default`. */
177
+ export?: string;
178
+ handler: string;
179
+ name: string;
180
+ /** Absolute file path, or the package specifier of a contributed definition. */
181
+ path: string;
182
+ /** Why the plugin contributed the definition. Only set for contributed definitions. */
183
+ reason?: string;
184
+ source?: string;
185
+ sourceRootDir?: string;
186
+ }
187
+ interface ViteWorkspaceDiscoveryOptions {
188
+ /** Workspace Definitions that Vite plugins contribute. See `collectWorkspaceContributions()`. */
189
+ contributions?: readonly CollectedWorkspaceContribution[];
190
+ serverDirs?: string[];
191
+ serverRootDir?: string;
192
+ }
193
+ declare function discoverViteWorkspaceDefinitions(rootDir: string, options?: ViteWorkspaceDiscoveryOptions): DiscoveredWorkspaceDefinition[];
194
+ //#endregion
195
+ //#region ../internal/src/console.d.ts
196
+ type MaybePromise<T> = T | Promise<T>;
197
+ /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
198
+ interface ViteHubConsoleDefinitionCatalogView {
199
+ kind: "definition-catalog";
200
+ /** States which runtime data this catalog does not include. */
201
+ notice: string;
202
+ }
203
+ interface ViteHubConsoleRecordColumn {
204
+ /** Key in `ViteHubConsoleRecord.cells`. */
205
+ key: string;
206
+ label: string;
207
+ }
208
+ /** Shows records in a table and the selected record's fields in a detail panel. */
209
+ interface ViteHubConsoleRecordTableView {
210
+ columns: readonly ViteHubConsoleRecordColumn[];
211
+ kind: "record-table";
212
+ /** States the source and limits of the records. */
213
+ notice: string;
214
+ }
215
+ /**
216
+ * Lists the collections and documents of an owner runtime and edits them with owner actions: a form generated from each
217
+ * collection's JSON Schema, a Markdown body, save, publish, and revision history.
218
+ */
219
+ interface ViteHubConsoleDocumentEditorView {
220
+ kind: "document-editor";
221
+ /** States where documents are stored and what the editor does not do. */
222
+ notice: string;
223
+ }
224
+ interface ViteHubConsoleOperationColumn {
225
+ /** Dot path into each item of the result, such as `author.name` or `messages.0.body`. */
226
+ key: string;
227
+ label: string;
228
+ /** `datetime` shows a time in milliseconds since the epoch as a date. `excerpt` cuts a long text. */
229
+ format?: "datetime" | "excerpt";
230
+ }
231
+ /** A chip above the list. Choosing it merges `input` into the operation input. The first chip is the default. */
232
+ interface ViteHubConsoleOperationFilter {
233
+ id: string;
234
+ label: string;
235
+ input: Readonly<Record<string, unknown>>;
236
+ }
237
+ /**
238
+ * Lists the items that an operation returns, called over the Console RPC with the signed-in Console user. The operation
239
+ * checks the access of that user for each item, so the view shows only what the user may read. `operation` must return an
240
+ * array of objects with an `id`. A failure of the operation, with its `fix`, shows where the list would be.
241
+ */
242
+ interface ViteHubConsoleOperationView {
243
+ columns: readonly ViteHubConsoleOperationColumn[];
244
+ filters?: readonly ViteHubConsoleOperationFilter[];
245
+ kind: "operation-view";
246
+ /**
247
+ * Makes each row a link: `{path}` placeholders take values from the item and are URL-encoded, and `{path:path}` takes an
248
+ * app path and encodes each segment (a value that is not an app path, such as `//evil.com/x`, gives no link). Rows where
249
+ * `when.path` is not `when.equals` get none.
250
+ */
251
+ link?: {
252
+ label?: string;
253
+ template: string;
254
+ when?: {
255
+ equals: string;
256
+ path: string;
257
+ };
258
+ };
259
+ notice: string;
260
+ /** Operation name, such as `comments.list`. */
261
+ operation: string;
262
+ /** Fetch every page with `limit` and a `before` object whose keys read these dot paths from the last item. */
263
+ pagination?: {
264
+ limit: number;
265
+ cursor: Readonly<Record<string, string>>;
266
+ };
267
+ }
268
+ interface ViteHubConsoleAuthView {
269
+ kind: "auth-management";
270
+ notice: string;
271
+ }
272
+ interface ViteHubConsoleAuthSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleAuthView> {}
273
+ type ViteHubConsoleSectionView = ViteHubConsoleOperationView | ViteHubConsoleAuthView | ViteHubConsoleDefinitionCatalogView | ViteHubConsoleRecordTableView | ViteHubConsoleDocumentEditorView;
274
+ /**
275
+ * The overview of a document editor section: document counts by state, the changes that wait for a publish, recent
276
+ * activity, and a New button per collection. It reads the owner `overview` action.
277
+ */
278
+ interface ViteHubConsoleDocumentDashboardView {
279
+ kind: "document-dashboard";
280
+ }
281
+ /**
282
+ * The media library of a document editor section: folders, uploads, alt text, focal points, and crops of the Blob Store
283
+ * that `blob.serve` serves. The owner decides who may use it with `mediaAccess`, and finds the documents that use a file
284
+ * with `references`. The page needs the Blob section, so declare it with `requires: ["blob"]`.
285
+ */
286
+ interface ViteHubConsoleMediaLibraryView {
287
+ kind: "media-library";
288
+ }
289
+ /**
290
+ * The singletons of a document editor section, such as site settings: one row per singleton that opens it in the
291
+ * editor. Singletons appear here instead of among the collections, and the Console hides the page when the section has
292
+ * none.
293
+ */
294
+ interface ViteHubConsoleDocumentSettingsView {
295
+ kind: "document-settings";
296
+ }
297
+ /** A view that the Console UI in `vite-hub` renders for a section page. */
298
+ type ViteHubConsoleSectionPageView = ViteHubConsoleDocumentDashboardView | ViteHubConsoleDocumentSettingsView | ViteHubConsoleMediaLibraryView;
299
+ /**
300
+ * A page of a section next to its main view, such as the Content dashboard or media library. The section sidebar lists
301
+ * the pages, and each page has its own URL:
302
+ *
303
+ * - `/_vitehub/<section>` serves the `index` page, or the main view when the section has none.
304
+ * - `/_vitehub/<section>/-/<page>` serves every other page. The `-` segment keeps page URLs apart from the main view's
305
+ * own segments, such as a collection name.
306
+ *
307
+ * Pages share the access of their section: `console.authorize` that allows the section allows every page of it.
308
+ */
309
+ interface ViteHubConsoleSectionPage {
310
+ /** Lowercase route segment, for example `media`. */
311
+ id: string;
312
+ /** Display name, for example `Media`. */
313
+ label: string;
314
+ /** Iconify class name, for example `i-lucide-image`. */
315
+ icon: string;
316
+ view: ViteHubConsoleSectionPageView;
317
+ /**
318
+ * Serve this page at the section root. At most one page sets it, and `/_vitehub/<section>/-/<id>` then redirects to
319
+ * the root.
320
+ */
321
+ index?: boolean;
322
+ /**
323
+ * Sidebar heading, for example `Assets`. Pages without a group lead the sidebar, above the main view's navigation.
324
+ * Grouped pages follow it, in the order their group first appears.
325
+ */
326
+ group?: string;
327
+ /** Section ids that the project must enable, such as `["blob"]`. The Console leaves the page out otherwise. */
328
+ requires?: readonly string[];
329
+ }
330
+ /** One entry of a record's activity, such as a comment in a thread. `at` is an ISO 8601 timestamp. */
331
+ interface ViteHubConsoleRecordActivity {
332
+ author: string;
333
+ at: string;
334
+ text: string;
335
+ }
336
+ /** One serializable record row. Values are display strings. Do not put credentials in records. */
337
+ interface ViteHubConsoleRecord {
338
+ cells: Readonly<Record<string, string>>;
339
+ fields: readonly ViteHubDefinitionField[];
340
+ id: string;
341
+ /** The Console can run this record when it represents a runnable Schedule Definition. */
342
+ runnable?: boolean;
343
+ /**
344
+ * Where the record lives in the app, such as the page of a comment thread. `href` is an app path that starts with one
345
+ * `/`, or an `https:` URL. The Console opens it in a new tab.
346
+ */
347
+ link?: {
348
+ href: string;
349
+ label: string;
350
+ };
351
+ /** Entries in time order, such as the comments of a thread. The Console shows them as a conversation. */
352
+ activity?: readonly ViteHubConsoleRecordActivity[];
353
+ }
354
+ /** Serializable description of a Console section. The Console UI in `vite-hub` renders the view. */
355
+ interface ViteHubConsoleSectionDescriptor<TView extends ViteHubConsoleSectionView = ViteHubConsoleSectionView> {
356
+ description: string;
357
+ /**
358
+ * Iconify class name, for example `i-lucide-inbox`. The Console draws with Lucide; `ph` also resolves. The
359
+ * Console build bundles the icon of every section in the `vite-hub` Console registry and fails if it cannot resolve one.
360
+ */
361
+ icon: string;
362
+ /** Lowercase route segment, for example `queues`. The Console serves the section at `/_vitehub/<id>`. */
363
+ id: string;
364
+ /** Plural display name, for example `Queues`. */
365
+ label: string;
366
+ view: TView;
367
+ /** Pages next to the main view, in sidebar order. Only document editor sections render pages today. */
368
+ pages?: readonly ViteHubConsoleSectionPage[];
369
+ }
370
+ interface ViteHubConsoleDefinitionCatalogSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDefinitionCatalogView> {
371
+ /** Reads the section data on the server. The Console never runs it in the browser. */
372
+ read: (options: TOptions) => MaybePromise<readonly ViteHubDefinitionSummary[]>;
373
+ }
374
+ interface ViteHubConsoleRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
375
+ /** Reads the section data on the server. The Console never runs it in the browser. */
376
+ read: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
377
+ }
378
+ /** A named export of an owner package server module that the host imports in its generated server code. */
379
+ interface ViteHubConsoleServerExport {
380
+ /** Named export of `module`. */
381
+ export: string;
382
+ /**
383
+ * Owner package module specifier, for example `@vite-hub/email/runtime/console`. The host maps it to the module
384
+ * path that the application can import.
385
+ */
386
+ module: string;
387
+ }
388
+ /**
389
+ * Server module export that returns records on each Console request. The export must be a
390
+ * {@link ViteHubConsoleRuntimeRecordReader}.
391
+ */
392
+ interface ViteHubConsoleRuntimeReader extends ViteHubConsoleServerExport {}
393
+ /**
394
+ * A record table that also reads records at request time. The Console shows the build-time records of `read` first,
395
+ * then the records of the `runtime` reader. A runtime record replaces a build-time record with the same id.
396
+ */
397
+ interface ViteHubConsoleRuntimeRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
398
+ /** Reads build-time records on the server. When omitted, the section has only runtime records. */
399
+ read?: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
400
+ runtime: ViteHubConsoleRuntimeReader;
401
+ /**
402
+ * Returns the absolute path of the application module that turns the section on, such as `server/comments.ts`, or
403
+ * `undefined` when the project has none. With it, the host shows the section only when the module exists; without
404
+ * it, a Vite option enables the section.
405
+ */
406
+ entry?: (options: TOptions) => MaybePromise<string | undefined>;
407
+ }
408
+ /** A section whose list comes from an operation, called with the Console user on each visit. It has no build-time data. */
409
+ interface ViteHubConsoleOperationSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleOperationView> {}
410
+ /**
411
+ * A document editor section. The owner finds the application module that holds its runtime, such as `server/content.ts`,
412
+ * and names the server export that turns that module into {@link ViteHubConsoleDocumentActions}. The host shows the
413
+ * section only when `entry` finds a module, imports the module on the first Console request, and checks the Console
414
+ * section before it calls an action. The owner actions check their own access policy for the signed-in user.
415
+ */
416
+ interface ViteHubConsoleDocumentEditorSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDocumentEditorView> {
417
+ /** Returns the absolute path of the application module, or `undefined` when the project has none. */
418
+ entry: (options: TOptions) => MaybePromise<string | undefined>;
419
+ /**
420
+ * Reads, at build time and without running the application, what the project lacks for some editor features, such as
421
+ * a runner for scheduled publishes. The Console merges it with the owner `setup` action on each request.
422
+ */
423
+ inspect?: (options: TOptions, entry: string) => MaybePromise<ViteHubConsoleDocumentSetup>;
424
+ /** Owner export that must be a {@link ViteHubConsoleDocumentActionsFactory}. */
425
+ actions: ViteHubConsoleServerExport;
426
+ }
427
+ /**
428
+ * A Console section that an owner package contributes. The owner defines the label, icon, view, and data reader.
429
+ * `TOptions` is the discovery context that the host passes to `read`.
430
+ */
431
+ type ViteHubConsoleSectionContribution<TOptions = void> = ViteHubConsoleAuthSection | ViteHubConsoleDefinitionCatalogSection<TOptions> | ViteHubConsoleRecordTableSection<TOptions> | ViteHubConsoleRuntimeRecordTableSection<TOptions> | ViteHubConsoleDocumentEditorSection<TOptions> | ViteHubConsoleOperationSection;
432
+ /** A fix that the owner names for a feature the project lacks, such as `Add authorize to defineContent().` */
433
+ interface ViteHubConsoleDocumentHint {
434
+ /** One sentence that names the fix. Text in backticks shows as code. */
435
+ message: string;
436
+ /** Absolute URL of the documentation for the fix. */
437
+ docs?: string;
438
+ }
439
+ /**
440
+ * What the project lacks for some editor features. The editor names each fix where the feature would be, instead of
441
+ * failing without a reason.
442
+ */
443
+ interface ViteHubConsoleDocumentSetup {
444
+ /** Present when no user can read anything because the owner has no access policy. */
445
+ access?: ViteHubConsoleDocumentHint;
446
+ /**
447
+ * Live co-editing. `definition` names the Realtime Definition whose rooms are `<collection>/<id>`; the editor joins
448
+ * the room of a Markdown document instead of taking the edit lease. `unavailable` names why the owner wanted live
449
+ * editing and the host cannot run it, such as a host without a Realtime authority. Absent when live editing is off.
450
+ */
451
+ live?: {
452
+ definition: string;
453
+ } | {
454
+ unavailable: string;
455
+ };
456
+ /**
457
+ * Present when nothing runs scheduled publishes. The editor disables Schedule, and overdue schedules name the fix.
458
+ */
459
+ schedule?: ViteHubConsoleDocumentHint;
460
+ }
461
+ //#endregion
462
+ //#region src/inspect.d.ts
463
+ interface WorkspaceInspectionOptions {
464
+ /** Vite plugins that can contribute Workspace Definitions through `vitehub.workspaces`. */
465
+ plugins?: readonly unknown[];
466
+ projectRoot: string;
467
+ rootDir: string;
468
+ serverDirs?: string[];
469
+ serverRootDir: string;
470
+ }
471
+ /** Lists Workspace Definitions, Agent workspaces, and contributed Workspaces as serializable inspection summaries. */
472
+ declare function inspectWorkspaceDefinitions(options: WorkspaceInspectionOptions): Promise<ViteHubDefinitionSummary[]>;
473
+ /** Console section that lists discovered Workspace Definitions. `vitehub inspect definitions` reads the same data. */
474
+ declare const workspaceConsoleSection: ViteHubConsoleSectionContribution<WorkspaceInspectionOptions>;
475
+ //#endregion
476
+ export { createWorkspaceNitroConfig as _, ViteWorkspaceDiscoveryOptions as a, WorkspaceContributingPlugin as c, WorkspaceContributionFactory as d, collectWorkspaceContributions as f, WorkspaceVitePluginAPI as g, WorkspaceVitePlugin as h, DiscoveredWorkspaceDefinition as i, WorkspaceContribution as l, WorkspaceNitroConfigOptions as m, inspectWorkspaceDefinitions as n, discoverViteWorkspaceDefinitions as o, NitroConfig as p, workspaceConsoleSection as r, CollectedWorkspaceContribution as s, WorkspaceInspectionOptions as t, WorkspaceContributionContext as u, hubWorkspace as v };
package/dist/vite.d.ts CHANGED
@@ -1,50 +1,2 @@
1
- import { nt as WorkspaceModuleOptions } from "./types-60Yn149G.js";
2
- import { Plugin } from "vite";
3
-
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>;
30
- interface WorkspaceVitePluginAPI {
31
- getWorkspaces: () => Array<{
32
- name: string;
33
- }>;
34
- }
35
- interface WorkspaceCliContributingPlugin {
36
- vitehub?: {
37
- cli?: () => unknown | Promise<unknown>;
38
- };
39
- }
40
- type WorkspaceVitePlugin = Plugin & WorkspaceCliContributingPlugin & {
41
- api: WorkspaceVitePluginAPI;
42
- };
43
- declare function hubWorkspace(options?: WorkspaceModuleOptions): WorkspaceVitePlugin;
44
- declare module "vite" {
45
- interface UserConfig {
46
- workspace?: false | WorkspaceModuleOptions;
47
- }
48
- }
49
- //#endregion
50
- export { NitroConfig, WorkspaceNitroConfigOptions, WorkspaceVitePlugin, WorkspaceVitePluginAPI, createWorkspaceNitroConfig, hubWorkspace };
1
+ import { _ as createWorkspaceNitroConfig, a as ViteWorkspaceDiscoveryOptions, c as WorkspaceContributingPlugin, d as WorkspaceContributionFactory, f as collectWorkspaceContributions, g as WorkspaceVitePluginAPI, h as WorkspaceVitePlugin, i as DiscoveredWorkspaceDefinition, l as WorkspaceContribution, m as WorkspaceNitroConfigOptions, n as inspectWorkspaceDefinitions, o as discoverViteWorkspaceDefinitions, p as NitroConfig, r as workspaceConsoleSection, s as CollectedWorkspaceContribution, t as WorkspaceInspectionOptions, u as WorkspaceContributionContext, v as hubWorkspace } from "./vite-CcZmMQ7S.js";
2
+ export { type CollectedWorkspaceContribution, type DiscoveredWorkspaceDefinition, type NitroConfig, type ViteWorkspaceDiscoveryOptions, type WorkspaceContributingPlugin, type WorkspaceContribution, type WorkspaceContributionContext, type WorkspaceContributionFactory, type WorkspaceInspectionOptions, type WorkspaceNitroConfigOptions, type WorkspaceVitePlugin, type WorkspaceVitePluginAPI, collectWorkspaceContributions, createWorkspaceNitroConfig, discoverViteWorkspaceDefinitions, hubWorkspace, inspectWorkspaceDefinitions, workspaceConsoleSection };
package/dist/vite.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as hubWorkspace, t as createWorkspaceNitroConfig } from "./vite-tbfDxtlu.js";
2
- export { createWorkspaceNitroConfig, hubWorkspace };
1
+ import { a as workspaceConsoleSection, i as inspectWorkspaceDefinitions, n as hubWorkspace, o as discoverViteWorkspaceDefinitions, s as collectWorkspaceContributions, t as createWorkspaceNitroConfig } from "./vite-BEvgU2GY.js";
2
+ export { collectWorkspaceContributions, createWorkspaceNitroConfig, discoverViteWorkspaceDefinitions, hubWorkspace, inspectWorkspaceDefinitions, workspaceConsoleSection };