@mono-lit/utility 0.0.0-stage → 0.0.1

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 (54) hide show
  1. package/LICENSE.md +54 -0
  2. package/README.md +156 -2
  3. package/dist/app-roots-BJsIxzjk.d.ts +91 -0
  4. package/dist/app-roots-CvJnmXcs.js +128 -0
  5. package/dist/config-node-UzJrXg0Z.js +76 -0
  6. package/dist/config-node.d.ts +977 -0
  7. package/dist/config-node.js +7 -0
  8. package/dist/config.d.ts +2 -0
  9. package/dist/config.js +3 -0
  10. package/dist/create-config-D3m6xTaQ.d.ts +733 -0
  11. package/dist/create-config-DdL3Fh6T.js +357 -0
  12. package/dist/fetching.d.ts +239 -0
  13. package/dist/fetching.js +867 -0
  14. package/dist/generate-CJ7MtcDd.js +291 -0
  15. package/dist/index-C2hZeNkq.d.ts +365 -0
  16. package/dist/index-ClrZbU7n.d.ts +518 -0
  17. package/dist/index.d.ts +29 -0
  18. package/dist/index.js +939 -0
  19. package/dist/merge-file-C5nzi_MY.d.ts +122 -0
  20. package/dist/merge-file-CtyKTu5L.js +133 -0
  21. package/dist/mock-db-5mJTObSC.js +1282 -0
  22. package/dist/mock-db.d.ts +2 -0
  23. package/dist/mock-db.js +4 -0
  24. package/dist/mono-alias-DNDm-jB_.js +508 -0
  25. package/dist/mono-clone.mjs +958 -0
  26. package/dist/mono-db.d.ts +1 -0
  27. package/dist/mono-db.js +151 -0
  28. package/dist/mono-env.mjs +231 -0
  29. package/dist/mono-git.mjs +798 -0
  30. package/dist/mono-link-YlOQ2PVS.js +488 -0
  31. package/dist/mono-prepare.d.ts +1 -0
  32. package/dist/mono-prepare.js +27 -0
  33. package/dist/mono-skills.d.ts +1 -0
  34. package/dist/mono-skills.js +830 -0
  35. package/dist/mono-tsconfig-D2qRL9_R.js +204 -0
  36. package/dist/mono.mjs +34 -0
  37. package/dist/nuxt-layers-DP1m7f1-.js +176 -0
  38. package/dist/nuxt-layers.d.ts +34 -0
  39. package/dist/nuxt-layers.js +3 -0
  40. package/dist/nuxt-runtime.d.ts +18 -0
  41. package/dist/nuxt-runtime.js +102 -0
  42. package/dist/nuxt.d.ts +386 -0
  43. package/dist/nuxt.js +590 -0
  44. package/dist/runtime-C_IWNrAG.js +5817 -0
  45. package/dist/runtime.d.ts +2583 -0
  46. package/dist/runtime.js +4 -0
  47. package/dist/session-Bk985AIM.js +1721 -0
  48. package/dist/types-B6FdB7LJ.d.ts +57 -0
  49. package/dist/universal-B2eD9xho.d.ts +97 -0
  50. package/dist/universal-BNTo_83u.js +599 -0
  51. package/dist/virtual-mono-apps.d.ts +16 -0
  52. package/dist/vite.d.ts +940 -0
  53. package/dist/vite.js +1132 -0
  54. package/package.json +141 -3
