typerighter 0.7.0 → 0.9.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.
Files changed (37) hide show
  1. package/dist/app-C-qfoH4a.js +373 -0
  2. package/dist/brand-CG1fQshq.js +5 -0
  3. package/dist/{cli-CDd4TNg1.js → cli-mg9QpUrf.js} +159 -132
  4. package/dist/cli.js +1 -1
  5. package/dist/client/app/index.d.ts +12 -3
  6. package/dist/client/app/index.d.ts.map +1 -1
  7. package/dist/client/app/router.d.ts +6 -2
  8. package/dist/client/app/router.d.ts.map +1 -1
  9. package/dist/client/theme-default.js +541 -417
  10. package/dist/client.js +1 -1
  11. package/dist/es-CG8rP6j5.js +22524 -0
  12. package/dist/index.js +2 -2
  13. package/dist/{init-Bfnl0t1B.js → init-BSgCv7vy.js} +664 -654
  14. package/dist/node/build/index.d.ts.map +1 -1
  15. package/dist/node/build/prerender.d.ts +2 -0
  16. package/dist/node/build/prerender.d.ts.map +1 -1
  17. package/dist/node/plugin/vite/index.d.ts.map +1 -1
  18. package/dist/shared/utils/field.d.ts +2 -0
  19. package/dist/shared/utils/field.d.ts.map +1 -0
  20. package/dist/shared/utils/index.d.ts +1 -0
  21. package/dist/shared/utils/index.d.ts.map +1 -1
  22. package/dist/shared/utils/url.d.ts +5 -0
  23. package/dist/shared/utils/url.d.ts.map +1 -1
  24. package/dist/shared-BIdsxcZ2.js +265 -0
  25. package/dist/shared.js +2 -0
  26. package/dist/typerighter.css +1 -1
  27. package/dist/vite-8CV23ALg.js +10704 -0
  28. package/dist/vite.js +1 -1
  29. package/package.json +7 -3
  30. package/dist/app-Bf0aLzaG.js +0 -370
  31. package/dist/brand-BfamszbH.js +0 -12
  32. package/dist/client/app/composables/useUrl.d.ts +0 -6
  33. package/dist/client/app/composables/useUrl.d.ts.map +0 -1
  34. package/dist/constants-DJbUAb1-.js +0 -32189
  35. package/dist/es-ClqUVRJn.js +0 -705
  36. package/dist/shared-CpPZZ8IH.js +0 -196
  37. package/dist/vite-DnP-_NzR.js +0 -326
@@ -1,7 +1,5 @@
1
- import { o as e } from "./constants-DJbUAb1-.js";
2
- import { _ as t, a as n, b as r, g as i, i as a, x as o } from "./shared-CpPZZ8IH.js";
3
- import { o as s } from "./brand-BfamszbH.js";
4
- import { n as c, t as l } from "./vite-DnP-_NzR.js";
1
+ import { A as e, F as t, O as n, P as r, d as i, f as a, s as o } from "./shared-BIdsxcZ2.js";
2
+ import { a as s, n as c, t as l } from "./vite-8CV23ALg.js";
5
3
  import u from "node:path";
6
4
  import d from "picocolors";
7
5
  import { build as f, createServer as p } from "vite";
@@ -15,6 +13,8 @@ async function g(e) {
15
13
  content: c.html,
16
14
  title: c.pageData.title,
17
15
  description: c.pageData.frontmatter.description === void 0 ? "" : String(c.pageData.frontmatter.description),
16
+ url: e.base + s.replace(/^\//, ""),
17
+ siteTitle: e.siteTitle,
18
18
  clientEntry: n,
19
19
  cssFiles: r,
20
20
  jsFiles: i,
@@ -24,16 +24,32 @@ async function g(e) {
24
24
  }));
25
25
  }
