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.
- package/dist/app-Bw90hv7G.js +266 -0
- package/dist/brand-BtMsUv5o.js +201 -0
- package/dist/{cli-CoyGXgR1.js → cli-s44ly0MH.js} +233 -172
- package/dist/cli.js +1 -1
- package/dist/client/app/index.d.ts +12 -4
- package/dist/client/app/index.d.ts.map +1 -1
- package/dist/client/app/router.d.ts.map +1 -1
- package/dist/client/theme-default.js +707 -149
- package/dist/client.js +2 -2
- package/dist/constants-E2UATqMm.js +32183 -0
- package/dist/es-ClqUVRJn.js +705 -0
- package/dist/index.js +4 -4
- package/dist/{init-CUo89E7j.js → init-0hKcjQtf.js} +10 -12
- package/dist/node/build/index.d.ts.map +1 -1
- package/dist/node/lib/markdown/index.d.ts.map +1 -1
- package/dist/node/lib/markdown/plugins/callout-container.d.ts +4 -0
- package/dist/node/lib/markdown/plugins/callout-container.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/custom-container.d.ts +3 -0
- package/dist/node/lib/markdown/plugins/custom-container.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/{highlight.d.ts → highlight/index.d.ts} +1 -1
- package/dist/node/lib/markdown/plugins/highlight/index.d.ts.map +1 -0
- package/dist/node/lib/markdown/plugins/highlight/language.d.ts +3 -0
- package/dist/node/lib/markdown/plugins/highlight/language.d.ts.map +1 -0
- package/dist/node/lib/progress.d.ts.map +1 -1
- package/dist/node/lib/render/vue.d.ts +2 -2
- package/dist/node/lib/render/vue.d.ts.map +1 -1
- package/dist/node/lib/typedown-context.d.ts +4 -4
- package/dist/node/lib/typedown-context.d.ts.map +1 -1
- package/dist/node/plugin/vite/constants.d.ts +2 -1
- package/dist/node/plugin/vite/constants.d.ts.map +1 -1
- package/dist/node/plugin/vite/index.d.ts +15 -1
- package/dist/node/plugin/vite/index.d.ts.map +1 -1
- package/dist/node/plugin/vite/search.d.ts +15 -0
- package/dist/node/plugin/vite/search.d.ts.map +1 -0
- package/dist/shared/constants.d.ts +6 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/types/content.d.ts +54 -4
- package/dist/shared/types/content.d.ts.map +1 -1
- package/dist/shared/types/ssg.d.ts +3 -1
- package/dist/shared/types/ssg.d.ts.map +1 -1
- package/dist/shared/utils/content.d.ts +5 -5
- package/dist/shared/utils/content.d.ts.map +1 -1
- package/dist/shared/utils/debounce.d.ts +2 -0
- package/dist/shared/utils/debounce.d.ts.map +1 -0
- package/dist/shared/utils/format.d.ts +5 -1
- package/dist/shared/utils/format.d.ts.map +1 -1
- package/dist/shared/utils/html.d.ts +1 -0
- package/dist/shared/utils/html.d.ts.map +1 -1
- package/dist/shared/utils/index.d.ts +6 -4
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/shared/utils/path.d.ts +8 -0
- package/dist/shared/utils/path.d.ts.map +1 -0
- package/dist/shared/utils/regex.d.ts +2 -0
- package/dist/shared/utils/regex.d.ts.map +1 -0
- package/dist/shared/utils/time.d.ts +6 -0
- package/dist/shared/utils/time.d.ts.map +1 -0
- package/dist/shared/utils/url.d.ts +6 -2
- package/dist/shared/utils/url.d.ts.map +1 -1
- package/dist/typerighter.css +1 -1
- package/dist/vite-nzhkELg7.js +309 -0
- package/dist/vite.js +2 -3
- package/package.json +9 -5
- package/dist/app-CM3biamr.js +0 -184
- package/dist/brand-CeSqpEQ2.js +0 -4
- package/dist/chunk-DfAF0w94-EwUSVR-h.js +0 -13
- package/dist/constants-B7b8AsH0.js +0 -9530
- package/dist/content-BM3UKxcc.js +0 -16
- package/dist/lib-CBtriEt5-Ch50D04V.js +0 -3309
- package/dist/liteDOM-Cp0aN3bP-YwW1TGWI.js +0 -741
- package/dist/node/lib/markdown/plugins/container.d.ts +0 -3
- package/dist/node/lib/markdown/plugins/container.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/highlight.d.ts.map +0 -1
- package/dist/node/plugin/vite/codegen.d.ts +0 -27
- package/dist/node/plugin/vite/codegen.d.ts.map +0 -1
- package/dist/node/plugin/vite/codegen.test.d.ts +0 -2
- package/dist/node/plugin/vite/codegen.test.d.ts.map +0 -1
- package/dist/plugin-D2xuSVM4.js +0 -1
- package/dist/rolldown-runtime-Dqa2HsxW.js +0 -20
- package/dist/shared/utils/environment.d.ts +0 -2
- package/dist/shared/utils/environment.d.ts.map +0 -1
- package/dist/shared/utils/highlight.d.ts +0 -3
- package/dist/shared/utils/highlight.d.ts.map +0 -1
- package/dist/shared/utils/html.test.d.ts +0 -2
- package/dist/shared/utils/html.test.d.ts.map +0 -1
- package/dist/shared-DzTfF-_d.js +0 -14
- package/dist/tex-svg-full-BI3fonbT-CfoPQ3xc.js +0 -60224
- package/dist/vite-BxXQPieu.js +0 -228
- package/dist/wgxpath.install-node-Csk64Aj9-C0enUGLs.js +0 -1094
- package/dist/xypic-DrMJn58R-B4fw2rYo.js +0 -14846
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { a as
|
|
3
|
-
import { n
|
|
4
|
-
import
|
|
5
|
-
import { build as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
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
|
|
15
|
-
let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await
|
|
16
|
-
await Promise.all(e.pagePaths.map(async (
|
|
17
|
-
let
|
|
18
|
-
content:
|
|
19
|
-
title:
|
|
20
|
-
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
|
-
}),
|
|
26
|
-
await
|
|
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
|
|
30
|
-
let
|
|
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>${
|
|
37
|
-
<meta name="description" content="${
|
|
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
|
|
48
|
-
let t =
|
|
49
|
-
for (let e of r) e.
|
|
50
|
-
return
|
|
51
|
-
clientEntry:
|
|
52
|
-
cssFiles:
|
|
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
|
|
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} (${
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
|
101
|
-
await
|
|
102
|
-
...
|
|
103
|
-
root:
|
|
104
|
-
base:
|
|
105
|
-
plugins:
|
|
106
|
-
customLogger:
|
|
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
|
-
...
|
|
110
|
-
outDir:
|
|
111
|
-
|
|
116
|
+
...n.viteConfig?.build,
|
|
117
|
+
outDir: f,
|
|
118
|
+
manifest: !0,
|
|
112
119
|
emptyOutDir: !0,
|
|
113
120
|
rollupOptions: {
|
|
114
|
-
...
|
|
115
|
-
input:
|
|
121
|
+
...n.viteConfig?.build?.rollupOptions,
|
|
122
|
+
input: M
|
|
116
123
|
}
|
|
117
124
|
}
|
|
118
125
|
});
|
|
119
|
-
let
|
|
120
|
-
|
|
121
|
-
let x = new
|
|
122
|
-
await
|
|
123
|
-
...
|
|
124
|
-
root:
|
|
125
|
-
base:
|
|
126
|
-
plugins:
|
|
127
|
-
customLogger:
|
|
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
|
-
...
|
|
131
|
-
outDir:
|
|
132
|
-
ssr:
|
|
137
|
+
...n.viteConfig?.build,
|
|
138
|
+
outDir: p,
|
|
139
|
+
ssr: N,
|
|
133
140
|
emptyOutDir: !0
|
|
134
141
|
}
|
|
135
142
|
}), x.done("SSR bundle");
|
|
136
|
-
let
|
|
137
|
-
let
|
|
138
|
-
return
|
|
143
|
+
let S = y.map((e) => {
|
|
144
|
+
let n = t(e);
|
|
145
|
+
return n === "index" ? "/" : `/${n}`;
|
|
139
146
|
});
|
|
140
|
-
S
|
|
141
|
-
let
|
|
142
|
-
await
|
|
143
|
-
ssrEntryPath:
|
|
144
|
-
clientOutDir:
|
|
145
|
-
outDir:
|
|
146
|
-
base:
|
|
147
|
-
pagePaths:
|
|
148
|
-
progress:
|
|
149
|
-
}),
|
|
150
|
-
let
|
|
151
|
-
await
|
|
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
|
-
|
|
161
|
+
m.rm(j, {
|
|
155
162
|
recursive: !0,
|
|
156
163
|
force: !0
|
|
157
164
|
}),
|
|
158
|
-
|
|
165
|
+
m.rm(f, {
|
|
159
166
|
recursive: !0,
|
|
160
167
|
force: !0
|
|
161
168
|
}),
|
|
162
|
-
|
|
169
|
+
m.rm(p, {
|
|
163
170
|
recursive: !0,
|
|
164
171
|
force: !0
|
|
165
172
|
})
|
|
166
173
|
]);
|
|
167
174
|
}
|
|
168
|
-
|
|
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
|
-
|
|
171
|
-
|
|
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
|
|
175
|
-
let r =
|
|
176
|
-
return
|
|
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
|
|
243
|
+
function T(e) {
|
|
183
244
|
return e == null ? [] : Array.isArray(e) ? e : [e];
|
|
184
245
|
}
|
|
185
|
-
function
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
|
283
|
+
function O(e) {
|
|
223
284
|
return e.replace(/[<[].+/, "").trim();
|
|
224
285
|
}
|
|
225
|
-
function
|
|
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
|
|
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
|
|
308
|
+
function j(e) {
|
|
248
309
|
return e.sort((e, t) => e.length > t.length ? -1 : 1)[0];
|
|
249
310
|
}
|
|
250
|
-
function
|
|
311
|
+
function M(e, t) {
|
|
251
312
|
return e.length >= t ? e : `${e}${" ".repeat(t - e.length)}`;
|
|
252
313
|
}
|
|
253
|
-
function
|
|
314
|
+
function N(e) {
|
|
254
315
|
return e.replaceAll(/([a-z])-([a-z])/g, (e, t, n) => t + n.toUpperCase());
|
|
255
316
|
}
|
|
256
|
-
function
|
|
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
|
|
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
|
|
338
|
+
function I(e) {
|
|
278
339
|
let t = /([^\\/]+)$/.exec(e);
|
|
279
340
|
return t ? t[1] : "";
|
|
280
341
|
}
|
|
281
|
-
function
|
|
282
|
-
return e.split(".").map((e, t) => t === 0 ?
|
|
342
|
+
function L(e) {
|
|
343
|
+
return e.split(".").map((e, t) => t === 0 ? N(e) : e).join(".");
|
|
283
344
|
}
|
|
284
|
-
var
|
|
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
|
-
},
|
|
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 =
|
|
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-/, "")),
|
|
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
|
-
},
|
|
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",
|
|
307
|
-
} else
|
|
308
|
-
var
|
|
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 =
|
|
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
|
|
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
|
|
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 =
|
|
430
|
+
let n = j(t.map((e) => e.rawName));
|
|
370
431
|
a.push({
|
|
371
432
|
title: "Commands",
|
|
372
|
-
body: t.map((e) => ` ${
|
|
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 =
|
|
441
|
+
let e = j(o.map((e) => e.rawName));
|
|
381
442
|
a.push({
|
|
382
443
|
title: "Options",
|
|
383
|
-
body: o.map((t) => ` ${
|
|
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} ${
|
|
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
|
|
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
|
|
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
|
|
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
|
|
478
|
+
if (e < this.cli.args.length) throw new R(`Unused args: ${this.cli.args.slice(e).map((e) => `\`${e}\``).join(", ")}`);
|
|
418
479
|
}
|
|
419
|
-
},
|
|
480
|
+
}, U = class extends H {
|
|
420
481
|
constructor(e) {
|
|
421
482
|
super("@@global@@", "", {}, e);
|
|
422
483
|
}
|
|
423
|
-
},
|
|
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
|
|
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
|
|
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 (!
|
|
471
|
-
e =
|
|
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] ?
|
|
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 =
|
|
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 =
|
|
568
|
+
let o = D(e, r);
|
|
508
569
|
o = Object.keys(o).reduce((e, t) => ({
|
|
509
570
|
...e,
|
|
510
|
-
[
|
|
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 !== "_" && (
|
|
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
|
-
},
|
|
533
|
-
function
|
|
534
|
-
let t =
|
|
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
|
-
|
|
597
|
+
J("runtime", e);
|
|
537
598
|
}), process.on("unhandledRejection", (e) => {
|
|
538
|
-
|
|
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
|
|
541
|
-
root:
|
|
601
|
+
let n = await f({
|
|
602
|
+
root: Y(e),
|
|
542
603
|
configFile: !1,
|
|
543
|
-
plugins: [
|
|
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(
|
|
612
|
+
let r = e(Y(t));
|
|
552
613
|
try {
|
|
553
|
-
await
|
|
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-
|
|
562
|
-
await t(
|
|
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:
|
|
627
|
+
root: Y(e),
|
|
567
628
|
preview: { port: t.port }
|
|
568
629
|
})).printUrls();
|
|
569
|
-
}), t.help(), t.version("0.
|
|
630
|
+
}), t.help(), t.version("0.4.0"), t.parse();
|
|
570
631
|
}
|
|
571
|
-
function
|
|
632
|
+
function J(e, t) {
|
|
572
633
|
let n = t instanceof Error ? t.message : String(t);
|
|
573
|
-
console.error(`\n${
|
|
634
|
+
console.error(`\n${K} ${p.red(`${e} failed`)}\n`), console.error(p.red(n)), console.error(""), process.exit(1);
|
|
574
635
|
}
|
|
575
|
-
function
|
|
576
|
-
return
|
|
636
|
+
function Y(e) {
|
|
637
|
+
return u.resolve(e ?? process.cwd());
|
|
577
638
|
}
|
|
578
639
|
//#endregion
|
|
579
|
-
export {
|
|
640
|
+
export { x as n, q as t };
|