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.
- package/dist/app-Bw90hv7G.js +266 -0
- package/dist/brand-BtMsUv5o.js +201 -0
- package/dist/{cli-VgaueuJP.js → cli-s44ly0MH.js} +227 -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-Ci83UWu-.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 -29
- 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-DRzll98J.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-D9ePlTzy.js +0 -229
- 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 Object.values(r)) e.isEntry ? (i = e.file, e.css &&
|
|
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:
|
|
53
|
-
jsFiles:
|
|
47
|
+
cssFiles: a,
|
|
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,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} (${
|
|
68
|
+
this.logger.success(`${e} (${y(t)})`);
|
|
74
69
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
107
|
-
await
|
|
108
|
-
...
|
|
109
|
-
root:
|
|
110
|
-
base:
|
|
111
|
-
plugins:
|
|
112
|
-
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,
|
|
113
114
|
logLevel: "silent",
|
|
114
115
|
build: {
|
|
115
|
-
...
|
|
116
|
-
outDir:
|
|
116
|
+
...n.viteConfig?.build,
|
|
117
|
+
outDir: f,
|
|
117
118
|
manifest: !0,
|
|
118
119
|
emptyOutDir: !0,
|
|
119
120
|
rollupOptions: {
|
|
120
|
-
...
|
|
121
|
-
input:
|
|
121
|
+
...n.viteConfig?.build?.rollupOptions,
|
|
122
|
+
input: M
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
});
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
let x = new
|
|
128
|
-
await
|
|
129
|
-
...
|
|
130
|
-
root:
|
|
131
|
-
base:
|
|
132
|
-
plugins:
|
|
133
|
-
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,
|
|
134
135
|
logLevel: "silent",
|
|
135
136
|
build: {
|
|
136
|
-
...
|
|
137
|
-
outDir:
|
|
138
|
-
ssr:
|
|
137
|
+
...n.viteConfig?.build,
|
|
138
|
+
outDir: p,
|
|
139
|
+
ssr: N,
|
|
139
140
|
emptyOutDir: !0
|
|
140
141
|
}
|
|
141
142
|
}), x.done("SSR bundle");
|
|
142
|
-
let
|
|
143
|
-
let
|
|
144
|
-
return
|
|
143
|
+
let S = y.map((e) => {
|
|
144
|
+
let n = t(e);
|
|
145
|
+
return n === "index" ? "/" : `/${n}`;
|
|
145
146
|
});
|
|
146
|
-
S
|
|
147
|
-
let
|
|
148
|
-
await
|
|
149
|
-
ssrEntryPath:
|
|
150
|
-
clientOutDir:
|
|
151
|
-
outDir:
|
|
152
|
-
base:
|
|
153
|
-
pagePaths:
|
|
154
|
-
progress:
|
|
155
|
-
}),
|
|
156
|
-
let
|
|
157
|
-
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);
|
|
158
159
|
} finally {
|
|
159
160
|
await Promise.all([
|
|
160
|
-
|
|
161
|
+
m.rm(j, {
|
|
161
162
|
recursive: !0,
|
|
162
163
|
force: !0
|
|
163
164
|
}),
|
|
164
|
-
|
|
165
|
+
m.rm(f, {
|
|
165
166
|
recursive: !0,
|
|
166
167
|
force: !0
|
|
167
168
|
}),
|
|
168
|
-
|
|
169
|
+
m.rm(p, {
|
|
169
170
|
recursive: !0,
|
|
170
171
|
force: !0
|
|
171
172
|
})
|
|
172
173
|
]);
|
|
173
174
|
}
|
|
174
|
-
|
|
175
|
+
i.log(`\nBuild complete. Output: ${o}`);
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
-
let n = (
|
|
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
|
|
181
|
-
let r =
|
|
182
|
-
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));
|
|
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
|
|
243
|
+
function T(e) {
|
|
189
244
|
return e == null ? [] : Array.isArray(e) ? e : [e];
|
|
190
245
|
}
|
|
191
|
-
function
|
|
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
|
|
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 =
|
|
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
|
-
|
|
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
|
|
283
|
+
function O(e) {
|
|
229
284
|
return e.replace(/[<[].+/, "").trim();
|
|
230
285
|
}
|
|
231
|
-
function
|
|
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
|
|
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
|
|
308
|
+
function j(e) {
|
|
254
309
|
return e.sort((e, t) => e.length > t.length ? -1 : 1)[0];
|
|
255
310
|
}
|
|
256
|
-
function
|
|
311
|
+
function M(e, t) {
|
|
257
312
|
return e.length >= t ? e : `${e}${" ".repeat(t - e.length)}`;
|
|
258
313
|
}
|
|
259
|
-
function
|
|
314
|
+
function N(e) {
|
|
260
315
|
return e.replaceAll(/([a-z])-([a-z])/g, (e, t, n) => t + n.toUpperCase());
|
|
261
316
|
}
|
|
262
|
-
function
|
|
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
|
|
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
|
|
338
|
+
function I(e) {
|
|
284
339
|
let t = /([^\\/]+)$/.exec(e);
|
|
285
340
|
return t ? t[1] : "";
|
|
286
341
|
}
|
|
287
|
-
function
|
|
288
|
-
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(".");
|
|
289
344
|
}
|
|
290
|
-
var
|
|
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
|
-
},
|
|
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 =
|
|
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-/, "")),
|
|
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
|
-
},
|
|
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",
|
|
313
|
-
} else
|
|
314
|
-
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 {
|
|
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 =
|
|
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
|
|
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
|
|
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 =
|
|
430
|
+
let n = j(t.map((e) => e.rawName));
|
|
376
431
|
a.push({
|
|
377
432
|
title: "Commands",
|
|
378
|
-
body: t.map((e) => ` ${
|
|
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 =
|
|
441
|
+
let e = j(o.map((e) => e.rawName));
|
|
387
442
|
a.push({
|
|
388
443
|
title: "Options",
|
|
389
|
-
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")
|
|
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} ${
|
|
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
|
|
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
|
|
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
|
|
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
|
|
478
|
+
if (e < this.cli.args.length) throw new R(`Unused args: ${this.cli.args.slice(e).map((e) => `\`${e}\``).join(", ")}`);
|
|
424
479
|
}
|
|
425
|
-
},
|
|
480
|
+
}, U = class extends H {
|
|
426
481
|
constructor(e) {
|
|
427
482
|
super("@@global@@", "", {}, e);
|
|
428
483
|
}
|
|
429
|
-
},
|
|
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
|
|
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
|
|
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 (!
|
|
477
|
-
e =
|
|
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] ?
|
|
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 =
|
|
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 =
|
|
568
|
+
let o = D(e, r);
|
|
514
569
|
o = Object.keys(o).reduce((e, t) => ({
|
|
515
570
|
...e,
|
|
516
|
-
[
|
|
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 !== "_" && (
|
|
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
|
-
},
|
|
539
|
-
function
|
|
540
|
-
let t =
|
|
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
|
-
|
|
597
|
+
J("runtime", e);
|
|
543
598
|
}), process.on("unhandledRejection", (e) => {
|
|
544
|
-
|
|
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
|
|
547
|
-
root:
|
|
601
|
+
let n = await f({
|
|
602
|
+
root: Y(e),
|
|
548
603
|
configFile: !1,
|
|
549
|
-
plugins: [
|
|
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(
|
|
612
|
+
let r = e(Y(t));
|
|
558
613
|
try {
|
|
559
|
-
await
|
|
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-
|
|
568
|
-
await t(
|
|
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:
|
|
627
|
+
root: Y(e),
|
|
573
628
|
preview: { port: t.port }
|
|
574
629
|
})).printUrls();
|
|
575
|
-
}), t.help(), t.version("0.
|
|
630
|
+
}), t.help(), t.version("0.4.0"), t.parse();
|
|
576
631
|
}
|
|
577
|
-
function
|
|
632
|
+
function J(e, t) {
|
|
578
633
|
let n = t instanceof Error ? t.message : String(t);
|
|
579
|
-
console.error(`\n${
|
|
634
|
+
console.error(`\n${K} ${p.red(`${e} failed`)}\n`), console.error(p.red(n)), console.error(""), process.exit(1);
|
|
580
635
|
}
|
|
581
|
-
function
|
|
582
|
-
return
|
|
636
|
+
function Y(e) {
|
|
637
|
+
return u.resolve(e ?? process.cwd());
|
|
583
638
|
}
|
|
584
639
|
//#endregion
|
|
585
|
-
export {
|
|
640
|
+
export { x as n, q as t };
|