26
26
  function _(e) {
27
- let t = e.cssFiles.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), n = e.jsFiles.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n");
27
+ let t = o(e.title), n = o(e.description), r = e.title === e.siteTitle ? t : `${t} - ${o(e.siteTitle)}`, i = e.cssFiles.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), a = e.jsFiles.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n");
28
28
  return `<!DOCTYPE html>
29
29
  <html lang="${e.lang ?? "en"}">
30
30
  <head>
31
31
  <meta charset="UTF-8">
32
32
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
33
- <title>${s(e.title)}</title>
34
- <meta name="description" content="${s(e.description)}">
35
- ${t}
36
- ${n}
33
+ <title>${r}</title>
34
+ <meta name="description" content="${n}">
35
+ <link rel="icon" href="${e.base}favicon.svg" type="image/svg+xml">
36
+ <link rel="canonical" href="${o(e.url)}">
37
+ <meta property="og:type" content="article">
38
+ <meta property="og:title" content="${t}">
39
+ <meta property="og:description" content="${n}">
40
+ <meta property="og:image" content="${e.base}og-image.png">
41
+ <meta name="twitter:card" content="summary_large_image">
42
+ <meta name="twitter:title" content="${t}">
43
+ <meta name="twitter:description" content="${n}">
44
+ <meta name="twitter:image" content="${e.base}og-image.png">
45
+ <script type="application/ld+json">${JSON.stringify({
46
+ "@context": "https://schema.org",
47
+ "@type": "Article",
48
+ headline: e.title,
49
+ description: e.description
50
+ })}<\/script>
51
+ ${i}
52
+ ${a}
37
53
  </head>
38
54
  <body>
39
55
  <div id="app">${e.content}</div>
@@ -76,43 +92,43 @@ function b(e) {
76
92
  //#endregion
77
93
  //#region src/node/build/index.ts
78
94
  var x = "typerighter/client/theme-default";
79
- async function S(e, n = {}) {
80
- let { root: r, logger: i } = e, o = u.resolve(r, n.outDir ?? "dist"), s = n.base ?? "/", d = u.join(o, ".client"), p = u.join(o, ".server");
95
+ async function S(t, n = {}) {
96
+ let { root: r, logger: a } = t, o = u.resolve(r, n.outDir ?? "dist"), s = n.base ?? "/", d = u.join(o, ".client"), p = u.join(o, ".server");
81
97
  await h.rm(o, {
82
98
  recursive: !0,
83
99
  force: !0
84
100
  });
85
- let m = await e.getTdContext(), [_, v, b, S] = await Promise.all([
101
+ let m = await t.getTdContext(), [_, v, b, S] = await Promise.all([
86
102
  m.getConfig(),
87
103
  m.listFiles(),
88
104
  m.listFilesGroupedBySchema(),
89
105
  m.listSchemas()
90
- ]), E = await Promise.all(S.map(async (e) => [e, (await m.getSchema(e)).properties])), D = Object.fromEntries(E), O = a(Object.values(b).flat()), k = JSON.stringify({
106
+ ]), D = await Promise.all(S.map(async (e) => [e, (await m.getSchema(e)).properties])), O = Object.fromEntries(D), k = i(Object.values(b).flat()), A = JSON.stringify({
91
107
  title: _.siteTitle,
92
108
  description: _.siteDescription
93
- }), A = JSON.stringify({ contentTree: O }), j = u.join(r, "node_modules", ".typerighter");
94
- await h.mkdir(j, { recursive: !0 });
95
- let M = u.join(j, "client-entry.js"), N = u.join(j, "ssr-entry.js");
96
- await Promise.all([h.writeFile(M, l({
109
+ }), j = JSON.stringify({ contentTree: k }), M = u.join(r, "node_modules", ".typerighter");
110
+ await h.mkdir(M, { recursive: !0 });
111
+ let N = u.join(M, "client-entry.js"), P = u.join(M, "ssr-entry.js");
112
+ await Promise.all([h.writeFile(N, l({
97
113
  contentDir: _.contentDir,
98
114
  siteTitle: _.siteTitle,
99
115
  siteDescription: _.siteDescription,
100
116
  repo: _.repo,
101
- contentTree: O,
102
- schemas: D
103
- })), h.writeFile(N, C({
117
+ contentTree: k,
118
+ schemas: O
119
+ })), h.writeFile(P, C({
104
120
  contentDir: _.contentDir,
105
121
  layoutImport: x,
106
- siteConfig: k,
107
- siteData: A
122
+ siteConfig: A,
123
+ siteData: j
108
124
  }))]);
109
125
  try {
110
- let a = c({ context: e }), l = e.createViteLogger(), m = new y(i, "Building client bundle...");
126
+ let i = c({ context: t }), l = t.createViteLogger(), m = new y(a, "Building client bundle...");
111
127
  await f({
112
128
  ...n.viteConfig,
113
129
  root: r,
114
130
  base: s,
115
- plugins: a,
131
+ plugins: i,
116
132
  customLogger: l,
117
133
  logLevel: "silent",
118
134
  build: {
@@ -122,46 +138,49 @@ async function S(e, n = {}) {
122
138
  emptyOutDir: !0,
123
139
  rollupOptions: {
124
140
  ...n.viteConfig?.build?.rollupOptions,
125
- input: M
141
+ input: N
126
142
  }
127
143
  }
128
144
  });
129
145
  let b = await h.readdir(u.join(d, "assets")).catch(() => []);
130
146
  m.done(`Client bundle (${b.length} chunks)`);
131
- let x = new y(i, "Building SSR bundle...");
147
+ let x = new y(a, "Building SSR bundle...");
132
148
  await f({
133
149
  ...n.viteConfig,
134
150
  root: r,
135
151
  base: s,
136
- plugins: a,
152
+ plugins: i,
137
153
  customLogger: l,
138
154
  logLevel: "silent",
139
155
  build: {
140
156
  ...n.viteConfig?.build,
141
157
  outDir: p,
142
- ssr: N,
158
+ ssr: P,
143
159
  emptyOutDir: !0
144
160
  }
145
161
  }), x.done("SSR bundle");
146
- let S = v.map((e) => {
147
- let n = t(e);
162
+ let S = v.map((t) => {
163
+ let n = e(t);
148
164
  return n === "index" ? "/" : `/${n}`;
149
165
  });
150
- S.push("/"), T(O.children, "", S);
151
- let C = new y(i, "Pre-rendering pages...");
166
+ S.push("/"), E(k.children, "", S);
167
+ let C = new y(a, "Pre-rendering pages...");
152
168
  await g({
153
169
  ssrEntryPath: u.join(p, "ssr-entry.js"),
154
170
  clientOutDir: d,
155
171
  outDir: o,
156
172
  base: s,
157
173
  pagePaths: S,
174
+ siteTitle: _.siteTitle,
158
175
  progress: C
159
176
  }), C.done(`Pre-rendered ${S.length} pages`);
160
- let E = u.join(d, "assets"), D = u.join(o, "assets");
161
- await h.cp(E, D, { recursive: !0 }).catch(() => {}), await w(u.join(r, _.contentDir), o);
177
+ let D = T(S, s);
178
+ await h.writeFile(u.join(o, "sitemap.xml"), D);
179
+ let O = u.join(d, "assets"), A = u.join(o, "assets");
180
+ await h.cp(O, A, { recursive: !0 }).catch(() => {}), await w(u.join(r, _.contentDir), o);
162
181
  } finally {
163
182
  await Promise.all([
164
- h.rm(j, {
183
+ h.rm(M, {
165
184
  recursive: !0,
166
185
  force: !0
167
186
  }),
@@ -175,24 +194,25 @@ async function S(e, n = {}) {
175
194
  })
176
195
  ]);
177
196
  }
178
- i.log(`\nBuild complete. Output: ${o}`);
197
+ a.log(`\nBuild complete. Output: ${o}`);
179
198
  }
180
199
  function C(e) {
181
- let t = `/${e.contentDir}/${o}`, i = JSON.parse(e.siteConfig), a = JSON.parse(e.siteData), s = n((a.contentTree ?? {
200
+ let n = `/${e.contentDir}/${t}`, i = JSON.parse(e.siteConfig), o = JSON.parse(e.siteData), s = a((o.contentTree ?? {
182
201
  rootItems: [],
183
202
  children: []
184
203
  }).children ?? [], i.title ?? ""), c = JSON.stringify({
185
- ...a,
204
+ ...o,
186
205
  directoryListings: s
187
206
  });
188
207
  return `
