typerighter 0.1.4 → 0.1.6
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/bin/typedown.js +3 -1
- package/dist/cli-CrGQH71K.js +158 -0
- package/dist/cli.js +2 -0
- package/dist/html-cZxXrc6x.js +24 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -127
- package/dist/init-fZWFQnOM.js +646 -0
- package/dist/node/cli/index.d.ts +1 -1
- package/dist/node/cli/index.d.ts.map +1 -1
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/plugin/vite/index.d.ts.map +1 -1
- package/dist/plugin-B4GVd-re.js +1 -0
- package/dist/rolldown-runtime-Dqa2HsxW.js +20 -0
- package/dist/{typedown-context-WluCH44c.js → typedown-context-C5kvAxE0.js} +4 -19
- package/dist/typedown-context-uGzfOyIE.js +2 -0
- package/dist/{plugin-C-rHOs3n.js → vite-QefJNNFo.js} +34 -60
- package/dist/vite.js +2 -1
- package/package.json +4 -6
- package/dist/typedown-context-lK0KGe3B.js +0 -2
package/bin/typedown.js
CHANGED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { r as e } from "./rolldown-runtime-Dqa2HsxW.js";
|
|
2
|
+
import { i as t, r as n } from "./typedown-context-C5kvAxE0.js";
|
|
3
|
+
import { n as r, r as i, t as a } from "./vite-QefJNNFo.js";
|
|
4
|
+
import { n as o } from "./html-cZxXrc6x.js";
|
|
5
|
+
import s from "node:path";
|
|
6
|
+
import c from "node:fs/promises";
|
|
7
|
+
import l from "node:os";
|
|
8
|
+
import { build as u, createLogger as d, createServer as f } from "vite";
|
|
9
|
+
//#region src/node/build/render.ts
|
|
10
|
+
var p = /* @__PURE__ */ e(t(), 1);
|
|
11
|
+
async function m(e) {
|
|
12
|
+
let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await h(e.clientOutDir);
|
|
13
|
+
for (let a = 0; a < e.pagePaths.length; a += 8) {
|
|
14
|
+
let l = e.pagePaths.slice(a, a + 8);
|
|
15
|
+
await Promise.all(l.map(async (a) => {
|
|
16
|
+
let l = await t.render(a), u = o({
|
|
17
|
+
content: l.html,
|
|
18
|
+
title: l.pageData.title,
|
|
19
|
+
description: l.pageData.frontmatter.description === void 0 ? "" : String(l.pageData.frontmatter.description),
|
|
20
|
+
clientEntry: n,
|
|
21
|
+
cssFiles: r,
|
|
22
|
+
jsFiles: i,
|
|
23
|
+
base: e.base
|
|
24
|
+
}), d = a === "/" ? "index.html" : `${a.replace(/^\//, "")}.html`, f = s.join(e.outDir, d);
|
|
25
|
+
await c.mkdir(s.dirname(f), { recursive: !0 }), await c.writeFile(f, u);
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function h(e) {
|
|
30
|
+
let t = s.join(e, "assets"), n = [], r = await c.readdir(t).catch(() => n), i = [], a = [], o = "";
|
|
31
|
+
for (let e of r) e.endsWith(".css") ? i.push(`assets/${e}`) : e.endsWith(".js") && (e.startsWith("client-entry") || e.startsWith("index") ? o = `assets/${e}` : a.push(`assets/${e}`));
|
|
32
|
+
return !o && a.length > 0 && (o = a[0], a.splice(0, 1)), {
|
|
33
|
+
clientEntry: o,
|
|
34
|
+
cssFiles: i,
|
|
35
|
+
jsFiles: a
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/node/build/index.ts
|
|
40
|
+
var g = "typerighter/client/theme-default";
|
|
41
|
+
async function _(e) {
|
|
42
|
+
let t = s.resolve(e.root), a = s.resolve(t, e.outDir ?? "dist"), o = e.base ?? "/", d = s.join(a, ".client"), f = s.join(a, ".server"), { tdContext: p } = await import("./typedown-context-uGzfOyIE.js"), [h, _, y] = await Promise.all([
|
|
43
|
+
p.getConfig(),
|
|
44
|
+
p.listFiles(),
|
|
45
|
+
p.listFilesGroupedBySchema()
|
|
46
|
+
]), b = _.some((e) => e === "index.td"), x = JSON.stringify({
|
|
47
|
+
title: h.siteTitle,
|
|
48
|
+
description: h.siteDescription
|
|
49
|
+
}), S = JSON.stringify({ sidebarGroups: y }), C = await c.mkdtemp(s.join(l.tmpdir(), "typerighter-")), w = s.join(C, "client-entry.js"), T = s.join(C, "ssr-entry.js");
|
|
50
|
+
await Promise.all([c.writeFile(w, r({
|
|
51
|
+
contentDir: h.contentDir,
|
|
52
|
+
siteTitle: h.siteTitle,
|
|
53
|
+
siteDescription: h.siteDescription,
|
|
54
|
+
hasIndex: b,
|
|
55
|
+
sidebarGroups: y
|
|
56
|
+
})), c.writeFile(T, i({
|
|
57
|
+
contentDir: h.contentDir,
|
|
58
|
+
layoutImport: g,
|
|
59
|
+
siteConfig: x,
|
|
60
|
+
siteData: S
|
|
61
|
+
}))]);
|
|
62
|
+
try {
|
|
63
|
+
n.info("Phase 1: Building client bundle..."), await u({
|
|
64
|
+
...e.viteConfig,
|
|
65
|
+
root: t,
|
|
66
|
+
base: o,
|
|
67
|
+
build: {
|
|
68
|
+
...e.viteConfig?.build,
|
|
69
|
+
outDir: d,
|
|
70
|
+
ssrManifest: !0,
|
|
71
|
+
emptyOutDir: !0,
|
|
72
|
+
rollupOptions: {
|
|
73
|
+
...e.viteConfig?.build?.rollupOptions,
|
|
74
|
+
input: w
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}), n.info("Phase 2: Building SSR bundle..."), await u({
|
|
78
|
+
...e.viteConfig,
|
|
79
|
+
root: t,
|
|
80
|
+
base: o,
|
|
81
|
+
build: {
|
|
82
|
+
...e.viteConfig?.build,
|
|
83
|
+
outDir: f,
|
|
84
|
+
ssr: T,
|
|
85
|
+
emptyOutDir: !0
|
|
86
|
+
}
|
|
87
|
+
}), n.info("Phase 3: Pre-rendering pages...");
|
|
88
|
+
let r = _.map((e) => {
|
|
89
|
+
let t = e.replace(/\.td$/, "");
|
|
90
|
+
return t === "index" ? "/" : `/${t}`;
|
|
91
|
+
});
|
|
92
|
+
await m({
|
|
93
|
+
ssrEntryPath: s.join(f, "ssr-entry.js"),
|
|
94
|
+
clientOutDir: d,
|
|
95
|
+
outDir: a,
|
|
96
|
+
base: o,
|
|
97
|
+
pagePaths: r
|
|
98
|
+
});
|
|
99
|
+
let i = s.join(d, "assets"), l = s.join(a, "assets");
|
|
100
|
+
await c.cp(i, l, { recursive: !0 }).catch(() => {}), await v(s.join(t, h.contentDir), a);
|
|
101
|
+
} finally {
|
|
102
|
+
await Promise.all([
|
|
103
|
+
c.rm(C, {
|
|
104
|
+
recursive: !0,
|
|
105
|
+
force: !0
|
|
106
|
+
}),
|
|
107
|
+
c.rm(d, {
|
|
108
|
+
recursive: !0,
|
|
109
|
+
force: !0
|
|
110
|
+
}),
|
|
111
|
+
c.rm(f, {
|
|
112
|
+
recursive: !0,
|
|
113
|
+
force: !0
|
|
114
|
+
})
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
117
|
+
n.info(`Build complete. Output: ${a}`);
|
|
118
|
+
}
|
|
119
|
+
async function v(e, t) {
|
|
120
|
+
let n = (await c.readdir(e, {
|
|
121
|
+
recursive: !0,
|
|
122
|
+
withFileTypes: !0
|
|
123
|
+
})).filter((e) => e.isFile() && !e.name.endsWith(".td")).map((n) => {
|
|
124
|
+
let r = s.join(n.parentPath, n.name), i = s.relative(e, r), a = s.join(t, i);
|
|
125
|
+
return c.mkdir(s.dirname(a), { recursive: !0 }).then(() => c.copyFile(r, a));
|
|
126
|
+
});
|
|
127
|
+
await Promise.all(n);
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/node/cli/index.ts
|
|
131
|
+
async function y() {
|
|
132
|
+
let e = process.argv.slice(2), t = e[0], n = e[1] ?? process.cwd();
|
|
133
|
+
try {
|
|
134
|
+
if (!t || t === "dev") {
|
|
135
|
+
let e = await f({
|
|
136
|
+
root: n,
|
|
137
|
+
configFile: !1,
|
|
138
|
+
plugins: [a()]
|
|
139
|
+
});
|
|
140
|
+
await e.listen(), e.printUrls();
|
|
141
|
+
} else if (t === "build") await _({ root: n });
|
|
142
|
+
else if (t === "init") {
|
|
143
|
+
let { initialize: e } = await import("./init-fZWFQnOM.js");
|
|
144
|
+
await e(n);
|
|
145
|
+
} else if (t === "preview") {
|
|
146
|
+
let { preview: e } = await import("vite");
|
|
147
|
+
(await e({ root: n })).printUrls();
|
|
148
|
+
} else b(`unknown command "${t}".`);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
b(`${t ?? "dev"} error:`, e);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function b(e, t) {
|
|
154
|
+
let n = d(), r = [p.default.red(e)];
|
|
155
|
+
t instanceof Error && (r.push(t.message), t.stack && r.push(t.stack)), n.error(r.join("\n")), process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
export { _ as n, y as t };
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/node/build/html.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
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");
|
|
4
|
+
return `<!DOCTYPE html>
|
|
5
|
+
<html lang="${e.lang ?? "en"}">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="UTF-8">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
+
<title>${t(e.title)}</title>
|
|
10
|
+
<meta name="description" content="${t(e.description)}">
|
|
11
|
+
${n}
|
|
12
|
+
${r}
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div id="app">${e.content}</div>
|
|
16
|
+
<script type="module" src="${e.base}${e.clientEntry}"><\/script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>`;
|
|
19
|
+
}
|
|
20
|
+
function t(e) {
|
|
21
|
+
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { e as n, t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './node
|
|
1
|
+
export * from './node';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,127 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import s from "node:os";
|
|
6
|
-
import { build as c } from "vite";
|
|
7
|
-
//#region src/node/build/render.ts
|
|
8
|
-
async function l(e) {
|
|
9
|
-
let n = await import(e.ssrEntryPath), { clientEntry: r, cssFiles: i, jsFiles: s } = await u(e.clientOutDir);
|
|
10
|
-
for (let c = 0; c < e.pagePaths.length; c += 8) {
|
|
11
|
-
let l = e.pagePaths.slice(c, c + 8);
|
|
12
|
-
await Promise.all(l.map(async (c) => {
|
|
13
|
-
let l = await n.render(c), u = t({
|
|
14
|
-
content: l.html,
|
|
15
|
-
title: l.pageData.title,
|
|
16
|
-
description: l.pageData.frontmatter.description === void 0 ? "" : String(l.pageData.frontmatter.description),
|
|
17
|
-
clientEntry: r,
|
|
18
|
-
cssFiles: i,
|
|
19
|
-
jsFiles: s,
|
|
20
|
-
base: e.base
|
|
21
|
-
}), d = c === "/" ? "index.html" : `${c.replace(/^\//, "")}.html`, f = a.join(e.outDir, d);
|
|
22
|
-
await o.mkdir(a.dirname(f), { recursive: !0 }), await o.writeFile(f, u);
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
async function u(e) {
|
|
27
|
-
let t = a.join(e, "assets"), n = [], r = await o.readdir(t).catch(() => n), i = [], s = [], c = "";
|
|
28
|
-
for (let e of r) e.endsWith(".css") ? i.push(`assets/${e}`) : e.endsWith(".js") && (e.startsWith("client-entry") || e.startsWith("index") ? c = `assets/${e}` : s.push(`assets/${e}`));
|
|
29
|
-
return !c && s.length > 0 && (c = s[0], s.splice(0, 1)), {
|
|
30
|
-
clientEntry: c,
|
|
31
|
-
cssFiles: i,
|
|
32
|
-
jsFiles: s
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/node/build/index.ts
|
|
37
|
-
var d = "typerighter/client/theme-default";
|
|
38
|
-
async function f(t) {
|
|
39
|
-
let i = a.resolve(t.root), u = a.resolve(i, t.outDir ?? "dist"), f = t.base ?? "/", m = a.join(u, ".client"), h = a.join(u, ".server"), { tdContext: g } = await import("./typedown-context-lK0KGe3B.js"), [_, v, y] = await Promise.all([
|
|
40
|
-
g.getConfig(),
|
|
41
|
-
g.listFiles(),
|
|
42
|
-
g.listFilesGroupedBySchema()
|
|
43
|
-
]), b = v.some((e) => e === "index.td"), x = JSON.stringify({
|
|
44
|
-
title: _.siteTitle,
|
|
45
|
-
description: _.siteDescription
|
|
46
|
-
}), S = JSON.stringify({ sidebarGroups: y }), C = await o.mkdtemp(a.join(s.tmpdir(), "typerighter-")), w = a.join(C, "client-entry.js"), T = a.join(C, "ssr-entry.js");
|
|
47
|
-
await Promise.all([o.writeFile(w, n({
|
|
48
|
-
contentDir: _.contentDir,
|
|
49
|
-
siteTitle: _.siteTitle,
|
|
50
|
-
siteDescription: _.siteDescription,
|
|
51
|
-
hasIndex: b,
|
|
52
|
-
sidebarGroups: y
|
|
53
|
-
})), o.writeFile(T, r({
|
|
54
|
-
contentDir: _.contentDir,
|
|
55
|
-
layoutImport: d,
|
|
56
|
-
siteConfig: x,
|
|
57
|
-
siteData: S
|
|
58
|
-
}))]);
|
|
59
|
-
try {
|
|
60
|
-
e.info("Phase 1: Building client bundle..."), await c({
|
|
61
|
-
...t.viteConfig,
|
|
62
|
-
root: i,
|
|
63
|
-
base: f,
|
|
64
|
-
build: {
|
|
65
|
-
...t.viteConfig?.build,
|
|
66
|
-
outDir: m,
|
|
67
|
-
ssrManifest: !0,
|
|
68
|
-
emptyOutDir: !0,
|
|
69
|
-
rollupOptions: {
|
|
70
|
-
...t.viteConfig?.build?.rollupOptions,
|
|
71
|
-
input: w
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}), e.info("Phase 2: Building SSR bundle..."), await c({
|
|
75
|
-
...t.viteConfig,
|
|
76
|
-
root: i,
|
|
77
|
-
base: f,
|
|
78
|
-
build: {
|
|
79
|
-
...t.viteConfig?.build,
|
|
80
|
-
outDir: h,
|
|
81
|
-
ssr: T,
|
|
82
|
-
emptyOutDir: !0
|
|
83
|
-
}
|
|
84
|
-
}), e.info("Phase 3: Pre-rendering pages...");
|
|
85
|
-
let n = v.map((e) => {
|
|
86
|
-
let t = e.replace(/\.td$/, "");
|
|
87
|
-
return t === "index" ? "/" : `/${t}`;
|
|
88
|
-
});
|
|
89
|
-
await l({
|
|
90
|
-
ssrEntryPath: a.join(h, "ssr-entry.js"),
|
|
91
|
-
clientOutDir: m,
|
|
92
|
-
outDir: u,
|
|
93
|
-
base: f,
|
|
94
|
-
pagePaths: n
|
|
95
|
-
});
|
|
96
|
-
let r = a.join(m, "assets"), s = a.join(u, "assets");
|
|
97
|
-
await o.cp(r, s, { recursive: !0 }).catch(() => {}), await p(a.join(i, _.contentDir), u);
|
|
98
|
-
} finally {
|
|
99
|
-
await Promise.all([
|
|
100
|
-
o.rm(C, {
|
|
101
|
-
recursive: !0,
|
|
102
|
-
force: !0
|
|
103
|
-
}),
|
|
104
|
-
o.rm(m, {
|
|
105
|
-
recursive: !0,
|
|
106
|
-
force: !0
|
|
107
|
-
}),
|
|
108
|
-
o.rm(h, {
|
|
109
|
-
recursive: !0,
|
|
110
|
-
force: !0
|
|
111
|
-
})
|
|
112
|
-
]);
|
|
113
|
-
}
|
|
114
|
-
e.info(`Build complete. Output: ${u}`);
|
|
115
|
-
}
|
|
116
|
-
async function p(e, t) {
|
|
117
|
-
let n = (await o.readdir(e, {
|
|
118
|
-
recursive: !0,
|
|
119
|
-
withFileTypes: !0
|
|
120
|
-
})).filter((e) => e.isFile() && !e.name.endsWith(".td")).map((n) => {
|
|
121
|
-
let r = a.join(n.parentPath, n.name), i = a.relative(e, r), s = a.join(t, i);
|
|
122
|
-
return o.mkdir(a.dirname(s), { recursive: !0 }).then(() => o.copyFile(r, s));
|
|
123
|
-
});
|
|
124
|
-
await Promise.all(n);
|
|
125
|
-
}
|
|
126
|
-
//#endregion
|
|
127
|
-
export { f as buildSite, i as typedown };
|
|
1
|
+
import { t as e } from "./vite-QefJNNFo.js";
|
|
2
|
+
import "./plugin-B4GVd-re.js";
|
|
3
|
+
import { n as t, t as n } from "./cli-CrGQH71K.js";
|
|
4
|
+
export { t as buildSite, n as cli, e as typedown };
|
|
@@ -0,0 +1,646 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dqa2HsxW.js";
|
|
2
|
+
import { t } from "./html-cZxXrc6x.js";
|
|
3
|
+
import n from "node:path";
|
|
4
|
+
import "node:fs";
|
|
5
|
+
import r from "node:fs/promises";
|
|
6
|
+
import { styleText as i } from "node:util";
|
|
7
|
+
import a, { stdin as o, stdout as s } from "node:process";
|
|
8
|
+
import c from "node:readline";
|
|
9
|
+
import "node:tty";
|
|
10
|
+
//#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
11
|
+
var l = (() => {
|
|
12
|
+
let e = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
13
|
+
return (t) => {
|
|
14
|
+
let n = 0;
|
|
15
|
+
for (e.lastIndex = 0; e.test(t);) n += 1;
|
|
16
|
+
return t.length - n;
|
|
17
|
+
};
|
|
18
|
+
})(), u = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, d = (e) => e === 8987 || e === 9001 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141, f = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y, ee = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, p = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy, te = /\t{1,1000}/y, m = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy, ne = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y, re = /\p{M}+/gu, h = {
|
|
19
|
+
limit: Infinity,
|
|
20
|
+
ellipsis: ""
|
|
21
|
+
}, g = (e, t = {}, n = {}) => {
|
|
22
|
+
let r = t.limit ?? Infinity, i = t.ellipsis ?? "", a = t?.ellipsisWidth ?? (i ? g(i, h, n).width : 0), o = n.controlWidth ?? 0, s = n.tabWidth ?? 8, c = n.emojiWidth ?? 2, _ = n.regularWidth ?? 1, v = n.wideWidth ?? 2, y = [
|
|
23
|
+
[ne, _],
|
|
24
|
+
[f, 0],
|
|
25
|
+
[ee, o],
|
|
26
|
+
[te, s],
|
|
27
|
+
[m, c],
|
|
28
|
+
[p, v]
|
|
29
|
+
], b = 0, x = 0, S = e.length, C = 0, w = !1, T = S, E = Math.max(0, r - a), D = 0, O = 0, k = 0, A = 0;
|
|
30
|
+
outer: for (;;) {
|
|
31
|
+
if (O > D || x >= S && x > b) {
|
|
32
|
+
let t = e.slice(D, O) || e.slice(b, x);
|
|
33
|
+
C = 0;
|
|
34
|
+
for (let e of t.replaceAll(re, "")) {
|
|
35
|
+
let t = e.codePointAt(0) || 0;
|
|
36
|
+
if (A = u(t) ? 2 : d(t) ? v : _, k + A > E && (T = Math.min(T, Math.max(D, b) + C)), k + A > r) {
|
|
37
|
+
w = !0;
|
|
38
|
+
break outer;
|
|
39
|
+
}
|
|
40
|
+
C += e.length, k += A;
|
|
41
|
+
}
|
|
42
|
+
D = O = 0;
|
|
43
|
+
}
|
|
44
|
+
if (x >= S) break outer;
|
|
45
|
+
for (let t = 0, n = y.length; t < n; t++) {
|
|
46
|
+
let [n, i] = y[t];
|
|
47
|
+
if (n.lastIndex = x, n.test(e)) {
|
|
48
|
+
if (C = n === p ? l(e.slice(x, n.lastIndex)) : n === m ? 1 : n.lastIndex - x, A = C * i, k + A > E && (T = Math.min(T, x + Math.floor((E - k) / i))), k + A > r) {
|
|
49
|
+
w = !0;
|
|
50
|
+
break outer;
|
|
51
|
+
}
|
|
52
|
+
k += A, D = b, O = x, x = b = n.lastIndex;
|
|
53
|
+
continue outer;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
x += 1;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
width: w ? E : k,
|
|
60
|
+
index: w ? T : S,
|
|
61
|
+
truncated: w,
|
|
62
|
+
ellipsed: w && r >= a
|
|
63
|
+
};
|
|
64
|
+
}, _ = {
|
|
65
|
+
limit: Infinity,
|
|
66
|
+
ellipsis: "",
|
|
67
|
+
ellipsisWidth: 0
|
|
68
|
+
}, v = (e, t = {}) => g(e, _, t).width, y = "\x1B", b = "", x = 39, S = "\x07", C = "[", w = "]", T = "m", E = `${w}8;;`, D = RegExp(`(?:\\${C}(?<code>\\d+)m|\\${E}(?<uri>.*)${S})`, "y"), O = (e) => {
|
|
69
|
+
if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
|
|
70
|
+
if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
|
|
71
|
+
if (e === 1 || e === 2) return 22;
|
|
72
|
+
if (e === 3) return 23;
|
|
73
|
+
if (e === 4) return 24;
|
|
74
|
+
if (e === 7) return 27;
|
|
75
|
+
if (e === 8) return 28;
|
|
76
|
+
if (e === 9) return 29;
|
|
77
|
+
if (e === 0) return 0;
|
|
78
|
+
}, k = (e) => `${y}${C}${e}${T}`, A = (e) => `${y}${E}${e}${S}`, j = (e, t, n) => {
|
|
79
|
+
let r = t[Symbol.iterator](), i = !1, a = !1, o = e.at(-1), s = o === void 0 ? 0 : v(o), c = r.next(), l = r.next(), u = 0;
|
|
80
|
+
for (; !c.done;) {
|
|
81
|
+
let o = c.value, d = v(o);
|
|
82
|
+
s + d <= n ? e[e.length - 1] += o : (e.push(o), s = 0), (o === y || o === b) && (i = !0, a = t.startsWith(E, u + 1)), i ? a ? o === S && (i = !1, a = !1) : o === T && (i = !1) : (s += d, s === n && !l.done && (e.push(""), s = 0)), c = l, l = r.next(), u += o.length;
|
|
83
|
+
}
|
|
84
|
+
o = e.at(-1), !s && o !== void 0 && o.length && e.length > 1 && (e[e.length - 2] += e.pop());
|
|
85
|
+
}, ie = (e) => {
|
|
86
|
+
let t = e.split(" "), n = t.length;
|
|
87
|
+
for (; n && !v(t[n - 1]);) n--;
|
|
88
|
+
return n === t.length ? e : t.slice(0, n).join(" ") + t.slice(n).join("");
|
|
89
|
+
}, ae = (e, t, n = {}) => {
|
|
90
|
+
if (n.trim !== !1 && e.trim() === "") return "";
|
|
91
|
+
let r = "", i, a, o = e.split(" "), s = [""], c = 0;
|
|
92
|
+
for (let e = 0; e < o.length; e++) {
|
|
93
|
+
let r = o[e];
|
|
94
|
+
if (n.trim !== !1) {
|
|
95
|
+
let e = s.at(-1) ?? "", t = e.trimStart();
|
|
96
|
+
e.length !== t.length && (s[s.length - 1] = t, c = v(t));
|
|
97
|
+
}
|
|
98
|
+
e !== 0 && (c >= t && (n.wordWrap === !1 || n.trim === !1) && (s.push(""), c = 0), (c || n.trim === !1) && (s[s.length - 1] += " ", c++));
|
|
99
|
+
let i = v(r);
|
|
100
|
+
if (n.hard && i > t) {
|
|
101
|
+
let e = t - c, n = 1 + Math.floor((i - e - 1) / t);
|
|
102
|
+
Math.floor((i - 1) / t) < n && s.push(""), j(s, r, t), c = v(s.at(-1) ?? "");
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (c + i > t && c && i) {
|
|
106
|
+
if (n.wordWrap === !1 && c < t) {
|
|
107
|
+
j(s, r, t), c = v(s.at(-1) ?? "");
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
s.push(""), c = 0;
|
|
111
|
+
}
|
|
112
|
+
if (c + i > t && n.wordWrap === !1) {
|
|
113
|
+
j(s, r, t), c = v(s.at(-1) ?? "");
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
s[s.length - 1] += r, c += i;
|
|
117
|
+
}
|
|
118
|
+
n.trim !== !1 && (s = s.map((e) => ie(e)));
|
|
119
|
+
let l = s.join("\n"), u = !1;
|
|
120
|
+
for (let e = 0; e < l.length; e++) {
|
|
121
|
+
let t = l[e];
|
|
122
|
+
if (r += t, u) u = !1;
|
|
123
|
+
else if (u = t >= "\ud800" && t <= "\udbff", u) continue;
|
|
124
|
+
if (t === y || t === b) {
|
|
125
|
+
D.lastIndex = e + 1;
|
|
126
|
+
let t = D.exec(l)?.groups;
|
|
127
|
+
if (t?.code !== void 0) {
|
|
128
|
+
let e = Number.parseFloat(t.code);
|
|
129
|
+
i = e === x ? void 0 : e;
|
|
130
|
+
} else t?.uri !== void 0 && (a = t.uri.length === 0 ? void 0 : t.uri);
|
|
131
|
+
}
|
|
132
|
+
if (l[e + 1] === "\n") {
|
|
133
|
+
a && (r += A(""));
|
|
134
|
+
let e = i ? O(i) : void 0;
|
|
135
|
+
i && e && (r += k(e));
|
|
136
|
+
} else t === "\n" && (i && O(i) && (r += k(i)), a && (r += A(a)));
|
|
137
|
+
}
|
|
138
|
+
return r;
|
|
139
|
+
}, oe = /\r?\n/;
|
|
140
|
+
function M(e, t, n) {
|
|
141
|
+
return String(e).normalize().split(oe).map((e) => ae(e, t, n)).join("\n");
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region ../../node_modules/.pnpm/@clack+core@1.4.3/node_modules/@clack/core/dist/index.mjs
|
|
145
|
+
var N = (/* @__PURE__ */ e(((e, t) => {
|
|
146
|
+
var n = "\x1B", r = `${n}[`, i = "\x07", a = {
|
|
147
|
+
to(e, t) {
|
|
148
|
+
return t ? `${r}${t + 1};${e + 1}H` : `${r}${e + 1}G`;
|
|
149
|
+
},
|
|
150
|
+
move(e, t) {
|
|
151
|
+
let n = "";
|
|
152
|
+
return e < 0 ? n += `${r}${-e}D` : e > 0 && (n += `${r}${e}C`), t < 0 ? n += `${r}${-t}A` : t > 0 && (n += `${r}${t}B`), n;
|
|
153
|
+
},
|
|
154
|
+
up: (e = 1) => `${r}${e}A`,
|
|
155
|
+
down: (e = 1) => `${r}${e}B`,
|
|
156
|
+
forward: (e = 1) => `${r}${e}C`,
|
|
157
|
+
backward: (e = 1) => `${r}${e}D`,
|
|
158
|
+
nextLine: (e = 1) => `${r}E`.repeat(e),
|
|
159
|
+
prevLine: (e = 1) => `${r}F`.repeat(e),
|
|
160
|
+
left: `${r}G`,
|
|
161
|
+
hide: `${r}?25l`,
|
|
162
|
+
show: `${r}?25h`,
|
|
163
|
+
save: `${n}7`,
|
|
164
|
+
restore: `${n}8`
|
|
165
|
+
};
|
|
166
|
+
t.exports = {
|
|
167
|
+
cursor: a,
|
|
168
|
+
scroll: {
|
|
169
|
+
up: (e = 1) => `${r}S`.repeat(e),
|
|
170
|
+
down: (e = 1) => `${r}T`.repeat(e)
|
|
171
|
+
},
|
|
172
|
+
erase: {
|
|
173
|
+
screen: `${r}2J`,
|
|
174
|
+
up: (e = 1) => `${r}1J`.repeat(e),
|
|
175
|
+
down: (e = 1) => `${r}J`.repeat(e),
|
|
176
|
+
line: `${r}2K`,
|
|
177
|
+
lineEnd: `${r}K`,
|
|
178
|
+
lineStart: `${r}1K`,
|
|
179
|
+
lines(e) {
|
|
180
|
+
let t = "";
|
|
181
|
+
for (let n = 0; n < e; n++) t += this.line + (n < e - 1 ? a.up() : "");
|
|
182
|
+
return e && (t += a.left), t;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
beep: i
|
|
186
|
+
};
|
|
187
|
+
})))(), P = {
|
|
188
|
+
actions: /* @__PURE__ */ new Set([
|
|
189
|
+
"up",
|
|
190
|
+
"down",
|
|
191
|
+
"left",
|
|
192
|
+
"right",
|
|
193
|
+
"space",
|
|
194
|
+
"enter",
|
|
195
|
+
"cancel"
|
|
196
|
+
]),
|
|
197
|
+
aliases: /* @__PURE__ */ new Map([
|
|
198
|
+
["k", "up"],
|
|
199
|
+
["j", "down"],
|
|
200
|
+
["h", "left"],
|
|
201
|
+
["l", "right"],
|
|
202
|
+
["", "cancel"],
|
|
203
|
+
["escape", "cancel"]
|
|
204
|
+
]),
|
|
205
|
+
messages: {
|
|
206
|
+
cancel: "Canceled",
|
|
207
|
+
error: "Something went wrong"
|
|
208
|
+
},
|
|
209
|
+
withGuide: !0,
|
|
210
|
+
date: {
|
|
211
|
+
monthNames: [
|
|
212
|
+
"January",
|
|
213
|
+
"February",
|
|
214
|
+
"March",
|
|
215
|
+
"April",
|
|
216
|
+
"May",
|
|
217
|
+
"June",
|
|
218
|
+
"July",
|
|
219
|
+
"August",
|
|
220
|
+
"September",
|
|
221
|
+
"October",
|
|
222
|
+
"November",
|
|
223
|
+
"December"
|
|
224
|
+
],
|
|
225
|
+
messages: {
|
|
226
|
+
required: "Please enter a valid date",
|
|
227
|
+
invalidMonth: "There are only 12 months in a year",
|
|
228
|
+
invalidDay: (e, t) => `There are only ${e} days in ${t}`,
|
|
229
|
+
afterMin: (e) => `Date must be on or after ${e.toISOString().slice(0, 10)}`,
|
|
230
|
+
beforeMax: (e) => `Date must be on or before ${e.toISOString().slice(0, 10)}`
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function F(e, t) {
|
|
235
|
+
if (typeof e == "string") return P.aliases.get(e) === t;
|
|
236
|
+
for (let n of e) if (n !== void 0 && F(n, t)) return !0;
|
|
237
|
+
return !1;
|
|
238
|
+
}
|
|
239
|
+
function se(e, t) {
|
|
240
|
+
if (e === t) return;
|
|
241
|
+
let n = e.split("\n"), r = t.split("\n"), i = Math.max(n.length, r.length), a = [];
|
|
242
|
+
for (let e = 0; e < i; e++) n[e] !== r[e] && a.push(e);
|
|
243
|
+
return {
|
|
244
|
+
lines: a,
|
|
245
|
+
numLinesBefore: n.length,
|
|
246
|
+
numLinesAfter: r.length,
|
|
247
|
+
numLines: i
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
globalThis.process.platform.startsWith("win");
|
|
251
|
+
var I = Symbol("clack:cancel");
|
|
252
|
+
function L(e) {
|
|
253
|
+
return e === I;
|
|
254
|
+
}
|
|
255
|
+
function R(e, t) {
|
|
256
|
+
let n = e;
|
|
257
|
+
n.isTTY && n.setRawMode(t);
|
|
258
|
+
}
|
|
259
|
+
var ce = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
260
|
+
function z(e, t) {
|
|
261
|
+
if ("~standard" in e) {
|
|
262
|
+
let n = e["~standard"].validate(t);
|
|
263
|
+
if (n instanceof Promise) throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
264
|
+
return n.issues?.at(0)?.message;
|
|
265
|
+
}
|
|
266
|
+
return e(t);
|
|
267
|
+
}
|
|
268
|
+
var B = class {
|
|
269
|
+
input;
|
|
270
|
+
output;
|
|
271
|
+
_abortSignal;
|
|
272
|
+
rl;
|
|
273
|
+
opts;
|
|
274
|
+
_render;
|
|
275
|
+
_track = !1;
|
|
276
|
+
_prevFrame = "";
|
|
277
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
278
|
+
_cursor = 0;
|
|
279
|
+
state = "initial";
|
|
280
|
+
error = "";
|
|
281
|
+
value;
|
|
282
|
+
userInput = "";
|
|
283
|
+
constructor(e, t = !0) {
|
|
284
|
+
let { input: n = o, output: r = s, render: i, signal: a, ...c } = e;
|
|
285
|
+
this.opts = c, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = i.bind(this), this._track = t, this._abortSignal = a, this.input = n, this.output = r;
|
|
286
|
+
}
|
|
287
|
+
unsubscribe() {
|
|
288
|
+
this._subscribers.clear();
|
|
289
|
+
}
|
|
290
|
+
setSubscriber(e, t) {
|
|
291
|
+
let n = this._subscribers.get(e) ?? [];
|
|
292
|
+
n.push(t), this._subscribers.set(e, n);
|
|
293
|
+
}
|
|
294
|
+
on(e, t) {
|
|
295
|
+
this.setSubscriber(e, { cb: t });
|
|
296
|
+
}
|
|
297
|
+
once(e, t) {
|
|
298
|
+
this.setSubscriber(e, {
|
|
299
|
+
cb: t,
|
|
300
|
+
once: !0
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
emit(e, ...t) {
|
|
304
|
+
let n = this._subscribers.get(e) ?? [], r = [];
|
|
305
|
+
for (let e of n) e.cb(...t), e.once && r.push(() => n.splice(n.indexOf(e), 1));
|
|
306
|
+
for (let e of r) e();
|
|
307
|
+
}
|
|
308
|
+
prompt() {
|
|
309
|
+
return new Promise((e) => {
|
|
310
|
+
if (this._abortSignal) {
|
|
311
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(I);
|
|
312
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
313
|
+
this.state = "cancel", this.close();
|
|
314
|
+
}, { once: !0 });
|
|
315
|
+
}
|
|
316
|
+
this.rl = c.createInterface({
|
|
317
|
+
input: this.input,
|
|
318
|
+
tabSize: 2,
|
|
319
|
+
prompt: "",
|
|
320
|
+
escapeCodeTimeout: 50,
|
|
321
|
+
terminal: !0
|
|
322
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), R(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
323
|
+
this.output.write(N.cursor.show), this.output.off("resize", this.render), R(this.input, !1), e(this.value);
|
|
324
|
+
}), this.once("cancel", () => {
|
|
325
|
+
this.output.write(N.cursor.show), this.output.off("resize", this.render), R(this.input, !1), e(I);
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
_isActionKey(e, t) {
|
|
330
|
+
return e === " ";
|
|
331
|
+
}
|
|
332
|
+
_shouldSubmit(e, t) {
|
|
333
|
+
return !0;
|
|
334
|
+
}
|
|
335
|
+
_setValue(e) {
|
|
336
|
+
this.value = e, this.emit("value", this.value);
|
|
337
|
+
}
|
|
338
|
+
_setUserInput(e, t) {
|
|
339
|
+
this.userInput = e ?? "", this.emit("userInput", this.userInput), t && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
340
|
+
}
|
|
341
|
+
_clearUserInput() {
|
|
342
|
+
this.rl?.write(null, {
|
|
343
|
+
ctrl: !0,
|
|
344
|
+
name: "u"
|
|
345
|
+
}), this._setUserInput("");
|
|
346
|
+
}
|
|
347
|
+
onKeypress(e, t) {
|
|
348
|
+
if (this._track && t.name !== "return" && (t.name && this._isActionKey(e, t) && this.rl?.write(null, {
|
|
349
|
+
ctrl: !0,
|
|
350
|
+
name: "h"
|
|
351
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), t?.name && (!this._track && P.aliases.has(t.name) && this.emit("cursor", P.aliases.get(t.name)), P.actions.has(t.name) && this.emit("cursor", t.name)), e && (e.toLowerCase() === "y" || e.toLowerCase() === "n") && this.emit("confirm", e.toLowerCase() === "y"), this.emit("key", e, t), t?.name === "return" && this._shouldSubmit(e, t)) {
|
|
352
|
+
if (this.opts.validate) {
|
|
353
|
+
let e = z(this.opts.validate, this.value);
|
|
354
|
+
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
|
|
355
|
+
}
|
|
356
|
+
this.state !== "error" && (this.state = "submit");
|
|
357
|
+
}
|
|
358
|
+
F([
|
|
359
|
+
e,
|
|
360
|
+
t?.name,
|
|
361
|
+
t?.sequence
|
|
362
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
363
|
+
}
|
|
364
|
+
close() {
|
|
365
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write("\n"), R(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
366
|
+
}
|
|
367
|
+
restoreCursor() {
|
|
368
|
+
let e = M(this._prevFrame, process.stdout.columns, {
|
|
369
|
+
hard: !0,
|
|
370
|
+
trim: !1
|
|
371
|
+
}).split("\n").length - 1;
|
|
372
|
+
this.output.write(N.cursor.move(-999, e * -1));
|
|
373
|
+
}
|
|
374
|
+
render() {
|
|
375
|
+
let e = M(this._render(this) ?? "", process.stdout.columns, {
|
|
376
|
+
hard: !0,
|
|
377
|
+
trim: !1
|
|
378
|
+
});
|
|
379
|
+
if (e !== this._prevFrame) {
|
|
380
|
+
if (this.state === "initial") this.output.write(N.cursor.hide);
|
|
381
|
+
else {
|
|
382
|
+
let t = se(this._prevFrame, e), n = ce(this.output);
|
|
383
|
+
if (this.restoreCursor(), t) {
|
|
384
|
+
let r = Math.max(0, t.numLinesAfter - n), i = Math.max(0, t.numLinesBefore - n), a = t.lines.find((e) => e >= r);
|
|
385
|
+
if (a === void 0) {
|
|
386
|
+
this._prevFrame = e;
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
if (t.lines.length === 1) {
|
|
390
|
+
this.output.write(N.cursor.move(0, a - i)), this.output.write(N.erase.lines(1));
|
|
391
|
+
let t = e.split("\n");
|
|
392
|
+
this.output.write(t[a]), this._prevFrame = e, this.output.write(N.cursor.move(0, t.length - a - 1));
|
|
393
|
+
return;
|
|
394
|
+
} else if (t.lines.length > 1) {
|
|
395
|
+
if (r < i) a = r;
|
|
396
|
+
else {
|
|
397
|
+
let e = a - i;
|
|
398
|
+
e > 0 && this.output.write(N.cursor.move(0, e));
|
|
399
|
+
}
|
|
400
|
+
this.output.write(N.erase.down());
|
|
401
|
+
let t = e.split("\n").slice(a);
|
|
402
|
+
this.output.write(t.join("\n")), this._prevFrame = e;
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
this.output.write(N.erase.down());
|
|
407
|
+
}
|
|
408
|
+
this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}, V = class extends B {
|
|
412
|
+
get userInputWithCursor() {
|
|
413
|
+
if (this.state === "submit") return this.userInput;
|
|
414
|
+
let e = this.userInput;
|
|
415
|
+
if (this.cursor >= e.length) return `${this.userInput}\u2588`;
|
|
416
|
+
let t = e.slice(0, this.cursor), n = e.slice(this.cursor, this.cursor + 1), r = e.slice(this.cursor + 1);
|
|
417
|
+
return `${t}${i("inverse", n)}${r}`;
|
|
418
|
+
}
|
|
419
|
+
get cursor() {
|
|
420
|
+
return this._cursor;
|
|
421
|
+
}
|
|
422
|
+
constructor(e) {
|
|
423
|
+
super({
|
|
424
|
+
...e,
|
|
425
|
+
initialUserInput: e.initialUserInput ?? e.initialValue
|
|
426
|
+
}), this.on("userInput", (e) => {
|
|
427
|
+
this._setValue(e);
|
|
428
|
+
}), this.on("finalize", () => {
|
|
429
|
+
this.value ||= e.defaultValue, this.value === void 0 && (this.value = "");
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region ../../node_modules/.pnpm/@clack+prompts@1.7.0/node_modules/@clack/prompts/dist/index.mjs
|
|
435
|
+
function H() {
|
|
436
|
+
return a.platform === "win32" ? !!a.env.CI || !!a.env.WT_SESSION || !!a.env.TERMINUS_SUBLIME || a.env.ConEmuTask === "{cmd::Cmder}" || a.env.TERM_PROGRAM === "Terminus-Sublime" || a.env.TERM_PROGRAM === "vscode" || a.env.TERM === "xterm-256color" || a.env.TERM === "alacritty" || a.env.TERMINAL_EMULATOR === "JetBrains-JediTerm" : a.env.TERM !== "linux";
|
|
437
|
+
}
|
|
438
|
+
var U = H(), W = (e, t) => U ? e : t, G = W("◆", "*"), le = W("■", "x"), ue = W("▲", "x"), K = W("◇", "o"), de = W("┌", "T"), q = W("│", "|"), J = W("└", "—"), fe = W("●", "•"), pe = W("◆", "*"), me = W("▲", "!"), he = W("■", "x"), ge = (e) => {
|
|
439
|
+
switch (e) {
|
|
440
|
+
case "initial":
|
|
441
|
+
case "active": return i("cyan", G);
|
|
442
|
+
case "cancel": return i("red", le);
|
|
443
|
+
case "error": return i("yellow", ue);
|
|
444
|
+
case "submit": return i("green", K);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
`${i("dim", "↑/↓")}`, `${i("dim", "Space:")}`, `${i("dim", "Enter:")}`;
|
|
448
|
+
var Y = {
|
|
449
|
+
message: (e = [], { symbol: t = i("gray", q), secondarySymbol: n = i("gray", q), output: r = process.stdout, spacing: a = 1, withGuide: o } = {}) => {
|
|
450
|
+
let s = [], c = o ?? P.withGuide, l = c ? n : "", u = c ? `${t} ` : "", d = c ? `${n} ` : "";
|
|
451
|
+
for (let e = 0; e < a; e++) s.push(l);
|
|
452
|
+
let f = Array.isArray(e) ? e : e.split("\n");
|
|
453
|
+
if (f.length > 0) {
|
|
454
|
+
let [e, ...r] = f;
|
|
455
|
+
e.length > 0 ? s.push(`${u}${e}`) : s.push(c ? t : "");
|
|
456
|
+
for (let e of r) e.length > 0 ? s.push(`${d}${e}`) : s.push(c ? n : "");
|
|
457
|
+
}
|
|
458
|
+
r.write(`${s.join("\n")}
|
|
459
|
+
`);
|
|
460
|
+
},
|
|
461
|
+
info: (e, t) => {
|
|
462
|
+
Y.message(e, {
|
|
463
|
+
...t,
|
|
464
|
+
symbol: i("blue", fe)
|
|
465
|
+
});
|
|
466
|
+
},
|
|
467
|
+
success: (e, t) => {
|
|
468
|
+
Y.message(e, {
|
|
469
|
+
...t,
|
|
470
|
+
symbol: i("green", pe)
|
|
471
|
+
});
|
|
472
|
+
},
|
|
473
|
+
step: (e, t) => {
|
|
474
|
+
Y.message(e, {
|
|
475
|
+
...t,
|
|
476
|
+
symbol: i("green", K)
|
|
477
|
+
});
|
|
478
|
+
},
|
|
479
|
+
warn: (e, t) => {
|
|
480
|
+
Y.message(e, {
|
|
481
|
+
...t,
|
|
482
|
+
symbol: i("yellow", me)
|
|
483
|
+
});
|
|
484
|
+
},
|
|
485
|
+
warning: (e, t) => {
|
|
486
|
+
Y.warn(e, t);
|
|
487
|
+
},
|
|
488
|
+
error: (e, t) => {
|
|
489
|
+
Y.message(e, {
|
|
490
|
+
...t,
|
|
491
|
+
symbol: i("red", he)
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}, X = (e = "", t) => {
|
|
495
|
+
let n = t?.output ?? process.stdout, r = t?.withGuide ?? P.withGuide ? `${i("gray", J)} ` : "";
|
|
496
|
+
n.write(`${r}${i("red", e)}
|
|
497
|
+
|
|
498
|
+
`);
|
|
499
|
+
}, _e = (e = "", t) => {
|
|
500
|
+
let n = t?.output ?? process.stdout, r = t?.withGuide ?? P.withGuide ? `${i("gray", de)} ` : "";
|
|
501
|
+
n.write(`${r}${e}
|
|
502
|
+
`);
|
|
503
|
+
}, Z = (e = "", t) => {
|
|
504
|
+
let n = t?.output ?? process.stdout, r = t?.withGuide ?? P.withGuide ? `${i("gray", q)}
|
|
505
|
+
${i("gray", J)} ` : "";
|
|
506
|
+
n.write(`${r}${e}
|
|
507
|
+
|
|
508
|
+
`);
|
|
509
|
+
};
|
|
510
|
+
`${i("dim", "↑/↓")}`, `${i("dim", "Enter:")}`, `${i("gray", q)}`;
|
|
511
|
+
var Q = (e) => new V({
|
|
512
|
+
validate: e.validate,
|
|
513
|
+
placeholder: e.placeholder,
|
|
514
|
+
defaultValue: e.defaultValue,
|
|
515
|
+
initialValue: e.initialValue,
|
|
516
|
+
output: e.output,
|
|
517
|
+
signal: e.signal,
|
|
518
|
+
input: e.input,
|
|
519
|
+
render() {
|
|
520
|
+
let t = e?.withGuide ?? P.withGuide, n = `${`${t ? `${i("gray", q)}
|
|
521
|
+
` : ""}${ge(this.state)} `}${e.message}
|
|
522
|
+
`, r = e.placeholder && e.placeholder.length > 0 ? i("inverse", e.placeholder[0]) + i("dim", e.placeholder.slice(1)) : i(["inverse", "hidden"], "_"), a = this.userInput ? this.userInputWithCursor : r, o = this.value ?? "";
|
|
523
|
+
switch (this.state) {
|
|
524
|
+
case "error": {
|
|
525
|
+
let e = this.error ? ` ${i("yellow", this.error)}` : "", r = t ? `${i("yellow", q)} ` : "", o = t ? i("yellow", J) : "";
|
|
526
|
+
return `${n.trim()}
|
|
527
|
+
${r}${a}
|
|
528
|
+
${o}${e}
|
|
529
|
+
`;
|
|
530
|
+
}
|
|
531
|
+
case "submit": {
|
|
532
|
+
let e = o ? ` ${i("dim", o)}` : "";
|
|
533
|
+
return `${n}${t ? i("gray", q) : ""}${e}`;
|
|
534
|
+
}
|
|
535
|
+
case "cancel": {
|
|
536
|
+
let e = o ? ` ${i(["strikethrough", "dim"], o)}` : "", r = t ? i("gray", q) : "";
|
|
537
|
+
return `${n}${r}${e}${o.trim() ? `
|
|
538
|
+
${r}` : ""}`;
|
|
539
|
+
}
|
|
540
|
+
default: return `${n}${t ? `${i("cyan", q)} ` : ""}${a}
|
|
541
|
+
${t ? i("cyan", J) : ""}
|
|
542
|
+
`;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}).prompt();
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/node/cli/init.ts
|
|
548
|
+
async function ve(e) {
|
|
549
|
+
_e("typedown");
|
|
550
|
+
let t = n.basename(n.resolve(e)), r = await Q({
|
|
551
|
+
message: "Project name",
|
|
552
|
+
placeholder: t,
|
|
553
|
+
defaultValue: t
|
|
554
|
+
});
|
|
555
|
+
L(r) && (X("Cancelled."), process.exit(0));
|
|
556
|
+
let i = await Q({
|
|
557
|
+
message: "Site title",
|
|
558
|
+
placeholder: r,
|
|
559
|
+
defaultValue: r
|
|
560
|
+
});
|
|
561
|
+
L(i) && (X("Cancelled."), process.exit(0));
|
|
562
|
+
let a = await Q({
|
|
563
|
+
message: "Site description",
|
|
564
|
+
placeholder: "A typedown site",
|
|
565
|
+
defaultValue: "A typedown site"
|
|
566
|
+
});
|
|
567
|
+
L(a) && (X("Cancelled."), process.exit(0)), await Ce(e, {
|
|
568
|
+
projectName: r,
|
|
569
|
+
siteTitle: i,
|
|
570
|
+
siteDescription: a
|
|
571
|
+
});
|
|
572
|
+
let o = [];
|
|
573
|
+
e !== "." && o.push(`cd ${e}`), o.push("pnpm install", "pnpm dev"), Y.info(o.join("\n")), Z("Done");
|
|
574
|
+
}
|
|
575
|
+
function ye(e) {
|
|
576
|
+
return `<!doctype html>
|
|
577
|
+
<html lang="en">
|
|
578
|
+
<head>
|
|
579
|
+
<meta charset="UTF-8" />
|
|
580
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
581
|
+
<title>${t(e.siteTitle)}</title>
|
|
582
|
+
</head>
|
|
583
|
+
<body>
|
|
584
|
+
<div id="app"></div>
|
|
585
|
+
</body>
|
|
586
|
+
</html>
|
|
587
|
+
`;
|
|
588
|
+
}
|
|
589
|
+
function be(e) {
|
|
590
|
+
return JSON.stringify({
|
|
591
|
+
name: e.projectName,
|
|
592
|
+
version: "0.0.0",
|
|
593
|
+
private: !0,
|
|
594
|
+
type: "module",
|
|
595
|
+
scripts: {
|
|
596
|
+
dev: "typedown dev",
|
|
597
|
+
build: "typedown build",
|
|
598
|
+
preview: "typedown preview"
|
|
599
|
+
},
|
|
600
|
+
dependencies: {
|
|
601
|
+
typerighter: "^0.1.3",
|
|
602
|
+
vue: "^3.5.0"
|
|
603
|
+
},
|
|
604
|
+
devDependencies: { vite: "^8.0.0" }
|
|
605
|
+
}, void 0, 2) + "\n";
|
|
606
|
+
}
|
|
607
|
+
function xe() {
|
|
608
|
+
return "---\n_type: Article\ntitle: \"Hello, world\"\n---\n\nWelcome to your new typedown site.\n";
|
|
609
|
+
}
|
|
610
|
+
function Se() {
|
|
611
|
+
return "---\n_type: schema\nproperties:\n title:\n type: string\n tags:\n type: list[string]\n optional: true\n---\n";
|
|
612
|
+
}
|
|
613
|
+
async function Ce(e, t) {
|
|
614
|
+
let i = n.resolve(e), a = n.join(i, "vault", "content"), o = n.join(i, "vault", "schemas");
|
|
615
|
+
await r.mkdir(a, { recursive: !0 }), await r.mkdir(o, { recursive: !0 }), await Promise.all([
|
|
616
|
+
$(i, "package.json", be(t)),
|
|
617
|
+
$(i, "vite.config.ts", Te()),
|
|
618
|
+
$(i, "typedown.yaml", we(t)),
|
|
619
|
+
$(i, "index.html", ye(t)),
|
|
620
|
+
$(o, "Article.td", Se()),
|
|
621
|
+
$(a, "hello.td", xe())
|
|
622
|
+
]);
|
|
623
|
+
}
|
|
624
|
+
function we(e) {
|
|
625
|
+
return `version: "1.0.0"
|
|
626
|
+
vault:
|
|
627
|
+
content_dir: vault/content
|
|
628
|
+
schema_dir: vault/schemas
|
|
629
|
+
site:
|
|
630
|
+
title: "${e.siteTitle}"
|
|
631
|
+
description: "${e.siteDescription}"
|
|
632
|
+
`;
|
|
633
|
+
}
|
|
634
|
+
function Te() {
|
|
635
|
+
return "import { defineConfig } from \"vite\";\nimport { typedown } from \"typerighter/vite\";\n\nexport default defineConfig({\n plugins: [typedown()],\n});\n";
|
|
636
|
+
}
|
|
637
|
+
async function $(e, t, i) {
|
|
638
|
+
let a = n.join(e, t);
|
|
639
|
+
if (await r.access(a).then(() => !0).catch(() => !1)) {
|
|
640
|
+
Y.warn(`skip ${t} (already exists)`);
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
await r.writeFile(a, i), Y.success(`created ${t}`);
|
|
644
|
+
}
|
|
645
|
+
//#endregion
|
|
646
|
+
export { ve as initialize };
|
package/dist/node/cli/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function cli(): Promise<void>;
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/cli/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/cli/index.ts"],"names":[],"mappings":"AAWA,wBAAsB,GAAG,kBAyCxB"}
|
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACP,MAAM,MAAM,CAAC;AAqBd,wBAAgB,QAAQ,IAAK,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,MAAM,EACP,MAAM,MAAM,CAAC;AAqBd,wBAAgB,QAAQ,IAAK,MAAM,EAAE,CA4JpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./vite-QefJNNFo.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in e) t(r, i, {
|
|
5
|
+
get: e[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, c = (e, i, o, s) => {
|
|
10
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
|
+
get: ((e) => i[e]).bind(null, d),
|
|
12
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
|
+
});
|
|
14
|
+
return e;
|
|
15
|
+
}, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
|
|
16
|
+
value: n,
|
|
17
|
+
enumerable: !0
|
|
18
|
+
}) : a, n));
|
|
19
|
+
//#endregion
|
|
20
|
+
export { s as n, l as r, o as t };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as __exportAll, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-Dqa2HsxW.js";
|
|
1
2
|
import { t as l$2 } from "./chunk-DfAF0w94-EwUSVR-h.js";
|
|
2
3
|
import { n as isLinkToPage, r as EXTERNAL_URL_RE, t as isExternal } from "./shared-DzTfF-_d.js";
|
|
3
4
|
import path from "node:path";
|
|
@@ -7,24 +8,8 @@ import MarkdownIt from "markdown-it";
|
|
|
7
8
|
import { createHighlighter, guessEmbeddedLanguages, isSpecialLang } from "shiki";
|
|
8
9
|
import fs from "node:fs";
|
|
9
10
|
import { URL as URL$1 } from "node:url";
|
|
10
|
-
//#region
|
|
11
|
-
var
|
|
12
|
-
let d = {};
|
|
13
|
-
for (var f in s) __defProp$1(d, f, {
|
|
14
|
-
get: s[f],
|
|
15
|
-
enumerable: !0
|
|
16
|
-
});
|
|
17
|
-
return u || __defProp$1(d, Symbol.toStringTag, { value: "Module" }), d;
|
|
18
|
-
}, __copyProps$1 = (s, u, d, f) => {
|
|
19
|
-
if (u && typeof u == "object" || typeof u == "function") for (var p = __getOwnPropNames$1(u), m = 0, h = p.length, g; m < h; m++) g = p[m], !__hasOwnProp$1.call(s, g) && g !== d && __defProp$1(s, g, {
|
|
20
|
-
get: ((s) => u[s]).bind(null, g),
|
|
21
|
-
enumerable: !(f = __getOwnPropDesc$1(u, g)) || f.enumerable
|
|
22
|
-
});
|
|
23
|
-
return s;
|
|
24
|
-
}, __toESM = (s, u, d) => (d = s == null ? {} : __create(__getProtoOf(s)), __copyProps$1(u || !s || !s.__esModule ? __defProp$1(d, "default", {
|
|
25
|
-
value: s,
|
|
26
|
-
enumerable: !0
|
|
27
|
-
}) : d, s)), require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((s, u) => {
|
|
11
|
+
//#region __vite-browser-external
|
|
12
|
+
var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((s, u) => {
|
|
28
13
|
u.exports = {};
|
|
29
14
|
})), require_kind_of = /* @__PURE__ */ __commonJSMin(((s, u) => {
|
|
30
15
|
var d = Object.prototype.toString;
|
|
@@ -9508,4 +9493,4 @@ async function initializeTypedownContext() {
|
|
|
9508
9493
|
}
|
|
9509
9494
|
var tdContext = await initializeTypedownContext();
|
|
9510
9495
|
//#endregion
|
|
9511
|
-
export { tdContext as n, logger as r, TypedownContext as t };
|
|
9496
|
+
export { require_picocolors_browser as i, tdContext as n, logger as r, TypedownContext as t };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { n as e } from "./typedown-context-
|
|
1
|
+
import { n as e } from "./typedown-context-C5kvAxE0.js";
|
|
2
2
|
import "./shared-DzTfF-_d.js";
|
|
3
3
|
import { c as t, r as n } from "./brand-DSd9HWVy.js";
|
|
4
|
-
import r from "
|
|
5
|
-
import i from "@
|
|
4
|
+
import { t as r } from "./html-cZxXrc6x.js";
|
|
5
|
+
import i from "@tailwindcss/vite";
|
|
6
|
+
import a from "@vitejs/plugin-vue";
|
|
6
7
|
//#region src/node/lib/render/vue.ts
|
|
7
|
-
async function
|
|
8
|
+
async function o(e, n, r) {
|
|
8
9
|
let i = {
|
|
9
10
|
path: r,
|
|
10
11
|
relativePath: r,
|
|
@@ -27,34 +28,11 @@ async function a(e, n, r) {
|
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
//#endregion
|
|
30
|
-
//#region src/node/build/html.ts
|
|
31
|
-
function o(e) {
|
|
32
|
-
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");
|
|
33
|
-
return `<!DOCTYPE html>
|
|
34
|
-
<html lang="${e.lang ?? "en"}">
|
|
35
|
-
<head>
|
|
36
|
-
<meta charset="UTF-8">
|
|
37
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
38
|
-
<title>${s(e.title)}</title>
|
|
39
|
-
<meta name="description" content="${s(e.description)}">
|
|
40
|
-
${t}
|
|
41
|
-
${n}
|
|
42
|
-
</head>
|
|
43
|
-
<body>
|
|
44
|
-
<div id="app">${e.content}</div>
|
|
45
|
-
<script type="module" src="${e.base}${e.clientEntry}"><\/script>
|
|
46
|
-
</body>
|
|
47
|
-
</html>`;
|
|
48
|
-
}
|
|
49
|
-
function s(e) {
|
|
50
|
-
return e.replaceAll("&", "&").replaceAll("\"", """).replaceAll("<", "<").replaceAll(">", ">");
|
|
51
|
-
}
|
|
52
|
-
//#endregion
|
|
53
31
|
//#region src/node/plugin/vite/constants.ts
|
|
54
|
-
var
|
|
32
|
+
var s = "@typedown/app", c = "\0@typedown/app", l = "__typedown_index__.td";
|
|
55
33
|
//#endregion
|
|
56
34
|
//#region src/node/plugin/vite/codegen.ts
|
|
57
|
-
function
|
|
35
|
+
function u(e) {
|
|
58
36
|
let { contentDir: t, hasIndex: n } = e;
|
|
59
37
|
return `
|
|
60
38
|
import 'typerighter/style.css';
|
|
@@ -62,12 +40,12 @@ import { createTypedownApp } from 'typerighter/client';
|
|
|
62
40
|
import theme from 'typerighter/client/theme-default';
|
|
63
41
|
|
|
64
42
|
const pages = import.meta.glob('${`/${t}/**/*.td`}');
|
|
65
|
-
${n ? "" : `pages['/${t}/${
|
|
43
|
+
${n ? "" : `pages['/${t}/${l}'] = () => import('${l}');`}
|
|
66
44
|
|
|
67
45
|
async function loadPageModule(pagePath) {
|
|
68
46
|
const key = '/${t}/' + pagePath.replace(/^\\//, '') + '.td';
|
|
69
47
|
const altKey = '/${t}/' + pagePath.replace(/^\\//, '') + '/index.td';
|
|
70
|
-
const loader = pages[key] || pages[altKey]${n ? "" : ` || (pagePath === '/' ? pages['/${t}/${
|
|
48
|
+
const loader = pages[key] || pages[altKey]${n ? "" : ` || (pagePath === '/' ? pages['/${t}/${l}'] : undefined)`};
|
|
71
49
|
if (!loader) return undefined;
|
|
72
50
|
return loader();
|
|
73
51
|
}
|
|
@@ -79,7 +57,7 @@ const { app } = await createTypedownApp(loadPageModule, theme.Layout, ${JSON.str
|
|
|
79
57
|
app.mount('#app');
|
|
80
58
|
`;
|
|
81
59
|
}
|
|
82
|
-
function
|
|
60
|
+
function d(e) {
|
|
83
61
|
let t = JSON.stringify(e).replace(/'/g, "\\'"), n = JSON.stringify({
|
|
84
62
|
schema: "",
|
|
85
63
|
frontmatter: {},
|
|
@@ -93,7 +71,7 @@ export default { name: "index", components: { TdOverview } }
|
|
|
93
71
|
<\/script>
|
|
94
72
|
<template><TdOverview :groups='${t}' /></template>`;
|
|
95
73
|
}
|
|
96
|
-
function
|
|
74
|
+
function f(e) {
|
|
97
75
|
let t = `/${e.contentDir}/**/*.td`;
|
|
98
76
|
return `
|
|
99
77
|
import { createTypedownApp } from 'typerighter/client';
|
|
@@ -118,18 +96,14 @@ export async function render(url) {
|
|
|
118
96
|
}
|
|
119
97
|
//#endregion
|
|
120
98
|
//#region src/node/plugin/vite/index.ts
|
|
121
|
-
function
|
|
99
|
+
function p() {
|
|
122
100
|
let t;
|
|
123
101
|
return [
|
|
124
102
|
{
|
|
125
103
|
name: "vite-plugin-typedown",
|
|
126
104
|
enforce: "pre",
|
|
127
|
-
async transformIndexHtml(t) {
|
|
128
|
-
let r = await e.getConfig();
|
|
129
|
-
return t.replace(/<title>.*?<\/title>/, `<title>${s(r.siteTitle)}</title>`).replace("</head>", ` <link rel="icon" type="image/svg+xml" href="${n}">\n</head>`).replace("</body>", ` <script type="module" src="/${c}"><\/script>\n</body>`);
|
|
130
|
-
},
|
|
131
105
|
resolveId(e) {
|
|
132
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return
|
|
106
|
+
if (e === "/@typedown/app" || e === "@typedown/app") return c;
|
|
133
107
|
if (e.endsWith("__typedown_index__.td")) return e;
|
|
134
108
|
},
|
|
135
109
|
async load(t) {
|
|
@@ -139,16 +113,16 @@ function m() {
|
|
|
139
113
|
e.listFiles(),
|
|
140
114
|
e.listFilesGroupedBySchema()
|
|
141
115
|
]), i = n.some((e) => e === "index.td");
|
|
142
|
-
return
|
|
116
|
+
return u({
|
|
143
117
|
...t,
|
|
144
118
|
hasIndex: i,
|
|
145
119
|
sidebarGroups: r
|
|
146
120
|
});
|
|
147
121
|
}
|
|
148
|
-
if (t.endsWith("__typedown_index__.td")) return
|
|
122
|
+
if (t.endsWith("__typedown_index__.td")) return d(await e.listFilesGroupedBySchema());
|
|
149
123
|
},
|
|
150
|
-
configureServer(
|
|
151
|
-
return t =
|
|
124
|
+
configureServer(i) {
|
|
125
|
+
return t = i, e.rpc.onConfigChanged(() => t && h(t)), e.rpc.onContentChanged(({ content: e }) => {
|
|
152
126
|
if (t) {
|
|
153
127
|
for (let n of t.moduleGraph.idToModuleMap.values()) if (n.file?.endsWith(e)) {
|
|
154
128
|
t.moduleGraph.invalidateModule(n), t.hot.send({
|
|
@@ -163,32 +137,32 @@ function m() {
|
|
|
163
137
|
break;
|
|
164
138
|
}
|
|
165
139
|
}
|
|
166
|
-
}), e.rpc.onContentCreated(() => t &&
|
|
167
|
-
|
|
168
|
-
if (!t.url ||
|
|
140
|
+
}), e.rpc.onContentCreated(() => t && g(t)), e.rpc.onContentDeleted(() => t && g(t)), e.rpc.onSchemaChanged(() => t && g(t)), e.rpc.onSchemaCreated(() => t && g(t)), e.rpc.onSchemaDeleted(() => t && g(t)), () => {
|
|
141
|
+
i.middlewares.use((t, i, a) => {
|
|
142
|
+
if (!t.url || i.writableEnded || t.url.startsWith("/@") || t.url.startsWith("/node_modules") || t.url.includes(".")) return a();
|
|
169
143
|
e.getConfig().then((e) => {
|
|
170
144
|
let t = `<!DOCTYPE html>
|
|
171
145
|
<html lang="en">
|
|
172
146
|
<head>
|
|
173
147
|
<meta charset="UTF-8">
|
|
174
148
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
175
|
-
<title>${
|
|
149
|
+
<title>${r(e.siteTitle)}</title>
|
|
176
150
|
<link rel="icon" type="image/svg+xml" href="${n}">
|
|
177
151
|
</head>
|
|
178
152
|
<body>
|
|
179
153
|
<div id="app"></div>
|
|
180
|
-
<script type="module" src="/${
|
|
154
|
+
<script type="module" src="/${s}"><\/script>
|
|
181
155
|
</body>
|
|
182
156
|
</html>`;
|
|
183
|
-
|
|
184
|
-
}).catch(
|
|
157
|
+
i.setHeader("Content-Type", "text/html"), i.end(t);
|
|
158
|
+
}).catch(a);
|
|
185
159
|
});
|
|
186
160
|
};
|
|
187
161
|
},
|
|
188
162
|
async transform(t, n) {
|
|
189
163
|
let r = n.split("?")[0];
|
|
190
164
|
if (!r.endsWith(".td") || r.includes("__typedown_index__.td")) return;
|
|
191
|
-
let i = (await e.getConfig()).contentDir,
|
|
165
|
+
let i = (await e.getConfig()).contentDir, a = r.includes(i) ? r.slice(r.indexOf(i) + i.length + 1) : r, s = await e.getFile(a), { vueSrc: c } = await o(e.md, s, a);
|
|
192
166
|
return {
|
|
193
167
|
code: c,
|
|
194
168
|
map: null
|
|
@@ -198,25 +172,25 @@ function m() {
|
|
|
198
172
|
if (e.endsWith(".td")) return [];
|
|
199
173
|
}
|
|
200
174
|
},
|
|
201
|
-
|
|
202
|
-
...
|
|
175
|
+
a({ include: /\.(?:vue|td)$/ }),
|
|
176
|
+
...i()
|
|
203
177
|
];
|
|
204
178
|
}
|
|
205
|
-
function
|
|
179
|
+
function m(e) {
|
|
206
180
|
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
207
181
|
}
|
|
208
|
-
function
|
|
209
|
-
for (let t of
|
|
182
|
+
function h(e) {
|
|
183
|
+
for (let t of m(e)) e.moduleGraph.invalidateModule(t);
|
|
210
184
|
e.hot.send({ type: "full-reload" });
|
|
211
185
|
}
|
|
212
|
-
function
|
|
213
|
-
let t =
|
|
186
|
+
function g(e) {
|
|
187
|
+
let t = m(e).map((t) => (e.moduleGraph.invalidateModule(t), _(t)));
|
|
214
188
|
0 < t.length && e.hot.send({
|
|
215
189
|
type: "update",
|
|
216
190
|
updates: t
|
|
217
191
|
});
|
|
218
192
|
}
|
|
219
|
-
function
|
|
193
|
+
function _(e) {
|
|
220
194
|
return {
|
|
221
195
|
type: "js-update",
|
|
222
196
|
path: e.url,
|
|
@@ -225,4 +199,4 @@ function v(e) {
|
|
|
225
199
|
};
|
|
226
200
|
}
|
|
227
201
|
//#endregion
|
|
228
|
-
export {
|
|
202
|
+
export { u as n, f as r, p as t };
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "typerighter",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.6",
|
|
5
5
|
"description": "Typedown: A typed content framework.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -74,12 +74,10 @@
|
|
|
74
74
|
"picocolors": "^1.1.1",
|
|
75
75
|
"shiki": "^4.3.1",
|
|
76
76
|
"tailwindcss": "^4.3.3",
|
|
77
|
-
"@typerighter/rpc-client": "0.1.4",
|
|
78
|
-
"@typerighter/rpc-server": "0.1.4"
|
|
79
|
-
},
|
|
80
|
-
"peerDependencies": {
|
|
81
77
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
82
|
-
"vue": "^3.0.0"
|
|
78
|
+
"vue": "^3.0.0",
|
|
79
|
+
"@typerighter/rpc-client": "0.1.6",
|
|
80
|
+
"@typerighter/rpc-server": "0.1.6"
|
|
83
81
|
},
|
|
84
82
|
"devDependencies": {
|
|
85
83
|
"@hdnax/nuclint": "^0.17.4",
|