@nimtech/nimpress 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.es.js CHANGED
@@ -1,51 +1,51 @@
1
- import { d as B, c as Me, r as Ie, s as Zt, p as Vt, a as rt, b as pe, e as Kt, f as Yt, g as _e, h as it, i as Qt, j as at, k as Xt, l as qt, m as es, C as ge, n as ts, o as Le, q as He, w as me, t as ct, u as ss, v as ns, x as we, y as os, z as rs, A as is, B as as, D as cs, E as Ue, F as ls, G as us } from "./plugin-C8OdcVeq.js";
2
- import { join as d, dirname as N, relative as E, sep as L, extname as fe, resolve as x, basename as D } from "node:path";
3
- import { readdirSync as ae, existsSync as b, writeFileSync as W, mkdirSync as J, rmSync as te, readFileSync as C, statSync as lt, watch as Ze, openSync as ps } from "node:fs";
4
- import ue from "gray-matter";
5
- import { readFile as je, readdir as ms, writeFile as ee, mkdir as Ne, copyFile as ut } from "node:fs/promises";
6
- import { s as fs, r as $e } from "./typeMembers-CNvE92EX.js";
7
- import { createServer as pt, build as mt } from "vite";
8
- import { createHash as ft } from "node:crypto";
9
- import { spawnSync as se, spawn as ke } from "node:child_process";
10
- import { createInterface as dt } from "node:readline/promises";
11
- import { homedir as Q, platform as ds } from "node:os";
12
- import { parse as hs } from "yaml";
13
- import { fileURLToPath as ht } from "node:url";
14
- import { createInterface as gs } from "node:readline";
1
+ import { d as B, c as xe, r as Je, s as Qt, p as Xt, a as lt, b as me, e as qt, f as es, g as Te, h as ut, i as ts, j as pt, k as ss, l as ns, m as os, C as we, n as rs, o as Be, q as Ke, w as fe, t as mt, u as is, v as as, x as $e, y as cs, z as ls, A as us, B as ps, D as ms, E as Ye, F as fs, G as ds } from "./plugin-DOHMact8.js";
2
+ import { join as d, dirname as O, relative as E, sep as z, extname as de, resolve as j, basename as W } from "node:path";
3
+ import { readdirSync as ce, existsSync as y, writeFileSync as N, mkdirSync as L, rmSync as se, readFileSync as S, statSync as ft, watch as Qe, openSync as hs } from "node:fs";
4
+ import pe from "gray-matter";
5
+ import { readFile as Ee, readdir as gs, writeFile as te, mkdir as Pe, copyFile as dt } from "node:fs/promises";
6
+ import { s as ws, r as ye } from "./typeMembers-CNvE92EX.js";
7
+ import { createServer as ht, build as gt } from "vite";
8
+ import { createHash as wt } from "node:crypto";
9
+ import { spawnSync as ne, spawn as Se } from "node:child_process";
10
+ import { createInterface as $t } from "node:readline/promises";
11
+ import { homedir as Q, platform as $s } from "node:os";
12
+ import { parse as ys } from "yaml";
13
+ import { fileURLToPath as yt } from "node:url";
14
+ import { createInterface as bs } from "node:readline";
15
15
  function _(e, t) {
16
- return e.find((n) => n.startsWith(`--${t}=`))?.slice(t.length + 3);
16
+ return e.find((s) => s.startsWith(`--${t}=`))?.slice(t.length + 3);
17
17
  }
18
18
  function M(e, t) {
19
19
  return e.includes(`--${t}`);
20
20
  }
21
21
  function K(e, t) {
22
- return e.filter((n) => !n.startsWith("--"))[t];
22
+ return e.filter((s) => !s.startsWith("--"))[t];
23
23
  }
