typerighter 0.4.4 → 0.30.4
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-wLTpP3BP.js +2382 -0
- package/dist/brand-CG1fQshq.js +5 -0
- package/dist/cli-DFeDkMZb.js +440 -0
- package/dist/cli.js +1 -1
- package/dist/client/app/index.d.ts +43 -4
- package/dist/client/app/index.d.ts.map +1 -1
- package/dist/client/app/router.d.ts +6 -2
- package/dist/client/app/router.d.ts.map +1 -1
- package/dist/client/theme-default.js +2319 -597
- package/dist/client.js +1 -1
- package/dist/fonts.css +2 -0
- package/dist/index.js +3 -4
- package/dist/init-4ZHUVwp-.js +821 -0
- package/dist/math.css +1 -0
- package/dist/node/build/index.d.ts.map +1 -1
- package/dist/node/build/prerender.d.ts +2 -0
- package/dist/node/build/prerender.d.ts.map +1 -1
- package/dist/node/cli/index.d.ts.map +1 -1
- package/dist/node/cli/init.d.ts +7 -1
- package/dist/node/cli/init.d.ts.map +1 -1
- package/dist/node/context.d.ts.map +1 -1
- package/dist/node/lib/html-template.d.ts +22 -0
- package/dist/node/lib/html-template.d.ts.map +1 -0
- package/dist/node/lib/image-dimensions.d.ts +6 -0
- package/dist/node/lib/image-dimensions.d.ts.map +1 -0
- package/dist/node/lib/index.d.ts +0 -1
- package/dist/node/lib/index.d.ts.map +1 -1
- package/dist/node/lib/progress.d.ts +2 -0
- package/dist/node/lib/progress.d.ts.map +1 -1
- package/dist/node/lib/render/highlight/index.d.ts.map +1 -0
- package/dist/node/lib/render/highlight/language.d.ts.map +1 -0
- package/dist/node/lib/render/postprocess.d.ts +2 -0
- package/dist/node/lib/render/postprocess.d.ts.map +1 -0
- package/dist/node/lib/render/vue.d.ts +1 -0
- package/dist/node/lib/render/vue.d.ts.map +1 -1
- package/dist/node/{plugin/vite/search.d.ts → lib/search-indexer/index.d.ts} +2 -3
- package/dist/node/lib/search-indexer/index.d.ts.map +1 -0
- package/dist/node/lib/search-indexer/scan.d.ts +4 -0
- package/dist/node/lib/search-indexer/scan.d.ts.map +1 -0
- package/dist/node/lib/typedown-context.d.ts +6 -10
- package/dist/node/lib/typedown-context.d.ts.map +1 -1
- package/dist/node/plugin/vite/constants.d.ts +6 -0
- package/dist/node/plugin/vite/constants.d.ts.map +1 -1
- package/dist/node/plugin/vite/index.d.ts +7 -13
- package/dist/node/plugin/vite/index.d.ts.map +1 -1
- package/dist/node/plugin/vite/middleware/index.d.ts +3 -0
- package/dist/node/plugin/vite/middleware/index.d.ts.map +1 -0
- package/dist/node/plugin/vite/middleware/vault-assets.d.ts +5 -0
- package/dist/node/plugin/vite/middleware/vault-assets.d.ts.map +1 -0
- package/dist/node/plugin/vite/middleware/virtual-html.d.ts +6 -0
- package/dist/node/plugin/vite/middleware/virtual-html.d.ts.map +1 -0
- package/dist/node/plugin/vite/virtual/app.d.ts +23 -0
- package/dist/node/plugin/vite/virtual/app.d.ts.map +1 -0
- package/dist/node/plugin/vite/virtual/pages.d.ts +12 -0
- package/dist/node/plugin/vite/virtual/pages.d.ts.map +1 -0
- package/dist/node/plugin/vite/virtual/search-index.d.ts +11 -0
- package/dist/node/plugin/vite/virtual/search-index.d.ts.map +1 -0
- package/dist/node/plugin/vite/virtual/site-data.d.ts +13 -0
- package/dist/node/plugin/vite/virtual/site-data.d.ts.map +1 -0
- package/dist/node/plugin/vite/virtual/utils.d.ts +8 -0
- package/dist/node/plugin/vite/virtual/utils.d.ts.map +1 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/types/content.d.ts +42 -11
- package/dist/shared/types/content.d.ts.map +1 -1
- package/dist/shared/types/index.d.ts +0 -1
- package/dist/shared/types/index.d.ts.map +1 -1
- package/dist/shared/types/ssg.d.ts +18 -3
- package/dist/shared/types/ssg.d.ts.map +1 -1
- package/dist/shared/utils/content.d.ts +5 -3
- package/dist/shared/utils/content.d.ts.map +1 -1
- package/dist/shared/utils/field.d.ts +2 -0
- package/dist/shared/utils/field.d.ts.map +1 -0
- package/dist/shared/utils/html.d.ts +2 -0
- package/dist/shared/utils/html.d.ts.map +1 -1
- package/dist/shared/utils/index.d.ts +1 -0
- package/dist/shared/utils/index.d.ts.map +1 -1
- package/dist/shared/utils/path.d.ts +1 -0
- package/dist/shared/utils/path.d.ts.map +1 -1
- package/dist/shared/utils/url.d.ts +9 -1
- package/dist/shared/utils/url.d.ts.map +1 -1
- package/dist/shared-B-n46X4N.js +405 -0
- package/dist/shared.js +2 -0
- package/dist/temml-DZbhOfRE.js +8146 -0
- package/dist/typerighter.css +1 -1
- package/dist/vite-vMuZ0f3f.js +1469 -0
- package/dist/vite.js +2 -2
- package/package.json +26 -40
- package/dist/app-Bw90hv7G.js +0 -266
- package/dist/brand-CmL-6h9U.js +0 -203
- package/dist/cli-Dz9GEomM.js +0 -640
- package/dist/constants-7heqadyd.js +0 -32183
- package/dist/init-z0GJPXx4.js +0 -2356
- package/dist/node/lib/markdown/index.d.ts +0 -5
- package/dist/node/lib/markdown/index.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/callout-container.d.ts +0 -4
- package/dist/node/lib/markdown/plugins/callout-container.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/custom-container.d.ts +0 -3
- package/dist/node/lib/markdown/plugins/custom-container.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/highlight/index.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/highlight/language.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/image.d.ts +0 -3
- package/dist/node/lib/markdown/plugins/image.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/line-number.d.ts +0 -3
- package/dist/node/lib/markdown/plugins/line-number.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/link.d.ts +0 -3
- package/dist/node/lib/markdown/plugins/link.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/pre-wrapper.d.ts +0 -6
- package/dist/node/lib/markdown/plugins/pre-wrapper.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/restore-entities.d.ts +0 -3
- package/dist/node/lib/markdown/plugins/restore-entities.d.ts.map +0 -1
- package/dist/node/lib/markdown/plugins/table.d.ts +0 -3
- package/dist/node/lib/markdown/plugins/table.d.ts.map +0 -1
- package/dist/node/plugin/vite/search.d.ts.map +0 -1
- package/dist/shared/types/markdown.d.ts +0 -62
- package/dist/shared/types/markdown.d.ts.map +0 -1
- package/dist/vite-B-ktlRz9.js +0 -309
- /package/dist/node/lib/{markdown/plugins → render}/highlight/index.d.ts +0 -0
- /package/dist/node/lib/{markdown/plugins → render}/highlight/language.d.ts +0 -0
|
@@ -0,0 +1,821 @@
|
|
|
1
|
+
import { q as e } from "./shared-B-n46X4N.js";
|
|
2
|
+
import { r as t } from "./vite-vMuZ0f3f.js";
|
|
3
|
+
import { a as n, i as r, n as i, r as a, t as o } from "./brand-CG1fQshq.js";
|
|
4
|
+
import s from "node:path";
|
|
5
|
+
import c from "node:fs/promises";
|
|
6
|
+
import "node:fs";
|
|
7
|
+
import { styleText as l } from "node:util";
|
|
8
|
+
import u, { stdin as d, stdout as f } from "node:process";
|
|
9
|
+
import p from "node:readline";
|
|
10
|
+
import "node:tty";
|
|
11
|
+
//#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
|
|
12
|
+
var m = (() => {
|
|
13
|
+
let e = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
14
|
+
return (t) => {
|
|
15
|
+
let n = 0;
|
|
16
|
+
for (e.lastIndex = 0; e.test(t);) n += 1;
|
|
17
|
+
return t.length - n;
|
|
18
|
+
};
|
|
19
|
+
})(), h = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510, ee = (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, g = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y, _ = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y, v = /(?:(?![\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, y = /[\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, ie = {
|
|
20
|
+
limit: Infinity,
|
|
21
|
+
ellipsis: ""
|
|
22
|
+
}, b = (e, t = {}, n = {}) => {
|
|
23
|
+
let r = t.limit ?? Infinity, i = t.ellipsis ?? "", a = t?.ellipsisWidth ?? (i ? b(i, ie, n).width : 0), o = n.controlWidth ?? 0, s = n.tabWidth ?? 8, c = n.emojiWidth ?? 2, l = n.regularWidth ?? 1, u = n.wideWidth ?? 2, d = [
|
|
24
|
+
[ne, l],
|
|
25
|
+
[g, 0],
|
|
26
|
+
[_, o],
|
|
27
|
+
[te, s],
|
|
28
|
+
[y, c],
|
|
29
|
+
[v, u]
|
|
30
|
+
], f = 0, p = 0, x = e.length, S = 0, C = !1, w = x, T = Math.max(0, r - a), E = 0, D = 0, O = 0, k = 0;
|
|
31
|
+
outer: for (;;) {
|
|
32
|
+
if (D > E || p >= x && p > f) {
|
|
33
|
+
let t = e.slice(E, D) || e.slice(f, p);
|
|
34
|
+
S = 0;
|
|
35
|
+
for (let e of t.replaceAll(re, "")) {
|
|
36
|
+
let t = e.codePointAt(0) || 0;
|
|
37
|
+
if (k = h(t) ? 2 : ee(t) ? u : l, O + k > T && (w = Math.min(w, Math.max(E, f) + S)), O + k > r) {
|
|
38
|
+
C = !0;
|
|
39
|
+
break outer;
|
|
40
|
+
}
|
|
41
|
+
S += e.length, O += k;
|
|
42
|
+
}
|
|
43
|
+
E = D = 0;
|
|
44
|
+
}
|
|
45
|
+
if (p >= x) break outer;
|
|
46
|
+
for (let t = 0, n = d.length; t < n; t++) {
|
|
47
|
+
let [n, i] = d[t];
|
|
48
|
+
if (n.lastIndex = p, n.test(e)) {
|
|
49
|
+
if (S = n === v ? m(e.slice(p, n.lastIndex)) : n === y ? 1 : n.lastIndex - p, k = S * i, O + k > T && (w = Math.min(w, p + Math.floor((T - O) / i))), O + k > r) {
|
|
50
|
+
C = !0;
|
|
51
|
+
break outer;
|
|
52
|
+
}
|
|
53
|
+
O += k, E = f, D = p, p = f = n.lastIndex;
|
|
54
|
+
continue outer;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
p += 1;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
width: C ? T : O,
|
|
61
|
+
index: C ? w : x,
|
|
62
|
+
truncated: C,
|
|
63
|
+
ellipsed: C && r >= a
|
|
64
|
+
};
|
|
65
|
+
}, x = {
|
|
66
|
+
limit: Infinity,
|
|
67
|
+
ellipsis: "",
|
|
68
|
+
ellipsisWidth: 0
|
|
69
|
+
}, S = (e, t = {}) => b(e, x, t).width, C = "\x1B", w = "", T = 39, E = "\x07", D = "[", O = "]", k = "m", A = `${O}8;;`, j = RegExp(`(?:\\${D}(?<code>\\d+)m|\\${A}(?<uri>.*)${E})`, "y"), M = (e) => {
|
|
70
|
+
if (e >= 30 && e <= 37 || e >= 90 && e <= 97) return 39;
|
|
71
|
+
if (e >= 40 && e <= 47 || e >= 100 && e <= 107) return 49;
|
|
72
|
+
if (e === 1 || e === 2) return 22;
|
|
73
|
+
if (e === 3) return 23;
|
|
74
|
+
if (e === 4) return 24;
|
|
75
|
+
if (e === 7) return 27;
|
|
76
|
+
if (e === 8) return 28;
|
|
77
|
+
if (e === 9) return 29;
|
|
78
|
+
if (e === 0) return 0;
|
|
79
|
+
}, N = (e) => `${C}${D}${e}${k}`, P = (e) => `${C}${A}${e}${E}`, F = (e, t, n) => {
|
|
80
|
+
let r = t[Symbol.iterator](), i = !1, a = !1, o = e.at(-1), s = o === void 0 ? 0 : S(o), c = r.next(), l = r.next(), u = 0;
|
|
81
|
+
for (; !c.done;) {
|
|
82
|
+
let o = c.value, d = S(o);
|
|
83
|
+
s + d <= n ? e[e.length - 1] += o : (e.push(o), s = 0), (o === C || o === w) && (i = !0, a = t.startsWith(A, u + 1)), i ? a ? o === E && (i = !1, a = !1) : o === k && (i = !1) : (s += d, s === n && !l.done && (e.push(""), s = 0)), c = l, l = r.next(), u += o.length;
|
|
84
|
+
}
|
|
85
|
+
o = e.at(-1), !s && o !== void 0 && o.length && e.length > 1 && (e[e.length - 2] += e.pop());
|
|
86
|
+
}, ae = (e) => {
|
|
87
|
+
let t = e.split(" "), n = t.length;
|
|
88
|
+
for (; n && !S(t[n - 1]);) n--;
|
|
89
|
+
return n === t.length ? e : t.slice(0, n).join(" ") + t.slice(n).join("");
|
|
90
|
+
}, oe = (e, t, n = {}) => {
|
|
91
|
+
if (n.trim !== !1 && e.trim() === "") return "";
|
|
92
|
+
let r = "", i, a, o = e.split(" "), s = [""], c = 0;
|
|
93
|
+
for (let e = 0; e < o.length; e++) {
|
|
94
|
+
let r = o[e];
|
|
95
|
+
if (n.trim !== !1) {
|
|
96
|
+
let e = s.at(-1) ?? "", t = e.trimStart();
|
|
97
|
+
e.length !== t.length && (s[s.length - 1] = t, c = S(t));
|
|
98
|
+
}
|
|
99
|
+
e !== 0 && (c >= t && (n.wordWrap === !1 || n.trim === !1) && (s.push(""), c = 0), (c || n.trim === !1) && (s[s.length - 1] += " ", c++));
|
|
100
|
+
let i = S(r);
|
|
101
|
+
if (n.hard && i > t) {
|
|
102
|
+
let e = t - c, n = 1 + Math.floor((i - e - 1) / t);
|
|
103
|
+
Math.floor((i - 1) / t) < n && s.push(""), F(s, r, t), c = S(s.at(-1) ?? "");
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (c + i > t && c && i) {
|
|
107
|
+
if (n.wordWrap === !1 && c < t) {
|
|
108
|
+
F(s, r, t), c = S(s.at(-1) ?? "");
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
s.push(""), c = 0;
|
|
112
|
+
}
|
|
113
|
+
if (c + i > t && n.wordWrap === !1) {
|
|
114
|
+
F(s, r, t), c = S(s.at(-1) ?? "");
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
s[s.length - 1] += r, c += i;
|
|
118
|
+
}
|
|
119
|
+
n.trim !== !1 && (s = s.map((e) => ae(e)));
|
|
120
|
+
let l = s.join("\n"), u = !1;
|
|
121
|
+
for (let e = 0; e < l.length; e++) {
|
|
122
|
+
let t = l[e];
|
|
123
|
+
if (r += t, u) u = !1;
|
|
124
|
+
else if (u = t >= "\ud800" && t <= "\udbff", u) continue;
|
|
125
|
+
if (t === C || t === w) {
|
|
126
|
+
j.lastIndex = e + 1;
|
|
127
|
+
let t = j.exec(l)?.groups;
|
|
128
|
+
if (t?.code !== void 0) {
|
|
129
|
+
let e = Number.parseFloat(t.code);
|
|
130
|
+
i = e === T ? void 0 : e;
|
|
131
|
+
} else t?.uri !== void 0 && (a = t.uri.length === 0 ? void 0 : t.uri);
|
|
132
|
+
}
|
|
133
|
+
if (l[e + 1] === "\n") {
|
|
134
|
+
a && (r += P(""));
|
|
135
|
+
let e = i ? M(i) : void 0;
|
|
136
|
+
i && e && (r += N(e));
|
|
137
|
+
} else t === "\n" && (i && M(i) && (r += N(i)), a && (r += P(a)));
|
|
138
|
+
}
|
|
139
|
+
return r;
|
|
140
|
+
}, se = /\r?\n/;
|
|
141
|
+
function I(e, t, n) {
|
|
142
|
+
return String(e).normalize().split(se).map((e) => oe(e, t, n)).join("\n");
|
|
143
|
+
}
|
|
144
|
+
//#endregion
|
|
145
|
+
//#region ../../node_modules/.pnpm/@clack+core@1.4.3/node_modules/@clack/core/dist/index.mjs
|
|
146
|
+
var L = (/* @__PURE__ */ e(((e, t) => {
|
|
147
|
+
var n = "\x1B", r = `${n}[`, i = "\x07", a = {
|
|
148
|
+
to(e, t) {
|
|
149
|
+
return t ? `${r}${t + 1};${e + 1}H` : `${r}${e + 1}G`;
|
|
150
|
+
},
|
|
151
|
+
move(e, t) {
|
|
152
|
+
let n = "";
|
|
153
|
+
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;
|
|
154
|
+
},
|
|
155
|
+
up: (e = 1) => `${r}${e}A`,
|
|
156
|
+
down: (e = 1) => `${r}${e}B`,
|
|
157
|
+
forward: (e = 1) => `${r}${e}C`,
|
|
158
|
+
backward: (e = 1) => `${r}${e}D`,
|
|
159
|
+
nextLine: (e = 1) => `${r}E`.repeat(e),
|
|
160
|
+
prevLine: (e = 1) => `${r}F`.repeat(e),
|
|
161
|
+
left: `${r}G`,
|
|
162
|
+
hide: `${r}?25l`,
|
|
163
|
+
show: `${r}?25h`,
|
|
164
|
+
save: `${n}7`,
|
|
165
|
+
restore: `${n}8`
|
|
166
|
+
};
|
|
167
|
+
t.exports = {
|
|
168
|
+
cursor: a,
|
|
169
|
+
scroll: {
|
|
170
|
+
up: (e = 1) => `${r}S`.repeat(e),
|
|
171
|
+
down: (e = 1) => `${r}T`.repeat(e)
|
|
172
|
+
},
|
|
173
|
+
erase: {
|
|
174
|
+
screen: `${r}2J`,
|
|
175
|
+
up: (e = 1) => `${r}1J`.repeat(e),
|
|
176
|
+
down: (e = 1) => `${r}J`.repeat(e),
|
|
177
|
+
line: `${r}2K`,
|
|
178
|
+
lineEnd: `${r}K`,
|
|
179
|
+
lineStart: `${r}1K`,
|
|
180
|
+
lines(e) {
|
|
181
|
+
let t = "";
|
|
182
|
+
for (let n = 0; n < e; n++) t += this.line + (n < e - 1 ? a.up() : "");
|
|
183
|
+
return e && (t += a.left), t;
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
beep: i
|
|
187
|
+
};
|
|
188
|
+
})))();
|
|
189
|
+
function R(e, t, n) {
|
|
190
|
+
if (!n.some((e) => !e.disabled)) return e;
|
|
191
|
+
let r = e + t, i = Math.max(n.length - 1, 0), a = r < 0 ? i : r > i ? 0 : r;
|
|
192
|
+
return n[a]?.disabled ? R(a, t < 0 ? -1 : 1, n) : a;
|
|
193
|
+
}
|
|
194
|
+
var z = {
|
|
195
|
+
actions: /* @__PURE__ */ new Set([
|
|
196
|
+
"up",
|
|
197
|
+
"down",
|
|
198
|
+
"left",
|
|
199
|
+
"right",
|
|
200
|
+
"space",
|
|
201
|
+
"enter",
|
|
202
|
+
"cancel"
|
|
203
|
+
]),
|
|
204
|
+
aliases: /* @__PURE__ */ new Map([
|
|
205
|
+
["k", "up"],
|
|
206
|
+
["j", "down"],
|
|
207
|
+
["h", "left"],
|
|
208
|
+
["l", "right"],
|
|
209
|
+
["", "cancel"],
|
|
210
|
+
["escape", "cancel"]
|
|
211
|
+
]),
|
|
212
|
+
messages: {
|
|
213
|
+
cancel: "Canceled",
|
|
214
|
+
error: "Something went wrong"
|
|
215
|
+
},
|
|
216
|
+
withGuide: !0,
|
|
217
|
+
date: {
|
|
218
|
+
monthNames: [
|
|
219
|
+
"January",
|
|
220
|
+
"February",
|
|
221
|
+
"March",
|
|
222
|
+
"April",
|
|
223
|
+
"May",
|
|
224
|
+
"June",
|
|
225
|
+
"July",
|
|
226
|
+
"August",
|
|
227
|
+
"September",
|
|
228
|
+
"October",
|
|
229
|
+
"November",
|
|
230
|
+
"December"
|
|
231
|
+
],
|
|
232
|
+
messages: {
|
|
233
|
+
required: "Please enter a valid date",
|
|
234
|
+
invalidMonth: "There are only 12 months in a year",
|
|
235
|
+
invalidDay: (e, t) => `There are only ${e} days in ${t}`,
|
|
236
|
+
afterMin: (e) => `Date must be on or after ${e.toISOString().slice(0, 10)}`,
|
|
237
|
+
beforeMax: (e) => `Date must be on or before ${e.toISOString().slice(0, 10)}`
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
function ce(e, t) {
|
|
242
|
+
if (typeof e == "string") return z.aliases.get(e) === t;
|
|
243
|
+
for (let n of e) if (n !== void 0 && ce(n, t)) return !0;
|
|
244
|
+
return !1;
|
|
245
|
+
}
|
|
246
|
+
function le(e, t) {
|
|
247
|
+
if (e === t) return;
|
|
248
|
+
let n = e.split("\n"), r = t.split("\n"), i = Math.max(n.length, r.length), a = [];
|
|
249
|
+
for (let e = 0; e < i; e++) n[e] !== r[e] && a.push(e);
|
|
250
|
+
return {
|
|
251
|
+
lines: a,
|
|
252
|
+
numLinesBefore: n.length,
|
|
253
|
+
numLinesAfter: r.length,
|
|
254
|
+
numLines: i
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
globalThis.process.platform.startsWith("win");
|
|
258
|
+
var B = Symbol("clack:cancel");
|
|
259
|
+
function ue(e) {
|
|
260
|
+
return e === B;
|
|
261
|
+
}
|
|
262
|
+
function V(e, t) {
|
|
263
|
+
let n = e;
|
|
264
|
+
n.isTTY && n.setRawMode(t);
|
|
265
|
+
}
|
|
266
|
+
var de = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, H = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
|
|
267
|
+
function U(e, t, n, r = n, i = n, a) {
|
|
268
|
+
return I(t, de(e ?? f) - n.length, {
|
|
269
|
+
hard: !0,
|
|
270
|
+
trim: !1
|
|
271
|
+
}).split("\n").map((e, t, o) => {
|
|
272
|
+
let s = a ? a(e, t) : e;
|
|
273
|
+
return t === 0 ? `${r}${s}` : t === o.length - 1 ? `${i}${s}` : `${n}${s}`;
|
|
274
|
+
}).join("\n");
|
|
275
|
+
}
|
|
276
|
+
function fe(e, t) {
|
|
277
|
+
if ("~standard" in e) {
|
|
278
|
+
let n = e["~standard"].validate(t);
|
|
279
|
+
if (n instanceof Promise) throw TypeError("Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic.");
|
|
280
|
+
return n.issues?.at(0)?.message;
|
|
281
|
+
}
|
|
282
|
+
return e(t);
|
|
283
|
+
}
|
|
284
|
+
var W = class {
|
|
285
|
+
input;
|
|
286
|
+
output;
|
|
287
|
+
_abortSignal;
|
|
288
|
+
rl;
|
|
289
|
+
opts;
|
|
290
|
+
_render;
|
|
291
|
+
_track = !1;
|
|
292
|
+
_prevFrame = "";
|
|
293
|
+
_subscribers = /* @__PURE__ */ new Map();
|
|
294
|
+
_cursor = 0;
|
|
295
|
+
state = "initial";
|
|
296
|
+
error = "";
|
|
297
|
+
value;
|
|
298
|
+
userInput = "";
|
|
299
|
+
constructor(e, t = !0) {
|
|
300
|
+
let { input: n = d, output: r = f, render: i, signal: a, ...o } = e;
|
|
301
|
+
this.opts = o, 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;
|
|
302
|
+
}
|
|
303
|
+
unsubscribe() {
|
|
304
|
+
this._subscribers.clear();
|
|
305
|
+
}
|
|
306
|
+
setSubscriber(e, t) {
|
|
307
|
+
let n = this._subscribers.get(e) ?? [];
|
|
308
|
+
n.push(t), this._subscribers.set(e, n);
|
|
309
|
+
}
|
|
310
|
+
on(e, t) {
|
|
311
|
+
this.setSubscriber(e, { cb: t });
|
|
312
|
+
}
|
|
313
|
+
once(e, t) {
|
|
314
|
+
this.setSubscriber(e, {
|
|
315
|
+
cb: t,
|
|
316
|
+
once: !0
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
emit(e, ...t) {
|
|
320
|
+
let n = this._subscribers.get(e) ?? [], r = [];
|
|
321
|
+
for (let e of n) e.cb(...t), e.once && r.push(() => n.splice(n.indexOf(e), 1));
|
|
322
|
+
for (let e of r) e();
|
|
323
|
+
}
|
|
324
|
+
prompt() {
|
|
325
|
+
return new Promise((e) => {
|
|
326
|
+
if (this._abortSignal) {
|
|
327
|
+
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), e(B);
|
|
328
|
+
this._abortSignal.addEventListener("abort", () => {
|
|
329
|
+
this.state = "cancel", this.close();
|
|
330
|
+
}, { once: !0 });
|
|
331
|
+
}
|
|
332
|
+
this.rl = p.createInterface({
|
|
333
|
+
input: this.input,
|
|
334
|
+
tabSize: 2,
|
|
335
|
+
prompt: "",
|
|
336
|
+
escapeCodeTimeout: 50,
|
|
337
|
+
terminal: !0
|
|
338
|
+
}), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), V(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
|
|
339
|
+
this.output.write(L.cursor.show), this.output.off("resize", this.render), V(this.input, !1), e(this.value);
|
|
340
|
+
}), this.once("cancel", () => {
|
|
341
|
+
this.output.write(L.cursor.show), this.output.off("resize", this.render), V(this.input, !1), e(B);
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
_isActionKey(e, t) {
|
|
346
|
+
return e === " ";
|
|
347
|
+
}
|
|
348
|
+
_shouldSubmit(e, t) {
|
|
349
|
+
return !0;
|
|
350
|
+
}
|
|
351
|
+
_setValue(e) {
|
|
352
|
+
this.value = e, this.emit("value", this.value);
|
|
353
|
+
}
|
|
354
|
+
_setUserInput(e, t) {
|
|
355
|
+
this.userInput = e ?? "", this.emit("userInput", this.userInput), t && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
356
|
+
}
|
|
357
|
+
_clearUserInput() {
|
|
358
|
+
this.rl?.write(null, {
|
|
359
|
+
ctrl: !0,
|
|
360
|
+
name: "u"
|
|
361
|
+
}), this._setUserInput("");
|
|
362
|
+
}
|
|
363
|
+
onKeypress(e, t) {
|
|
364
|
+
if (this._track && t.name !== "return" && (t.name && this._isActionKey(e, t) && this.rl?.write(null, {
|
|
365
|
+
ctrl: !0,
|
|
366
|
+
name: "h"
|
|
367
|
+
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), t?.name && (!this._track && z.aliases.has(t.name) && this.emit("cursor", z.aliases.get(t.name)), z.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)) {
|
|
368
|
+
if (this.opts.validate) {
|
|
369
|
+
let e = fe(this.opts.validate, this.value);
|
|
370
|
+
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
|
|
371
|
+
}
|
|
372
|
+
this.state !== "error" && (this.state = "submit");
|
|
373
|
+
}
|
|
374
|
+
ce([
|
|
375
|
+
e,
|
|
376
|
+
t?.name,
|
|
377
|
+
t?.sequence
|
|
378
|
+
], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
|
|
379
|
+
}
|
|
380
|
+
close() {
|
|
381
|
+
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write("\n"), V(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
382
|
+
}
|
|
383
|
+
restoreCursor() {
|
|
384
|
+
let e = I(this._prevFrame, process.stdout.columns, {
|
|
385
|
+
hard: !0,
|
|
386
|
+
trim: !1
|
|
387
|
+
}).split("\n").length - 1;
|
|
388
|
+
this.output.write(L.cursor.move(-999, e * -1));
|
|
389
|
+
}
|
|
390
|
+
render() {
|
|
391
|
+
let e = I(this._render(this) ?? "", process.stdout.columns, {
|
|
392
|
+
hard: !0,
|
|
393
|
+
trim: !1
|
|
394
|
+
});
|
|
395
|
+
if (e !== this._prevFrame) {
|
|
396
|
+
if (this.state === "initial") this.output.write(L.cursor.hide);
|
|
397
|
+
else {
|
|
398
|
+
let t = le(this._prevFrame, e), n = H(this.output);
|
|
399
|
+
if (this.restoreCursor(), t) {
|
|
400
|
+
let r = Math.max(0, t.numLinesAfter - n), i = Math.max(0, t.numLinesBefore - n), a = t.lines.find((e) => e >= r);
|
|
401
|
+
if (a === void 0) {
|
|
402
|
+
this._prevFrame = e;
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (t.lines.length === 1) {
|
|
406
|
+
this.output.write(L.cursor.move(0, a - i)), this.output.write(L.erase.lines(1));
|
|
407
|
+
let t = e.split("\n");
|
|
408
|
+
this.output.write(t[a]), this._prevFrame = e, this.output.write(L.cursor.move(0, t.length - a - 1));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (t.lines.length > 1) {
|
|
412
|
+
if (r < i) a = r;
|
|
413
|
+
else {
|
|
414
|
+
let e = a - i;
|
|
415
|
+
e > 0 && this.output.write(L.cursor.move(0, e));
|
|
416
|
+
}
|
|
417
|
+
this.output.write(L.erase.down());
|
|
418
|
+
let t = e.split("\n").slice(a);
|
|
419
|
+
this.output.write(t.join("\n")), this._prevFrame = e;
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
this.output.write(L.erase.down());
|
|
424
|
+
}
|
|
425
|
+
this.output.write(e), this.state === "initial" && (this.state = "active"), this._prevFrame = e;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}, pe = class extends W {
|
|
429
|
+
options;
|
|
430
|
+
cursor = 0;
|
|
431
|
+
get _selectedValue() {
|
|
432
|
+
return this.options[this.cursor];
|
|
433
|
+
}
|
|
434
|
+
changeValue() {
|
|
435
|
+
let e = this._selectedValue;
|
|
436
|
+
this.value = e === void 0 ? void 0 : e.value;
|
|
437
|
+
}
|
|
438
|
+
constructor(e) {
|
|
439
|
+
super(e, !1), this.options = e.options;
|
|
440
|
+
let t = this.options.findIndex(({ value: t }) => t === e.initialValue), n = t === -1 ? 0 : t;
|
|
441
|
+
this.cursor = this.options[n]?.disabled ? R(n, 1, this.options) : n, this.changeValue(), this.on("cursor", (e) => {
|
|
442
|
+
switch (e) {
|
|
443
|
+
case "left":
|
|
444
|
+
case "up":
|
|
445
|
+
this.cursor = R(this.cursor, -1, this.options);
|
|
446
|
+
break;
|
|
447
|
+
case "down":
|
|
448
|
+
case "right": this.cursor = R(this.cursor, 1, this.options);
|
|
449
|
+
}
|
|
450
|
+
this.changeValue();
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}, me = class extends W {
|
|
454
|
+
get userInputWithCursor() {
|
|
455
|
+
if (this.state === "submit") return this.userInput;
|
|
456
|
+
let e = this.userInput;
|
|
457
|
+
if (this.cursor >= e.length) return `${this.userInput}\u2588`;
|
|
458
|
+
let t = e.slice(0, this.cursor), n = e.slice(this.cursor, this.cursor + 1), r = e.slice(this.cursor + 1);
|
|
459
|
+
return `${t}${l("inverse", n)}${r}`;
|
|
460
|
+
}
|
|
461
|
+
get cursor() {
|
|
462
|
+
return this._cursor;
|
|
463
|
+
}
|
|
464
|
+
constructor(e) {
|
|
465
|
+
super({
|
|
466
|
+
...e,
|
|
467
|
+
initialUserInput: e.initialUserInput ?? e.initialValue
|
|
468
|
+
}), this.on("userInput", (e) => {
|
|
469
|
+
this._setValue(e);
|
|
470
|
+
}), this.on("finalize", () => {
|
|
471
|
+
this.value ||= e.defaultValue, this.value === void 0 && (this.value = "");
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region ../../node_modules/.pnpm/@clack+prompts@1.7.0/node_modules/@clack/prompts/dist/index.mjs
|
|
477
|
+
function he() {
|
|
478
|
+
return u.platform === "win32" ? !!u.env.CI || !!u.env.WT_SESSION || !!u.env.TERMINUS_SUBLIME || u.env.ConEmuTask === "{cmd::Cmder}" || u.env.TERM_PROGRAM === "Terminus-Sublime" || u.env.TERM_PROGRAM === "vscode" || u.env.TERM === "xterm-256color" || u.env.TERM === "alacritty" || u.env.TERMINAL_EMULATOR === "JetBrains-JediTerm" : u.env.TERM !== "linux";
|
|
479
|
+
}
|
|
480
|
+
var ge = he(), G = (e, t) => ge ? e : t, _e = G("◆", "*"), ve = G("■", "x"), ye = G("▲", "x"), K = G("◇", "o"), be = G("┌", "T"), q = G("│", "|"), J = G("└", "—"), xe = G("●", ">"), Y = G("○", " "), Se = G("●", "•"), Ce = G("◆", "*"), we = G("▲", "!"), Te = G("■", "x"), Ee = (e) => {
|
|
481
|
+
switch (e) {
|
|
482
|
+
case "initial":
|
|
483
|
+
case "active": return l("cyan", _e);
|
|
484
|
+
case "cancel": return l("red", ve);
|
|
485
|
+
case "error": return l("yellow", ye);
|
|
486
|
+
case "submit": return l("green", K);
|
|
487
|
+
}
|
|
488
|
+
}, De = (e) => {
|
|
489
|
+
switch (e) {
|
|
490
|
+
case "initial":
|
|
491
|
+
case "active": return l("cyan", q);
|
|
492
|
+
case "cancel": return l("red", q);
|
|
493
|
+
case "error": return l("yellow", q);
|
|
494
|
+
case "submit": return l("green", q);
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
function Oe(e, t) {
|
|
498
|
+
let n = [`${t ? `${l("cyan", q)} ` : ""}${e.join(" • ")}`];
|
|
499
|
+
return t && n.push(l("cyan", J)), n;
|
|
500
|
+
}
|
|
501
|
+
var ke = (e, t, n, r, i, a = !1) => {
|
|
502
|
+
let o = t, s = 0;
|
|
503
|
+
if (a) for (let t = r - 1; t >= n; t--) {
|
|
504
|
+
let n = e[t];
|
|
505
|
+
if (n && (o -= n.length), s++, o <= i) break;
|
|
506
|
+
}
|
|
507
|
+
else for (let t = n; t < r; t++) {
|
|
508
|
+
let n = e[t];
|
|
509
|
+
if (n && (o -= n.length), s++, o <= i) break;
|
|
510
|
+
}
|
|
511
|
+
return {
|
|
512
|
+
lineCount: o,
|
|
513
|
+
removals: s
|
|
514
|
+
};
|
|
515
|
+
}, Ae = ({ cursor: e, options: t, style: n, output: r = process.stdout, maxItems: i = Infinity, columnPadding: a = 0, rowPadding: o = 4 }) => {
|
|
516
|
+
let s = de(r) - a, c = H(r), u = l("dim", "..."), d = Math.max(c - o, 0), f = Math.max(Math.min(i, d), 5), p = 0;
|
|
517
|
+
e >= f - 3 && (p = Math.max(Math.min(e - f + 3, t.length - f), 0));
|
|
518
|
+
let m = f < t.length && p > 0, h = f < t.length && p + f < t.length, ee = Math.min(p + f, t.length), g = [], _ = 0;
|
|
519
|
+
m && _++, h && _++;
|
|
520
|
+
let v = p + +!!m, te = ee - +!!h;
|
|
521
|
+
for (let r = v; r < te; r++) {
|
|
522
|
+
let i = t[r], a = I(i ? n(i, r === e) : "", s, {
|
|
523
|
+
hard: !0,
|
|
524
|
+
trim: !1
|
|
525
|
+
}).split("\n");
|
|
526
|
+
g.push(a), _ += a.length;
|
|
527
|
+
}
|
|
528
|
+
if (_ > d) {
|
|
529
|
+
let t = 0, n = 0, r = _, i = e - v, a = d, o = () => ke(g, r, 0, i, a), s = () => ke(g, r, i + 1, g.length, a, !0);
|
|
530
|
+
m ? ({lineCount: r, removals: t} = o(), r > a && (h || --a, {lineCount: r, removals: n} = s())) : (h || --a, {lineCount: r, removals: n} = s(), r > a && (--a, {lineCount: r, removals: t} = o())), t > 0 && (m = !0, g.splice(0, t)), n > 0 && (h = !0, g.splice(g.length - n, n));
|
|
531
|
+
}
|
|
532
|
+
let y = [];
|
|
533
|
+
m && y.push(u);
|
|
534
|
+
for (let e of g) for (let t of e) y.push(t);
|
|
535
|
+
return h && y.push(u), y;
|
|
536
|
+
};
|
|
537
|
+
`${l("dim", "↑/↓")}`, `${l("dim", "Space:")}`, `${l("dim", "Enter:")}`;
|
|
538
|
+
var X = {
|
|
539
|
+
message: (e = [], { symbol: t = l("gray", q), secondarySymbol: n = l("gray", q), output: r = process.stdout, spacing: i = 1, withGuide: a } = {}) => {
|
|
540
|
+
let o = [], s = a ?? z.withGuide, c = s ? n : "", u = s ? `${t} ` : "", d = s ? `${n} ` : "";
|
|
541
|
+
for (let e = 0; e < i; e++) o.push(c);
|
|
542
|
+
let f = Array.isArray(e) ? e : e.split("\n");
|
|
543
|
+
if (f.length > 0) {
|
|
544
|
+
let [e, ...r] = f;
|
|
545
|
+
e.length > 0 ? o.push(`${u}${e}`) : o.push(s ? t : "");
|
|
546
|
+
for (let e of r) e.length > 0 ? o.push(`${d}${e}`) : o.push(s ? n : "");
|
|
547
|
+
}
|
|
548
|
+
r.write(`${o.join("\n")}
|
|
549
|
+
`);
|
|
550
|
+
},
|
|
551
|
+
info: (e, t) => {
|
|
552
|
+
X.message(e, {
|
|
553
|
+
...t,
|
|
554
|
+
symbol: l("blue", Se)
|
|
555
|
+
});
|
|
556
|
+
},
|
|
557
|
+
success: (e, t) => {
|
|
558
|
+
X.message(e, {
|
|
559
|
+
...t,
|
|
560
|
+
symbol: l("green", Ce)
|
|
561
|
+
});
|
|
562
|
+
},
|
|
563
|
+
step: (e, t) => {
|
|
564
|
+
X.message(e, {
|
|
565
|
+
...t,
|
|
566
|
+
symbol: l("green", K)
|
|
567
|
+
});
|
|
568
|
+
},
|
|
569
|
+
warn: (e, t) => {
|
|
570
|
+
X.message(e, {
|
|
571
|
+
...t,
|
|
572
|
+
symbol: l("yellow", we)
|
|
573
|
+
});
|
|
574
|
+
},
|
|
575
|
+
warning: (e, t) => {
|
|
576
|
+
X.warn(e, t);
|
|
577
|
+
},
|
|
578
|
+
error: (e, t) => {
|
|
579
|
+
X.message(e, {
|
|
580
|
+
...t,
|
|
581
|
+
symbol: l("red", Te)
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}, je = (e = "", t) => {
|
|
585
|
+
let n = t?.output ?? process.stdout, r = t?.withGuide ?? z.withGuide ? `${l("gray", J)} ` : "";
|
|
586
|
+
n.write(`${r}${l("red", e)}
|
|
587
|
+
|
|
588
|
+
`);
|
|
589
|
+
}, Me = (e = "", t) => {
|
|
590
|
+
let n = t?.output ?? process.stdout, r = t?.withGuide ?? z.withGuide ? `${l("gray", be)} ` : "";
|
|
591
|
+
n.write(`${r}${e}
|
|
592
|
+
`);
|
|
593
|
+
}, Ne = (e = "", t) => {
|
|
594
|
+
let n = t?.output ?? process.stdout, r = t?.withGuide ?? z.withGuide ? `${l("gray", q)}
|
|
595
|
+
${l("gray", J)} ` : "";
|
|
596
|
+
n.write(`${r}${e}
|
|
597
|
+
|
|
598
|
+
`);
|
|
599
|
+
}, Pe = [`${l("dim", "↑/↓")} to navigate`, `${l("dim", "Enter:")} confirm`], Z = (e, t) => e.includes("\n") ? e.split("\n").map((e) => t(e)).join("\n") : t(e), Fe = (e) => {
|
|
600
|
+
let t = (e, t) => {
|
|
601
|
+
if (e === void 0) return "";
|
|
602
|
+
let n = e.label ?? String(e.value);
|
|
603
|
+
switch (t) {
|
|
604
|
+
case "disabled": return `${l("gray", Y)} ${Z(n, (e) => l("gray", e))}${e.hint ? ` ${l("dim", `(${e.hint ?? "disabled"})`)}` : ""}`;
|
|
605
|
+
case "selected": return `${Z(n, (e) => l("dim", e))}`;
|
|
606
|
+
case "active": return `${l("green", xe)} ${n}${e.hint ? ` ${l("dim", `(${e.hint})`)}` : ""}`;
|
|
607
|
+
case "cancelled": return `${Z(n, (e) => l(["strikethrough", "dim"], e))}`;
|
|
608
|
+
default: return `${l("dim", Y)} ${Z(n, (e) => l("dim", e))}`;
|
|
609
|
+
}
|
|
610
|
+
}, n = e.showInstructions ?? !0;
|
|
611
|
+
return new pe({
|
|
612
|
+
options: e.options,
|
|
613
|
+
signal: e.signal,
|
|
614
|
+
input: e.input,
|
|
615
|
+
output: e.output,
|
|
616
|
+
initialValue: e.initialValue,
|
|
617
|
+
render() {
|
|
618
|
+
let r = e.withGuide ?? z.withGuide, i = `${Ee(this.state)} `, a = `${De(this.state)} `, o = U(e.output, e.message, a, i), s = `${r ? `${l("gray", q)}
|
|
619
|
+
` : ""}${o}
|
|
620
|
+
`;
|
|
621
|
+
switch (this.state) {
|
|
622
|
+
case "submit": {
|
|
623
|
+
let n = r ? `${l("gray", q)} ` : "";
|
|
624
|
+
return `${s}${U(e.output, t(this.options[this.cursor], "selected"), n)}`;
|
|
625
|
+
}
|
|
626
|
+
case "cancel": {
|
|
627
|
+
let n = r ? `${l("gray", q)} ` : "";
|
|
628
|
+
return `${s}${U(e.output, t(this.options[this.cursor], "cancelled"), n)}${r ? `
|
|
629
|
+
${l("gray", q)}` : ""}`;
|
|
630
|
+
}
|
|
631
|
+
default: {
|
|
632
|
+
let i = r ? `${l("cyan", q)} ` : "", a = s.split("\n").length, o = n ? Oe(Pe, r) : r ? [l("cyan", J)] : [], c = o.join("\n"), u = o.length + 1;
|
|
633
|
+
return `${s}${i}${Ae({
|
|
634
|
+
output: e.output,
|
|
635
|
+
cursor: this.cursor,
|
|
636
|
+
options: this.options,
|
|
637
|
+
maxItems: e.maxItems,
|
|
638
|
+
columnPadding: i.length,
|
|
639
|
+
rowPadding: a + u,
|
|
640
|
+
style: (e, n) => t(e, e.disabled ? "disabled" : n ? "active" : "inactive")
|
|
641
|
+
}).join(`
|
|
642
|
+
${i}`)}
|
|
643
|
+
${c}
|
|
644
|
+
`;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}).prompt();
|
|
649
|
+
};
|
|
650
|
+
`${l("gray", q)}`;
|
|
651
|
+
var Ie = (e) => new me({
|
|
652
|
+
validate: e.validate,
|
|
653
|
+
placeholder: e.placeholder,
|
|
654
|
+
defaultValue: e.defaultValue,
|
|
655
|
+
initialValue: e.initialValue,
|
|
656
|
+
output: e.output,
|
|
657
|
+
signal: e.signal,
|
|
658
|
+
input: e.input,
|
|
659
|
+
render() {
|
|
660
|
+
let t = e?.withGuide ?? z.withGuide, n = `${`${t ? `${l("gray", q)}
|
|
661
|
+
` : ""}${Ee(this.state)} `}${e.message}
|
|
662
|
+
`, r = e.placeholder && e.placeholder.length > 0 ? l("inverse", e.placeholder[0]) + l("dim", e.placeholder.slice(1)) : l(["inverse", "hidden"], "_"), i = this.userInput ? this.userInputWithCursor : r, a = this.value ?? "";
|
|
663
|
+
switch (this.state) {
|
|
664
|
+
case "error": {
|
|
665
|
+
let e = this.error ? ` ${l("yellow", this.error)}` : "", r = t ? `${l("yellow", q)} ` : "", a = t ? l("yellow", J) : "";
|
|
666
|
+
return `${n.trim()}
|
|
667
|
+
${r}${i}
|
|
668
|
+
${a}${e}
|
|
669
|
+
`;
|
|
670
|
+
}
|
|
671
|
+
case "submit": {
|
|
672
|
+
let e = a ? ` ${l("dim", a)}` : "";
|
|
673
|
+
return `${n}${t ? l("gray", q) : ""}${e}`;
|
|
674
|
+
}
|
|
675
|
+
case "cancel": {
|
|
676
|
+
let e = a ? ` ${l(["strikethrough", "dim"], a)}` : "", r = t ? l("gray", q) : "";
|
|
677
|
+
return `${n}${r}${e}${a.trim() ? `
|
|
678
|
+
${r}` : ""}`;
|
|
679
|
+
}
|
|
680
|
+
default: return `${n}${t ? `${l("cyan", q)} ` : ""}${i}
|
|
681
|
+
${t ? l("cyan", J) : ""}
|
|
682
|
+
`;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}).prompt();
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region src/node/cli/init.ts
|
|
688
|
+
async function Le(e, t = {}) {
|
|
689
|
+
let n = !qe(t);
|
|
690
|
+
await Ye(e, n ? await Re(e, t) : Xe(t)), n && Je(e);
|
|
691
|
+
}
|
|
692
|
+
async function Re(e, t) {
|
|
693
|
+
Me("typedown");
|
|
694
|
+
let n = await Be(e);
|
|
695
|
+
n.hasTypedownYaml && !t.yes && await ze();
|
|
696
|
+
let r = t.name ?? await Q("Project name", n.packageName ?? s.basename(e));
|
|
697
|
+
return {
|
|
698
|
+
projectName: r,
|
|
699
|
+
siteTitle: t.title ?? await Q("Site title", r),
|
|
700
|
+
siteDescription: t.description ?? await Q("Site description", "A typedown site")
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
async function ze() {
|
|
704
|
+
X.warn("typedown.yaml already exists in this directory");
|
|
705
|
+
let e = await Fe({
|
|
706
|
+
message: "What would you like to do?",
|
|
707
|
+
options: [{
|
|
708
|
+
value: "scaffold",
|
|
709
|
+
label: "Continue scaffolding (skip existing files)"
|
|
710
|
+
}, {
|
|
711
|
+
value: "cancel",
|
|
712
|
+
label: "Cancel"
|
|
713
|
+
}]
|
|
714
|
+
});
|
|
715
|
+
(ue(e) || e === "cancel") && (je("Cancelled."), process.exit(0));
|
|
716
|
+
}
|
|
717
|
+
async function Be(e) {
|
|
718
|
+
let n = {
|
|
719
|
+
hasPackageJson: !1,
|
|
720
|
+
hasTypedownYaml: !1,
|
|
721
|
+
packageName: void 0
|
|
722
|
+
};
|
|
723
|
+
try {
|
|
724
|
+
let t = await c.readFile(s.join(e, "package.json"), "utf-8"), r = JSON.parse(t);
|
|
725
|
+
n.hasPackageJson = !0, typeof r.name == "string" && 0 < r.name.length && (n.packageName = r.name);
|
|
726
|
+
} catch {}
|
|
727
|
+
for (let r of t) try {
|
|
728
|
+
await c.access(s.join(e, r)), n.hasTypedownYaml = !0;
|
|
729
|
+
break;
|
|
730
|
+
} catch {}
|
|
731
|
+
return n;
|
|
732
|
+
}
|
|
733
|
+
function Ve() {
|
|
734
|
+
return `<svg fill="none" viewBox="${n}" xmlns="http://www.w3.org/2000/svg">
|
|
735
|
+
<path clip-rule="evenodd" d="${i}" fill-rule="evenodd" fill="${a}"/>
|
|
736
|
+
<path d="${r}" fill="${a}"/>
|
|
737
|
+
<path d="${o}" fill="${a}"/>
|
|
738
|
+
</svg>
|
|
739
|
+
`;
|
|
740
|
+
}
|
|
741
|
+
function He(e) {
|
|
742
|
+
return JSON.stringify({
|
|
743
|
+
name: e.projectName,
|
|
744
|
+
version: "0.0.0",
|
|
745
|
+
private: !0,
|
|
746
|
+
type: "module",
|
|
747
|
+
scripts: {
|
|
748
|
+
dev: "typerighter dev",
|
|
749
|
+
build: "typerighter build",
|
|
750
|
+
preview: "typerighter preview"
|
|
751
|
+
},
|
|
752
|
+
devDependencies: { typerighter: "^0.30.4" }
|
|
753
|
+
}, void 0, 2) + "\n";
|
|
754
|
+
}
|
|
755
|
+
function Ue() {
|
|
756
|
+
return "User-agent: *\nAllow: /\n\nSitemap: /sitemap.xml\n";
|
|
757
|
+
}
|
|
758
|
+
function We() {
|
|
759
|
+
return "---\n_type: Article\ntitle: \"Hello, world\"\n---\n\nWelcome to your new typedown site.\n";
|
|
760
|
+
}
|
|
761
|
+
function Ge() {
|
|
762
|
+
return "---\n_type: schema\nproperties:\n title:\n type: string\n tags:\n type: list[string]\n optional: true\n---\n";
|
|
763
|
+
}
|
|
764
|
+
function Ke(e) {
|
|
765
|
+
return `version: "1.0.0"
|
|
766
|
+
vault:
|
|
767
|
+
root_dir: "vault"
|
|
768
|
+
site:
|
|
769
|
+
title: "${e.siteTitle}"
|
|
770
|
+
description: "${e.siteDescription}"
|
|
771
|
+
`;
|
|
772
|
+
}
|
|
773
|
+
function qe(e) {
|
|
774
|
+
return e.name !== void 0 && e.title !== void 0 && e.description !== void 0;
|
|
775
|
+
}
|
|
776
|
+
function Je(e) {
|
|
777
|
+
let t = ["Done scaffolding."];
|
|
778
|
+
e !== "." && t.push(`cd ${e}`), t.push("pnpm install"), t.push("pnpm dev"), Ne(t.join("\n"));
|
|
779
|
+
}
|
|
780
|
+
async function Q(e, t) {
|
|
781
|
+
let n = await Ie({
|
|
782
|
+
message: e,
|
|
783
|
+
placeholder: t,
|
|
784
|
+
defaultValue: t
|
|
785
|
+
});
|
|
786
|
+
return ue(n) && (je("Cancelled."), process.exit(0)), n;
|
|
787
|
+
}
|
|
788
|
+
async function Ye(e, t) {
|
|
789
|
+
let n = s.join(e, "vault"), r = s.join(e, "vault", "_types"), i = s.join(e, "public"), a = s.join(e, ".typedown", ".local");
|
|
790
|
+
await Promise.all([
|
|
791
|
+
c.mkdir(n, { recursive: !0 }),
|
|
792
|
+
c.mkdir(r, { recursive: !0 }),
|
|
793
|
+
c.mkdir(i, { recursive: !0 }),
|
|
794
|
+
c.mkdir(a, { recursive: !0 })
|
|
795
|
+
]), await $(a, ".gitignore", "*\n", { silent: !0 }), await Promise.all([
|
|
796
|
+
$(e, ".gitignore", "node_modules/\ndist/\n", { silent: !0 }),
|
|
797
|
+
$(e, "package.json", He(t)),
|
|
798
|
+
$(e, "typedown.yaml", Ke(t)),
|
|
799
|
+
$(i, "favicon.svg", Ve(), { silent: !0 }),
|
|
800
|
+
$(i, "robots.txt", Ue(), { silent: !0 })
|
|
801
|
+
]);
|
|
802
|
+
let o = await Promise.all([$(r, "Article.td", Ge(), { silent: !0 }), $(n, "hello.td", We(), { silent: !0 })]), l = o.filter(Boolean), u = o.filter((e) => !e);
|
|
803
|
+
0 < l.length && X.success(`created sample schema and content (${l.length} files)`), 0 < u.length && X.warn(`skipped ${u.length} sample files (already exist)`);
|
|
804
|
+
}
|
|
805
|
+
function Xe(e) {
|
|
806
|
+
return {
|
|
807
|
+
projectName: e.name,
|
|
808
|
+
siteTitle: e.title,
|
|
809
|
+
siteDescription: e.description
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
async function $(e, t, n, r = {}) {
|
|
813
|
+
let i = s.join(e, t);
|
|
814
|
+
try {
|
|
815
|
+
return await c.access(i), r.silent || X.warn(`skip ${t} (already exists)`), !1;
|
|
816
|
+
} catch {
|
|
817
|
+
return await c.writeFile(i, n), r.silent || X.success(`created ${t}`), !0;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
//#endregion
|
|
821
|
+
export { Le as initialize };
|