@nimtech/nimpress 2.6.10 → 2.6.12

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/dist/cli.es.js CHANGED
@@ -1,30 +1,30 @@
1
- import { d as J, c as Ae, r as Me, s as Bt, p as Gt, a as tt, b as pe, e as Ht, f as Ut, g as De, h as st, i as Zt, j as nt, k as Vt, l as Kt, m as Yt, C as ge, n as Qt, o as ot, q as Ge, w as me, t as rt, u as Xt, v as qt, x as es, y as ts, z as ss, A as ns, B as we, D as os } from "./plugin-BDy913Zy.js";
1
+ import { d as z, c as Ae, r as Me, s as Gt, p as Ht, a as st, b as pe, e as Ut, f as Zt, g as De, h as nt, i as Vt, j as ot, k as Kt, l as Yt, m as Qt, C as ge, n as Xt, o as rt, q as Ge, w as me, t as it, u as qt, v as es, x as He, y as ts, z as ss, A as ns, B as os, D as we, E as rs } from "./plugin-DnnKU6ST.js";
2
2
  import { join as d, dirname as N, relative as F, sep as L, extname as fe, resolve as x, basename as D } from "node:path";
3
- import { readdirSync as re, existsSync as b, writeFileSync as W, mkdirSync as B, rmSync as q, readFileSync as C, statSync as it, watch as He } from "node:fs";
4
- import le from "gray-matter";
5
- import { readFile as Se, readdir as rs, writeFile as X, mkdir as _e, copyFile as at } from "node:fs/promises";
6
- import { s as is, r as $e } from "./typeMembers-CNvE92EX.js";
7
- import { createServer as ct, build as lt } from "vite";
8
- import { createHash as ut } from "node:crypto";
9
- import { createInterface as pt } from "node:readline/promises";
10
- import { fileURLToPath as mt } from "node:url";
11
- import { homedir as K, platform as as } from "node:os";
12
- import { spawnSync as ee, spawn as Ie } from "node:child_process";
13
- import { createInterface as cs } from "node:readline";
14
- import { parse as ls } from "yaml";
3
+ import { readdirSync as ie, existsSync as b, writeFileSync as W, mkdirSync as B, rmSync as ee, readFileSync as C, statSync as at, watch as Ue } from "node:fs";
4
+ import ue from "gray-matter";
5
+ import { readFile as Se, readdir as is, writeFile as q, mkdir as _e, copyFile as ct } from "node:fs/promises";
6
+ import { s as as, r as $e } from "./typeMembers-CNvE92EX.js";
7
+ import { createServer as lt, build as ut } from "vite";
8
+ import { createHash as pt } from "node:crypto";
9
+ import { createInterface as mt } from "node:readline/promises";
10
+ import { fileURLToPath as ft } from "node:url";
11
+ import { homedir as K, platform as cs } from "node:os";
12
+ import { spawnSync as te, spawn as Ie } from "node:child_process";
13
+ import { createInterface as ls } from "node:readline";
14
+ import { parse as us } from "yaml";
15
15
  function _(e, t) {
16
16
  return e.find((n) => n.startsWith(`--${t}=`))?.slice(t.length + 3);
17
17
  }