189
208
  import { createTypedownApp } from 'typerighter/client';
190
209
  import { TdDirectoryIndex } from 'typerighter/client/theme-default';
210
+ import { isIndexUrl, getDirectoryFromPageUrl } from 'typerighter/shared';
191
211
  import { renderToString } from 'vue/server-renderer';
192
212
  import { h } from 'vue';
193
213
  import theme from '${e.layoutImport}';
194
214
 
195
- const pages = import.meta.glob('${t}', { eager: true });
215
+ const pages = import.meta.glob('${n}', { eager: true });
196
216
  const contentExts = ${JSON.stringify(r)};
197
217
  const siteData = ${c};
198
218
 
@@ -208,9 +228,9 @@ function loadPageModule(pagePath) {
208
228
  const page = findPage(base);
209
229
  if (page) return Promise.resolve(page);
210
230
 
211
- if (pagePath.endsWith('/index')) {
212
- const dirPath = pagePath.slice(0, -'/index'.length) || '/';
213
- const dir = siteData.directoryListings[dirPath] || siteData.directoryListings[dirPath + '/'];
231
+ if (isIndexUrl(pagePath)) {
232
+ const dirPath = getDirectoryFromPageUrl(pagePath);
233
+ const dir = siteData.directoryListings[dirPath];
214
234
  if (dir) return Promise.resolve({
215
235
  default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex); } },
216
236
  __pageData: { frontmatter: {}, headings: [], title: dir.title },
@@ -229,35 +249,42 @@ export async function render(url) {
229
249
  `;
230
250
  }
231
251
  async function w(e, t) {
232
- let n = (await h.readdir(e, {
252
+ let r = (await h.readdir(e, {
233
253
  recursive: !0,
234
254
  withFileTypes: !0
235
- })).filter((e) => e.isFile() && !i(e.name)).map(async (n) => {
255
+ })).filter((e) => e.isFile() && !n(e.name)).map(async (n) => {
236
256
  let r = u.join(n.parentPath, n.name), i = u.relative(e, r), a = u.join(t, i);
237
257
  return h.mkdir(u.dirname(a), { recursive: !0 }).then(() => h.copyFile(r, a));
238
258
  });
239
- await Promise.all(n);
259
+ await Promise.all(r);
240
260
  }
241
- function T(e, t, n) {
261
+ function T(e, t) {
262
+ return `<?xml version="1.0" encoding="UTF-8"?>
263
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
264
+ ${e.map((e) => ` <url><loc>${o(t + e.replace(/^\//, ""))}</loc></url>`).join("\n")}
265
+ </urlset>
266
+ `;
267
+ }
268
+ function E(e, t, n) {
242
269
  for (let r of e) {
243
270
  let e = `${t}/${r.name}`;
244
- n.push(e), T(r.children, e, n);
271
+ n.push(e), E(r.children, e, n);
245
272
  }
246
273
  }
247
274
  //#endregion
248
275
  //#region ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
249
- function E(e) {
276
+ function D(e) {
250
277
  return e == null ? [] : Array.isArray(e) ? e : [e];
251
278
  }
252
- function D(e, t, n, r) {
279
+ function O(e, t, n, r) {
253
280
  var i, a = e[t], o = ~r.string.indexOf(t) ? n == null || n === !0 ? "" : String(n) : typeof n == "boolean" ? n : ~r.boolean.indexOf(t) ? n === "false" ? !1 : n === "true" || (e._.push((i = +n, i * 0 == 0 ? i : n)), !!n) : (i = +n, i * 0 == 0 ? i : n);
254
281
  e[t] = a == null ? o : Array.isArray(a) ? a.concat(o) : [a, o];
255
282
  }
256
- function O(e, t) {
283
+ function k(e, t) {
257
284
  e ||= [], t ||= {};
258
285
  var n, r, i, a, o, s = { _: [] }, c = 0, l = 0, u = 0, d = e.length;
259
286
  let f = t.alias !== void 0, p = t.unknown !== void 0, m = t.default !== void 0;
260
- if (t.alias = t.alias || {}, t.string = E(t.string), t.boolean = E(t.boolean), f) for (n in t.alias) for (r = t.alias[n] = E(t.alias[n]), c = 0; c < r.length; c++) (t.alias[r[c]] = r.concat(n)).splice(c, 1);
287
+ if (t.alias = t.alias || {}, t.string = D(t.string), t.boolean = D(t.boolean), f) for (n in t.alias) for (r = t.alias[n] = D(t.alias[n]), c = 0; c < r.length; c++) (t.alias[r[c]] = r.concat(n)).splice(c, 1);
261
288
  for (c = t.boolean.length; c-- > 0;) for (r = t.alias[t.boolean[c]] || [], l = r.length; l-- > 0;) t.boolean.push(r[l]);
262
289
  for (c = t.string.length; c-- > 0;) for (r = t.alias[t.string[c]] || [], l = r.length; l-- > 0;) t.string.push(r[l]);
263
290
  if (m) {
@@ -278,7 +305,7 @@ function O(e, t) {
278
305
  for (u = l + 1; u < i.length && i.charCodeAt(u) !== 61; u++);
279
306
  for (a = i.substring(l, u), o = i.substring(++u) || c + 1 === d || ("" + e[c + 1]).charCodeAt(0) === 45 || e[++c], r = l === 2 ? [a] : a, u = 0; u < r.length; u++) {
280
307
  if (a = r[u], p && !~h.indexOf(a)) return t.unknown("-".repeat(l) + a);
281
- D(s, a, u + 1 < r.length || o, t);
308
+ O(s, a, u + 1 < r.length || o, t);
282
309
  }
283
310
  }
284
311
  }
@@ -286,10 +313,10 @@ function O(e, t) {
286
313
  if (f) for (n in s) for (r = t.alias[n] || []; r.length > 0;) s[r.shift()] = s[n];
287
314
  return s;
288
315
  }
289
- function k(e) {
316
+ function A(e) {
290
317
  return e.replace(/[<[].+/, "").trim();
291
318
  }
292
- function A(e) {
319
+ function j(e) {
293
320
  let t = /<([^>]+)>/g, n = /\[([^\]]+)\]/g, r = [], i = (e) => {
294
321
  let t = !1, n = e[1];
295
322
  return n.startsWith("...") && (n = n.slice(3), t = !0), {
@@ -303,7 +330,7 @@ function A(e) {
303
330
  for (; o = n.exec(e);) r.push(i(o));
304
331
  return r;
305
332
  }
306
- function j(e) {
333
+ function M(e) {
307
334
  let t = {
308
335
  alias: {},
309
336
  boolean: []
@@ -311,16 +338,16 @@ function j(e) {
311
338
  for (let [n, r] of e.entries()) r.names.length > 1 && (t.alias[r.names[0]] = r.names.slice(1)), r.isBoolean && (r.negated && e.some((e, t) => t !== n && e.names.some((e) => r.names.includes(e)) && typeof e.required == "boolean") || t.boolean.push(r.names[0]));
312
339
  return t;
313
340
  }
314
- function M(e) {
341
+ function N(e) {
315
342
  return e.sort((e, t) => e.length > t.length ? -1 : 1)[0];
316
343
  }
317
- function N(e, t) {
344
+ function P(e, t) {
318
345
  return e.length >= t ? e : `${e}${" ".repeat(t - e.length)}`;
319
346
  }
320
- function P(e) {
347
+ function F(e) {
321
348
  return e.replaceAll(/([a-z])-([a-z])/g, (e, t, n) => t + n.toUpperCase());
322
349
  }
323
- function F(e, t, n) {
350
+ function I(e, t, n) {
324
351
  let r = e;
325
352
  for (let e = 0; e < t.length; e++) {
326
353
  let i = t[e];
@@ -335,24 +362,24 @@ function F(e, t, n) {
335
362
  r = r[i];
336
363
  }
337
364
  }
338
- function I(e, t) {
365
+ function L(e, t) {
339
366
  for (let n of Object.keys(t)) {
340
367
  let r = t[n];
341
368
  r.shouldTransform && (e[n] = [e[n]].flat(), typeof r.transformFunction == "function" && (e[n] = e[n].map(r.transformFunction)));
342
369
  }
343
370
  }
344
- function L(e) {
371
+ function R(e) {
345
372
  let t = /([^\\/]+)$/.exec(e);
346
373
  return t ? t[1] : "";
347
374
  }
348
- function R(e) {
349
- return e.split(".").map((e, t) => t === 0 ? P(e) : e).join(".");
375
+ function z(e) {
376
+ return e.split(".").map((e, t) => t === 0 ? F(e) : e).join(".");
350
377
  }
351
- var z = class extends Error {
378
+ var B = class extends Error {
352
379
  constructor(e) {
353
380
  super(e), this.name = "CACError", typeof Error.captureStackTrace != "function" && (this.stack = Error(e).stack);
354
381
  }
355
- }, B = class {
382
+ }, V = class {
356
383
  rawName;
357
384
  description;
358
385
  name;
@@ -362,17 +389,17 @@ var z = class extends Error {
362
389
  config;
363
390
  negated;
364
391
  constructor(e, t, n) {
365
- this.rawName = e, this.description = t, this.config = Object.assign({}, n), e = e.replaceAll(".*", ""), this.negated = !1, this.names = k(e).split(",").map((e) => {
392
+ this.rawName = e, this.description = t, this.config = Object.assign({}, n), e = e.replaceAll(".*", ""), this.negated = !1, this.names = A(e).split(",").map((e) => {
366
393
  let t = e.trim().replace(/^-{1,2}/, "");
367
- return t.startsWith("no-") && (this.negated = !0, t = t.replace(/^no-/, "")), R(t);
394
+ return t.startsWith("no-") && (this.negated = !0, t = t.replace(/^no-/, "")), z(t);
368
395
  }).sort((e, t) => e.length > t.length ? 1 : -1), this.name = this.names.at(-1), this.negated && this.config.default == null && (this.config.default = !0), e.includes("<") ? this.required = !0 : e.includes("[") ? this.required = !1 : this.isBoolean = !0;
369
396
  }
370
- }, V, H;
397
+ }, H, U;
371
398
  if (typeof process < "u") {
372
399
  let e;
373
- e = typeof Deno < "u" && typeof Deno.version?.deno == "string" ? "deno" : typeof Bun < "u" && typeof Bun.version == "string" ? "bun" : "node", H = `${process.platform}-${process.arch} ${e}-${process.version}`, V = process.argv;
374
- } else H = typeof navigator > "u" ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
375
- var U = class {
400
+ e = typeof Deno < "u" && typeof Deno.version?.deno == "string" ? "deno" : typeof Bun < "u" && typeof Bun.version == "string" ? "bun" : "node", U = `${process.platform}-${process.arch} ${e}-${process.version}`, H = process.argv;
401
+ } else U = typeof navigator > "u" ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
402
+ var W = class {
376
403
  rawName;
377
404
  description;
378
405
  config;
@@ -388,7 +415,7 @@ var U = class {
388
415
  helpCallback;
389
416
  globalCommand;
390
417
  constructor(e, t, n = {}, r) {
391
- this.rawName = e, this.description = t, this.config = n, this.cli = r, this.options = [], this.aliasNames = [], this.name = k(e), this.args = A(e), this.examples = [];
418
+ this.rawName = e, this.description = t, this.config = n, this.cli = r, this.options = [], this.aliasNames = [], this.name = A(e), this.args = j(e), this.examples = [];
392
419
  }
393
420
  usage(e) {
394
421
  return this.usageText = e, this;
@@ -406,7 +433,7 @@ var U = class {
406
433
  return this.examples.push(e), this;
407
434
  }
408
435
  option(e, t, n) {
409
- let r = new B(e, t, n);
436
+ let r = new V(e, t, n);
410
437
  return this.options.push(r), this;
411
438
  }
412
439
  alias(e) {
@@ -422,7 +449,7 @@ var U = class {
422
449
  return this.name === "" || this.aliasNames.includes("!");
423
450
  }
424
451
  get isGlobalCommand() {
425
- return this instanceof W;
452
+ return this instanceof G;
426
453
  }
427
454
  hasOption(e) {
428
455
  return e = e.split(".")[0], this.options.find((t) => t.names.includes(e));
@@ -433,10 +460,10 @@ var U = class {
433
460
  title: "Usage",
434
461
  body: ` $ ${e} ${this.usageText || this.rawName}`
435
462
  }), (this.isGlobalCommand || this.isDefaultCommand) && t.length > 0) {
436
- let n = M(t.map((e) => e.rawName));
463
+ let n = N(t.map((e) => e.rawName));
437
464
  a.push({
438
465
  title: "Commands",
439
- body: t.map((e) => ` ${N(e.rawName, n.length)} ${e.description}`).join("\n")
466
+ body: t.map((e) => ` ${P(e.rawName, n.length)} ${e.description}`).join("\n")
440
467
  }, {
441
468
  title: "For more info, run any command with the `--help` flag",
442
469
  body: t.map((t) => ` $ ${e}${t.name === "" ? "" : ` ${t.name}`} --help`).join("\n")
@@ -444,10 +471,10 @@ var U = class {
444
471
  }
445
472
  let o = this.isGlobalCommand ? r : [...this.options, ...r || []];
446
473
  if (!this.isGlobalCommand && !this.isDefaultCommand && (o = o.filter((e) => e.name !== "version")), o.length > 0) {
447
- let e = M(o.map((e) => e.rawName));
474
+ let e = N(o.map((e) => e.rawName));
448
475
  a.push({
449
476
  title: "Options",
450
- body: o.map((t) => ` ${N(t.rawName, e.length)} ${t.description} ${t.config.default === void 0 ? "" : `(default: ${t.config.default})`}`).join("\n")
477
+ body: o.map((t) => ` ${P(t.rawName, e.length)} ${t.description} ${t.config.default === void 0 ? "" : `(default: ${t.config.default})`}`).join("\n")
451
478
  });
452
479
  }
453
480
  this.examples.length > 0 && a.push({
@@ -457,16 +484,16 @@ var U = class {
457
484
  }
458
485
  outputVersion() {
459
486
  let { name: e } = this.cli, { versionNumber: t } = this.cli.globalCommand;
460
- t && console.info(`${e}/${t} ${H}`);
487
+ t && console.info(`${e}/${t} ${U}`);
461
488
  }
462
489
  checkRequiredArgs() {
463
490
  let e = this.args.filter((e) => e.required).length;
464
- if (this.cli.args.length < e) throw new z(`missing required args for command \`${this.rawName}\``);
491
+ if (this.cli.args.length < e) throw new B(`missing required args for command \`${this.rawName}\``);
465
492
  }
466
493
  checkUnknownOptions() {
467
494
  let { options: e, globalCommand: t } = this.cli;
468
495
  if (!this.config.allowUnknownOptions) {
469
- for (let n of Object.keys(e)) if (n !== "--" && !this.hasOption(n) && !t.hasOption(n)) throw new z(`Unknown option \`${n.length > 1 ? `--${n}` : `-${n}`}\``);
496
+ for (let n of Object.keys(e)) if (n !== "--" && !this.hasOption(n) && !t.hasOption(n)) throw new B(`Unknown option \`${n.length > 1 ? `--${n}` : `-${n}`}\``);
470
497
  }
471
498
  }
472
499
  checkOptionValue() {
@@ -475,19 +502,19 @@ var U = class {
475
502
  let r = e[t.name.split(".")[0]];
476
503
  if (t.required) {
477
504
  let e = n.some((e) => e.negated && e.names.includes(t.name));
478
- if (r === !0 || r === !1 && !e) throw new z(`option \`${t.rawName}\` value is missing`);
505
+ if (r === !0 || r === !1 && !e) throw new B(`option \`${t.rawName}\` value is missing`);
479
506
  }
480
507
  }
481
508
  }
482
509
  checkUnusedArgs() {
483
510
  let e = this.args.some((e) => e.variadic) ? Infinity : this.args.length;
484
- if (e < this.cli.args.length) throw new z(`Unused args: ${this.cli.args.slice(e).map((e) => `\`${e}\``).join(", ")}`);
511
+ if (e < this.cli.args.length) throw new B(`Unused args: ${this.cli.args.slice(e).map((e) => `\`${e}\``).join(", ")}`);
485
512
  }
486
- }, W = class extends U {
513
+ }, G = class extends W {
487
514
  constructor(e) {
488
515
  super("@@global@@", "", {}, e);
489
516
  }
490
- }, G = class extends EventTarget {
517
+ }, K = class extends EventTarget {
491
518
  name;
492
519
  commands;
493
520
  globalCommand;
@@ -499,13 +526,13 @@ var U = class {
499
526
  showHelpOnExit;
500
527
  showVersionOnExit;
501
528
  constructor(e = "") {
502
- super(), this.name = e, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new W(this), this.globalCommand.usage("<command> [options]");
529
+ super(), this.name = e, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new G(this), this.globalCommand.usage("<command> [options]");
503
530
  }
504
531
  usage(e) {
505
532
  return this.globalCommand.usage(e), this;
506
533
  }
507
534
  command(e, t, n) {
508
- let r = new U(e, t || "", n, this);
535
+ let r = new W(e, t || "", n, this);
509
536
  return r.globalCommand = this.globalCommand, this.commands.push(r), r;
510
537
  }
511
538
  option(e, t, n) {
@@ -534,10 +561,10 @@ var U = class {
534
561
  }
535
562
  parse(e, { run: t = !0 } = {}) {
536
563
  if (!e) {
537
- if (!V) throw Error("No argv provided and runtime process argv is not available.");
538
- e = V;
564
+ if (!H) throw Error("No argv provided and runtime process argv is not available.");
565
+ e = H;
539
566
  }
540
- this.rawArgs = e, this.name ||= e[1] ? L(e[1]) : "cli";
567
+ this.rawArgs = e, this.name ||= e[1] ? R(e[1]) : "cli";
541
568
  let n = !0;
542
569
  for (let t of this.commands) {
543
570
  let r = this.mri(e.slice(2), t), i = r.args[0];
@@ -569,19 +596,19 @@ var U = class {
569
596
  return t && this.runMatchedCommand(), !this.matchedCommand && this.args[0] && this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] })), r;
570
597
  }
571
598
  mri(e, t) {
572
- let n = [...this.globalCommand.options, ...t ? t.options : []], r = j(n), i = [], a = e.indexOf("--");
599
+ let n = [...this.globalCommand.options, ...t ? t.options : []], r = M(n), i = [], a = e.indexOf("--");
573
600
  a !== -1 && (i = e.slice(a + 1), e = e.slice(0, a));
574
- let o = O(e, r);
601
+ let o = k(e, r);
575
602
  o = Object.keys(o).reduce((e, t) => ({
576
603
  ...e,
577
- [R(t)]: o[t]
604
+ [z(t)]: o[t]
578
605
  }), { _: [] });
579
606
  let s = o._, c = { "--": i }, l = t && t.config.ignoreOptionDefaultValue ? t.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue, u = Object.create(null);
580
607
  for (let e of n) {
581
608
  if (!l && e.config.default !== void 0) for (let t of e.names) c[t] = e.config.default;
582
609
  Array.isArray(e.config.type) && u[e.name] === void 0 && (u[e.name] = Object.create(null), u[e.name].shouldTransform = !0, u[e.name].transformFunction = e.config.type[0]);
583
610
  }
584
- for (let e of Object.keys(o)) e !== "_" && (F(c, e.split("."), o[e]), I(c, u));
611
+ for (let e of Object.keys(o)) e !== "_" && (I(c, e.split("."), o[e]), L(c, u));
585
612
  return {
586
613
  args: s,
587
614
  options: c
@@ -596,16 +623,16 @@ var U = class {
596
623
  t.variadic ? r.push(e.slice(n)) : r.push(e[n]);
597
624
  }), r.push(t), n.commandAction.apply(this, r);
598
625
  }
599
- }, K = (e = "") => new G(e), q = d.bold(d.cyan("[typerighter]"));
600
- function J() {
601
- let t = K("typerighter");
626
+ }, q = (e = "") => new K(e), J = d.bold(d.cyan("[typerighter]"));
627
+ function Y() {
628
+ let e = q("typerighter");
602
629
  process.on("uncaughtException", (e) => {
603
- Y("runtime", e);
630
+ X("runtime", e);
604
631
  }), process.on("unhandledRejection", (e) => {
605
- Y("runtime", e instanceof Error ? e : Error(String(e)));
606
- }), t.command("[root]", "Start dev server").alias("dev").option("--port <port>", "Port to listen on").option("--host", "Expose to network").action(async (e, t) => {
632
+ X("runtime", e instanceof Error ? e : Error(String(e)));
633
+ }), e.command("[root]", "Start dev server").alias("dev").option("--port <port>", "Port to listen on").option("--host", "Expose to network").action(async (e, t) => {
607
634
  let n = await p({
608
- root: X(e),
635
+ root: Z(e),
609
636
  configFile: !1,
610
637
  plugins: [c()],
611
638
  server: {
@@ -614,55 +641,55 @@ function J() {
614
641
  }
615
642
  });
616
643
  await n.listen(), n.printUrls();
617
- }), t.command("build [root]", "Build for production").option("--outDir <dir>", "Output directory", { default: "dist" }).option("--base <path>", "Base public path", { default: "/" }).action(async (t, n) => {
618
- let r = e(X(t));
644
+ }), e.command("build [root]", "Build for production").option("--outDir <dir>", "Output directory", { default: "dist" }).option("--base <path>", "Base public path", { default: "/" }).action(async (e, t) => {
645
+ let n = s(Z(e));
619
646
  try {
620
- await S(r, {
621
- outDir: n.outDir,
622
- base: n.base
647
+ await S(n, {
648
+ outDir: t.outDir,
649
+ base: t.base
623
650
  });
624
651
  } finally {
625
- r.dispose();
652
+ n.dispose();
626
653
  }
627
- }), t.command("init [root]", "Scaffold a new project").action(async (e) => {
628
- let { initialize: t } = await import("./init-Bfnl0t1B.js");
629
- await t(X(e));
630
- }), t.command("preview [root]", "Preview production build").option("--port <port>", "Port to listen on").action(async (e, t) => {
654
+ }), e.command("init [root]", "Scaffold a new project").action(async (e) => {
655
+ let { initialize: t } = await import("./init-BSgCv7vy.js");
656
+ await t(Z(e));
657
+ }), e.command("preview [root]", "Preview production build").option("--port <port>", "Port to listen on").action(async (e, t) => {
631
658
  let { preview: n } = await import("vite");
632
659
  (await n({
633
- root: X(e),
660
+ root: Z(e),
634
661
  preview: { port: t.port }
635
662
  })).printUrls();
636
- }), t.command("check [root]", "Check vault for errors").option("--fix", "Auto-fix formatting issues").action(async (t, n) => {
637
- let r = e(X(t)), { logger: i } = r;
663
+ }), e.command("check [root]", "Check vault for errors").option("--fix", "Auto-fix formatting issues").action(async (e, t) => {
664
+ let n = s(Z(e)), { logger: r } = n;
638
665
  try {
639
- i.start("Checking vault...");
640
- let e = await r.getTdContext(), t = await e.checkVault();
641
- for (let e of t.diagnostics) e.severity === "error" ? i.error(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`) : i.warn(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`);
642
- if (n.fix && 0 < t.warningCount) {
643
- let t = await e.getConfig(), n = await e.listFiles(), r = 0;
644
- for (let i of n) {
645
- let n = await e.formatFile(i);
666
+ r.start("Checking vault...");
667
+ let e = await n.getTdContext(), i = await e.checkVault();
668
+ for (let e of i.diagnostics) e.severity === "error" ? r.error(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`) : r.warn(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`);
669
+ if (t.fix && 0 < i.warningCount) {
670
+ let t = await e.getConfig(), n = await e.listFiles(), i = 0;
671
+ for (let r of n) {
672
+ let n = await e.formatFile(r);
646
673
  if (n.changed) {
647
- let e = u.resolve(t.contentDir, i);
648
- m.writeFileSync(e, n.content), r++;
674
+ let e = u.resolve(t.contentDir, r);
675
+ m.writeFileSync(e, n.content), i++;
649
676
  }
650
677
  }
651
- 0 < r && i.success(`Fixed ${r} file(s)`);
678
+ 0 < i && r.success(`Fixed ${i} file(s)`);
652
679
  }
653
- let a = `${t.fileCount} files checked, ${t.errorCount} error(s), ${t.warningCount} warning(s)`;
654
- 0 < t.errorCount ? (i.error(a), process.exit(1)) : i.success(a);
680
+ let a = `${i.fileCount} files checked, ${i.errorCount} error(s), ${i.warningCount} warning(s)`;
681
+ 0 < i.errorCount ? (r.error(a), process.exit(1)) : r.success(a);
655
682
  } finally {
656
- r.dispose();
683
+ n.dispose();
657
684
  }
658
- }), t.help(), t.version("0.7.0"), t.parse();
685
+ }), e.help(), e.version("0.9.0"), e.parse();
659
686
  }
660
- function Y(e, t) {
687
+ function X(e, t) {
661
688
  let n = t instanceof Error ? t.message : String(t);
662
- console.error(`\n${q} ${d.red(`${e} failed`)}\n`), console.error(d.red(n)), console.error(""), process.exit(1);
689
+ console.error(`\n${J} ${d.red(`${e} failed`)}\n`), console.error(d.red(n)), console.error(""), process.exit(1);
663
690
  }
664
- function X(e) {
691
+ function Z(e) {
665
692
  return u.resolve(e ?? process.cwd());
666
693
  }
667
694
  //#endregion
668
- export { S as n, J as t };
695
+ export { S as n, Y as t };
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as e } from "./cli-CDd4TNg1.js";
1
+ import { t as e } from "./cli-mg9QpUrf.js";
2
2
  export { e as cli };