typerighter 0.3.1 → 0.4.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 (91) hide show
  1. package/dist/app-Bw90hv7G.js +266 -0
  2. package/dist/brand-BtMsUv5o.js +201 -0
  3. package/dist/{cli-VgaueuJP.js → cli-s44ly0MH.js} +227 -172
  4. package/dist/cli.js +1 -1
  5. package/dist/client/app/index.d.ts +12 -4
  6. package/dist/client/app/index.d.ts.map +1 -1
  7. package/dist/client/app/router.d.ts.map +1 -1
  8. package/dist/client/theme-default.js +707 -149
  9. package/dist/client.js +2 -2
  10. package/dist/constants-E2UATqMm.js +32183 -0
  11. package/dist/es-ClqUVRJn.js +705 -0
  12. package/dist/index.js +4 -4
  13. package/dist/{init-Ci83UWu-.js → init-0hKcjQtf.js} +10 -12
  14. package/dist/node/build/index.d.ts.map +1 -1
  15. package/dist/node/lib/markdown/index.d.ts.map +1 -1
  16. package/dist/node/lib/markdown/plugins/callout-container.d.ts +4 -0
  17. package/dist/node/lib/markdown/plugins/callout-container.d.ts.map +1 -0
  18. package/dist/node/lib/markdown/plugins/custom-container.d.ts +3 -0
  19. package/dist/node/lib/markdown/plugins/custom-container.d.ts.map +1 -0
  20. package/dist/node/lib/markdown/plugins/{highlight.d.ts → highlight/index.d.ts} +1 -1
  21. package/dist/node/lib/markdown/plugins/highlight/index.d.ts.map +1 -0
  22. package/dist/node/lib/markdown/plugins/highlight/language.d.ts +3 -0
  23. package/dist/node/lib/markdown/plugins/highlight/language.d.ts.map +1 -0
  24. package/dist/node/lib/progress.d.ts.map +1 -1
  25. package/dist/node/lib/render/vue.d.ts +2 -2
  26. package/dist/node/lib/render/vue.d.ts.map +1 -1
  27. package/dist/node/lib/typedown-context.d.ts +4 -4
  28. package/dist/node/lib/typedown-context.d.ts.map +1 -1
  29. package/dist/node/plugin/vite/constants.d.ts +2 -1
  30. package/dist/node/plugin/vite/constants.d.ts.map +1 -1
  31. package/dist/node/plugin/vite/index.d.ts +15 -1
  32. package/dist/node/plugin/vite/index.d.ts.map +1 -1
  33. package/dist/node/plugin/vite/search.d.ts +15 -0
  34. package/dist/node/plugin/vite/search.d.ts.map +1 -0
  35. package/dist/shared/constants.d.ts +6 -0
  36. package/dist/shared/constants.d.ts.map +1 -0
  37. package/dist/shared/index.d.ts +1 -0
  38. package/dist/shared/index.d.ts.map +1 -1
  39. package/dist/shared/types/content.d.ts +54 -4
  40. package/dist/shared/types/content.d.ts.map +1 -1
  41. package/dist/shared/types/ssg.d.ts +3 -1
  42. package/dist/shared/types/ssg.d.ts.map +1 -1
  43. package/dist/shared/utils/content.d.ts +5 -5
  44. package/dist/shared/utils/content.d.ts.map +1 -1
  45. package/dist/shared/utils/debounce.d.ts +2 -0
  46. package/dist/shared/utils/debounce.d.ts.map +1 -0
  47. package/dist/shared/utils/format.d.ts +5 -1
  48. package/dist/shared/utils/format.d.ts.map +1 -1
  49. package/dist/shared/utils/html.d.ts +1 -0
  50. package/dist/shared/utils/html.d.ts.map +1 -1
  51. package/dist/shared/utils/index.d.ts +6 -4
  52. package/dist/shared/utils/index.d.ts.map +1 -1
  53. package/dist/shared/utils/path.d.ts +8 -0
  54. package/dist/shared/utils/path.d.ts.map +1 -0
  55. package/dist/shared/utils/regex.d.ts +2 -0
  56. package/dist/shared/utils/regex.d.ts.map +1 -0
  57. package/dist/shared/utils/time.d.ts +6 -0
  58. package/dist/shared/utils/time.d.ts.map +1 -0
  59. package/dist/shared/utils/url.d.ts +6 -2
  60. package/dist/shared/utils/url.d.ts.map +1 -1
  61. package/dist/typerighter.css +1 -1
  62. package/dist/vite-nzhkELg7.js +309 -0
  63. package/dist/vite.js +2 -3
  64. package/package.json +9 -5
  65. package/dist/app-CM3biamr.js +0 -184
  66. package/dist/brand-CeSqpEQ2.js +0 -4
  67. package/dist/chunk-DfAF0w94-EwUSVR-h.js +0 -13
  68. package/dist/constants-B7b8AsH0.js +0 -9530
  69. package/dist/content-BM3UKxcc.js +0 -16
  70. package/dist/lib-CBtriEt5-Ch50D04V.js +0 -3309
  71. package/dist/liteDOM-Cp0aN3bP-YwW1TGWI.js +0 -741
  72. package/dist/node/lib/markdown/plugins/container.d.ts +0 -3
  73. package/dist/node/lib/markdown/plugins/container.d.ts.map +0 -1
  74. package/dist/node/lib/markdown/plugins/highlight.d.ts.map +0 -1
  75. package/dist/node/plugin/vite/codegen.d.ts +0 -29
  76. package/dist/node/plugin/vite/codegen.d.ts.map +0 -1
  77. package/dist/node/plugin/vite/codegen.test.d.ts +0 -2
  78. package/dist/node/plugin/vite/codegen.test.d.ts.map +0 -1
  79. package/dist/plugin-DRzll98J.js +0 -1
  80. package/dist/rolldown-runtime-Dqa2HsxW.js +0 -20
  81. package/dist/shared/utils/environment.d.ts +0 -2
  82. package/dist/shared/utils/environment.d.ts.map +0 -1
  83. package/dist/shared/utils/highlight.d.ts +0 -3
  84. package/dist/shared/utils/highlight.d.ts.map +0 -1
  85. package/dist/shared/utils/html.test.d.ts +0 -2
  86. package/dist/shared/utils/html.test.d.ts.map +0 -1
  87. package/dist/shared-DzTfF-_d.js +0 -14
  88. package/dist/tex-svg-full-BI3fonbT-CfoPQ3xc.js +0 -60224
  89. package/dist/vite-D9ePlTzy.js +0 -229
  90. package/dist/wgxpath.install-node-Csk64Aj9-C0enUGLs.js +0 -1094
  91. package/dist/xypic-DrMJn58R-B4fw2rYo.js +0 -14846