package/dist/vite.d.ts ADDED
@@ -0,0 +1,940 @@
1
+ import { c as MonoConfig, o as MonoAppType, w as MonoTemplate } from "./create-config-D3m6xTaQ.js";
2
+ import { r as MonoAppRootSource, t as MonoAppRoot } from "./app-roots-BJsIxzjk.js";
3
+ import { Plugin, PluginOption, ViteDevServer } from "vite";
4
+
5
+ //#region src/vite/remote-matcher.d.ts
6
+ /** The options every compat transform accepts, so they stay interchangeable. */
7
+ interface MonoRemoteGateOptions {
8
+ /** Only transform files whose id contains this marker. Default '/.mono/apps/'. */
9
+ appsMarker?: string;
10
+ /**
11
+ * Absolute roots that also count as remote source — a locally-linked app's
12
+ * checkout. `monoRepo()` supplies these; there is nothing to pass by hand.
13
+ */
14
+ appsRoots?: string[];
15
+ }
16
+ //#endregion
17
+ //#region src/vite/mono-pagemeta.d.ts
18
+ interface MonoPageMetaPluginOptions extends MonoRemoteGateOptions {}
19
+ /**
20
+ * Vite plugin: strip the Nuxt page macro `definePageMeta({ … })` from synced
21
+ * remote `.vue` files (those under `.mono/apps/`) so it never reaches the Vue/Vite
22
+ * host's runtime.
23
+ *
24
+ * The Vue host doesn't need the macro: route META (layout/title) is injected
25
+ * separately by the host's `extendRoute` via `parsePageMetaFromFile`, which reads
26
+ * the page from disk (and so is unaffected by this in-memory strip). Removing the
27
+ * call outright — rather than rewriting it to unplugin-vue-router's `definePage`
28
+ * — means we don't depend on vue-router's own macro-stripping transform (and its
29
+ * `transform.filter`/ordering) ever running on the same module. Our single
30
+ * `enforce: 'pre'` transform, before `@vitejs/plugin-vue` compiles the SFC, is
31
+ * all that's required.
32
+ *
33
+ * `enforce: 'pre'` so it runs before the SFC is compiled — place `monoVue()`
34
+ * before `VueRouter()` in the plugins array.
35
+ */
36
+ declare function monoPageMetaToDefinePage(options?: MonoPageMetaPluginOptions): Plugin;
37
+ /** Clearer alias for {@link monoPageMetaToDefinePage}. */
38
+ declare const monoStripPageMeta: typeof monoPageMetaToDefinePage;
39
+ //#endregion
40
+ //#region src/vite/mono-layout-slot.d.ts
41
+ /**
42
+ * Vite plugin: rewrite a synced remote **layout**'s default `<slot/>` (the
43
+ * Nuxt page outlet) into `<router-view />` for the Vue/Vite host.
44
+ *
45
+ * `vite-plugin-vue-layouts-next`'s `setupLayouts` wraps each page as a CHILD
46
+ * route of its layout, so the layout component must render `<router-view/>` for
47
+ * the page to appear. Nuxt layouts instead use `<slot/>` (NuxtLayout injects the
48
+ * page into the default slot). Without this rewrite the page renders nowhere — the
49
+ * layout chrome shows but the page content is blank.
50
+ *
51
+ * Scope: `.vue` files under a remote `.mono/apps/.../layouts/` dir. Only the DEFAULT
52
+ * slot is rewritten — named slots (`<slot name="…">`) are left untouched, since
53
+ * those are real content slots, not the page outlet. `<router-view>` is globally
54
+ * registered by `app.use(router)`, so no import is needed.
55
+ *
56
+ * Mirror of `mono-pagemeta`'s transform; the Nuxt host never runs this (it uses
57
+ * the same layout files via `<slot/>`).
58
+ */
59
+ declare function monoLayoutSlotToRouterView(options?: MonoPageMetaPluginOptions): Plugin;
60
+ //#endregion
61
+ //#region src/vite/mono-nuxt-state.d.ts
62
+ interface MonoNuxtStatePluginOptions extends MonoPageMetaPluginOptions {
63
+ /**
64
+ * Module the shims are imported from. Default `'@mono-lit/utility/runtime'` — change
65
+ * it if the host aliases the package or wants its own implementation.
66
+ */
67
+ importFrom?: string;
68
+ /**
69
+ * Nuxt auto-imports to shim. Default `['useState', 'clearNuxtState']`. Every
70
+ * name listed must be exported by `importFrom`.
71
+ */
72
+ composables?: string[];
73
+ }
74
+ /**
75
+ * Vite plugin: make Nuxt's `useState()` work in a Vue/Vite host.
76
+ *
77
+ * A synced Nuxt remote writes `const msg = useState('msg', () => 'hello')` and
78
+ * relies on Nuxt auto-importing it. Nothing provides that name in a plain Vue app,
79
+ * so the page dies with `useState is not defined`. This plugin rewrites the
80
+ * remote's modules to pull the name from `@mono-lit/utility/runtime`, whose
81
+ * {@link ../composables/nuxt-state.useState | shim} is the same thing minus the
82
+ * SSR payload: a keyed ref registry, so `useState('msg', () => 'hello')` resolves
83
+ * to a shared `ref('hello')` and a keyless call to a plain one.
84
+ *
85
+ * Injecting an import (rather than textually rewriting the call to `ref(...)`)
86
+ * keeps the KEY meaningful — two components on the same key must see one ref,
87
+ * which a per-call `ref()` can't do — and doesn't depend on the host auto-importing
88
+ * `ref`.
89
+ *
90
+ * Scope: files under `.mono/apps/` (the `appsMarker` option; pass `''` to cover the
91
+ * host's own sources too). A file is left alone when it already binds the name
92
+ * itself — an explicit import, a local `const`/`function`, or an aliased
93
+ * (`useState as x`) Nuxt import. A PLAIN import from a Nuxt virtual module
94
+ * (`#imports` / `#app`) is stripped first, since those specifiers resolve to
95
+ * nothing outside Nuxt.
96
+ *
97
+ * `enforce: 'pre'` so `.vue` files are still raw SFC source — register before
98
+ * `@vitejs/plugin-vue`, alongside the other `monoVue()` plugins.
99
+ */
100
+ declare function monoNuxtStateToRef(options?: MonoNuxtStatePluginOptions): Plugin;
101
+ /** Clearer alias for {@link monoNuxtStateToRef}. */
102
+ declare const monoNuxtState: typeof monoNuxtStateToRef;
103
+ //#endregion
104
+ //#region src/vite/mono-link.d.ts
105
+ interface MonoLinkPluginOptions extends MonoPageMetaPluginOptions {
106
+ /**
107
+ * Give an external link `rel="noopener noreferrer"` when it has no `rel` of its
108
+ * own (what `<NuxtLink external>` does). Default true; `no-rel` on the source
109
+ * tag opts out per-link.
110
+ */
111
+ externalRel?: boolean;
112
+ }
113
+ /**
114
+ * Vite plugin: `<NuxtLink>` -> `<RouterLink>` (or `<a>`) for a Vue/Vite host.
115
+ *
116
+ * A synced Nuxt remote links with `<NuxtLink to="/x">`, which Nuxt auto-imports.
117
+ * The Vue host has no such component, so Vue logs `Failed to resolve component:
118
+ * NuxtLink` and renders nothing. This rewrites the tag in remote templates:
119
+ *
120
+ * - `<NuxtLink to="/x">` -> `<RouterLink to="/x">`
121
+ * - `<NuxtLink external to="/x">` -> `<RouterLink to="/x" target="_blank" rel="noopener noreferrer">`
122
+ * - `<NuxtLink to="https://…">` -> `<a href="https://…" rel="noopener noreferrer">`
123
+ *
124
+ * `external` stays a RouterLink because vue-router's `guardEvent` won't intercept
125
+ * a click on a targeted anchor — the browser navigates for real, which is what
126
+ * `external` means, and `to` still resolves as a route. An ABSOLUTE `to` is the
127
+ * one case that can't: `router.resolve('https://x.dev')` treats it as a path and
128
+ * renders `href="/https://x.dev"`, so those become a real `<a>` (with
129
+ * `target="_blank"` too when the tag also said `external`).
130
+ *
131
+ * Nuxt-only props (`prefetch`, `no-rel`, `trailing-slash`, …) are dropped rather
132
+ * than passed through, or they'd land on the DOM as literal attributes. `href` is
133
+ * renamed to `to` (NuxtLink accepts both), and for the `<a>` form `to` becomes
134
+ * `href`. Everything else — `class`, `target`, `@click`, `v-if`, slots — is left
135
+ * exactly as written, and `</NuxtLink>` follows whatever its opening tag became.
136
+ *
137
+ * Case is preserved: `<nuxt-link>` -> `<router-link>`. `RouterLink` is registered
138
+ * globally by `app.use(router)`, so nothing needs importing.
139
+ *
140
+ * LIMITS (both warn at build time rather than mis-compiling): a computed
141
+ * `:external="cond"` can't be resolved here, so the link stays in-app (no
142
+ * `target`); and a `custom` NuxtLink gets neither treatment, since it renders no
143
+ * element of its own — only the `v-slot="{ href, navigate }"` content.
144
+ *
145
+ * `enforce: 'pre'` — the SFC must still be raw source, so register before
146
+ * `@vitejs/plugin-vue` (`monoVue()` / `monoRepo().nuxt().hostResolver()` do).
147
+ */
148
+ declare function monoNuxtLinkToRouterLink(options?: MonoLinkPluginOptions): Plugin;
149
+ /**
150
+ * Vite plugin (Nuxt host): `<RouterLink>` -> `<NuxtLink>` for synced **Vue**
151
+ * remotes — the mirror of {@link monoNuxtLinkToRouterLink}, registered by
152
+ * `@mono-lit/utility/nuxt`.
153
+ *
154
+ * `<RouterLink>` does resolve under Nuxt (vue-router registers it), so this isn't
155
+ * a fix for a broken render — it's so remote links behave like the host's own:
156
+ * route prefetching, external/absolute-URL handling, and `trailingSlash`
157
+ * normalisation, none of which RouterLink does. Every RouterLink prop (`to`,
158
+ * `replace`, `active-class`, `exact-active-class`, `custom`, `aria-current-value`)
159
+ * is a NuxtLink prop too, so this is a pure tag rename — attributes, slots and
160
+ * `v-slot` bindings pass through untouched. Case is preserved:
161
+ * `<router-link>` -> `<nuxt-link>`.
162
+ */
163
+ declare function monoRouterLinkToNuxtLink(options?: MonoLinkPluginOptions): Plugin;
164
+ /** Clearer aliases. */
165
+ declare const monoNuxtLink: typeof monoNuxtLinkToRouterLink;
166
+ declare const monoRouterLink: typeof monoRouterLinkToNuxtLink;
167
+ //#endregion
168
+ //#region src/vite/extend-route.d.ts
169
+ interface MonoExtendRouteOptions extends MonoRemoteGateOptions {
170
+ /**
171
+ * Give every route an explicit `meta.layout` so `setupLayouts` wraps each page
172
+ * exactly once. Without it, a page inside a folder that has no `index.vue`
173
+ * renders its layout TWICE — see {@link monoExtendRoute}. Default true.
174
+ */
175
+ normalizeLayouts?: boolean;
176
+ /**
177
+ * Layout for pages that declare none. MUST match the app's
178
+ * `Layouts({ defaultLayout })`, or those pages get an unknown layout name.
179
+ * Default 'default'.
180
+ */
181
+ defaultLayout?: string;
182
+ }
183
+ /**
184
+ * The narrow surface of vue-router's `EditableTreeNode` we touch in `extendRoute`.
185
+ * `components` is a **Map** (view name -> resolved filepath) in vue-router 5;
186
+ * `component` is the convenience getter for the `default` view's filepath.
187
+ */
188
+ interface ExtendRouteNode {
189
+ component?: string;
190
+ components?: Map<string, string> | Record<string, string>;
191
+ /** Readonly, and NEVER contains `definePage()` meta — parse the source for that. */
192
+ meta?: Readonly<Record<string, unknown>>;
193
+ addToMeta(meta: Record<string, unknown>): void;
194
+ }
195
+ /**
196
+ * Build a `VueRouter({ extendRoute })` callback that does two things.
197
+ *
198
+ * **1. Seeds meta for synced remote pages** (component path under `appsMarker`,
199
+ * default `/.mono/apps/`). Remote Nuxt pages declare meta with `definePageMeta`,
200
+ * which vue-router does not read from disk (and which `monoVue()` strips from the
201
+ * runtime build), so it's parsed from the source and added to the route where
202
+ * `setupLayouts` can see `meta.layout`.
203
+ *
204
+ * **2. Gives every route an explicit layout, so no page is wrapped twice.**
205
+ * `setupLayouts` wraps in two independent places: every TOP-LEVEL record, and any
206
+ * record that declares `meta.layout`. A page folder becomes a component-less GROUP
207
+ * record (`{ path: '/module-one', children: [{ path: 'example', … }] }`), and the
208
+ * plugin's guard against wrapping such a group only fires when the group's `''`
209
+ * child is already a layout — i.e. only when the folder has an `index.vue` that
210
+ * itself declares a layout. Any other shape gets the default layout around the
211
+ * group AND the page's own layout inside it:
212
+ *
213
+ * "/module-one" L(default) <-- group, wrapped because it is top-level
214
+ * "" (group)
215
+ * "example" L(home) <-- page, wrapped because it declares a layout
216
+ * "" PAGE
217
+ *
218
+ * So `pages/module-one/example.vue` renders two nested layouts while
219
+ * `pages/flow/{index,create}.vue` renders one. Fixed per node, no child lookahead:
220
+ * - a group (no component) gets `layout: false`, which `setupLayouts` honours by
221
+ * leaving the record alone — killing the outer wrapper
222
+ * - a page that declares no layout gets `defaultLayout`, so removing that wrapper
223
+ * can't leave a page unwrapped
224
+ *
225
+ * Layout normalisation applies to EVERY route, not just remote ones: a host-owned
226
+ * nested folder doubles exactly the same way. `meta.layout` is read from the page
227
+ * SOURCE because `EditableTreeNode.meta` deliberately excludes `definePage()` meta.
228
+ * A page declaring `layout: false` keeps it — never overwrite an explicit value.
229
+ *
230
+ * Reads the default component filepath via `route.component` — NOT
231
+ * `Object.values(route.components)`, which yields `[]` because `components` is a `Map`.
232
+ *
233
+ * import { monoExtendRoute } from '@mono-lit/utility/vite'
234
+ * VueRouter({ routesFolder: [...], extendRoute: monoExtendRoute() })
235
+ */
236
+ declare function monoExtendRoute(options?: MonoExtendRouteOptions): (route: ExtendRouteNode) => void;
237
+ //#endregion
238
+ //#region src/vite/mono-vite.d.ts
239
+ /**
240
+ * Options shared by every ecosystem key. The federated dirs are mono's job; this
241
+ * is how you say where *this* app's own copies live.
242
+ */
243
+ interface MonoViteOwnDirs {
244
+ /**
245
+ * This app's own dir(s) for that ecosystem, placed BEFORE the federated ones.
246
+ *
247
+ * Defaults to the type-aware convention (`src/pages` in a `vue` app,
248
+ * `app/components` in a `nuxt` one) and is **skipped when it does not exist**,
249
+ * so an app that simply has no `layouts/` needs no configuration. Pass `false`
250
+ * for federated dirs only.
251
+ */
252
+ own?: string | string[] | false;
253
+ }
254
+ /**
255
+ * Options for the underlying plugin, merged OVER mono's defaults. Left loose on
256
+ * purpose: @mono-lit/utility does not depend on these packages (see
257
+ * `./resolve-from-root`), so importing their option types would drag them into
258
+ * the install graph for the sake of autocomplete.
259
+ */
260
+ type PluginOpts = Record<string, any>;
261
+ /** One option object per ecosystem plugin. */
262
+ type MonoEcoOptions = PluginOpts & MonoViteOwnDirs;
263
+ /** The ecosystem plugins mono can build. */
264
+ type MonoEcoKey = 'pages' | 'layouts' | 'composables' | 'components';
265
+ /** Upstream plugin name for each key — used for the duplicate warning. */
266
+ declare const MONO_ECO_PLUGIN_NAMES: Record<MonoEcoKey, string>;
267
+ interface MonoViteOptions {
268
+ /** `vue-router/vite`. `false` to register it yourself. */
269
+ pages?: false | MonoEcoOptions;
270
+ /** `unplugin-vue-components/vite`. */
271
+ components?: false | MonoEcoOptions;
272
+ /** `vite-plugin-vue-layouts-next`. */
273
+ layouts?: false | MonoEcoOptions;
274
+ /** `unplugin-auto-import/vite` — this key carries the plugin's options. */
275
+ composables?: false | MonoEcoOptions;
276
+ /** The stores half of the same auto-import plugin: dirs only. */
277
+ stores?: false | MonoViteOwnDirs;
278
+ /**
279
+ * Force the Nuxt-compat transforms on or off, or pass their options.
280
+ * Default: **auto** — on iff some extends-active app has `type: 'nuxt'`.
281
+ *
282
+ * These are NOT flattened onto the top level, because
283
+ * `MonoRepoNuxtHostOptions` already carries a `composables` key (which Nuxt
284
+ * composables `useState` should be shimmed from) that would collide with the
285
+ * ecosystem key of the same name.
286
+ */
287
+ nuxtCompat?: boolean | MonoRepoNuxtHostOptions;
288
+ /** `false` to skip `extendRoute`. You almost certainly do not want to. */
289
+ extendRoute?: false | MonoExtendRouteOptions;
290
+ }
291
+ /** Everything the builders need from the `monoRepo()` closure. */
292
+ interface MonoViteContext {
293
+ rootDir: string;
294
+ /** This app's own kind, from `mono.config.ts` `type`. */
295
+ ownType: MonoAppType;
296
+ /**
297
+ * This app's own role, from `mono.config.ts` `template`. Leaf-only — never
298
+ * inherited through `extends`. `undefined` behaves as `'remote'`, which is
299
+ * what this file did before the field existed.
300
+ */
301
+ template?: MonoTemplate;
302
+ apps: {
303
+ name: string;
304
+ type: MonoAppType;
305
+ path?: string;
306
+ }[];
307
+ ecosystem: (subs: string | string[]) => string[];
308
+ extendRoute: (options?: MonoExtendRouteOptions) => unknown;
309
+ hostResolver: (options?: MonoRepoNuxtHostOptions) => Plugin[];
310
+ plugin: Plugin;
311
+ /**
312
+ * What the consumer has already wired themselves this config-load, so
313
+ * `vite()` does not register a second copy. Marked SYNCHRONOUSLY, because a
314
+ * `vite.config.ts` array literal evaluates left to right and `vite()` runs in
315
+ * that same pass. Three things mark it:
316
+ *
317
+ * - the plugin factories (`mono.pages()`) and their `.options()` siblings
318
+ * - `mono.ecosystem('pages' | 'components' | 'layouts' | 'composables' |
319
+ * 'stores')` — asking mono for an ecosystem's dirs means you are feeding
320
+ * them to your own plugin, which is exactly the long-hand config
321
+ * - `mono.nuxt().hostResolver()`, which marks `'compat'`
322
+ *
323
+ * An explicit option (`vite({ components: {…} })`) overrides the skip.
324
+ */
325
+ built: Set<MonoEcoKey | 'compat' | 'plugin'>;
326
+ }
327
+ /**
328
+ * Which ecosystem a `mono.ecosystem(sub)` call belongs to, by first path
329
+ * segment — `composables/shared` and `stores/shared` both feed auto-import.
330
+ */
331
+ declare const MONO_ECO_SUB_KEYS: Record<string, MonoEcoKey>;
332
+ /** Map one ecosystem subpath to the plugin that consumes it, if any. */
333
+ declare function ecoKeyForSub(sub: string): MonoEcoKey | undefined;
334
+ /** `VueRouter()` options: own + federated page folders, plus `extendRoute`. */
335
+ declare function monoPagesOptions(ctx: MonoViteContext, opts?: MonoEcoOptions, extendRouteOpts?: false | MonoExtendRouteOptions): PluginOpts;
336
+ /**
337
+ * `Layouts()` options: own layout dirs, plus the federated ones unless this app
338
+ * is the host.
339
+ *
340
+ * Layouts are the one ecosystem where the two roles genuinely disagree. A HOST
341
+ * ships the shared shell, so it renders its own `layouts/` and must not adopt a
342
+ * remote's — a remote's `default.vue` would otherwise compete with the shell's.
343
+ * A REMOTE is the opposite: it has no shell of its own and consumes the host's.
344
+ * `template` in `mono.config.ts` is what says which, and it is the only thing
345
+ * that can — the distinction is not visible on disk (an app with no `layouts/`
346
+ * looks the same either way, and `ownDirs` already drops it).
347
+ *
348
+ * `template` sets a DEFAULT, not a lock: `layoutsDirs` replaces the whole list,
349
+ * so one call can always opt out without a mono-specific knob.
350
+ */
351
+ declare function monoLayoutsOptions(ctx: MonoViteContext, opts?: MonoEcoOptions): PluginOpts;
352
+ /**
353
+ * Per-ecosystem controls for the auto-import plugin.
354
+ *
355
+ * `unplugin-auto-import` is the one plugin that serves TWO ecosystems, because
356
+ * it has a single `dirs` array. So it is named after the plugin rather than an
357
+ * ecosystem, and each ecosystem is a named sub-key — rather than the positional
358
+ * second argument this used to take, or two plugin instances, which would both
359
+ * transform every module and race on the same `auto-imports.d.ts`.
360
+ */
361
+ interface MonoAutoImportOptions extends PluginOpts {
362
+ /** This app's own `composables/` dir, or `false` to take only federated ones. */
363
+ composables?: false | MonoViteOwnDirs;
364
+ /** This app's own `stores/` dir, or `false` to leave stores out entirely. */
365
+ stores?: false | MonoViteOwnDirs;
366
+ }
367
+ /**
368
+ * `AutoImport()` options: own + federated composables AND stores dirs.
369
+ *
370
+ * `imports` covers only the preset NAMES that resolve from this app. The object
371
+ * presets (`unheadVueComposablesImports`, `VueRouterAutoImports`) need a module
372
+ * load, which cannot happen synchronously — import them in your config and pass
373
+ * your own `imports`, or use `mono.autoImport()`, which resolves them for you.
374
+ */
375
+ declare function monoAutoImportOptions(ctx: MonoViteContext, opts?: MonoAutoImportOptions): PluginOpts;
376
+ /** `Components()` options: own + federated component dirs. */
377
+ declare function monoComponentsOptions(ctx: MonoViteContext, opts?: MonoEcoOptions): PluginOpts;
378
+ /** `vue-router/vite` + `ecosystem('pages')` + `extendRoute`. `enforce: 'pre'`. */
379
+ declare function monoPages(ctx: MonoViteContext, opts?: MonoEcoOptions, extendRouteOpts?: false | MonoExtendRouteOptions): Promise<PluginOption>;
380
+ /** `vite-plugin-vue-layouts-next` + `ecosystem('layouts')`. `enforce: 'pre'`. */
381
+ declare function monoLayouts(ctx: MonoViteContext, opts?: MonoEcoOptions): Promise<PluginOption>;
382
+ /**
383
+ * `unplugin-auto-import/vite` + the federated composables AND stores dirs.
384
+ * `enforce: 'post'`. One plugin covers both ecosystems, so `stores` is a
385
+ * dirs-only companion option rather than its own factory.
386
+ */
387
+ declare function monoAutoImport(ctx: MonoViteContext, opts?: MonoAutoImportOptions): Promise<PluginOption>;
388
+ /** `unplugin-vue-components/vite` + `ecosystem('components')`. `enforce: 'post'`. */
389
+ declare function monoComponents(ctx: MonoViteContext, opts?: MonoEcoOptions): Promise<PluginOption>;
390
+ /**
391
+ * Build the federated plugin stack.
392
+ *
393
+ * Returned order matters only WITHIN each `enforce` bucket, and that is exactly
394
+ * what this controls: compat transforms before `VueRouter` (both `pre`), and
395
+ * `mono.plugin` after auto-import/components (both `post`).
396
+ *
397
+ * Any ecosystem plugin already built via its own factory earlier in the same
398
+ * `plugins` array is skipped, so mixing the two styles never double-registers.
399
+ */
400
+ declare function monoVite(ctx: MonoViteContext, opts?: MonoViteOptions): Promise<PluginOption[]>;
401
+ /**
402
+ * Make `mono.vite()` win when an ecosystem is registered twice.
403
+ *
404
+ * The long-hand config registers `VueRouter`/`AutoImport`/`Components`/`Layouts`
405
+ * by hand. Passing that ecosystem to `vite({ components: {…} })` says "mono owns
406
+ * this one now" — so mono's instance stays live and the hand-written one is
407
+ * stood down, leaving exactly one active plugin per ecosystem.
408
+ *
409
+ * When neither instance is mono's, nothing is touched: that is the consumer's
410
+ * own duplicate, and silently disabling one would be worse than saying so.
411
+ */
412
+ declare function reconcileEcoPlugins(plugins: unknown): {
413
+ won: string[];
414
+ conflicting: string[];
415
+ };
416
+ //#endregion
417
+ //#region src/composables/expose.d.ts
418
+ /**
419
+ * Deep-clone `value` keeping ONLY JSON-safe leaves: strings, numbers, booleans,
420
+ * null, plain objects and arrays. Everything else is thrown away automatically —
421
+ * functions & class constructors (e.g. `oDataService: DefaultService`, DevExtreme
422
+ * `DataSource`/`ODataStore`/`CustomStore`), class instances, symbols, `undefined`,
423
+ * `bigint`, `Date`, `Map`, `Set`. Cycles and runaway depth are guarded, so it
424
+ * never throws and never leaks non-serialisable values into a client bundle.
425
+ *
426
+ * The single source of truth for the `__MONO_CONFIG_EXPOSE__` global shared by
427
+ * the Vite host (`monoRepo`) and the Nuxt host (`@mono-lit/utility/nuxt`).
428
+ *
429
+ * Exported so a custom `expose` can opt into the same sanitisation:
430
+ * expose: (c) => sanitizeForExpose({ ...c, extra: customInstance })
431
+ */
432
+ declare function sanitizeForExpose(value: unknown, depth?: number, seen?: WeakSet<object>): unknown;
433
+ //#endregion
434
+ //#region src/vite/mono-repo.d.ts
435
+ interface MonoRepoOptions {
436
+ /**
437
+ * Override/extend the auto-computed `monoAlias` map. Each entry's `dir` is
438
+ * resolved against the project root (absolute paths kept as-is). Example:
439
+ * alias: { '@mono-host': { dir: 'src' } }
440
+ */
441
+ alias?: Record<string, {
442
+ dir: string;
443
+ }>;
444
+ /**
445
+ * Customize the client-exposed config global `__MONO_CONFIG_EXPOSE__`.
446
+ * Receives the resolved mono config; return the (serialisable) object to
447
+ * expose. Defaults to the same trimmed, browser-safe subset the Nuxt module
448
+ * ships (`name`/`apps`/`cookie`/`env`/`jwt`/`menu` + `fetching.auth`).
449
+ */
450
+ expose?: (config: MonoConfig) => Record<string, unknown>;
451
+ /** Packages excluded from Vite dep pre-bundling (web-components dedup). Default ['@mono-lit/helper']. */
452
+ optimizeExclude?: string[];
453
+ /** Project root. Defaults to `process.cwd()` (Vite's default root). */
454
+ dirname?: string;
455
+ /** Folder scanned for remotes. Default './.mono/apps'. */
456
+ appsDir?: string;
457
+ /**
458
+ * Let the config chain load when a federated app isn't synced into
459
+ * `.mono/apps/`: its `mono.config` import resolves to an empty config instead of
460
+ * throwing `Cannot find module '@<app>-root/mono.config'`. Only that specifier is
461
+ * stubbed — app code importing a missing app still fails. Default true.
462
+ */
463
+ stubMissing?: boolean;
464
+ /** Warn (once) naming the apps that were stubbed. Default true. */
465
+ warnMissing?: boolean;
466
+ /**
467
+ * @deprecated `apps[].path` is honoured in every command; nothing depends on
468
+ * which one is running. Accepted so existing `monoRepo({ command })` calls
469
+ * keep type-checking.
470
+ */
471
+ command?: 'serve' | 'build';
472
+ /** @deprecated `apps[].path` is authoritative in every command; ignored. */
473
+ link?: boolean;
474
+ /**
475
+ * Restart the dev server when this app's or any active app's
476
+ * `mono.config.ts` changes (see `monoLith`). Default true.
477
+ */
478
+ restartOnConfigChange?: boolean;
479
+ /**
480
+ * Add every `path` sibling's source dir to the dev watcher, so a page or
481
+ * component ADDED in a sibling reaches the ecosystem plugins. Default true.
482
+ */
483
+ watchSiblings?: boolean;
484
+ }
485
+ /** Options for {@link MonoRepoNuxt.hostResolver} (mirrors `monoNuxtHost`'s options). */
486
+ interface MonoRepoNuxtHostOptions extends MonoNuxtStatePluginOptions, MonoLinkPluginOptions {
487
+ /**
488
+ * Define the Nuxt compile-time constants `import.meta.server` / `import.meta.client`
489
+ * for synced remote code that branches on them (a Vite SPA client is
490
+ * `client: true`, `server: false`). Default true.
491
+ */
492
+ defineImportMeta?: boolean;
493
+ /**
494
+ * Resolve Nuxt's `useState()` (and `clearNuxtState()`) to the `@mono-lit/utility/runtime`
495
+ * shim in synced remote code. Default true.
496
+ */
497
+ nuxtState?: boolean;
498
+ /**
499
+ * Rewrite `<NuxtLink>` in synced remote templates to `<RouterLink>` — plus
500
+ * `target="_blank"` when the link is `external`, or a plain `<a>` when `to` is
501
+ * an absolute URL vue-router can't resolve. Default true.
502
+ */
503
+ nuxtLink?: boolean;
504
+ }
505
+ /**
506
+ * Nuxt-host compatibility helpers — used when a federated **remote is a Nuxt
507
+ * app** rendered inside this Vue/Vite host. Returned by {@link MonoRepoResult.nuxt}.
508
+ */
509
+ interface MonoRepoNuxt {
510
+ /**
511
+ * The Vite plugins that resolve unsupported Nuxt code in a Vue/Vite host
512
+ * (= `monoNuxtHost()`): strips the `definePageMeta({…})` macro from
513
+ * `.mono/apps/*.vue`, rewrites a remote layout's default `<slot/>` ->
514
+ * `<router-view/>`, points Nuxt's auto-imported `useState()` at the
515
+ * `@mono-lit/utility/runtime` shim, rewrites `<NuxtLink>` -> `<RouterLink>` (plus
516
+ * `target="_blank"` when `external`), and defines `import.meta.server`/`import.meta.client`.
517
+ * Spread BEFORE `VueRouter()`:
518
+ * plugins: [...mono.nuxt().hostResolver(), VueRouter({...})]
519
+ */
520
+ hostResolver: (options?: MonoRepoNuxtHostOptions) => Plugin[];
521
+ /**
522
+ * A `VueRouter({ extendRoute })` callback (= `monoExtendRoute()`) that injects
523
+ * `{ layout, title }` parsed from a synced remote page's source so
524
+ * `setupLayouts` can wrap it. Host pages (which use `definePage`) are skipped.
525
+ * VueRouter({ extendRoute: mono.nuxt().extendRoute() })
526
+ */
527
+ extendRoute: (options?: MonoExtendRouteOptions) => ReturnType<typeof monoExtendRoute>;
528
+ }
529
+ /**
530
+ * Result of {@link monoRepo} — a Vite plugin plus the resolved mono values.
531
+ *
532
+ * `plugin` wires `resolve.alias`, `__MONO_CONFIG_EXPOSE__`, `server.fs.allow` and
533
+ * dep dedup; `ecosystem(subs)` discovers remote dirs (type-aware) to feed the
534
+ * ecosystem plugins AT REGISTRATION TIME; `nuxt()` exposes the nuxt-host compat
535
+ * helpers (`hostResolver`, `extendRoute`) for when a remote is a Nuxt app.
536
+ */
537
+ interface MonoRepoResult {
538
+ /**
539
+ * Everything mono-specific, in one entry. Register it LAST.
540
+ *
541
+ * ```ts
542
+ * plugins: [vue({…}), UnoCSS(), mono.vite()]
543
+ * ```
544
+ *
545
+ * **The same call in a host and in a remote.** It is named after Vite, not
546
+ * after a role, because that is what it is: the mono half of *this app's*
547
+ * `vite.config.ts`, whichever side of the federation the app is on.
548
+ * Everything that used to differ between the two templates is derived —
549
+ * the Nuxt-compat transforms from `apps[].type`, `src/` vs `app/` from
550
+ * `type`, the root-`index.vue` exclusion from whether this app ships its own
551
+ * `pages/index.vue`. The one thing that cannot be derived is layouts, and
552
+ * `template: 'host' | 'remote'` in `mono.config.ts` declares it.
553
+ *
554
+ * Always contributes:
555
+ * - **The Nuxt-remote compat transforms** — strips `definePageMeta`, rewrites
556
+ * a remote layout's `<slot/>` to `<router-view/>`, shims `useState`, turns
557
+ * `<NuxtLink>` into `<RouterLink>`. Added **only when a federated remote is
558
+ * `type: 'nuxt'`**, read from `mono.config.ts` — so one config file serves a
559
+ * Nuxt remote and a Vue remote unchanged, with nothing to switch by hand.
560
+ * - **`plugin`** — `resolve.alias`, `__MONO_CONFIG_EXPOSE__`,
561
+ * `server.fs.allow`, dep dedup. Skipped if you list `mono.plugin` yourself.
562
+ *
563
+ * Plus any ecosystem you hand it. Each gets one flat key — `pages`,
564
+ * `components`, `layouts`, `composables`, `stores` — carrying that plugin's
565
+ * options over mono's defaults (see {@link MonoViteOptions}):
566
+ *
567
+ * | you write | result |
568
+ * | --- | --- |
569
+ * | nothing for that key | whatever YOU registered runs; `vite()` stays out |
570
+ * | `{ components: {…} }` | mono builds it and **wins** — your instance is stood down |
571
+ * | `{ components: false }` | yours runs, explicitly |
572
+ *
573
+ * "Stays out" is not guesswork: taking an ecosystem's options or dirs from
574
+ * mono — `mono.components.options()`, `mono.ecosystem('components')` — marks
575
+ * it as yours. And winning means neutralising the loser's hooks rather than
576
+ * removing it, because Vite fixes the plugin list before any `config()` hook
577
+ * runs; mono logs which ones it took over.
578
+ *
579
+ * Position-independent in both directions: Vite buckets plugins by `enforce`
580
+ * before running any hook, and the compat transforms declare a hook-level
581
+ * `order: 'pre'`, so they run ahead of `VueRouter` and `vue()` no matter
582
+ * where this sits.
583
+ */
584
+ vite: (options?: MonoViteOptions) => Promise<PluginOption[]>;
585
+ /**
586
+ * `vue-router/vite`, federated.
587
+ *
588
+ * `mono.pages()` is the ready-made plugin; **`mono.pages.options()`** is just
589
+ * its options, synchronously, for the `VueRouter` you construct:
590
+ *
591
+ * ```ts
592
+ * VueRouter(mono.pages.options())
593
+ * ```
594
+ *
595
+ * What the options carry:
596
+ * - `routesFolder` — this app's own `src/pages` (`app/pages` in a Nuxt app),
597
+ * plus every federated remote's pages, type-driven. Dirs that do not exist
598
+ * are dropped.
599
+ * - `extendRoute` — seeds `{ layout, title }` onto every route, so
600
+ * `setupLayouts` cannot wrap a page twice. Overriding it replaces that;
601
+ * leave it alone unless you mean to.
602
+ * - When this app has its own `pages/index.vue` it owns `/`, so each remote's
603
+ * root `index.vue` is excluded automatically.
604
+ *
605
+ * Anything you pass wins: `mono.pages.options({ importMode: 'sync' })`.
606
+ * `own` sets this app's dir (`false` = federated only); `routesFolder`
607
+ * REPLACES the whole list, federated entries included.
608
+ *
609
+ * Taking either form marks pages as yours, so `vite()` will not register a
610
+ * second `VueRouter`.
611
+ */
612
+ pages: ((options?: MonoEcoOptions) => Promise<PluginOption>) & {
613
+ /** The `VueRouter()` options — see {@link MonoRepoResult.pages}. */options: (options?: MonoEcoOptions) => Record<string, any>;
614
+ };
615
+ /**
616
+ * `vite-plugin-vue-layouts-next`, federated.
617
+ *
618
+ * ```ts
619
+ * Layouts(mono.layouts.options())
620
+ * ```
621
+ *
622
+ * `layoutsDirs` is this app's own `src/layouts` when it exists, plus every
623
+ * federated app's layouts — so an app that ships none resolves to the other
624
+ * app's alone, with nothing hardcoded. `defaultLayout` defaults to
625
+ * `'default'`.
626
+ *
627
+ * **The one ecosystem `template` changes.** A `template: 'host'` app owns the
628
+ * shared shell, so it takes its own layouts and NO federated ones; anything
629
+ * else (including no `template` at all) takes both. Nothing on disk can tell
630
+ * the two apart, which is why this is declared rather than derived.
631
+ *
632
+ * Anything you pass wins: `mono.layouts.options({ defaultLayout: 'blank' })`.
633
+ * `own` sets this app's dir (`false` = federated only); `layoutsDirs`
634
+ * REPLACES the whole list.
635
+ *
636
+ * Taking either form marks layouts as yours, so `vite()` skips its own copy.
637
+ */
638
+ layouts: ((options?: MonoEcoOptions) => Promise<PluginOption>) & {
639
+ /** The `Layouts()` options — see {@link MonoRepoResult.layouts}. */options: (options?: MonoEcoOptions) => Record<string, any>;
640
+ };
641
+ /**
642
+ * `unplugin-auto-import/vite`, federated.
643
+ *
644
+ * ```ts
645
+ * AutoImport(mono.autoImport.options())
646
+ * ```
647
+ *
648
+ * **This one is named after the plugin, not an ecosystem** — it is the only
649
+ * 2:1 case, serving composables AND stores from a single `dirs` array. So
650
+ * both are named sub-keys of one call, rather than two plugin instances
651
+ * (which would each transform every module and race on the same
652
+ * `auto-imports.d.ts`):
653
+ *
654
+ * ```ts
655
+ * AutoImport(mono.autoImport.options({
656
+ * composables: { own: 'src/use' },
657
+ * stores: false, // leave stores out entirely
658
+ * imports: [ … ],
659
+ * }))
660
+ * ```
661
+ *
662
+ * `dirs` is this app's own `composables/` and `stores/` plus every federated
663
+ * remote's `composables`, `composables/shared`, `stores` and `stores/shared`.
664
+ * Dirs that do not exist are dropped.
665
+ *
666
+ * The one asymmetry in this API: **`options()` fills `imports` with the
667
+ * preset NAMES only** (`vue`, `vue-router`, `@vueuse/core`, `pinia` — each
668
+ * only if resolvable from this app). The object presets
669
+ * (`unheadVueComposablesImports`, `VueRouterAutoImports`) need a module load,
670
+ * which cannot happen synchronously — import them in your config and pass
671
+ * your own `imports`, or use the async `mono.autoImport()`, which resolves
672
+ * them for you.
673
+ *
674
+ * Taking either form marks this ecosystem as yours, so `vite()` skips its own.
675
+ */
676
+ autoImport: ((options?: MonoAutoImportOptions) => Promise<PluginOption>) & {
677
+ /** The `AutoImport()` options — see {@link MonoRepoResult.autoImport}. */options: (options?: MonoAutoImportOptions) => Record<string, any>;
678
+ };
679
+ /**
680
+ * Alias of {@link MonoRepoResult.autoImport}, kept because this ecosystem is
681
+ * named `composables` everywhere else (`vite({ composables })`,
682
+ * `ecosystem('composables')`). Prefer `autoImport` — the name says which
683
+ * plugin you get, and that stores come with it.
684
+ */
685
+ composables: ((options?: MonoAutoImportOptions) => Promise<PluginOption>) & {
686
+ options: (options?: MonoAutoImportOptions) => Record<string, any>;
687
+ };
688
+ /**
689
+ * `unplugin-vue-components/vite`, federated.
690
+ *
691
+ * ```ts
692
+ * Components(mono.components.options())
693
+ * ```
694
+ *
695
+ * `dirs` is this app's own `src/components` (`app/components` in a Nuxt app)
696
+ * plus every federated remote's, type-driven; dirs that do not exist are
697
+ * dropped. Defaults also cover `dts`, `directoryAsNamespace`,
698
+ * `collapseSamePrefixes`, `extensions` and `include`.
699
+ *
700
+ * Anything you pass wins:
701
+ * `mono.components.options({ directoryAsNamespace: false })`. `own` sets this
702
+ * app's dir (`false` = federated only); `dirs` REPLACES the whole list, so to
703
+ * ADD one, spread first:
704
+ *
705
+ * ```ts
706
+ * Components(mono.components.options({
707
+ * dirs: [...mono.components.options().dirs, 'src/widgets'],
708
+ * }))
709
+ * ```
710
+ *
711
+ * Taking either form marks components as yours, so `vite()` skips its own.
712
+ */
713
+ components: ((options?: MonoEcoOptions) => Promise<PluginOption>) & {
714
+ /** The `Components()` options — see {@link MonoRepoResult.components}. */options: (options?: MonoEcoOptions) => Record<string, any>;
715
+ };
716
+ /** Vite plugin — register LAST. Wires alias, define, server.fs, optimizeDeps. */
717
+ plugin: Plugin;
718
+ /**
719
+ * Discover remote folders across every extends-active app for the given
720
+ * subpath(s). Type-aware: a `nuxt` remote resolves to `app/<sub>`, a `vue`
721
+ * remote to `src/<sub>`. Equivalent to
722
+ * `monoEcosystem({ dirname, apps, subs })` — centralised here so the config
723
+ * is loaded only once.
724
+ *
725
+ * Pass the result into the ecosystem plugins when you register them:
726
+ * AutoImport({ dirs: ['src/composables', ...mono.ecosystem(['composables/shared', 'composables'])] })
727
+ * Components({ dirs: ['./src/components', ...mono.ecosystem('components')] })
728
+ * Layouts({ layoutsDirs: mono.ecosystem('layouts') })
729
+ * VueRouter({ routesFolder: [{ src: 'src/pages' }, ...mono.ecosystem('pages')] })
730
+ */
731
+ ecosystem: (subs: string | string[]) => string[];
732
+ /**
733
+ * A `VueRouter({ extendRoute })` callback (= `monoExtendRoute()`). Wire it in
734
+ * EVERY federated app, Nuxt remote or not: besides seeding meta for synced Nuxt
735
+ * pages, it gives every route an explicit `meta.layout` so `setupLayouts` can't
736
+ * wrap a page twice (a page in a folder with no `index.vue` otherwise renders
737
+ * its layout nested inside the default one).
738
+ * VueRouter({ routesFolder: [...], extendRoute: mono.extendRoute() })
739
+ */
740
+ extendRoute: (options?: MonoExtendRouteOptions) => ReturnType<typeof monoExtendRoute>;
741
+ /**
742
+ * Nuxt-host compatibility helpers (`hostResolver`, `extendRoute`) for when a
743
+ * federated remote is a Nuxt app rendered in this Vue/Vite host. See
744
+ * {@link MonoRepoNuxt}.
745
+ */
746
+ nuxt: () => MonoRepoNuxt;
747
+ /** The resolved mono config (post `extends`-chain merge). */
748
+ config: MonoConfig;
749
+ /** The computed `monoAlias` map (also applied by `plugin`). */
750
+ alias: Record<string, string>;
751
+ /** The extends-active apps `{ name, type }` that `ecosystem()` discovers over. */
752
+ apps: {
753
+ name: string;
754
+ type: MonoAppType;
755
+ path?: string;
756
+ }[];
757
+ /**
758
+ * Every federated app resolved to the directory it is read from — a
759
+ * `.mono/apps` clone or an `apps[].path` sibling (`source`). For anything
760
+ * that needs the directories themselves, e.g. UnoCSS `content.filesystem`
761
+ * globs over sibling sources.
762
+ */
763
+ appRoots: MonoAppRoot[];
764
+ }
765
+ /**
766
+ * Mono Vite host helper — the single-call Vite equivalent of the Nuxt host's
767
+ * `@mono-lit/utility/nuxt` module.
768
+ *
769
+ * Loads `mono.config.ts` ONCE (c12/jiti, taught the `monoAlias` map), resolves
770
+ * the `extends`-active apps, and returns:
771
+ * - `plugin`: a Vite plugin (register LAST) wiring `resolve.alias`,
772
+ * `__MONO_CONFIG_EXPOSE__`, `server.fs.allow` and dep dedup
773
+ * - `ecosystem(subs)`: type-aware remote dir discovery (`nuxt` -> `app/<sub>`,
774
+ * `vue` -> `src/<sub>`) to feed AutoImport / Components / Layouts / VueRouter
775
+ * `routesFolder` at registration time
776
+ * - `config` / `alias` / `apps`: the resolved values, for advanced use
777
+ *
778
+ * Why async + explicit dirs (not post-registration injection): current
779
+ * `unplugin-auto-import` exposes no `api`, `unplugin-vue-components`' `api` has
780
+ * no `options`, and `vue-router` / `vite-plugin-vue-layouts-next` capture their
781
+ * dirs option in a closure — so none of them can be mutated after registration.
782
+ * Passing dirs at registration is the only reliable path; this helper just
783
+ * centralises the config load so you discover them with one-liner
784
+ * `mono.ecosystem(...)` instead of repeating `monoAlias` / `getMonoConfig` /
785
+ * `activeApps` / `define` / `server.fs` in every host.
786
+ *
787
+ * import { monoRepo } from '@mono-lit/utility/vite'
788
+ *
789
+ * export default defineConfig(async ({ mode }) => {
790
+ * const mono = await monoRepo()
791
+ * return {
792
+ * plugins: [
793
+ * vue({ template: { compilerOptions: { isCustomElement } } }),
794
+ * UnoCSS(),
795
+ * mono.vite(), // ← VueRouter + layouts + auto-import + components + plugin
796
+ * ],
797
+ * }
798
+ * })
799
+ *
800
+ * The same file works whether the federated remote is a Nuxt app or a Vue one —
801
+ * `vite()` reads `apps[].type` and adds the Nuxt-compat transforms only when one
802
+ * is a Nuxt remote. `ecosystem()` stays public for anything `vite()` does not
803
+ * own, and any ecosystem key can be turned off to register it by hand:
804
+ *
805
+ * mono.vite({ layouts: false }),
806
+ * Layouts({ layoutsDirs: mono.ecosystem('layouts') }),
807
+ */
808
+ declare function monoRepo(options?: MonoRepoOptions): Promise<MonoRepoResult>;
809
+ //#endregion
810
+ //#region src/composables/parse-page-meta.d.ts
811
+ /**
812
+ * Page meta mono cares about: `layout` (which layout wraps the page)
813
+ * and `title` (route title). Both optional.
814
+ */
815
+ interface MonoPageMeta {
816
+ /** Layout name, or `false` for a page that opts out of layouts entirely. */
817
+ layout?: string | false;
818
+ title?: string;
819
+ }
820
+ /**
821
+ * Extract `{ layout, title }` from a page's `<script setup>` source, supporting
822
+ * BOTH macro forms:
823
+ * - Nuxt: `definePageMeta({ layout: 'home', title: 'Home' })`
824
+ * - vue-router (unplugin-vue-router): `definePage({ meta: { layout, title } })`
825
+ *
826
+ * String-literal values only (layout/title are always literals in these apps).
827
+ * Used by the Nuxt host module (to seed remote route meta) and by the Vite
828
+ * host's `extendRoute` (since unplugin-vue-router reads page files from disk and
829
+ * never sees the `definePageMeta -> definePage` Vite transform).
830
+ */
831
+ declare function parsePageMeta(code: string): MonoPageMeta;
832
+ /** {@link parsePageMeta} for a file path (build-time, Node). Returns `{}` on read error. */
833
+ declare function parsePageMetaFromFile(file: string): MonoPageMeta;
834
+ //#endregion
835
+ //#region src/vite/resolve-from-root.d.ts
836
+ /** A loader that imports bare specifiers as the app at `rootDir` would. */
837
+ type RootLoader = <T = any>(id: string) => Promise<T>;
838
+ /**
839
+ * Build a {@link RootLoader} anchored at `rootDir`.
840
+ *
841
+ * `createRequire` needs a *file* to resolve from — `noop.js` never has to exist,
842
+ * it only fixes the directory the walk starts in.
843
+ */
844
+ declare function createRootLoader(rootDir: string): RootLoader;
845
+ /** `true` when `id` can be resolved from the app root. Never throws. */
846
+ declare function canResolveFromRoot(rootDir: string, id: string): boolean;
847
+ //#endregion
848
+ //#region src/vite/mono-lith.d.ts
849
+ declare const MONO_APPS_VIRTUAL_ID = "virtual:mono-apps";
850
+ interface MonoLithOptions {
851
+ /** Project root. Defaults to `process.cwd()`. */
852
+ dirname?: string;
853
+ /** Folder scanned for clones. @default './.mono/apps' */
854
+ appsDir?: string;
855
+ /**
856
+ * Pre-resolved roots (what `monoRepo` already computed). Resolved from
857
+ * `mono.config.ts` when omitted.
858
+ */
859
+ appRoots?: MonoAppRoot[];
860
+ /**
861
+ * Names of the apps that contribute — the `extends`-gated set. Every
862
+ * resolved root when omitted. Drives `virtual:mono-apps` and the config
863
+ * watch list; siblings are served and watched regardless.
864
+ */
865
+ activeNames?: string[];
866
+ /**
867
+ * Restart the dev server when any active app's `mono.config.ts` changes.
868
+ * @default true
869
+ */
870
+ restartOnConfigChange?: boolean;
871
+ /**
872
+ * Add every `path` sibling's source dir to the dev watcher so new files are
873
+ * picked up by the ecosystem plugins.
874
+ * @default true
875
+ */
876
+ watchSiblings?: boolean;
877
+ }
878
+ /** The hooks, shared by {@link monoLith} and `monoRepo`'s own plugin. */
879
+ interface MonoLithHooks {
880
+ /** Extra `server.fs.allow` entries: every `path` root. */
881
+ fsAllow: string[];
882
+ /** The resolved roots this instance works from. */
883
+ appRoots: MonoAppRoot[];
884
+ configureServer: (server: ViteDevServer) => void;
885
+ resolveId: (id: string) => string | undefined;
886
+ load: (id: string) => string | undefined;
887
+ }
888
+ declare function createMonoLithHooks(options?: MonoLithOptions): MonoLithHooks;
889
+ /**
890
+ * Standalone plugin for a long-hand `vite.config.ts`. `monoRepo().vite()` /
891
+ * `mono.plugin` already include these hooks — do not register both.
892
+ *
893
+ * ```ts
894
+ * import { monoLith } from '@mono-lit/utility/vite'
895
+ * plugins: [VueRouter({ … }), vue(), monoLith({ dirname: __dirname })]
896
+ * ```
897
+ */
898
+ declare function monoLith(options?: MonoLithOptions): Plugin;
899
+ //#endregion
900
+ //#region src/vite/index.d.ts
901
+ interface MonoVueOptions extends MonoNuxtStatePluginOptions, MonoLinkPluginOptions {
902
+ /**
903
+ * Define the Nuxt compile-time constants `import.meta.server` /
904
+ * `import.meta.client` for synced remote code that branches on them
905
+ * (a Vite SPA client is `client: true`, `server: false`). Default true.
906
+ */
907
+ defineImportMeta?: boolean;
908
+ /**
909
+ * Resolve Nuxt's `useState()` (and `clearNuxtState()`) to the `@mono-lit/utility/runtime`
910
+ * shim in synced remote code. Default true.
911
+ */
912
+ nuxtState?: boolean;
913
+ /**
914
+ * Rewrite `<NuxtLink>` in synced remote templates to `<RouterLink>` — plus
915
+ * `target="_blank"` when the link is `external`, or a plain `<a>` when `to` is
916
+ * an absolute URL vue-router can't resolve. Default true.
917
+ */
918
+ nuxtLink?: boolean;
919
+ }
920
+ /**
921
+ * Vite-host compatibility layer for running a **Nuxt remote** inside a plain
922
+ * Vue 3 + Vite host. Returns the plugins needed for the narrow Nuxt surface the
923
+ * synced remote code uses:
924
+ * - strips the Nuxt `definePageMeta({…})` macro from `.mono/apps/*.vue` (route meta is
925
+ * injected separately by the host's `extendRoute` via `parsePageMetaFromFile`)
926
+ * - rewrites a remote layout's default `<slot/>` -> `<router-view/>` (so Nuxt
927
+ * `<slot>` layouts render the page under `setupLayouts`' nested routes)
928
+ * - points Nuxt's auto-imported `useState()` at the `@mono-lit/utility/runtime` shim
929
+ * (a keyed ref registry — `useState('k', () => 'hello')` -> a shared `ref('hello')`)
930
+ * - rewrites `<NuxtLink>` -> `<RouterLink>` (`external` adds `target="_blank"`,
931
+ * so the browser navigates for real; an absolute-URL `to` becomes an `<a>`)
932
+ * - defines `import.meta.server`/`import.meta.client` (SPA client constants)
933
+ *
934
+ * Mirrors `@mono-lit/helper/vite`'s `monoSsr()` shape. Register before `VueRouter()`:
935
+ * import { monoVue } from '@mono-lit/utility/vite'
936
+ * plugins: [ ...monoVue(), VueRouter({...}), vue(), ... ]
937
+ */
938
+ declare function monoVue(options?: MonoVueOptions): Plugin[];
939
+ //#endregion
940
+ export { MONO_APPS_VIRTUAL_ID, MONO_ECO_PLUGIN_NAMES, MONO_ECO_SUB_KEYS, type MonoAppRoot, type MonoAppRootSource, type MonoAutoImportOptions, type MonoEcoKey, type MonoEcoOptions, type MonoExtendRouteOptions, type MonoLinkPluginOptions, type MonoLithHooks, type MonoLithOptions, type MonoNuxtStatePluginOptions, type MonoPageMeta, type MonoPageMetaPluginOptions, type MonoRepoNuxt, type MonoRepoNuxtHostOptions, type MonoRepoOptions, type MonoRepoResult, type MonoViteContext, type MonoViteOptions, type MonoViteOwnDirs, MonoVueOptions, type RootLoader, canResolveFromRoot, createMonoLithHooks, createRootLoader, ecoKeyForSub, monoAutoImport, monoAutoImportOptions, monoComponents, monoComponentsOptions, monoExtendRoute, monoLayoutSlotToRouterView, monoLayouts, monoLayoutsOptions, monoLith, monoVue as monoNuxtHost, monoVue, monoNuxtLink, monoNuxtLinkToRouterLink, monoNuxtState, monoNuxtStateToRef, monoPageMetaToDefinePage, monoPages, monoPagesOptions, monoRepo, monoRouterLink, monoRouterLinkToNuxtLink, monoStripPageMeta, monoVite, parsePageMeta, parsePageMetaFromFile, reconcileEcoPlugins, sanitizeForExpose };