@mono-lit/utility 0.0.4 → 0.0.6

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.
package/README.md CHANGED
@@ -1,157 +1,157 @@
1
- # Mono Utils
2
-
3
- A comprehensive utility library for Vue.js applications built around DevExtreme UI components, providing powerful data management, validation, and export capabilities.
4
-
5
- ## Features
6
-
7
- - 🔧 **OData Integration** - Sophisticated OData client with batch operations, caching, and error handling
8
- - 🎛️ **DevExtreme Helpers** - Utilities for data grids, lookups, and form components
9
- - ✅ **Schema Validation** - Yup or Valibot (any Standard Schema) validation with nested object support
10
- - 📊 **Excel Export** - Advanced Excel export capabilities with custom formatting and formulas
11
- - 🔔 **Notification System** - Notivue-based notification management
12
- - 🚨 **Error Handling** - Comprehensive HTTP and OData error handling
13
- - 🔄 **Data Manipulation** - Powerful utilities for data transformation and operations
14
-
15
- ## Installation
16
-
17
- **From npmjs (public):**
18
-
19
- ```bash
20
- pnpm add @mono-lit/utility
21
- ```
22
-
23
- **From the Netlify registry:** add this to your project's `.npmrc`, then run the same `pnpm add`:
24
-
25
- ```ini
26
- @mono-lit:registry=https://mono-libs.netlify.app/npm/
27
- //mono-libs.netlify.app/npm/:_authToken=<REGISTRY_DOWNLOAD_TOKEN>
28
- ```
29
-
30
- See the [repository README](https://github.com/mono-lit/core#install-in-your-project) for details.
31
-
32
- ## Dependencies
33
-
34
- ### Core Dependencies
35
-
36
- These are the essential dependencies required for core functionality:
37
-
38
- ```bash
39
- npm install notivue valibot exceljs file-saver-es @odata2ts/http-client-fetch json-server change-case chokidar
40
- ```
41
-
42
- **Note:** The additional dependencies (`json-server`, `change-case`, `chokidar`) are recommended for development and should be installed as devDependencies:
43
-
44
- ```bash
45
- npm install --save-dev json-server change-case chokidar
46
- ```
47
-
48
- ### Optional DevExtreme Dependencies
49
-
50
- **For DevExtreme UI Components:**
51
- If you're using DevExtreme components, you'll also need:
52
-
53
- ```bash
54
- npm install devextreme devextreme-vue
55
- ```
56
-
57
- **Note:** The core data fetching, validation, and Excel export utilities work independently of any UI framework. You can use this library with Vue, React, Angular, or vanilla JavaScript.
58
-
59
- ## Quick Start
60
-
61
- ### Basic Setup
62
-
63
- ```vue
64
- <script setup>
65
- import { useUtils } from '@mono-lit/utility/runtime'
66
-
67
- const utils = useUtils()
68
-
69
- // Destructure the utilities you need
70
- const {
71
- notif,
72
- validateAllSchema,
73
- validateSchema,
74
- replacerData,
75
- exportExcel,
76
- useFetchOData,
77
- createFetcher,
78
- advanceExportExcel
79
- } = utils
80
- </script>
81
- ```
82
-
83
- ### Usage Without DevExtreme
84
-
85
- For users working with other UI frameworks (React, Angular, or vanilla JavaScript), you can still use the core data fetching, validation, and export utilities:
86
-
87
- ```javascript
88
- import { useUtils } from '@mono-lit/utility/runtime'
89
-
90
- const { useFetchOData, notif, advanceExportExcel } = useUtils()
91
-
92
- // Fetch data
93
- const { data, error } = await useFetchOData({
94
- url: '/Users',
95
- baseUrl: 'https://your-api.com/odata',
96
- type: 'data'
97
- })
98
-
99
- if (error) {
100
- notif({
101
- message: error.message,
102
- type: 'error'
103
- })
104
- }
105
-
106
- // Export to Excel
107
- await advanceExportExcel({
108
- title: 'User Report',
109
- items: data,
110
- config: {
111
- columns: [
112
- { key: 'Id', title: 'ID', width: 10 },
113
- { key: 'Name', title: 'Name', width: 30 },
114
- { key: 'Email', title: 'Email', width: 40 }
115
- ]
116
- }
117
- })
118
- ```
119
-
120
- ## Documentation
121
-
122
- - **[Data Fetching](./docs/data-fetching.md)** - OData integration, HTTP client, data manipulation
123
- - **[Excel Export](./docs/excel-export.md)** - Advanced Excel export with formatting and formulas
124
- - **[Validation](./docs/validation.md)** - Schema validation with Yup or Valibot
125
- - **[Notifications](./docs/notifications.md)** - Notivue-based notification system
126
- - **[DevExtreme Integration](./docs/devextreme-integration.md)** - DevExtreme UI helpers and components
127
-
128
- ## API Reference
129
-
130
- ### useUtils Return Object
131
-
132
- The main `useUtils()` function returns an object with the following utilities:
133
-
134
- #### Core Utilities
135
- - `notif` - Notification system
136
- - `validateAllSchema` - Validate entire form (Yup or Valibot)
137
- - `validateSchema` - Validate single field (Yup or Valibot)
138
- - `validateAllSchemaCheck` - Check if any validation errors exist
139
- - `clearSchemaValidation` - Clear all validation errors
140
-
141
- #### Data Utilities
142
- - `replacerData` - Add/update/remove items from arrays or DataSources
143
- - `filterOrIn` - Create OData filter expressions
144
-
145
- #### UI Components
146
- - `exportExcel` - Basic Excel export
147
- - `advanceExportExcel` - Advanced Excel export with formulas
148
-
149
- #### OData & HTTP
150
- - `useFetchOData` - Main OData fetching utility
151
- - `createFetcher` - Create reusable fetchers
152
- - `useNormalFetch` - Simple HTTP fetch utility
153
- - `createUniqueFetcher` - Fetch unique records
154
-
155
- ## License
156
-
1
+ # Mono Utils
2
+
3
+ A comprehensive utility library for Vue.js applications built around DevExtreme UI components, providing powerful data management, validation, and export capabilities.
4
+
5
+ ## Features
6
+
7
+ - 🔧 **OData Integration** - Sophisticated OData client with batch operations, caching, and error handling
8
+ - 🎛️ **DevExtreme Helpers** - Utilities for data grids, lookups, and form components
9
+ - ✅ **Schema Validation** - Yup or Valibot (any Standard Schema) validation with nested object support
10
+ - 📊 **Excel Export** - Advanced Excel export capabilities with custom formatting and formulas
11
+ - 🔔 **Notification System** - Notivue-based notification management
12
+ - 🚨 **Error Handling** - Comprehensive HTTP and OData error handling
13
+ - 🔄 **Data Manipulation** - Powerful utilities for data transformation and operations
14
+
15
+ ## Installation
16
+
17
+ **From npmjs (public):**
18
+
19
+ ```bash
20
+ pnpm add @mono-lit/utility
21
+ ```
22
+
23
+ **From the Netlify registry:** add this to your project's `.npmrc`, then run the same `pnpm add`:
24
+
25
+ ```ini
26
+ @mono-lit:registry=https://mono-libs.netlify.app/npm/
27
+ //mono-libs.netlify.app/npm/:_authToken=<REGISTRY_DOWNLOAD_TOKEN>
28
+ ```
29
+
30
+ See the [repository README](https://github.com/mono-lit/core#install-in-your-project) for details.
31
+
32
+ ## Dependencies
33
+
34
+ ### Core Dependencies
35
+
36
+ These are the essential dependencies required for core functionality:
37
+
38
+ ```bash
39
+ npm install notivue valibot exceljs file-saver-es @odata2ts/http-client-fetch json-server change-case chokidar
40
+ ```
41
+
42
+ **Note:** The additional dependencies (`json-server`, `change-case`, `chokidar`) are recommended for development and should be installed as devDependencies:
43
+
44
+ ```bash
45
+ npm install --save-dev json-server change-case chokidar
46
+ ```
47
+
48
+ ### Optional DevExtreme Dependencies
49
+
50
+ **For DevExtreme UI Components:**
51
+ If you're using DevExtreme components, you'll also need:
52
+
53
+ ```bash
54
+ npm install devextreme devextreme-vue
55
+ ```
56
+
57
+ **Note:** The core data fetching, validation, and Excel export utilities work independently of any UI framework. You can use this library with Vue, React, Angular, or vanilla JavaScript.
58
+
59
+ ## Quick Start
60
+
61
+ ### Basic Setup
62
+
63
+ ```vue
64
+ <script setup>
65
+ import { useUtils } from '@mono-lit/utility/runtime'
66
+
67
+ const utils = useUtils()
68
+
69
+ // Destructure the utilities you need
70
+ const {
71
+ notif,
72
+ validateAllSchema,
73
+ validateSchema,
74
+ replacerData,
75
+ exportExcel,
76
+ useFetchOData,
77
+ createFetcher,
78
+ advanceExportExcel
79
+ } = utils
80
+ </script>
81
+ ```
82
+
83
+ ### Usage Without DevExtreme
84
+
85
+ For users working with other UI frameworks (React, Angular, or vanilla JavaScript), you can still use the core data fetching, validation, and export utilities:
86
+
87
+ ```javascript
88
+ import { useUtils } from '@mono-lit/utility/runtime'
89
+
90
+ const { useFetchOData, notif, advanceExportExcel } = useUtils()
91
+
92
+ // Fetch data
93
+ const { data, error } = await useFetchOData({
94
+ url: '/Users',
95
+ baseUrl: 'https://your-api.com/odata',
96
+ type: 'data'
97
+ })
98
+
99
+ if (error) {
100
+ notif({
101
+ message: error.message,
102
+ type: 'error'
103
+ })
104
+ }
105
+
106
+ // Export to Excel
107
+ await advanceExportExcel({
108
+ title: 'User Report',
109
+ items: data,
110
+ config: {
111
+ columns: [
112
+ { key: 'Id', title: 'ID', width: 10 },
113
+ { key: 'Name', title: 'Name', width: 30 },
114
+ { key: 'Email', title: 'Email', width: 40 }
115
+ ]
116
+ }
117
+ })
118
+ ```
119
+
120
+ ## Documentation
121
+
122
+ - **[Data Fetching](./docs/data-fetching.md)** - OData integration, HTTP client, data manipulation
123
+ - **[Excel Export](./docs/excel-export.md)** - Advanced Excel export with formatting and formulas
124
+ - **[Validation](./docs/validation.md)** - Schema validation with Yup or Valibot
125
+ - **[Notifications](./docs/notifications.md)** - Notivue-based notification system
126
+ - **[DevExtreme Integration](./docs/devextreme-integration.md)** - DevExtreme UI helpers and components
127
+
128
+ ## API Reference
129
+
130
+ ### useUtils Return Object
131
+
132
+ The main `useUtils()` function returns an object with the following utilities:
133
+
134
+ #### Core Utilities
135
+ - `notif` - Notification system
136
+ - `validateAllSchema` - Validate entire form (Yup or Valibot)
137
+ - `validateSchema` - Validate single field (Yup or Valibot)
138
+ - `validateAllSchemaCheck` - Check if any validation errors exist
139
+ - `clearSchemaValidation` - Clear all validation errors
140
+
141
+ #### Data Utilities
142
+ - `replacerData` - Add/update/remove items from arrays or DataSources
143
+ - `filterOrIn` - Create OData filter expressions
144
+
145
+ #### UI Components
146
+ - `exportExcel` - Basic Excel export
147
+ - `advanceExportExcel` - Advanced Excel export with formulas
148
+
149
+ #### OData & HTTP
150
+ - `useFetchOData` - Main OData fetching utility
151
+ - `createFetcher` - Create reusable fetchers
152
+ - `useNormalFetch` - Simple HTTP fetch utility
153
+ - `createUniqueFetcher` - Fetch unique records
154
+
155
+ ## License
156
+
157
157
  This project is licensed under the MIT License.
@@ -78,6 +78,18 @@ declare function appRootDirs(roots: MonoAppRoot[]): string[];
78
78
  declare function pathAppRoots(roots: MonoAppRoot[]): MonoAppRoot[];
79
79
  /** @deprecated renamed {@link pathAppRoots}. */
80
80
  declare const linkedAppRoots: typeof pathAppRoots;
81
+ /**
82
+ * `true` for a HOSTED (mini) app: a source-only root with no `package.json`.
83
+ *
84
+ * A mini remote ships pages/components/composables and its `mono.config.ts`,
85
+ * nothing else — no dependencies, no build config, no env. It cannot install
86
+ * or run by itself; the host that federates it supplies all of that. Derived
87
+ * from the folder rather than declared, so nothing in `apps[]` changes: the
88
+ * same entry (`url` or `path`) serves a full remote and a mini.
89
+ */
90
+ declare function isHostedApp(root: string): boolean;
91
+ /** The hosted (mini) subset of `roots` — see {@link isHostedApp}. */
92
+ declare function hostedAppRoots(roots: MonoAppRoot[]): MonoAppRoot[];
81
93
  /** `true` when an app entry can be synced from GitHub. */
82
94
  declare function hasUrl(app: MonoAppRootInput | undefined): boolean;
83
95
  /** The error every entry point raises for a `path` with no directory and no `url`. */
@@ -87,4 +99,4 @@ declare function isMissingPathError(e: unknown): boolean;
87
99
  /** Test seam: forget which missing paths have been reported. */
88
100
  declare function resetAppPathWarnings(): void;
89
101
  //#endregion
90
- export { ResolveAppRootsOptions as a, isMissingPathError as c, pathAppRoots as d, resetAppPathWarnings as f, MonoMissingPathPolicy as i, linkedAppRoots as l, MonoAppRootInput as n, appRootDirs as o, resolveAppRoots as p, MonoAppRootSource as r, hasUrl as s, MonoAppRoot as t, missingPathMessage as u };
102
+ export { ResolveAppRootsOptions as a, hostedAppRoots as c, linkedAppRoots as d, missingPathMessage as f, resolveAppRoots as h, MonoMissingPathPolicy as i, isHostedApp as l, resetAppPathWarnings as m, MonoAppRootInput as n, appRootDirs as o, pathAppRoots as p, MonoAppRootSource as r, hasUrl as s, MonoAppRoot as t, isMissingPathError as u };
@@ -94,6 +94,22 @@ function pathAppRoots(roots) {
94
94
  }
95
95
  /** @deprecated renamed {@link pathAppRoots}. */
96
96
  const linkedAppRoots = pathAppRoots;
97
+ /**
98
+ * `true` for a HOSTED (mini) app: a source-only root with no `package.json`.
99
+ *
100
+ * A mini remote ships pages/components/composables and its `mono.config.ts`,
101
+ * nothing else — no dependencies, no build config, no env. It cannot install
102
+ * or run by itself; the host that federates it supplies all of that. Derived
103
+ * from the folder rather than declared, so nothing in `apps[]` changes: the
104
+ * same entry (`url` or `path`) serves a full remote and a mini.
105
+ */
106
+ function isHostedApp(root) {
107
+ return isDirectory(root) && !fs.existsSync(path.join(root, "package.json"));
108
+ }
109
+ /** The hosted (mini) subset of `roots` — see {@link isHostedApp}. */
110
+ function hostedAppRoots(roots) {
111
+ return roots.filter((r) => isHostedApp(r.root));
112
+ }
97
113
  /** `true` when an app entry can be synced from GitHub. */
98
114
  function hasUrl(app) {
99
115
  return typeof app?.url === "string" && app.url.trim().length > 0;
@@ -125,4 +141,4 @@ function resetAppPathWarnings() {
125
141
  }
126
142
 
127
143
  //#endregion
128
- export { missingPathMessage as a, resolveAppRoots as c, linkedAppRoots as i, hasUrl as n, pathAppRoots as o, isMissingPathError as r, resetAppPathWarnings as s, appRootDirs as t };
144
+ export { isMissingPathError as a, pathAppRoots as c, isHostedApp as i, resetAppPathWarnings as l, hasUrl as n, linkedAppRoots as o, hostedAppRoots as r, missingPathMessage as s, appRootDirs as t, resolveAppRoots as u };
@@ -1,5 +1,5 @@
1
1
  import { S as MonoSkillConfig, c as MonoConfig, o as MonoAppType, w as MonoTemplate } from "./create-config-B8IhX4ht.js";
2
- import { a as ResolveAppRootsOptions, c as isMissingPathError, d as pathAppRoots, f as resetAppPathWarnings, i as MonoMissingPathPolicy, l as linkedAppRoots, n as MonoAppRootInput, o as appRootDirs, p as resolveAppRoots, r as MonoAppRootSource, s as hasUrl, t as MonoAppRoot, u as missingPathMessage } from "./app-roots-DK41xMWj.js";
2
+ import { a as ResolveAppRootsOptions, c as hostedAppRoots, d as linkedAppRoots, f as missingPathMessage, h as resolveAppRoots, i as MonoMissingPathPolicy, l as isHostedApp, m as resetAppPathWarnings, n as MonoAppRootInput, o as appRootDirs, p as pathAppRoots, r as MonoAppRootSource, s as hasUrl, t as MonoAppRoot, u as isMissingPathError } from "./app-roots-BlcIuAan.js";
3
3
  import { LoadConfigOptions } from "c12";
4
4
  import { TSConfig } from "pkg-types";
5
5
  //#region src/composables/config-node.d.ts
@@ -305,6 +305,11 @@ export interface RunMonoPrepareResult {
305
305
  * does not exist yet — they have not run their own `mono prepare`.
306
306
  */
307
307
  unpreparedApps: string[];
308
+ /**
309
+ * Hosted (mini) `path` apps — no `package.json` — this host prepared on their
310
+ * behalf: `node_modules` linked to the host's, `.mono/tsconfig.json` written.
311
+ */
312
+ hostedApps: HostedAppPrepared[];
308
313
  }
309
314
  /**
310
315
  * Generate `<dirname>/.mono/tsconfig.json` from the mono alias map and wire it
@@ -312,6 +317,43 @@ export interface RunMonoPrepareResult {
312
317
  * inline `@mono-*` paths. Idempotent: safe to run repeatedly.
313
318
  */
314
319
  export declare function runMonoPrepare(opts: RunMonoPrepareOptions): Promise<RunMonoPrepareResult>;
320
+ /** What {@link adoptHostedApps} did for one hosted (mini) `path` app. */
321
+ export interface HostedAppPrepared {
322
+ name: string;
323
+ /** `<mini>/node_modules` -> `<host>/node_modules`: made, already right, or left alone. */
324
+ link: 'created' | 'kept' | 'skipped';
325
+ /** Absolute path of the generated `<mini>/.mono/tsconfig.json`. */
326
+ tsconfig: string;
327
+ }
328
+ /**
329
+ * Prepare every HOSTED (mini) app read in place through `apps[].path`, from the
330
+ * host's side — the mini has no `package.json`, so it can never run a
331
+ * `mono prepare` (or an install) of its own.
332
+ *
333
+ * Only a mini that names THIS host in its own `apps[]` (by name — typically a
334
+ * `url` entry — or by a `path` landing here) is prepared: the wiring is declared
335
+ * on both sides, never inferred. Any other hosted app is skipped with a warning
336
+ * that spells out the entry to add.
337
+ *
338
+ * 1. `<mini>/node_modules` becomes a link (a junction on Windows — no admin
339
+ * rights needed) to the host's `node_modules`. A sibling outside the host
340
+ * has no `node_modules` above it, so every bare import in its files —
341
+ * `vue`, `@mono-lit/utility/*` — fails in Vite AND in jiti (the host's c12
342
+ * loads the mini's `mono.config.ts`). One link fixes Vite, jiti, vue-tsc and
343
+ * the editor together, and because the realpaths ARE the host's, there is
344
+ * still exactly one copy of Vue. A real directory there is never touched.
345
+ * 2. `<mini>/.mono/tsconfig.json` extends the host's config (Nuxt host:
346
+ * `.nuxt/tsconfig.app.json`, Vite host: `tsconfig.json`), and — when the
347
+ * mini has none — `<mini>/tsconfig.json` extends that, so the editor
348
+ * type-checks the mini against the host's aliases and generated
349
+ * auto-import/route types.
350
+ *
351
+ * Unlike `wireClonedApps`' rule for full `path` apps, this DOES write into the
352
+ * sibling — but only files a mini gitignores (`node_modules`, `.mono/`, the
353
+ * generated `tsconfig.json`). Nothing it commits is ever edited. A clone under `.mono/apps` needs none
354
+ * of this: Node already walks up to the host's `node_modules`.
355
+ */
356
+ export declare function adoptHostedApps(dirname: string): HostedAppPrepared[];
315
357
  //#endregion
316
358
  //#region src/skills/config.d.ts
317
359
  /**
@@ -920,4 +962,4 @@ export declare function runSessionShow({ cwd, app, sessionId, remote, run }: {
920
962
  run?: GitRunner;
921
963
  }): SessionShowResult;
922
964
  //#endregion
923
- export { MonoAppRoot, MonoAppRootInput, MonoAppRootSource, MonoMissingPathPolicy, type MonoSkillConfig, ResolveAppRootsOptions, appRootDirs, hasUrl, isMissingPathError, linkedAppRoots, missingPathMessage, pathAppRoots, resetAppPathWarnings, resolveAppRoots };
965
+ export { MonoAppRoot, MonoAppRootInput, MonoAppRootSource, MonoMissingPathPolicy, type MonoSkillConfig, ResolveAppRootsOptions, appRootDirs, hasUrl, hostedAppRoots, isHostedApp, isMissingPathError, linkedAppRoots, missingPathMessage, pathAppRoots, resetAppPathWarnings, resolveAppRoots };
@@ -1,7 +1,7 @@
1
- import { a as missingPathMessage, c as resolveAppRoots, i as linkedAppRoots, n as hasUrl, o as pathAppRoots, r as isMissingPathError, s as resetAppPathWarnings, t as appRootDirs } from "./app-roots-CvJnmXcs.js";
1
+ import { a as isMissingPathError, c as pathAppRoots, i as isHostedApp, l as resetAppPathWarnings, n as hasUrl, o as linkedAppRoots, r as hostedAppRoots, s as missingPathMessage, t as appRootDirs, u as resolveAppRoots } from "./app-roots-LpDrHF_J.js";
2
2
  import { n as loadMonoConfig, t as getMonoConfig } from "./config-node-UzJrXg0Z.js";
3
- import { a as extractTemplate, c as monoConfigFileFor, d as resolveFederatedRoots, f as stripCommentsSafe, i as extractSkill, l as monoMissingApps, n as extractConfig, o as formatMissingApps, r as extractConfigName, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-DNDm-jB_.js";
4
- import { a as monoTsconfigPaths, i as buildMonoTsconfig, n as MONO_DIR, o as runMonoPrepare, r as MONO_TSCONFIG_REF, t as MONO_APPS_DIR } from "./mono-tsconfig-D2qRL9_R.js";
5
- import { A as BASE_ARGS, B as refPatterns, C as commitAndPush, D as repoDir, E as readRepoFile, F as parseHeadSha, G as SKILLS_DEFAULTS, H as tokenRemote, I as parseLsRemote, J as loadSkillsEnv, K as isGenericAppName, L as parseSymref, M as firstFatal, N as gitEnv, O as resolveRemote, P as isNonFastForward, R as redactUrl, S as SkillsAccessError, T as listRepoFiles, U as ALLOWED_FLAGS, V as runGit, W as GENERIC_APP_NAMES, Y as resolveSkillTarget, _ as stagingRoot, a as applyPlan, b as resolveAppId, c as chunkConversation, d as REQUIRED_FILES, f as cacheDir, g as removeSession, h as moveToFailed, i as runSearch, j as classifyGitFailure, k as skillsRoot, l as redact, m as loadStagedSession, n as runCheck, o as buildSavePlan, p as listSessions, q as loadSkillConfig, r as runRead, s as runSave, t as runSessionShow, u as redactBuffer, v as validateStagedSession, w as ensureRepo, x as detectActor, y as normalizeAppId, z as refDirCandidates } from "./session-Bcig-rPi.js";
3
+ import { a as extractTemplate, c as monoConfigFileFor, d as resolveFederatedRoots, f as stripCommentsSafe, i as extractSkill, l as monoMissingApps, n as extractConfig, o as formatMissingApps, r as extractConfigName, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-BU2B0tYL.js";
4
+ import { a as buildMonoTsconfig, i as adoptHostedApps, n as MONO_DIR, o as monoTsconfigPaths, r as MONO_TSCONFIG_REF, s as runMonoPrepare, t as MONO_APPS_DIR } from "./mono-tsconfig-CYOKwy6E.js";
5
+ import { A as BASE_ARGS, B as refPatterns, C as commitAndPush, D as repoDir, E as readRepoFile, F as parseHeadSha, G as SKILLS_DEFAULTS, H as tokenRemote, I as parseLsRemote, J as loadSkillsEnv, K as isGenericAppName, L as parseSymref, M as firstFatal, N as gitEnv, O as resolveRemote, P as isNonFastForward, R as redactUrl, S as SkillsAccessError, T as listRepoFiles, U as ALLOWED_FLAGS, V as runGit, W as GENERIC_APP_NAMES, Y as resolveSkillTarget, _ as stagingRoot, a as applyPlan, b as resolveAppId, c as chunkConversation, d as REQUIRED_FILES, f as cacheDir, g as removeSession, h as moveToFailed, i as runSearch, j as classifyGitFailure, k as skillsRoot, l as redact, m as loadStagedSession, n as runCheck, o as buildSavePlan, p as listSessions, q as loadSkillConfig, r as runRead, s as runSave, t as runSessionShow, u as redactBuffer, v as validateStagedSession, w as ensureRepo, x as detectActor, y as normalizeAppId, z as refDirCandidates } from "./session-CbSl2BMJ.js";
6
6
 
7
- export { ALLOWED_FLAGS, BASE_ARGS, GENERIC_APP_NAMES, MONO_APPS_DIR, MONO_DIR, MONO_TSCONFIG_REF, REQUIRED_FILES, SKILLS_DEFAULTS, SkillsAccessError, appRootDirs, applyPlan, assertAppSources, buildMonoTsconfig, buildSavePlan, cacheDir, chunkConversation, classifyGitFailure, commitAndPush, detectActor, ensureRepo, extractConfig, extractConfigName, extractSkill, extractTemplate, firstFatal, formatMissingApps, getMonoConfig, gitEnv, hasUrl, isGenericAppName, isMissingPathError, isNonFastForward, linkedAppRoots, listRepoFiles, listSessions, loadMonoConfig, loadSkillConfig, loadSkillsEnv, loadStagedSession, missingPathMessage, monoAlias, monoConfigFileFor, monoMissingApps, monoStubAliases, monoTsconfigPaths, moveToFailed, normalizeAppId, parseHeadSha, parseLsRemote, parseSymref, pathAppRoots, readRepoFile, redact, redactBuffer, redactUrl, refDirCandidates, refPatterns, removeSession, repoDir, resetAppPathWarnings, resolveAppId, resolveAppRoots, resolveFederatedRoots, resolveRemote, resolveSkillTarget, runCheck, runGit, runMonoPrepare, runRead, runSave, runSearch, runSessionShow, skillsRoot, stagingRoot, stripCommentsSafe, tokenRemote, validateStagedSession };
7
+ export { ALLOWED_FLAGS, BASE_ARGS, GENERIC_APP_NAMES, MONO_APPS_DIR, MONO_DIR, MONO_TSCONFIG_REF, REQUIRED_FILES, SKILLS_DEFAULTS, SkillsAccessError, adoptHostedApps, appRootDirs, applyPlan, assertAppSources, buildMonoTsconfig, buildSavePlan, cacheDir, chunkConversation, classifyGitFailure, commitAndPush, detectActor, ensureRepo, extractConfig, extractConfigName, extractSkill, extractTemplate, firstFatal, formatMissingApps, getMonoConfig, gitEnv, hasUrl, hostedAppRoots, isGenericAppName, isHostedApp, isMissingPathError, isNonFastForward, linkedAppRoots, listRepoFiles, listSessions, loadMonoConfig, loadSkillConfig, loadSkillsEnv, loadStagedSession, missingPathMessage, monoAlias, monoConfigFileFor, monoMissingApps, monoStubAliases, monoTsconfigPaths, moveToFailed, normalizeAppId, parseHeadSha, parseLsRemote, parseSymref, pathAppRoots, readRepoFile, redact, redactBuffer, redactUrl, refDirCandidates, refPatterns, removeSession, repoDir, resetAppPathWarnings, resolveAppId, resolveAppRoots, resolveFederatedRoots, resolveRemote, resolveSkillTarget, runCheck, runGit, runMonoPrepare, runRead, runSave, runSearch, runSessionShow, skillsRoot, stagingRoot, stripCommentsSafe, tokenRemote, validateStagedSession };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as mergeEcosystem, r as monoEcosystem } from "./merge-file-CtyKTu5L.js";
1
+ import { n as mergeEcosystem, r as monoEcosystem } from "./merge-file-DahuGcvr.js";
2
2
  import fs from "node:fs";
3
3
  import path, { resolve } from "node:path";
4
4
  import fs$1 from "node:fs/promises";
@@ -1,4 +1,4 @@
1
- import { c as resolveAppRoots } from "./app-roots-CvJnmXcs.js";
1
+ import { u as resolveAppRoots } from "./app-roots-LpDrHF_J.js";
2
2
  import { l as srcDirForType } from "./create-config-DdL3Fh6T.js";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
@@ -1,4 +1,4 @@
1
- import { c as resolveAppRoots } from "./app-roots-CvJnmXcs.js";
1
+ import { u as resolveAppRoots } from "./app-roots-LpDrHF_J.js";
2
2
  import { l as srcDirForType } from "./create-config-DdL3Fh6T.js";
3
3
  import fs from "node:fs";
4
4
  import path from "node:path";
package/dist/mono-db.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { c as resolveMonoConfig } from "./create-config-DdL3Fh6T.js";
2
2
  import { t as getMonoConfig } from "./config-node-UzJrXg0Z.js";
3
- import { s as monoAlias } from "./mono-alias-DNDm-jB_.js";
3
+ import { s as monoAlias } from "./mono-alias-BU2B0tYL.js";
4
4
  import { n as generateSeed, s as parseMockSchema } from "./generate-CJ7MtcDd.js";
5
5
  import { writeFileSync } from "node:fs";
6
6
  import path from "node:path";
package/dist/mono-env.mjs CHANGED
@@ -87,8 +87,9 @@ const childEnv = {
87
87
  ...process.env,
88
88
  }
89
89
 
90
- function loadEnvByPath(fullPath, displayPath, label) {
90
+ function loadEnvByPath(fullPath, displayPath, label, quietIfMissing = false) {
91
91
  if (!existsSync(fullPath)) {
92
+ if (quietIfMissing) return
92
93
  console.warn(`[mono-env] Warning: ${label} env file not found: ${displayPath}`)
93
94
  return
94
95
  }
@@ -161,12 +162,16 @@ function loadAppEnv(app) {
161
162
  return
162
163
  }
163
164
 
165
+ // A hosted (mini) app — no package.json — ships no env of its own: the host
166
+ // owns env, so a missing file there is the normal case, not worth a warning.
167
+ const hosted = !existsSync(resolve(app.dir, 'package.json'))
168
+
164
169
  for (const file of envFiles) {
165
170
  const envFileName = basename(file)
166
171
  const appEnvPath = resolve(app.dir, envFileName)
167
172
  const displayPath = `${displayDir(app.dir)}/${envFileName}`
168
173
 
169
- loadEnvByPath(appEnvPath, displayPath, `app:${app.name}`)
174
+ loadEnvByPath(appEnvPath, displayPath, `app:${app.name}`, hosted)
170
175
  }
171
176
  }
172
177
 
@@ -1,4 +1,8 @@
1
+ import { c as pathAppRoots } from "./app-roots-LpDrHF_J.js";
2
+ import { l as srcDirForType } from "./create-config-DdL3Fh6T.js";
3
+ import { c as monoConfigFileFor, d as resolveFederatedRoots, n as extractConfig } from "./mono-alias-BU2B0tYL.js";
1
4
  import fs from "node:fs";
5
+ import { join } from "node:path";
2
6
 
3
7
  //#region src/vite/remote-matcher.ts
4
8
  /** `C:\a\B` -> `c:/a/b` — ids arrive slashed either way, and Windows is case-insensitive. */
@@ -68,6 +72,103 @@ function parsePageMetaFromFile(file) {
68
72
  }
69
73
  }
70
74
 
75
+ //#endregion
76
+ //#region src/vite/mono-lith.ts
77
+ const MONO_APPS_VIRTUAL_ID = "virtual:mono-apps";
78
+ const RESOLVED_VIRTUAL_ID = "\0virtual:mono-apps";
79
+ /** `C:\a\B` -> `c:/a/b` — chokidar and Vite slash paths differently, and Windows is case-insensitive. */
80
+ function normalizeFsPath(value) {
81
+ const slashed = value.replace(/\\/g, "/");
82
+ return process.platform === "win32" ? slashed.toLowerCase() : slashed;
83
+ }
84
+ /** Forward-slashed absolute path, safe inside a JS string literal. */
85
+ function importSpecifier(file) {
86
+ return JSON.stringify(file.replace(/\\/g, "/"));
87
+ }
88
+ function createMonoLithHooks(options = {}) {
89
+ const rootDir = options.dirname ?? process.cwd();
90
+ const appRoots = options.appRoots ?? resolveFederatedRoots({
91
+ dirname: rootDir,
92
+ ...options.appsDir ? { appsDir: options.appsDir } : {}
93
+ });
94
+ const siblings = pathAppRoots(appRoots);
95
+ const active = options.activeNames ? appRoots.filter((r) => options.activeNames.includes(r.name)) : appRoots;
96
+ const configFiles = [];
97
+ const ownName = extractConfig(rootDir).name ?? "<root>";
98
+ const ownConfig = monoConfigFileFor(rootDir);
99
+ if (ownConfig) configFiles.push({
100
+ name: ownName,
101
+ file: ownConfig
102
+ });
103
+ for (const root of active) {
104
+ const file = monoConfigFileFor(root.root);
105
+ if (file) configFiles.push({
106
+ name: root.name,
107
+ file
108
+ });
109
+ }
110
+ const configByPath = new Map(configFiles.map((c) => [normalizeFsPath(c.file), c.name]));
111
+ const load = (id) => {
112
+ if (id !== RESOLVED_VIRTUAL_ID) return void 0;
113
+ return [
114
+ "// Generated by @mono-lit/utility (virtual:mono-apps): one lazy import per",
115
+ "// federated app’s mono.config, whether it is a sibling or a clone.",
116
+ "export default {",
117
+ ...active.flatMap((r) => {
118
+ const file = monoConfigFileFor(r.root);
119
+ return file ? [` ${JSON.stringify(r.name)}: () => import(${importSpecifier(file)}),`] : [];
120
+ }),
121
+ "}",
122
+ ""
123
+ ].join("\n");
124
+ };
125
+ const configureServer = (server) => {
126
+ if (options.watchSiblings !== false) for (const sibling of siblings) server.watcher.add(join(sibling.root, srcDirForType(sibling.type ?? "vue")));
127
+ if (options.restartOnConfigChange === false) return;
128
+ for (const { file } of configFiles) server.watcher.add(file);
129
+ let restarting = false;
130
+ const onConfigEvent = (file) => {
131
+ const name = configByPath.get(normalizeFsPath(file));
132
+ if (!name || restarting) return;
133
+ restarting = true;
134
+ server.config.logger.info(`[mono] mono.config changed (${name}) — restarting`, { timestamp: true });
135
+ server.restart();
136
+ };
137
+ server.watcher.on("change", onConfigEvent);
138
+ server.watcher.on("add", onConfigEvent);
139
+ server.watcher.on("unlink", onConfigEvent);
140
+ };
141
+ return {
142
+ fsAllow: siblings.map((r) => r.root),
143
+ appRoots,
144
+ configureServer,
145
+ resolveId: (id) => id === "virtual:mono-apps" ? RESOLVED_VIRTUAL_ID : void 0,
146
+ load
147
+ };
148
+ }
149
+ /**
150
+ * Standalone plugin for a long-hand `vite.config.ts`. `monoRepo().vite()` /
151
+ * `mono.plugin` already include these hooks — do not register both.
152
+ *
153
+ * ```ts
154
+ * import { monoLith } from '@mono-lit/utility/vite'
155
+ * plugins: [VueRouter({ … }), vue(), monoLith({ dirname: __dirname })]
156
+ * ```
157
+ */
158
+ function monoLith(options = {}) {
159
+ const hooks = createMonoLithHooks(options);
160
+ return {
161
+ name: "mono-lith",
162
+ config() {
163
+ if (!hooks.fsAllow.length) return;
164
+ return { server: { fs: { allow: [options.dirname ?? process.cwd(), ...hooks.fsAllow] } } };
165
+ },
166
+ configureServer: hooks.configureServer,
167
+ resolveId: hooks.resolveId,
168
+ load: hooks.load
169
+ };
170
+ }
171
+
71
172
  //#endregion
72
173
  //#region src/composables/expose.ts
73
174
  /**
@@ -485,4 +586,4 @@ function unquote(valuePart) {
485
586
  }
486
587
 
487
588
  //#endregion
488
- export { defaultMonoExpose as a, parsePageMetaFromFile as c, monoRouterLinkToNuxtLink as i, remoteGate as l, monoNuxtLinkToRouterLink as n, sanitizeForExpose as o, monoRouterLink as r, parsePageMeta as s, monoNuxtLink as t };
589
+ export { defaultMonoExpose as a, createMonoLithHooks as c, parsePageMetaFromFile as d, remoteGate as f, monoRouterLinkToNuxtLink as i, monoLith as l, monoNuxtLinkToRouterLink as n, sanitizeForExpose as o, monoRouterLink as r, MONO_APPS_VIRTUAL_ID as s, monoNuxtLink as t, parsePageMeta as u };
@@ -1,4 +1,4 @@
1
- import { o as runMonoPrepare } from "./mono-tsconfig-D2qRL9_R.js";
1
+ import { s as runMonoPrepare } from "./mono-tsconfig-CYOKwy6E.js";
2
2
  import path from "node:path";
3
3
  import { defineCommand, runMain } from "citty";
4
4
 
@@ -21,6 +21,10 @@ const main = defineCommand({
21
21
  else console.log("[mono] tsconfig.json already extends ./.mono/tsconfig.json");
22
22
  if (result.removedKeys.length) console.log(`[mono] removed ${result.removedKeys.length} inline alias path(s) from tsconfig.json`);
23
23
  if (result.wiredApps.length) console.log(`[mono] wired ${result.wiredApps.length} cloned app tsconfig(s) -> ${monoRel}: ${result.wiredApps.join(", ")}`);
24
+ for (const app of result.hostedApps) {
25
+ const link = app.link === "skipped" ? "node_modules NOT linked" : `node_modules ${app.link}`;
26
+ console.log(`[mono] hosted app ${app.name}: ${link}, wrote ${path.relative(dirname, app.tsconfig)}`);
27
+ }
24
28
  }
25
29
  });
26
30
  runMain(main);
@@ -1,4 +1,4 @@
1
- import { J as loadSkillsEnv, K as isGenericAppName, O as resolveRemote, R as redactUrl, S as SkillsAccessError, U as ALLOWED_FLAGS, Y as resolveSkillTarget, _ as stagingRoot, b as resolveAppId, i as runSearch, n as runCheck, o as buildSavePlan, p as listSessions, q as loadSkillConfig, r as runRead, s as runSave, t as runSessionShow, w as ensureRepo, x as detectActor } from "./session-Bcig-rPi.js";
1
+ import { J as loadSkillsEnv, K as isGenericAppName, O as resolveRemote, R as redactUrl, S as SkillsAccessError, U as ALLOWED_FLAGS, Y as resolveSkillTarget, _ as stagingRoot, b as resolveAppId, i as runSearch, n as runCheck, o as buildSavePlan, p as listSessions, q as loadSkillConfig, r as runRead, s as runSave, t as runSessionShow, w as ensureRepo, x as detectActor } from "./session-CbSl2BMJ.js";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { defineCommand, runMain } from "citty";
@@ -1,5 +1,6 @@
1
- import { c as resolveAppRoots } from "./app-roots-CvJnmXcs.js";
2
- import { f as stripCommentsSafe, n as extractConfig, s as monoAlias } from "./mono-alias-DNDm-jB_.js";
1
+ import { r as hostedAppRoots, u as resolveAppRoots } from "./app-roots-LpDrHF_J.js";
2
+ import { l as srcDirForType } from "./create-config-DdL3Fh6T.js";
3
+ import { f as stripCommentsSafe, n as extractConfig, s as monoAlias } from "./mono-alias-BU2B0tYL.js";
3
4
  import fs from "node:fs";
4
5
  import path from "node:path";
5
6
  import { readTSConfig, writeTSConfig } from "pkg-types";
@@ -148,6 +149,7 @@ async function runMonoPrepare(opts) {
148
149
  }
149
150
  await writeTSConfig(rootTsconfigPath, root);
150
151
  const wiredApps = await wireClonedApps(dirname, monoTsconfigPath, writtenKeys);
152
+ const hostedApps = adoptHostedApps(dirname);
151
153
  const unpreparedApps = unpreparedPathApps(dirname);
152
154
  if (unpreparedApps.length) console.warn(`[mono] ${unpreparedApps.join(", ")}: tsconfig.json extends ./.mono/tsconfig.json but the file is missing — run \`mono prepare\` in that app.`);
153
155
  return {
@@ -158,9 +160,138 @@ async function runMonoPrepare(opts) {
158
160
  addedExtends,
159
161
  wiredApps,
160
162
  outsideProject,
161
- unpreparedApps
163
+ unpreparedApps,
164
+ hostedApps
162
165
  };
163
166
  }
167
+ /**
168
+ * Prepare every HOSTED (mini) app read in place through `apps[].path`, from the
169
+ * host's side — the mini has no `package.json`, so it can never run a
170
+ * `mono prepare` (or an install) of its own.
171
+ *
172
+ * Only a mini that names THIS host in its own `apps[]` (by name — typically a
173
+ * `url` entry — or by a `path` landing here) is prepared: the wiring is declared
174
+ * on both sides, never inferred. Any other hosted app is skipped with a warning
175
+ * that spells out the entry to add.
176
+ *
177
+ * 1. `<mini>/node_modules` becomes a link (a junction on Windows — no admin
178
+ * rights needed) to the host's `node_modules`. A sibling outside the host
179
+ * has no `node_modules` above it, so every bare import in its files —
180
+ * `vue`, `@mono-lit/utility/*` — fails in Vite AND in jiti (the host's c12
181
+ * loads the mini's `mono.config.ts`). One link fixes Vite, jiti, vue-tsc and
182
+ * the editor together, and because the realpaths ARE the host's, there is
183
+ * still exactly one copy of Vue. A real directory there is never touched.
184
+ * 2. `<mini>/.mono/tsconfig.json` extends the host's config (Nuxt host:
185
+ * `.nuxt/tsconfig.app.json`, Vite host: `tsconfig.json`), and — when the
186
+ * mini has none — `<mini>/tsconfig.json` extends that, so the editor
187
+ * type-checks the mini against the host's aliases and generated
188
+ * auto-import/route types.
189
+ *
190
+ * Unlike `wireClonedApps`' rule for full `path` apps, this DOES write into the
191
+ * sibling — but only files a mini gitignores (`node_modules`, `.mono/`, the
192
+ * generated `tsconfig.json`). Nothing it commits is ever edited. A clone under `.mono/apps` needs none
193
+ * of this: Node already walks up to the host's `node_modules`.
194
+ */
195
+ function adoptHostedApps(dirname) {
196
+ const host = extractConfig(dirname);
197
+ const roots = resolveAppRoots({
198
+ dirname,
199
+ appsDir: MONO_APPS_DIR,
200
+ apps: host.apps,
201
+ onMissingPath: "ignore",
202
+ listClones: false
203
+ });
204
+ const hostModules = path.join(dirname, "node_modules");
205
+ const base = host.type === "nuxt" ? path.join(dirname, ".nuxt", "tsconfig.app.json") : path.join(dirname, "tsconfig.json");
206
+ const prepared = [];
207
+ for (const { name, type, root } of hostedAppRoots(roots)) {
208
+ if (!namesHost(root, dirname, host.name)) {
209
+ const hint = `{ name: '${host.name ?? path.basename(dirname)}', url: '<the host repo>', type: '${host.type}' }`;
210
+ console.warn(`[mono] ${name}: not prepared — its mono.config.ts does not name this host. Add ${hint} to its apps[].`);
211
+ continue;
212
+ }
213
+ const link = linkHostModules(name, root, hostModules);
214
+ const miniMono = path.join(root, MONO_DIR);
215
+ if (!fs.existsSync(miniMono)) fs.mkdirSync(miniMono, { recursive: true });
216
+ const tsconfigPath = path.join(miniMono, "tsconfig.json");
217
+ const rel = (abs) => toRelativePosix(miniMono, abs);
218
+ const miniSrc = srcDirForType(type ?? host.type);
219
+ const include = host.type === "nuxt" ? [rel(path.join(dirname, ".nuxt", "nuxt.d.ts"))] : [`${rel(dirname)}/*.d.ts`, `${rel(path.join(dirname, srcDirForType(host.type)))}/**/*.d.ts`];
220
+ const json = {
221
+ extends: rel(base),
222
+ compilerOptions: { rootDir: rel(commonDir(dirname, root)) },
223
+ include: [
224
+ `../${miniSrc}/**/*`,
225
+ "../mono.config.ts",
226
+ "../*.d.ts",
227
+ ...include
228
+ ],
229
+ exclude: ["../node_modules", `${rel(hostModules)}`]
230
+ };
231
+ const text = `${JSON.stringify(json, null, 2)}\n`;
232
+ if (!fs.existsSync(tsconfigPath) || fs.readFileSync(tsconfigPath, "utf8") !== text) fs.writeFileSync(tsconfigPath, text);
233
+ const entryPath = path.join(root, "tsconfig.json");
234
+ if (!fs.existsSync(entryPath)) fs.writeFileSync(entryPath, `${JSON.stringify({ extends: MONO_TSCONFIG_REF }, null, 2)}\n`);
235
+ prepared.push({
236
+ name,
237
+ link,
238
+ tsconfig: tsconfigPath
239
+ });
240
+ }
241
+ return prepared;
242
+ }
243
+ /** Point `<root>/node_modules` at the host's. Never replaces a real directory. */
244
+ function linkHostModules(name, root, hostModules) {
245
+ if (!fs.existsSync(hostModules)) {
246
+ console.warn(`[mono] ${name}: the host has no node_modules yet — install the host first.`);
247
+ return "skipped";
248
+ }
249
+ const linkPath = path.join(root, "node_modules");
250
+ let stat;
251
+ try {
252
+ stat = fs.lstatSync(linkPath);
253
+ } catch {
254
+ stat = void 0;
255
+ }
256
+ if (stat) {
257
+ if (!stat.isSymbolicLink()) {
258
+ console.warn(`[mono] ${name}: ${linkPath} is a real directory — a hosted app uses the host's node_modules; delete it to let mono link them.`);
259
+ return "skipped";
260
+ }
261
+ let current = "";
262
+ try {
263
+ current = fs.realpathSync(linkPath);
264
+ } catch {}
265
+ if (current && samePath(current, fs.realpathSync(hostModules))) return "kept";
266
+ fs.unlinkSync(linkPath);
267
+ }
268
+ fs.symlinkSync(hostModules, linkPath, process.platform === "win32" ? "junction" : "dir");
269
+ return "created";
270
+ }
271
+ /**
272
+ * Does the app at `root` name this host in its `apps[]`? By the host's `name` (a
273
+ * `url` entry, the usual way), or by a `path` that lands on `hostDir`. Read
274
+ * statically, like every other `apps[]` read before the config can execute.
275
+ */
276
+ function namesHost(root, hostDir, hostName) {
277
+ return extractConfig(root).apps.some((app) => hostName !== null && app.name === hostName || typeof app.path === "string" && samePath(path.resolve(root, app.path), hostDir));
278
+ }
279
+ function samePath(a, b) {
280
+ const norm = (p) => {
281
+ const r = path.resolve(p);
282
+ return process.platform === "win32" ? r.toLowerCase() : r;
283
+ };
284
+ return norm(a) === norm(b);
285
+ }
286
+ /** Deepest directory containing both `a` and `b`. */
287
+ function commonDir(a, b) {
288
+ const pa = path.resolve(a).split(path.sep);
289
+ const pb = path.resolve(b).split(path.sep);
290
+ const eq = (x, y) => process.platform === "win32" ? x.toLowerCase() === y.toLowerCase() : x === y;
291
+ let i = 0;
292
+ while (i < pa.length && i < pb.length && eq(pa[i], pb[i])) i++;
293
+ return pa.slice(0, i).join(path.sep) || path.sep;
294
+ }
164
295
  /** Written alias keys whose target directory is not under `dirname`. */
165
296
  function pathsOutsideProject(dirname, paths) {
166
297
  const monoDir = path.resolve(dirname, MONO_DIR);
@@ -201,4 +332,4 @@ function unpreparedPathApps(dirname) {
201
332
  }
202
333
 
203
334
  //#endregion
204
- export { monoTsconfigPaths as a, buildMonoTsconfig as i, MONO_DIR as n, runMonoPrepare as o, MONO_TSCONFIG_REF as r, MONO_APPS_DIR as t };
335
+ export { buildMonoTsconfig as a, adoptHostedApps as i, MONO_DIR as n, monoTsconfigPaths as o, MONO_TSCONFIG_REF as r, runMonoPrepare as s, MONO_APPS_DIR as t };
@@ -1,5 +1,5 @@
1
- import { c as resolveAppRoots } from "./app-roots-CvJnmXcs.js";
2
- import { a as extractTemplate, n as extractConfig } from "./mono-alias-DNDm-jB_.js";
1
+ import { u as resolveAppRoots } from "./app-roots-LpDrHF_J.js";
2
+ import { a as extractTemplate, n as extractConfig } from "./mono-alias-BU2B0tYL.js";
3
3
  import { existsSync } from "node:fs";
4
4
  import { join, normalize, resolve } from "node:path";
5
5
 
@@ -1,5 +1,5 @@
1
1
  import "./create-config-B8IhX4ht.js";
2
- import "./app-roots-DK41xMWj.js";
2
+ import "./app-roots-BlcIuAan.js";
3
3
  //#region src/nuxt/nuxt-layers.d.ts
4
4
  interface MonoNuxtLayersOptions {
5
5
  /** Project root. `apps[].path` resolves against it. @default process.cwd() */
@@ -1,3 +1,3 @@
1
- import { n as monoNuxtLayers } from "./nuxt-layers-DP1m7f1-.js";
1
+ import { n as monoNuxtLayers } from "./nuxt-layers-BO0AGwA5.js";
2
2
 
3
3
  export { monoNuxtLayers };
package/dist/nuxt.js CHANGED
@@ -1,10 +1,10 @@
1
- import { o as pathAppRoots, t as appRootDirs } from "./app-roots-CvJnmXcs.js";
1
+ import { c as pathAppRoots, t as appRootDirs } from "./app-roots-LpDrHF_J.js";
2
2
  import { c as resolveMonoConfig, l as srcDirForType, o as resolveExtendsAppNames, s as resolveExtendsEcosystems } from "./create-config-DdL3Fh6T.js";
3
- import { n as mergeEcosystem, r as monoEcosystem, t as ecosystemSubAllowed } from "./merge-file-CtyKTu5L.js";
3
+ import { n as mergeEcosystem, r as monoEcosystem, t as ecosystemSubAllowed } from "./merge-file-DahuGcvr.js";
4
4
  import { t as getMonoConfig } from "./config-node-UzJrXg0Z.js";
5
- import { d as resolveFederatedRoots, n as extractConfig, o as formatMissingApps, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-DNDm-jB_.js";
6
- import { a as defaultMonoExpose, i as monoRouterLinkToNuxtLink, l as remoteGate, o as sanitizeForExpose, s as parsePageMeta } from "./mono-link-YlOQ2PVS.js";
7
- import { r as registerMonoNuxtLayers, t as monoLayerCandidates } from "./nuxt-layers-DP1m7f1-.js";
5
+ import { d as resolveFederatedRoots, n as extractConfig, o as formatMissingApps, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-BU2B0tYL.js";
6
+ import { a as defaultMonoExpose, c as createMonoLithHooks, f as remoteGate, i as monoRouterLinkToNuxtLink, o as sanitizeForExpose, u as parsePageMeta } from "./mono-link-URGX8xsT.js";
7
+ import { r as registerMonoNuxtLayers, t as monoLayerCandidates } from "./nuxt-layers-BO0AGwA5.js";
8
8
  import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
9
9
  import { isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
10
10
  import { addComponentsDir, addImportsDir, addPlugin, addPluginTemplate, addRouteMiddleware, addTemplate, addVitePlugin, defineNuxtModule, extendPages, extendViteConfig } from "@nuxt/kit";
@@ -246,6 +246,18 @@ const monoNuxtModule = defineNuxtModule({
246
246
  const activeNames = resolveExtendsAppNames(rawConfig);
247
247
  const activeApps = hasExtends ? (rawConfig.apps ?? []).filter((a) => activeNames.includes(a.name)) : rawConfig.apps ?? [];
248
248
  const activeRoots = appRoots.filter((r) => activeApps.some((a) => a.name === r.name));
249
+ const lith = createMonoLithHooks({
250
+ dirname: rootDir,
251
+ appRoots,
252
+ ...hasExtends ? { activeNames } : {},
253
+ restartOnConfigChange: false
254
+ });
255
+ addVitePlugin({
256
+ name: "mono-nuxt-apps",
257
+ configureServer: lith.configureServer,
258
+ resolveId: lith.resolveId,
259
+ load: lith.load
260
+ });
249
261
  const extendsEcosystems = resolveExtendsEcosystems(rawConfig);
250
262
  const monoConfig = {
251
263
  ...resolveMonoConfig(rawConfig),
@@ -1,4 +1,4 @@
1
- import { i as extractSkill, n as extractConfig } from "./mono-alias-DNDm-jB_.js";
1
+ import { i as extractSkill, n as extractConfig } from "./mono-alias-BU2B0tYL.js";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { config } from "dotenv";
package/dist/vite.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { c as MonoConfig, o as MonoAppType, w as MonoTemplate } from "./create-config-B8IhX4ht.js";
2
- import { r as MonoAppRootSource, t as MonoAppRoot } from "./app-roots-DK41xMWj.js";
2
+ import { r as MonoAppRootSource, t as MonoAppRoot } from "./app-roots-BlcIuAan.js";
3
3
  import { Plugin, PluginOption, ViteDevServer } from "vite";
4
4
  //#region src/vite/remote-matcher.d.ts
5
5
  /** The options every compat transform accepts, so they stay interchangeable. */
package/dist/vite.js CHANGED
@@ -1,9 +1,9 @@
1
- import { o as pathAppRoots, t as appRootDirs } from "./app-roots-CvJnmXcs.js";
1
+ import { c as pathAppRoots, t as appRootDirs } from "./app-roots-LpDrHF_J.js";
2
2
  import { c as resolveMonoConfig, l as srcDirForType, o as resolveExtendsAppNames, s as resolveExtendsEcosystems } from "./create-config-DdL3Fh6T.js";
3
- import { r as monoEcosystem } from "./merge-file-CtyKTu5L.js";
3
+ import { r as monoEcosystem } from "./merge-file-DahuGcvr.js";
4
4
  import { t as getMonoConfig } from "./config-node-UzJrXg0Z.js";
5
- import { c as monoConfigFileFor, d as resolveFederatedRoots, n as extractConfig, o as formatMissingApps, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-DNDm-jB_.js";
6
- import { a as defaultMonoExpose, c as parsePageMetaFromFile, i as monoRouterLinkToNuxtLink, l as remoteGate, n as monoNuxtLinkToRouterLink, o as sanitizeForExpose, r as monoRouterLink, s as parsePageMeta, t as monoNuxtLink } from "./mono-link-YlOQ2PVS.js";
5
+ import { d as resolveFederatedRoots, n as extractConfig, o as formatMissingApps, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-BU2B0tYL.js";
6
+ import { a as defaultMonoExpose, c as createMonoLithHooks, d as parsePageMetaFromFile, f as remoteGate, i as monoRouterLinkToNuxtLink, l as monoLith, n as monoNuxtLinkToRouterLink, o as sanitizeForExpose, r as monoRouterLink, s as MONO_APPS_VIRTUAL_ID, t as monoNuxtLink, u as parsePageMeta } from "./mono-link-URGX8xsT.js";
7
7
  import { existsSync } from "node:fs";
8
8
  import { isAbsolute, join, resolve } from "node:path";
9
9
  import { createRequire } from "node:module";
@@ -349,103 +349,6 @@ function monoExtendRoute(options = {}) {
349
349
  };
350
350
  }
351
351
 
352
- //#endregion
353
- //#region src/vite/mono-lith.ts
354
- const MONO_APPS_VIRTUAL_ID = "virtual:mono-apps";
355
- const RESOLVED_VIRTUAL_ID = "\0virtual:mono-apps";
356
- /** `C:\a\B` -> `c:/a/b` — chokidar and Vite slash paths differently, and Windows is case-insensitive. */
357
- function normalizeFsPath(value) {
358
- const slashed = value.replace(/\\/g, "/");
359
- return process.platform === "win32" ? slashed.toLowerCase() : slashed;
360
- }
361
- /** Forward-slashed absolute path, safe inside a JS string literal. */
362
- function importSpecifier(file) {
363
- return JSON.stringify(file.replace(/\\/g, "/"));
364
- }
365
- function createMonoLithHooks(options = {}) {
366
- const rootDir = options.dirname ?? process.cwd();
367
- const appRoots = options.appRoots ?? resolveFederatedRoots({
368
- dirname: rootDir,
369
- ...options.appsDir ? { appsDir: options.appsDir } : {}
370
- });
371
- const siblings = pathAppRoots(appRoots);
372
- const active = options.activeNames ? appRoots.filter((r) => options.activeNames.includes(r.name)) : appRoots;
373
- const configFiles = [];
374
- const ownName = extractConfig(rootDir).name ?? "<root>";
375
- const ownConfig = monoConfigFileFor(rootDir);
376
- if (ownConfig) configFiles.push({
377
- name: ownName,
378
- file: ownConfig
379
- });
380
- for (const root of active) {
381
- const file = monoConfigFileFor(root.root);
382
- if (file) configFiles.push({
383
- name: root.name,
384
- file
385
- });
386
- }
387
- const configByPath = new Map(configFiles.map((c) => [normalizeFsPath(c.file), c.name]));
388
- const load = (id) => {
389
- if (id !== RESOLVED_VIRTUAL_ID) return void 0;
390
- return [
391
- "// Generated by @mono-lit/utility (virtual:mono-apps): one lazy import per",
392
- "// federated app’s mono.config, whether it is a sibling or a clone.",
393
- "export default {",
394
- ...active.flatMap((r) => {
395
- const file = monoConfigFileFor(r.root);
396
- return file ? [` ${JSON.stringify(r.name)}: () => import(${importSpecifier(file)}),`] : [];
397
- }),
398
- "}",
399
- ""
400
- ].join("\n");
401
- };
402
- const configureServer = (server) => {
403
- if (options.watchSiblings !== false) for (const sibling of siblings) server.watcher.add(join(sibling.root, srcDirForType(sibling.type ?? "vue")));
404
- if (options.restartOnConfigChange === false) return;
405
- for (const { file } of configFiles) server.watcher.add(file);
406
- let restarting = false;
407
- const onConfigEvent = (file) => {
408
- const name = configByPath.get(normalizeFsPath(file));
409
- if (!name || restarting) return;
410
- restarting = true;
411
- server.config.logger.info(`[mono] mono.config changed (${name}) — restarting`, { timestamp: true });
412
- server.restart();
413
- };
414
- server.watcher.on("change", onConfigEvent);
415
- server.watcher.on("add", onConfigEvent);
416
- server.watcher.on("unlink", onConfigEvent);
417
- };
418
- return {
419
- fsAllow: siblings.map((r) => r.root),
420
- appRoots,
421
- configureServer,
422
- resolveId: (id) => id === "virtual:mono-apps" ? RESOLVED_VIRTUAL_ID : void 0,
423
- load
424
- };
425
- }
426
- /**
427
- * Standalone plugin for a long-hand `vite.config.ts`. `monoRepo().vite()` /
428
- * `mono.plugin` already include these hooks — do not register both.
429
- *
430
- * ```ts
431
- * import { monoLith } from '@mono-lit/utility/vite'
432
- * plugins: [VueRouter({ … }), vue(), monoLith({ dirname: __dirname })]
433
- * ```
434
- */
435
- function monoLith(options = {}) {
436
- const hooks = createMonoLithHooks(options);
437
- return {
438
- name: "mono-lith",
439
- config() {
440
- if (!hooks.fsAllow.length) return;
441
- return { server: { fs: { allow: [options.dirname ?? process.cwd(), ...hooks.fsAllow] } } };
442
- },
443
- configureServer: hooks.configureServer,
444
- resolveId: hooks.resolveId,
445
- load: hooks.load
446
- };
447
- }
448
-
449
352
  //#endregion
450
353
  //#region src/vite/resolve-from-root.ts
451
354
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-lit/utility",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Mono config, fetching, auth/token, Nuxt/Vite integration and shared helpers for the @mono-lit ecosystem.",
5
5
  "keywords": [
6
6
  "vue",
@@ -110,7 +110,7 @@
110
110
  "vite": "8.3.4",
111
111
  "vue-tsc": "~3.2.0",
112
112
  "yup": "1.7.1",
113
- "@mono-lit/helper": "0.0.5"
113
+ "@mono-lit/helper": "0.0.6"
114
114
  },
115
115
  "dependencies": {
116
116
  "@nuxt/kit": "^4.6.2",