@@ -1,42 +1,37 @@
1
- import "./shared-DzTfF-_d.js";
2
- import { a as e, s as t } from "./constants-B7b8AsH0.js";
3
- import { n, r, t as i } from "./vite-D9ePlTzy.js";
4
- import a from "node:path";
5
- import { build as o, createServer as s } from "vite";
6
- import c from "picocolors";
7
- import l from "node:fs/promises";
8
- //#region src/shared/utils/format.ts
9
- function u(e) {
10
- return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
11
- }
12
- //#endregion
1
+ import { o as e } from "./constants-E2UATqMm.js";
2
+ import { C as t, D as n, E as r, S as i, d as a, f as o, l as s } from "./brand-BtMsUv5o.js";
3
+ import { n as c, t as l } from "./vite-nzhkELg7.js";
4
+ import u from "node:path";
5
+ import { build as d, createServer as f } from "vite";
6
+ import p from "picocolors";
7
+ import m from "node:fs/promises";
13
8
  //#region src/node/build/prerender.ts
14
- async function d(e) {
15
- let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await p(e.clientOutDir), o = e.pagePaths.length, s = 0;
16
- await Promise.all(e.pagePaths.map(async (c) => {
17
- let u = await t.render(c), d = f({
18
- content: u.html,
19
- title: u.pageData.title,
20
- description: u.pageData.frontmatter.description === void 0 ? "" : String(u.pageData.frontmatter.description),
9
+ async function h(e) {
10
+ let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await _(e.clientOutDir), a = e.pagePaths.length, o = 0;
11
+ await Promise.all(e.pagePaths.map(async (s) => {
12
+ let c = await t.render(s), l = g({
13
+ content: c.html,
14
+ title: c.pageData.title,
15
+ description: c.pageData.frontmatter.description === void 0 ? "" : String(c.pageData.frontmatter.description),
21
16
  clientEntry: n,
22
17
  cssFiles: r,
23
18
  jsFiles: i,
24
19
  base: e.base
25
- }), p = c === "/" ? "index.html" : `${c.replace(/^\//, "")}.html`, m = a.join(e.outDir, p);
26
- await l.mkdir(a.dirname(m), { recursive: !0 }), await l.writeFile(m, d), s++, e.progress?.update(s, o);
20
+ }), d = s === "/" ? "index.html" : `${s.replace(/^\//, "")}.html`, f = u.join(e.outDir, d);
21
+ await m.mkdir(u.dirname(f), { recursive: !0 }), await m.writeFile(f, l), o++, e.progress?.update(o, a);
27
22
  }));
28
23
  }
29
- function f(e) {
30
- let n = e.cssFiles.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), r = e.jsFiles.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n");
24
+ function g(e) {
25
+ 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");
31
26
  return `<!DOCTYPE html>
32
27
  <html lang="${e.lang ?? "en"}">
33
28
  <head>
34
29
  <meta charset="UTF-8">
35
30
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
36
- <title>${t(e.title)}</title>
37
- <meta name="description" content="${t(e.description)}">
31
+ <title>${s(e.title)}</title>
32
+ <meta name="description" content="${s(e.description)}">
33
+ ${t}
38
34
  ${n}
39
- ${r}
40
35
  </head>
41
36
  <body>
42
37
  <div id="app">${e.content}</div>
@@ -44,18 +39,18 @@ ${r}
44
39
  </body>
45
40
  </html>`;
46
41
  }
47
- async function p(e) {
48
- let t = a.join(e, ".vite", "manifest.json"), n = await l.readFile(t, "utf-8"), r = JSON.parse(n), i = "", o = [], s = [];
49
- for (let e of Object.values(r)) e.isEntry ? (i = e.file, e.css && o.push(...e.css)) : e.file.endsWith(".js") && s.push(e.file);
42
+ async function _(e) {
43
+ let t = u.join(e, ".vite", "manifest.json"), n = await m.readFile(t, "utf-8"), r = JSON.parse(n), i = "", a = [], o = [];
44
+ for (let e of Object.values(r)) e.isEntry ? (i = e.file, e.css && a.push(...e.css)) : e.file.endsWith(".js") && o.push(e.file);
50
45
  return {
51
46
  clientEntry: i,
52
- cssFiles: o,
53
- jsFiles: s
47
+ cssFiles: a,
48
+ jsFiles: o
54
49
  };
55
50
  }
56
51
  //#endregion
57
52
  //#region src/node/lib/progress.ts
58
- var m = class {
53
+ var v = class {
59
54
  logger;
60
55
  label;
61
56
  start;
@@ -70,133 +65,193 @@ var m = class {
70
65
  done(e) {
71
66
  process.stdout.isTTY && process.stdout.write("\r\x1B[K");
72
67
  let t = Math.round(performance.now() - this.start);
73
- this.logger.success(`${e} (${u(t)})`);
68
+ this.logger.success(`${e} (${y(t)})`);
74
69
  }
75
- }, h = "typerighter/client/theme-default";
76
- async function g(e, t = {}) {
77
- let { root: s, logger: c } = e, u = a.resolve(s, t.outDir ?? "dist"), f = t.base ?? "/", p = a.join(u, ".client"), g = a.join(u, ".server");
78
- await l.rm(u, {
70
+ };
71
+ function y(e) {
72
+ return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
73
+ }
74
+ //#endregion
75
+ //#region src/node/build/index.ts
76
+ var b = "typerighter/client/theme-default";
77
+ async function x(e, n = {}) {
78
+ let { root: r, logger: i } = e, o = u.resolve(r, n.outDir ?? "dist"), s = n.base ?? "/", f = u.join(o, ".client"), p = u.join(o, ".server");
79
+ await m.rm(o, {
79
80
  recursive: !0,
80
81
  force: !0
81
82
  });
82
- let v = await e.getTdContext(), [y, b, x] = await Promise.all([
83
- v.getConfig(),
84
- v.listFiles(),
85
- v.listFilesGroupedBySchema()
86
- ]), S = b.some((e) => e === "index.td"), C = JSON.stringify({
87
- title: y.siteTitle,
88
- description: y.siteDescription
89
- }), w = JSON.stringify({ sidebarGroups: x }), T = a.join(s, "node_modules", ".typerighter");
90
- await l.mkdir(T, { recursive: !0 });
91
- let E = a.join(T, "client-entry.js"), D = a.join(T, "ssr-entry.js");
92
- await Promise.all([l.writeFile(E, n({
93
- contentDir: y.contentDir,
94
- siteTitle: y.siteTitle,
95
- siteDescription: y.siteDescription,
96
- hasIndex: S,
97
- sidebarGroups: x
98
- })), l.writeFile(D, r({
99
- contentDir: y.contentDir,
100
- layoutImport: h,
101
- siteConfig: C,
102
- siteData: w,
103
- hasIndex: S
83
+ let g = await e.getTdContext(), [_, y, x, T] = await Promise.all([
84
+ g.getConfig(),
85
+ g.listFiles(),
86
+ g.listFilesGroupedBySchema(),
87
+ g.listSchemas()
88
+ ]), E = await Promise.all(T.map(async (e) => [e, (await g.getSchema(e)).properties])), D = Object.fromEntries(E), O = a(Object.values(x).flat()), k = JSON.stringify({
89
+ title: _.siteTitle,
90
+ description: _.siteDescription
91
+ }), A = JSON.stringify({ contentTree: O }), j = u.join(r, "node_modules", ".typerighter");
92
+ await m.mkdir(j, { recursive: !0 });
93
+ let M = u.join(j, "client-entry.js"), N = u.join(j, "ssr-entry.js");
94
+ await Promise.all([m.writeFile(M, l({
95
+ contentDir: _.contentDir,
96
+ siteTitle: _.siteTitle,
97
+ siteDescription: _.siteDescription,
98
+ contentTree: O,
99
+ schemas: D
100
+ })), m.writeFile(N, S({
101
+ contentDir: _.contentDir,
102
+ layoutImport: b,
103
+ siteConfig: k,
104
+ siteData: A
104
105
  }))]);
105
106
  try {
106
- let n = i({ context: e }), r = e.createViteLogger(), h = new m(c, "Building client bundle...");
107
- await o({
108
- ...t.viteConfig,
109
- root: s,
110
- base: f,
111
- plugins: n,
112
- customLogger: r,
107
+ let a = c({ context: e }), l = e.createViteLogger(), g = new v(i, "Building client bundle...");
108
+ await d({
109
+ ...n.viteConfig,
110
+ root: r,
111
+ base: s,
112
+ plugins: a,
113
+ customLogger: l,
113
114
  logLevel: "silent",
114
115
  build: {
115
- ...t.viteConfig?.build,
116
- outDir: p,
116
+ ...n.viteConfig?.build,
117
+ outDir: f,
117
118
  manifest: !0,
118
119
  emptyOutDir: !0,
119
120
  rollupOptions: {
120
- ...t.viteConfig?.build?.rollupOptions,
121
- input: E
121
+ ...n.viteConfig?.build?.rollupOptions,
122
+ input: M
122
123
  }
123
124
  }
124
125
  });
125
- let v = await l.readdir(a.join(p, "assets")).catch(() => []);
126
- h.done(`Client bundle (${v.length} chunks)`);
127
- let x = new m(c, "Building SSR bundle...");
128
- await o({
129
- ...t.viteConfig,
130
- root: s,
131
- base: f,
132
- plugins: n,
133
- customLogger: r,
126
+ let b = await m.readdir(u.join(f, "assets")).catch(() => []);
127
+ g.done(`Client bundle (${b.length} chunks)`);
128
+ let x = new v(i, "Building SSR bundle...");
129
+ await d({
130
+ ...n.viteConfig,
131
+ root: r,
132
+ base: s,
133
+ plugins: a,
134
+ customLogger: l,
134
135
  logLevel: "silent",
135
136
  build: {
136
- ...t.viteConfig?.build,
137
- outDir: g,
138
- ssr: D,
137
+ ...n.viteConfig?.build,
138
+ outDir: p,
139
+ ssr: N,
139
140
  emptyOutDir: !0
140
141
  }
141
142
  }), x.done("SSR bundle");
142
- let C = b.map((e) => {
143
- let t = e.replace(/\.td$/, "");
144
- return t === "index" ? "/" : `/${t}`;
143
+ let S = y.map((e) => {
144
+ let n = t(e);
145
+ return n === "index" ? "/" : `/${n}`;
145
146
  });
146
- S || C.push("/");
147
- let w = new m(c, "Pre-rendering pages...");
148
- await d({
149
- ssrEntryPath: a.join(g, "ssr-entry.js"),
150
- clientOutDir: p,
151
- outDir: u,
152
- base: f,
153
- pagePaths: C,
154
- progress: w
155
- }), w.done(`Pre-rendered ${C.length} pages`);
156
- let T = a.join(p, "assets"), O = a.join(u, "assets");
157
- await l.cp(T, O, { recursive: !0 }).catch(() => {}), await _(a.join(s, y.contentDir), u);
147
+ S.push("/"), w(O.children, "", S);
148
+ let T = new v(i, "Pre-rendering pages...");
149
+ await h({
150
+ ssrEntryPath: u.join(p, "ssr-entry.js"),
151
+ clientOutDir: f,
152
+ outDir: o,
153
+ base: s,
154
+ pagePaths: S,
155
+ progress: T
156
+ }), T.done(`Pre-rendered ${S.length} pages`);
157
+ let E = u.join(f, "assets"), D = u.join(o, "assets");
158
+ await m.cp(E, D, { recursive: !0 }).catch(() => {}), await C(u.join(r, _.contentDir), o);
158
159
  } finally {
159
160
  await Promise.all([
160
- l.rm(T, {
161
+ m.rm(j, {
161
162
  recursive: !0,
162
163
  force: !0
163
164
  }),
164
- l.rm(p, {
165
+ m.rm(f, {
165
166
  recursive: !0,
166
167
  force: !0
167
168
  }),
168
- l.rm(g, {
169
+ m.rm(p, {
169
170
  recursive: !0,
170
171
  force: !0
171
172
  })
172
173
  ]);
173
174
  }
174
- c.log(`\nBuild complete. Output: ${u}`);
175
+ i.log(`\nBuild complete. Output: ${o}`);
175
176
  }
176
- async function _(e, t) {
177
- let n = (await l.readdir(e, {
177
+ function S(e) {
178
+ let t = `/${e.contentDir}/${n}`, i = JSON.parse(e.siteConfig), a = o((JSON.parse(e.siteData).contentTree ?? {
179
+ rootItems: [],
180
+ children: []
181
+ }).children ?? [], i.title ?? "");
182
+ return `
183
+ import { createTypedownApp } from 'typerighter/client';
184
+ import { TdDirectoryIndex } from 'typerighter/client/theme-default';
185
+ import { renderToString } from 'vue/server-renderer';
186
+ import { h } from 'vue';
187
+ import theme from '${e.layoutImport}';
188
+
189
+ const pages = import.meta.glob('${t}', { eager: true });
190
+ const contentExts = ${JSON.stringify(r)};
191
+
192
+ const directoryIndex = ${JSON.stringify(a)};
193
+
194
+ function findPage(base) {
195
+ for (const ext of contentExts) {
196
+ const key = base + ext;
197
+ if (pages[key]) return pages[key];
198
+ const indexKey = base + '/index' + ext;
199
+ if (pages[indexKey]) return pages[indexKey];
200
+ }
201
+ }
202
+
203
+ function loadPageModule(pagePath) {
204
+ const base = ('/${e.contentDir}/' + pagePath).replace(/\\/+/g, '/').replace(/\\/$/, '');
205
+ const page = findPage(base);
206
+ if (page) return Promise.resolve(page);
207
+
208
+ const dir = directoryIndex[pagePath] || directoryIndex[pagePath + '/'];
209
+ if (dir) return Promise.resolve({
210
+ default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex, dir); } },
211
+ __pageData: { frontmatter: {}, headings: [], title: dir.title },
212
+ });
213
+
214
+ return Promise.resolve(undefined);
215
+ }
216
+
217
+ export async function render(url) {
218
+ const { app, router } = await createTypedownApp(loadPageModule, theme.Layout, ${e.siteConfig}, ${e.siteData});
219
+ await router.go(url, { replace: true });
220
+ const html = await renderToString(app);
221
+ return { html, pageData: router.route.data };
222
+ }
223
+ `;
224
+ }
225
+ async function C(e, t) {
226
+ let n = (await m.readdir(e, {
178
227
  recursive: !0,
179
228
  withFileTypes: !0
180
- })).filter((e) => e.isFile() && !e.name.endsWith(".td")).map(async (n) => {
181
- let r = a.join(n.parentPath, n.name), i = a.relative(e, r), o = a.join(t, i);
182
- return l.mkdir(a.dirname(o), { recursive: !0 }).then(() => l.copyFile(r, o));
229
+ })).filter((e) => e.isFile() && !i(e.name)).map(async (n) => {
230
+ let r = u.join(n.parentPath, n.name), i = u.relative(e, r), a = u.join(t, i);
231
+ return m.mkdir(u.dirname(a), { recursive: !0 }).then(() => m.copyFile(r, a));
183
232
  });
184
233
  await Promise.all(n);
185
234
  }
235
+ function w(e, t, n) {
236
+ for (let r of e) {
237
+ let e = `${t}/${r.name}`;
238
+ n.push(e), w(r.children, e, n);
239
+ }
240
+ }
186
241
  //#endregion
187
242
  //#region ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
188
- function v(e) {
243
+ function T(e) {
189
244
  return e == null ? [] : Array.isArray(e) ? e : [e];
190
245
  }
191
- function y(e, t, n, r) {
246
+ function E(e, t, n, r) {
192
247
  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);
193
248
  e[t] = a == null ? o : Array.isArray(a) ? a.concat(o) : [a, o];
194
249
  }
195
- function b(e, t) {
250
+ function D(e, t) {
196
251
  e ||= [], t ||= {};
197
252
  var n, r, i, a, o, s = { _: [] }, c = 0, l = 0, u = 0, d = e.length;
198
253
  let f = t.alias !== void 0, p = t.unknown !== void 0, m = t.default !== void 0;
199
- if (t.alias = t.alias || {}, t.string = v(t.string), t.boolean = v(t.boolean), f) for (n in t.alias) for (r = t.alias[n] = v(t.alias[n]), c = 0; c < r.length; c++) (t.alias[r[c]] = r.concat(n)).splice(c, 1);
254
+ if (t.alias = t.alias || {}, t.string = T(t.string), t.boolean = T(t.boolean), f) for (n in t.alias) for (r = t.alias[n] = T(t.alias[n]), c = 0; c < r.length; c++) (t.alias[r[c]] = r.concat(n)).splice(c, 1);
200
255
  for (c = t.boolean.length; c-- > 0;) for (r = t.alias[t.boolean[c]] || [], l = r.length; l-- > 0;) t.boolean.push(r[l]);
201
256
  for (c = t.string.length; c-- > 0;) for (r = t.alias[t.string[c]] || [], l = r.length; l-- > 0;) t.string.push(r[l]);
202
257
  if (m) {
@@ -217,7 +272,7 @@ function b(e, t) {
217
272
  for (u = l + 1; u < i.length && i.charCodeAt(u) !== 61; u++);
218
273
  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++) {
219
274
  if (a = r[u], p && !~h.indexOf(a)) return t.unknown("-".repeat(l) + a);
220
- y(s, a, u + 1 < r.length || o, t);
275
+ E(s, a, u + 1 < r.length || o, t);
221
276
  }
222
277
  }
223
278
  }
@@ -225,10 +280,10 @@ function b(e, t) {
225
280
  if (f) for (n in s) for (r = t.alias[n] || []; r.length > 0;) s[r.shift()] = s[n];
226
281
  return s;
227
282
  }
228
- function x(e) {
283
+ function O(e) {
229
284
  return e.replace(/[<[].+/, "").trim();
230
285
  }
231
- function S(e) {
286
+ function k(e) {
232
287
  let t = /<([^>]+)>/g, n = /\[([^\]]+)\]/g, r = [], i = (e) => {
233
288
  let t = !1, n = e[1];
234
289
  return n.startsWith("...") && (n = n.slice(3), t = !0), {
@@ -242,7 +297,7 @@ function S(e) {
242
297
  for (; o = n.exec(e);) r.push(i(o));
243
298
  return r;
244
299
  }
245
- function C(e) {
300
+ function A(e) {
246
301
  let t = {
247
302
  alias: {},
248
303
  boolean: []
@@ -250,16 +305,16 @@ function C(e) {
250
305
  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]));
251
306
  return t;
252
307
  }
253
- function w(e) {
308
+ function j(e) {
254
309
  return e.sort((e, t) => e.length > t.length ? -1 : 1)[0];
255
310
  }
256
- function T(e, t) {
311
+ function M(e, t) {
257
312
  return e.length >= t ? e : `${e}${" ".repeat(t - e.length)}`;
258
313
  }
259
- function E(e) {
314
+ function N(e) {
260
315
  return e.replaceAll(/([a-z])-([a-z])/g, (e, t, n) => t + n.toUpperCase());
261
316
  }
262
- function D(e, t, n) {
317
+ function P(e, t, n) {
263
318
  let r = e;
264
319
  for (let e = 0; e < t.length; e++) {
265
320
  let i = t[e];
@@ -274,24 +329,24 @@ function D(e, t, n) {
274
329
  r = r[i];
275
330
  }
276
331
  }
277
- function O(e, t) {
332
+ function F(e, t) {
278
333
  for (let n of Object.keys(t)) {
279
334
  let r = t[n];
280
335
  r.shouldTransform && (e[n] = [e[n]].flat(), typeof r.transformFunction == "function" && (e[n] = e[n].map(r.transformFunction)));
281
336
  }
282
337
  }
283
- function k(e) {
338
+ function I(e) {
284
339
  let t = /([^\\/]+)$/.exec(e);
285
340
  return t ? t[1] : "";
286
341
  }
287
- function A(e) {
288
- return e.split(".").map((e, t) => t === 0 ? E(e) : e).join(".");
342
+ function L(e) {
343
+ return e.split(".").map((e, t) => t === 0 ? N(e) : e).join(".");
289
344
  }
290
- var j = class extends Error {
345
+ var R = class extends Error {
291
346
  constructor(e) {
292
347
  super(e), this.name = "CACError", typeof Error.captureStackTrace != "function" && (this.stack = Error(e).stack);
293
348
  }
294
- }, M = class {
349
+ }, z = class {
295
350
  rawName;
296
351
  description;
297
352
  name;
@@ -301,17 +356,17 @@ var j = class extends Error {
301
356
  config;
302
357
  negated;
303
358
  constructor(e, t, n) {
304
- this.rawName = e, this.description = t, this.config = Object.assign({}, n), e = e.replaceAll(".*", ""), this.negated = !1, this.names = x(e).split(",").map((e) => {
359
+ this.rawName = e, this.description = t, this.config = Object.assign({}, n), e = e.replaceAll(".*", ""), this.negated = !1, this.names = O(e).split(",").map((e) => {
305
360
  let t = e.trim().replace(/^-{1,2}/, "");
306
- return t.startsWith("no-") && (this.negated = !0, t = t.replace(/^no-/, "")), A(t);
361
+ return t.startsWith("no-") && (this.negated = !0, t = t.replace(/^no-/, "")), L(t);
307
362
  }).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;
308
363
  }
309
- }, N, P;
364
+ }, B, V;
310
365
  if (typeof process < "u") {
311
366
  let e;
312
- e = typeof Deno < "u" && typeof Deno.version?.deno == "string" ? "deno" : typeof Bun < "u" && typeof Bun.version == "string" ? "bun" : "node", P = `${process.platform}-${process.arch} ${e}-${process.version}`, N = process.argv;
313
- } else P = typeof navigator > "u" ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
314
- var F = class {
367
+ e = typeof Deno < "u" && typeof Deno.version?.deno == "string" ? "deno" : typeof Bun < "u" && typeof Bun.version == "string" ? "bun" : "node", V = `${process.platform}-${process.arch} ${e}-${process.version}`, B = process.argv;
368
+ } else V = typeof navigator > "u" ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
369
+ var H = class {
315
370
  rawName;
316
371
  description;
317
372
  config;
@@ -327,7 +382,7 @@ var F = class {
327
382
  helpCallback;
328
383
  globalCommand;
329
384
  constructor(e, t, n = {}, r) {
330
- this.rawName = e, this.description = t, this.config = n, this.cli = r, this.options = [], this.aliasNames = [], this.name = x(e), this.args = S(e), this.examples = [];
385
+ this.rawName = e, this.description = t, this.config = n, this.cli = r, this.options = [], this.aliasNames = [], this.name = O(e), this.args = k(e), this.examples = [];
331
386
  }
332
387
  usage(e) {
333
388
  return this.usageText = e, this;
@@ -345,7 +400,7 @@ var F = class {
345
400
  return this.examples.push(e), this;
346
401
  }
347
402
  option(e, t, n) {
348
- let r = new M(e, t, n);
403
+ let r = new z(e, t, n);
349
404
  return this.options.push(r), this;
350
405
  }
351
406
  alias(e) {
@@ -361,7 +416,7 @@ var F = class {
361
416
  return this.name === "" || this.aliasNames.includes("!");
362
417
  }
363
418
  get isGlobalCommand() {
364
- return this instanceof I;
419
+ return this instanceof U;
365
420
  }
366
421
  hasOption(e) {
367
422
  return e = e.split(".")[0], this.options.find((t) => t.names.includes(e));
@@ -372,10 +427,10 @@ var F = class {
372
427
  title: "Usage",
373
428
  body: ` $ ${e} ${this.usageText || this.rawName}`
374
429
  }), (this.isGlobalCommand || this.isDefaultCommand) && t.length > 0) {
375
- let n = w(t.map((e) => e.rawName));
430
+ let n = j(t.map((e) => e.rawName));
376
431
  a.push({
377
432
  title: "Commands",
378
- body: t.map((e) => ` ${T(e.rawName, n.length)} ${e.description}`).join("\n")
433
+ body: t.map((e) => ` ${M(e.rawName, n.length)} ${e.description}`).join("\n")
379
434
  }, {
380
435
  title: "For more info, run any command with the `--help` flag",
381
436
  body: t.map((t) => ` $ ${e}${t.name === "" ? "" : ` ${t.name}`} --help`).join("\n")
@@ -383,10 +438,10 @@ var F = class {
383
438
  }
384
439
  let o = this.isGlobalCommand ? r : [...this.options, ...r || []];
385
440
  if (!this.isGlobalCommand && !this.isDefaultCommand && (o = o.filter((e) => e.name !== "version")), o.length > 0) {
386
- let e = w(o.map((e) => e.rawName));
441
+ let e = j(o.map((e) => e.rawName));
387
442
  a.push({
388
443
  title: "Options",
389
- body: o.map((t) => ` ${T(t.rawName, e.length)} ${t.description} ${t.config.default === void 0 ? "" : `(default: ${t.config.default})`}`).join("\n")
444
+ body: o.map((t) => ` ${M(t.rawName, e.length)} ${t.description} ${t.config.default === void 0 ? "" : `(default: ${t.config.default})`}`).join("\n")
390
445
  });
391
446
  }
392
447
  this.examples.length > 0 && a.push({
@@ -396,16 +451,16 @@ var F = class {
396
451
  }
397
452
  outputVersion() {
398
453
  let { name: e } = this.cli, { versionNumber: t } = this.cli.globalCommand;
399
- t && console.info(`${e}/${t} ${P}`);
454
+ t && console.info(`${e}/${t} ${V}`);
400
455
  }
401
456
  checkRequiredArgs() {
402
457
  let e = this.args.filter((e) => e.required).length;
403
- if (this.cli.args.length < e) throw new j(`missing required args for command \`${this.rawName}\``);
458
+ if (this.cli.args.length < e) throw new R(`missing required args for command \`${this.rawName}\``);
404
459
  }
405
460
  checkUnknownOptions() {
406
461
  let { options: e, globalCommand: t } = this.cli;
407
462
  if (!this.config.allowUnknownOptions) {
408
- for (let n of Object.keys(e)) if (n !== "--" && !this.hasOption(n) && !t.hasOption(n)) throw new j(`Unknown option \`${n.length > 1 ? `--${n}` : `-${n}`}\``);
463
+ for (let n of Object.keys(e)) if (n !== "--" && !this.hasOption(n) && !t.hasOption(n)) throw new R(`Unknown option \`${n.length > 1 ? `--${n}` : `-${n}`}\``);
409
464
  }
410
465
  }
411
466
  checkOptionValue() {
@@ -414,19 +469,19 @@ var F = class {
414
469
  let r = e[t.name.split(".")[0]];
415
470
  if (t.required) {
416
471
  let e = n.some((e) => e.negated && e.names.includes(t.name));
417
- if (r === !0 || r === !1 && !e) throw new j(`option \`${t.rawName}\` value is missing`);
472
+ if (r === !0 || r === !1 && !e) throw new R(`option \`${t.rawName}\` value is missing`);
418
473
  }
419
474
  }
420
475
  }
421
476
  checkUnusedArgs() {
422
477
  let e = this.args.some((e) => e.variadic) ? Infinity : this.args.length;
423
- if (e < this.cli.args.length) throw new j(`Unused args: ${this.cli.args.slice(e).map((e) => `\`${e}\``).join(", ")}`);
478
+ if (e < this.cli.args.length) throw new R(`Unused args: ${this.cli.args.slice(e).map((e) => `\`${e}\``).join(", ")}`);
424
479
  }
425
- }, I = class extends F {
480
+ }, U = class extends H {
426
481
  constructor(e) {
427
482
  super("@@global@@", "", {}, e);
428
483
  }
429
- }, L = class extends EventTarget {
484
+ }, W = class extends EventTarget {
430
485
  name;
431
486
  commands;
432
487
  globalCommand;
@@ -438,13 +493,13 @@ var F = class {
438
493
  showHelpOnExit;
439
494
  showVersionOnExit;
440
495
  constructor(e = "") {
441
- super(), this.name = e, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new I(this), this.globalCommand.usage("<command> [options]");
496
+ super(), this.name = e, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new U(this), this.globalCommand.usage("<command> [options]");
442
497
  }
443
498
  usage(e) {
444
499
  return this.globalCommand.usage(e), this;
445
500
  }
446
501
  command(e, t, n) {
447
- let r = new F(e, t || "", n, this);
502
+ let r = new H(e, t || "", n, this);
448
503
  return r.globalCommand = this.globalCommand, this.commands.push(r), r;
449
504
  }
450
505
  option(e, t, n) {
@@ -473,10 +528,10 @@ var F = class {
473
528
  }
474
529
  parse(e, { run: t = !0 } = {}) {
475
530
  if (!e) {
476
- if (!N) throw Error("No argv provided and runtime process argv is not available.");
477
- e = N;
531
+ if (!B) throw Error("No argv provided and runtime process argv is not available.");
532
+ e = B;
478
533
  }
479
- this.rawArgs = e, this.name ||= e[1] ? k(e[1]) : "cli";
534
+ this.rawArgs = e, this.name ||= e[1] ? I(e[1]) : "cli";
480
535
  let n = !0;
481
536
  for (let t of this.commands) {
482
537
  let r = this.mri(e.slice(2), t), i = r.args[0];
@@ -508,19 +563,19 @@ var F = class {
508
563
  return t && this.runMatchedCommand(), !this.matchedCommand && this.args[0] && this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] })), r;
509
564
  }
510
565
  mri(e, t) {
511
- let n = [...this.globalCommand.options, ...t ? t.options : []], r = C(n), i = [], a = e.indexOf("--");
566
+ let n = [...this.globalCommand.options, ...t ? t.options : []], r = A(n), i = [], a = e.indexOf("--");
512
567
  a !== -1 && (i = e.slice(a + 1), e = e.slice(0, a));
513
- let o = b(e, r);
568
+ let o = D(e, r);
514
569
  o = Object.keys(o).reduce((e, t) => ({
515
570
  ...e,
516
- [A(t)]: o[t]
571
+ [L(t)]: o[t]
517
572
  }), { _: [] });
518
573
  let s = o._, c = { "--": i }, l = t && t.config.ignoreOptionDefaultValue ? t.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue, u = Object.create(null);
519
574
  for (let e of n) {
520
575
  if (!l && e.config.default !== void 0) for (let t of e.names) c[t] = e.config.default;
521
576
  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]);
522
577
  }
523
- for (let e of Object.keys(o)) e !== "_" && (D(c, e.split("."), o[e]), O(c, u));
578
+ for (let e of Object.keys(o)) e !== "_" && (P(c, e.split("."), o[e]), F(c, u));
524
579
  return {
525
580
  args: s,
526
581
  options: c
@@ -535,18 +590,18 @@ var F = class {
535
590
  t.variadic ? r.push(e.slice(n)) : r.push(e[n]);
536
591
  }), r.push(t), n.commandAction.apply(this, r);
537
592
  }
538
- }, R = (e = "") => new L(e), z = c.bold(c.cyan("[typerighter]"));
539
- function B() {
540
- let t = R("typerighter");
593
+ }, G = (e = "") => new W(e), K = p.bold(p.cyan("[typerighter]"));
594
+ function q() {
595
+ let t = G("typerighter");
541
596
  process.on("uncaughtException", (e) => {
542
- V("runtime", e);
597
+ J("runtime", e);
543
598
  }), process.on("unhandledRejection", (e) => {
544
- V("runtime", e instanceof Error ? e : Error(String(e)));
599
+ J("runtime", e instanceof Error ? e : Error(String(e)));
545
600
  }), t.command("[root]", "Start dev server").alias("dev").option("--port <port>", "Port to listen on").option("--host", "Expose to network").action(async (e, t) => {
546
- let n = await s({
547
- root: H(e),
601
+ let n = await f({
602
+ root: Y(e),
548
603
  configFile: !1,
549
- plugins: [i()],
604
+ plugins: [c()],
550
605
  server: {
551
606
  port: t.port,
552
607
  host: t.host
@@ -554,9 +609,9 @@ function B() {
554
609
  });
555
610
  await n.listen(), n.printUrls();
556
611
  }), 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) => {
557
- let r = e(H(t));
612
+ let r = e(Y(t));
558
613
  try {
559
- await g(r, {
614
+ await x(r, {
560
615
  outDir: n.outDir,
561
616
  base: n.base
562
617
  });
@@ -564,22 +619,22 @@ function B() {
564
619
  r.dispose();
565
620
  }
566
621
  }), t.command("init [root]", "Scaffold a new project").action(async (e) => {
567
- let { initialize: t } = await import("./init-Ci83UWu-.js");
568
- await t(H(e));
622
+ let { initialize: t } = await import("./init-0hKcjQtf.js");
623
+ await t(Y(e));
569
624
  }), t.command("preview [root]", "Preview production build").option("--port <port>", "Port to listen on").action(async (e, t) => {
570
625
  let { preview: n } = await import("vite");
571
626
  (await n({
572
- root: H(e),
627
+ root: Y(e),
573
628
  preview: { port: t.port }
574
629
  })).printUrls();
575
- }), t.help(), t.version("0.3.1"), t.parse();
630
+ }), t.help(), t.version("0.4.0"), t.parse();
576
631
  }
577
- function V(e, t) {
632
+ function J(e, t) {
578
633
  let n = t instanceof Error ? t.message : String(t);
579
- console.error(`\n${z} ${c.red(`${e} failed`)}\n`), console.error(c.red(n)), console.error(""), process.exit(1);
634
+ console.error(`\n${K} ${p.red(`${e} failed`)}\n`), console.error(p.red(n)), console.error(""), process.exit(1);
580
635
  }
581
- function H(e) {
582
- return a.resolve(e ?? process.cwd());
636
+ function Y(e) {
637
+ return u.resolve(e ?? process.cwd());
583
638
  }
584
639
  //#endregion
585
- export { g as n, B as t };
640
+ export { x as n, q as t };