24
24
  function X(e, t = []) {
25
- let s;
25
+ let n;
26
26
  try {
27
- s = ae(e, { withFileTypes: !0 });
27
+ n = ce(e, { withFileTypes: !0 });
28
28
  } catch {
29
29
  return t;
30
30
  }
31
- for (const n of s) {
32
- const o = d(e, n.name);
33
- if (n.isDirectory()) {
34
- if (n.name === "node_modules" || n.name.startsWith(".")) continue;
31
+ for (const s of n) {
32
+ const o = d(e, s.name);
33
+ if (s.isDirectory()) {
34
+ if (s.name === "node_modules" || s.name.startsWith(".")) continue;
35
35
  X(o, t);
36
- } else n.isFile() && t.push(o);
36
+ } else s.isFile() && t.push(o);
37
37
  }
38
38
  return t;
39
39
  }
40
- function We(e, t, s) {
40
+ function Re(e, t, n) {
41
41
  if (t.length) {
42
42
  console.error(`${e} failed with ${t.length} problems`);
43
- for (const n of t) console.error(` ${n}`);
43
+ for (const s of t) console.error(` ${s}`);
44
44
  process.exit(1);
45
45
  }
46
- console.log(s);
46
+ console.log(n);
47
47
  }
48
- function ws() {
48
+ function vs() {
49
49
  return `import { defineConfig } from '@nimtech/nimpress/plugin'
50
50
 
51
51
  /**
@@ -181,7 +181,7 @@ export default defineConfig({
181
181
  })
182
182
  `;
183
183
  }
184
- function $s() {
184
+ function ks() {
185
185
  return JSON.stringify(
186
186
  {
187
187
  $schema: "./node_modules/@nimtech/nimpress/config.schema.json",
@@ -195,7 +195,7 @@ function $s() {
195
195
  ) + `
196
196
  `;
197
197
  }
198
- function ys(e) {
198
+ function xs(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 bs(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, $s()), console.log(`nimpress init: ${s} written, field descriptions come from the referenced config.schema.json`)) : (W(t, ws()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
240
+ function Ss(e) {
241
+ const t = d(e, "nimpress.config.ts"), n = d(e, "nimpress.config.json"), s = M(process.argv.slice(2), "json");
242
+ !y(t) && !y(n) && (s ? (N(n, ks()), console.log(`nimpress init: ${n} written, field descriptions come from the referenced config.schema.json`)) : (N(t, vs()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
243
243
  const o = d(e, B.contentDir);
244
- (!b(o) || ae(o).length === 0) && (J(o, { recursive: !0 }), W(
244
+ (!y(o) || ce(o).length === 0) && (L(o, { recursive: !0 }), N(
245
245
  d(o, "index.md"),
246
246
  `---
247
247
  title: Home
@@ -250,214 +250,220 @@ title: Home
250
250
  Welcome to your Nimpress site.
251
251
  `
252
252
  ));
253
- const i = ys(B.contentDir);
253
+ const i = xs(B.contentDir);
254
254
  for (const c of ["CLAUDE.md", "AGENTS.md"]) {
255
255
  const l = d(e, c);
256
- b(l) || (W(l, i), console.log(`nimpress init: ${c} written, pointing at the packaged rules in node_modules/@nimtech/nimpress/.claude/rules/`));
256
+ y(l) || (N(l, 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 vs = { vue: "vueStory", svelte: "svelteStory" }, ks = { vue: ".svelte", svelte: ".vue" };
260
- function ce(e) {
259
+ const js = { vue: "vueStory", svelte: "svelteStory" }, Cs = { vue: ".svelte", svelte: ".vue" };
260
+ function le(e) {
261
261
  return `run nimpress modules update ${e}`;
262
262
  }
263
- async function xs(e) {
263
+ async function Es(e) {
264
264
  let t;
265
265
  try {
266
- t = await ms(e, { withFileTypes: !0 });
266
+ t = await gs(e, { withFileTypes: !0 });
267
267
  } catch {
268
268
  return [];
269
269
  }
270
- return t.filter((s) => s.isFile() && /\.story\.tsx?$/.test(s.name)).map((s) => s.name);
270
+ return t.filter((n) => n.isFile() && /\.story\.tsx?$/.test(n.name)).map((n) => n.name);
271
271
  }
272
- function Ss(e, t) {
273
- const s = t === "integer" ? "number" : t;
274
- return e.every((n) => typeof n === s);
272
+ function Os(e, t) {
273
+ const n = t === "integer" ? "number" : t;
274
+ return e.every((s) => typeof s === n);
275
275
  }
276
- function js(e, t, s, n, o) {
277
- const r = [], i = n.properties ?? {}, c = o.properties ?? {};
276
+ function Fs(e, t, n, s, o) {
277
+ const r = [], i = s.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, ${ce(t)}`);
279
+ m in i || r.push(`${e}: prop ${m} is missing from the schema, ${le(t)}`);
280
280
  for (const m of Object.keys(i))
281
- m in c || r.push(`${e}: schema prop ${m} has no counterpart in ${s}, remove it or restore the prop`);
281
+ m in c || r.push(`${e}: schema prop ${m} has no counterpart in ${n}, 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}, ${ce(t)}`
286
- ), f.enum && h.type && !Ss(f.enum, h.type) && r.push(`${e}: prop ${m} enum values mismatch the source type ${h.type}`), f.enum && h.enum)) {
287
- const g = new Set(h.enum.map((k) => JSON.stringify(k))), w = f.enum.filter((k) => !g.has(JSON.stringify(k)));
285
+ `${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${le(t)}`
286
+ ), f.enum && h.type && !Os(f.enum, h.type) && r.push(`${e}: prop ${m} enum values mismatch the source type ${h.type}`), f.enum && h.enum)) {
287
+ const g = new Set(h.enum.map((v) => JSON.stringify(v))), w = f.enum.filter((v) => !g.has(JSON.stringify(v)));
288
288
  w.length && r.push(
289
- `${e}: prop ${m} enum carries ${w.map((k) => JSON.stringify(k)).join(", ")} outside the source union`
289
+ `${e}: prop ${m} enum carries ${w.map((v) => JSON.stringify(v)).join(", ")} outside the source union`
290
290
  );
291
291
  }
292
292
  }
293
- const l = n.slots ?? {}, a = o.slots ?? {};
293
+ const l = s.slots ?? {}, a = o.slots ?? {};
294
294
  for (const m of Object.keys(a))
295
- m in l || r.push(`${e}: slot ${m} is missing from the schema, ${ce(t)}`);
295
+ m in l || r.push(`${e}: slot ${m} is missing from the schema, ${le(t)}`);
296
296
  for (const m of Object.keys(l))
297
- m in a || r.push(`${e}: schema slot ${m} has no counterpart in ${s}`);
298
- const u = new Set(n.emits ?? []), p = new Set(o.emits ?? []);
299
- for (const m of p)
300
- u.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${ce(t)}`);
297
+ m in a || r.push(`${e}: schema slot ${m} has no counterpart in ${n}`);
298
+ const p = new Set(s.emits ?? []), u = new Set(o.emits ?? []);
301
299
  for (const m of u)
302
- p.has(m) || r.push(`${e}: schema emit ${m} has no counterpart in ${s}`);
300
+ p.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${le(t)}`);
301
+ for (const m of p)
302
+ u.has(m) || r.push(`${e}: schema emit ${m} has no counterpart in ${n}`);
303
303
  return r;
304
304
  }
305
- async function gt(e, t, s) {
306
- const n = s ? [s] : Object.keys(t.modules.systems), o = [], r = await Me(e, t.contentDir);
307
- for (const i of n) {
305
+ async function bt(e, t, n) {
306
+ const s = n ? [n] : Object.keys(t.modules.systems), o = [], r = await xe(e, t.contentDir);
307
+ for (const i of s) {
308
308
  const c = t.modules.systems[i];
309
309
  if (!c) {
310
310
  o.push(`${i}: not a configured system`);
311
311
  continue;
312
312
  }
313
- const l = c.framework, a = vs[l === "vue" ? "svelte" : "vue"], u = ks[l];
314
- for (const p of r) {
315
- if (p.system !== i) continue;
316
- const m = N(p.pageFile), f = E(e, m).split(L).join("/"), h = await xs(m);
317
- h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${p.component}`);
313
+ const l = c.framework, a = js[l === "vue" ? "svelte" : "vue"], p = Cs[l];
314
+ for (const u of r) {
315
+ if (u.system !== i) continue;
316
+ const m = O(u.pageFile), f = E(e, m).split(z).join("/"), h = await Es(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
- for (const F of h) {
319
+ for (const D of h) {
320
320
  let T;
321
321
  try {
322
- T = await je(d(m, F), "utf-8");
322
+ T = await Ee(d(m, D), "utf-8");
323
323
  } catch {
324
324
  continue;
325
325
  }
326
- (/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(F), T.includes(a) && o.push(`${f}/${F}: uses ${a} inside the ${l} system ${i}`);
326
+ (/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(D), T.includes(a) && o.push(`${f}/${D}: uses ${a} inside the ${l} system ${i}`);
327
327
  for (const $ of T.matchAll(/from\s+['"]([^'"]+)['"]/g))
328
- fe($[1]) === u && o.push(`${f}/${F}: imports ${$[1]} inside the ${l} system ${i}`);
328
+ de($[1]) === p && o.push(`${f}/${D}: imports ${$[1]} inside the ${l} system ${i}`);
329
329
  }
330
- const w = Ie(e, t.modules, i, p.component, p.file);
331
- if (w && fe(w.componentFile) === u && o.push(
330
+ const w = Je(e, t.modules, i, u.component, u.file);
331
+ if (w && de(w.componentFile) === p && o.push(
332
332
  `${f}: component file ${E(e, w.componentFile)} mismatches the ${l} system ${i}`
333
- ), b(d(m, "schema.json")) && b(d(m, "schema.yml"))) {
333
+ ), y(d(m, "schema.json")) && y(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 = Zt(m);
338
- if (!k) {
339
- o.push(`${f}: schema file missing, ${ce(p.component)}`);
337
+ const v = Qt(m);
338
+ if (!v) {
339
+ o.push(`${f}: schema file missing, ${le(u.component)}`);
340
340
  continue;
341
341
  }
342
- let j;
342
+ let k;
343
343
  try {
344
- j = await je(k.path, "utf-8");
344
+ k = await Ee(v.path, "utf-8");
345
345
  } catch {
346
- o.push(`${f}: ${k.form} schema unreadable`);
346
+ o.push(`${f}: ${v.form} schema unreadable`);
347
347
  continue;
348
348
  }
349
- let O;
349
+ let F;
350
350
  try {
351
- O = Vt(j, k.form);
351
+ F = Xt(k, v.form);
352
352
  } catch {
353
- o.push(`${f}: schema is not valid ${k.form}, fix it by hand`);
353
+ o.push(`${f}: schema is not valid ${v.form}, fix it by hand`);
354
354
  continue;
355
355
  }
356
- const v = new Set(Object.keys(O.properties ?? {}));
357
- for (const F of await rt(m))
358
- if (!g.has(F.file))
359
- for (const T of Object.keys(F.props ?? {}))
360
- v.has(T) || o.push(`${f}/${F.file}: prop ${T} is absent from the schema, ${ce(p.component)}`);
361
- const R = w ? await je(w.componentFile, "utf-8").catch(() => {
356
+ const x = new Set(Object.keys(F.properties ?? {}));
357
+ for (const D of await lt(m))
358
+ if (!g.has(D.file))
359
+ for (const T of Object.keys(D.props ?? {}))
360
+ x.has(T) || o.push(`${f}/${D.file}: prop ${T} is absent from the schema, ${le(u.component)}`);
361
+ const R = w ? await Ee(w.componentFile, "utf-8").catch(() => {
362
362
  }) : void 0;
363
363
  if (w) {
364
- const F = await pe(w.componentFile, l, p.component);
365
- if (F) {
366
- const T = fs(p.component, F.props, F.slots, F.emits);
364
+ const D = await me(w.componentFile, l, u.component);
365
+ if (D) {
366
+ const T = ws(u.component, D.props, D.slots, D.emits);
367
367
  o.push(
368
- ...js(f, p.component, E(e, w.componentFile), O, T)
368
+ ...Fs(f, u.component, E(e, w.componentFile), F, T)
369
369
  );
370
370
  }
371
371
  }
372
- Kt(Yt(p.component, O, { sourceFile: w?.componentFile, sourceText: R }));
372
+ qt(es(u.component, F, { sourceFile: w?.componentFile, sourceText: R }));
373
373
  }
374
374
  }
375
- return _e(e), o;
375
+ return Te(e), o;
376
376
  }
377
- function wt(e) {
377
+ function vt(e) {
378
378
  return Object.entries(e.modules.systems).filter(([, t]) => t.visibility !== "dev-only").map(([t]) => t);
379
379
  }
380
- async function $t(e, t, s) {
381
- for (const n of s)
380
+ async function kt(e, t, n) {
381
+ for (const s of n)
382
382
  try {
383
- await (await pt(await at(e, t, n, "serve"))).listen(), console.log(`nimpress modules: ${n} harness on port ${Xt(t.modules, n)}`);
383
+ await (await ht(await pt(e, t, s, "serve"))).listen(), console.log(`nimpress modules: ${s} harness on port ${ss(t.modules, s)}`);
384
384
  } catch (o) {
385
- console.warn(`nimpress modules: harness for ${n} failed to start: ${String(o)}`);
385
+ console.warn(`nimpress modules: harness for ${s} failed to start: ${String(o)}`);
386
386
  }
387
387
  }
388
- async function yt(e, t, s) {
389
- for (const n of s)
390
- await mt(await at(e, t, n, "build")), console.log(`nimpress modules: built ${n}`);
388
+ async function xt(e, t, n) {
389
+ const s = await xe(e, t.contentDir);
390
+ for (const o of n) {
391
+ if (!s.some((r) => r.system === o)) {
392
+ console.log(`nimpress modules: ${o} has no component pages, no harness built`);
393
+ continue;
394
+ }
395
+ await gt(await pt(e, t, o, "build")), console.log(`nimpress modules: built ${o}`);
396
+ }
391
397
  }
392
- async function Cs(e, t) {
393
- const s = await pt(await it({ cwd: e, command: "serve", resolved: t }));
394
- await s.listen(), await $t(e, t, Object.keys(t.modules.systems)), s.printUrls(), s.bindCLIShortcuts({ print: !0 });
398
+ async function Ds(e, t) {
399
+ const n = await ht(await ut({ cwd: e, command: "serve", resolved: t }));
400
+ await n.listen(), await kt(e, t, Object.keys(t.modules.systems)), n.printUrls(), n.bindCLIShortcuts({ print: !0 });
395
401
  }
396
- async function bt(e, t) {
397
- const s = d(e, "index.html"), n = !b(s);
398
- n && W(s, Qt(t));
402
+ async function St(e, t) {
403
+ const n = d(e, "index.html"), s = !y(n);
404
+ s && N(n, ts(t));
399
405
  const o = () => {
400
- n && te(s, { force: !0 });
406
+ s && se(n, { force: !0 });
401
407
  }, r = () => {
402
408
  o(), process.exit(130);
403
409
  };
404
410
  process.once("SIGINT", r), process.once("SIGTERM", r);
405
411
  try {
406
- await mt(await it({ cwd: e, command: "build", resolved: t, htmlInput: s }));
412
+ await gt(await ut({ cwd: e, command: "build", resolved: t, htmlInput: n }));
407
413
  } finally {
408
414
  process.off("SIGINT", r), process.off("SIGTERM", r), o();
409
415
  }
410
- await yt(e, t, wt(t));
416
+ await xt(e, t, vt(t));
411
417
  }
412
- const Es = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], Os = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Ve = /^[a-z0-9][a-z0-9.-]*$/, Fs = /^[A-Z][A-Za-z0-9]*$/;
413
- function Ds(e) {
418
+ const Ws = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], _s = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Xe = /^[a-z0-9][a-z0-9.-]*$/, Ns = /^[A-Z][A-Za-z0-9]*$/;
419
+ function Ts(e) {
414
420
  const t = e.resolve;
415
421
  if (!t || typeof t != "object") return [];
416
- const s = t.alias;
417
- return !s || typeof s != "object" ? [] : Array.isArray(s) ? s.flatMap((n) => {
418
- if (!n || typeof n != "object") return [];
419
- const { find: o, replacement: r } = n;
422
+ const n = t.alias;
423
+ return !n || typeof n != "object" ? [] : Array.isArray(n) ? n.flatMap((s) => {
424
+ if (!s || typeof s != "object") return [];
425
+ const { find: o, replacement: r } = s;
420
426
  return typeof o != "string" || typeof r != "string" ? [] : [{ find: o, replacement: r }];
421
- }) : Object.entries(s).flatMap(
422
- ([n, o]) => typeof o == "string" ? [{ find: n, replacement: o }] : []
427
+ }) : Object.entries(n).flatMap(
428
+ ([s, o]) => typeof o == "string" ? [{ find: s, replacement: o }] : []
423
429
  );
424
430
  }
425
- function _s(e) {
426
- const t = [], s = [
431
+ function Ps(e) {
432
+ const t = [], n = [
427
433
  /(?:^|\n)[ \t]*import[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
428
434
  /(?:^|\n)[ \t]*export[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
429
435
  /(?:^|\n)[ \t]*import[ \t]+['"]([^'"\n]+)['"]/g,
430
436
  /\bimport\(\s*['"]([^'"\n]+)['"]\s*\)/g
431
437
  ];
432
- for (const n of s) {
438
+ for (const s of n) {
433
439
  let o;
434
- for (; o = n.exec(e); ) t.push(o[1]);
440
+ for (; o = s.exec(e); ) t.push(o[1]);
435
441
  }
436
442
  return t;
437
443
  }
438
- function Ke(e) {
439
- return Os.some((t) => {
440
- const s = e + t;
441
- if (!b(s)) return !1;
444
+ function qe(e) {
445
+ return _s.some((t) => {
446
+ const n = e + t;
447
+ if (!y(n)) return !1;
442
448
  try {
443
- return lt(s).isFile();
449
+ return ft(n).isFile();
444
450
  } catch {
445
451
  return !1;
446
452
  }
447
453
  });
448
454
  }
449
- function Ns(e, t) {
450
- const s = x(e, t.contentDir), n = Ds(t.vite), o = [];
451
- for (const r of X(s)) {
452
- if (!Es.some((l) => r.endsWith(l))) continue;
455
+ function Rs(e, t) {
456
+ const n = j(e, t.contentDir), s = Ts(t.vite), o = [];
457
+ for (const r of X(n)) {
458
+ if (!Ws.some((l) => r.endsWith(l))) continue;
453
459
  let i;
454
460
  try {
455
- i = C(r, "utf-8");
461
+ i = S(r, "utf-8");
456
462
  } catch {
457
463
  continue;
458
464
  }
459
- const c = E(s, r).split(L).join("/");
460
- for (const l of _s(i)) {
465
+ const c = E(n, r).split(z).join("/");
466
+ for (const l of Ps(i)) {
461
467
  if (l.includes("_shared/") || l.startsWith("_shared")) {
462
468
  o.push(
463
469
  `${c}: imports ${l}, shared fixture folders are forbidden, stories are self contained and shared setup lives in a group harness component`
@@ -466,130 +472,130 @@ function Ns(e, t) {
466
472
  }
467
473
  const a = l.split("?")[0];
468
474
  if (a.startsWith("./") || a.startsWith("../")) {
469
- const p = x(N(r), a);
470
- Ke(p) || o.push(`${c}: unresolved import ${l}, fix the path or create the file`);
475
+ const u = j(O(r), a);
476
+ qe(u) || o.push(`${c}: unresolved import ${l}, fix the path or create the file`);
471
477
  continue;
472
478
  }
473
- const u = n.find((p) => a === p.find || a.startsWith(p.find + "/"));
474
- if (u) {
475
- const p = x(e, u.replacement + a.slice(u.find.length));
476
- Ke(p) || o.push(`${c}: unresolved import ${l} via alias ${u.find}`);
479
+ const p = s.find((u) => a === u.find || a.startsWith(u.find + "/"));
480
+ if (p) {
481
+ const u = j(e, p.replacement + a.slice(p.find.length));
482
+ qe(u) || o.push(`${c}: unresolved import ${l} via alias ${p.find}`);
477
483
  }
478
484
  }
479
485
  }
480
486
  return o;
481
487
  }
482
- function Ws(e, t) {
483
- const s = x(e, t.contentDir), n = [];
484
- if (!b(s)) return [`${t.contentDir}: contentDir does not exist`];
488
+ function As(e, t) {
489
+ const n = j(e, t.contentDir), s = [];
490
+ if (!y(n)) return [`${t.contentDir}: contentDir does not exist`];
485
491
  const o = /* @__PURE__ */ new Map();
486
492
  let r, i;
487
493
  const c = /* @__PURE__ */ new Map();
488
- for (const a of X(s)) {
489
- const u = E(s, a).split(L).join("/"), p = N(a), m = D(a);
494
+ for (const a of X(n)) {
495
+ const p = E(n, a).split(z).join("/"), u = O(a), m = W(a);
490
496
  if (m.endsWith(".md")) {
491
- const f = c.get(p) ?? [];
492
- f.push(a), c.set(p, f);
497
+ const f = c.get(u) ?? [];
498
+ f.push(a), c.set(u, f);
493
499
  const h = m.slice(0, -3);
494
- Ve.test(h) || n.push(`${u}: 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`);
500
+ Xe.test(h) || s.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`);
495
501
  let g;
496
502
  try {
497
- g = ue(C(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
503
+ g = pe(S(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
498
504
  } catch {
499
505
  continue;
500
506
  }
501
- if (g?.type === "glossary" && (i ? n.push(`${u}: second type glossary page in the site, ${E(s, i).split(L).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(ue(C(a, "utf-8")).content) || n.push(`${u}: 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(`${u}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? n.push(`${u}: second type 404 page in the site, ${E(s, r).split(L).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
502
- const w = o.get(p);
503
- w ? n.push(`${u}: second type component page in one folder, ${E(s, w).split(L).join("/")} already owns it, one component per folder`) : o.set(p, a);
507
+ if (g?.type === "glossary" && (i ? s.push(`${p}: second type glossary page in the site, ${E(n, i).split(z).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(pe(S(a, "utf-8")).content) || s.push(`${p}: type glossary needs a definition list body, term lines followed by lines starting with a colon`)), g?.type === "section" && !a.endsWith(`${z}index.md`) && s.push(`${p}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? s.push(`${p}: second type 404 page in the site, ${E(n, r).split(z).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
508
+ const w = o.get(u);
509
+ w ? s.push(`${p}: second type component page in one folder, ${E(n, w).split(z).join("/")} already owns it, one component per folder`) : o.set(u, a);
504
510
  }
505
511
  if (g?.type === "dbml") {
506
512
  const w = typeof g.spec == "string" ? g.spec : "";
507
- w ? b(x(p, w)) || n.push(`${u}: spec ${w} does not resolve, create the file or fix the path`) : n.push(`${u}: type dbml needs a spec field pointing at the .dbml file`);
513
+ w ? y(j(u, w)) || s.push(`${p}: spec ${w} does not resolve, create the file or fix the path`) : s.push(`${p}: type dbml needs a spec field pointing at the .dbml file`);
508
514
  }
509
- g?.type === "changelog" && typeof g.path == "string" && n.push(`${u}: changelog entries never set path, the collection mounts at the folder route, remove the path field`);
515
+ g?.type === "changelog" && typeof g.path == "string" && s.push(`${p}: changelog entries never set path, the collection mounts at the folder route, remove the path field`);
510
516
  }
511
- if (m.endsWith(".css") && !m.startsWith("_") && D(N(a)) === "styles" && N(N(a)) === s) {
517
+ if (m.endsWith(".css") && !m.startsWith("_") && W(O(a)) === "styles" && O(O(a)) === n) {
512
518
  const f = m.replace(/\.css$/, "");
513
- ge.includes(f) || n.push(`${u}: ${f} is not a component class root, name the file after one of ${ge.join(", ")}`);
519
+ we.includes(f) || s.push(`${p}: ${f} is not a component class root, name the file after one of ${we.join(", ")}`);
514
520
  continue;
515
521
  }
516
522
  if (m.endsWith(".css") && !m.startsWith("_") && m.split(".").length > 2) {
517
- const f = m.split(".")[0], h = ts(m, f);
518
- if (h && b(d(N(a), `${f}.md`))) {
519
- ge.includes(h) || n.push(`${u}: ${h} is not a component class root, name the file after one of ${ge.join(", ")}`);
523
+ const f = m.split(".")[0], h = rs(m, f);
524
+ if (h && y(d(O(a), `${f}.md`))) {
525
+ we.includes(h) || s.push(`${p}: ${h} is not a component class root, name the file after one of ${we.join(", ")}`);
520
526
  continue;
521
527
  }
522
528
  }
523
529
  if (m.endsWith(".css") && !m.startsWith("_")) {
524
530
  const f = a.replace(/\.css$/, ".md");
525
- b(f) || n.push(`${u}: page css without a matching ${D(f)}, page styles are named after the page they scope`);
531
+ y(f) || s.push(`${p}: page css without a matching ${W(f)}, page styles are named after the page they scope`);
526
532
  }
527
533
  }
528
- for (const [a, u] of c) {
529
- const p = E(s, a).split(L).join("/") || ".", m = o.has(a);
534
+ for (const [a, p] of c) {
535
+ const u = E(n, a).split(z).join("/") || ".", m = o.has(a);
530
536
  let f = [];
531
537
  try {
532
- f = ae(a);
538
+ f = ce(a);
533
539
  } catch {
534
540
  continue;
535
541
  }
536
- f.filter((g) => /\.story\.tsx?$/.test(g)).length && !m && n.push(`${p}: story files without a type component page, add the component index.md or move the stories`);
542
+ f.filter((g) => /\.story\.tsx?$/.test(g)).length && !m && s.push(`${u}: story files without a type component page, add the component index.md or move the stories`);
537
543
  for (const g of ["schema.json", "schema.yml"])
538
- f.includes(g) && !m && n.push(`${p}: ${g} without a type component page, it belongs beside the component index.md`);
539
- if (m && u.length > 1) {
540
- const g = u.filter((w) => w !== o.get(a)).map((w) => D(w));
541
- n.push(`${p}: a component folder holds exactly one md file, move ${g.join(", ")} out`);
544
+ f.includes(g) && !m && s.push(`${u}: ${g} without a type component page, it belongs beside the component index.md`);
545
+ if (m && p.length > 1) {
546
+ const g = p.filter((w) => w !== o.get(a)).map((w) => W(w));
547
+ s.push(`${u}: a component folder holds exactly one md file, move ${g.join(", ")} out`);
542
548
  }
543
549
  }
544
550
  const l = (a) => {
545
- let u;
551
+ let p;
546
552
  try {
547
- u = ae(a, { withFileTypes: !0 });
553
+ p = ce(a, { withFileTypes: !0 });
548
554
  } catch {
549
555
  return;
550
556
  }
551
- for (const p of u)
552
- if (p.isDirectory() && !(p.name.startsWith(".") || p.name === "node_modules")) {
553
- if (!Ve.test(p.name) && !Fs.test(p.name)) {
554
- const m = E(s, d(a, p.name)).split(L).join("/");
555
- n.push(`${m}/: folder names are lowercase kebab case, or PascalCase for component and group folders, rename it`);
557
+ for (const u of p)
558
+ if (u.isDirectory() && !(u.name.startsWith(".") || u.name === "node_modules")) {
559
+ if (!Xe.test(u.name) && !Ns.test(u.name)) {
560
+ const m = E(n, d(a, u.name)).split(z).join("/");
561
+ s.push(`${m}/: folder names are lowercase kebab case, or PascalCase for component and group folders, rename it`);
556
562
  }
557
- l(d(a, p.name));
563
+ l(d(a, u.name));
558
564
  }
559
565
  };
560
- return l(s), n;
566
+ return l(n), s;
561
567
  }
562
- async function Ts(e, t) {
563
- const s = Le(e, t, "lint"), n = () => te(s, { recursive: !0, force: !0 }), o = () => {
564
- n(), process.exit(130);
568
+ async function Ms(e, t) {
569
+ const n = Be(e, t, "lint"), s = () => se(n, { recursive: !0, force: !0 }), o = () => {
570
+ s(), process.exit(130);
565
571
  };
566
572
  process.once("SIGINT", o), process.once("SIGTERM", o);
567
573
  try {
568
- return await bt(e, { ...t, paths: { ...t.paths, out: s } }), [];
574
+ return await St(e, { ...t, paths: { ...t.paths, out: n } }), [];
569
575
  } catch (r) {
570
576
  return (r instanceof Error ? r.message : String(r)).split(`
571
577
  `).filter((c) => c.trim()).map((c) => `build: ${c.trim()}`);
572
578
  } finally {
573
- process.off("SIGINT", o), process.off("SIGTERM", o), n();
579
+ process.off("SIGINT", o), process.off("SIGTERM", o), s();
574
580
  }
575
581
  }
576
- async function Ps(e, t) {
577
- const s = process.argv.slice(2), n = [
578
- ...Ws(e, t),
579
- ...(qt(e, t.pageTypes ?? {}), await es(e, t.contentDir)),
580
- ...Ns(e, t),
581
- ...await gt(e, t)
582
+ async function Is(e, t) {
583
+ const n = process.argv.slice(2), s = [
584
+ ...As(e, t),
585
+ ...(ns(e, t.pageTypes ?? {}), await os(e, t.contentDir)),
586
+ ...Rs(e, t),
587
+ ...await bt(e, t)
582
588
  ];
583
- if (n.length) {
584
- We("nimpress lint", n, "");
589
+ if (s.length) {
590
+ Re("nimpress lint", s, "");
585
591
  return;
586
592
  }
587
- if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), M(s, "no-build")) return;
593
+ if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), M(n, "no-build")) return;
588
594
  console.log("nimpress lint: building to verify the output compiles");
589
- const o = await Ts(e, t);
590
- We("nimpress lint", o, "nimpress lint: build ok, everything passes");
595
+ const o = await Ms(e, t);
596
+ Re("nimpress lint", o, "nimpress lint: build ok, everything passes");
591
597
  }
592
- const Rs = {
598
+ const Ls = {
593
599
  ".json": "application/json",
594
600
  ".xml": "application/rss+xml",
595
601
  ".html": "text/html",
@@ -602,176 +608,176 @@ const Rs = {
602
608
  ".webp": "image/webp",
603
609
  ".pdf": "application/pdf"
604
610
  };
605
- function As(e, t, s) {
606
- const n = s[0], o = d(e, _(s, "dist") ?? t.paths.out), r = `/${t.paths.guarded}/`, i = d(o, "access.json");
607
- if (!b(i))
611
+ function zs(e, t, n) {
612
+ const s = n[0], o = d(e, _(n, "dist") ?? t.paths.out), r = `/${t.paths.guarded}/`, i = d(o, "access.json");
613
+ if (!y(i))
608
614
  throw new Error(`[nimpress] guard: ${i} not found, run a build first`);
609
- const c = JSON.parse(C(i, "utf-8"));
610
- if (n === "map") {
611
- const l = He(o, t), a = d(o, "guard.map.json"), u = b(a) ? JSON.parse(C(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, p = b(l) ? X(l) : [], m = u.prefix ?? r, f = p.map((w) => {
612
- const k = E(l, w).split("\\").join("/"), j = k.split("/")[0] ?? "", O = [
615
+ const c = JSON.parse(S(i, "utf-8"));
616
+ if (s === "map") {
617
+ const l = Ke(o, t), a = d(o, "guard.map.json"), p = y(a) ? JSON.parse(S(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, u = y(l) ? X(l) : [], m = p.prefix ?? r, f = u.map((w) => {
618
+ const v = E(l, w).split("\\").join("/"), k = v.split("/")[0] ?? "", F = [
613
619
  ...new Set(
614
- Object.values(u.routes ?? {}).filter((R) => R.bundle === j && R.gate).map((R) => R.gate)
620
+ Object.values(p.routes ?? {}).filter((R) => R.bundle === k && R.gate).map((R) => R.gate)
615
621
  )
616
- ], v = C(w);
622
+ ], x = S(w);
617
623
  return {
618
- path: `${m}${k}`,
619
- file: k,
620
- bundle: j,
621
- sha256: ft("sha256").update(v).digest("hex"),
622
- size: lt(w).size,
623
- mime: Rs[fe(w).toLowerCase()] ?? "application/octet-stream",
624
- gates: O
624
+ path: `${m}${v}`,
625
+ file: v,
626
+ bundle: k,
627
+ sha256: wt("sha256").update(x).digest("hex"),
628
+ size: ft(w).size,
629
+ mime: Ls[de(w).toLowerCase()] ?? "application/octet-stream",
630
+ gates: F
625
631
  };
626
- }), h = _(s, "out"), g = h ? d(e, h) : a;
627
- W(
632
+ }), h = _(n, "out"), g = h ? d(e, h) : a;
633
+ N(
628
634
  g,
629
- JSON.stringify({ ...u, prefix: m, files: f }, null, 2) + `
635
+ JSON.stringify({ ...p, prefix: m, files: f }, null, 2) + `
630
636
  `
631
637
  ), console.log(`nimpress guard: mapped ${f.length} guarded files to ${g}`);
632
638
  return;
633
639
  }
634
- if (n === "apply") {
635
- const l = _(s, "map");
640
+ if (s === "apply") {
641
+ const l = _(n, "map");
636
642
  if (!l) throw new Error("[nimpress] guard apply requires --map=<uploaded mapping json>");
637
- const a = JSON.parse(C(d(e, l), "utf-8"));
643
+ const a = JSON.parse(S(d(e, l), "utf-8"));
638
644
  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((u) => ({
640
- path: u.path,
641
- file: u.file,
642
- bundle: u.bundle,
643
- asset_id: u.asset_id,
644
- url: u.url
645
- })), W(i, JSON.stringify(c, null, 2) + `
646
- `), te(He(o, t), { recursive: !0, force: !0 }), te(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
645
+ c.base = a.base.replace(/\/$/, ""), c.files = (a.files ?? []).map((p) => ({
646
+ path: p.path,
647
+ file: p.file,
648
+ bundle: p.bundle,
649
+ asset_id: p.asset_id,
650
+ url: p.url
651
+ })), N(i, JSON.stringify(c, null, 2) + `
652
+ `), se(Ke(o, t), { recursive: !0, force: !0 }), se(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
647
653
  return;
648
654
  }
649
655
  throw new Error("[nimpress] guard expects map or apply");
650
656
  }
651
- function vt(e) {
652
- const t = fe(e);
657
+ function jt(e) {
658
+ const t = de(e);
653
659
  return t === ".vue" ? "vue" : t === ".svelte" ? "svelte" : null;
654
660
  }
655
- async function Je(e, t, s, n, o) {
656
- const i = (await Me(e, t.contentDir)).find((m) => m.system === s && m.component === n);
661
+ async function Ge(e, t, n, s, o) {
662
+ const i = (await xe(e, t.contentDir)).find((m) => m.system === n && m.component === s);
657
663
  if (!i)
658
- return console.warn(`[nimpress] modules story: no type component page found for ${s}/${n}`), null;
659
- const c = Ie(e, t.modules, s, n, i.file);
664
+ return console.warn(`[nimpress] modules story: no type component page found for ${n}/${s}`), null;
665
+ const c = Je(e, t.modules, n, s, i.file);
660
666
  if (!c)
661
- return console.warn(`[nimpress] modules story: no source found for ${s}/${n}`), null;
662
- const l = o ?? vt(c.componentFile);
667
+ return console.warn(`[nimpress] modules story: no source found for ${n}/${s}`), null;
668
+ const l = o ?? jt(c.componentFile);
663
669
  if (!l)
664
670
  throw new Error(
665
671
  `[nimpress] modules story: failed to detect framework for ${c.componentFile}, pass --framework=vue or --framework=svelte`
666
672
  );
667
- const a = l === "vue" ? "vueStory" : "svelteStory", u = `import { ${a} } from '@nimtech/nimpress/story'
673
+ const a = l === "vue" ? "vueStory" : "svelteStory", p = `import { ${a} } from '@nimtech/nimpress/story'
668
674
 
669
675
  // story: Default
670
676
  export default ${a}({
671
677
  name: "Default"
672
678
  })
673
- `, p = d(N(i.pageFile), "default.story.tsx");
674
- return b(p) ? (console.warn(`[nimpress] modules story: ${p} exists, not overwriting`), null) : (await ee(p, u), p);
679
+ `, u = d(O(i.pageFile), "default.story.tsx");
680
+ return y(u) ? (console.warn(`[nimpress] modules story: ${u} exists, not overwriting`), null) : (await te(u, p), u);
675
681
  }
676
- async function Ms(e, t, s) {
677
- const n = await Me(e, t.contentDir);
682
+ async function Js(e, t, n) {
683
+ const s = await xe(e, t.contentDir);
678
684
  let o = 0;
679
- for (const r of n)
680
- if (!(r.system !== s || (await rt(N(r.pageFile))).length))
685
+ for (const r of s)
686
+ if (!(r.system !== n || (await lt(O(r.pageFile))).length))
681
687
  try {
682
- await Je(e, t, s, r.component) && o++;
688
+ await Ge(e, t, n, r.component) && o++;
683
689
  } catch (c) {
684
690
  console.warn(String(c));
685
691
  }
686
692
  return o;
687
693
  }
688
- async function Is(e, t, s, n, o) {
689
- const r = t.modules.systems[s];
690
- if (!r) throw new Error(`[nimpress] modules create: unknown system ${s}`);
691
- const i = d(e, t.contentDir, "components", "Components", n), c = d(i, "index.md");
692
- if (b(c))
694
+ async function Bs(e, t, n, s, o) {
695
+ const r = t.modules.systems[n];
696
+ if (!r) throw new Error(`[nimpress] modules create: unknown system ${n}`);
697
+ const i = d(e, t.contentDir, "components", "Components", s), c = d(i, "index.md");
698
+ if (y(c))
693
699
  throw new Error(`[nimpress] modules create: ${c} exists`);
694
700
  const { mkdir: l } = await import("node:fs/promises");
695
701
  await l(i, { recursive: !0 });
696
702
  const a = r.package;
697
- await ee(
703
+ await te(
698
704
  c,
699
705
  `---
700
- title: ${n}
706
+ title: ${s}
701
707
  type: component
702
708
  data:
703
- system: ${s}
704
- component: ${n}${a ? `
709
+ system: ${n}
710
+ component: ${s}${a ? `
705
711
  package: "${a}"` : ""}
706
712
  ---
707
713
 
708
714
  ## Usage
709
715
 
710
716
  \`\`\`ts
711
- import { ${n} } from "${a ?? s}";
717
+ import { ${s} } from "${a ?? n}";
712
718
  \`\`\`
713
719
  `
714
720
  );
715
- const u = Ie(e, t.modules, s, n);
716
- if (u) {
717
- const p = o ?? vt(u.componentFile) ?? r.framework;
718
- await me(i, n, await pe(u.componentFile, p, n)), await Je(e, t, s, n, o);
721
+ const p = Je(e, t.modules, n, s);
722
+ if (p) {
723
+ const u = o ?? jt(p.componentFile) ?? r.framework;
724
+ await fe(i, s, await me(p.componentFile, u, s)), await Ge(e, t, n, s, o);
719
725
  } else {
720
- const p = r.framework === "vue" ? "vueStory" : "svelteStory";
721
- await ee(
726
+ const u = r.framework === "vue" ? "vueStory" : "svelteStory";
727
+ await te(
722
728
  d(i, "default.story.tsx"),
723
- `import { ${p} } from '@nimtech/nimpress/story'
729
+ `import { ${u} } from '@nimtech/nimpress/story'
724
730
 
725
731
  // story: Default
726
- export default ${p}({
732
+ export default ${u}({
727
733
  name: "Default",
728
734
  props: {}
729
735
  })
730
736
  `
731
737
  ), console.warn(
732
- `nimpress modules: no source found for ${n}, wrote a stub story, schema.json follows once the component exists and import or create runs again`
738
+ `nimpress modules: no source found for ${s}, wrote a stub story, schema.json follows once the component exists and import or create runs again`
733
739
  );
734
740
  }
735
741
  return i;
736
742
  }
737
- function ye(e) {
743
+ function be(e) {
738
744
  try {
739
- return JSON.parse(JSON.stringify(e, (t, s) => typeof s == "function" ? void 0 : s));
745
+ return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? void 0 : n));
740
746
  } catch {
741
747
  return {};
742
748
  }
743
749
  }
744
- function be(e, t = []) {
745
- let s;
750
+ function ve(e, t = []) {
751
+ let n;
746
752
  try {
747
- s = ae(e, { withFileTypes: !0 });
753
+ n = ce(e, { withFileTypes: !0 });
748
754
  } catch {
749
755
  return t;
750
756
  }
751
- for (const n of s) {
752
- const o = d(e, n.name);
753
- if (n.isDirectory()) {
754
- if (n.name === "node_modules" || n.name.startsWith(".")) continue;
755
- be(o, t);
756
- } else n.isFile() && t.push(o);
757
+ for (const s of n) {
758
+ const o = d(e, s.name);
759
+ if (s.isDirectory()) {
760
+ if (s.name === "node_modules" || s.name.startsWith(".")) continue;
761
+ ve(o, t);
762
+ } else s.isFile() && t.push(o);
757
763
  }
758
764
  return t;
759
765
  }
760
- function Te(e) {
766
+ function Ae(e) {
761
767
  return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9-]/g, "");
762
768
  }
763
- function Pe(e) {
764
- const t = C(e, "utf-8"), s = t.split(`
765
- `), n = [];
769
+ function Me(e) {
770
+ const t = S(e, "utf-8"), n = t.split(`
771
+ `), s = [];
766
772
  let o = 0;
767
- for (; o < s.length; ) {
768
- const f = s[o];
773
+ for (; o < n.length; ) {
774
+ const f = n[o];
769
775
  if (/^\s*import\b/.test(f)) {
770
776
  let h = f;
771
- for (; !/from\s+["'][^"']+["'];?\s*$/.test(h) && !/^\s*import\s+["'][^"']+["'];?\s*$/.test(h) && o + 1 < s.length; )
777
+ for (; !/from\s+["'][^"']+["'];?\s*$/.test(h) && !/^\s*import\s+["'][^"']+["'];?\s*$/.test(h) && o + 1 < n.length; )
772
778
  o++, h += `
773
- ` + s[o];
774
- n.push(h), o++;
779
+ ` + n[o];
780
+ s.push(h), o++;
775
781
  continue;
776
782
  }
777
783
  if (/^\s*$/.test(f)) {
@@ -780,26 +786,26 @@ function Pe(e) {
780
786
  }
781
787
  break;
782
788
  }
783
- const r = N(e), i = [], c = (f) => {
784
- const h = x(r, f);
785
- return /\.(vue|svelte)$/.test(f) ? { kind: "source", abs: h } : f.endsWith(".ts") ? b(h) ? { kind: "data", abs: h } : null : b(`${h}.ts`) ? { kind: "data", abs: `${h}.ts` } : b(`${h}.vue`) || b(`${h}.svelte`) || b(d(h, "index.ts")) ? { kind: "source", abs: h } : null;
789
+ const r = O(e), i = [], c = (f) => {
790
+ const h = j(r, f);
791
+ return /\.(vue|svelte)$/.test(f) ? { kind: "source", abs: h } : f.endsWith(".ts") ? y(h) ? { kind: "data", abs: h } : null : y(`${h}.ts`) ? { kind: "data", abs: `${h}.ts` } : y(`${h}.vue`) || y(`${h}.svelte`) || y(d(h, "index.ts")) ? { kind: "source", abs: h } : null;
786
792
  };
787
- for (const f of n) {
793
+ for (const f of s) {
788
794
  const h = f.match(/from\s+["'](\.\.?\/[^"']+)["']/)?.[1];
789
795
  if (!h) continue;
790
796
  const g = c(h);
791
797
  g?.kind === "data" && i.push(g.abs);
792
798
  }
793
- const l = n.filter((f) => !f.includes("@storybook")).map(
799
+ const l = s.filter((f) => !f.includes("@storybook")).map(
794
800
  (f) => f.replace(/from\s+["'](\.\.?\/[^"']+)["']/g, (h, g) => {
795
801
  const w = c(g);
796
- return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${D(g).replace(/\.ts$/, "")}"`;
802
+ return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${W(g).replace(/\.ts$/, "")}"`;
797
803
  })
798
804
  ).join(`
799
805
  `);
800
- let a = t.slice(s.slice(0, o).join(`
806
+ let a = t.slice(n.slice(0, o).join(`
801
807
  `).length);
802
- const u = (f) => {
808
+ const p = (f) => {
803
809
  const h = a.search(f);
804
810
  if (h < 0) return;
805
811
  const g = a.indexOf("{", h);
@@ -808,16 +814,16 @@ function Pe(e) {
808
814
  `, h) + 1);
809
815
  return;
810
816
  }
811
- const w = $e(a, g + 1), k = g + 1 + w.length + 1, j = a.slice(k).match(/^[^\n]*/)?.[0] ?? "";
812
- a = a.slice(0, h) + a.slice(k + j.length);
817
+ const w = ye(a, g + 1), v = g + 1 + w.length + 1, k = a.slice(v).match(/^[^\n]*/)?.[0] ?? "";
818
+ a = a.slice(0, h) + a.slice(v + k.length);
813
819
  };
814
- u(/^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 p = 0;
816
- for (; /^(?:export )?interface \w+/m.test(a) && p < 50; )
817
- u(/^(?:export )?interface \w+[^\n]*/m), p++;
820
+ 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, "");
821
+ let u = 0;
822
+ for (; /^(?:export )?interface \w+/m.test(a) && u < 50; )
823
+ p(/^(?:export )?interface \w+[^\n]*/m), u++;
818
824
  let m = 0;
819
825
  for (; /^export const \w+/m.test(a) && m < 200; )
820
- u(/^export const \w+[^\n]*/m), m++;
826
+ p(/^export const \w+[^\n]*/m), m++;
821
827
  return {
822
828
  file: e,
823
829
  text: t,
@@ -828,10 +834,10 @@ function Pe(e) {
828
834
  dataModules: i
829
835
  };
830
836
  }
831
- function Ls(e, t) {
832
- const s = e.indexOf(":", t) + 1;
833
- let n = 0, o = null;
834
- for (let r = s; r < e.length; r++) {
837
+ function Gs(e, t) {
838
+ const n = e.indexOf(":", t) + 1;
839
+ let s = 0, o = null;
840
+ for (let r = n; r < e.length; r++) {
835
841
  const i = e[r], c = e[r - 1];
836
842
  if (o) {
837
843
  i === o && c !== "\\" && (o = null);
@@ -841,24 +847,24 @@ function Ls(e, t) {
841
847
  o = i;
842
848
  continue;
843
849
  }
844
- if (i === "{" || i === "(" || i === "[") n++;
845
- else if (i === "}" || i === ")" || i === "]") n--;
846
- else if (i === "," && n === 0) return e.slice(s, r).trim();
850
+ if (i === "{" || i === "(" || i === "[") s++;
851
+ else if (i === "}" || i === ")" || i === "]") s--;
852
+ else if (i === "," && s === 0) return e.slice(n, r).trim();
847
853
  }
848
- return e.slice(s).trim();
854
+ return e.slice(n).trim();
849
855
  }
850
- function kt(e) {
856
+ function Ct(e) {
851
857
  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
858
  }
853
- function xt(e) {
854
- const t = [], s = /export const (\w+)\s*(?::[^=]*)?=\s*\{/g;
855
- let n;
856
- for (; n = s.exec(e.text); ) {
857
- const o = n[1];
859
+ function Et(e) {
860
+ const t = [], n = /export const (\w+)\s*(?::[^=]*)?=\s*\{/g;
861
+ let s;
862
+ for (; s = n.exec(e.text); ) {
863
+ const o = s[1];
858
864
  if (o === "default" || o === "meta") continue;
859
- const r = $e(e.text, s.lastIndex), i = r.search(/\brender\s*:/);
865
+ const r = ye(e.text, n.lastIndex), i = r.search(/\brender\s*:/);
860
866
  if (i >= 0) {
861
- const a = Ls(r, i);
867
+ const a = Gs(r, i);
862
868
  if (a) {
863
869
  t.push({ name: o, renderFn: a });
864
870
  continue;
@@ -869,13 +875,13 @@ function xt(e) {
869
875
  if (c >= 0) {
870
876
  const a = r.indexOf("{", c);
871
877
  if (a >= 0) {
872
- const u = $e(r, a + 1);
878
+ const p = ye(r, a + 1);
873
879
  try {
874
- l = ye(new Function(`${kt(e.declarations)}
875
- return {${u}}`)());
880
+ l = be(new Function(`${Ct(e.declarations)}
881
+ return {${p}}`)());
876
882
  } catch {
877
883
  try {
878
- l = ye(new Function(`return {${u}}`)());
884
+ l = be(new Function(`return {${p}}`)());
879
885
  } catch {
880
886
  l = {};
881
887
  }
@@ -886,18 +892,18 @@ return {${u}}`)());
886
892
  }
887
893
  return t;
888
894
  }
889
- function St(e) {
895
+ function Ot(e) {
890
896
  const t = e.text.search(/\bargTypes\s*:\s*\{/);
891
897
  if (t < 0) return;
892
- const s = e.text.indexOf("{", t), n = $e(e.text, s + 1);
898
+ const n = e.text.indexOf("{", t), s = ye(e.text, n + 1);
893
899
  let o;
894
900
  try {
895
- o = ye(new Function(`return {${n}}`)());
901
+ o = be(new Function(`return {${s}}`)());
896
902
  } catch {
897
903
  try {
898
- o = ye(
899
- new Function(`${kt(e.declarations)}
900
- return {${n}}`)()
904
+ o = be(
905
+ new Function(`${Ct(e.declarations)}
906
+ return {${s}}`)()
901
907
  );
902
908
  } catch {
903
909
  return;
@@ -906,20 +912,20 @@ return {${n}}`)()
906
912
  const r = {};
907
913
  for (const [i, c] of Object.entries(o)) {
908
914
  if (!c || typeof c != "object") continue;
909
- const l = c.control, a = typeof l == "string" ? l : String(l?.type ?? ""), u = c.options ?? (typeof l == "object" ? l?.options : void 0), p = {};
910
- typeof c.description == "string" && (p.description = c.description), Array.isArray(u) ? p.enum = u : a === "boolean" ? p.type = "boolean" : a === "number" || a === "range" ? p.type = "number" : a === "text" || a === "color" || a === "date" ? p.type = "string" : a === "object" && (p.type = "object"), c.defaultValue !== void 0 && (p.default = c.defaultValue), Object.keys(p).length && (r[i] = p);
915
+ const l = c.control, a = typeof l == "string" ? l : String(l?.type ?? ""), p = c.options ?? (typeof l == "object" ? l?.options : void 0), u = {};
916
+ typeof c.description == "string" && (u.description = c.description), Array.isArray(p) ? u.enum = p : 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
917
  }
912
918
  return Object.keys(r).length ? r : void 0;
913
919
  }
914
- async function jt(e) {
920
+ async function Ft(e) {
915
921
  const t = [...e].sort();
916
922
  for (let i = 0; i < t.length; i++)
917
923
  console.log(`${String(i + 1).padStart(4)} ${t[i]}`);
918
- const s = dt({ input: process.stdin, output: process.stdout }), n = await s.question(
924
+ const n = $t({ input: process.stdin, output: process.stdout }), s = await n.question(
919
925
  "select components to import, comma separated numbers, names, or /regex/, empty imports all: "
920
926
  );
921
- s.close();
922
- const o = n.trim();
927
+ n.close();
928
+ const o = s.trim();
923
929
  if (!o) return new Set(t);
924
930
  const r = /* @__PURE__ */ new Set();
925
931
  for (const i of o.split(",").map((c) => c.trim()).filter(Boolean)) {
@@ -938,154 +944,154 @@ async function jt(e) {
938
944
  }
939
945
  return r;
940
946
  }
941
- function Ct(e, t) {
942
- const s = /* @__PURE__ */ new Map(), n = d(e, "node_modules", t, "index.mjs");
943
- if (!b(n)) return s;
944
- const o = C(n, "utf-8");
947
+ function Dt(e, t) {
948
+ const n = /* @__PURE__ */ new Map(), s = d(e, "node_modules", t, "index.mjs");
949
+ if (!y(s)) return n;
950
+ const o = S(s, "utf-8");
945
951
  for (const r of o.matchAll(/export \{ default as ([A-Za-z]+) \}/g))
946
- s.set(r[1].toLowerCase(), r[1]);
947
- return s;
952
+ n.set(r[1].toLowerCase(), r[1]);
953
+ return n;
948
954
  }
949
- async function Js(e, t, s, n) {
950
- const o = t.modules.systems[s];
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"), l = o.package, a = n.match ? new RegExp(n.match) : null;
953
- if (n.file) {
954
- const $ = x(e, n.file);
955
- if (!b($)) throw new Error(`[nimpress] modules import: ${$} not found`);
956
- if (fe($) !== i)
955
+ async function Hs(e, t, n, s) {
956
+ const o = t.modules.systems[n];
957
+ if (!o) throw new Error(`[nimpress] modules import: unknown system ${n}`);
958
+ const r = o.framework, i = r === "vue" ? ".vue" : ".svelte", c = d(e, t.contentDir, "components"), l = o.package, a = s.match ? new RegExp(s.match) : null;
959
+ if (s.file) {
960
+ const $ = j(e, s.file);
961
+ if (!y($)) throw new Error(`[nimpress] modules import: ${$} not found`);
962
+ if (de($) !== i)
957
963
  throw new Error(`[nimpress] modules import: ${$} does not match system framework ${r}`);
958
- const y = n.name ?? D($, i), I = o.source ? x(e, o.source) : e, P = d(c, "Components", y);
959
- await Ne(P, { recursive: !0 });
964
+ const b = s.name ?? W($, i), I = o.source ? j(e, o.source) : e, P = d(c, "Components", b);
965
+ await Pe(P, { recursive: !0 });
960
966
  const A = E(I, $);
961
- await ee(d(P, "index.md"), Re(s, y, l, A)), await me(P, y, await pe($, r, y)), console.log(`nimpress modules: imported ${y} at ${E(e, P)}`);
967
+ await te(d(P, "index.md"), Ie(n, b, l, A)), await fe(P, b, await me($, r, b)), console.log(`nimpress modules: imported ${b} at ${E(e, P)}`);
962
968
  return;
963
969
  }
964
- if (n.fromStories) {
965
- await zs(e, t, s, n);
970
+ if (s.fromStories) {
971
+ await Us(e, t, n, s);
966
972
  return;
967
973
  }
968
- const u = x(e, n.source ?? o.source ?? "");
969
- if (!b(u))
970
- throw new Error(`[nimpress] modules import: source ${u} not found`);
971
- const p = be(u), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = p.filter(($) => $.endsWith(".stories.ts")), g = n.stories ? [x(e, n.stories)] : [];
974
+ const p = j(e, s.source ?? o.source ?? "");
975
+ if (!y(p))
976
+ throw new Error(`[nimpress] modules import: source ${p} not found`);
977
+ const u = ve(p), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = u.filter(($) => $.endsWith(".stories.ts")), g = s.stories ? [j(e, s.stories)] : [];
972
978
  for (const $ of g)
973
- for (const y of be($))
974
- y.endsWith(".stories.ts") && h.push(y);
975
- const w = p.filter(
976
- ($) => $.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(D($, i))
977
- ), k = new Set(w.map(($) => D($, i))), j = l && !o.source ? Ct(e, l) : null;
979
+ for (const b of ve($))
980
+ b.endsWith(".stories.ts") && h.push(b);
981
+ const w = u.filter(
982
+ ($) => $.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(W($, i))
983
+ ), v = new Set(w.map(($) => W($, i))), k = l && !o.source ? Dt(e, l) : null;
978
984
  for (const $ of h) {
979
- const y = Pe($);
980
- if (y.title?.includes("/")) {
981
- const [G, z] = y.title.split("/");
982
- m.set(z, G.replace(/\s+/g, ""));
985
+ const b = Me($);
986
+ if (b.title?.includes("/")) {
987
+ const [G, J] = b.title.split("/");
988
+ m.set(J, G.replace(/\s+/g, ""));
983
989
  }
984
- const I = D($, ".stories.ts");
985
- let A = b(d(N($), `${I}${i}`)) ? I : y.metaComponent ?? I;
986
- if (!k.has(A)) {
990
+ const I = W($, ".stories.ts");
991
+ let A = y(d(O($), `${I}${i}`)) ? I : b.metaComponent ?? I;
992
+ if (!v.has(A)) {
987
993
  let G = "";
988
- for (const z of k)
989
- I.startsWith(z) && z.length > G.length && (G = z);
990
- G ? A = G : console.warn(`nimpress modules: ${D($)} targets ${A} which has no component page`);
994
+ for (const J of v)
995
+ I.startsWith(J) && J.length > G.length && (G = J);
996
+ G ? A = G : console.warn(`nimpress modules: ${W($)} targets ${A} which has no component page`);
991
997
  }
992
- const S = j?.get(A.toLowerCase()) ?? A, Z = f.get(S) ?? [];
993
- Z.push(y), f.set(S, Z);
994
- }
995
- const O = /* @__PURE__ */ new Map();
996
- let v = 0, R = 0;
997
- const F = w.filter(($) => !a || a.test(D($, i))), T = n.select ? await jt(F.map(($) => D($, i))) : null;
998
- for (const $ of F) {
999
- const y = D($, i);
1000
- if (T && !T.has(y)) continue;
1001
- if (O.has(y)) {
1002
- console.warn(`nimpress modules: skip duplicate ${y}, kept ${O.get(y)}`);
998
+ const C = k?.get(A.toLowerCase()) ?? A, Z = f.get(C) ?? [];
999
+ Z.push(b), f.set(C, Z);
1000
+ }
1001
+ const F = /* @__PURE__ */ new Map();
1002
+ let x = 0, R = 0;
1003
+ const D = w.filter(($) => !a || a.test(W($, i))), T = s.select ? await Ft(D.map(($) => W($, i))) : null;
1004
+ for (const $ of D) {
1005
+ const b = W($, i);
1006
+ if (T && !T.has(b)) continue;
1007
+ if (F.has(b)) {
1008
+ console.warn(`nimpress modules: skip duplicate ${b}, kept ${F.get(b)}`);
1003
1009
  continue;
1004
1010
  }
1005
- O.set(y, E(u, $));
1006
- const I = m.get(y) ?? "Components", P = d(c, I, y);
1007
- await Ne(P, { recursive: !0 });
1008
- const A = E(u, $), S = A === `${y}/${y}${i}` || A === `${y}${i}`, Z = (f.get(y) ?? []).map((H) => St(H)).reduce(
1009
- (H, ne) => ne ? { ...H ?? {}, ...ne } : H,
1011
+ F.set(b, E(p, $));
1012
+ const I = m.get(b) ?? "Components", P = d(c, I, b);
1013
+ await Pe(P, { recursive: !0 });
1014
+ const A = E(p, $), C = A === `${b}/${b}${i}` || A === `${b}${i}`, Z = (f.get(b) ?? []).map((H) => Ot(H)).reduce(
1015
+ (H, oe) => oe ? { ...H ?? {}, ...oe } : H,
1010
1016
  void 0
1011
1017
  );
1012
- await ee(d(P, "index.md"), Re(s, y, l, S ? void 0 : A)), await me(P, y, await pe($, r, y)), Z && await ct(P, { properties: Z }), v++;
1013
- const G = f.get(y) ?? [], z = /* @__PURE__ */ new Set();
1018
+ await te(d(P, "index.md"), Ie(n, b, l, C ? void 0 : A)), await fe(P, b, await me($, r, b)), Z && await mt(P, { properties: Z }), x++;
1019
+ const G = f.get(b) ?? [], J = /* @__PURE__ */ new Set();
1014
1020
  for (const H of G) {
1015
- const ne = D(H.file, ".stories.ts"), ze = xt(H);
1016
- ze.length || console.warn(`nimpress modules: no stories mined from ${D(H.file)}`);
1021
+ const oe = W(H.file, ".stories.ts"), Ue = Et(H);
1022
+ Ue.length || console.warn(`nimpress modules: no stories mined from ${W(H.file)}`);
1017
1023
  for (const q of H.dataModules)
1018
- await ut(q, d(P, D(q)));
1019
- for (const q of ze) {
1020
- const Be = q.name === y ? "Default" : ne === y ? q.name : `${ne} ${q.name}`;
1021
- let he = Te(Be);
1022
- z.has(he) && (he = Te(`${ne}-${q.name}`));
1023
- const Ge = d(P, `${he}.story.tsx`);
1024
- z.add(he), !b(Ge) && (await ee(Ge, Et(r, Be, ne, q, H)), R++);
1024
+ await dt(q, d(P, W(q)));
1025
+ for (const q of Ue) {
1026
+ const Ze = q.name === b ? "Default" : oe === b ? q.name : `${oe} ${q.name}`;
1027
+ let ge = Ae(Ze);
1028
+ J.has(ge) && (ge = Ae(`${oe}-${q.name}`));
1029
+ const Ve = d(P, `${ge}.story.tsx`);
1030
+ J.add(ge), !y(Ve) && (await te(Ve, Wt(r, Ze, oe, q, H)), R++);
1025
1031
  }
1026
1032
  }
1027
1033
  }
1028
- console.log(`nimpress modules: imported ${v} components with ${R} stories for ${s}`);
1034
+ console.log(`nimpress modules: imported ${x} components with ${R} stories for ${n}`);
1029
1035
  }
1030
- async function zs(e, t, s, n) {
1031
- const o = t.modules.systems[s], r = o.framework, i = d(e, t.contentDir, "components"), c = x(e, n.stories ?? "");
1032
- if (!n.stories || !b(c))
1036
+ async function Us(e, t, n, s) {
1037
+ const o = t.modules.systems[n], r = o.framework, i = d(e, t.contentDir, "components"), c = j(e, s.stories ?? "");
1038
+ if (!s.stories || !y(c))
1033
1039
  throw new Error("[nimpress] modules import --from-stories requires --stories=<csf dir>");
1034
- const l = o.source ? x(e, o.source) : e, a = n.match ? new RegExp(n.match) : null, u = /* @__PURE__ */ new Set();
1035
- let p = 0, m = 0;
1036
- const f = be(c).filter((g) => g.endsWith(".stories.ts")), h = n.select ? await jt(
1037
- f.map((g) => Pe(g).metaComponent ?? D(g, ".stories.ts"))
1040
+ const l = o.source ? j(e, o.source) : e, a = s.match ? new RegExp(s.match) : null, p = /* @__PURE__ */ new Set();
1041
+ let u = 0, m = 0;
1042
+ const f = ve(c).filter((g) => g.endsWith(".stories.ts")), h = s.select ? await Ft(
1043
+ f.map((g) => Me(g).metaComponent ?? W(g, ".stories.ts"))
1038
1044
  ) : null;
1039
1045
  for (const g of f) {
1040
- const w = Pe(g), k = D(g, ".stories.ts"), j = w.metaComponent ?? k;
1041
- if (h && !h.has(j)) continue;
1042
- const O = w.text.match(
1043
- new RegExp(`import\\s+(?:\\{\\s*)?${j}(?:\\s*\\})?\\s+from\\s+["']([^"']+)["']`)
1046
+ const w = Me(g), v = W(g, ".stories.ts"), k = w.metaComponent ?? v;
1047
+ if (h && !h.has(k)) continue;
1048
+ const F = w.text.match(
1049
+ new RegExp(`import\\s+(?:\\{\\s*)?${k}(?:\\s*\\})?\\s+from\\s+["']([^"']+)["']`)
1044
1050
  )?.[1];
1045
- let v = j, R = o.package, F;
1046
- if (O && !O.startsWith(".") && !O.startsWith("@/")) {
1047
- const S = O.split("/")[0].startsWith("@") ? O.split("/").slice(0, 2).join("/") : O.split("/")[0];
1048
- R = S, v = Ct(e, S).get(j.toLowerCase()) ?? j;
1049
- } else if (O?.startsWith("@/components/")) {
1050
- const S = O.slice(13);
1051
- S === v || S === `${v}/${v}.vue` || (F = S.endsWith(".vue") || S.endsWith(".svelte") ? S : `${S}/${v}.vue`);
1052
- } else if (O?.startsWith(".")) {
1053
- const S = x(N(g), O);
1054
- F = E(l, S);
1051
+ let x = k, R = o.package, D;
1052
+ if (F && !F.startsWith(".") && !F.startsWith("@/")) {
1053
+ const C = F.split("/")[0].startsWith("@") ? F.split("/").slice(0, 2).join("/") : F.split("/")[0];
1054
+ R = C, x = Dt(e, C).get(k.toLowerCase()) ?? k;
1055
+ } else if (F?.startsWith("@/components/")) {
1056
+ const C = F.slice(13);
1057
+ C === x || C === `${x}/${x}.vue` || (D = C.endsWith(".vue") || C.endsWith(".svelte") ? C : `${C}/${x}.vue`);
1058
+ } else if (F?.startsWith(".")) {
1059
+ const C = j(O(g), F);
1060
+ D = E(l, C);
1055
1061
  }
1056
- if (a && !a.test(v)) continue;
1057
- if (u.has(v)) {
1058
- console.warn(`nimpress modules: skip duplicate ${v} from ${D(g)}`);
1062
+ if (a && !a.test(x)) continue;
1063
+ if (p.has(x)) {
1064
+ console.warn(`nimpress modules: skip duplicate ${x} from ${W(g)}`);
1059
1065
  continue;
1060
1066
  }
1061
- u.add(v);
1062
- const T = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", $ = d(i, T, v);
1063
- await Ne($, { recursive: !0 }), await ee(d($, "index.md"), Re(s, v, R, F));
1064
- const y = r === "vue" ? ".vue" : ".svelte", P = (F ? [x(l, F)] : [
1065
- d(l, v, `${v}${y}`),
1066
- d(l, `${v}${y}`)
1067
- ]).find((S) => b(S));
1067
+ p.add(x);
1068
+ const T = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", $ = d(i, T, x);
1069
+ await Pe($, { recursive: !0 }), await te(d($, "index.md"), Ie(n, x, R, D));
1070
+ const b = r === "vue" ? ".vue" : ".svelte", P = (D ? [j(l, D)] : [
1071
+ d(l, x, `${x}${b}`),
1072
+ d(l, `${x}${b}`)
1073
+ ]).find((C) => y(C));
1068
1074
  if (P)
1069
- await me($, v, await pe(P, r, v));
1075
+ await fe($, x, await me(P, r, x));
1070
1076
  else if (R) {
1071
- const S = ss(e, R, v);
1072
- S ? await me($, v, ns(C(S, "utf-8"), v)) : console.warn(`nimpress modules: no source or d.ts found for ${v}, the schema seed is skipped`);
1077
+ const C = is(e, R, x);
1078
+ C ? await fe($, x, as(S(C, "utf-8"), x)) : console.warn(`nimpress modules: no source or d.ts found for ${x}, the schema seed is skipped`);
1073
1079
  }
1074
- const A = St(w);
1075
- A && await ct($, { properties: A }), p++;
1076
- for (const S of w.dataModules)
1077
- await ut(S, d($, D(S)));
1078
- for (const S of xt(w)) {
1079
- const Z = S.name === v ? "Default" : S.name, G = Te(Z), z = d($, `${G}.story.tsx`);
1080
- b(z) || (await ee(z, Et(r, Z, k, S, w)), m++);
1080
+ const A = Ot(w);
1081
+ A && await mt($, { properties: A }), u++;
1082
+ for (const C of w.dataModules)
1083
+ await dt(C, d($, W(C)));
1084
+ for (const C of Et(w)) {
1085
+ const Z = C.name === x ? "Default" : C.name, G = Ae(Z), J = d($, `${G}.story.tsx`);
1086
+ y(J) || (await te(J, Wt(r, Z, v, C, w)), m++);
1081
1087
  }
1082
1088
  }
1083
- console.log(`nimpress modules: imported ${p} components with ${m} stories for ${s} from stories`);
1089
+ console.log(`nimpress modules: imported ${u} components with ${m} stories for ${n} from stories`);
1084
1090
  }
1085
- function Re(e, t, s, n) {
1086
- const o = s ? `
1087
- package: "${s}"` : "", r = n ? `
1088
- file: ${JSON.stringify(n)}` : "";
1091
+ function Ie(e, t, n, s) {
1092
+ const o = n ? `
1093
+ package: "${n}"` : "", r = s ? `
1094
+ file: ${JSON.stringify(s)}` : "";
1089
1095
  return `---
1090
1096
  title: ${t}
1091
1097
  type: component
@@ -1097,13 +1103,13 @@ data:
1097
1103
  ## Usage
1098
1104
 
1099
1105
  \`\`\`ts
1100
- import { ${t} } from "${s ?? e}";
1106
+ import { ${t} } from "${n ?? e}";
1101
1107
  \`\`\`
1102
1108
  `;
1103
1109
  }
1104
- function Et(e, t, s, n, o) {
1110
+ function Wt(e, t, n, s, o) {
1105
1111
  const r = e === "vue" ? "vueStory" : "svelteStory";
1106
- return n.renderFn ? `import { ${r} } from '@nimtech/nimpress/story'
1112
+ return s.renderFn ? `import { ${r} } from '@nimtech/nimpress/story'
1107
1113
  ${o.imports}
1108
1114
 
1109
1115
  ${o.declarations}
@@ -1111,442 +1117,481 @@ ${o.declarations}
1111
1117
  // story: ${t}
1112
1118
  export default ${r}({
1113
1119
  name: ${JSON.stringify(t)},
1114
- description: ${JSON.stringify(`Scenario from ${s}`)},
1115
- render: ${n.renderFn}
1120
+ description: ${JSON.stringify(`Scenario from ${n}`)},
1121
+ render: ${s.renderFn}
1116
1122
  })
1117
1123
  ` : `import { ${r} } from '@nimtech/nimpress/story'
1118
1124
 
1119
1125
  // story: ${t}
1120
1126
  export default ${r}({
1121
1127
  name: ${JSON.stringify(t)},
1122
- props: ${JSON.stringify(n.props ?? {}, null, 2)}
1128
+ props: ${JSON.stringify(s.props ?? {}, null, 2)}
1123
1129
  })
1124
1130
  `;
1125
1131
  }
1126
- function Ot(e) {
1132
+ const ee = { target: "", gate: "", set: !1, off: !1 };
1133
+ function He(e) {
1127
1134
  if (!e.startsWith(`---
1128
1135
  `)) return null;
1129
1136
  const t = e.indexOf(`
1130
1137
  ---`, 4);
1131
1138
  return t < 0 ? null : e.slice(4, t);
1132
1139
  }
1133
- function Bs(e) {
1134
- for (const t of e.split(`
1135
- `)) {
1136
- if (!t.startsWith("export:")) continue;
1137
- const s = t.slice(7).trim().replace(/^["']|["']$/g, "");
1138
- return s === "" || s === "false" ? null : s;
1139
- }
1140
- return null;
1141
- }
1142
- function Gs(e, t) {
1143
- const s = Ot(e);
1140
+ function Oe(e) {
1141
+ return e.trim().replace(/^["']|["']$/g, "");
1142
+ }
1143
+ function _t(e) {
1144
+ const t = e.split(`
1145
+ `), n = t.findIndex((r) => r.startsWith("export:"));
1146
+ if (n < 0) return ee;
1147
+ const s = Oe(t[n].slice(7));
1148
+ if (s === "false") return { ...ee, set: !0, off: !0 };
1149
+ if (s !== "") return { ...ee, target: s, set: !0 };
1150
+ const o = { ...ee, set: !0 };
1151
+ for (const r of t.slice(n + 1)) {
1152
+ if (!r.startsWith(" ")) break;
1153
+ const [i, ...c] = r.trim().split(":");
1154
+ i === "target" && (o.target = Oe(c.join(":"))), i === "gate" && (o.gate = Oe(c.join(":")));
1155
+ }
1156
+ return o.target || (o.target = "true"), o;
1157
+ }
1158
+ function Zs(e) {
1159
+ if (!y(e)) return ee;
1160
+ const t = He(S(e, "utf-8"));
1161
+ return t === null ? ee : _t(t);
1162
+ }
1163
+ function Le(e, t, n) {
1164
+ const s = n.get(t);
1165
+ if (s) return s;
1166
+ const o = Zs(d(t, "index.md")), r = t === e || !t.startsWith(e) ? ee : Le(e, O(t), n), i = o.set ? o.off ? ee : o : r;
1167
+ return n.set(t, i), i;
1168
+ }
1169
+ function Vs(e, t, n = "") {
1170
+ const s = He(e);
1144
1171
  if (s === null) return e;
1145
- const n = s.split(`
1146
- `).filter((r) => !r.startsWith("export:") && !r.startsWith(" file:")), o = n.findIndex((r) => r.startsWith(" package:"));
1147
- return t && o >= 0 && !n.some((r) => r.startsWith(" version:")) && n.splice(o + 1, 0, ` version: ${JSON.stringify(t)}`), `---
1148
- ${n.join(`
1172
+ const o = [];
1173
+ let r = !1;
1174
+ for (const c of s.split(`
1175
+ `))
1176
+ r && c.startsWith(" ") || (r = c.startsWith("export:"), !(r || c.startsWith(" file:")) && o.push(c));
1177
+ const i = o.findIndex((c) => c.startsWith(" package:"));
1178
+ return t && i >= 0 && !o.some((c) => c.startsWith(" version:")) && o.splice(i + 1, 0, ` version: ${JSON.stringify(t)}`), n && !o.some((c) => c.startsWith("gate:")) && o.push(`gate: ${n}`), `---
1179
+ ${o.join(`
1149
1180
  `)}${e.slice(4 + s.length)}`;
1150
1181
  }
1151
- function Ae(e, t, s) {
1152
- const n = _(s, "target") ?? "", o = d(e, _(s, "out") ?? t.paths.export), r = d(e, t.contentDir);
1182
+ function ze(e, t, n) {
1183
+ const s = _(n, "target") ?? "", o = d(e, _(n, "out") ?? t.paths.export), r = d(e, t.contentDir);
1153
1184
  let i = "";
1154
1185
  try {
1155
- i = JSON.parse(C(d(e, "package.json"), "utf-8")).version ?? "";
1186
+ i = JSON.parse(S(d(e, "package.json"), "utf-8")).version ?? "";
1156
1187
  } catch {
1157
1188
  i = "";
1158
1189
  }
1159
- let c = 0;
1160
- for (const l of X(r)) {
1161
- if (!l.endsWith(".md")) continue;
1162
- const a = C(l, "utf-8"), u = Ot(a);
1163
- if (u === null) continue;
1164
- const p = Bs(u);
1165
- if (p === null || n && p !== n && p !== "true") continue;
1166
- const m = N(l), f = d(o, E(r, m));
1167
- J(f, { recursive: !0 });
1168
- for (const h of ae(m, { withFileTypes: !0 })) {
1190
+ const c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), a = [];
1191
+ for (const u of X(r)) {
1192
+ if (!u.endsWith(".md")) {
1193
+ const v = Le(r, O(u), c);
1194
+ v.set && (!s || v.target === s || v.target === "true") && a.push(u);
1195
+ continue;
1196
+ }
1197
+ const m = He(S(u, "utf-8"));
1198
+ if (m === null) continue;
1199
+ const f = _t(m), h = Le(r, O(u), c), g = h.set && !(f.set && f.off) && (!f.set || W(u) === "index.md"), w = g ? h : f;
1200
+ !w.set || w.off || s && w.target !== s && w.target !== "true" || l.set(u, { spec: w, folder: g });
1201
+ }
1202
+ const p = /* @__PURE__ */ new Set();
1203
+ for (const u of a) {
1204
+ const m = d(o, E(r, u));
1205
+ L(O(m), { recursive: !0 }), N(m, S(u)), p.add(u);
1206
+ }
1207
+ for (const [u, m] of l) {
1208
+ const f = O(u);
1209
+ for (const h of ce(f, { withFileTypes: !0 })) {
1169
1210
  if (!h.isFile()) continue;
1170
- const g = C(d(m, h.name), "utf-8");
1171
- W(
1172
- d(f, h.name),
1173
- h.name.endsWith(".md") ? Gs(g, i) : g
1174
- );
1211
+ const g = d(f, h.name);
1212
+ if (p.has(g)) continue;
1213
+ let w = m.spec.gate;
1214
+ if (h.name.endsWith(".md")) {
1215
+ const k = l.get(g);
1216
+ if (!k && m.folder) continue;
1217
+ k && (w = k.spec.gate);
1218
+ }
1219
+ const v = d(o, E(r, g));
1220
+ L(O(v), { recursive: !0 }), N(v, h.name.endsWith(".md") ? Vs(S(g, "utf-8"), i, w) : S(g)), p.add(g);
1175
1221
  }
1176
- c++;
1177
1222
  }
1178
- console.log(`nimpress export: ${c} pages collected into ${o}`);
1223
+ console.log(`nimpress export: ${l.size} pages collected into ${o}`);
1179
1224
  }
1180
- function Ft(e = Q()) {
1225
+ function Nt(e = Q()) {
1181
1226
  return d(e, ".nimpress", "config.json");
1182
1227
  }
1183
- function Dt(e = Q()) {
1228
+ function Tt(e = Q()) {
1184
1229
  return d(e, ".tide", "nimpress", "sites");
1185
1230
  }
1186
- function _t(e = Q()) {
1187
- const t = Ft(e);
1188
- return b(t) ? { links: JSON.parse(C(t, "utf-8")).links ?? {} } : { links: {} };
1231
+ function Pt(e = Q()) {
1232
+ const t = Nt(e);
1233
+ return y(t) ? { links: JSON.parse(S(t, "utf-8")).links ?? {} } : { links: {} };
1189
1234
  }
1190
- function Nt(e, t = Q()) {
1191
- const s = Ft(t);
1192
- J(N(s), { recursive: !0 }), W(s, `${JSON.stringify(e, null, 2)}
1235
+ function Rt(e, t = Q()) {
1236
+ const n = Nt(t);
1237
+ L(O(n), { recursive: !0 }), N(n, `${JSON.stringify(e, null, 2)}
1193
1238
  `);
1194
1239
  }
1195
- function ve(e) {
1196
- const t = e.trim().replace(/\.git$/, "").replace(/\/+$/, ""), s = t.match(/[:/]([^/:]+)\/([^/]+)$/);
1197
- if (s && t.includes("github.com")) return `${s[1]}/${s[2]}`;
1198
- const n = t.match(/^([^/\s]+)\/([^/\s]+)$/);
1199
- if (n) return `${n[1]}/${n[2]}`;
1240
+ function ke(e) {
1241
+ const t = e.trim().replace(/\.git$/, "").replace(/\/+$/, ""), n = t.match(/[:/]([^/:]+)\/([^/]+)$/);
1242
+ if (n && t.includes("github.com")) return `${n[1]}/${n[2]}`;
1243
+ const s = t.match(/^([^/\s]+)\/([^/\s]+)$/);
1244
+ if (s) return `${s[1]}/${s[2]}`;
1200
1245
  throw new Error(`[nimpress] view: cannot read owner/repo from ${e}`);
1201
1246
  }
1202
- function Ce(e) {
1247
+ function Fe(e) {
1203
1248
  const t = e.trim();
1204
- return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${ve(t)}.git`;
1249
+ return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${ke(t)}.git`;
1205
1250
  }
1206
- function Wt(e) {
1251
+ function At(e) {
1207
1252
  const t = d(e, ".github", "workflows");
1208
- return b(t) ? ae(t).filter((s) => s.endsWith(".yml") || s.endsWith(".yaml")).sort().map((s) => d(t, s)) : [];
1253
+ return y(t) ? ce(t).filter((n) => n.endsWith(".yml") || n.endsWith(".yaml")).sort().map((n) => d(t, n)) : [];
1209
1254
  }
1210
- function Tt(e) {
1255
+ function Mt(e) {
1211
1256
  try {
1212
- const t = hs(C(e, "utf-8"));
1257
+ const t = ys(S(e, "utf-8"));
1213
1258
  return typeof t == "object" && t !== null ? t : null;
1214
1259
  } catch {
1215
1260
  return null;
1216
1261
  }
1217
1262
  }
1218
- function le(e, t) {
1219
- return String(e ?? "").replace(/\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (n, o) => {
1263
+ function ue(e, t) {
1264
+ return String(e ?? "").replace(/\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (s, o) => {
1220
1265
  for (const r of t)
1221
1266
  if (r && r[o] !== void 0) return String(r[o]);
1222
1267
  return "";
1223
1268
  }).trim();
1224
1269
  }
1225
- function Pt(e, t) {
1226
- const s = [];
1227
- for (const n of Object.values(e.jobs ?? {}))
1228
- for (const o of n.steps ?? [])
1229
- typeof o.uses == "string" && o.uses.includes(`/actions/${t}@`) && s.push({ step: o, scopes: [o.env, n.env, e.env] });
1230
- return s;
1270
+ function It(e, t) {
1271
+ const n = [];
1272
+ for (const s of Object.values(e.jobs ?? {}))
1273
+ for (const o of s.steps ?? [])
1274
+ typeof o.uses == "string" && o.uses.includes(`/actions/${t}@`) && n.push({ step: o, scopes: [o.env, s.env, e.env] });
1275
+ return n;
1231
1276
  }
1232
- function Hs(e) {
1277
+ function Ks(e) {
1233
1278
  const t = /* @__PURE__ */ new Map();
1234
- for (const s of Wt(e)) {
1235
- const n = Tt(s);
1236
- if (n)
1237
- for (const { step: o, scopes: r } of Pt(n, "docs-notify")) {
1238
- const i = le(o.with?.["docs-repo"], r);
1279
+ for (const n of At(e)) {
1280
+ const s = Mt(n);
1281
+ if (s)
1282
+ for (const { step: o, scopes: r } of It(s, "docs-notify")) {
1283
+ const i = ue(o.with?.["docs-repo"], r);
1239
1284
  if (!i) continue;
1240
- const c = le(o.with?.["export-dir"], r) || ".nimpress";
1285
+ const c = ue(o.with?.["export-dir"], r) || ".nimpress";
1241
1286
  t.set(i, { repo: i, exportDir: c });
1242
1287
  }
1243
1288
  }
1244
1289
  return [...t.values()];
1245
1290
  }
1246
- function Ye(e) {
1291
+ function et(e) {
1247
1292
  return e.replace(/\$\{\{\s*github\.workspace\s*\}\}\/?/g, "").replace(/^\.\//, "");
1248
1293
  }
1249
- function Us(e, t) {
1250
- const s = {
1294
+ function Ys(e, t) {
1295
+ const n = {
1251
1296
  contentRoot: t,
1252
- mapping: b(d(e, "nimpress.sources.json")) ? "nimpress.sources.json" : "",
1297
+ mapping: y(d(e, "nimpress.sources.json")) ? "nimpress.sources.json" : "",
1253
1298
  defaults: {}
1254
1299
  };
1255
- for (const n of Wt(e)) {
1256
- const o = Tt(n);
1300
+ for (const s of At(e)) {
1301
+ const o = Mt(s);
1257
1302
  if (o)
1258
- for (const { step: r, scopes: i } of Pt(o, "docs-sync")) {
1259
- const c = Ye(le(r.with?.["docs-dir"], i)), l = (m) => {
1260
- const f = Ye(m);
1303
+ for (const { step: r, scopes: i } of It(o, "docs-sync")) {
1304
+ const c = et(ue(r.with?.["docs-dir"], i)), l = (m) => {
1305
+ const f = et(m);
1261
1306
  return (c && f.startsWith(`${c}/`) ? f.slice(c.length + 1) : f).replace(/\/+$/, "");
1262
- }, a = le(r.with?.["content-root"], i);
1263
- a && (s.contentRoot = l(a));
1264
- const u = le(r.with?.mapping, i);
1265
- u && (s.mapping = l(u));
1266
- const p = le(r.with?.defaults, i);
1267
- return p && (s.defaults = JSON.parse(p)), s;
1307
+ }, a = ue(r.with?.["content-root"], i);
1308
+ a && (n.contentRoot = l(a));
1309
+ const p = ue(r.with?.mapping, i);
1310
+ p && (n.mapping = l(p));
1311
+ const u = ue(r.with?.defaults, i);
1312
+ return u && (n.defaults = JSON.parse(u)), n;
1268
1313
  }
1269
1314
  }
1270
- return s;
1315
+ return n;
1271
1316
  }
1272
- function Zs(e, t) {
1273
- const s = { ...e };
1274
- return t.target && (s.target = t.target), t.targets?.length && (s.targets = t.targets), t.mode && (s.mode = t.mode), s;
1317
+ function Qs(e, t) {
1318
+ const n = { ...e };
1319
+ return t.target && (n.target = t.target), t.targets?.length && (n.targets = t.targets), t.mode && (n.mode = t.mode), n;
1275
1320
  }
1276
- function Vs(e) {
1321
+ function Xs(e) {
1277
1322
  const t = e.mode || "mirror";
1278
- 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 }] : [];
1323
+ return e.targets?.length ? e.targets.map((n) => ({ from: n.from ?? "", to: n.to, mode: n.mode || t })) : e.target ? [{ from: "", to: e.target, mode: t }] : [];
1279
1324
  }
1280
- function Ks(e, t, s) {
1281
- let n = t.defaults;
1325
+ function qs(e, t, n) {
1326
+ let s = t.defaults;
1282
1327
  const o = t.mapping ? d(e, t.mapping) : "";
1283
- if (o && b(o)) {
1284
- const i = JSON.parse(C(o, "utf-8")).sources?.[s];
1285
- i && (n = Zs(n, i));
1328
+ if (o && y(o)) {
1329
+ const i = JSON.parse(S(o, "utf-8")).sources?.[n];
1330
+ i && (s = Qs(s, i));
1286
1331
  }
1287
- return n;
1332
+ return s;
1288
1333
  }
1289
- function Qe(e) {
1334
+ function tt(e) {
1290
1335
  const t = /* @__PURE__ */ new Map();
1291
- if (!b(e)) return t;
1292
- for (const s of X(e))
1293
- t.set(E(e, s).split(L).join("/"), C(s));
1336
+ if (!y(e)) return t;
1337
+ for (const n of X(e))
1338
+ t.set(E(e, n).split(z).join("/"), S(n));
1294
1339
  return t;
1295
1340
  }
1296
- function Ys(e, t, s) {
1297
- const n = { added: [], modified: [], deleted: [] }, o = Qe(e), r = Qe(t);
1341
+ function en(e, t, n) {
1342
+ const s = { added: [], modified: [], deleted: [] }, o = tt(e), r = tt(t);
1298
1343
  for (const [i, c] of o) {
1299
1344
  const l = r.get(i);
1300
1345
  if (l && l.equals(c)) continue;
1301
1346
  const a = d(t, ...i.split("/"));
1302
- J(N(a), { recursive: !0 }), W(a, c), l ? n.modified.push(i) : n.added.push(i);
1347
+ L(O(a), { recursive: !0 }), N(a, c), l ? s.modified.push(i) : s.added.push(i);
1303
1348
  }
1304
- if (s === "mirror")
1349
+ if (n === "mirror")
1305
1350
  for (const i of r.keys())
1306
- o.has(i) || (te(d(t, ...i.split("/")), { force: !0 }), n.deleted.push(i));
1307
- return n;
1351
+ o.has(i) || (se(d(t, ...i.split("/")), { force: !0 }), s.deleted.push(i));
1352
+ return s;
1308
1353
  }
1309
- function Qs(e, t) {
1310
- const s = /* @__PURE__ */ new Map();
1354
+ function tn(e, t) {
1355
+ const n = /* @__PURE__ */ new Map();
1311
1356
  for (const o of X(e)) {
1312
1357
  if (!o.endsWith(".md")) continue;
1313
- const r = ue(C(o, "utf-8")).data.path, i = os(e, o, typeof r == "string" ? r : void 0);
1314
- s.set(i, [...s.get(i) ?? [], o]);
1358
+ const r = pe(S(o, "utf-8")).data.path, i = cs(e, o, typeof r == "string" ? r : void 0);
1359
+ n.set(i, [...n.get(i) ?? [], o]);
1315
1360
  }
1316
- const n = [];
1317
- for (const o of s.values())
1318
- o.some((r) => t.has(r)) && n.push(...o.filter((r) => !t.has(r)));
1319
- return n.sort();
1361
+ const s = [];
1362
+ for (const o of n.values())
1363
+ o.some((r) => t.has(r)) && s.push(...o.filter((r) => !t.has(r)));
1364
+ return s.sort();
1320
1365
  }
1321
- function ie(e, t, s) {
1322
- const n = se("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...s } });
1323
- return { ok: n.status === 0, out: `${n.stdout ?? ""}${n.stderr ?? ""}`.trim() };
1366
+ function ae(e, t, n) {
1367
+ const s = ne("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...n } });
1368
+ return { ok: s.status === 0, out: `${s.stdout ?? ""}${s.stderr ?? ""}`.trim() };
1324
1369
  }
1325
- function Rt(e) {
1326
- const t = ie(["rev-parse", "--show-toplevel"], e);
1370
+ function Lt(e) {
1371
+ const t = ae(["rev-parse", "--show-toplevel"], e);
1327
1372
  return t.ok ? t.out : e;
1328
1373
  }
1329
- function Xs(e) {
1330
- const t = ie(["remote", "get-url", "origin"], e);
1374
+ function sn(e) {
1375
+ const t = ae(["remote", "get-url", "origin"], e);
1331
1376
  if (!t.ok) throw new Error(`[nimpress] view: ${e} has no origin remote, so its docs site mapping cannot be looked up`);
1332
- return ve(t.out);
1377
+ return ke(t.out);
1333
1378
  }
1334
- function qs() {
1335
- return se("gh", ["--version"], { encoding: "utf-8" }).status === 0;
1379
+ function nn() {
1380
+ return ne("gh", ["--version"], { encoding: "utf-8" }).status === 0;
1336
1381
  }
1337
- function At(e) {
1382
+ function zt(e) {
1338
1383
  return e?.method === "ssh" && e.key ? { GIT_SSH_COMMAND: `ssh -i ${e.key} -o IdentitiesOnly=yes` } : {};
1339
1384
  }
1340
- function Ee(e) {
1341
- return e.login?.method === "gh" ? se("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : ie(["ls-remote", "--exit-code", "-h", e.url], void 0, At(e.login)).ok;
1385
+ function De(e) {
1386
+ return e.login?.method === "gh" ? ne("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : ae(["ls-remote", "--exit-code", "-h", e.url], void 0, zt(e.login)).ok;
1342
1387
  }
1343
- async function Mt(e) {
1344
- const t = dt({ input: process.stdin, output: process.stdout });
1388
+ async function Jt(e) {
1389
+ const t = $t({ input: process.stdin, output: process.stdout });
1345
1390
  try {
1346
1391
  return (await t.question(e)).trim();
1347
1392
  } finally {
1348
1393
  t.close();
1349
1394
  }
1350
1395
  }
1351
- async function en(e) {
1352
- if (Ee(e)) return e;
1353
- if (console.log(`nimpress view: ${e.url} refused the connection`), qs()) {
1354
- if (console.log("nimpress view: logging in through gh"), se("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
1396
+ async function on(e) {
1397
+ if (De(e)) return e;
1398
+ if (console.log(`nimpress view: ${e.url} refused the connection`), nn()) {
1399
+ if (console.log("nimpress view: logging in through gh"), ne("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
1355
1400
  const o = { ...e, login: { method: "gh" } };
1356
- if (Ee(o)) return o;
1401
+ if (De(o)) return o;
1357
1402
  throw new Error(`[nimpress] view: ${e.repo} is still unreachable after the gh login, ask for access to it`);
1358
1403
  }
1359
- const t = await Mt("nimpress view: path to the ssh key with access to the repo: ");
1404
+ const t = await Jt("nimpress view: path to the ssh key with access to the repo: ");
1360
1405
  if (!t) throw new Error("[nimpress] view: no ssh key given and gh is not installed");
1361
- const s = { ...e, login: { method: "ssh", key: x(t.replace(/^~/, Q())) } };
1362
- if (Ee(s)) return s;
1363
- throw new Error(`[nimpress] view: ${e.repo} is still unreachable with ${s.login.key}, ask for access to it`);
1406
+ const n = { ...e, login: { method: "ssh", key: j(t.replace(/^~/, Q())) } };
1407
+ if (De(n)) return n;
1408
+ throw new Error(`[nimpress] view: ${e.repo} is still unreachable with ${n.login.key}, ask for access to it`);
1364
1409
  }
1365
- async function tn(e, t, s = Q()) {
1366
- const n = Rt(e), o = _t(s), r = o.links[n] ?? [], i = Hs(n), c = _(t, "docs-repo");
1410
+ async function rn(e, t, n = Q()) {
1411
+ const s = Lt(e), o = Pt(n), r = o.links[s] ?? [], i = Ks(s), c = _(t, "docs-repo");
1367
1412
  let l;
1368
1413
  if (c) {
1369
- const u = ve(c), p = i.find((m) => m.repo === u)?.exportDir ?? _(t, "export-dir") ?? ".nimpress";
1370
- l = [{ repo: u, url: Ce(c), exportDir: p, login: r.find((m) => m.repo === u)?.login }];
1414
+ const p = ke(c), u = i.find((m) => m.repo === p)?.exportDir ?? _(t, "export-dir") ?? ".nimpress";
1415
+ l = [{ repo: p, url: Fe(c), exportDir: u, login: r.find((m) => m.repo === p)?.login }];
1371
1416
  } else if (i.length)
1372
- l = i.map((u) => ({
1373
- repo: u.repo,
1374
- url: r.find((p) => p.repo === u.repo)?.url ?? Ce(u.repo),
1375
- exportDir: u.exportDir,
1376
- login: r.find((p) => p.repo === u.repo)?.login
1417
+ l = i.map((p) => ({
1418
+ repo: p.repo,
1419
+ url: r.find((u) => u.repo === p.repo)?.url ?? Fe(p.repo),
1420
+ exportDir: p.exportDir,
1421
+ login: r.find((u) => u.repo === p.repo)?.login
1377
1422
  }));
1378
1423
  else if (r.length)
1379
1424
  l = r;
1380
1425
  else {
1381
- console.log(`nimpress view: no workflow under ${n} names a docs site`);
1382
- const u = await Mt("nimpress view: docs site repo, owner/repo or a url, http or ssh: ");
1383
- if (!u) throw new Error("[nimpress] view: no docs site given");
1384
- l = [{ repo: ve(u), url: Ce(u), exportDir: _(t, "export-dir") ?? ".nimpress" }];
1426
+ console.log(`nimpress view: no workflow under ${s} names a docs site`);
1427
+ const p = await Jt("nimpress view: docs site repo, owner/repo or a url, http or ssh: ");
1428
+ if (!p) throw new Error("[nimpress] view: no docs site given");
1429
+ l = [{ repo: ke(p), url: Fe(p), exportDir: _(t, "export-dir") ?? ".nimpress" }];
1385
1430
  }
1386
1431
  const a = [];
1387
- for (const u of l) a.push(await en(u));
1388
- return o.links[n] = a, Nt(o, s), a;
1432
+ for (const p of l) a.push(await on(p));
1433
+ return o.links[s] = a, Rt(o, n), a;
1389
1434
  }
1390
- function sn(e, t = Q()) {
1391
- return d(Dt(t), e.repo.replace("/", "__"));
1435
+ function an(e, t = Q()) {
1436
+ return d(Tt(t), e.repo.replace("/", "__"));
1392
1437
  }
1393
- function nn(e, t, s) {
1394
- const n = At(e.login);
1395
- if (!b(d(t, ".git"))) {
1396
- J(N(t), { recursive: !0 }), console.log(`nimpress view: cloning ${e.repo}`);
1397
- const r = e.login?.method === "gh" ? se("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : se("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...n } });
1438
+ function cn(e, t, n) {
1439
+ const s = zt(e.login);
1440
+ if (!y(d(t, ".git"))) {
1441
+ L(O(t), { recursive: !0 }), console.log(`nimpress view: cloning ${e.repo}`);
1442
+ const r = e.login?.method === "gh" ? ne("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : ne("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...s } });
1398
1443
  if (r.status !== 0) throw new Error(`[nimpress] view: clone of ${e.repo} failed
1399
1444
  ${r.stderr ?? ""}`);
1400
1445
  return;
1401
1446
  }
1402
- if (s) return;
1403
- const o = ie(["fetch", "--depth", "1", "origin", "HEAD"], t, n);
1447
+ if (n) return;
1448
+ const o = ae(["fetch", "--depth", "1", "origin", "HEAD"], t, s);
1404
1449
  if (!o.ok) throw new Error(`[nimpress] view: fetch of ${e.repo} failed
1405
1450
  ${o.out}`);
1406
- ie(["reset", "--hard", "FETCH_HEAD"], t), ie(["clean", "-fd"], t);
1451
+ ae(["reset", "--hard", "FETCH_HEAD"], t), ae(["clean", "-fd"], t);
1407
1452
  }
1408
- function on(e) {
1409
- const t = ["pnpm-lock.yaml", "package.json"].map((s) => d(e, s)).find((s) => b(s));
1410
- return t ? ft("sha256").update(C(t)).digest("hex") : "";
1453
+ function ln(e) {
1454
+ const t = ["pnpm-lock.yaml", "package.json"].map((n) => d(e, n)).find((n) => y(n));
1455
+ return t ? wt("sha256").update(S(t)).digest("hex") : "";
1411
1456
  }
1412
- function rn(e) {
1413
- const t = d(e, B.paths.cache, "view", "lockfile.sha256"), s = on(e);
1414
- if (b(d(e, "node_modules")) && b(t) && C(t, "utf-8").trim() === s) return;
1415
- if (console.log("nimpress view: installing the docs site dependencies"), se("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
1416
- J(N(t), { recursive: !0 }), W(t, `${s}
1457
+ function un(e) {
1458
+ const t = d(e, B.paths.cache, "view", "lockfile.sha256"), n = ln(e);
1459
+ if (y(d(e, "node_modules")) && y(t) && S(t, "utf-8").trim() === n) return;
1460
+ if (console.log("nimpress view: installing the docs site dependencies"), ne("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
1461
+ L(O(t), { recursive: !0 }), N(t, `${n}
1417
1462
  `);
1418
1463
  }
1419
- function It(e, t) {
1420
- const s = ds(), n = s === "darwin" ? ["open", ...t ? ["-a", t] : [], e] : s === "win32" ? ["cmd", "/c", "start", "", ...t ? [t] : [], e] : t ? [t, e] : ["xdg-open", e], o = ke(n[0], n.slice(1), { stdio: "ignore", detached: !0 });
1464
+ function Bt(e, t) {
1465
+ const n = $s(), s = n === "darwin" ? ["open", ...t ? ["-a", t] : [], e] : n === "win32" ? ["cmd", "/c", "start", "", ...t ? [t] : [], e] : t ? [t, e] : ["xdg-open", e], o = Se(s[0], s.slice(1), { stdio: "ignore", detached: !0 });
1421
1466
  o.on("error", () => console.log(`nimpress: open ${e} in ${t ?? "a browser"}`)), o.unref();
1422
1467
  }
1423
- function Xe(e, t) {
1424
- let s;
1468
+ function st(e, t) {
1469
+ let n;
1425
1470
  return () => {
1426
- s && clearTimeout(s), s = setTimeout(e, t);
1471
+ n && clearTimeout(n), n = setTimeout(e, t);
1427
1472
  };
1428
1473
  }
1429
- function an(e, t) {
1474
+ function pn(e, t) {
1430
1475
  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`);
1431
1476
  }
1432
- function cn(e) {
1433
- const t = ke("pnpm", ["exec", "nimpress", "dev"], { cwd: e, stdio: ["ignore", "pipe", "inherit"] }), s = new Promise((n, o) => {
1477
+ function mn(e) {
1478
+ const t = Se("pnpm", ["exec", "nimpress", "dev"], { cwd: e, stdio: ["ignore", "pipe", "inherit"] }), n = new Promise((s, o) => {
1434
1479
  let r = !1;
1435
1480
  t.stdout?.on("data", (i) => {
1436
1481
  const c = i.toString();
1437
1482
  if (process.stdout.write(c), r) return;
1438
1483
  const l = c.replace(/\x1b\[[0-9;]*m/g, "").match(/Local\s*:?\s+(https?:\/\/\S+)/);
1439
- l && (r = !0, n(l[1]));
1484
+ l && (r = !0, s(l[1]));
1440
1485
  }), t.on("exit", (i) => {
1441
1486
  r || o(new Error(`[nimpress] view: the docs site dev server exited with ${i ?? "a signal"} before it printed a url`));
1442
1487
  }), t.on("error", (i) => o(new Error(`[nimpress] view: cannot run the docs site dev server, ${i.message}`)));
1443
1488
  });
1444
- return { child: t, origin: s };
1445
- }
1446
- async function ln(e, t) {
1447
- const s = M(t, "offline"), n = await tn(e, t), o = Xs(e), r = Rt(e), i = await we(e), c = _(t, "target") ? [`--target=${_(t, "target")}`] : [], l = [];
1448
- for (const u of n) {
1449
- const p = x(r, u.exportDir);
1450
- if (i.configFile && Ae(e, i.resolved, [...c, `--out=${p}`]), !b(p))
1451
- throw new Error(`[nimpress] view: no export folder at ${p}, write the pages there or mark pages with export: and add a config`);
1452
- const m = sn(u);
1453
- nn(u, m, s), rn(m);
1454
- const f = await we(m);
1455
- if (!f.configFile) throw new Error(`[nimpress] view: ${u.repo} carries no nimpress config, so it is not a docs site`);
1456
- const h = Us(m, f.resolved.contentDir), g = Vs(Ks(m, h, o));
1489
+ return { child: t, origin: n };
1490
+ }
1491
+ async function fn(e, t) {
1492
+ const n = M(t, "offline"), s = await rn(e, t), o = sn(e), r = Lt(e), i = await $e(e), c = _(t, "target") ? [`--target=${_(t, "target")}`] : [], l = [];
1493
+ for (const p of s) {
1494
+ const u = j(r, p.exportDir);
1495
+ if (i.configFile && ze(e, i.resolved, [...c, `--out=${u}`]), !y(u))
1496
+ throw new Error(`[nimpress] view: no export folder at ${u}, write the pages there or mark pages with export: and add a config`);
1497
+ const m = an(p);
1498
+ cn(p, m, n), un(m);
1499
+ const f = await $e(m);
1500
+ if (!f.configFile) throw new Error(`[nimpress] view: ${p.repo} carries no nimpress config, so it is not a docs site`);
1501
+ const h = Ys(m, f.resolved.contentDir), g = Xs(qs(m, h, o));
1457
1502
  if (!g.length)
1458
1503
  throw new Error(
1459
- `[nimpress] view: ${u.repo} has no target for ${o}, add it to nimpress.sources.json or the receiver defaults`
1504
+ `[nimpress] view: ${p.repo} has no target for ${o}, add it to nimpress.sources.json or the receiver defaults`
1460
1505
  );
1461
- const w = x(m, h.contentRoot), k = x(m, f.resolved.contentDir);
1462
- let j = [];
1463
- const O = () => {
1464
- j.length && ie(["checkout", "--", ...j], m);
1506
+ const w = j(m, h.contentRoot), v = j(m, f.resolved.contentDir);
1507
+ let k = [];
1508
+ const F = () => {
1509
+ k.length && ae(["checkout", "--", ...k], m);
1465
1510
  const $ = /* @__PURE__ */ new Set();
1466
- for (const y of g) {
1467
- const I = d(p, ...y.from.split("/").filter(Boolean)), P = d(w, ...y.to.split("/"));
1468
- an(y.to, Ys(I, P, y.mode));
1511
+ for (const b of g) {
1512
+ const I = d(u, ...b.from.split("/").filter(Boolean)), P = d(w, ...b.to.split("/"));
1513
+ pn(b.to, en(I, P, b.mode));
1469
1514
  for (const A of X(I)) $.add(d(P, E(I, A)));
1470
1515
  }
1471
- j = Qs(k, $);
1472
- for (const y of j) te(y);
1473
- j.length && console.log(`nimpress view: the local pages replace ${j.map((y) => E(m, y)).join(", ")}`);
1516
+ k = tn(v, $);
1517
+ for (const b of k) se(b);
1518
+ k.length && console.log(`nimpress view: the local pages replace ${k.map((b) => E(m, b)).join(", ")}`);
1474
1519
  };
1475
- O();
1476
- const v = Ze(p, { recursive: !0 }, Xe(O, 150));
1477
- if (l.push(() => v.close()), i.configFile) {
1478
- const $ = Ze(
1479
- x(e, i.resolved.contentDir),
1520
+ F();
1521
+ const x = Qe(u, { recursive: !0 }, st(F, 150));
1522
+ if (l.push(() => x.close()), i.configFile) {
1523
+ const $ = Qe(
1524
+ j(e, i.resolved.contentDir),
1480
1525
  { recursive: !0 },
1481
- Xe(() => Ae(e, i.resolved, [...c, `--out=${p}`]), 150)
1526
+ st(() => ze(e, i.resolved, [...c, `--out=${u}`]), 150)
1482
1527
  );
1483
1528
  l.push(() => $.close());
1484
1529
  }
1485
- const { child: R, origin: F } = cn(m);
1530
+ const { child: R, origin: D } = mn(m);
1486
1531
  l.push(() => R.kill());
1487
- const T = `${(await F).replace(/\/$/, "")}/${g[0].to}`;
1488
- console.log(`nimpress view: ${o} inside ${u.repo} at ${T}`), M(t, "no-browser") || It(T);
1532
+ const T = `${(await D).replace(/\/$/, "")}/${g[0].to}`;
1533
+ console.log(`nimpress view: ${o} inside ${p.repo} at ${T}`), M(t, "no-browser") || Bt(T);
1489
1534
  }
1490
1535
  const a = () => {
1491
- for (const u of l) u();
1536
+ for (const p of l) p();
1492
1537
  process.exit(0);
1493
1538
  };
1494
1539
  process.on("SIGINT", a), process.on("SIGTERM", a);
1495
1540
  }
1496
- const un = 6e4;
1497
- function oe(e, t) {
1498
- const s = _(t, "system");
1499
- if (s === void 0) return;
1500
- const n = Object.keys(e.modules.systems);
1501
- if (!n.includes(s))
1502
- throw new Error(`[nimpress] modules: unknown system ${s}, configured: ${n.join(", ") || "none"}`);
1503
- return s;
1541
+ const dn = 6e4;
1542
+ function re(e, t) {
1543
+ const n = _(t, "system");
1544
+ if (n === void 0) return;
1545
+ const s = Object.keys(e.modules.systems);
1546
+ if (!s.includes(n))
1547
+ throw new Error(`[nimpress] modules: unknown system ${n}, configured: ${s.join(", ") || "none"}`);
1548
+ return n;
1504
1549
  }
1505
- function Oe(e, t, s) {
1506
- const n = oe(e, t);
1507
- if (n) return n;
1550
+ function We(e, t, n) {
1551
+ const s = re(e, t);
1552
+ if (s) return s;
1508
1553
  const o = Object.keys(e.modules.systems);
1509
1554
  if (o.length === 1) return o[0];
1510
1555
  throw o.length ? new Error(
1511
- `[nimpress] modules ${s}: several systems configured (${o.join(", ")}), pass --system=<name>`
1512
- ) : new Error(`[nimpress] modules ${s}: no systems configured`);
1556
+ `[nimpress] modules ${n}: several systems configured (${o.join(", ")}), pass --system=<name>`
1557
+ ) : new Error(`[nimpress] modules ${n}: no systems configured`);
1513
1558
  }
1514
- async function pn(e, t, s) {
1515
- const n = s[0], o = s.slice(1), r = Object.keys(t.modules.systems);
1516
- if (n === "init") {
1517
- fn(e, t);
1559
+ async function hn(e, t, n) {
1560
+ const s = n[0], o = n.slice(1), r = Object.keys(t.modules.systems);
1561
+ if (s === "init") {
1562
+ wn(e, t);
1518
1563
  return;
1519
1564
  }
1520
- if (n === "dev") {
1521
- const i = oe(t, o), c = i ? [i] : r;
1565
+ if (s === "dev") {
1566
+ const i = re(t, o), c = i ? [i] : r;
1522
1567
  if (!c.length) throw new Error("[nimpress] modules dev: no systems configured");
1523
- await $t(e, t, c), await new Promise(() => {
1568
+ await kt(e, t, c), await new Promise(() => {
1524
1569
  });
1525
1570
  }
1526
- if (n === "build") {
1527
- const i = oe(t, o), c = i ? [i] : wt(t);
1571
+ if (s === "build") {
1572
+ const i = re(t, o), c = i ? [i] : vt(t);
1528
1573
  if (!c.length) throw new Error("[nimpress] modules build: no systems configured");
1529
- await yt(e, t, c);
1574
+ await xt(e, t, c);
1530
1575
  return;
1531
1576
  }
1532
- if (n === "lint") {
1533
- const i = await gt(e, t, oe(t, o));
1534
- We("nimpress modules lint", i, "nimpress modules lint: systems, schemas, and stories ok");
1577
+ if (s === "lint") {
1578
+ const i = await bt(e, t, re(t, o));
1579
+ Re("nimpress modules lint", i, "nimpress modules lint: systems, schemas, and stories ok");
1535
1580
  return;
1536
1581
  }
1537
- if (n === "story") {
1538
- const i = Oe(t, o, "story"), c = K(o, 0), l = _(o, "framework");
1582
+ if (s === "story") {
1583
+ const i = We(t, o, "story"), c = K(o, 0), l = _(o, "framework");
1539
1584
  if (c) {
1540
- const u = await Je(e, t, i, c, l);
1541
- u && console.log(`nimpress modules: story written to ${u}`);
1585
+ const p = await Ge(e, t, i, c, l);
1586
+ p && console.log(`nimpress modules: story written to ${p}`);
1542
1587
  return;
1543
1588
  }
1544
- const a = await Ms(e, t, i);
1589
+ const a = await Js(e, t, i);
1545
1590
  console.log(`nimpress modules: ${a} auto stories written for ${i}`);
1546
1591
  return;
1547
1592
  }
1548
- if (n === "stories") {
1549
- const i = K(o, 0), c = await qe(e, t, "stories", i, oe(t, o));
1593
+ if (s === "stories") {
1594
+ const i = K(o, 0), c = await nt(e, t, "stories", i, re(t, o));
1550
1595
  if (M(o, "json")) {
1551
1596
  console.log(JSON.stringify(c, null, 2));
1552
1597
  return;
@@ -1554,31 +1599,31 @@ async function pn(e, t, s) {
1554
1599
  if (!i) {
1555
1600
  const l = /* @__PURE__ */ new Map();
1556
1601
  for (const a of c) l.set(`${a.system} ${a.component}`, (l.get(`${a.system} ${a.component}`) ?? 0) + 1);
1557
- for (const [a, u] of l) console.log(`${a} ${u}`);
1602
+ for (const [a, p] of l) console.log(`${a} ${p}`);
1558
1603
  return;
1559
1604
  }
1560
1605
  for (const l of c) console.log(`${l.system} ${l.component} ${l.story} ${l.route}`);
1561
1606
  return;
1562
1607
  }
1563
- if (n === "open") {
1608
+ if (s === "open") {
1564
1609
  const i = K(o, 0);
1565
1610
  if (!i)
1566
1611
  throw new Error("[nimpress] modules open expects: nimpress modules open <Component> [story] [--system=<name>] [--browser=<app>]");
1567
- const c = await qe(e, t, "open", i, oe(t, o)), l = c.map((m) => m.system).filter((m, f, h) => h.indexOf(m) === f);
1612
+ const c = await nt(e, t, "open", i, re(t, o)), l = c.map((m) => m.system).filter((m, f, h) => h.indexOf(m) === f);
1568
1613
  if (l.length > 1)
1569
1614
  throw new Error(`[nimpress] modules open: ${i} is in several systems (${l.join(", ")}), pass --system=<name>`);
1570
- const a = K(o, 1), u = rs(c, a);
1571
- if (!u)
1615
+ const a = K(o, 1), p = ls(c, a);
1616
+ if (!p)
1572
1617
  throw new Error(
1573
1618
  `[nimpress] modules open: no story ${a} for ${c[0].system}/${c[0].component}, stories: ${c.map((m) => m.story).join(", ")}`
1574
1619
  );
1575
- const p = is(t, u);
1576
- await mn(e, t, u, p), It(p, _(o, "browser")), console.log(`nimpress modules open: ${u.system}/${u.component} ${u.story} at ${p}`);
1620
+ const u = us(t, p);
1621
+ await gn(e, t, p, u), Bt(u, _(o, "browser")), console.log(`nimpress modules open: ${p.system}/${p.component} ${p.story} at ${u}`);
1577
1622
  return;
1578
1623
  }
1579
- if (n === "import") {
1580
- const i = Oe(t, o, "import"), c = K(o, 0);
1581
- await Js(e, t, i, {
1624
+ if (s === "import") {
1625
+ const i = We(t, o, "import"), c = K(o, 0);
1626
+ await Hs(e, t, i, {
1582
1627
  file: c,
1583
1628
  name: _(o, "name"),
1584
1629
  source: _(o, "source"),
@@ -1586,127 +1631,127 @@ async function pn(e, t, s) {
1586
1631
  match: _(o, "match"),
1587
1632
  fromStories: o.includes("--from-stories"),
1588
1633
  select: o.includes("--select")
1589
- }), _e(e);
1634
+ }), Te(e);
1590
1635
  return;
1591
1636
  }
1592
- if (n === "update") {
1593
- const i = _(o, "component") ?? K(o, 0), c = await as(e, t, { ref: i, system: oe(t, o) });
1594
- console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`), _e(e);
1637
+ if (s === "update") {
1638
+ const i = _(o, "component") ?? K(o, 0), c = await ps(e, t, { ref: i, system: re(t, o) });
1639
+ console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`), Te(e);
1595
1640
  return;
1596
1641
  }
1597
- if (n === "create") {
1642
+ if (s === "create") {
1598
1643
  const i = _(o, "component");
1599
1644
  if (i) {
1600
1645
  if (!M(o, "schema"))
1601
1646
  throw new Error("[nimpress] modules create --component expects --schema to upsert the schema");
1602
- const p = await cs(e, t, i);
1603
- console.log(`nimpress modules: schema upserted at ${p}`);
1647
+ const u = await ms(e, t, i);
1648
+ console.log(`nimpress modules: schema upserted at ${u}`);
1604
1649
  return;
1605
1650
  }
1606
1651
  const c = K(o, 0);
1607
1652
  if (!c)
1608
1653
  throw new Error("[nimpress] modules create expects: nimpress modules create <Component> [--system=<name>], or --component=<ref> --schema");
1609
- const l = Oe(t, o, "create"), a = _(o, "framework"), u = await Is(e, t, l, c, a);
1610
- console.log(`nimpress modules: created ${c} at ${E(e, u)}`);
1654
+ const l = We(t, o, "create"), a = _(o, "framework"), p = await Bs(e, t, l, c, a);
1655
+ console.log(`nimpress modules: created ${c} at ${E(e, p)}`);
1611
1656
  return;
1612
1657
  }
1613
1658
  throw new Error("[nimpress] modules expects init, dev, build, lint, story, stories, open, import, create or update");
1614
1659
  }
1615
- async function qe(e, t, s, n, o) {
1616
- const r = await Ue(e, t, { component: n, system: o });
1617
- if (n && !r.length) {
1618
- const i = (await Ue(e, t, { system: o })).map((c) => `${c.system}/${c.component}`).filter((c, l, a) => a.indexOf(c) === l && c.toLowerCase().includes(n.toLowerCase()));
1660
+ async function nt(e, t, n, s, o) {
1661
+ const r = await Ye(e, t, { component: s, system: o });
1662
+ if (s && !r.length) {
1663
+ const i = (await Ye(e, t, { system: o })).map((c) => `${c.system}/${c.component}`).filter((c, l, a) => a.indexOf(c) === l && c.toLowerCase().includes(s.toLowerCase()));
1619
1664
  throw new Error(
1620
- `[nimpress] modules ${s}: no stories for ${n}${o ? ` in ${o}` : ""}` + (i.length ? `, did you mean ${i.slice(0, 8).join(", ")}` : "")
1665
+ `[nimpress] modules ${n}: no stories for ${s}${o ? ` in ${o}` : ""}` + (i.length ? `, did you mean ${i.slice(0, 8).join(", ")}` : "")
1621
1666
  );
1622
1667
  }
1623
1668
  return r;
1624
1669
  }
1625
- async function et(e) {
1670
+ async function ot(e) {
1626
1671
  try {
1627
1672
  return (await fetch(e, { signal: AbortSignal.timeout(2e3) })).status;
1628
1673
  } catch {
1629
1674
  return;
1630
1675
  }
1631
1676
  }
1632
- async function mn(e, t, s, n) {
1633
- let o = await et(n);
1677
+ async function gn(e, t, n, s) {
1678
+ let o = await ot(s);
1634
1679
  if (o === void 0) {
1635
- const r = Le(e, t, "modules", "dev.log");
1636
- J(N(r), { recursive: !0 });
1637
- const i = ps(r, "a"), c = ke(process.execPath, [process.argv[1], "dev"], { cwd: e, detached: !0, stdio: ["ignore", i, i] });
1680
+ const r = Be(e, t, "modules", "dev.log");
1681
+ L(O(r), { recursive: !0 });
1682
+ const i = hs(r, "a"), c = Se(process.execPath, [process.argv[1], "dev"], { cwd: e, detached: !0, stdio: ["ignore", i, i] });
1638
1683
  c.unref();
1639
1684
  let l = !1;
1640
1685
  c.on("exit", () => l = !0), console.log(`nimpress modules open: started nimpress dev in the background, pid ${c.pid}, log ${E(e, r)}`);
1641
- const a = Date.now() + un;
1686
+ const a = Date.now() + dn;
1642
1687
  for (; o === void 0 && !l && Date.now() < a; )
1643
- await new Promise((u) => setTimeout(u, 500)), o = await et(n);
1688
+ await new Promise((p) => setTimeout(p, 500)), o = await ot(s);
1644
1689
  if (o === void 0)
1645
- throw new Error(`[nimpress] modules open: the ${s.system} harness did not answer on ${n}, see ${E(e, r)}`);
1690
+ throw new Error(`[nimpress] modules open: the ${n.system} harness did not answer on ${s}, see ${E(e, r)}`);
1646
1691
  }
1647
1692
  if (o !== 200)
1648
1693
  throw new Error(
1649
- `[nimpress] modules open: the ${s.system} harness answers ${o} for ${s.component}, restart nimpress dev so it picks the component up`
1694
+ `[nimpress] modules open: the ${n.system} harness answers ${o} for ${n.component}, restart nimpress dev so it picks the component up`
1650
1695
  );
1651
1696
  }
1652
- function fn(e, t) {
1653
- const s = d(e, t.modules.dir);
1654
- J(s, { recursive: !0 });
1655
- const n = d(e, "nimpress.config.json");
1656
- if (b(n)) {
1657
- const o = JSON.parse(C(n, "utf-8"));
1658
- o.modules || (o.modules = { dir: t.modules.dir, route: t.modules.route, systems: {} }, W(n, JSON.stringify(o, null, 2) + `
1659
- `), console.log(`nimpress modules: modules block added to ${n}`));
1697
+ function wn(e, t) {
1698
+ const n = d(e, t.modules.dir);
1699
+ L(n, { recursive: !0 });
1700
+ const s = d(e, "nimpress.config.json");
1701
+ if (y(s)) {
1702
+ const o = JSON.parse(S(s, "utf-8"));
1703
+ o.modules || (o.modules = { dir: t.modules.dir, route: t.modules.route, systems: {} }, N(s, JSON.stringify(o, null, 2) + `
1704
+ `), console.log(`nimpress modules: modules block added to ${s}`));
1660
1705
  } else
1661
1706
  console.log("nimpress modules: add a modules block with systems entries to your nimpress config");
1662
- console.log(`nimpress modules: folder ready at ${s}`);
1663
- }
1664
- const Fe = d(".claude", "skills", "nimpress", "SKILL.md");
1665
- function Lt() {
1666
- const e = N(ht(import.meta.url)), t = [
1667
- x(e, Fe),
1668
- x(e, "..", Fe),
1669
- x(e, "..", "..", Fe)
1707
+ console.log(`nimpress modules: folder ready at ${n}`);
1708
+ }
1709
+ const _e = d(".claude", "skills", "nimpress", "SKILL.md");
1710
+ function Gt() {
1711
+ const e = O(yt(import.meta.url)), t = [
1712
+ j(e, _e),
1713
+ j(e, "..", _e),
1714
+ j(e, "..", "..", _e)
1670
1715
  ];
1671
- for (const s of t)
1716
+ for (const n of t)
1672
1717
  try {
1673
- return C(s, "utf-8");
1718
+ return S(n, "utf-8");
1674
1719
  } catch {
1675
1720
  }
1676
1721
  throw new Error(`[nimpress] skill: SKILL.md not found, looked in ${t.join(", ")}`);
1677
1722
  }
1678
- function Jt(e, t) {
1679
- const s = t ? d(Q(), ".claude") : d(e, ".claude"), n = d(s, "skills", "nimpress");
1680
- J(n, { recursive: !0 });
1681
- const o = d(n, "SKILL.md");
1682
- return W(o, Lt()), console.log(`wrote ${o}`), o;
1723
+ function Ht(e, t) {
1724
+ const n = t ? d(Q(), ".claude") : d(e, ".claude"), s = d(n, "skills", "nimpress");
1725
+ L(s, { recursive: !0 });
1726
+ const o = d(s, "SKILL.md");
1727
+ return N(o, Gt()), console.log(`wrote ${o}`), o;
1683
1728
  }
1684
- function dn(e, t) {
1685
- const s = t[0];
1686
- if (s === "get") {
1687
- process.stdout.write(Lt());
1729
+ function $n(e, t) {
1730
+ const n = t[0];
1731
+ if (n === "get") {
1732
+ process.stdout.write(Gt());
1688
1733
  return;
1689
1734
  }
1690
- if (s === "put") {
1691
- Jt(e, !M(t, "project"));
1735
+ if (n === "put") {
1736
+ Ht(e, !M(t, "project"));
1692
1737
  return;
1693
1738
  }
1694
1739
  throw new Error("[nimpress] skill expects get or put");
1695
1740
  }
1696
- const hn = "nimling/nimpress", gn = "nimpress@nimpress";
1697
- function tt(e, t) {
1741
+ const yn = "nimling/nimpress", bn = "nimpress@nimpress";
1742
+ function rt(e, t) {
1698
1743
  console.log(`claude ${t.join(" ")}`);
1699
- const s = se("claude", t, { cwd: e, stdio: "inherit" });
1700
- if (s.error) throw new Error(`[nimpress] plugin: could not run claude, install Claude Code first: ${s.error.message}`);
1701
- if (s.status !== 0) throw new Error(`[nimpress] plugin: claude ${t.join(" ")} exited with ${s.status}`);
1744
+ const n = ne("claude", t, { cwd: e, stdio: "inherit" });
1745
+ if (n.error) throw new Error(`[nimpress] plugin: could not run claude, install Claude Code first: ${n.error.message}`);
1746
+ if (n.status !== 0) throw new Error(`[nimpress] plugin: claude ${t.join(" ")} exited with ${n.status}`);
1702
1747
  }
1703
- function wn(e, t) {
1704
- const s = t ? "user" : "project";
1705
- tt(e, ["plugin", "marketplace", "add", hn, "--scope", s]), tt(e, ["plugin", "install", gn, "--scope", s]);
1748
+ function vn(e, t) {
1749
+ const n = t ? "user" : "project";
1750
+ rt(e, ["plugin", "marketplace", "add", yn, "--scope", n]), rt(e, ["plugin", "install", bn, "--scope", n]);
1706
1751
  }
1707
- function $n(e, t) {
1752
+ function kn(e, t) {
1708
1753
  if (t[0] === "put") {
1709
- wn(e, !M(t, "project"));
1754
+ vn(e, !M(t, "project"));
1710
1755
  return;
1711
1756
  }
1712
1757
  throw new Error("[nimpress] plugin expects put");
@@ -1715,7 +1760,7 @@ const V = {
1715
1760
  name: "--system",
1716
1761
  value: !0,
1717
1762
  describe: "the configured component system to act on"
1718
- }, st = {
1763
+ }, it = {
1719
1764
  name: "--framework",
1720
1765
  value: !0,
1721
1766
  describe: "vue or svelte, overriding the framework of the system"
@@ -1759,7 +1804,7 @@ const V = {
1759
1804
  { name: "dev", describe: "Serve the harnesses and stay running", flags: [V], subs: [] },
1760
1805
  { name: "build", describe: "Build the harness bundles", flags: [V], subs: [] },
1761
1806
  { name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [V], subs: [] },
1762
- { name: "story", describe: "Write auto stories for one component or for every component", flags: [V, st], subs: [] },
1807
+ { name: "story", describe: "Write auto stories for one component or for every component", flags: [V, it], subs: [] },
1763
1808
  {
1764
1809
  name: "stories",
1765
1810
  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",
@@ -1791,7 +1836,7 @@ const V = {
1791
1836
  describe: "Create a component page, or upsert one schema",
1792
1837
  flags: [
1793
1838
  V,
1794
- st,
1839
+ it,
1795
1840
  { name: "--component", value: !0, describe: "the component reference whose schema is upserted" },
1796
1841
  { name: "--schema", value: !1, describe: "required with --component, upserts the schema" }
1797
1842
  ],
@@ -1915,36 +1960,36 @@ const V = {
1915
1960
  { name: "powershell", describe: "the powershell completion script", flags: [], subs: [] }
1916
1961
  ]
1917
1962
  }
1918
- ], zt = ["bash", "zsh", "fish", "powershell"];
1919
- function xe(e) {
1963
+ ], Ut = ["bash", "zsh", "fish", "powershell"];
1964
+ function je(e) {
1920
1965
  const t = [];
1921
- for (const s of [...e.flags, ...e.subs.flatMap((n) => n.flags)])
1922
- t.some((n) => n.name === s.name) || t.push(s);
1966
+ for (const n of [...e.flags, ...e.subs.flatMap((s) => s.flags)])
1967
+ t.some((s) => s.name === n.name) || t.push(n);
1923
1968
  return t;
1924
1969
  }
1925
- function Se(e, t) {
1970
+ function Ce(e, t) {
1926
1971
  return t && e.value ? `${e.name}=` : e.name;
1927
1972
  }
1928
- function yn() {
1973
+ function xn() {
1929
1974
  const e = ["_nimpress() {", ' local cur="${COMP_WORDS[COMP_CWORD]}"'];
1930
1975
  e.push(` local words="${Y.map((t) => t.name).join(" ")}"`), e.push(' if [ "$COMP_CWORD" -gt 1 ]; then'), e.push(' case "${COMP_WORDS[1]}" in');
1931
1976
  for (const t of Y) {
1932
- const s = [...t.subs.map((n) => n.name), ...xe(t).map((n) => Se(n, !1))];
1933
- e.push(` ${t.name}) words="${s.join(" ")}" ;;`);
1977
+ const n = [...t.subs.map((s) => s.name), ...je(t).map((s) => Ce(s, !1))];
1978
+ e.push(` ${t.name}) words="${n.join(" ")}" ;;`);
1934
1979
  }
1935
1980
  return e.push(' *) words="" ;;'), e.push(" esac"), e.push(" fi"), e.push(' COMPREPLY=( $(compgen -W "$words" -- "$cur") )'), e.push("}"), e.push("complete -o default -F _nimpress nimpress"), e.join(`
1936
1981
  `) + `
1937
1982
  `;
1938
1983
  }
1939
- function De(e, t, s) {
1940
- const n = [`${e}entries=(`];
1941
- for (const o of s) n.push(`${e} ${o}`);
1942
- return n.push(`${e})`), n.push(`${e}_describe '${t}' entries`), n.push(`${e}return`), n;
1984
+ function Ne(e, t, n) {
1985
+ const s = [`${e}entries=(`];
1986
+ for (const o of n) s.push(`${e} ${o}`);
1987
+ return s.push(`${e})`), s.push(`${e}_describe '${t}' entries`), s.push(`${e}return`), s;
1943
1988
  }
1944
- function bn() {
1989
+ function Sn() {
1945
1990
  const e = ["#compdef nimpress", "", "_nimpress() {", " local -a entries", " if (( CURRENT == 2 )); then"];
1946
1991
  e.push(
1947
- ...De(
1992
+ ...Ne(
1948
1993
  " ",
1949
1994
  "nimpress command",
1950
1995
  Y.map((t) => `'${t.name}:${t.describe}'`)
@@ -1952,18 +1997,18 @@ function bn() {
1952
1997
  ), e.push(" fi"), e.push(' case "$words[2]" in');
1953
1998
  for (const t of Y) {
1954
1999
  e.push(` ${t.name})`), t.subs.length && (e.push(" if (( CURRENT == 3 )); then"), e.push(
1955
- ...De(
2000
+ ...Ne(
1956
2001
  " ",
1957
2002
  `${t.name} argument`,
1958
- t.subs.map((n) => `'${n.name}:${n.describe}'`)
2003
+ t.subs.map((s) => `'${s.name}:${s.describe}'`)
1959
2004
  )
1960
2005
  ), e.push(" fi"));
1961
- const s = xe(t);
1962
- s.length ? e.push(
1963
- ...De(
2006
+ const n = je(t);
2007
+ n.length ? e.push(
2008
+ ...Ne(
1964
2009
  " ",
1965
2010
  "nimpress flag",
1966
- s.map((n) => `'${Se(n, !0)}:${n.describe}'`)
2011
+ n.map((s) => `'${Ce(s, !0)}:${s.describe}'`)
1967
2012
  )
1968
2013
  ) : e.push(" return"), e.push(" ;;");
1969
2014
  }
@@ -1971,26 +2016,26 @@ function bn() {
1971
2016
  `) + `
1972
2017
  `;
1973
2018
  }
1974
- function vn() {
2019
+ function jn() {
1975
2020
  const e = ["complete -c nimpress -f"];
1976
2021
  for (const t of Y)
1977
2022
  e.push(
1978
2023
  `complete -c nimpress -n '__fish_use_subcommand' -a '${t.name}' -d '${t.describe}'`
1979
2024
  );
1980
2025
  for (const t of Y) {
1981
- const s = `__fish_seen_subcommand_from ${t.name}`;
1982
- for (const n of t.subs)
1983
- e.push(`complete -c nimpress -n '${s}' -a '${n.name}' -d '${n.describe}'`);
1984
- for (const n of xe(t))
2026
+ const n = `__fish_seen_subcommand_from ${t.name}`;
2027
+ for (const s of t.subs)
2028
+ e.push(`complete -c nimpress -n '${n}' -a '${s.name}' -d '${s.describe}'`);
2029
+ for (const s of je(t))
1985
2030
  e.push(
1986
- `complete -c nimpress -n '${s}' -a '${Se(n, !0)}' -d '${n.describe}'`
2031
+ `complete -c nimpress -n '${n}' -a '${Ce(s, !0)}' -d '${s.describe}'`
1987
2032
  );
1988
2033
  }
1989
2034
  return e.join(`
1990
2035
  `) + `
1991
2036
  `;
1992
2037
  }
1993
- function kn() {
2038
+ function Cn() {
1994
2039
  const e = [
1995
2040
  "Register-ArgumentCompleter -Native -CommandName nimpress -ScriptBlock {",
1996
2041
  " param($wordToComplete, $commandAst, $cursorPosition)",
@@ -2002,21 +2047,21 @@ function kn() {
2002
2047
  " switch ($words[1]) {"
2003
2048
  ];
2004
2049
  for (const t of Y) {
2005
- const s = [...t.subs.map((n) => n.name), ...xe(t).map((n) => Se(n, !0))];
2006
- e.push(` '${t.name}' { $candidates = @(${s.map((n) => `'${n}'`).join(", ")}) }`);
2050
+ const n = [...t.subs.map((s) => s.name), ...je(t).map((s) => Ce(s, !0))];
2051
+ e.push(` '${t.name}' { $candidates = @(${n.map((s) => `'${s}'`).join(", ")}) }`);
2007
2052
  }
2008
2053
  return e.push(" }"), e.push(" }"), e.push(' $candidates | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {'), e.push(" [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)"), e.push(" }"), e.push("}"), e.join(`
2009
2054
  `) + `
2010
2055
  `;
2011
2056
  }
2012
- function Bt(e) {
2013
- if (e === "bash") return yn();
2014
- if (e === "zsh") return bn();
2015
- if (e === "fish") return vn();
2016
- if (e === "powershell") return kn();
2017
- throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${zt.join(", ")}`);
2057
+ function Zt(e) {
2058
+ if (e === "bash") return xn();
2059
+ if (e === "zsh") return Sn();
2060
+ if (e === "fish") return jn();
2061
+ if (e === "powershell") return Cn();
2062
+ throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${Ut.join(", ")}`);
2018
2063
  }
2019
- function nt(e) {
2064
+ function at(e) {
2020
2065
  return e === "fish" ? [
2021
2066
  "function nimpress",
2022
2067
  " if test -x node_modules/.bin/nimpress",
@@ -2038,96 +2083,96 @@ function nt(e) {
2038
2083
  ].join(`
2039
2084
  `);
2040
2085
  }
2041
- function xn() {
2042
- const e = D(process.env.SHELL ?? "");
2086
+ function En() {
2087
+ const e = W(process.env.SHELL ?? "");
2043
2088
  for (const t of ["zsh", "bash", "fish"])
2044
2089
  if (e.includes(t)) return t;
2045
2090
  return "";
2046
2091
  }
2047
- function Sn(e, t) {
2048
- const s = "# >>> nimpress completion >>>", n = "# <<< nimpress completion <<<", o = `${s}
2092
+ function On(e, t) {
2093
+ const n = "# >>> nimpress completion >>>", s = "# <<< nimpress completion <<<", o = `${n}
2049
2094
  ${t}
2050
- ${n}`, r = e.indexOf(s), i = e.indexOf(n);
2051
- return r >= 0 && i > r ? e.slice(0, r) + o + e.slice(i + n.length) : r >= 0 ? e.replace(/\n+$/, "") + `
2095
+ ${s}`, r = e.indexOf(n), i = e.indexOf(s);
2096
+ return r >= 0 && i > r ? e.slice(0, r) + o + e.slice(i + s.length) : r >= 0 ? e.replace(/\n+$/, "") + `
2052
2097
  ` + o + `
2053
2098
  ` : (e === "" || e.endsWith(`
2054
2099
  `) ? e : e + `
2055
2100
  `) + o + `
2056
2101
  `;
2057
2102
  }
2058
- function jn(e, t) {
2059
- let s = "";
2103
+ function Fn(e, t) {
2104
+ let n = "";
2060
2105
  try {
2061
- s = C(e, "utf-8");
2106
+ n = S(e, "utf-8");
2062
2107
  } catch {
2063
- s = "";
2108
+ n = "";
2064
2109
  }
2065
- W(e, Sn(s, t));
2110
+ N(e, On(n, t));
2066
2111
  }
2067
- function Cn(e) {
2068
- const t = e || xn();
2112
+ function Dn(e) {
2113
+ const t = e || En();
2069
2114
  if (!t)
2070
2115
  throw new Error("[nimpress] completion: could not detect the shell from $SHELL, name it: nimpress completion <shell> --auto");
2071
- const s = Bt(t), n = Q();
2116
+ const n = Zt(t), s = Q();
2072
2117
  if (t === "fish") {
2073
- const a = d(n, ".config", "fish", "completions");
2074
- J(a, { recursive: !0 });
2075
- const u = d(a, "nimpress.fish");
2076
- W(u, s), console.log(`wrote ${u}`);
2077
- const p = d(n, ".config", "fish", "functions");
2078
- J(p, { recursive: !0 });
2079
- const m = d(p, "nimpress.fish");
2080
- W(m, nt(t)), console.log(`wrote ${m}`), console.log("fish loads them on the next shell");
2118
+ const a = d(s, ".config", "fish", "completions");
2119
+ L(a, { recursive: !0 });
2120
+ const p = d(a, "nimpress.fish");
2121
+ N(p, n), console.log(`wrote ${p}`);
2122
+ const u = d(s, ".config", "fish", "functions");
2123
+ L(u, { recursive: !0 });
2124
+ const m = d(u, "nimpress.fish");
2125
+ N(m, at(t)), console.log(`wrote ${m}`), console.log("fish loads them on the next shell");
2081
2126
  return;
2082
2127
  }
2083
2128
  if (t !== "bash" && t !== "zsh")
2084
2129
  throw new Error(`[nimpress] completion: auto install covers bash, zsh, and fish, for ${t} run: nimpress completion ${t}`);
2085
- const o = d(n, ".config", "nimpress", "completions");
2086
- J(o, { recursive: !0 });
2130
+ const o = d(s, ".config", "nimpress", "completions");
2131
+ L(o, { recursive: !0 });
2087
2132
  const r = d(o, t === "zsh" ? "_nimpress" : "nimpress.bash");
2088
- W(r, s), console.log(`wrote ${r}`);
2089
- const i = d(n, t === "zsh" ? ".zshrc" : ".bashrc"), c = t === "zsh" ? `fpath=("${o}" $fpath)
2090
- autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`, l = `${nt(t)}
2133
+ N(r, n), console.log(`wrote ${r}`);
2134
+ const i = d(s, t === "zsh" ? ".zshrc" : ".bashrc"), c = t === "zsh" ? `fpath=("${o}" $fpath)
2135
+ autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`, l = `${at(t)}
2091
2136
  ${c}`;
2092
- jn(i, l), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
2137
+ Fn(i, l), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
2093
2138
  }
2094
- function En(e, t) {
2095
- const s = K(t, 0) ?? "", n = M(t, "auto"), o = M(t, "skill");
2096
- if (!n) {
2139
+ function Wn(e, t) {
2140
+ const n = K(t, 0) ?? "", s = M(t, "auto"), o = M(t, "skill");
2141
+ if (!s) {
2097
2142
  if (o) throw new Error("[nimpress] completion: --skill installs alongside --auto");
2098
- if (!s) throw new Error(`[nimpress] completion: name a shell (${zt.join(", ")}) or pass --auto`);
2099
- process.stdout.write(Bt(s));
2143
+ if (!n) throw new Error(`[nimpress] completion: name a shell (${Ut.join(", ")}) or pass --auto`);
2144
+ process.stdout.write(Zt(n));
2100
2145
  return;
2101
2146
  }
2102
- Cn(s), o && Jt(e, !0);
2147
+ Dn(n), o && Ht(e, !0);
2103
2148
  }
2104
- const On = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), Fn = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), Dn = 2e4, de = /* @__PURE__ */ new Map();
2105
- function Gt(e, t) {
2106
- const s = [...t, e.name];
2107
- return e.subs.length ? e.subs.flatMap((n) => Gt(n, s)) : [
2149
+ const _n = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), Nn = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), Tn = 2e4, he = /* @__PURE__ */ new Map();
2150
+ function Vt(e, t) {
2151
+ const n = [...t, e.name];
2152
+ return e.subs.length ? e.subs.flatMap((s) => Vt(s, n)) : [
2108
2153
  {
2109
- name: s.join("_"),
2110
- argv: s,
2154
+ name: n.join("_"),
2155
+ argv: n,
2111
2156
  describe: e.describe,
2112
2157
  flags: e.flags,
2113
- serves: Fn.has(s.join(" "))
2158
+ serves: Nn.has(n.join(" "))
2114
2159
  }
2115
2160
  ];
2116
2161
  }
2117
- const Ht = Y.filter((e) => !On.has(e.name)).flatMap((e) => Gt(e, []));
2118
- function _n() {
2119
- const e = N(ht(import.meta.url));
2120
- for (const t of [x(e, "..", "package.json"), x(e, "..", "..", "package.json")])
2162
+ const Kt = Y.filter((e) => !_n.has(e.name)).flatMap((e) => Vt(e, []));
2163
+ function Pn() {
2164
+ const e = O(yt(import.meta.url));
2165
+ for (const t of [j(e, "..", "package.json"), j(e, "..", "..", "package.json")])
2121
2166
  try {
2122
- return JSON.parse(C(t, "utf-8")).version;
2167
+ return JSON.parse(S(t, "utf-8")).version;
2123
2168
  } catch {
2124
2169
  }
2125
2170
  return "0.0.0";
2126
2171
  }
2127
- function Nn(e) {
2172
+ function Rn(e) {
2128
2173
  const t = {};
2129
- for (const s of e.flags)
2130
- t[s.name.slice(2)] = { type: s.value ? "string" : "boolean", description: s.describe };
2174
+ for (const n of e.flags)
2175
+ t[n.name.slice(2)] = { type: n.value ? "string" : "boolean", description: n.describe };
2131
2176
  return {
2132
2177
  type: "object",
2133
2178
  properties: {
@@ -2138,12 +2183,12 @@ function Nn(e) {
2138
2183
  additionalProperties: !1
2139
2184
  };
2140
2185
  }
2141
- function Wn() {
2186
+ function An() {
2142
2187
  return [
2143
- ...Ht.map((e) => ({
2188
+ ...Kt.map((e) => ({
2144
2189
  name: e.name,
2145
2190
  description: `nimpress ${e.argv.join(" ")}: ${e.describe}${e.serves ? ". Keeps running in the background and returns its pid with the first output" : ""}`,
2146
- inputSchema: Nn(e)
2191
+ inputSchema: Rn(e)
2147
2192
  })),
2148
2193
  {
2149
2194
  name: "stop",
@@ -2157,247 +2202,247 @@ function Wn() {
2157
2202
  }
2158
2203
  ];
2159
2204
  }
2160
- function Tn(e, t) {
2161
- const s = [...e.argv, ...t.args ?? []];
2162
- for (const [n, o] of Object.entries(t.flags ?? {}))
2163
- o === !0 ? s.push(`--${n}`) : typeof o == "string" && s.push(`--${n}=${o}`);
2164
- return s;
2205
+ function Mn(e, t) {
2206
+ const n = [...e.argv, ...t.args ?? []];
2207
+ for (const [s, o] of Object.entries(t.flags ?? {}))
2208
+ o === !0 ? n.push(`--${s}`) : typeof o == "string" && n.push(`--${s}=${o}`);
2209
+ return n;
2165
2210
  }
2166
2211
  function U(e, t = !1) {
2167
2212
  return { content: [{ type: "text", text: e || "(no output)" }], ...t ? { isError: t } : {} };
2168
2213
  }
2169
- function Ut(e, t, s) {
2170
- return ke(process.execPath, [process.argv[1], ...Tn(t, s)], {
2171
- cwd: x(e, s.cwd ?? "."),
2214
+ function Yt(e, t, n) {
2215
+ return Se(process.execPath, [process.argv[1], ...Mn(t, n)], {
2216
+ cwd: j(e, n.cwd ?? "."),
2172
2217
  env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" },
2173
2218
  stdio: ["ignore", "pipe", "pipe"]
2174
2219
  });
2175
2220
  }
2176
- function Pn(e, t, s) {
2177
- const n = Ut(e, t, s);
2221
+ function In(e, t, n) {
2222
+ const s = Yt(e, t, n);
2178
2223
  let o = "";
2179
- return n.stdout?.on("data", (r) => o += r), n.stderr?.on("data", (r) => o += r), new Promise((r) => {
2180
- n.on("error", (i) => r(U(`${o}${i.message}`, !0))), n.on("close", (i) => r(U(o, i !== 0)));
2224
+ return s.stdout?.on("data", (r) => o += r), s.stderr?.on("data", (r) => o += r), new Promise((r) => {
2225
+ s.on("error", (i) => r(U(`${o}${i.message}`, !0))), s.on("close", (i) => r(U(o, i !== 0)));
2181
2226
  });
2182
2227
  }
2183
- function Rn(e, t, s) {
2184
- const n = Ut(e, t, s);
2228
+ function Ln(e, t, n) {
2229
+ const s = Yt(e, t, n);
2185
2230
  let o = "";
2186
2231
  return new Promise((r) => {
2187
2232
  const i = (a) => {
2188
- clearTimeout(l), n.stdout?.removeAllListeners("data"), n.stderr?.removeAllListeners("data"), n.stdout?.resume(), n.stderr?.resume(), r(a);
2233
+ clearTimeout(l), s.stdout?.removeAllListeners("data"), s.stderr?.removeAllListeners("data"), s.stdout?.resume(), s.stderr?.resume(), r(a);
2189
2234
  }, c = (a) => {
2190
- o += a, /https?:\/\/\S+/.test(o) && i(U(`pid ${n.pid}
2235
+ o += a, /https?:\/\/\S+/.test(o) && i(U(`pid ${s.pid}
2191
2236
  ${o}`));
2192
- }, l = setTimeout(() => i(U(`pid ${n.pid}
2193
- ${o}`)), Dn);
2194
- n.stdout?.on("data", c), n.stderr?.on("data", c), n.on("error", (a) => i(U(`${o}${a.message}`, !0))), n.on("exit", (a) => {
2195
- de.delete(n.pid ?? -1), i(U(o, a !== 0));
2196
- }), n.pid && de.set(n.pid, n);
2237
+ }, l = setTimeout(() => i(U(`pid ${s.pid}
2238
+ ${o}`)), Tn);
2239
+ s.stdout?.on("data", c), s.stderr?.on("data", c), s.on("error", (a) => i(U(`${o}${a.message}`, !0))), s.on("exit", (a) => {
2240
+ he.delete(s.pid ?? -1), i(U(o, a !== 0));
2241
+ }), s.pid && he.set(s.pid, s);
2197
2242
  });
2198
2243
  }
2199
- function An(e) {
2200
- const t = de.get(e);
2201
- return t ? (t.kill("SIGTERM"), de.delete(e), U(`stopped ${e}`)) : U(`no server with pid ${e} was started by this session`, !0);
2244
+ function zn(e) {
2245
+ const t = he.get(e);
2246
+ return t ? (t.kill("SIGTERM"), he.delete(e), U(`stopped ${e}`)) : U(`no server with pid ${e} was started by this session`, !0);
2202
2247
  }
2203
- async function Mn(e, t) {
2204
- const s = String(t.name ?? ""), n = t.arguments ?? {};
2205
- if (s === "stop") return An(Number(n.pid));
2206
- const o = Ht.find((r) => r.name === s);
2207
- return o ? b(x(e, n.cwd ?? ".")) ? o.serves ? Rn(e, o, n) : Pn(e, o, n) : U(`no folder ${n.cwd} under ${e}`, !0) : U(`unknown tool ${s}`, !0);
2248
+ async function Jn(e, t) {
2249
+ const n = String(t.name ?? ""), s = t.arguments ?? {};
2250
+ if (n === "stop") return zn(Number(s.pid));
2251
+ const o = Kt.find((r) => r.name === n);
2252
+ return o ? y(j(e, s.cwd ?? ".")) ? o.serves ? Ln(e, o, s) : In(e, o, s) : U(`no folder ${s.cwd} under ${e}`, !0) : U(`unknown tool ${n}`, !0);
2208
2253
  }
2209
- function re(e, t) {
2254
+ function ie(e, t) {
2210
2255
  process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: e, ...t }) + `
2211
2256
  `);
2212
2257
  }
2213
- async function In(e, t) {
2258
+ async function Bn(e, t) {
2214
2259
  if (t.id !== void 0) {
2215
2260
  if (t.method === "initialize") {
2216
- re(t.id, {
2261
+ ie(t.id, {
2217
2262
  result: {
2218
2263
  protocolVersion: t.params?.protocolVersion ?? "2025-06-18",
2219
2264
  capabilities: { tools: {} },
2220
- serverInfo: { name: "nimpress", version: _n() }
2265
+ serverInfo: { name: "nimpress", version: Pn() }
2221
2266
  }
2222
2267
  });
2223
2268
  return;
2224
2269
  }
2225
2270
  if (t.method === "ping") {
2226
- re(t.id, { result: {} });
2271
+ ie(t.id, { result: {} });
2227
2272
  return;
2228
2273
  }
2229
2274
  if (t.method === "tools/list") {
2230
- re(t.id, { result: { tools: Wn() } });
2275
+ ie(t.id, { result: { tools: An() } });
2231
2276
  return;
2232
2277
  }
2233
2278
  if (t.method === "tools/call") {
2234
- re(t.id, { result: await Mn(e, t.params ?? {}) });
2279
+ ie(t.id, { result: await Jn(e, t.params ?? {}) });
2235
2280
  return;
2236
2281
  }
2237
- re(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
2282
+ ie(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
2238
2283
  }
2239
2284
  }
2240
- function Ln(e) {
2241
- const t = gs({ input: process.stdin }), s = /* @__PURE__ */ new Set();
2242
- t.on("line", (n) => {
2243
- if (!n.trim()) return;
2285
+ function Gn(e) {
2286
+ const t = bs({ input: process.stdin }), n = /* @__PURE__ */ new Set();
2287
+ t.on("line", (s) => {
2288
+ if (!s.trim()) return;
2244
2289
  let o;
2245
2290
  try {
2246
- o = JSON.parse(n);
2291
+ o = JSON.parse(s);
2247
2292
  } catch {
2248
- re(null, { error: { code: -32700, message: "parse error" } });
2293
+ ie(null, { error: { code: -32700, message: "parse error" } });
2249
2294
  return;
2250
2295
  }
2251
- const r = In(e, o).catch((i) => re(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => s.delete(r));
2252
- s.add(r);
2296
+ const r = Bn(e, o).catch((i) => ie(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => n.delete(r));
2297
+ n.add(r);
2253
2298
  }), t.on("close", async () => {
2254
- await Promise.all(s);
2255
- for (const n of de.values()) n.kill("SIGTERM");
2299
+ await Promise.all(n);
2300
+ for (const s of he.values()) s.kill("SIGTERM");
2256
2301
  process.exit(0);
2257
2302
  });
2258
2303
  }
2259
- function Jn(e, t, s) {
2260
- if (typeof s.path == "string") return s.path.startsWith("/") ? s.path : `/${s.path}`;
2261
- const n = E(e, t).split(L).join("/").replace(/\.md$/, "");
2262
- return n === "index" ? "/" : `/${n.replace(/\/index$/, "")}`;
2304
+ function Hn(e, t, n) {
2305
+ if (typeof n.path == "string") return n.path.startsWith("/") ? n.path : `/${n.path}`;
2306
+ const s = E(e, t).split(z).join("/").replace(/\.md$/, "");
2307
+ return s === "index" ? "/" : `/${s.replace(/\/index$/, "")}`;
2263
2308
  }
2264
- function ot(e) {
2265
- return e ? (Array.isArray(e) ? e : String(e).split(",")).map((s) => String(s).trim()).filter(Boolean) : [];
2309
+ function ct(e) {
2310
+ return e ? (Array.isArray(e) ? e : String(e).split(",")).map((n) => String(n).trim()).filter(Boolean) : [];
2266
2311
  }
2267
- function zn(e) {
2312
+ function Un(e) {
2268
2313
  return e.split(`
2269
2314
  `).filter((t) => /^#{1,6}\s/.test(t)).map((t) => t.replace(/^#{1,6}\s+/, "").trim());
2270
2315
  }
2271
- function Bn(e, t) {
2272
- const s = x(e, t.contentDir), o = X(s).filter((a) => a.endsWith(".md")).map((a) => {
2273
- const { data: u, content: p } = ue(C(a, "utf-8"));
2274
- return { file: a, data: u, content: p };
2316
+ function Zn(e, t) {
2317
+ const n = j(e, t.contentDir), o = X(n).filter((a) => a.endsWith(".md")).map((a) => {
2318
+ const { data: p, content: u } = pe(S(a, "utf-8"));
2319
+ return { file: a, data: p, content: u };
2275
2320
  }).filter((a) => typeof a.data.title == "string" && a.data.visibility !== "hidden" && !a.data.link), r = o.map((a) => ({
2276
2321
  slug: a.file,
2277
2322
  title: String(a.data.title),
2278
- headings: zn(a.content),
2279
- tags: ot(a.data.tags),
2323
+ headings: Un(a.content),
2324
+ tags: ct(a.data.tags),
2280
2325
  body: a.content
2281
- })), i = ls(r), c = t.site?.url?.replace(/\/$/, "") ?? "", l = t.base.replace(/\/$/, "");
2326
+ })), i = fs(r), c = t.site?.url?.replace(/\/$/, "") ?? "", l = t.base.replace(/\/$/, "");
2282
2327
  return o.map((a) => {
2283
- const u = i.get(a.file) ?? { keywords: [], description: "" }, p = a.data.meta ?? {}, m = Array.isArray(p.keywords) ? p.keywords : typeof p.keywords == "string" ? [p.keywords] : void 0, f = typeof p.description == "string" ? p.description : typeof a.data.description == "string" ? a.data.description : void 0, h = p.override === !0, g = t.seo?.auto === !0, w = g ? h && m ? m : u.keywords.length ? u.keywords : m ?? [] : m ?? ot(a.data.tags), k = g ? h && f ? f : u.description || f || "" : f ?? "", j = Jn(s, a.file, a.data);
2328
+ const p = 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 : p.keywords.length ? p.keywords : m ?? [] : m ?? ct(a.data.tags), v = g ? h && f ? f : p.description || f || "" : f ?? "", k = Hn(n, a.file, a.data);
2284
2329
  return {
2285
- path: j,
2286
- file: E(e, a.file).split(L).join("/"),
2330
+ path: k,
2331
+ file: E(e, a.file).split(z).join("/"),
2287
2332
  title: String(a.data.title),
2288
2333
  keywords: w,
2289
- description: k,
2290
- robots: us(typeof p.robots == "string" ? p.robots : "index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1", t.seo?.ai?.index, typeof p.ai == "boolean" ? p.ai : void 0),
2291
- canonical: typeof p.canonical == "string" ? p.canonical : c ? `${c}${l}${j === "/" ? "/" : j}` : "",
2292
- generated: u,
2293
- authored: { keywords: m, description: f, override: h, ai: typeof p.ai == "boolean" ? p.ai : void 0 }
2334
+ description: v,
2335
+ robots: ds(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),
2336
+ canonical: typeof u.canonical == "string" ? u.canonical : c ? `${c}${l}${k === "/" ? "/" : k}` : "",
2337
+ generated: p,
2338
+ authored: { keywords: m, description: f, override: h, ai: typeof u.ai == "boolean" ? u.ai : void 0 }
2294
2339
  };
2295
2340
  });
2296
2341
  }
2297
- function Gn(e, t) {
2298
- let s = 0;
2299
- for (const n of t) {
2300
- const o = x(e, n.file), { data: r, content: i } = ue(C(o, "utf-8")), c = { ...r.meta ?? {} };
2342
+ function Vn(e, t) {
2343
+ let n = 0;
2344
+ for (const s of t) {
2345
+ const o = j(e, s.file), { data: r, content: i } = pe(S(o, "utf-8")), c = { ...r.meta ?? {} };
2301
2346
  let l = !1;
2302
- c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords, l = !0), c.description === void 0 && n.generated.description && (c.description = n.generated.description, l = !0), l && (W(o, ue.stringify(i, { ...r, meta: c })), s += 1);
2347
+ c.keywords === void 0 && s.generated.keywords.length && (c.keywords = s.generated.keywords, l = !0), c.description === void 0 && s.generated.description && (c.description = s.generated.description, l = !0), l && (N(o, pe.stringify(i, { ...r, meta: c })), n += 1);
2303
2348
  }
2304
- return s;
2349
+ return n;
2305
2350
  }
2306
- function Hn(e, t, s) {
2307
- const n = Bn(e, t), o = _(s, "out") ?? "seo.map.json";
2308
- for (const r of n) {
2351
+ function Kn(e, t, n) {
2352
+ const s = Zn(e, t), o = _(n, "out") ?? "seo.map.json";
2353
+ for (const r of s) {
2309
2354
  const i = t.seo?.auto ? r.authored.override ? "authored" : "generated" : "authored";
2310
2355
  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}`);
2311
2356
  }
2312
- if (W(x(e, o), JSON.stringify(n, null, 2) + `
2313
- `), console.log(`nimpress seo: ${n.length} pages, map written to ${o}`), s.includes("--write")) {
2314
- const r = Gn(e, n);
2357
+ if (N(j(e, o), JSON.stringify(s, null, 2) + `
2358
+ `), console.log(`nimpress seo: ${s.length} pages, map written to ${o}`), n.includes("--write")) {
2359
+ const r = Vn(e, s);
2315
2360
  console.log(`nimpress seo: generated fields written into ${r} pages`);
2316
2361
  }
2317
2362
  }
2318
- async function Un(e, t) {
2319
- const s = K(t, 0);
2320
- if (s !== "clear") throw new Error(`[nimpress] cache: unknown subcommand ${s ?? ""}, use clear`);
2321
- const n = M(t, "links"), o = M(t, "sites"), r = M(t, "local"), i = !n && !o && !r;
2322
- if (n || i) {
2323
- const c = _t(), l = Object.keys(c.links).length;
2324
- Nt({ links: {} }), console.log(`nimpress cache: cleared ${l} links`);
2363
+ async function Yn(e, t) {
2364
+ const n = K(t, 0);
2365
+ if (n !== "clear") throw new Error(`[nimpress] cache: unknown subcommand ${n ?? ""}, use clear`);
2366
+ const s = M(t, "links"), o = M(t, "sites"), r = M(t, "local"), i = !s && !o && !r;
2367
+ if (s || i) {
2368
+ const c = Pt(), l = Object.keys(c.links).length;
2369
+ Rt({ links: {} }), console.log(`nimpress cache: cleared ${l} links`);
2325
2370
  }
2326
2371
  if (o || i) {
2327
- const c = Dt();
2328
- te(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
2372
+ const c = Tt();
2373
+ se(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
2329
2374
  }
2330
2375
  if (r) {
2331
- const { resolved: c, configFile: l } = await we(e);
2376
+ const { resolved: c, configFile: l } = await $e(e);
2332
2377
  if (!l) throw new Error(`[nimpress] cache: --local needs a nimpress config in ${e}`);
2333
- const a = Le(e, c);
2334
- b(a) && te(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
2378
+ const a = Be(e, c);
2379
+ y(a) && se(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
2335
2380
  }
2336
2381
  }
2337
- async function co(e) {
2338
- const t = e[0] ?? "dev", s = e.slice(1), n = process.cwd();
2382
+ async function mo(e) {
2383
+ const t = e[0] ?? "dev", n = e.slice(1), s = process.cwd();
2339
2384
  if (t === "init") {
2340
- bs(n);
2385
+ Ss(s);
2341
2386
  return;
2342
2387
  }
2343
2388
  if (t === "skill") {
2344
- dn(n, s);
2389
+ $n(s, n);
2345
2390
  return;
2346
2391
  }
2347
2392
  if (t === "plugin") {
2348
- $n(n, s);
2393
+ kn(s, n);
2349
2394
  return;
2350
2395
  }
2351
2396
  if (t === "mcp") {
2352
- Ln(n);
2397
+ Gn(s);
2353
2398
  return;
2354
2399
  }
2355
2400
  if (t === "completion") {
2356
- En(n, s);
2401
+ Wn(s, n);
2357
2402
  return;
2358
2403
  }
2359
- if (t === "view" || t === "dev" && M(s, "view")) {
2360
- await ln(n, s);
2404
+ if (t === "view" || t === "dev" && M(n, "view")) {
2405
+ await fn(s, n);
2361
2406
  return;
2362
2407
  }
2363
2408
  if (t === "cache") {
2364
- await Un(n, s);
2409
+ await Yn(s, n);
2365
2410
  return;
2366
2411
  }
2367
- const { resolved: o } = await we(n);
2412
+ const { resolved: o } = await $e(s);
2368
2413
  if (t === "seo") {
2369
- Hn(n, o, s);
2414
+ Kn(s, o, n);
2370
2415
  return;
2371
2416
  }
2372
2417
  if (t === "lint") {
2373
- await Ps(n, o);
2418
+ await Is(s, o);
2374
2419
  return;
2375
2420
  }
2376
2421
  if (t === "dev") {
2377
- await Cs(n, o);
2422
+ await Ds(s, o);
2378
2423
  return;
2379
2424
  }
2380
2425
  if (t === "build") {
2381
- await bt(n, o);
2426
+ await St(s, o);
2382
2427
  return;
2383
2428
  }
2384
2429
  if (t === "guard") {
2385
- As(n, o, s);
2430
+ zs(s, o, n);
2386
2431
  return;
2387
2432
  }
2388
2433
  if (t === "modules") {
2389
- await pn(n, o, s);
2434
+ await hn(s, o, n);
2390
2435
  return;
2391
2436
  }
2392
2437
  if (t === "export") {
2393
- Ae(n, o, s);
2438
+ ze(s, o, n);
2394
2439
  return;
2395
2440
  }
2396
2441
  throw new Error(`[nimpress] unknown command: ${t}`);
2397
2442
  }
2398
2443
  export {
2399
- it as buildViteConfig,
2400
- Qt as indexHtml,
2401
- we as loadNimpressConfig,
2402
- co as run
2444
+ ut as buildViteConfig,
2445
+ ts as indexHtml,
2446
+ $e as loadNimpressConfig,
2447
+ mo as run
2403
2448
  };