18
- function I(e, t) {
18
+ function M(e, t) {
19
19
  return e.includes(`--${t}`);
20
20
  }
21
- function ie(e, t) {
21
+ function ne(e, t) {
22
22
  return e.filter((n) => !n.startsWith("--"))[t];
23
23
  }
24
24
  function Y(e, t = []) {
25
25
  let s;
26
26
  try {
27
- s = re(e, { withFileTypes: !0 });
27
+ s = ie(e, { withFileTypes: !0 });
28
28
  } catch {
29
29
  return t;
30
30
  }
@@ -45,7 +45,7 @@ function Ne(e, t, s) {
45
45
  }
46
46
  console.log(s);
47
47
  }
48
- function us() {
48
+ function ps() {
49
49
  return `import { defineConfig } from '@nimtech/nimpress/plugin'
50
50
 
51
51
  /**
@@ -55,15 +55,15 @@ function us() {
55
55
  */
56
56
  export default defineConfig({
57
57
  /** Site title shown in the header and the tab. */
58
- title: ${JSON.stringify(J.title)},
58
+ title: ${JSON.stringify(z.title)},
59
59
 
60
- /** Folder holding the markdown content. Default ${JSON.stringify(J.contentDir)}. */
60
+ /** Folder holding the markdown content. Default ${JSON.stringify(z.contentDir)}. */
61
61
  // contentDir: 'docs',
62
62
 
63
- /** Root assets folder copied into the build, never inside contentDir. Default ${JSON.stringify(J.assetsDir)}. */
63
+ /** Root assets folder copied into the build, never inside contentDir. Default ${JSON.stringify(z.assetsDir)}. */
64
64
  // assetsDir: 'assets',
65
65
 
66
- /** Url base the assets folder serves under. Default ${JSON.stringify(J.assetUrlBase)}. */
66
+ /** Url base the assets folder serves under. Default ${JSON.stringify(z.assetUrlBase)}. */
67
67
  // assetUrlBase: '/assets',
68
68
 
69
69
  /**
@@ -181,21 +181,21 @@ export default defineConfig({
181
181
  })
182
182
  `;
183
183
  }
184
- function ps() {
184
+ function ms() {
185
185
  return JSON.stringify(
186
186
  {
187
187
  $schema: "./node_modules/@nimtech/nimpress/config.schema.json",
188
- title: J.title,
189
- contentDir: J.contentDir,
190
- assetsDir: J.assetsDir,
191
- assetUrlBase: J.assetUrlBase
188
+ title: z.title,
189
+ contentDir: z.contentDir,
190
+ assetsDir: z.assetsDir,
191
+ assetUrlBase: z.assetUrlBase
192
192
  },
193
193
  null,
194
194
  2
195
195
  ) + `
196
196
  `;
197
197
  }
198
- function ms(e) {
198
+ function fs(e) {
199
199
  return `# Nimpress project
200
200
 
201
201
  This site is built with @nimtech/nimpress. Content lives in \`${e}/\` as markdown with typed frontmatter.
@@ -237,11 +237,11 @@ The authoritative AI working rules ship inside the package at \`node_modules/@ni
237
237
  8. \`nimpress guard map\` and \`nimpress guard apply\` wire gated pages, marked with the \`gate:\` frontmatter field, to the auth provider artifacts.
238
238
  `;
239
239
  }
240
- function fs(e) {
241
- const t = d(e, "nimpress.config.ts"), s = d(e, "nimpress.config.json"), n = I(process.argv.slice(2), "json");
242
- !b(t) && !b(s) && (n ? (W(s, ps()), console.log(`nimpress init: ${s} written, field descriptions come from the referenced config.schema.json`)) : (W(t, us()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
243
- const o = d(e, J.contentDir);
244
- (!b(o) || re(o).length === 0) && (B(o, { recursive: !0 }), W(
240
+ function ds(e) {
241
+ const t = d(e, "nimpress.config.ts"), s = d(e, "nimpress.config.json"), n = M(process.argv.slice(2), "json");
242
+ !b(t) && !b(s) && (n ? (W(s, ms()), console.log(`nimpress init: ${s} written, field descriptions come from the referenced config.schema.json`)) : (W(t, ps()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
243
+ const o = d(e, z.contentDir);
244
+ (!b(o) || ie(o).length === 0) && (B(o, { recursive: !0 }), W(
245
245
  d(o, "index.md"),
246
246
  `---
247
247
  title: Home
@@ -250,59 +250,59 @@ title: Home
250
250
  Welcome to your Nimpress site.
251
251
  `
252
252
  ));
253
- const i = ms(J.contentDir);
253
+ const i = fs(z.contentDir);
254
254
  for (const c of ["CLAUDE.md", "AGENTS.md"]) {
255
- const u = d(e, c);
256
- b(u) || (W(u, i), console.log(`nimpress init: ${c} written, pointing at the packaged rules in node_modules/@nimtech/nimpress/.claude/rules/`));
255
+ const p = d(e, c);
256
+ b(p) || (W(p, i), console.log(`nimpress init: ${c} written, pointing at the packaged rules in node_modules/@nimtech/nimpress/.claude/rules/`));
257
257
  }
258
258
  }
259
- const ds = { vue: "vueStory", svelte: "svelteStory" }, hs = { vue: ".svelte", svelte: ".vue" };
260
- function ae(e) {
259
+ const hs = { vue: "vueStory", svelte: "svelteStory" }, gs = { vue: ".svelte", svelte: ".vue" };
260
+ function ce(e) {
261
261
  return `run nimpress modules update ${e}`;
262
262
  }
263
- async function gs(e) {
263
+ async function ws(e) {
264
264
  let t;
265
265
  try {
266
- t = await rs(e, { withFileTypes: !0 });
266
+ t = await is(e, { withFileTypes: !0 });
267
267
  } catch {
268
268
  return [];
269
269
  }
270
270
  return t.filter((s) => s.isFile() && /\.story\.tsx?$/.test(s.name)).map((s) => s.name);
271
271
  }
272
- function ws(e, t) {
272
+ function $s(e, t) {
273
273
  const s = t === "integer" ? "number" : t;
274
274
  return e.every((n) => typeof n === s);
275
275
  }
276
- function $s(e, t, s, n, o) {
276
+ function ys(e, t, s, n, o) {
277
277
  const r = [], i = n.properties ?? {}, c = o.properties ?? {};
278
278
  for (const m of Object.keys(c))
279
- m in i || r.push(`${e}: prop ${m} is missing from the schema, ${ae(t)}`);
279
+ m in i || r.push(`${e}: prop ${m} is missing from the schema, ${ce(t)}`);
280
280
  for (const m of Object.keys(i))
281
281
  m in c || r.push(`${e}: schema prop ${m} has no counterpart in ${s}, remove it or restore the prop`);
282
282
  for (const [m, f] of Object.entries(i)) {
283
283
  const h = c[m];
284
284
  if (h && (f.type && h.type && f.type !== h.type && !f.enum && r.push(
285
- `${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${ae(t)}`
286
- ), f.enum && h.type && !ws(f.enum, h.type) && r.push(`${e}: prop ${m} enum values mismatch the source type ${h.type}`), f.enum && h.enum)) {
285
+ `${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${ce(t)}`
286
+ ), f.enum && h.type && !$s(f.enum, h.type) && r.push(`${e}: prop ${m} enum values mismatch the source type ${h.type}`), f.enum && h.enum)) {
287
287
  const g = new Set(h.enum.map((k) => JSON.stringify(k))), w = f.enum.filter((k) => !g.has(JSON.stringify(k)));
288
288
  w.length && r.push(
289
289
  `${e}: prop ${m} enum carries ${w.map((k) => JSON.stringify(k)).join(", ")} outside the source union`
290
290
  );
291
291
  }
292
292
  }
293
- const u = n.slots ?? {}, a = o.slots ?? {};
293
+ const p = n.slots ?? {}, a = o.slots ?? {};
294
294
  for (const m of Object.keys(a))
295
- m in u || r.push(`${e}: slot ${m} is missing from the schema, ${ae(t)}`);
296
- for (const m of Object.keys(u))
295
+ m in p || r.push(`${e}: slot ${m} is missing from the schema, ${ce(t)}`);
296
+ for (const m of Object.keys(p))
297
297
  m in a || r.push(`${e}: schema slot ${m} has no counterpart in ${s}`);
298
- const p = new Set(n.emits ?? []), l = new Set(o.emits ?? []);
298
+ const l = new Set(n.emits ?? []), u = new Set(o.emits ?? []);
299
+ for (const m of u)
300
+ l.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${ce(t)}`);
299
301
  for (const m of l)
300
- p.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${ae(t)}`);
301
- for (const m of p)
302
- l.has(m) || r.push(`${e}: schema emit ${m} has no counterpart in ${s}`);
302
+ u.has(m) || r.push(`${e}: schema emit ${m} has no counterpart in ${s}`);
303
303
  return r;
304
304
  }
305
- async function ft(e, t, s) {
305
+ async function dt(e, t, s) {
306
306
  const n = s ? [s] : Object.keys(t.modules.systems), o = [], r = await Ae(e, t.contentDir);
307
307
  for (const i of n) {
308
308
  const c = t.modules.systems[i];
@@ -310,11 +310,11 @@ async function ft(e, t, s) {
310
310
  o.push(`${i}: not a configured system`);
311
311
  continue;
312
312
  }
313
- const u = c.framework, a = ds[u === "vue" ? "svelte" : "vue"], p = hs[u];
314
- for (const l of r) {
315
- if (l.system !== i) continue;
316
- const m = N(l.pageFile), f = F(e, m).split(L).join("/"), h = await gs(m);
317
- h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${l.component}`);
313
+ const p = c.framework, a = hs[p === "vue" ? "svelte" : "vue"], l = gs[p];
314
+ for (const u of r) {
315
+ if (u.system !== i) continue;
316
+ const m = N(u.pageFile), f = F(e, m).split(L).join("/"), h = await ws(m);
317
+ h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${u.component}`);
318
318
  const g = /* @__PURE__ */ new Set();
319
319
  for (const O of h) {
320
320
  let T;
@@ -323,20 +323,20 @@ async function ft(e, t, s) {
323
323
  } catch {
324
324
  continue;
325
325
  }
326
- (/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(O), T.includes(a) && o.push(`${f}/${O}: uses ${a} inside the ${u} system ${i}`);
326
+ (/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(O), T.includes(a) && o.push(`${f}/${O}: uses ${a} inside the ${p} system ${i}`);
327
327
  for (const $ of T.matchAll(/from\s+['"]([^'"]+)['"]/g))
328
- fe($[1]) === p && o.push(`${f}/${O}: imports ${$[1]} inside the ${u} system ${i}`);
328
+ fe($[1]) === l && o.push(`${f}/${O}: imports ${$[1]} inside the ${p} system ${i}`);
329
329
  }
330
- const w = Me(e, t.modules, i, l.component, l.file);
331
- if (w && fe(w.componentFile) === p && o.push(
332
- `${f}: component file ${F(e, w.componentFile)} mismatches the ${u} system ${i}`
330
+ const w = Me(e, t.modules, i, u.component, u.file);
331
+ if (w && fe(w.componentFile) === l && o.push(
332
+ `${f}: component file ${F(e, w.componentFile)} mismatches the ${p} system ${i}`
333
333
  ), b(d(m, "schema.json")) && b(d(m, "schema.yml"))) {
334
334
  o.push(`${f}: both schema.json and schema.yml exist, keep one`);
335
335
  continue;
336
336
  }
337
- const k = Bt(m);
337
+ const k = Gt(m);
338
338
  if (!k) {
339
- o.push(`${f}: schema file missing, ${ae(l.component)}`);
339
+ o.push(`${f}: schema file missing, ${ce(u.component)}`);
340
340
  continue;
341
341
  }
342
342
  let j;
@@ -348,69 +348,69 @@ async function ft(e, t, s) {
348
348
  }
349
349
  let E;
350
350
  try {
351
- E = Gt(j, k.form);
351
+ E = Ht(j, k.form);
352
352
  } catch {
353
353
  o.push(`${f}: schema is not valid ${k.form}, fix it by hand`);
354
354
  continue;
355
355
  }
356
356
  const v = new Set(Object.keys(E.properties ?? {}));
357
- for (const O of await tt(m))
357
+ for (const O of await st(m))
358
358
  if (!g.has(O.file))
359
359
  for (const T of Object.keys(O.props ?? {}))
360
- v.has(T) || o.push(`${f}/${O.file}: prop ${T} is absent from the schema, ${ae(l.component)}`);
360
+ v.has(T) || o.push(`${f}/${O.file}: prop ${T} is absent from the schema, ${ce(u.component)}`);
361
361
  const R = w ? await Se(w.componentFile, "utf-8").catch(() => {
362
362
  }) : void 0;
363
363
  if (w) {
364
- const O = await pe(w.componentFile, u, l.component);
364
+ const O = await pe(w.componentFile, p, u.component);
365
365
  if (O) {
366
- const T = is(l.component, O.props, O.slots, O.emits);
366
+ const T = as(u.component, O.props, O.slots, O.emits);
367
367
  o.push(
368
- ...$s(f, l.component, F(e, w.componentFile), E, T)
368
+ ...ys(f, u.component, F(e, w.componentFile), E, T)
369
369
  );
370
370
  }
371
371
  }
372
- Ht(Ut(l.component, E, { sourceFile: w?.componentFile, sourceText: R }));
372
+ Ut(Zt(u.component, E, { sourceFile: w?.componentFile, sourceText: R }));
373
373
  }
374
374
  }
375
375
  return De(e), o;
376
376
  }
377
- function dt(e) {
377
+ function ht(e) {
378
378
  return Object.entries(e.modules.systems).filter(([, t]) => t.visibility !== "dev-only").map(([t]) => t);
379
379
  }
380
- async function ht(e, t, s) {
380
+ async function gt(e, t, s) {
381
381
  for (const n of s)
382
382
  try {
383
- await (await ct(await nt(e, t, n, "serve"))).listen(), console.log(`nimpress modules: ${n} harness on port ${Vt(t.modules, n)}`);
383
+ await (await lt(await ot(e, t, n, "serve"))).listen(), console.log(`nimpress modules: ${n} harness on port ${Kt(t.modules, n)}`);
384
384
  } catch (o) {
385
385
  console.warn(`nimpress modules: harness for ${n} failed to start: ${String(o)}`);
386
386
  }
387
387
  }
388
- async function gt(e, t, s) {
388
+ async function wt(e, t, s) {
389
389
  for (const n of s)
390
- await lt(await nt(e, t, n, "build")), console.log(`nimpress modules: built ${n}`);
390
+ await ut(await ot(e, t, n, "build")), console.log(`nimpress modules: built ${n}`);
391
391
  }
392
- async function ys(e, t) {
393
- const s = await ct(await st({ cwd: e, command: "serve", resolved: t }));
394
- await s.listen(), await ht(e, t, Object.keys(t.modules.systems)), s.printUrls(), s.bindCLIShortcuts({ print: !0 });
392
+ async function bs(e, t) {
393
+ const s = await lt(await nt({ cwd: e, command: "serve", resolved: t }));
394
+ await s.listen(), await gt(e, t, Object.keys(t.modules.systems)), s.printUrls(), s.bindCLIShortcuts({ print: !0 });
395
395
  }
396
- async function wt(e, t) {
396
+ async function $t(e, t) {
397
397
  const s = d(e, "index.html"), n = !b(s);
398
- n && W(s, Zt(t));
398
+ n && W(s, Vt(t));
399
399
  const o = () => {
400
- n && q(s, { force: !0 });
400
+ n && ee(s, { force: !0 });
401
401
  }, r = () => {
402
402
  o(), process.exit(130);
403
403
  };
404
404
  process.once("SIGINT", r), process.once("SIGTERM", r);
405
405
  try {
406
- await lt(await st({ cwd: e, command: "build", resolved: t, htmlInput: s }));
406
+ await ut(await nt({ cwd: e, command: "build", resolved: t, htmlInput: s }));
407
407
  } finally {
408
408
  process.off("SIGINT", r), process.off("SIGTERM", r), o();
409
409
  }
410
- await gt(e, t, dt(t));
410
+ await wt(e, t, ht(t));
411
411
  }
412
- const bs = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], vs = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Ue = /^[a-z0-9][a-z0-9.-]*$/, ks = /^[A-Z][A-Za-z0-9]*$/;
413
- function xs(e) {
412
+ const vs = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], ks = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Ze = /^[a-z0-9][a-z0-9.-]*$/, xs = /^[A-Z][A-Za-z0-9]*$/;
413
+ function Ss(e) {
414
414
  const t = e.resolve;
415
415
  if (!t || typeof t != "object") return [];
416
416
  const s = t.alias;
@@ -422,7 +422,7 @@ function xs(e) {
422
422
  ([n, o]) => typeof o == "string" ? [{ find: n, replacement: o }] : []
423
423
  );
424
424
  }
425
- function Ss(e) {
425
+ function js(e) {
426
426
  const t = [], s = [
427
427
  /(?:^|\n)[ \t]*import[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
428
428
  /(?:^|\n)[ \t]*export[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
@@ -435,21 +435,21 @@ function Ss(e) {
435
435
  }
436
436
  return t;
437
437
  }
438
- function Ze(e) {
439
- return vs.some((t) => {
438
+ function Ve(e) {
439
+ return ks.some((t) => {
440
440
  const s = e + t;
441
441
  if (!b(s)) return !1;
442
442
  try {
443
- return it(s).isFile();
443
+ return at(s).isFile();
444
444
  } catch {
445
445
  return !1;
446
446
  }
447
447
  });
448
448
  }
449
- function js(e, t) {
450
- const s = x(e, t.contentDir), n = xs(t.vite), o = [];
449
+ function Cs(e, t) {
450
+ const s = x(e, t.contentDir), n = Ss(t.vite), o = [];
451
451
  for (const r of Y(s)) {
452
- if (!bs.some((u) => r.endsWith(u))) continue;
452
+ if (!vs.some((p) => r.endsWith(p))) continue;
453
453
  let i;
454
454
  try {
455
455
  i = C(r, "utf-8");
@@ -457,115 +457,115 @@ function js(e, t) {
457
457
  continue;
458
458
  }
459
459
  const c = F(s, r).split(L).join("/");
460
- for (const u of Ss(i)) {
461
- if (u.includes("_shared/") || u.startsWith("_shared")) {
460
+ for (const p of js(i)) {
461
+ if (p.includes("_shared/") || p.startsWith("_shared")) {
462
462
  o.push(
463
- `${c}: imports ${u}, shared fixture folders are forbidden, stories are self contained and shared setup lives in a group harness component`
463
+ `${c}: imports ${p}, shared fixture folders are forbidden, stories are self contained and shared setup lives in a group harness component`
464
464
  );
465
465
  continue;
466
466
  }
467
- const a = u.split("?")[0];
467
+ const a = p.split("?")[0];
468
468
  if (a.startsWith("./") || a.startsWith("../")) {
469
- const l = x(N(r), a);
470
- Ze(l) || o.push(`${c}: unresolved import ${u}, fix the path or create the file`);
469
+ const u = x(N(r), a);
470
+ Ve(u) || o.push(`${c}: unresolved import ${p}, fix the path or create the file`);
471
471
  continue;
472
472
  }
473
- const p = n.find((l) => a === l.find || a.startsWith(l.find + "/"));
474
- if (p) {
475
- const l = x(e, p.replacement + a.slice(p.find.length));
476
- Ze(l) || o.push(`${c}: unresolved import ${u} via alias ${p.find}`);
473
+ const l = n.find((u) => a === u.find || a.startsWith(u.find + "/"));
474
+ if (l) {
475
+ const u = x(e, l.replacement + a.slice(l.find.length));
476
+ Ve(u) || o.push(`${c}: unresolved import ${p} via alias ${l.find}`);
477
477
  }
478
478
  }
479
479
  }
480
480
  return o;
481
481
  }
482
- function Cs(e, t) {
482
+ function Es(e, t) {
483
483
  const s = x(e, t.contentDir), n = [];
484
484
  if (!b(s)) return [`${t.contentDir}: contentDir does not exist`];
485
485
  const o = /* @__PURE__ */ new Map();
486
486
  let r, i;
487
487
  const c = /* @__PURE__ */ new Map();
488
488
  for (const a of Y(s)) {
489
- const p = F(s, a).split(L).join("/"), l = N(a), m = D(a);
489
+ const l = F(s, a).split(L).join("/"), u = N(a), m = D(a);
490
490
  if (m.endsWith(".md")) {
491
- const f = c.get(l) ?? [];
492
- f.push(a), c.set(l, f);
491
+ const f = c.get(u) ?? [];
492
+ f.push(a), c.set(u, f);
493
493
  const h = m.slice(0, -3);
494
- Ue.test(h) || n.push(`${p}: markdown file names are lowercase kebab case, rename to ${h.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9.-]+/g, "-")}.md`);
494
+ Ze.test(h) || n.push(`${l}: markdown file names are lowercase kebab case, rename to ${h.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9.-]+/g, "-")}.md`);
495
495
  let g;
496
496
  try {
497
- g = le(C(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
497
+ g = ue(C(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
498
498
  } catch {
499
499
  continue;
500
500
  }
501
- if (g?.type === "glossary" && (i ? n.push(`${p}: second type glossary page in the site, ${F(s, i).split(L).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(le(C(a, "utf-8")).content) || n.push(`${p}: type glossary needs a definition list body, term lines followed by lines starting with a colon`)), g?.type === "section" && !a.endsWith(`${L}index.md`) && n.push(`${p}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? n.push(`${p}: second type 404 page in the site, ${F(s, r).split(L).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
502
- const w = o.get(l);
503
- w ? n.push(`${p}: second type component page in one folder, ${F(s, w).split(L).join("/")} already owns it, one component per folder`) : o.set(l, a);
501
+ if (g?.type === "glossary" && (i ? n.push(`${l}: second type glossary page in the site, ${F(s, i).split(L).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(ue(C(a, "utf-8")).content) || n.push(`${l}: type glossary needs a definition list body, term lines followed by lines starting with a colon`)), g?.type === "section" && !a.endsWith(`${L}index.md`) && n.push(`${l}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? n.push(`${l}: second type 404 page in the site, ${F(s, r).split(L).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
502
+ const w = o.get(u);
503
+ w ? n.push(`${l}: second type component page in one folder, ${F(s, w).split(L).join("/")} already owns it, one component per folder`) : o.set(u, a);
504
504
  }
505
505
  if (g?.type === "dbml") {
506
506
  const w = typeof g.spec == "string" ? g.spec : "";
507
- w ? b(x(l, w)) || n.push(`${p}: spec ${w} does not resolve, create the file or fix the path`) : n.push(`${p}: type dbml needs a spec field pointing at the .dbml file`);
507
+ w ? b(x(u, w)) || n.push(`${l}: spec ${w} does not resolve, create the file or fix the path`) : n.push(`${l}: type dbml needs a spec field pointing at the .dbml file`);
508
508
  }
509
- g?.type === "changelog" && typeof g.path == "string" && n.push(`${p}: changelog entries never set path, the collection mounts at the folder route, remove the path field`);
509
+ g?.type === "changelog" && typeof g.path == "string" && n.push(`${l}: changelog entries never set path, the collection mounts at the folder route, remove the path field`);
510
510
  }
511
511
  if (m.endsWith(".css") && !m.startsWith("_") && D(N(a)) === "styles" && N(N(a)) === s) {
512
512
  const f = m.replace(/\.css$/, "");
513
- ge.includes(f) || n.push(`${p}: ${f} is not a component class root, name the file after one of ${ge.join(", ")}`);
513
+ ge.includes(f) || n.push(`${l}: ${f} is not a component class root, name the file after one of ${ge.join(", ")}`);
514
514
  continue;
515
515
  }
516
516
  if (m.endsWith(".css") && !m.startsWith("_") && m.split(".").length > 2) {
517
- const f = m.split(".")[0], h = Qt(m, f);
517
+ const f = m.split(".")[0], h = Xt(m, f);
518
518
  if (h && b(d(N(a), `${f}.md`))) {
519
- ge.includes(h) || n.push(`${p}: ${h} is not a component class root, name the file after one of ${ge.join(", ")}`);
519
+ ge.includes(h) || n.push(`${l}: ${h} is not a component class root, name the file after one of ${ge.join(", ")}`);
520
520
  continue;
521
521
  }
522
522
  }
523
523
  if (m.endsWith(".css") && !m.startsWith("_")) {
524
524
  const f = a.replace(/\.css$/, ".md");
525
- b(f) || n.push(`${p}: page css without a matching ${D(f)}, page styles are named after the page they scope`);
525
+ b(f) || n.push(`${l}: page css without a matching ${D(f)}, page styles are named after the page they scope`);
526
526
  }
527
527
  }
528
- for (const [a, p] of c) {
529
- const l = F(s, a).split(L).join("/") || ".", m = o.has(a);
528
+ for (const [a, l] of c) {
529
+ const u = F(s, a).split(L).join("/") || ".", m = o.has(a);
530
530
  let f = [];
531
531
  try {
532
- f = re(a);
532
+ f = ie(a);
533
533
  } catch {
534
534
  continue;
535
535
  }
536
- f.filter((g) => /\.story\.tsx?$/.test(g)).length && !m && n.push(`${l}: story files without a type component page, add the component index.md or move the stories`);
536
+ f.filter((g) => /\.story\.tsx?$/.test(g)).length && !m && n.push(`${u}: story files without a type component page, add the component index.md or move the stories`);
537
537
  for (const g of ["schema.json", "schema.yml"])
538
- f.includes(g) && !m && n.push(`${l}: ${g} without a type component page, it belongs beside the component index.md`);
539
- if (m && p.length > 1) {
540
- const g = p.filter((w) => w !== o.get(a)).map((w) => D(w));
541
- n.push(`${l}: a component folder holds exactly one md file, move ${g.join(", ")} out`);
538
+ f.includes(g) && !m && n.push(`${u}: ${g} without a type component page, it belongs beside the component index.md`);
539
+ if (m && l.length > 1) {
540
+ const g = l.filter((w) => w !== o.get(a)).map((w) => D(w));
541
+ n.push(`${u}: a component folder holds exactly one md file, move ${g.join(", ")} out`);
542
542
  }
543
543
  }
544
- const u = (a) => {
545
- let p;
544
+ const p = (a) => {
545
+ let l;
546
546
  try {
547
- p = re(a, { withFileTypes: !0 });
547
+ l = ie(a, { withFileTypes: !0 });
548
548
  } catch {
549
549
  return;
550
550
  }
551
- for (const l of p)
552
- if (l.isDirectory() && !(l.name.startsWith(".") || l.name === "node_modules")) {
553
- if (!Ue.test(l.name) && !ks.test(l.name)) {
554
- const m = F(s, d(a, l.name)).split(L).join("/");
551
+ for (const u of l)
552
+ if (u.isDirectory() && !(u.name.startsWith(".") || u.name === "node_modules")) {
553
+ if (!Ze.test(u.name) && !xs.test(u.name)) {
554
+ const m = F(s, d(a, u.name)).split(L).join("/");
555
555
  n.push(`${m}/: folder names are lowercase kebab case, or PascalCase for component and group folders, rename it`);
556
556
  }
557
- u(d(a, l.name));
557
+ p(d(a, u.name));
558
558
  }
559
559
  };
560
- return u(s), n;
560
+ return p(s), n;
561
561
  }
562
- async function Es(e, t) {
563
- const s = ot(e, t, "lint"), n = () => q(s, { recursive: !0, force: !0 }), o = () => {
562
+ async function Os(e, t) {
563
+ const s = rt(e, t, "lint"), n = () => ee(s, { recursive: !0, force: !0 }), o = () => {
564
564
  n(), process.exit(130);
565
565
  };
566
566
  process.once("SIGINT", o), process.once("SIGTERM", o);
567
567
  try {
568
- return await wt(e, { ...t, paths: { ...t.paths, out: s } }), [];
568
+ return await $t(e, { ...t, paths: { ...t.paths, out: s } }), [];
569
569
  } catch (r) {
570
570
  return (r instanceof Error ? r.message : String(r)).split(`
571
571
  `).filter((c) => c.trim()).map((c) => `build: ${c.trim()}`);
@@ -573,23 +573,23 @@ async function Es(e, t) {
573
573
  process.off("SIGINT", o), process.off("SIGTERM", o), n();
574
574
  }
575
575
  }
576
- async function Os(e, t) {
576
+ async function Fs(e, t) {
577
577
  const s = process.argv.slice(2), n = [
578
+ ...Es(e, t),
579
+ ...(Yt(e, t.pageTypes ?? {}), await Qt(e, t.contentDir)),
578
580
  ...Cs(e, t),
579
- ...(Kt(e, t.pageTypes ?? {}), await Yt(e, t.contentDir)),
580
- ...js(e, t),
581
- ...await ft(e, t)
581
+ ...await dt(e, t)
582
582
  ];
583
583
  if (n.length) {
584
584
  Ne("nimpress lint", n, "");
585
585
  return;
586
586
  }
587
- if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), I(s, "no-build")) return;
587
+ if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), M(s, "no-build")) return;
588
588
  console.log("nimpress lint: building to verify the output compiles");
589
- const o = await Es(e, t);
589
+ const o = await Os(e, t);
590
590
  Ne("nimpress lint", o, "nimpress lint: build ok, everything passes");
591
591
  }
592
- const Fs = {
592
+ const Ds = {
593
593
  ".json": "application/json",
594
594
  ".xml": "application/rss+xml",
595
595
  ".html": "text/html",
@@ -602,53 +602,53 @@ const Fs = {
602
602
  ".webp": "image/webp",
603
603
  ".pdf": "application/pdf"
604
604
  };
605
- function Ds(e, t, s) {
605
+ function _s(e, t, s) {
606
606
  const n = s[0], o = d(e, _(s, "dist") ?? t.paths.out), r = `/${t.paths.guarded}/`, i = d(o, "access.json");
607
607
  if (!b(i))
608
608
  throw new Error(`[nimpress] guard: ${i} not found, run a build first`);
609
609
  const c = JSON.parse(C(i, "utf-8"));
610
610
  if (n === "map") {
611
- const u = Ge(o, t), a = d(o, "guard.map.json"), p = b(a) ? JSON.parse(C(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, l = b(u) ? Y(u) : [], m = p.prefix ?? r, f = l.map((w) => {
612
- const k = F(u, w).split("\\").join("/"), j = k.split("/")[0] ?? "", E = [
611
+ const p = Ge(o, t), a = d(o, "guard.map.json"), l = b(a) ? JSON.parse(C(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, u = b(p) ? Y(p) : [], m = l.prefix ?? r, f = u.map((w) => {
612
+ const k = F(p, w).split("\\").join("/"), j = k.split("/")[0] ?? "", E = [
613
613
  ...new Set(
614
- Object.values(p.routes ?? {}).filter((R) => R.bundle === j && R.gate).map((R) => R.gate)
614
+ Object.values(l.routes ?? {}).filter((R) => R.bundle === j && R.gate).map((R) => R.gate)
615
615
  )
616
616
  ], v = C(w);
617
617
  return {
618
618
  path: `${m}${k}`,
619
619
  file: k,
620
620
  bundle: j,
621
- sha256: ut("sha256").update(v).digest("hex"),
622
- size: it(w).size,
623
- mime: Fs[fe(w).toLowerCase()] ?? "application/octet-stream",
621
+ sha256: pt("sha256").update(v).digest("hex"),
622
+ size: at(w).size,
623
+ mime: Ds[fe(w).toLowerCase()] ?? "application/octet-stream",
624
624
  gates: E
625
625
  };
626
626
  }), h = _(s, "out"), g = h ? d(e, h) : a;
627
627
  W(
628
628
  g,
629
- JSON.stringify({ ...p, prefix: m, files: f }, null, 2) + `
629
+ JSON.stringify({ ...l, prefix: m, files: f }, null, 2) + `
630
630
  `
631
631
  ), console.log(`nimpress guard: mapped ${f.length} guarded files to ${g}`);
632
632
  return;
633
633
  }
634
634
  if (n === "apply") {
635
- const u = _(s, "map");
636
- if (!u) throw new Error("[nimpress] guard apply requires --map=<uploaded mapping json>");
637
- const a = JSON.parse(C(d(e, u), "utf-8"));
635
+ const p = _(s, "map");
636
+ if (!p) throw new Error("[nimpress] guard apply requires --map=<uploaded mapping json>");
637
+ const a = JSON.parse(C(d(e, p), "utf-8"));
638
638
  if (!a.base) throw new Error("[nimpress] guard apply: mapping json carries no base url");
639
- c.base = a.base.replace(/\/$/, ""), c.files = (a.files ?? []).map((p) => ({
640
- path: p.path,
641
- file: p.file,
642
- bundle: p.bundle,
643
- asset_id: p.asset_id,
644
- url: p.url
639
+ c.base = a.base.replace(/\/$/, ""), c.files = (a.files ?? []).map((l) => ({
640
+ path: l.path,
641
+ file: l.file,
642
+ bundle: l.bundle,
643
+ asset_id: l.asset_id,
644
+ url: l.url
645
645
  })), W(i, JSON.stringify(c, null, 2) + `
646
- `), q(Ge(o, t), { recursive: !0, force: !0 }), q(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
646
+ `), ee(Ge(o, t), { recursive: !0, force: !0 }), ee(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
647
647
  return;
648
648
  }
649
649
  throw new Error("[nimpress] guard expects map or apply");
650
650
  }
651
- function $t(e) {
651
+ function yt(e) {
652
652
  const t = fe(e);
653
653
  return t === ".vue" ? "vue" : t === ".svelte" ? "svelte" : null;
654
654
  }
@@ -659,25 +659,25 @@ async function Le(e, t, s, n, o) {
659
659
  const c = Me(e, t.modules, s, n, i.file);
660
660
  if (!c)
661
661
  return console.warn(`[nimpress] modules story: no source found for ${s}/${n}`), null;
662
- const u = o ?? $t(c.componentFile);
663
- if (!u)
662
+ const p = o ?? yt(c.componentFile);
663
+ if (!p)
664
664
  throw new Error(
665
665
  `[nimpress] modules story: failed to detect framework for ${c.componentFile}, pass --framework=vue or --framework=svelte`
666
666
  );
667
- const a = u === "vue" ? "vueStory" : "svelteStory", p = `import { ${a} } from '@nimtech/nimpress/story'
667
+ const a = p === "vue" ? "vueStory" : "svelteStory", l = `import { ${a} } from '@nimtech/nimpress/story'
668
668
 
669
669
  // story: Default
670
670
  export default ${a}({
671
671
  name: "Default"
672
672
  })
673
- `, l = d(N(i.pageFile), "default.story.tsx");
674
- return b(l) ? (console.warn(`[nimpress] modules story: ${l} exists, not overwriting`), null) : (await X(l, p), l);
673
+ `, u = d(N(i.pageFile), "default.story.tsx");
674
+ return b(u) ? (console.warn(`[nimpress] modules story: ${u} exists, not overwriting`), null) : (await q(u, l), u);
675
675
  }
676
- async function _s(e, t, s) {
676
+ async function Ns(e, t, s) {
677
677
  const n = await Ae(e, t.contentDir);
678
678
  let o = 0;
679
679
  for (const r of n)
680
- if (!(r.system !== s || (await tt(N(r.pageFile))).length))
680
+ if (!(r.system !== s || (await st(N(r.pageFile))).length))
681
681
  try {
682
682
  await Le(e, t, s, r.component) && o++;
683
683
  } catch (c) {
@@ -685,16 +685,16 @@ async function _s(e, t, s) {
685
685
  }
686
686
  return o;
687
687
  }
688
- async function Ns(e, t, s, n, o) {
688
+ async function Ws(e, t, s, n, o) {
689
689
  const r = t.modules.systems[s];
690
690
  if (!r) throw new Error(`[nimpress] modules create: unknown system ${s}`);
691
691
  const i = d(e, t.contentDir, "components", "Components", n), c = d(i, "index.md");
692
692
  if (b(c))
693
693
  throw new Error(`[nimpress] modules create: ${c} exists`);
694
- const { mkdir: u } = await import("node:fs/promises");
695
- await u(i, { recursive: !0 });
694
+ const { mkdir: p } = await import("node:fs/promises");
695
+ await p(i, { recursive: !0 });
696
696
  const a = r.package;
697
- await X(
697
+ await q(
698
698
  c,
699
699
  `---
700
700
  title: ${n}
@@ -712,18 +712,18 @@ import { ${n} } from "${a ?? s}";
712
712
  \`\`\`
713
713
  `
714
714
  );
715
- const p = Me(e, t.modules, s, n);
716
- if (p) {
717
- const l = o ?? $t(p.componentFile) ?? r.framework;
718
- await me(i, n, await pe(p.componentFile, l, n)), await Le(e, t, s, n, o);
715
+ const l = Me(e, t.modules, s, n);
716
+ if (l) {
717
+ const u = o ?? yt(l.componentFile) ?? r.framework;
718
+ await me(i, n, await pe(l.componentFile, u, n)), await Le(e, t, s, n, o);
719
719
  } else {
720
- const l = r.framework === "vue" ? "vueStory" : "svelteStory";
721
- await X(
720
+ const u = r.framework === "vue" ? "vueStory" : "svelteStory";
721
+ await q(
722
722
  d(i, "default.story.tsx"),
723
- `import { ${l} } from '@nimtech/nimpress/story'
723
+ `import { ${u} } from '@nimtech/nimpress/story'
724
724
 
725
725
  // story: Default
726
- export default ${l}({
726
+ export default ${u}({
727
727
  name: "Default",
728
728
  props: {}
729
729
  })
@@ -744,7 +744,7 @@ function ye(e) {
744
744
  function be(e, t = []) {
745
745
  let s;
746
746
  try {
747
- s = re(e, { withFileTypes: !0 });
747
+ s = ie(e, { withFileTypes: !0 });
748
748
  } catch {
749
749
  return t;
750
750
  }
@@ -790,7 +790,7 @@ function Te(e) {
790
790
  const g = c(h);
791
791
  g?.kind === "data" && i.push(g.abs);
792
792
  }
793
- const u = n.filter((f) => !f.includes("@storybook")).map(
793
+ const p = n.filter((f) => !f.includes("@storybook")).map(
794
794
  (f) => f.replace(/from\s+["'](\.\.?\/[^"']+)["']/g, (h, g) => {
795
795
  const w = c(g);
796
796
  return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${D(g).replace(/\.ts$/, "")}"`;
@@ -799,7 +799,7 @@ function Te(e) {
799
799
  `);
800
800
  let a = t.slice(s.slice(0, o).join(`
801
801
  `).length);
802
- const p = (f) => {
802
+ const l = (f) => {
803
803
  const h = a.search(f);
804
804
  if (h < 0) return;
805
805
  const g = a.indexOf("{", h);
@@ -811,24 +811,24 @@ function Te(e) {
811
811
  const w = $e(a, g + 1), k = g + 1 + w.length + 1, j = a.slice(k).match(/^[^\n]*/)?.[0] ?? "";
812
812
  a = a.slice(0, h) + a.slice(k + j.length);
813
813
  };
814
- p(/^const meta\b[^\n]*/m), a = a.replace(/^export default meta;?\s*$/m, ""), a = a.replace(/^(?:export )?type \w+[^\n]*\n(?:[ \t]+[^\n]*\n?)*/gm, "");
815
- let l = 0;
816
- for (; /^(?:export )?interface \w+/m.test(a) && l < 50; )
817
- p(/^(?:export )?interface \w+[^\n]*/m), l++;
814
+ l(/^const meta\b[^\n]*/m), a = a.replace(/^export default meta;?\s*$/m, ""), a = a.replace(/^(?:export )?type \w+[^\n]*\n(?:[ \t]+[^\n]*\n?)*/gm, "");
815
+ let u = 0;
816
+ for (; /^(?:export )?interface \w+/m.test(a) && u < 50; )
817
+ l(/^(?:export )?interface \w+[^\n]*/m), u++;
818
818
  let m = 0;
819
819
  for (; /^export const \w+/m.test(a) && m < 200; )
820
- p(/^export const \w+[^\n]*/m), m++;
820
+ l(/^export const \w+[^\n]*/m), m++;
821
821
  return {
822
822
  file: e,
823
823
  text: t,
824
824
  title: t.match(/\btitle:\s*["']([^"']+)["']/)?.[1],
825
825
  metaComponent: t.match(/\bcomponent:\s*([A-Za-z_$][\w$]*)\s*[,\n}]/)?.[1],
826
- imports: u,
826
+ imports: p,
827
827
  declarations: a.trim(),
828
828
  dataModules: i
829
829
  };
830
830
  }
831
- function Ws(e, t) {
831
+ function Ts(e, t) {
832
832
  const s = e.indexOf(":", t) + 1;
833
833
  let n = 0, o = null;
834
834
  for (let r = s; r < e.length; r++) {
@@ -847,10 +847,10 @@ function Ws(e, t) {
847
847
  }
848
848
  return e.slice(s).trim();
849
849
  }
850
- function yt(e) {
850
+ function bt(e) {
851
851
  return e.replace(/\bsatisfies\s+[A-Za-z_$][\w$.]*(?:<[^>]*>)?/g, "").replace(/\bas\s+const\b/g, "").replace(/\)\s*:\s*[A-Za-z_$][\w$<>\[\], .|&]*\s*=>/g, ") =>").replace(/\(\s*([A-Za-z_$][\w$]*)\s*:\s*[A-Za-z_$][\w$<>\[\], .|&]*\)/g, "($1)");
852
852
  }
853
- function bt(e) {
853
+ function vt(e) {
854
854
  const t = [], s = /export const (\w+)\s*(?::[^=]*)?=\s*\{/g;
855
855
  let n;
856
856
  for (; n = s.exec(e.text); ) {
@@ -858,35 +858,35 @@ function bt(e) {
858
858
  if (o === "default" || o === "meta") continue;
859
859
  const r = $e(e.text, s.lastIndex), i = r.search(/\brender\s*:/);
860
860
  if (i >= 0) {
861
- const a = Ws(r, i);
861
+ const a = Ts(r, i);
862
862
  if (a) {
863
863
  t.push({ name: o, renderFn: a });
864
864
  continue;
865
865
  }
866
866
  }
867
867
  const c = r.search(/\bargs\s*:/);
868
- let u = {};
868
+ let p = {};
869
869
  if (c >= 0) {
870
870
  const a = r.indexOf("{", c);
871
871
  if (a >= 0) {
872
- const p = $e(r, a + 1);
872
+ const l = $e(r, a + 1);
873
873
  try {
874
- u = ye(new Function(`${yt(e.declarations)}
875
- return {${p}}`)());
874
+ p = ye(new Function(`${bt(e.declarations)}
875
+ return {${l}}`)());
876
876
  } catch {
877
877
  try {
878
- u = ye(new Function(`return {${p}}`)());
878
+ p = ye(new Function(`return {${l}}`)());
879
879
  } catch {
880
- u = {};
880
+ p = {};
881
881
  }
882
882
  }
883
883
  }
884
884
  }
885
- t.push({ name: o, props: u });
885
+ t.push({ name: o, props: p });
886
886
  }
887
887
  return t;
888
888
  }
889
- function vt(e) {
889
+ function kt(e) {
890
890
  const t = e.text.search(/\bargTypes\s*:\s*\{/);
891
891
  if (t < 0) return;
892
892
  const s = e.text.indexOf("{", t), n = $e(e.text, s + 1);
@@ -896,7 +896,7 @@ function vt(e) {
896
896
  } catch {
897
897
  try {
898
898
  o = ye(
899
- new Function(`${yt(e.declarations)}
899
+ new Function(`${bt(e.declarations)}
900
900
  return {${n}}`)()
901
901
  );
902
902
  } catch {
@@ -906,16 +906,16 @@ return {${n}}`)()
906
906
  const r = {};
907
907
  for (const [i, c] of Object.entries(o)) {
908
908
  if (!c || typeof c != "object") continue;
909
- const u = c.control, a = typeof u == "string" ? u : String(u?.type ?? ""), p = c.options ?? (typeof u == "object" ? u?.options : void 0), l = {};
910
- typeof c.description == "string" && (l.description = c.description), Array.isArray(p) ? l.enum = p : a === "boolean" ? l.type = "boolean" : a === "number" || a === "range" ? l.type = "number" : a === "text" || a === "color" || a === "date" ? l.type = "string" : a === "object" && (l.type = "object"), c.defaultValue !== void 0 && (l.default = c.defaultValue), Object.keys(l).length && (r[i] = l);
909
+ const p = c.control, a = typeof p == "string" ? p : String(p?.type ?? ""), l = c.options ?? (typeof p == "object" ? p?.options : void 0), u = {};
910
+ typeof c.description == "string" && (u.description = c.description), Array.isArray(l) ? u.enum = l : a === "boolean" ? u.type = "boolean" : a === "number" || a === "range" ? u.type = "number" : a === "text" || a === "color" || a === "date" ? u.type = "string" : a === "object" && (u.type = "object"), c.defaultValue !== void 0 && (u.default = c.defaultValue), Object.keys(u).length && (r[i] = u);
911
911
  }
912
912
  return Object.keys(r).length ? r : void 0;
913
913
  }
914
- async function kt(e) {
914
+ async function xt(e) {
915
915
  const t = [...e].sort();
916
916
  for (let i = 0; i < t.length; i++)
917
917
  console.log(`${String(i + 1).padStart(4)} ${t[i]}`);
918
- const s = pt({ input: process.stdin, output: process.stdout }), n = await s.question(
918
+ const s = mt({ input: process.stdin, output: process.stdout }), n = await s.question(
919
919
  "select components to import, comma separated numbers, names, or /regex/, empty imports all: "
920
920
  );
921
921
  s.close();
@@ -925,20 +925,20 @@ async function kt(e) {
925
925
  for (const i of o.split(",").map((c) => c.trim()).filter(Boolean)) {
926
926
  const c = i.match(/^\/(.+)\/$/);
927
927
  if (c) {
928
- const u = new RegExp(c[1]);
929
- for (const a of t) u.test(a) && r.add(a);
928
+ const p = new RegExp(c[1]);
929
+ for (const a of t) p.test(a) && r.add(a);
930
930
  continue;
931
931
  }
932
932
  if (/^\d+$/.test(i)) {
933
- const u = t[Number(i) - 1];
934
- u && r.add(u);
933
+ const p = t[Number(i) - 1];
934
+ p && r.add(p);
935
935
  continue;
936
936
  }
937
- for (const u of t) u === i && r.add(u);
937
+ for (const p of t) p === i && r.add(p);
938
938
  }
939
939
  return r;
940
940
  }
941
- function xt(e, t) {
941
+ function St(e, t) {
942
942
  const s = /* @__PURE__ */ new Map(), n = d(e, "node_modules", t, "index.mjs");
943
943
  if (!b(n)) return s;
944
944
  const o = C(n, "utf-8");
@@ -946,47 +946,47 @@ function xt(e, t) {
946
946
  s.set(r[1].toLowerCase(), r[1]);
947
947
  return s;
948
948
  }
949
- async function Ts(e, t, s, n) {
949
+ async function Ps(e, t, s, n) {
950
950
  const o = t.modules.systems[s];
951
951
  if (!o) throw new Error(`[nimpress] modules import: unknown system ${s}`);
952
- const r = o.framework, i = r === "vue" ? ".vue" : ".svelte", c = d(e, t.contentDir, "components"), u = o.package, a = n.match ? new RegExp(n.match) : null;
952
+ const r = o.framework, i = r === "vue" ? ".vue" : ".svelte", c = d(e, t.contentDir, "components"), p = o.package, a = n.match ? new RegExp(n.match) : null;
953
953
  if (n.file) {
954
954
  const $ = x(e, n.file);
955
955
  if (!b($)) throw new Error(`[nimpress] modules import: ${$} not found`);
956
956
  if (fe($) !== i)
957
957
  throw new Error(`[nimpress] modules import: ${$} does not match system framework ${r}`);
958
- const y = n.name ?? D($, i), M = o.source ? x(e, o.source) : e, P = d(c, "Components", y);
958
+ const y = n.name ?? D($, i), I = o.source ? x(e, o.source) : e, P = d(c, "Components", y);
959
959
  await _e(P, { recursive: !0 });
960
- const A = F(M, $);
961
- await X(d(P, "index.md"), Pe(s, y, u, A)), await me(P, y, await pe($, r, y)), console.log(`nimpress modules: imported ${y} at ${F(e, P)}`);
960
+ const A = F(I, $);
961
+ await q(d(P, "index.md"), Pe(s, y, p, A)), await me(P, y, await pe($, r, y)), console.log(`nimpress modules: imported ${y} at ${F(e, P)}`);
962
962
  return;
963
963
  }
964
964
  if (n.fromStories) {
965
- await Ps(e, t, s, n);
965
+ await Rs(e, t, s, n);
966
966
  return;
967
967
  }
968
- const p = x(e, n.source ?? o.source ?? "");
969
- if (!b(p))
970
- throw new Error(`[nimpress] modules import: source ${p} not found`);
971
- const l = be(p), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = l.filter(($) => $.endsWith(".stories.ts")), g = n.stories ? [x(e, n.stories)] : [];
968
+ const l = x(e, n.source ?? o.source ?? "");
969
+ if (!b(l))
970
+ throw new Error(`[nimpress] modules import: source ${l} not found`);
971
+ const u = be(l), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = u.filter(($) => $.endsWith(".stories.ts")), g = n.stories ? [x(e, n.stories)] : [];
972
972
  for (const $ of g)
973
973
  for (const y of be($))
974
974
  y.endsWith(".stories.ts") && h.push(y);
975
- const w = l.filter(
975
+ const w = u.filter(
976
976
  ($) => $.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(D($, i))
977
- ), k = new Set(w.map(($) => D($, i))), j = u && !o.source ? xt(e, u) : null;
977
+ ), k = new Set(w.map(($) => D($, i))), j = p && !o.source ? St(e, p) : null;
978
978
  for (const $ of h) {
979
979
  const y = Te($);
980
980
  if (y.title?.includes("/")) {
981
- const [G, z] = y.title.split("/");
982
- m.set(z, G.replace(/\s+/g, ""));
981
+ const [G, J] = y.title.split("/");
982
+ m.set(J, G.replace(/\s+/g, ""));
983
983
  }
984
- const M = D($, ".stories.ts");
985
- let A = b(d(N($), `${M}${i}`)) ? M : y.metaComponent ?? M;
984
+ const I = D($, ".stories.ts");
985
+ let A = b(d(N($), `${I}${i}`)) ? I : y.metaComponent ?? I;
986
986
  if (!k.has(A)) {
987
987
  let G = "";
988
- for (const z of k)
989
- M.startsWith(z) && z.length > G.length && (G = z);
988
+ for (const J of k)
989
+ I.startsWith(J) && J.length > G.length && (G = J);
990
990
  G ? A = G : console.warn(`nimpress modules: ${D($)} targets ${A} which has no component page`);
991
991
  }
992
992
  const S = j?.get(A.toLowerCase()) ?? A, Z = f.get(S) ?? [];
@@ -994,7 +994,7 @@ async function Ts(e, t, s, n) {
994
994
  }
995
995
  const E = /* @__PURE__ */ new Map();
996
996
  let v = 0, R = 0;
997
- const O = w.filter(($) => !a || a.test(D($, i))), T = n.select ? await kt(O.map(($) => D($, i))) : null;
997
+ const O = w.filter(($) => !a || a.test(D($, i))), T = n.select ? await xt(O.map(($) => D($, i))) : null;
998
998
  for (const $ of O) {
999
999
  const y = D($, i);
1000
1000
  if (T && !T.has(y)) continue;
@@ -1002,38 +1002,38 @@ async function Ts(e, t, s, n) {
1002
1002
  console.warn(`nimpress modules: skip duplicate ${y}, kept ${E.get(y)}`);
1003
1003
  continue;
1004
1004
  }
1005
- E.set(y, F(p, $));
1006
- const M = m.get(y) ?? "Components", P = d(c, M, y);
1005
+ E.set(y, F(l, $));
1006
+ const I = m.get(y) ?? "Components", P = d(c, I, y);
1007
1007
  await _e(P, { recursive: !0 });
1008
- const A = F(p, $), S = A === `${y}/${y}${i}` || A === `${y}${i}`, Z = (f.get(y) ?? []).map((H) => vt(H)).reduce(
1009
- (H, te) => te ? { ...H ?? {}, ...te } : H,
1008
+ const A = F(l, $), S = A === `${y}/${y}${i}` || A === `${y}${i}`, Z = (f.get(y) ?? []).map((H) => kt(H)).reduce(
1009
+ (H, se) => se ? { ...H ?? {}, ...se } : H,
1010
1010
  void 0
1011
1011
  );
1012
- await X(d(P, "index.md"), Pe(s, y, u, S ? void 0 : A)), await me(P, y, await pe($, r, y)), Z && await rt(P, { properties: Z }), v++;
1013
- const G = f.get(y) ?? [], z = /* @__PURE__ */ new Set();
1012
+ await q(d(P, "index.md"), Pe(s, y, p, S ? void 0 : A)), await me(P, y, await pe($, r, y)), Z && await it(P, { properties: Z }), v++;
1013
+ const G = f.get(y) ?? [], J = /* @__PURE__ */ new Set();
1014
1014
  for (const H of G) {
1015
- const te = D(H.file, ".stories.ts"), ze = bt(H);
1016
- ze.length || console.warn(`nimpress modules: no stories mined from ${D(H.file)}`);
1015
+ const se = D(H.file, ".stories.ts"), Je = vt(H);
1016
+ Je.length || console.warn(`nimpress modules: no stories mined from ${D(H.file)}`);
1017
1017
  for (const Q of H.dataModules)
1018
- await at(Q, d(P, D(Q)));
1019
- for (const Q of ze) {
1020
- const Je = Q.name === y ? "Default" : te === y ? Q.name : `${te} ${Q.name}`;
1021
- let he = We(Je);
1022
- z.has(he) && (he = We(`${te}-${Q.name}`));
1018
+ await ct(Q, d(P, D(Q)));
1019
+ for (const Q of Je) {
1020
+ const ze = Q.name === y ? "Default" : se === y ? Q.name : `${se} ${Q.name}`;
1021
+ let he = We(ze);
1022
+ J.has(he) && (he = We(`${se}-${Q.name}`));
1023
1023
  const Be = d(P, `${he}.story.tsx`);
1024
- z.add(he), !b(Be) && (await X(Be, St(r, Je, te, Q, H)), R++);
1024
+ J.add(he), !b(Be) && (await q(Be, jt(r, ze, se, Q, H)), R++);
1025
1025
  }
1026
1026
  }
1027
1027
  }
1028
1028
  console.log(`nimpress modules: imported ${v} components with ${R} stories for ${s}`);
1029
1029
  }
1030
- async function Ps(e, t, s, n) {
1030
+ async function Rs(e, t, s, n) {
1031
1031
  const o = t.modules.systems[s], r = o.framework, i = d(e, t.contentDir, "components"), c = x(e, n.stories ?? "");
1032
1032
  if (!n.stories || !b(c))
1033
1033
  throw new Error("[nimpress] modules import --from-stories requires --stories=<csf dir>");
1034
- const u = o.source ? x(e, o.source) : e, a = n.match ? new RegExp(n.match) : null, p = /* @__PURE__ */ new Set();
1035
- let l = 0, m = 0;
1036
- const f = be(c).filter((g) => g.endsWith(".stories.ts")), h = n.select ? await kt(
1034
+ const p = o.source ? x(e, o.source) : e, a = n.match ? new RegExp(n.match) : null, l = /* @__PURE__ */ new Set();
1035
+ let u = 0, m = 0;
1036
+ const f = be(c).filter((g) => g.endsWith(".stories.ts")), h = n.select ? await xt(
1037
1037
  f.map((g) => Te(g).metaComponent ?? D(g, ".stories.ts"))
1038
1038
  ) : null;
1039
1039
  for (const g of f) {
@@ -1045,42 +1045,42 @@ async function Ps(e, t, s, n) {
1045
1045
  let v = j, R = o.package, O;
1046
1046
  if (E && !E.startsWith(".") && !E.startsWith("@/")) {
1047
1047
  const S = E.split("/")[0].startsWith("@") ? E.split("/").slice(0, 2).join("/") : E.split("/")[0];
1048
- R = S, v = xt(e, S).get(j.toLowerCase()) ?? j;
1048
+ R = S, v = St(e, S).get(j.toLowerCase()) ?? j;
1049
1049
  } else if (E?.startsWith("@/components/")) {
1050
1050
  const S = E.slice(13);
1051
1051
  S === v || S === `${v}/${v}.vue` || (O = S.endsWith(".vue") || S.endsWith(".svelte") ? S : `${S}/${v}.vue`);
1052
1052
  } else if (E?.startsWith(".")) {
1053
1053
  const S = x(N(g), E);
1054
- O = F(u, S);
1054
+ O = F(p, S);
1055
1055
  }
1056
1056
  if (a && !a.test(v)) continue;
1057
- if (p.has(v)) {
1057
+ if (l.has(v)) {
1058
1058
  console.warn(`nimpress modules: skip duplicate ${v} from ${D(g)}`);
1059
1059
  continue;
1060
1060
  }
1061
- p.add(v);
1061
+ l.add(v);
1062
1062
  const T = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", $ = d(i, T, v);
1063
- await _e($, { recursive: !0 }), await X(d($, "index.md"), Pe(s, v, R, O));
1064
- const y = r === "vue" ? ".vue" : ".svelte", P = (O ? [x(u, O)] : [
1065
- d(u, v, `${v}${y}`),
1066
- d(u, `${v}${y}`)
1063
+ await _e($, { recursive: !0 }), await q(d($, "index.md"), Pe(s, v, R, O));
1064
+ const y = r === "vue" ? ".vue" : ".svelte", P = (O ? [x(p, O)] : [
1065
+ d(p, v, `${v}${y}`),
1066
+ d(p, `${v}${y}`)
1067
1067
  ]).find((S) => b(S));
1068
1068
  if (P)
1069
1069
  await me($, v, await pe(P, r, v));
1070
1070
  else if (R) {
1071
- const S = Xt(e, R, v);
1072
- S ? await me($, v, qt(C(S, "utf-8"), v)) : console.warn(`nimpress modules: no source or d.ts found for ${v}, the schema seed is skipped`);
1071
+ const S = qt(e, R, v);
1072
+ S ? await me($, v, es(C(S, "utf-8"), v)) : console.warn(`nimpress modules: no source or d.ts found for ${v}, the schema seed is skipped`);
1073
1073
  }
1074
- const A = vt(w);
1075
- A && await rt($, { properties: A }), l++;
1074
+ const A = kt(w);
1075
+ A && await it($, { properties: A }), u++;
1076
1076
  for (const S of w.dataModules)
1077
- await at(S, d($, D(S)));
1078
- for (const S of bt(w)) {
1079
- const Z = S.name === v ? "Default" : S.name, G = We(Z), z = d($, `${G}.story.tsx`);
1080
- b(z) || (await X(z, St(r, Z, k, S, w)), m++);
1077
+ await ct(S, d($, D(S)));
1078
+ for (const S of vt(w)) {
1079
+ const Z = S.name === v ? "Default" : S.name, G = We(Z), J = d($, `${G}.story.tsx`);
1080
+ b(J) || (await q(J, jt(r, Z, k, S, w)), m++);
1081
1081
  }
1082
1082
  }
1083
- console.log(`nimpress modules: imported ${l} components with ${m} stories for ${s} from stories`);
1083
+ console.log(`nimpress modules: imported ${u} components with ${m} stories for ${s} from stories`);
1084
1084
  }
1085
1085
  function Pe(e, t, s, n) {
1086
1086
  const o = s ? `
@@ -1101,7 +1101,7 @@ import { ${t} } from "${s ?? e}";
1101
1101
  \`\`\`
1102
1102
  `;
1103
1103
  }
1104
- function St(e, t, s, n, o) {
1104
+ function jt(e, t, s, n, o) {
1105
1105
  const r = e === "vue" ? "vueStory" : "svelteStory";
1106
1106
  return n.renderFn ? `import { ${r} } from '@nimtech/nimpress/story'
1107
1107
  ${o.imports}
@@ -1123,7 +1123,7 @@ export default ${r}({
1123
1123
  })
1124
1124
  `;
1125
1125
  }
1126
- function ue(e, t) {
1126
+ function ae(e, t) {
1127
1127
  const s = _(t, "system");
1128
1128
  if (s === void 0) return;
1129
1129
  const n = Object.keys(e.modules.systems);
@@ -1132,7 +1132,7 @@ function ue(e, t) {
1132
1132
  return s;
1133
1133
  }
1134
1134
  function je(e, t, s) {
1135
- const n = ue(e, t);
1135
+ const n = ae(e, t);
1136
1136
  if (n) return n;
1137
1137
  const o = Object.keys(e.modules.systems);
1138
1138
  if (o.length === 1) return o[0];
@@ -1140,43 +1140,64 @@ function je(e, t, s) {
1140
1140
  `[nimpress] modules ${s}: several systems configured (${o.join(", ")}), pass --system=<name>`
1141
1141
  ) : new Error(`[nimpress] modules ${s}: no systems configured`);
1142
1142
  }
1143
- async function Rs(e, t, s) {
1143
+ async function As(e, t, s) {
1144
1144
  const n = s[0], o = s.slice(1), r = Object.keys(t.modules.systems);
1145
1145
  if (n === "init") {
1146
- As(e, t);
1146
+ Ms(e, t);
1147
1147
  return;
1148
1148
  }
1149
1149
  if (n === "dev") {
1150
- const i = ue(t, o), c = i ? [i] : r;
1150
+ const i = ae(t, o), c = i ? [i] : r;
1151
1151
  if (!c.length) throw new Error("[nimpress] modules dev: no systems configured");
1152
- await ht(e, t, c), await new Promise(() => {
1152
+ await gt(e, t, c), await new Promise(() => {
1153
1153
  });
1154
1154
  }
1155
1155
  if (n === "build") {
1156
- const i = ue(t, o), c = i ? [i] : dt(t);
1156
+ const i = ae(t, o), c = i ? [i] : ht(t);
1157
1157
  if (!c.length) throw new Error("[nimpress] modules build: no systems configured");
1158
- await gt(e, t, c);
1158
+ await wt(e, t, c);
1159
1159
  return;
1160
1160
  }
1161
1161
  if (n === "lint") {
1162
- const i = await ft(e, t, ue(t, o));
1162
+ const i = await dt(e, t, ae(t, o));
1163
1163
  Ne("nimpress modules lint", i, "nimpress modules lint: systems, schemas, and stories ok");
1164
1164
  return;
1165
1165
  }
1166
1166
  if (n === "story") {
1167
- const i = je(t, o, "story"), c = ie(o, 0), u = _(o, "framework");
1167
+ const i = je(t, o, "story"), c = ne(o, 0), p = _(o, "framework");
1168
1168
  if (c) {
1169
- const p = await Le(e, t, i, c, u);
1170
- p && console.log(`nimpress modules: story written to ${p}`);
1169
+ const l = await Le(e, t, i, c, p);
1170
+ l && console.log(`nimpress modules: story written to ${l}`);
1171
1171
  return;
1172
1172
  }
1173
- const a = await _s(e, t, i);
1173
+ const a = await Ns(e, t, i);
1174
1174
  console.log(`nimpress modules: ${a} auto stories written for ${i}`);
1175
1175
  return;
1176
1176
  }
1177
+ if (n === "stories") {
1178
+ const i = ne(o, 0), c = ae(t, o), p = await He(e, t, { component: i, system: c });
1179
+ if (i && !p.length) {
1180
+ const a = (await He(e, t, { system: c })).map((l) => `${l.system}/${l.component}`).filter((l, u, m) => m.indexOf(l) === u && l.toLowerCase().includes(i.toLowerCase()));
1181
+ throw new Error(
1182
+ `[nimpress] modules stories: no stories for ${i}${c ? ` in ${c}` : ""}` + (a.length ? `, did you mean ${a.slice(0, 8).join(", ")}` : "")
1183
+ );
1184
+ }
1185
+ if (M(o, "json")) {
1186
+ console.log(JSON.stringify(p, null, 2));
1187
+ return;
1188
+ }
1189
+ if (!i) {
1190
+ const a = /* @__PURE__ */ new Map();
1191
+ for (const l of p) a.set(`${l.system} ${l.component}`, (a.get(`${l.system} ${l.component}`) ?? 0) + 1);
1192
+ for (const [l, u] of a) console.log(`${l} ${u}`);
1193
+ return;
1194
+ }
1195
+ for (const a of p) console.log(`${a.system} ${a.component} ${a.story} ${a.route}`);
1196
+ return;
1197
+ }
1177
1198
  if (n === "import") {
1178
- const i = je(t, o, "import"), c = ie(o, 0);
1179
- await Ts(e, t, i, {
1199
+ const i = je(t, o, "import"), c = ne(o, 0);
1200
+ await Ps(e, t, i, {
1180
1201
  file: c,
1181
1202
  name: _(o, "name"),
1182
1203
  source: _(o, "source"),
@@ -1188,29 +1209,29 @@ async function Rs(e, t, s) {
1188
1209
  return;
1189
1210
  }
1190
1211
  if (n === "update") {
1191
- const i = _(o, "component") ?? ie(o, 0), c = await es(e, t, { ref: i, system: ue(t, o) });
1212
+ const i = _(o, "component") ?? ne(o, 0), c = await ts(e, t, { ref: i, system: ae(t, o) });
1192
1213
  console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`), De(e);
1193
1214
  return;
1194
1215
  }
1195
1216
  if (n === "create") {
1196
1217
  const i = _(o, "component");
1197
1218
  if (i) {
1198
- if (!I(o, "schema"))
1219
+ if (!M(o, "schema"))
1199
1220
  throw new Error("[nimpress] modules create --component expects --schema to upsert the schema");
1200
- const l = await ts(e, t, i);
1201
- console.log(`nimpress modules: schema upserted at ${l}`);
1221
+ const u = await ss(e, t, i);
1222
+ console.log(`nimpress modules: schema upserted at ${u}`);
1202
1223
  return;
1203
1224
  }
1204
- const c = ie(o, 0);
1225
+ const c = ne(o, 0);
1205
1226
  if (!c)
1206
1227
  throw new Error("[nimpress] modules create expects: nimpress modules create <Component> [--system=<name>], or --component=<ref> --schema");
1207
- const u = je(t, o, "create"), a = _(o, "framework"), p = await Ns(e, t, u, c, a);
1208
- console.log(`nimpress modules: created ${c} at ${F(e, p)}`);
1228
+ const p = je(t, o, "create"), a = _(o, "framework"), l = await Ws(e, t, p, c, a);
1229
+ console.log(`nimpress modules: created ${c} at ${F(e, l)}`);
1209
1230
  return;
1210
1231
  }
1211
- throw new Error("[nimpress] modules expects init, dev, build, lint, story, import, create or update");
1232
+ throw new Error("[nimpress] modules expects init, dev, build, lint, story, stories, import, create or update");
1212
1233
  }
1213
- function As(e, t) {
1234
+ function Ms(e, t) {
1214
1235
  const s = d(e, t.modules.dir);
1215
1236
  B(s, { recursive: !0 });
1216
1237
  const n = d(e, "nimpress.config.json");
@@ -1222,14 +1243,14 @@ function As(e, t) {
1222
1243
  console.log("nimpress modules: add a modules block with systems entries to your nimpress config");
1223
1244
  console.log(`nimpress modules: folder ready at ${s}`);
1224
1245
  }
1225
- function jt(e) {
1246
+ function Ct(e) {
1226
1247
  if (!e.startsWith(`---
1227
1248
  `)) return null;
1228
1249
  const t = e.indexOf(`
1229
1250
  ---`, 4);
1230
1251
  return t < 0 ? null : e.slice(4, t);
1231
1252
  }
1232
- function Ms(e) {
1253
+ function Is(e) {
1233
1254
  for (const t of e.split(`
1234
1255
  `)) {
1235
1256
  if (!t.startsWith("export:")) continue;
@@ -1238,8 +1259,8 @@ function Ms(e) {
1238
1259
  }
1239
1260
  return null;
1240
1261
  }
1241
- function Is(e, t) {
1242
- const s = jt(e);
1262
+ function Ls(e, t) {
1263
+ const s = Ct(e);
1243
1264
  if (s === null) return e;
1244
1265
  const n = s.split(`
1245
1266
  `).filter((r) => !r.startsWith("export:") && !r.startsWith(" file:")), o = n.findIndex((r) => r.startsWith(" package:"));
@@ -1256,20 +1277,20 @@ function Re(e, t, s) {
1256
1277
  i = "";
1257
1278
  }
1258
1279
  let c = 0;
1259
- for (const u of Y(r)) {
1260
- if (!u.endsWith(".md")) continue;
1261
- const a = C(u, "utf-8"), p = jt(a);
1262
- if (p === null) continue;
1263
- const l = Ms(p);
1264
- if (l === null || n && l !== n && l !== "true") continue;
1265
- const m = N(u), f = d(o, F(r, m));
1280
+ for (const p of Y(r)) {
1281
+ if (!p.endsWith(".md")) continue;
1282
+ const a = C(p, "utf-8"), l = Ct(a);
1283
+ if (l === null) continue;
1284
+ const u = Is(l);
1285
+ if (u === null || n && u !== n && u !== "true") continue;
1286
+ const m = N(p), f = d(o, F(r, m));
1266
1287
  B(f, { recursive: !0 });
1267
- for (const h of re(m, { withFileTypes: !0 })) {
1288
+ for (const h of ie(m, { withFileTypes: !0 })) {
1268
1289
  if (!h.isFile()) continue;
1269
1290
  const g = C(d(m, h.name), "utf-8");
1270
1291
  W(
1271
1292
  d(f, h.name),
1272
- h.name.endsWith(".md") ? Is(g, i) : g
1293
+ h.name.endsWith(".md") ? Ls(g, i) : g
1273
1294
  );
1274
1295
  }
1275
1296
  c++;
@@ -1277,8 +1298,8 @@ function Re(e, t, s) {
1277
1298
  console.log(`nimpress export: ${c} pages collected into ${o}`);
1278
1299
  }
1279
1300
  const Ce = d(".claude", "skills", "nimpress", "SKILL.md");
1280
- function Ct() {
1281
- const e = N(mt(import.meta.url)), t = [
1301
+ function Et() {
1302
+ const e = N(ft(import.meta.url)), t = [
1282
1303
  x(e, Ce),
1283
1304
  x(e, "..", Ce),
1284
1305
  x(e, "..", "..", Ce)
@@ -1290,47 +1311,47 @@ function Ct() {
1290
1311
  }
1291
1312
  throw new Error(`[nimpress] skill: SKILL.md not found, looked in ${t.join(", ")}`);
1292
1313
  }
1293
- function Et(e, t) {
1314
+ function Ot(e, t) {
1294
1315
  const s = t ? d(K(), ".claude") : d(e, ".claude"), n = d(s, "skills", "nimpress");
1295
1316
  B(n, { recursive: !0 });
1296
1317
  const o = d(n, "SKILL.md");
1297
- return W(o, Ct()), console.log(`wrote ${o}`), o;
1318
+ return W(o, Et()), console.log(`wrote ${o}`), o;
1298
1319
  }
1299
- function Ls(e, t) {
1320
+ function Js(e, t) {
1300
1321
  const s = t[0];
1301
1322
  if (s === "get") {
1302
- process.stdout.write(Ct());
1323
+ process.stdout.write(Et());
1303
1324
  return;
1304
1325
  }
1305
1326
  if (s === "put") {
1306
- Et(e, !I(t, "project"));
1327
+ Ot(e, !M(t, "project"));
1307
1328
  return;
1308
1329
  }
1309
1330
  throw new Error("[nimpress] skill expects get or put");
1310
1331
  }
1311
- const zs = "nimling/nimpress", Js = "nimpress@nimpress";
1312
- function Ve(e, t) {
1332
+ const zs = "nimling/nimpress", Bs = "nimpress@nimpress";
1333
+ function Ke(e, t) {
1313
1334
  console.log(`claude ${t.join(" ")}`);
1314
- const s = ee("claude", t, { cwd: e, stdio: "inherit" });
1335
+ const s = te("claude", t, { cwd: e, stdio: "inherit" });
1315
1336
  if (s.error) throw new Error(`[nimpress] plugin: could not run claude, install Claude Code first: ${s.error.message}`);
1316
1337
  if (s.status !== 0) throw new Error(`[nimpress] plugin: claude ${t.join(" ")} exited with ${s.status}`);
1317
1338
  }
1318
- function Bs(e, t) {
1339
+ function Gs(e, t) {
1319
1340
  const s = t ? "user" : "project";
1320
- Ve(e, ["plugin", "marketplace", "add", zs, "--scope", s]), Ve(e, ["plugin", "install", Js, "--scope", s]);
1341
+ Ke(e, ["plugin", "marketplace", "add", zs, "--scope", s]), Ke(e, ["plugin", "install", Bs, "--scope", s]);
1321
1342
  }
1322
- function Gs(e, t) {
1343
+ function Hs(e, t) {
1323
1344
  if (t[0] === "put") {
1324
- Bs(e, !I(t, "project"));
1345
+ Gs(e, !M(t, "project"));
1325
1346
  return;
1326
1347
  }
1327
1348
  throw new Error("[nimpress] plugin expects put");
1328
1349
  }
1329
- const se = {
1350
+ const X = {
1330
1351
  name: "--system",
1331
1352
  value: !0,
1332
1353
  describe: "the configured component system to act on"
1333
- }, Ke = {
1354
+ }, Ye = {
1334
1355
  name: "--framework",
1335
1356
  value: !0,
1336
1357
  describe: "vue or svelte, overriding the framework of the system"
@@ -1371,15 +1392,21 @@ const se = {
1371
1392
  flags: [],
1372
1393
  subs: [
1373
1394
  { name: "init", describe: "Create the modules folder and the config block", flags: [], subs: [] },
1374
- { name: "dev", describe: "Serve the harnesses and stay running", flags: [se], subs: [] },
1375
- { name: "build", describe: "Build the harness bundles", flags: [se], subs: [] },
1376
- { name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [se], subs: [] },
1377
- { name: "story", describe: "Write auto stories for one component or for every component", flags: [se, Ke], subs: [] },
1395
+ { name: "dev", describe: "Serve the harnesses and stay running", flags: [X], subs: [] },
1396
+ { name: "build", describe: "Build the harness bundles", flags: [X], subs: [] },
1397
+ { name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [X], subs: [] },
1398
+ { name: "story", describe: "Write auto stories for one component or for every component", flags: [X, Ye], subs: [] },
1399
+ {
1400
+ name: "stories",
1401
+ describe: "List the stories of one component in every system that carries it, with the harness route that renders each story alone, or every component and its story count",
1402
+ flags: [X, { name: "--json", value: !1, describe: "print the routes as json" }],
1403
+ subs: []
1404
+ },
1378
1405
  {
1379
1406
  name: "import",
1380
1407
  describe: "Import components and storybook stories into component pages",
1381
1408
  flags: [
1382
- se,
1409
+ X,
1383
1410
  { name: "--name", value: !0, describe: "the component name when a single file is imported" },
1384
1411
  { name: "--source", value: !0, describe: "the component source root, overriding the system source" },
1385
1412
  { name: "--stories", value: !0, describe: "an extra folder of storybook csf files" },
@@ -1393,8 +1420,8 @@ const se = {
1393
1420
  name: "create",
1394
1421
  describe: "Create a component page, or upsert one schema",
1395
1422
  flags: [
1396
- se,
1397
- Ke,
1423
+ X,
1424
+ Ye,
1398
1425
  { name: "--component", value: !0, describe: "the component reference whose schema is upserted" },
1399
1426
  { name: "--schema", value: !1, describe: "required with --component, upserts the schema" }
1400
1427
  ],
@@ -1403,7 +1430,7 @@ const se = {
1403
1430
  {
1404
1431
  name: "update",
1405
1432
  describe: "Upsert the component schemas from the component types",
1406
- flags: [se, { name: "--component", value: !0, describe: "limit the upsert to one component reference" }],
1433
+ flags: [X, { name: "--component", value: !0, describe: "limit the upsert to one component reference" }],
1407
1434
  subs: []
1408
1435
  }
1409
1436
  ]
@@ -1518,7 +1545,7 @@ const se = {
1518
1545
  { name: "powershell", describe: "the powershell completion script", flags: [], subs: [] }
1519
1546
  ]
1520
1547
  }
1521
- ], Ot = ["bash", "zsh", "fish", "powershell"];
1548
+ ], Ft = ["bash", "zsh", "fish", "powershell"];
1522
1549
  function ke(e) {
1523
1550
  const t = [];
1524
1551
  for (const s of [...e.flags, ...e.subs.flatMap((n) => n.flags)])
@@ -1528,7 +1555,7 @@ function ke(e) {
1528
1555
  function xe(e, t) {
1529
1556
  return t && e.value ? `${e.name}=` : e.name;
1530
1557
  }
1531
- function Hs() {
1558
+ function Us() {
1532
1559
  const e = ["_nimpress() {", ' local cur="${COMP_WORDS[COMP_CWORD]}"'];
1533
1560
  e.push(` local words="${V.map((t) => t.name).join(" ")}"`), e.push(' if [ "$COMP_CWORD" -gt 1 ]; then'), e.push(' case "${COMP_WORDS[1]}" in');
1534
1561
  for (const t of V) {
@@ -1544,7 +1571,7 @@ function Ee(e, t, s) {
1544
1571
  for (const o of s) n.push(`${e} ${o}`);
1545
1572
  return n.push(`${e})`), n.push(`${e}_describe '${t}' entries`), n.push(`${e}return`), n;
1546
1573
  }
1547
- function Us() {
1574
+ function Zs() {
1548
1575
  const e = ["#compdef nimpress", "", "_nimpress() {", " local -a entries", " if (( CURRENT == 2 )); then"];
1549
1576
  e.push(
1550
1577
  ...Ee(
@@ -1574,7 +1601,7 @@ function Us() {
1574
1601
  `) + `
1575
1602
  `;
1576
1603
  }
1577
- function Zs() {
1604
+ function Vs() {
1578
1605
  const e = ["complete -c nimpress -f"];
1579
1606
  for (const t of V)
1580
1607
  e.push(
@@ -1593,7 +1620,7 @@ function Zs() {
1593
1620
  `) + `
1594
1621
  `;
1595
1622
  }
1596
- function Vs() {
1623
+ function Ks() {
1597
1624
  const e = [
1598
1625
  "Register-ArgumentCompleter -Native -CommandName nimpress -ScriptBlock {",
1599
1626
  " param($wordToComplete, $commandAst, $cursorPosition)",
@@ -1612,14 +1639,14 @@ function Vs() {
1612
1639
  `) + `
1613
1640
  `;
1614
1641
  }
1615
- function Ft(e) {
1616
- if (e === "bash") return Hs();
1617
- if (e === "zsh") return Us();
1618
- if (e === "fish") return Zs();
1619
- if (e === "powershell") return Vs();
1620
- throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${Ot.join(", ")}`);
1642
+ function Dt(e) {
1643
+ if (e === "bash") return Us();
1644
+ if (e === "zsh") return Zs();
1645
+ if (e === "fish") return Vs();
1646
+ if (e === "powershell") return Ks();
1647
+ throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${Ft.join(", ")}`);
1621
1648
  }
1622
- function Ye(e) {
1649
+ function Qe(e) {
1623
1650
  return e === "fish" ? [
1624
1651
  "function nimpress",
1625
1652
  " if test -x node_modules/.bin/nimpress",
@@ -1641,13 +1668,13 @@ function Ye(e) {
1641
1668
  ].join(`
1642
1669
  `);
1643
1670
  }
1644
- function Ks() {
1671
+ function Ys() {
1645
1672
  const e = D(process.env.SHELL ?? "");
1646
1673
  for (const t of ["zsh", "bash", "fish"])
1647
1674
  if (e.includes(t)) return t;
1648
1675
  return "";
1649
1676
  }
1650
- function Ys(e, t) {
1677
+ function Qs(e, t) {
1651
1678
  const s = "# >>> nimpress completion >>>", n = "# <<< nimpress completion <<<", o = `${s}
1652
1679
  ${t}
1653
1680
  ${n}`, r = e.indexOf(s), i = e.indexOf(n);
@@ -1658,29 +1685,29 @@ ${n}`, r = e.indexOf(s), i = e.indexOf(n);
1658
1685
  `) + o + `
1659
1686
  `;
1660
1687
  }
1661
- function Qs(e, t) {
1688
+ function Xs(e, t) {
1662
1689
  let s = "";
1663
1690
  try {
1664
1691
  s = C(e, "utf-8");
1665
1692
  } catch {
1666
1693
  s = "";
1667
1694
  }
1668
- W(e, Ys(s, t));
1695
+ W(e, Qs(s, t));
1669
1696
  }
1670
- function Xs(e) {
1671
- const t = e || Ks();
1697
+ function qs(e) {
1698
+ const t = e || Ys();
1672
1699
  if (!t)
1673
1700
  throw new Error("[nimpress] completion: could not detect the shell from $SHELL, name it: nimpress completion <shell> --auto");
1674
- const s = Ft(t), n = K();
1701
+ const s = Dt(t), n = K();
1675
1702
  if (t === "fish") {
1676
1703
  const a = d(n, ".config", "fish", "completions");
1677
1704
  B(a, { recursive: !0 });
1678
- const p = d(a, "nimpress.fish");
1679
- W(p, s), console.log(`wrote ${p}`);
1680
- const l = d(n, ".config", "fish", "functions");
1681
- B(l, { recursive: !0 });
1682
- const m = d(l, "nimpress.fish");
1683
- W(m, Ye(t)), console.log(`wrote ${m}`), console.log("fish loads them on the next shell");
1705
+ const l = d(a, "nimpress.fish");
1706
+ W(l, s), console.log(`wrote ${l}`);
1707
+ const u = d(n, ".config", "fish", "functions");
1708
+ B(u, { recursive: !0 });
1709
+ const m = d(u, "nimpress.fish");
1710
+ W(m, Qe(t)), console.log(`wrote ${m}`), console.log("fish loads them on the next shell");
1684
1711
  return;
1685
1712
  }
1686
1713
  if (t !== "bash" && t !== "zsh")
@@ -1690,36 +1717,36 @@ function Xs(e) {
1690
1717
  const r = d(o, t === "zsh" ? "_nimpress" : "nimpress.bash");
1691
1718
  W(r, s), console.log(`wrote ${r}`);
1692
1719
  const i = d(n, t === "zsh" ? ".zshrc" : ".bashrc"), c = t === "zsh" ? `fpath=("${o}" $fpath)
1693
- autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`, u = `${Ye(t)}
1720
+ autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`, p = `${Qe(t)}
1694
1721
  ${c}`;
1695
- Qs(i, u), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
1722
+ Xs(i, p), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
1696
1723
  }
1697
- function qs(e, t) {
1698
- const s = ie(t, 0) ?? "", n = I(t, "auto"), o = I(t, "skill");
1724
+ function en(e, t) {
1725
+ const s = ne(t, 0) ?? "", n = M(t, "auto"), o = M(t, "skill");
1699
1726
  if (!n) {
1700
1727
  if (o) throw new Error("[nimpress] completion: --skill installs alongside --auto");
1701
- if (!s) throw new Error(`[nimpress] completion: name a shell (${Ot.join(", ")}) or pass --auto`);
1702
- process.stdout.write(Ft(s));
1728
+ if (!s) throw new Error(`[nimpress] completion: name a shell (${Ft.join(", ")}) or pass --auto`);
1729
+ process.stdout.write(Dt(s));
1703
1730
  return;
1704
1731
  }
1705
- Xs(s), o && Et(e, !0);
1732
+ qs(s), o && Ot(e, !0);
1706
1733
  }
1707
- const en = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), tn = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), sn = 2e4, de = /* @__PURE__ */ new Map();
1708
- function Dt(e, t) {
1734
+ const tn = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), sn = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), nn = 2e4, de = /* @__PURE__ */ new Map();
1735
+ function _t(e, t) {
1709
1736
  const s = [...t, e.name];
1710
- return e.subs.length ? e.subs.flatMap((n) => Dt(n, s)) : [
1737
+ return e.subs.length ? e.subs.flatMap((n) => _t(n, s)) : [
1711
1738
  {
1712
1739
  name: s.join("_"),
1713
1740
  argv: s,
1714
1741
  describe: e.describe,
1715
1742
  flags: e.flags,
1716
- serves: tn.has(s.join(" "))
1743
+ serves: sn.has(s.join(" "))
1717
1744
  }
1718
1745
  ];
1719
1746
  }
1720
- const _t = V.filter((e) => !en.has(e.name)).flatMap((e) => Dt(e, []));
1721
- function nn() {
1722
- const e = N(mt(import.meta.url));
1747
+ const Nt = V.filter((e) => !tn.has(e.name)).flatMap((e) => _t(e, []));
1748
+ function on() {
1749
+ const e = N(ft(import.meta.url));
1723
1750
  for (const t of [x(e, "..", "package.json"), x(e, "..", "..", "package.json")])
1724
1751
  try {
1725
1752
  return JSON.parse(C(t, "utf-8")).version;
@@ -1727,7 +1754,7 @@ function nn() {
1727
1754
  }
1728
1755
  return "0.0.0";
1729
1756
  }
1730
- function on(e) {
1757
+ function rn(e) {
1731
1758
  const t = {};
1732
1759
  for (const s of e.flags)
1733
1760
  t[s.name.slice(2)] = { type: s.value ? "string" : "boolean", description: s.describe };
@@ -1741,12 +1768,12 @@ function on(e) {
1741
1768
  additionalProperties: !1
1742
1769
  };
1743
1770
  }
1744
- function rn() {
1771
+ function an() {
1745
1772
  return [
1746
- ..._t.map((e) => ({
1773
+ ...Nt.map((e) => ({
1747
1774
  name: e.name,
1748
1775
  description: `nimpress ${e.argv.join(" ")}: ${e.describe}${e.serves ? ". Keeps running in the background and returns its pid with the first output" : ""}`,
1749
- inputSchema: on(e)
1776
+ inputSchema: rn(e)
1750
1777
  })),
1751
1778
  {
1752
1779
  name: "stop",
@@ -1760,7 +1787,7 @@ function rn() {
1760
1787
  }
1761
1788
  ];
1762
1789
  }
1763
- function an(e, t) {
1790
+ function cn(e, t) {
1764
1791
  const s = [...e.argv, ...t.args ?? []];
1765
1792
  for (const [n, o] of Object.entries(t.flags ?? {}))
1766
1793
  o === !0 ? s.push(`--${n}`) : typeof o == "string" && s.push(`--${n}=${o}`);
@@ -1769,89 +1796,89 @@ function an(e, t) {
1769
1796
  function U(e, t = !1) {
1770
1797
  return { content: [{ type: "text", text: e || "(no output)" }], ...t ? { isError: t } : {} };
1771
1798
  }
1772
- function Nt(e, t, s) {
1773
- return Ie(process.execPath, [process.argv[1], ...an(t, s)], {
1799
+ function Wt(e, t, s) {
1800
+ return Ie(process.execPath, [process.argv[1], ...cn(t, s)], {
1774
1801
  cwd: x(e, s.cwd ?? "."),
1775
1802
  env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" },
1776
1803
  stdio: ["ignore", "pipe", "pipe"]
1777
1804
  });
1778
1805
  }
1779
- function cn(e, t, s) {
1780
- const n = Nt(e, t, s);
1806
+ function ln(e, t, s) {
1807
+ const n = Wt(e, t, s);
1781
1808
  let o = "";
1782
1809
  return n.stdout?.on("data", (r) => o += r), n.stderr?.on("data", (r) => o += r), new Promise((r) => {
1783
1810
  n.on("error", (i) => r(U(`${o}${i.message}`, !0))), n.on("close", (i) => r(U(o, i !== 0)));
1784
1811
  });
1785
1812
  }
1786
- function ln(e, t, s) {
1787
- const n = Nt(e, t, s);
1813
+ function un(e, t, s) {
1814
+ const n = Wt(e, t, s);
1788
1815
  let o = "";
1789
1816
  return new Promise((r) => {
1790
1817
  const i = (a) => {
1791
- clearTimeout(u), n.stdout?.removeAllListeners("data"), n.stderr?.removeAllListeners("data"), n.stdout?.resume(), n.stderr?.resume(), r(a);
1818
+ clearTimeout(p), n.stdout?.removeAllListeners("data"), n.stderr?.removeAllListeners("data"), n.stdout?.resume(), n.stderr?.resume(), r(a);
1792
1819
  }, c = (a) => {
1793
1820
  o += a, /https?:\/\/\S+/.test(o) && i(U(`pid ${n.pid}
1794
1821
  ${o}`));
1795
- }, u = setTimeout(() => i(U(`pid ${n.pid}
1796
- ${o}`)), sn);
1822
+ }, p = setTimeout(() => i(U(`pid ${n.pid}
1823
+ ${o}`)), nn);
1797
1824
  n.stdout?.on("data", c), n.stderr?.on("data", c), n.on("error", (a) => i(U(`${o}${a.message}`, !0))), n.on("exit", (a) => {
1798
1825
  de.delete(n.pid ?? -1), i(U(o, a !== 0));
1799
1826
  }), n.pid && de.set(n.pid, n);
1800
1827
  });
1801
1828
  }
1802
- function un(e) {
1829
+ function pn(e) {
1803
1830
  const t = de.get(e);
1804
1831
  return t ? (t.kill("SIGTERM"), de.delete(e), U(`stopped ${e}`)) : U(`no server with pid ${e} was started by this session`, !0);
1805
1832
  }
1806
- async function pn(e, t) {
1833
+ async function mn(e, t) {
1807
1834
  const s = String(t.name ?? ""), n = t.arguments ?? {};
1808
- if (s === "stop") return un(Number(n.pid));
1809
- const o = _t.find((r) => r.name === s);
1810
- return o ? b(x(e, n.cwd ?? ".")) ? o.serves ? ln(e, o, n) : cn(e, o, n) : U(`no folder ${n.cwd} under ${e}`, !0) : U(`unknown tool ${s}`, !0);
1835
+ if (s === "stop") return pn(Number(n.pid));
1836
+ const o = Nt.find((r) => r.name === s);
1837
+ return o ? b(x(e, n.cwd ?? ".")) ? o.serves ? un(e, o, n) : ln(e, o, n) : U(`no folder ${n.cwd} under ${e}`, !0) : U(`unknown tool ${s}`, !0);
1811
1838
  }
1812
- function ne(e, t) {
1839
+ function oe(e, t) {
1813
1840
  process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: e, ...t }) + `
1814
1841
  `);
1815
1842
  }
1816
- async function mn(e, t) {
1843
+ async function fn(e, t) {
1817
1844
  if (t.id !== void 0) {
1818
1845
  if (t.method === "initialize") {
1819
- ne(t.id, {
1846
+ oe(t.id, {
1820
1847
  result: {
1821
1848
  protocolVersion: t.params?.protocolVersion ?? "2025-06-18",
1822
1849
  capabilities: { tools: {} },
1823
- serverInfo: { name: "nimpress", version: nn() }
1850
+ serverInfo: { name: "nimpress", version: on() }
1824
1851
  }
1825
1852
  });
1826
1853
  return;
1827
1854
  }
1828
1855
  if (t.method === "ping") {
1829
- ne(t.id, { result: {} });
1856
+ oe(t.id, { result: {} });
1830
1857
  return;
1831
1858
  }
1832
1859
  if (t.method === "tools/list") {
1833
- ne(t.id, { result: { tools: rn() } });
1860
+ oe(t.id, { result: { tools: an() } });
1834
1861
  return;
1835
1862
  }
1836
1863
  if (t.method === "tools/call") {
1837
- ne(t.id, { result: await pn(e, t.params ?? {}) });
1864
+ oe(t.id, { result: await mn(e, t.params ?? {}) });
1838
1865
  return;
1839
1866
  }
1840
- ne(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
1867
+ oe(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
1841
1868
  }
1842
1869
  }
1843
- function fn(e) {
1844
- const t = cs({ input: process.stdin }), s = /* @__PURE__ */ new Set();
1870
+ function dn(e) {
1871
+ const t = ls({ input: process.stdin }), s = /* @__PURE__ */ new Set();
1845
1872
  t.on("line", (n) => {
1846
1873
  if (!n.trim()) return;
1847
1874
  let o;
1848
1875
  try {
1849
1876
  o = JSON.parse(n);
1850
1877
  } catch {
1851
- ne(null, { error: { code: -32700, message: "parse error" } });
1878
+ oe(null, { error: { code: -32700, message: "parse error" } });
1852
1879
  return;
1853
1880
  }
1854
- const r = mn(e, o).catch((i) => ne(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => s.delete(r));
1881
+ const r = fn(e, o).catch((i) => oe(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => s.delete(r));
1855
1882
  s.add(r);
1856
1883
  }), t.on("close", async () => {
1857
1884
  await Promise.all(s);
@@ -1859,77 +1886,77 @@ function fn(e) {
1859
1886
  process.exit(0);
1860
1887
  });
1861
1888
  }
1862
- function dn(e, t, s) {
1889
+ function hn(e, t, s) {
1863
1890
  if (typeof s.path == "string") return s.path.startsWith("/") ? s.path : `/${s.path}`;
1864
1891
  const n = F(e, t).split(L).join("/").replace(/\.md$/, "");
1865
1892
  return n === "index" ? "/" : `/${n.replace(/\/index$/, "")}`;
1866
1893
  }
1867
- function Qe(e) {
1894
+ function Xe(e) {
1868
1895
  return e ? (Array.isArray(e) ? e : String(e).split(",")).map((s) => String(s).trim()).filter(Boolean) : [];
1869
1896
  }
1870
- function hn(e) {
1897
+ function gn(e) {
1871
1898
  return e.split(`
1872
1899
  `).filter((t) => /^#{1,6}\s/.test(t)).map((t) => t.replace(/^#{1,6}\s+/, "").trim());
1873
1900
  }
1874
- function gn(e, t) {
1901
+ function wn(e, t) {
1875
1902
  const s = x(e, t.contentDir), o = Y(s).filter((a) => a.endsWith(".md")).map((a) => {
1876
- const { data: p, content: l } = le(C(a, "utf-8"));
1877
- return { file: a, data: p, content: l };
1903
+ const { data: l, content: u } = ue(C(a, "utf-8"));
1904
+ return { file: a, data: l, content: u };
1878
1905
  }).filter((a) => typeof a.data.title == "string" && a.data.visibility !== "hidden" && !a.data.link), r = o.map((a) => ({
1879
1906
  slug: a.file,
1880
1907
  title: String(a.data.title),
1881
- headings: hn(a.content),
1882
- tags: Qe(a.data.tags),
1908
+ headings: gn(a.content),
1909
+ tags: Xe(a.data.tags),
1883
1910
  body: a.content
1884
- })), i = ss(r), c = t.site?.url?.replace(/\/$/, "") ?? "", u = t.base.replace(/\/$/, "");
1911
+ })), i = ns(r), c = t.site?.url?.replace(/\/$/, "") ?? "", p = t.base.replace(/\/$/, "");
1885
1912
  return o.map((a) => {
1886
- const p = i.get(a.file) ?? { keywords: [], description: "" }, l = a.data.meta ?? {}, m = Array.isArray(l.keywords) ? l.keywords : typeof l.keywords == "string" ? [l.keywords] : void 0, f = typeof l.description == "string" ? l.description : typeof a.data.description == "string" ? a.data.description : void 0, h = l.override === !0, g = t.seo?.auto === !0, w = g ? h && m ? m : p.keywords.length ? p.keywords : m ?? [] : m ?? Qe(a.data.tags), k = g ? h && f ? f : p.description || f || "" : f ?? "", j = dn(s, a.file, a.data);
1913
+ const l = i.get(a.file) ?? { keywords: [], description: "" }, u = a.data.meta ?? {}, m = Array.isArray(u.keywords) ? u.keywords : typeof u.keywords == "string" ? [u.keywords] : void 0, f = typeof u.description == "string" ? u.description : typeof a.data.description == "string" ? a.data.description : void 0, h = u.override === !0, g = t.seo?.auto === !0, w = g ? h && m ? m : l.keywords.length ? l.keywords : m ?? [] : m ?? Xe(a.data.tags), k = g ? h && f ? f : l.description || f || "" : f ?? "", j = hn(s, a.file, a.data);
1887
1914
  return {
1888
1915
  path: j,
1889
1916
  file: F(e, a.file).split(L).join("/"),
1890
1917
  title: String(a.data.title),
1891
1918
  keywords: w,
1892
1919
  description: k,
1893
- robots: ns(typeof l.robots == "string" ? l.robots : "index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1", t.seo?.ai?.index, typeof l.ai == "boolean" ? l.ai : void 0),
1894
- canonical: typeof l.canonical == "string" ? l.canonical : c ? `${c}${u}${j === "/" ? "/" : j}` : "",
1895
- generated: p,
1896
- authored: { keywords: m, description: f, override: h, ai: typeof l.ai == "boolean" ? l.ai : void 0 }
1920
+ robots: os(typeof u.robots == "string" ? u.robots : "index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1", t.seo?.ai?.index, typeof u.ai == "boolean" ? u.ai : void 0),
1921
+ canonical: typeof u.canonical == "string" ? u.canonical : c ? `${c}${p}${j === "/" ? "/" : j}` : "",
1922
+ generated: l,
1923
+ authored: { keywords: m, description: f, override: h, ai: typeof u.ai == "boolean" ? u.ai : void 0 }
1897
1924
  };
1898
1925
  });
1899
1926
  }
1900
- function wn(e, t) {
1927
+ function $n(e, t) {
1901
1928
  let s = 0;
1902
1929
  for (const n of t) {
1903
- const o = x(e, n.file), { data: r, content: i } = le(C(o, "utf-8")), c = { ...r.meta ?? {} };
1904
- let u = !1;
1905
- c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords, u = !0), c.description === void 0 && n.generated.description && (c.description = n.generated.description, u = !0), u && (W(o, le.stringify(i, { ...r, meta: c })), s += 1);
1930
+ const o = x(e, n.file), { data: r, content: i } = ue(C(o, "utf-8")), c = { ...r.meta ?? {} };
1931
+ let p = !1;
1932
+ c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords, p = !0), c.description === void 0 && n.generated.description && (c.description = n.generated.description, p = !0), p && (W(o, ue.stringify(i, { ...r, meta: c })), s += 1);
1906
1933
  }
1907
1934
  return s;
1908
1935
  }
1909
- function $n(e, t, s) {
1910
- const n = gn(e, t), o = _(s, "out") ?? "seo.map.json";
1936
+ function yn(e, t, s) {
1937
+ const n = wn(e, t), o = _(s, "out") ?? "seo.map.json";
1911
1938
  for (const r of n) {
1912
1939
  const i = t.seo?.auto ? r.authored.override ? "authored" : "generated" : "authored";
1913
1940
  console.log(`${r.path.padEnd(40)} ${String(r.keywords.length).padStart(2)} keywords ${String(r.description.length).padStart(3)} chars ${r.robots.includes("noai") ? "noai" : "ai ok"} ${i}`);
1914
1941
  }
1915
1942
  if (W(x(e, o), JSON.stringify(n, null, 2) + `
1916
1943
  `), console.log(`nimpress seo: ${n.length} pages, map written to ${o}`), s.includes("--write")) {
1917
- const r = wn(e, n);
1944
+ const r = $n(e, n);
1918
1945
  console.log(`nimpress seo: generated fields written into ${r} pages`);
1919
1946
  }
1920
1947
  }
1921
- function Wt(e = K()) {
1948
+ function Tt(e = K()) {
1922
1949
  return d(e, ".nimpress", "config.json");
1923
1950
  }
1924
- function Tt(e = K()) {
1951
+ function Pt(e = K()) {
1925
1952
  return d(e, ".tide", "nimpress", "sites");
1926
1953
  }
1927
- function Pt(e = K()) {
1928
- const t = Wt(e);
1954
+ function Rt(e = K()) {
1955
+ const t = Tt(e);
1929
1956
  return b(t) ? { links: JSON.parse(C(t, "utf-8")).links ?? {} } : { links: {} };
1930
1957
  }
1931
- function Rt(e, t = K()) {
1932
- const s = Wt(t);
1958
+ function At(e, t = K()) {
1959
+ const s = Tt(t);
1933
1960
  B(N(s), { recursive: !0 }), W(s, `${JSON.stringify(e, null, 2)}
1934
1961
  `);
1935
1962
  }
@@ -1944,114 +1971,114 @@ function Oe(e) {
1944
1971
  const t = e.trim();
1945
1972
  return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${ve(t)}.git`;
1946
1973
  }
1947
- function At(e) {
1974
+ function Mt(e) {
1948
1975
  const t = d(e, ".github", "workflows");
1949
- return b(t) ? re(t).filter((s) => s.endsWith(".yml") || s.endsWith(".yaml")).sort().map((s) => d(t, s)) : [];
1976
+ return b(t) ? ie(t).filter((s) => s.endsWith(".yml") || s.endsWith(".yaml")).sort().map((s) => d(t, s)) : [];
1950
1977
  }
1951
- function Mt(e) {
1978
+ function It(e) {
1952
1979
  try {
1953
- const t = ls(C(e, "utf-8"));
1980
+ const t = us(C(e, "utf-8"));
1954
1981
  return typeof t == "object" && t !== null ? t : null;
1955
1982
  } catch {
1956
1983
  return null;
1957
1984
  }
1958
1985
  }
1959
- function ce(e, t) {
1986
+ function le(e, t) {
1960
1987
  return String(e ?? "").replace(/\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (n, o) => {
1961
1988
  for (const r of t)
1962
1989
  if (r && r[o] !== void 0) return String(r[o]);
1963
1990
  return "";
1964
1991
  }).trim();
1965
1992
  }
1966
- function It(e, t) {
1993
+ function Lt(e, t) {
1967
1994
  const s = [];
1968
1995
  for (const n of Object.values(e.jobs ?? {}))
1969
1996
  for (const o of n.steps ?? [])
1970
1997
  typeof o.uses == "string" && o.uses.includes(`/actions/${t}@`) && s.push({ step: o, scopes: [o.env, n.env, e.env] });
1971
1998
  return s;
1972
1999
  }
1973
- function yn(e) {
2000
+ function bn(e) {
1974
2001
  const t = /* @__PURE__ */ new Map();
1975
- for (const s of At(e)) {
1976
- const n = Mt(s);
2002
+ for (const s of Mt(e)) {
2003
+ const n = It(s);
1977
2004
  if (n)
1978
- for (const { step: o, scopes: r } of It(n, "docs-notify")) {
1979
- const i = ce(o.with?.["docs-repo"], r);
2005
+ for (const { step: o, scopes: r } of Lt(n, "docs-notify")) {
2006
+ const i = le(o.with?.["docs-repo"], r);
1980
2007
  if (!i) continue;
1981
- const c = ce(o.with?.["export-dir"], r) || ".nimpress";
2008
+ const c = le(o.with?.["export-dir"], r) || ".nimpress";
1982
2009
  t.set(i, { repo: i, exportDir: c });
1983
2010
  }
1984
2011
  }
1985
2012
  return [...t.values()];
1986
2013
  }
1987
- function Xe(e) {
2014
+ function qe(e) {
1988
2015
  return e.replace(/\$\{\{\s*github\.workspace\s*\}\}\/?/g, "").replace(/^\.\//, "");
1989
2016
  }
1990
- function bn(e, t) {
2017
+ function vn(e, t) {
1991
2018
  const s = {
1992
2019
  contentRoot: t,
1993
2020
  mapping: b(d(e, "nimpress.sources.json")) ? "nimpress.sources.json" : "",
1994
2021
  defaults: {}
1995
2022
  };
1996
- for (const n of At(e)) {
1997
- const o = Mt(n);
2023
+ for (const n of Mt(e)) {
2024
+ const o = It(n);
1998
2025
  if (o)
1999
- for (const { step: r, scopes: i } of It(o, "docs-sync")) {
2000
- const c = Xe(ce(r.with?.["docs-dir"], i)), u = (m) => {
2001
- const f = Xe(m);
2026
+ for (const { step: r, scopes: i } of Lt(o, "docs-sync")) {
2027
+ const c = qe(le(r.with?.["docs-dir"], i)), p = (m) => {
2028
+ const f = qe(m);
2002
2029
  return (c && f.startsWith(`${c}/`) ? f.slice(c.length + 1) : f).replace(/\/+$/, "");
2003
- }, a = ce(r.with?.["content-root"], i);
2004
- a && (s.contentRoot = u(a));
2005
- const p = ce(r.with?.mapping, i);
2006
- p && (s.mapping = u(p));
2007
- const l = ce(r.with?.defaults, i);
2008
- return l && (s.defaults = JSON.parse(l)), s;
2030
+ }, a = le(r.with?.["content-root"], i);
2031
+ a && (s.contentRoot = p(a));
2032
+ const l = le(r.with?.mapping, i);
2033
+ l && (s.mapping = p(l));
2034
+ const u = le(r.with?.defaults, i);
2035
+ return u && (s.defaults = JSON.parse(u)), s;
2009
2036
  }
2010
2037
  }
2011
2038
  return s;
2012
2039
  }
2013
- function vn(e, t) {
2040
+ function kn(e, t) {
2014
2041
  const s = { ...e };
2015
2042
  return t.target && (s.target = t.target), t.targets?.length && (s.targets = t.targets), t.mode && (s.mode = t.mode), s;
2016
2043
  }
2017
- function kn(e) {
2044
+ function xn(e) {
2018
2045
  const t = e.mode || "mirror";
2019
2046
  return e.targets?.length ? e.targets.map((s) => ({ from: s.from ?? "", to: s.to, mode: s.mode || t })) : e.target ? [{ from: "", to: e.target, mode: t }] : [];
2020
2047
  }
2021
- function xn(e, t, s) {
2048
+ function Sn(e, t, s) {
2022
2049
  let n = t.defaults;
2023
2050
  const o = t.mapping ? d(e, t.mapping) : "";
2024
2051
  if (o && b(o)) {
2025
2052
  const i = JSON.parse(C(o, "utf-8")).sources?.[s];
2026
- i && (n = vn(n, i));
2053
+ i && (n = kn(n, i));
2027
2054
  }
2028
2055
  return n;
2029
2056
  }
2030
- function qe(e) {
2057
+ function et(e) {
2031
2058
  const t = /* @__PURE__ */ new Map();
2032
2059
  if (!b(e)) return t;
2033
2060
  for (const s of Y(e))
2034
2061
  t.set(F(e, s).split(L).join("/"), C(s));
2035
2062
  return t;
2036
2063
  }
2037
- function Sn(e, t, s) {
2038
- const n = { added: [], modified: [], deleted: [] }, o = qe(e), r = qe(t);
2064
+ function jn(e, t, s) {
2065
+ const n = { added: [], modified: [], deleted: [] }, o = et(e), r = et(t);
2039
2066
  for (const [i, c] of o) {
2040
- const u = r.get(i);
2041
- if (u && u.equals(c)) continue;
2067
+ const p = r.get(i);
2068
+ if (p && p.equals(c)) continue;
2042
2069
  const a = d(t, ...i.split("/"));
2043
- B(N(a), { recursive: !0 }), W(a, c), u ? n.modified.push(i) : n.added.push(i);
2070
+ B(N(a), { recursive: !0 }), W(a, c), p ? n.modified.push(i) : n.added.push(i);
2044
2071
  }
2045
2072
  if (s === "mirror")
2046
2073
  for (const i of r.keys())
2047
- o.has(i) || (q(d(t, ...i.split("/")), { force: !0 }), n.deleted.push(i));
2074
+ o.has(i) || (ee(d(t, ...i.split("/")), { force: !0 }), n.deleted.push(i));
2048
2075
  return n;
2049
2076
  }
2050
- function jn(e, t) {
2077
+ function Cn(e, t) {
2051
2078
  const s = /* @__PURE__ */ new Map();
2052
2079
  for (const o of Y(e)) {
2053
2080
  if (!o.endsWith(".md")) continue;
2054
- const r = le(C(o, "utf-8")).data.path, i = os(e, o, typeof r == "string" ? r : void 0);
2081
+ const r = ue(C(o, "utf-8")).data.path, i = rs(e, o, typeof r == "string" ? r : void 0);
2055
2082
  s.set(i, [...s.get(i) ?? [], o]);
2056
2083
  }
2057
2084
  const n = [];
@@ -2059,253 +2086,253 @@ function jn(e, t) {
2059
2086
  o.some((r) => t.has(r)) && n.push(...o.filter((r) => !t.has(r)));
2060
2087
  return n.sort();
2061
2088
  }
2062
- function oe(e, t, s) {
2063
- const n = ee("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...s } });
2089
+ function re(e, t, s) {
2090
+ const n = te("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...s } });
2064
2091
  return { ok: n.status === 0, out: `${n.stdout ?? ""}${n.stderr ?? ""}`.trim() };
2065
2092
  }
2066
- function Lt(e) {
2067
- const t = oe(["rev-parse", "--show-toplevel"], e);
2093
+ function Jt(e) {
2094
+ const t = re(["rev-parse", "--show-toplevel"], e);
2068
2095
  return t.ok ? t.out : e;
2069
2096
  }
2070
- function Cn(e) {
2071
- const t = oe(["remote", "get-url", "origin"], e);
2097
+ function En(e) {
2098
+ const t = re(["remote", "get-url", "origin"], e);
2072
2099
  if (!t.ok) throw new Error(`[nimpress] view: ${e} has no origin remote, so its docs site mapping cannot be looked up`);
2073
2100
  return ve(t.out);
2074
2101
  }
2075
- function En() {
2076
- return ee("gh", ["--version"], { encoding: "utf-8" }).status === 0;
2102
+ function On() {
2103
+ return te("gh", ["--version"], { encoding: "utf-8" }).status === 0;
2077
2104
  }
2078
2105
  function zt(e) {
2079
2106
  return e?.method === "ssh" && e.key ? { GIT_SSH_COMMAND: `ssh -i ${e.key} -o IdentitiesOnly=yes` } : {};
2080
2107
  }
2081
2108
  function Fe(e) {
2082
- return e.login?.method === "gh" ? ee("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : oe(["ls-remote", "--exit-code", "-h", e.url], void 0, zt(e.login)).ok;
2109
+ return e.login?.method === "gh" ? te("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : re(["ls-remote", "--exit-code", "-h", e.url], void 0, zt(e.login)).ok;
2083
2110
  }
2084
- async function Jt(e) {
2085
- const t = pt({ input: process.stdin, output: process.stdout });
2111
+ async function Bt(e) {
2112
+ const t = mt({ input: process.stdin, output: process.stdout });
2086
2113
  try {
2087
2114
  return (await t.question(e)).trim();
2088
2115
  } finally {
2089
2116
  t.close();
2090
2117
  }
2091
2118
  }
2092
- async function On(e) {
2119
+ async function Fn(e) {
2093
2120
  if (Fe(e)) return e;
2094
- if (console.log(`nimpress view: ${e.url} refused the connection`), En()) {
2095
- if (console.log("nimpress view: logging in through gh"), ee("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
2121
+ if (console.log(`nimpress view: ${e.url} refused the connection`), On()) {
2122
+ if (console.log("nimpress view: logging in through gh"), te("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
2096
2123
  const o = { ...e, login: { method: "gh" } };
2097
2124
  if (Fe(o)) return o;
2098
2125
  throw new Error(`[nimpress] view: ${e.repo} is still unreachable after the gh login, ask for access to it`);
2099
2126
  }
2100
- const t = await Jt("nimpress view: path to the ssh key with access to the repo: ");
2127
+ const t = await Bt("nimpress view: path to the ssh key with access to the repo: ");
2101
2128
  if (!t) throw new Error("[nimpress] view: no ssh key given and gh is not installed");
2102
2129
  const s = { ...e, login: { method: "ssh", key: x(t.replace(/^~/, K())) } };
2103
2130
  if (Fe(s)) return s;
2104
2131
  throw new Error(`[nimpress] view: ${e.repo} is still unreachable with ${s.login.key}, ask for access to it`);
2105
2132
  }
2106
- async function Fn(e, t, s = K()) {
2107
- const n = Lt(e), o = Pt(s), r = o.links[n] ?? [], i = yn(n), c = _(t, "docs-repo");
2108
- let u;
2133
+ async function Dn(e, t, s = K()) {
2134
+ const n = Jt(e), o = Rt(s), r = o.links[n] ?? [], i = bn(n), c = _(t, "docs-repo");
2135
+ let p;
2109
2136
  if (c) {
2110
- const p = ve(c), l = i.find((m) => m.repo === p)?.exportDir ?? _(t, "export-dir") ?? ".nimpress";
2111
- u = [{ repo: p, url: Oe(c), exportDir: l, login: r.find((m) => m.repo === p)?.login }];
2137
+ const l = ve(c), u = i.find((m) => m.repo === l)?.exportDir ?? _(t, "export-dir") ?? ".nimpress";
2138
+ p = [{ repo: l, url: Oe(c), exportDir: u, login: r.find((m) => m.repo === l)?.login }];
2112
2139
  } else if (i.length)
2113
- u = i.map((p) => ({
2114
- repo: p.repo,
2115
- url: r.find((l) => l.repo === p.repo)?.url ?? Oe(p.repo),
2116
- exportDir: p.exportDir,
2117
- login: r.find((l) => l.repo === p.repo)?.login
2140
+ p = i.map((l) => ({
2141
+ repo: l.repo,
2142
+ url: r.find((u) => u.repo === l.repo)?.url ?? Oe(l.repo),
2143
+ exportDir: l.exportDir,
2144
+ login: r.find((u) => u.repo === l.repo)?.login
2118
2145
  }));
2119
2146
  else if (r.length)
2120
- u = r;
2147
+ p = r;
2121
2148
  else {
2122
2149
  console.log(`nimpress view: no workflow under ${n} names a docs site`);
2123
- const p = await Jt("nimpress view: docs site repo, owner/repo or a url, http or ssh: ");
2124
- if (!p) throw new Error("[nimpress] view: no docs site given");
2125
- u = [{ repo: ve(p), url: Oe(p), exportDir: _(t, "export-dir") ?? ".nimpress" }];
2150
+ const l = await Bt("nimpress view: docs site repo, owner/repo or a url, http or ssh: ");
2151
+ if (!l) throw new Error("[nimpress] view: no docs site given");
2152
+ p = [{ repo: ve(l), url: Oe(l), exportDir: _(t, "export-dir") ?? ".nimpress" }];
2126
2153
  }
2127
2154
  const a = [];
2128
- for (const p of u) a.push(await On(p));
2129
- return o.links[n] = a, Rt(o, s), a;
2155
+ for (const l of p) a.push(await Fn(l));
2156
+ return o.links[n] = a, At(o, s), a;
2130
2157
  }
2131
- function Dn(e, t = K()) {
2132
- return d(Tt(t), e.repo.replace("/", "__"));
2158
+ function _n(e, t = K()) {
2159
+ return d(Pt(t), e.repo.replace("/", "__"));
2133
2160
  }
2134
- function _n(e, t, s) {
2161
+ function Nn(e, t, s) {
2135
2162
  const n = zt(e.login);
2136
2163
  if (!b(d(t, ".git"))) {
2137
2164
  B(N(t), { recursive: !0 }), console.log(`nimpress view: cloning ${e.repo}`);
2138
- const r = e.login?.method === "gh" ? ee("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : ee("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...n } });
2165
+ const r = e.login?.method === "gh" ? te("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : te("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...n } });
2139
2166
  if (r.status !== 0) throw new Error(`[nimpress] view: clone of ${e.repo} failed
2140
2167
  ${r.stderr ?? ""}`);
2141
2168
  return;
2142
2169
  }
2143
2170
  if (s) return;
2144
- const o = oe(["fetch", "--depth", "1", "origin", "HEAD"], t, n);
2171
+ const o = re(["fetch", "--depth", "1", "origin", "HEAD"], t, n);
2145
2172
  if (!o.ok) throw new Error(`[nimpress] view: fetch of ${e.repo} failed
2146
2173
  ${o.out}`);
2147
- oe(["reset", "--hard", "FETCH_HEAD"], t), oe(["clean", "-fd"], t);
2174
+ re(["reset", "--hard", "FETCH_HEAD"], t), re(["clean", "-fd"], t);
2148
2175
  }
2149
- function Nn(e) {
2176
+ function Wn(e) {
2150
2177
  const t = ["pnpm-lock.yaml", "package.json"].map((s) => d(e, s)).find((s) => b(s));
2151
- return t ? ut("sha256").update(C(t)).digest("hex") : "";
2178
+ return t ? pt("sha256").update(C(t)).digest("hex") : "";
2152
2179
  }
2153
- function Wn(e) {
2154
- const t = d(e, J.paths.cache, "view", "lockfile.sha256"), s = Nn(e);
2180
+ function Tn(e) {
2181
+ const t = d(e, z.paths.cache, "view", "lockfile.sha256"), s = Wn(e);
2155
2182
  if (b(d(e, "node_modules")) && b(t) && C(t, "utf-8").trim() === s) return;
2156
- if (console.log("nimpress view: installing the docs site dependencies"), ee("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
2183
+ if (console.log("nimpress view: installing the docs site dependencies"), te("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
2157
2184
  B(N(t), { recursive: !0 }), W(t, `${s}
2158
2185
  `);
2159
2186
  }
2160
- function Tn(e) {
2161
- const t = as(), s = t === "darwin" ? ["open", e] : t === "win32" ? ["cmd", "/c", "start", "", e] : ["xdg-open", e], n = Ie(s[0], s.slice(1), { stdio: "ignore", detached: !0 });
2187
+ function Pn(e) {
2188
+ const t = cs(), s = t === "darwin" ? ["open", e] : t === "win32" ? ["cmd", "/c", "start", "", e] : ["xdg-open", e], n = Ie(s[0], s.slice(1), { stdio: "ignore", detached: !0 });
2162
2189
  n.on("error", () => console.log(`nimpress view: open ${e} in a browser`)), n.unref();
2163
2190
  }
2164
- function et(e, t) {
2191
+ function tt(e, t) {
2165
2192
  let s;
2166
2193
  return () => {
2167
2194
  s && clearTimeout(s), s = setTimeout(e, t);
2168
2195
  };
2169
2196
  }
2170
- function Pn(e, t) {
2197
+ function Rn(e, t) {
2171
2198
  t.added.length + t.modified.length + t.deleted.length !== 0 && console.log(`nimpress view: ${e} ${t.added.length} added, ${t.modified.length} modified, ${t.deleted.length} deleted`);
2172
2199
  }
2173
- function Rn(e) {
2200
+ function An(e) {
2174
2201
  const t = Ie("pnpm", ["exec", "nimpress", "dev"], { cwd: e, stdio: ["ignore", "pipe", "inherit"] }), s = new Promise((n, o) => {
2175
2202
  let r = !1;
2176
2203
  t.stdout?.on("data", (i) => {
2177
2204
  const c = i.toString();
2178
2205
  if (process.stdout.write(c), r) return;
2179
- const u = c.replace(/\x1b\[[0-9;]*m/g, "").match(/Local\s*:?\s+(https?:\/\/\S+)/);
2180
- u && (r = !0, n(u[1]));
2206
+ const p = c.replace(/\x1b\[[0-9;]*m/g, "").match(/Local\s*:?\s+(https?:\/\/\S+)/);
2207
+ p && (r = !0, n(p[1]));
2181
2208
  }), t.on("exit", (i) => {
2182
2209
  r || o(new Error(`[nimpress] view: the docs site dev server exited with ${i ?? "a signal"} before it printed a url`));
2183
2210
  }), t.on("error", (i) => o(new Error(`[nimpress] view: cannot run the docs site dev server, ${i.message}`)));
2184
2211
  });
2185
2212
  return { child: t, origin: s };
2186
2213
  }
2187
- async function An(e, t) {
2188
- const s = I(t, "offline"), n = await Fn(e, t), o = Cn(e), r = Lt(e), i = await we(e), c = _(t, "target") ? [`--target=${_(t, "target")}`] : [], u = [];
2189
- for (const p of n) {
2190
- const l = x(r, p.exportDir);
2191
- if (i.configFile && Re(e, i.resolved, [...c, `--out=${l}`]), !b(l))
2192
- throw new Error(`[nimpress] view: no export folder at ${l}, write the pages there or mark pages with export: and add a config`);
2193
- const m = Dn(p);
2194
- _n(p, m, s), Wn(m);
2214
+ async function Mn(e, t) {
2215
+ const s = M(t, "offline"), n = await Dn(e, t), o = En(e), r = Jt(e), i = await we(e), c = _(t, "target") ? [`--target=${_(t, "target")}`] : [], p = [];
2216
+ for (const l of n) {
2217
+ const u = x(r, l.exportDir);
2218
+ if (i.configFile && Re(e, i.resolved, [...c, `--out=${u}`]), !b(u))
2219
+ throw new Error(`[nimpress] view: no export folder at ${u}, write the pages there or mark pages with export: and add a config`);
2220
+ const m = _n(l);
2221
+ Nn(l, m, s), Tn(m);
2195
2222
  const f = await we(m);
2196
- if (!f.configFile) throw new Error(`[nimpress] view: ${p.repo} carries no nimpress config, so it is not a docs site`);
2197
- const h = bn(m, f.resolved.contentDir), g = kn(xn(m, h, o));
2223
+ if (!f.configFile) throw new Error(`[nimpress] view: ${l.repo} carries no nimpress config, so it is not a docs site`);
2224
+ const h = vn(m, f.resolved.contentDir), g = xn(Sn(m, h, o));
2198
2225
  if (!g.length)
2199
2226
  throw new Error(
2200
- `[nimpress] view: ${p.repo} has no target for ${o}, add it to nimpress.sources.json or the receiver defaults`
2227
+ `[nimpress] view: ${l.repo} has no target for ${o}, add it to nimpress.sources.json or the receiver defaults`
2201
2228
  );
2202
2229
  const w = x(m, h.contentRoot), k = x(m, f.resolved.contentDir);
2203
2230
  let j = [];
2204
2231
  const E = () => {
2205
- j.length && oe(["checkout", "--", ...j], m);
2232
+ j.length && re(["checkout", "--", ...j], m);
2206
2233
  const $ = /* @__PURE__ */ new Set();
2207
2234
  for (const y of g) {
2208
- const M = d(l, ...y.from.split("/").filter(Boolean)), P = d(w, ...y.to.split("/"));
2209
- Pn(y.to, Sn(M, P, y.mode));
2210
- for (const A of Y(M)) $.add(d(P, F(M, A)));
2235
+ const I = d(u, ...y.from.split("/").filter(Boolean)), P = d(w, ...y.to.split("/"));
2236
+ Rn(y.to, jn(I, P, y.mode));
2237
+ for (const A of Y(I)) $.add(d(P, F(I, A)));
2211
2238
  }
2212
- j = jn(k, $);
2213
- for (const y of j) q(y);
2239
+ j = Cn(k, $);
2240
+ for (const y of j) ee(y);
2214
2241
  j.length && console.log(`nimpress view: the local pages replace ${j.map((y) => F(m, y)).join(", ")}`);
2215
2242
  };
2216
2243
  E();
2217
- const v = He(l, { recursive: !0 }, et(E, 150));
2218
- if (u.push(() => v.close()), i.configFile) {
2219
- const $ = He(
2244
+ const v = Ue(u, { recursive: !0 }, tt(E, 150));
2245
+ if (p.push(() => v.close()), i.configFile) {
2246
+ const $ = Ue(
2220
2247
  x(e, i.resolved.contentDir),
2221
2248
  { recursive: !0 },
2222
- et(() => Re(e, i.resolved, [...c, `--out=${l}`]), 150)
2249
+ tt(() => Re(e, i.resolved, [...c, `--out=${u}`]), 150)
2223
2250
  );
2224
- u.push(() => $.close());
2251
+ p.push(() => $.close());
2225
2252
  }
2226
- const { child: R, origin: O } = Rn(m);
2227
- u.push(() => R.kill());
2253
+ const { child: R, origin: O } = An(m);
2254
+ p.push(() => R.kill());
2228
2255
  const T = `${(await O).replace(/\/$/, "")}/${g[0].to}`;
2229
- console.log(`nimpress view: ${o} inside ${p.repo} at ${T}`), I(t, "no-browser") || Tn(T);
2256
+ console.log(`nimpress view: ${o} inside ${l.repo} at ${T}`), M(t, "no-browser") || Pn(T);
2230
2257
  }
2231
2258
  const a = () => {
2232
- for (const p of u) p();
2259
+ for (const l of p) l();
2233
2260
  process.exit(0);
2234
2261
  };
2235
2262
  process.on("SIGINT", a), process.on("SIGTERM", a);
2236
2263
  }
2237
- async function Mn(e, t) {
2238
- const s = ie(t, 0);
2264
+ async function In(e, t) {
2265
+ const s = ne(t, 0);
2239
2266
  if (s !== "clear") throw new Error(`[nimpress] cache: unknown subcommand ${s ?? ""}, use clear`);
2240
- const n = I(t, "links"), o = I(t, "sites"), r = I(t, "local"), i = !n && !o && !r;
2267
+ const n = M(t, "links"), o = M(t, "sites"), r = M(t, "local"), i = !n && !o && !r;
2241
2268
  if (n || i) {
2242
- const c = Pt(), u = Object.keys(c.links).length;
2243
- Rt({ links: {} }), console.log(`nimpress cache: cleared ${u} links`);
2269
+ const c = Rt(), p = Object.keys(c.links).length;
2270
+ At({ links: {} }), console.log(`nimpress cache: cleared ${p} links`);
2244
2271
  }
2245
2272
  if (o || i) {
2246
- const c = Tt();
2247
- q(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
2273
+ const c = Pt();
2274
+ ee(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
2248
2275
  }
2249
2276
  if (r) {
2250
- const { resolved: c, configFile: u } = await we(e);
2251
- if (!u) throw new Error(`[nimpress] cache: --local needs a nimpress config in ${e}`);
2252
- const a = ot(e, c);
2253
- b(a) && q(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
2277
+ const { resolved: c, configFile: p } = await we(e);
2278
+ if (!p) throw new Error(`[nimpress] cache: --local needs a nimpress config in ${e}`);
2279
+ const a = rt(e, c);
2280
+ b(a) && ee(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
2254
2281
  }
2255
2282
  }
2256
- async function eo(e) {
2283
+ async function to(e) {
2257
2284
  const t = e[0] ?? "dev", s = e.slice(1), n = process.cwd();
2258
2285
  if (t === "init") {
2259
- fs(n);
2286
+ ds(n);
2260
2287
  return;
2261
2288
  }
2262
2289
  if (t === "skill") {
2263
- Ls(n, s);
2290
+ Js(n, s);
2264
2291
  return;
2265
2292
  }
2266
2293
  if (t === "plugin") {
2267
- Gs(n, s);
2294
+ Hs(n, s);
2268
2295
  return;
2269
2296
  }
2270
2297
  if (t === "mcp") {
2271
- fn(n);
2298
+ dn(n);
2272
2299
  return;
2273
2300
  }
2274
2301
  if (t === "completion") {
2275
- qs(n, s);
2302
+ en(n, s);
2276
2303
  return;
2277
2304
  }
2278
- if (t === "view" || t === "dev" && I(s, "view")) {
2279
- await An(n, s);
2305
+ if (t === "view" || t === "dev" && M(s, "view")) {
2306
+ await Mn(n, s);
2280
2307
  return;
2281
2308
  }
2282
2309
  if (t === "cache") {
2283
- await Mn(n, s);
2310
+ await In(n, s);
2284
2311
  return;
2285
2312
  }
2286
2313
  const { resolved: o } = await we(n);
2287
2314
  if (t === "seo") {
2288
- $n(n, o, s);
2315
+ yn(n, o, s);
2289
2316
  return;
2290
2317
  }
2291
2318
  if (t === "lint") {
2292
- await Os(n, o);
2319
+ await Fs(n, o);
2293
2320
  return;
2294
2321
  }
2295
2322
  if (t === "dev") {
2296
- await ys(n, o);
2323
+ await bs(n, o);
2297
2324
  return;
2298
2325
  }
2299
2326
  if (t === "build") {
2300
- await wt(n, o);
2327
+ await $t(n, o);
2301
2328
  return;
2302
2329
  }
2303
2330
  if (t === "guard") {
2304
- Ds(n, o, s);
2331
+ _s(n, o, s);
2305
2332
  return;
2306
2333
  }
2307
2334
  if (t === "modules") {
2308
- await Rs(n, o, s);
2335
+ await As(n, o, s);
2309
2336
  return;
2310
2337
  }
2311
2338
  if (t === "export") {
@@ -2315,8 +2342,8 @@ async function eo(e) {
2315
2342
  throw new Error(`[nimpress] unknown command: ${t}`);
2316
2343
  }
2317
2344
  export {
2318
- st as buildViteConfig,
2319
- Zt as indexHtml,
2345
+ nt as buildViteConfig,
2346
+ Vt as indexHtml,
2320
2347
  we as loadNimpressConfig,
2321
- eo as run
2348
+ to as run
2322
2349
  };