typerighter 0.3.0 → 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-CoyGXgR1.js → cli-s44ly0MH.js} +233 -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-CUo89E7j.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 -27
  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-D2xuSVM4.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-BxXQPieu.js +0 -228
  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-BxXQPieu.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, "assets"), n = [], r = await l.readdir(t).catch(() => n), i = [], o = [], s = "";
49
- for (let e of r) e.endsWith(".css") ? i.push(`assets/${e}`) : e.endsWith(".js") && (e.startsWith("client-entry") || e.startsWith("index") ? s = `assets/${e}` : o.push(`assets/${e}`));
50
- return !s && o.length > 0 && (s = o[0], o.splice(0, 1)), {
51
- clientEntry: s,
52
- cssFiles: i,
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);
45
+ return {
46
+ clientEntry: i,
47
+ cssFiles: a,
53
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,127 +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)})`);
74
- }
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"), v = await e.getTdContext(), [y, b, x] = await Promise.all([
78
- v.getConfig(),
79
- v.listFiles(),
80
- v.listFilesGroupedBySchema()
81
- ]), S = b.some((e) => e === "index.td"), C = JSON.stringify({
82
- title: y.siteTitle,
83
- description: y.siteDescription
84
- }), w = JSON.stringify({ sidebarGroups: x }), T = a.join(s, "node_modules", ".typerighter");
85
- await l.mkdir(T, { recursive: !0 });
86
- let E = a.join(T, "client-entry.js"), D = a.join(T, "ssr-entry.js");
87
- await Promise.all([l.writeFile(E, n({
88
- contentDir: y.contentDir,
89
- siteTitle: y.siteTitle,
90
- siteDescription: y.siteDescription,
91
- hasIndex: S,
92
- sidebarGroups: x
93
- })), l.writeFile(D, r({
94
- contentDir: y.contentDir,
95
- layoutImport: h,
96
- siteConfig: C,
97
- siteData: w
68
+ this.logger.success(`${e} (${y(t)})`);
69
+ }
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, {
80
+ recursive: !0,
81
+ force: !0
82
+ });
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
98
105
  }))]);
99
106
  try {
100
- let n = i({ context: e }), r = e.createViteLogger(), h = new m(c, "Building client bundle...");
101
- await o({
102
- ...t.viteConfig,
103
- root: s,
104
- base: f,
105
- plugins: n,
106
- 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,
107
114
  logLevel: "silent",
108
115
  build: {
109
- ...t.viteConfig?.build,
110
- outDir: p,
111
- ssrManifest: !0,
116
+ ...n.viteConfig?.build,
117
+ outDir: f,
118
+ manifest: !0,
112
119
  emptyOutDir: !0,
113
120
  rollupOptions: {
114
- ...t.viteConfig?.build?.rollupOptions,
115
- input: E
121
+ ...n.viteConfig?.build?.rollupOptions,
122
+ input: M
116
123
  }
117
124
  }
118
125
  });
119
- let v = await l.readdir(a.join(p, "assets")).catch(() => []);
120
- h.done(`Client bundle (${v.length} chunks)`);
121
- let x = new m(c, "Building SSR bundle...");
122
- await o({
123
- ...t.viteConfig,
124
- root: s,
125
- base: f,
126
- plugins: n,
127
- 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,
128
135
  logLevel: "silent",
129
136
  build: {
130
- ...t.viteConfig?.build,
131
- outDir: g,
132
- ssr: D,
137
+ ...n.viteConfig?.build,
138
+ outDir: p,
139
+ ssr: N,
133
140
  emptyOutDir: !0
134
141
  }
135
142
  }), x.done("SSR bundle");
136
- let C = b.map((e) => {
137
- let t = e.replace(/\.td$/, "");
138
- return t === "index" ? "/" : `/${t}`;
143
+ let S = y.map((e) => {
144
+ let n = t(e);
145
+ return n === "index" ? "/" : `/${n}`;
139
146
  });
140
- S || C.push("/");
141
- let w = new m(c, "Pre-rendering pages...");
142
- await d({
143
- ssrEntryPath: a.join(g, "ssr-entry.js"),
144
- clientOutDir: p,
145
- outDir: u,
146
- base: f,
147
- pagePaths: C,
148
- progress: w
149
- }), w.done(`Pre-rendered ${C.length} pages`);
150
- let T = a.join(p, "assets"), O = a.join(u, "assets");
151
- 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);
152
159
  } finally {
153
160
  await Promise.all([
154
- l.rm(T, {
161
+ m.rm(j, {
155
162
  recursive: !0,
156
163
  force: !0
157
164
  }),
158
- l.rm(p, {
165
+ m.rm(f, {
159
166
  recursive: !0,
160
167
  force: !0
161
168
  }),
162
- l.rm(g, {
169
+ m.rm(p, {
163
170
  recursive: !0,
164
171
  force: !0
165
172
  })
166
173
  ]);
167
174
  }
168
- c.log(`\nBuild complete. Output: ${u}`);
175
+ i.log(`\nBuild complete. Output: ${o}`);
176
+ }
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);
169
215
  }
170
- async function _(e, t) {
171
- let n = (await l.readdir(e, {
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, {
172
227
  recursive: !0,
173
228
  withFileTypes: !0
174
- })).filter((e) => e.isFile() && !e.name.endsWith(".td")).map(async (n) => {
175
- let r = a.join(n.parentPath, n.name), i = a.relative(e, r), o = a.join(t, i);
176
- 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));
177
232
  });
178
233
  await Promise.all(n);
179
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
+ }
180
241
  //#endregion
181
242
  //#region ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
182
- function v(e) {
243
+ function T(e) {
183
244
  return e == null ? [] : Array.isArray(e) ? e : [e];
184
245
  }
185
- function y(e, t, n, r) {
246
+ function E(e, t, n, r) {
186
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);
187
248
  e[t] = a == null ? o : Array.isArray(a) ? a.concat(o) : [a, o];
188
249
  }
189
- function b(e, t) {
250
+ function D(e, t) {
190
251
  e ||= [], t ||= {};
191
252
  var n, r, i, a, o, s = { _: [] }, c = 0, l = 0, u = 0, d = e.length;
192
253
  let f = t.alias !== void 0, p = t.unknown !== void 0, m = t.default !== void 0;
193
- 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);
194
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]);
195
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]);
196
257
  if (m) {
@@ -211,7 +272,7 @@ function b(e, t) {
211
272
  for (u = l + 1; u < i.length && i.charCodeAt(u) !== 61; u++);
212
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++) {
213
274
  if (a = r[u], p && !~h.indexOf(a)) return t.unknown("-".repeat(l) + a);
214
- y(s, a, u + 1 < r.length || o, t);
275
+ E(s, a, u + 1 < r.length || o, t);
215
276
  }
216
277
  }
217
278
  }
@@ -219,10 +280,10 @@ function b(e, t) {
219
280
  if (f) for (n in s) for (r = t.alias[n] || []; r.length > 0;) s[r.shift()] = s[n];
220
281
  return s;
221
282
  }
222
- function x(e) {
283
+ function O(e) {
223
284
  return e.replace(/[<[].+/, "").trim();
224
285
  }
225
- function S(e) {
286
+ function k(e) {
226
287
  let t = /<([^>]+)>/g, n = /\[([^\]]+)\]/g, r = [], i = (e) => {
227
288
  let t = !1, n = e[1];
228
289
  return n.startsWith("...") && (n = n.slice(3), t = !0), {
@@ -236,7 +297,7 @@ function S(e) {
236
297
  for (; o = n.exec(e);) r.push(i(o));
237
298
  return r;
238
299
  }
239
- function C(e) {
300
+ function A(e) {
240
301
  let t = {
241
302
  alias: {},
242
303
  boolean: []
@@ -244,16 +305,16 @@ function C(e) {
244
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]));
245
306
  return t;
246
307
  }
247
- function w(e) {
308
+ function j(e) {
248
309
  return e.sort((e, t) => e.length > t.length ? -1 : 1)[0];
249
310
  }
250
- function T(e, t) {
311
+ function M(e, t) {
251
312
  return e.length >= t ? e : `${e}${" ".repeat(t - e.length)}`;
252
313
  }
253
- function E(e) {
314
+ function N(e) {
254
315
  return e.replaceAll(/([a-z])-([a-z])/g, (e, t, n) => t + n.toUpperCase());
255
316
  }
256
- function D(e, t, n) {
317
+ function P(e, t, n) {
257
318
  let r = e;
258
319
  for (let e = 0; e < t.length; e++) {
259
320
  let i = t[e];
@@ -268,24 +329,24 @@ function D(e, t, n) {
268
329
  r = r[i];
269
330
  }
270
331
  }
271
- function O(e, t) {
332
+ function F(e, t) {
272
333
  for (let n of Object.keys(t)) {
273
334
  let r = t[n];
274
335
  r.shouldTransform && (e[n] = [e[n]].flat(), typeof r.transformFunction == "function" && (e[n] = e[n].map(r.transformFunction)));
275
336
  }
276
337
  }
277
- function k(e) {
338
+ function I(e) {
278
339
  let t = /([^\\/]+)$/.exec(e);
279
340
  return t ? t[1] : "";
280
341
  }
281
- function A(e) {
282
- 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(".");
283
344
  }
284
- var j = class extends Error {
345
+ var R = class extends Error {
285
346
  constructor(e) {
286
347
  super(e), this.name = "CACError", typeof Error.captureStackTrace != "function" && (this.stack = Error(e).stack);
287
348
  }
288
- }, M = class {
349
+ }, z = class {
289
350
  rawName;
290
351
  description;
291
352
  name;
@@ -295,17 +356,17 @@ var j = class extends Error {
295
356
  config;
296
357
  negated;
297
358
  constructor(e, t, n) {
298
- 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) => {
299
360
  let t = e.trim().replace(/^-{1,2}/, "");
300
- 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);
301
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;
302
363
  }
303
- }, N, P;
364
+ }, B, V;
304
365
  if (typeof process < "u") {
305
366
  let e;
306
- 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;
307
- } else P = typeof navigator > "u" ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
308
- 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 {
309
370
  rawName;
310
371
  description;
311
372
  config;
@@ -321,7 +382,7 @@ var F = class {
321
382
  helpCallback;
322
383
  globalCommand;
323
384
  constructor(e, t, n = {}, r) {
324
- 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 = [];
325
386
  }
326
387
  usage(e) {
327
388
  return this.usageText = e, this;
@@ -339,7 +400,7 @@ var F = class {
339
400
  return this.examples.push(e), this;
340
401
  }
341
402
  option(e, t, n) {
342
- let r = new M(e, t, n);
403
+ let r = new z(e, t, n);
343
404
  return this.options.push(r), this;
344
405
  }
345
406
  alias(e) {
@@ -355,7 +416,7 @@ var F = class {
355
416
  return this.name === "" || this.aliasNames.includes("!");
356
417
  }
357
418
  get isGlobalCommand() {
358
- return this instanceof I;
419
+ return this instanceof U;
359
420
  }
360
421
  hasOption(e) {
361
422
  return e = e.split(".")[0], this.options.find((t) => t.names.includes(e));
@@ -366,10 +427,10 @@ var F = class {
366
427
  title: "Usage",
367
428
  body: ` $ ${e} ${this.usageText || this.rawName}`
368
429
  }), (this.isGlobalCommand || this.isDefaultCommand) && t.length > 0) {
369
- let n = w(t.map((e) => e.rawName));
430
+ let n = j(t.map((e) => e.rawName));
370
431
  a.push({
371
432
  title: "Commands",
372
- 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")
373
434
  }, {
374
435
  title: "For more info, run any command with the `--help` flag",
375
436
  body: t.map((t) => ` $ ${e}${t.name === "" ? "" : ` ${t.name}`} --help`).join("\n")
@@ -377,10 +438,10 @@ var F = class {
377
438
  }
378
439
  let o = this.isGlobalCommand ? r : [...this.options, ...r || []];
379
440
  if (!this.isGlobalCommand && !this.isDefaultCommand && (o = o.filter((e) => e.name !== "version")), o.length > 0) {
380
- let e = w(o.map((e) => e.rawName));
441
+ let e = j(o.map((e) => e.rawName));
381
442
  a.push({
382
443
  title: "Options",
383
- 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")
384
445
  });
385
446
  }
386
447
  this.examples.length > 0 && a.push({
@@ -390,16 +451,16 @@ var F = class {
390
451
  }
391
452
  outputVersion() {
392
453
  let { name: e } = this.cli, { versionNumber: t } = this.cli.globalCommand;
393
- t && console.info(`${e}/${t} ${P}`);
454
+ t && console.info(`${e}/${t} ${V}`);
394
455
  }
395
456
  checkRequiredArgs() {
396
457
  let e = this.args.filter((e) => e.required).length;
397
- 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}\``);
398
459
  }
399
460
  checkUnknownOptions() {
400
461
  let { options: e, globalCommand: t } = this.cli;
401
462
  if (!this.config.allowUnknownOptions) {
402
- 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}`}\``);
403
464
  }
404
465
  }
405
466
  checkOptionValue() {
@@ -408,19 +469,19 @@ var F = class {
408
469
  let r = e[t.name.split(".")[0]];
409
470
  if (t.required) {
410
471
  let e = n.some((e) => e.negated && e.names.includes(t.name));
411
- 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`);
412
473
  }
413
474
  }
414
475
  }
415
476
  checkUnusedArgs() {
416
477
  let e = this.args.some((e) => e.variadic) ? Infinity : this.args.length;
417
- 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(", ")}`);
418
479
  }
419
- }, I = class extends F {
480
+ }, U = class extends H {
420
481
  constructor(e) {
421
482
  super("@@global@@", "", {}, e);
422
483
  }
423
- }, L = class extends EventTarget {
484
+ }, W = class extends EventTarget {
424
485
  name;
425
486
  commands;
426
487
  globalCommand;
@@ -432,13 +493,13 @@ var F = class {
432
493
  showHelpOnExit;
433
494
  showVersionOnExit;
434
495
  constructor(e = "") {
435
- 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]");
436
497
  }
437
498
  usage(e) {
438
499
  return this.globalCommand.usage(e), this;
439
500
  }
440
501
  command(e, t, n) {
441
- let r = new F(e, t || "", n, this);
502
+ let r = new H(e, t || "", n, this);
442
503
  return r.globalCommand = this.globalCommand, this.commands.push(r), r;
443
504
  }
444
505
  option(e, t, n) {
@@ -467,10 +528,10 @@ var F = class {
467
528
  }
468
529
  parse(e, { run: t = !0 } = {}) {
469
530
  if (!e) {
470
- if (!N) throw Error("No argv provided and runtime process argv is not available.");
471
- e = N;
531
+ if (!B) throw Error("No argv provided and runtime process argv is not available.");
532
+ e = B;
472
533
  }
473
- this.rawArgs = e, this.name ||= e[1] ? k(e[1]) : "cli";
534
+ this.rawArgs = e, this.name ||= e[1] ? I(e[1]) : "cli";
474
535
  let n = !0;
475
536
  for (let t of this.commands) {
476
537
  let r = this.mri(e.slice(2), t), i = r.args[0];
@@ -502,19 +563,19 @@ var F = class {
502
563
  return t && this.runMatchedCommand(), !this.matchedCommand && this.args[0] && this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] })), r;
503
564
  }
504
565
  mri(e, t) {
505
- 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("--");
506
567
  a !== -1 && (i = e.slice(a + 1), e = e.slice(0, a));
507
- let o = b(e, r);
568
+ let o = D(e, r);
508
569
  o = Object.keys(o).reduce((e, t) => ({
509
570
  ...e,
510
- [A(t)]: o[t]
571
+ [L(t)]: o[t]
511
572
  }), { _: [] });
512
573
  let s = o._, c = { "--": i }, l = t && t.config.ignoreOptionDefaultValue ? t.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue, u = Object.create(null);
513
574
  for (let e of n) {
514
575
  if (!l && e.config.default !== void 0) for (let t of e.names) c[t] = e.config.default;
515
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]);
516
577
  }
517
- 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));
518
579
  return {
519
580
  args: s,
520
581
  options: c
@@ -529,18 +590,18 @@ var F = class {
529
590
  t.variadic ? r.push(e.slice(n)) : r.push(e[n]);
530
591
  }), r.push(t), n.commandAction.apply(this, r);
531
592
  }
532
- }, R = (e = "") => new L(e), z = c.bold(c.cyan("[typerighter]"));
533
- function B() {
534
- let t = R("typerighter");
593
+ }, G = (e = "") => new W(e), K = p.bold(p.cyan("[typerighter]"));
594
+ function q() {
595
+ let t = G("typerighter");
535
596
  process.on("uncaughtException", (e) => {
536
- V("runtime", e);
597
+ J("runtime", e);
537
598
  }), process.on("unhandledRejection", (e) => {
538
- V("runtime", e instanceof Error ? e : Error(String(e)));
599
+ J("runtime", e instanceof Error ? e : Error(String(e)));
539
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) => {
540
- let n = await s({
541
- root: H(e),
601
+ let n = await f({
602
+ root: Y(e),
542
603
  configFile: !1,
543
- plugins: [i()],
604
+ plugins: [c()],
544
605
  server: {
545
606
  port: t.port,
546
607
  host: t.host
@@ -548,9 +609,9 @@ function B() {
548
609
  });
549
610
  await n.listen(), n.printUrls();
550
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) => {
551
- let r = e(H(t));
612
+ let r = e(Y(t));
552
613
  try {
553
- await g(r, {
614
+ await x(r, {
554
615
  outDir: n.outDir,
555
616
  base: n.base
556
617
  });
@@ -558,22 +619,22 @@ function B() {
558
619
  r.dispose();
559
620
  }
560
621
  }), t.command("init [root]", "Scaffold a new project").action(async (e) => {
561
- let { initialize: t } = await import("./init-CUo89E7j.js");
562
- await t(H(e));
622
+ let { initialize: t } = await import("./init-0hKcjQtf.js");
623
+ await t(Y(e));
563
624
  }), t.command("preview [root]", "Preview production build").option("--port <port>", "Port to listen on").action(async (e, t) => {
564
625
  let { preview: n } = await import("vite");
565
626
  (await n({
566
- root: H(e),
627
+ root: Y(e),
567
628
  preview: { port: t.port }
568
629
  })).printUrls();
569
- }), t.help(), t.version("0.3.0"), t.parse();
630
+ }), t.help(), t.version("0.4.0"), t.parse();
570
631
  }
571
- function V(e, t) {
632
+ function J(e, t) {
572
633
  let n = t instanceof Error ? t.message : String(t);
573
- 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);
574
635
  }
575
- function H(e) {
576
- return a.resolve(e ?? process.cwd());
636
+ function Y(e) {
637
+ return u.resolve(e ?? process.cwd());
577
638
  }
578
639
  //#endregion
579
- export { g as n, B as t };
640
+ export { x as n, q as t };