@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
@@ -0,0 +1,488 @@
1
+ import fs from "node:fs";
2
+
3
+ //#region src/vite/remote-matcher.ts
4
+ /** `C:\a\B` -> `c:/a/b` — ids arrive slashed either way, and Windows is case-insensitive. */
5
+ function normalizeId(value) {
6
+ const slashed = value.replace(/\\/g, "/");
7
+ return process.platform === "win32" ? slashed.toLowerCase() : slashed;
8
+ }
9
+ /** Strip the query so `foo.vue?vue&type=script` matches `foo.vue`. */
10
+ function idPath(id) {
11
+ return id?.split("?")[0] ?? "";
12
+ }
13
+ /**
14
+ * Build the "is this a remote's file?" predicate.
15
+ *
16
+ * Matches the marker substring OR containment in any root. Roots are compared
17
+ * as directory prefixes, so a root of `…/host` never swallows `…/host-extra`.
18
+ */
19
+ function createRemoteMatcher(options = {}) {
20
+ const marker = options.marker ?? "/.mono/apps/";
21
+ const roots = (options.roots ?? []).filter(Boolean).map((root) => `${normalizeId(root).replace(/\/+$/, "")}/`);
22
+ return (id) => {
23
+ const file = idPath(id);
24
+ if (!file) return false;
25
+ const normalized = normalizeId(file);
26
+ if (marker && normalized.includes(normalizeId(marker))) return true;
27
+ return roots.some((root) => normalized.startsWith(root));
28
+ };
29
+ }
30
+ /** `createRemoteMatcher` from the shared option names. */
31
+ function remoteGate(options = {}) {
32
+ return createRemoteMatcher({
33
+ ...options.appsMarker !== void 0 ? { marker: options.appsMarker } : {},
34
+ ...options.appsRoots ? { roots: options.appsRoots } : {}
35
+ });
36
+ }
37
+
38
+ //#endregion
39
+ //#region src/composables/parse-page-meta.ts
40
+ /**
41
+ * Extract `{ layout, title }` from a page's `<script setup>` source, supporting
42
+ * BOTH macro forms:
43
+ * - Nuxt: `definePageMeta({ layout: 'home', title: 'Home' })`
44
+ * - vue-router (unplugin-vue-router): `definePage({ meta: { layout, title } })`
45
+ *
46
+ * String-literal values only (layout/title are always literals in these apps).
47
+ * Used by the Nuxt host module (to seed remote route meta) and by the Vite
48
+ * host's `extendRoute` (since unplugin-vue-router reads page files from disk and
49
+ * never sees the `definePageMeta -> definePage` Vite transform).
50
+ */
51
+ function parsePageMeta(code) {
52
+ const meta = {};
53
+ const block = code.match(/definePageMeta\s*\(\s*\{([\s\S]*?)\}\s*\)/)?.[1] ?? code.match(/definePage\s*\(\s*\{\s*meta\s*:\s*\{([\s\S]*?)\}\s*,?\s*\}\s*\)/)?.[1];
54
+ if (!block) return meta;
55
+ const layout = block.match(/layout\s*:\s*['"]([^'"]+)['"]/)?.[1];
56
+ const title = block.match(/title\s*:\s*['"]([^'"]+)['"]/)?.[1];
57
+ if (layout) meta.layout = layout;
58
+ else if (/layout\s*:\s*false\b/.test(block)) meta.layout = false;
59
+ if (title) meta.title = title;
60
+ return meta;
61
+ }
62
+ /** {@link parsePageMeta} for a file path (build-time, Node). Returns `{}` on read error. */
63
+ function parsePageMetaFromFile(file) {
64
+ try {
65
+ return parsePageMeta(fs.readFileSync(file, "utf-8"));
66
+ } catch {
67
+ return {};
68
+ }
69
+ }
70
+
71
+ //#endregion
72
+ //#region src/composables/expose.ts
73
+ /**
74
+ * Is `v` a plain object (proto is `Object.prototype` or `null`) — not a class
75
+ * instance, Date, Map, etc. Used by {@link sanitizeForExpose} to decide whether
76
+ * to recurse into an object or drop it.
77
+ */
78
+ function isPlainObject(v) {
79
+ if (v === null || typeof v !== "object") return false;
80
+ const proto = Object.getPrototypeOf(v);
81
+ return proto === Object.prototype || proto === null;
82
+ }
83
+ /**
84
+ * Deep-clone `value` keeping ONLY JSON-safe leaves: strings, numbers, booleans,
85
+ * null, plain objects and arrays. Everything else is thrown away automatically —
86
+ * functions & class constructors (e.g. `oDataService: DefaultService`, DevExtreme
87
+ * `DataSource`/`ODataStore`/`CustomStore`), class instances, symbols, `undefined`,
88
+ * `bigint`, `Date`, `Map`, `Set`. Cycles and runaway depth are guarded, so it
89
+ * never throws and never leaks non-serialisable values into a client bundle.
90
+ *
91
+ * The single source of truth for the `__MONO_CONFIG_EXPOSE__` global shared by
92
+ * the Vite host (`monoRepo`) and the Nuxt host (`@mono-lit/utility/nuxt`).
93
+ *
94
+ * Exported so a custom `expose` can opt into the same sanitisation:
95
+ * expose: (c) => sanitizeForExpose({ ...c, extra: customInstance })
96
+ */
97
+ function sanitizeForExpose(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
98
+ if (depth > 10) return void 0;
99
+ if (value === null) return null;
100
+ const t = typeof value;
101
+ if (t === "string" || t === "number" || t === "boolean") return value;
102
+ if (t === "function" || t === "symbol" || t === "bigint" || t === "undefined") return void 0;
103
+ if (typeof value !== "object") return void 0;
104
+ if (seen.has(value)) return void 0;
105
+ seen.add(value);
106
+ if (Array.isArray(value)) return value.map((v) => sanitizeForExpose(v, depth + 1, seen)).filter((v) => v !== void 0);
107
+ if (isPlainObject(value)) {
108
+ const out = {};
109
+ for (const [k, v] of Object.entries(value)) {
110
+ const s = sanitizeForExpose(v, depth + 1, seen);
111
+ if (s !== void 0) out[k] = s;
112
+ }
113
+ return out;
114
+ }
115
+ }
116
+ /**
117
+ * Default `__MONO_CONFIG_EXPOSE__` builder: expose EVERYTHING that's JSON-safe.
118
+ *
119
+ * Deep-sanitises the full config so values like `fetching.api.myRest.type`/`url`
120
+ * ship to the client, while non-serialisable values are thrown away automatically
121
+ * — e.g. `fetching.api.myOdata.oDataService` (a class), `fetching.source`'s
122
+ * DevExtreme constructors, and the `extends` thunks. `extends`/`renderFn` are
123
+ * config-time-only, so they're stripped before sanitising to avoid recursing
124
+ * into layers / leaking the render fn.
125
+ */
126
+ function defaultMonoExpose(config) {
127
+ const { extends: _extends, renderFn: _renderFn, ...rest } = config;
128
+ return sanitizeForExpose(rest) ?? {};
129
+ }
130
+
131
+ //#endregion
132
+ //#region src/vite/mono-link.ts
133
+ /** `<Tag` / `</Tag` for the tags we rewrite — the lookahead keeps `<NuxtLinkFoo` out. */
134
+ const tagRe = (names) => new RegExp(`<(/?)(${names.join("|")})(?=[\\s/>])`, "g");
135
+ /** One attribute: `name`, `name="v"`, `:name="v"`, `@click.prevent="v"`, `v-if="v"`. */
136
+ const ATTR_RE = /([^\s"'=<>/]+)(\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'=<>`]+))?/g;
137
+ /** `https:` / `mailto:` / `tel:` / `//cdn…` — anything vue-router would mangle into a path. */
138
+ const ABSOLUTE_RE = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
139
+ /** Nuxt-only props: meaningless on `<RouterLink>`, and worse on a plain `<a>` (they'd render as DOM attributes). */
140
+ const NUXT_ONLY = [
141
+ "external",
142
+ "prefetch",
143
+ "noprefetch",
144
+ "prefetchon",
145
+ "prefetchedclass",
146
+ "norel",
147
+ "trailingslash"
148
+ ];
149
+ /** Router props on top of those — a plain `<a>` understands none of them. */
150
+ const ROUTER_ONLY = [
151
+ "replace",
152
+ "activeclass",
153
+ "exactactiveclass",
154
+ "ariacurrentvalue",
155
+ "custom",
156
+ "viewtransition"
157
+ ];
158
+ /**
159
+ * Vite plugin: `<NuxtLink>` -> `<RouterLink>` (or `<a>`) for a Vue/Vite host.
160
+ *
161
+ * A synced Nuxt remote links with `<NuxtLink to="/x">`, which Nuxt auto-imports.
162
+ * The Vue host has no such component, so Vue logs `Failed to resolve component:
163
+ * NuxtLink` and renders nothing. This rewrites the tag in remote templates:
164
+ *
165
+ * - `<NuxtLink to="/x">` -> `<RouterLink to="/x">`
166
+ * - `<NuxtLink external to="/x">` -> `<RouterLink to="/x" target="_blank" rel="noopener noreferrer">`
167
+ * - `<NuxtLink to="https://…">` -> `<a href="https://…" rel="noopener noreferrer">`
168
+ *
169
+ * `external` stays a RouterLink because vue-router's `guardEvent` won't intercept
170
+ * a click on a targeted anchor — the browser navigates for real, which is what
171
+ * `external` means, and `to` still resolves as a route. An ABSOLUTE `to` is the
172
+ * one case that can't: `router.resolve('https://x.dev')` treats it as a path and
173
+ * renders `href="/https://x.dev"`, so those become a real `<a>` (with
174
+ * `target="_blank"` too when the tag also said `external`).
175
+ *
176
+ * Nuxt-only props (`prefetch`, `no-rel`, `trailing-slash`, …) are dropped rather
177
+ * than passed through, or they'd land on the DOM as literal attributes. `href` is
178
+ * renamed to `to` (NuxtLink accepts both), and for the `<a>` form `to` becomes
179
+ * `href`. Everything else — `class`, `target`, `@click`, `v-if`, slots — is left
180
+ * exactly as written, and `</NuxtLink>` follows whatever its opening tag became.
181
+ *
182
+ * Case is preserved: `<nuxt-link>` -> `<router-link>`. `RouterLink` is registered
183
+ * globally by `app.use(router)`, so nothing needs importing.
184
+ *
185
+ * LIMITS (both warn at build time rather than mis-compiling): a computed
186
+ * `:external="cond"` can't be resolved here, so the link stays in-app (no
187
+ * `target`); and a `custom` NuxtLink gets neither treatment, since it renders no
188
+ * element of its own — only the `v-slot="{ href, navigate }"` content.
189
+ *
190
+ * `enforce: 'pre'` — the SFC must still be raw source, so register before
191
+ * `@vitejs/plugin-vue` (`monoVue()` / `monoRepo().nuxt().hostResolver()` do).
192
+ */
193
+ function monoNuxtLinkToRouterLink(options = {}) {
194
+ const isRemote = remoteGate(options);
195
+ const externalRel = options.externalRel !== false;
196
+ return {
197
+ name: "mono-nuxt-link-to-router-link",
198
+ enforce: "pre",
199
+ transform(code, id) {
200
+ const file = id?.split("?")[0]?.replace(/\\/g, "/");
201
+ if (!file || !file.endsWith(".vue") || !isRemote(file)) return;
202
+ if (!/<\/?(?:NuxtLink|nuxt-link)[\s/>]/.test(code)) return;
203
+ const warn = (message) => this.warn(`[mono-link] ${file}: ${message}`);
204
+ const out = rewriteTags(code, ["NuxtLink", "nuxt-link"], (name, attrsSrc) => renderNuxtLink(name, attrsSrc, externalRel, warn));
205
+ return out === code ? void 0 : {
206
+ code: out,
207
+ map: null
208
+ };
209
+ }
210
+ };
211
+ }
212
+ /**
213
+ * Vite plugin (Nuxt host): `<RouterLink>` -> `<NuxtLink>` for synced **Vue**
214
+ * remotes — the mirror of {@link monoNuxtLinkToRouterLink}, registered by
215
+ * `@mono-lit/utility/nuxt`.
216
+ *
217
+ * `<RouterLink>` does resolve under Nuxt (vue-router registers it), so this isn't
218
+ * a fix for a broken render — it's so remote links behave like the host's own:
219
+ * route prefetching, external/absolute-URL handling, and `trailingSlash`
220
+ * normalisation, none of which RouterLink does. Every RouterLink prop (`to`,
221
+ * `replace`, `active-class`, `exact-active-class`, `custom`, `aria-current-value`)
222
+ * is a NuxtLink prop too, so this is a pure tag rename — attributes, slots and
223
+ * `v-slot` bindings pass through untouched. Case is preserved:
224
+ * `<router-link>` -> `<nuxt-link>`.
225
+ */
226
+ function monoRouterLinkToNuxtLink(options = {}) {
227
+ const isRemote = remoteGate(options);
228
+ return {
229
+ name: "mono-router-link-to-nuxt-link",
230
+ enforce: "pre",
231
+ transform(code, id) {
232
+ const file = id?.split("?")[0]?.replace(/\\/g, "/");
233
+ if (!file || !file.endsWith(".vue") || !isRemote(file)) return;
234
+ if (!/<\/?(?:RouterLink|router-link)[\s/>]/.test(code)) return;
235
+ const out = rewriteTags(code, ["RouterLink", "router-link"], (name, attrsSrc) => ({
236
+ tag: name === "router-link" ? "nuxt-link" : "NuxtLink",
237
+ attrs: attrsSrc
238
+ }));
239
+ return out === code ? void 0 : {
240
+ code: out,
241
+ map: null
242
+ };
243
+ }
244
+ };
245
+ }
246
+ /** Clearer aliases. */
247
+ const monoNuxtLink = monoNuxtLinkToRouterLink;
248
+ const monoRouterLink = monoRouterLinkToNuxtLink;
249
+ /**
250
+ * Replace every `<name …>`/`</name>` pair using `render`, which returns the new
251
+ * tag name and attribute text for an opening tag. A stack carries each opening
252
+ * tag's replacement to its `</…>`, so a tag that became `<a>` closes as `</a>`
253
+ * while its sibling closes as `</RouterLink>`. Returns the input untouched if the
254
+ * markup is malformed (unterminated tag) rather than emitting half a rewrite.
255
+ */
256
+ function rewriteTags(code, names, render) {
257
+ const re = tagRe(names);
258
+ const stack = [];
259
+ let out = "";
260
+ let last = 0;
261
+ let match;
262
+ while (match = re.exec(code)) {
263
+ const closing = match[1] === "/";
264
+ const name = match[2];
265
+ out += code.slice(last, match.index);
266
+ if (closing) {
267
+ const gt = code.indexOf(">", match.index);
268
+ if (gt === -1) return code;
269
+ out += `</${stack.pop() ?? render(name, "").tag}>`;
270
+ last = gt + 1;
271
+ re.lastIndex = last;
272
+ continue;
273
+ }
274
+ const gt = findTagEnd(code, match.index + match[0].length);
275
+ if (gt === -1) return code;
276
+ const selfClosing = code[gt - 1] === "/";
277
+ const { tag, attrs } = render(name, code.slice(match.index + match[0].length, selfClosing ? gt - 1 : gt));
278
+ const text = attrs.trim() || attrs.includes("\n") ? attrs : selfClosing ? " " : "";
279
+ out += `<${tag}${text}${selfClosing ? "/>" : ">"}`;
280
+ if (!selfClosing) stack.push(tag);
281
+ last = gt + 1;
282
+ re.lastIndex = last;
283
+ }
284
+ out += code.slice(last);
285
+ return out;
286
+ }
287
+ /** Index of the `>` ending a tag, skipping quoted attribute values. */
288
+ function findTagEnd(code, from) {
289
+ let quote = "";
290
+ for (let i = from; i < code.length; i++) {
291
+ const c = code[i];
292
+ if (quote) {
293
+ if (c === quote) quote = "";
294
+ continue;
295
+ }
296
+ if (c === "\"" || c === "'" || c === "`") quote = c;
297
+ else if (c === ">") return i;
298
+ }
299
+ return -1;
300
+ }
301
+ /** The `<NuxtLink>` -> `<RouterLink>` / `<a>` decision for one opening tag. */
302
+ function renderNuxtLink(name, attrsSrc, externalRel, warn) {
303
+ const routerTag = name === "nuxt-link" ? "router-link" : "RouterLink";
304
+ const attrs = parseAttrs(attrsSrc);
305
+ const find = (key) => attrs.find((a) => a.key === key);
306
+ const custom = find("custom");
307
+ const external = staticFlag(find("external"));
308
+ const absolute = isAbsoluteTarget(find("to") ?? find("href"));
309
+ if (find("external") && external === void 0 && !custom) warn(`<${name} :external="…"> can't be resolved at build time, so no target="_blank" was added — it stays an in-app <${routerTag}>. Use a literal \`external\`, or an absolute URL in \`to\`.`);
310
+ if (custom) {
311
+ if (external || absolute) warn(`<${name} custom external> stays an in-app link — it renders no element to target. Handle the external href yourself.`);
312
+ return {
313
+ tag: routerTag,
314
+ attrs: buildRouterLink(attrsSrc, attrs, false, externalRel)
315
+ };
316
+ }
317
+ if (absolute) return {
318
+ tag: "a",
319
+ attrs: buildAnchor(attrsSrc, attrs, externalRel, external === true)
320
+ };
321
+ return {
322
+ tag: routerTag,
323
+ attrs: buildRouterLink(attrsSrc, attrs, external === true, externalRel)
324
+ };
325
+ }
326
+ /**
327
+ * Keep the router props, drop the Nuxt-only ones, fold `href` into `to`.
328
+ *
329
+ * An `external` link gets `target="_blank"` instead of becoming an `<a>`:
330
+ * vue-router's `guardEvent` refuses to intercept a click on an anchor with a
331
+ * `target`, so the browser navigates for real — a full page load out of the SPA,
332
+ * which is what `external` means — while `to` keeps working as a route.
333
+ */
334
+ function buildRouterLink(src, attrs, external, externalRel) {
335
+ const hasTo = attrs.some((a) => a.key === "to");
336
+ return edit(src, attrs, (a) => {
337
+ if (NUXT_ONLY.includes(a.key)) return "";
338
+ if (a.key === "href" && !hasTo) return rename(a, "to");
339
+ }, external ? externalAttrs(attrs, externalRel) : "");
340
+ }
341
+ /**
342
+ * `target="_blank"` + `rel="noopener noreferrer"` for an external link — each
343
+ * skipped if the author wrote their own (or opted out via `no-rel` /
344
+ * `externalRel: false`). Both fall through to the anchor RouterLink renders.
345
+ */
346
+ function externalAttrs(attrs, externalRel) {
347
+ const has = (key) => attrs.some((a) => a.key === key);
348
+ return `${has("target") ? "" : " target=\"_blank\""}${externalRel && !has("norel") && !has("rel") ? " rel=\"noopener noreferrer\"" : ""}`;
349
+ }
350
+ /**
351
+ * Keep the DOM/Vue attrs, drop every link-component prop, fold `to` into `href`.
352
+ * `blank` adds `target="_blank"` — for a link that said `external` outright, not
353
+ * for one we only inferred from an absolute URL.
354
+ */
355
+ function buildAnchor(src, attrs, externalRel, blank) {
356
+ const hasHref = attrs.some((a) => a.key === "href");
357
+ const noRel = attrs.some((a) => a.key === "norel");
358
+ const hasRel = attrs.some((a) => a.key === "rel");
359
+ const rel = externalRel && !noRel && !hasRel ? " rel=\"noopener noreferrer\"" : "";
360
+ return edit(src, attrs, (a) => {
361
+ if (NUXT_ONLY.includes(a.key) || ROUTER_ONLY.includes(a.key)) return "";
362
+ if (a.key === "to") return hasHref ? "" : rename(a, "href");
363
+ }, `${blank && !attrs.some((a) => a.key === "target") ? " target=\"_blank\"" : ""}${rel}`);
364
+ }
365
+ /**
366
+ * Rewrite an attribute source in place: `patch` returns the replacement text for
367
+ * an attribute (`''` deletes it) or `undefined` to leave it exactly as written;
368
+ * `append` is inserted after the LAST attribute (not at the very end, so a
369
+ * multi-line tag doesn't strand it past the closing indentation).
370
+ *
371
+ * Everything between attributes — spaces, newlines, indentation — is untouched, so
372
+ * the tag keeps its shape and the file keeps its line numbering (these plugins
373
+ * emit no sourcemap, so a shifted line would misplace every later Vue error).
374
+ */
375
+ function edit(src, attrs, patch, append = "") {
376
+ let out = "";
377
+ let last = 0;
378
+ for (const attr of attrs) {
379
+ const replacement = patch(attr);
380
+ if (replacement === void 0) continue;
381
+ const [start, end] = replacement === "" ? dropRange(src, attr) : [attr.start, attr.end];
382
+ out += src.slice(last, start) + replacement;
383
+ last = end;
384
+ }
385
+ if (!append) return out + src.slice(last);
386
+ const at = attrs.length ? attrs[attrs.length - 1].end : src.length;
387
+ return out + src.slice(last, at) + append + src.slice(at);
388
+ }
389
+ /**
390
+ * A dropped attribute takes one side's spacing with it, so `<NuxtLink external
391
+ * to="…">` doesn't come out as `<a href="…">`. Spaces and tabs only — eating a
392
+ * newline would pull the next attribute onto the previous line and shift every
393
+ * line after it. Trailing spacing goes first (keeping the tag-name separator);
394
+ * leading spacing only when nothing follows on the tag.
395
+ */
396
+ function dropRange(src, attr) {
397
+ const space = (i) => src[i] === " " || src[i] === " ";
398
+ let { start, end } = attr;
399
+ while (end < src.length && space(end)) end++;
400
+ if (!src.slice(end).trim()) while (start > 1 && space(start - 1)) start--;
401
+ return [start, end];
402
+ }
403
+ /** Same binding style and value, different prop name (`:to="x"` -> `:href="x"`). */
404
+ function rename(attr, prop) {
405
+ return `${attr.prefix}${prop}${attr.suffix}${attr.valuePart}`;
406
+ }
407
+ function parseAttrs(src) {
408
+ const out = [];
409
+ for (const match of src.matchAll(ATTR_RE)) {
410
+ const name = match[1];
411
+ const valuePart = match[2] ?? "";
412
+ const { prefix, prop, suffix, directive } = splitName(name);
413
+ out.push({
414
+ raw: match[0],
415
+ start: match.index,
416
+ end: match.index + match[0].length,
417
+ prefix,
418
+ prop,
419
+ suffix,
420
+ valuePart,
421
+ key: directive ? "" : prop.replace(/-/g, "").toLowerCase(),
422
+ bound: prefix !== ""
423
+ });
424
+ }
425
+ return out;
426
+ }
427
+ /**
428
+ * Split an attribute name into `prefix + prop + modifiers`. Directives, events and
429
+ * slots (`v-if`, `@click`, `#default`) get `directive: true` — they're never
430
+ * matched, renamed or dropped, just carried through verbatim.
431
+ */
432
+ function splitName(name) {
433
+ let prefix = "";
434
+ let rest = name;
435
+ if (rest.startsWith("v-bind:")) {
436
+ prefix = "v-bind:";
437
+ rest = rest.slice(7);
438
+ } else if (rest.startsWith(":") || rest.startsWith(".")) {
439
+ prefix = rest[0];
440
+ rest = rest.slice(1);
441
+ } else if (/^(?:@|#|v-)/.test(rest)) return {
442
+ prefix: "",
443
+ prop: rest,
444
+ suffix: "",
445
+ directive: true
446
+ };
447
+ if (rest.startsWith("[")) return {
448
+ prefix,
449
+ prop: rest,
450
+ suffix: "",
451
+ directive: true
452
+ };
453
+ const dot = rest.indexOf(".");
454
+ return {
455
+ prefix,
456
+ prop: dot === -1 ? rest : rest.slice(0, dot),
457
+ suffix: dot === -1 ? "" : rest.slice(dot),
458
+ directive: false
459
+ };
460
+ }
461
+ /**
462
+ * Is a boolean-ish prop statically on? `true`/`false` for a decidable literal,
463
+ * `undefined` for a runtime expression (which no build-time rewrite can settle).
464
+ */
465
+ function staticFlag(attr) {
466
+ if (!attr) return false;
467
+ const value = unquote(attr.valuePart);
468
+ if (!attr.bound) return value === "" || value === "true";
469
+ if (value === "true") return true;
470
+ if (value === "false") return false;
471
+ }
472
+ /** A `to`/`href` whose literal value is an absolute URL vue-router can't route. */
473
+ function isAbsoluteTarget(attr) {
474
+ if (!attr) return false;
475
+ const value = unquote(attr.valuePart);
476
+ if (!attr.bound) return ABSOLUTE_RE.test(value);
477
+ const literal = /^\s*(['"])([^'"]*)\1\s*$/.exec(value);
478
+ return literal ? ABSOLUTE_RE.test(literal[2]) : false;
479
+ }
480
+ /** `="foo"` -> `foo`; `''` (valueless attribute) -> `''`. */
481
+ function unquote(valuePart) {
482
+ const value = valuePart.replace(/^\s*=\s*/, "");
483
+ const quoted = /^(['"])([\s\S]*)\1$/.exec(value);
484
+ return (quoted ? quoted[2] : value).trim();
485
+ }
486
+
487
+ //#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 };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,27 @@
1
+ import { o as runMonoPrepare } from "./mono-tsconfig-D2qRL9_R.js";
2
+ import path from "node:path";
3
+ import { defineCommand, runMain } from "citty";
4
+
5
+ //#region pkg/cli/prepare.ts
6
+ runMain(defineCommand({
7
+ meta: {
8
+ name: "prepare",
9
+ description: "Generate .mono/tsconfig.json from the mono alias map and wire it into the root tsconfig (via extends)."
10
+ },
11
+ args: { cwd: {
12
+ type: "string",
13
+ description: "App root to prepare (defaults to the current directory)."
14
+ } },
15
+ async run({ args }) {
16
+ const dirname = path.resolve(args.cwd ?? process.cwd());
17
+ const result = await runMonoPrepare({ dirname });
18
+ const monoRel = path.relative(dirname, result.monoTsconfigPath) || result.monoTsconfigPath;
19
+ console.log(`[mono] wrote ${monoRel} (${result.writtenKeys.length} aliases)`);
20
+ if (result.addedExtends) console.log("[mono] added \"extends\" -> ./.mono/tsconfig.json to tsconfig.json");
21
+ else console.log("[mono] tsconfig.json already extends ./.mono/tsconfig.json");
22
+ if (result.removedKeys.length) console.log(`[mono] removed ${result.removedKeys.length} inline alias path(s) from tsconfig.json`);
23
+ if (result.wiredApps.length) console.log(`[mono] wired ${result.wiredApps.length} cloned app tsconfig(s) -> ${monoRel}: ${result.wiredApps.join(", ")}`);
24
+ }
25
+ }));
26
+
27
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };