typerighter 0.30.7 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -2
- package/README.npm.md +26 -0
- package/dist/{cli-D8F6dQfh.js → cli-DzRzaQXc.js} +5 -5
- package/dist/cli.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{init-fMad-EWX.js → init-SqtdxLwF.js} +2 -2
- package/dist/node/lib/typedown-context.d.ts.map +1 -1
- package/dist/node/plugin/vite/index.d.ts.map +1 -1
- package/dist/node/plugin/vite/virtual/app.d.ts.map +1 -1
- package/dist/typerighter.css +1 -1
- package/dist/{vite-CdFJrVOC.js → vite-OiCh59kk.js} +242 -231
- package/dist/vite.js +1 -1
- package/package.json +3 -3
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { F as e, G as t, H as n, I as r, K as i, M as a, P as o, R as s, S as c, T as l, U as u, _ as d, g as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { build as
|
|
9
|
-
import
|
|
10
|
-
import { createHighlighter as
|
|
11
|
-
import
|
|
12
|
-
import { RpcServer as
|
|
13
|
-
import { RPC_CANCELLED_CODE as
|
|
14
|
-
import { createRequire as
|
|
1
|
+
import { F as e, G as t, H as n, I as r, K as i, M as a, P as o, R as s, S as c, T as l, U as u, _ as d, f, g as p, h as m, m as h, p as g, s as _, u as v, v as y, w as b } from "./shared-B-n46X4N.js";
|
|
2
|
+
import { t as x } from "./temml-DZbhOfRE.js";
|
|
3
|
+
import { t as S } from "./es-ClqUVRJn.js";
|
|
4
|
+
import C, { resolve as w } from "node:path";
|
|
5
|
+
import T from "picocolors";
|
|
6
|
+
import ee from "@tailwindcss/vite";
|
|
7
|
+
import te from "@vitejs/plugin-vue";
|
|
8
|
+
import { build as ne, createLogger as re, normalizePath as ie } from "vite";
|
|
9
|
+
import E from "node:fs/promises";
|
|
10
|
+
import { createHighlighter as ae, guessEmbeddedLanguages as oe, isSpecialLang as se } from "shiki";
|
|
11
|
+
import D, { createReadStream as ce, existsSync as le, globSync as O, readFileSync as ue, statSync as de } from "node:fs";
|
|
12
|
+
import { RpcServer as fe } from "@typerighter/rpc-server";
|
|
13
|
+
import { RPC_CANCELLED_CODE as pe, RpcClient as me } from "@typerighter/rpc-client";
|
|
14
|
+
import { createRequire as he } from "node:module";
|
|
15
15
|
//#region src/node/lib/html-template.ts
|
|
16
|
-
function
|
|
17
|
-
let t =
|
|
16
|
+
function k(e) {
|
|
17
|
+
let t = _(e.title), n = _(e.description), r = e.siteTitle !== void 0 && e.title !== e.siteTitle ? `${t} - ${_(e.siteTitle)}` : t, i = e.canonicalUrl === void 0 ? "" : `\n <link rel="canonical" href="${_(e.canonicalUrl)}">`, a = e.headExtra === void 0 ? "" : e.headExtra + "\n", o = JSON.stringify({
|
|
18
18
|
"@context": "https://schema.org",
|
|
19
19
|
"@type": "Article",
|
|
20
20
|
headline: e.title,
|
|
@@ -56,7 +56,7 @@ ${a} </head>
|
|
|
56
56
|
async function ge(e) {
|
|
57
57
|
let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await _e(e.clientOutDir), a = e.pagePaths.length, o = 0;
|
|
58
58
|
await Promise.all(e.pagePaths.map(async (s) => {
|
|
59
|
-
let c = await t.render(s), l = r.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), u = i.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n"), d =
|
|
59
|
+
let c = await t.render(s), l = r.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), u = i.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n"), d = k({
|
|
60
60
|
title: c.pageData.title,
|
|
61
61
|
description: c.pageData.frontmatter.description === void 0 ? "" : String(c.pageData.frontmatter.description),
|
|
62
62
|
siteTitle: e.siteTitle,
|
|
@@ -65,12 +65,12 @@ async function ge(e) {
|
|
|
65
65
|
canonicalUrl: e.base + s.replace(/^\//, ""),
|
|
66
66
|
headExtra: [l, u].filter(Boolean).join("\n") || void 0,
|
|
67
67
|
appContent: c.html
|
|
68
|
-
}), f = s === "/" ? "index.html" : `${s.replace(/^\//, "")}.html`, p =
|
|
69
|
-
await
|
|
68
|
+
}), f = s === "/" ? "index.html" : `${s.replace(/^\//, "")}.html`, p = C.join(e.outDir, f);
|
|
69
|
+
await E.mkdir(C.dirname(p), { recursive: !0 }), await E.writeFile(p, d), o++, e.progress?.update(o, a);
|
|
70
70
|
}));
|
|
71
71
|
}
|
|
72
72
|
async function _e(e) {
|
|
73
|
-
let t =
|
|
73
|
+
let t = C.join(e, ".vite", "manifest.json"), n = await E.readFile(t, "utf-8"), r = JSON.parse(n), i = "", a = [], o = [];
|
|
74
74
|
for (let e of Object.values(r)) e.isEntry ? (i = e.file, e.css && a.push(...e.css)) : e.file.endsWith(".js") && o.push(e.file);
|
|
75
75
|
return {
|
|
76
76
|
clientEntry: i,
|
|
@@ -80,12 +80,12 @@ async function _e(e) {
|
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/node/lib/progress.ts
|
|
83
|
-
var
|
|
83
|
+
var A = [
|
|
84
84
|
"◐",
|
|
85
85
|
"◓",
|
|
86
86
|
"◑",
|
|
87
87
|
"◒"
|
|
88
|
-
],
|
|
88
|
+
], j = class {
|
|
89
89
|
logger;
|
|
90
90
|
label;
|
|
91
91
|
start;
|
|
@@ -93,8 +93,8 @@ var k = [
|
|
|
93
93
|
constructor(e, t) {
|
|
94
94
|
if (this.logger = e, this.label = t, this.start = performance.now(), process.stdout.isTTY) {
|
|
95
95
|
let e = 0;
|
|
96
|
-
process.stdout.write(
|
|
97
|
-
e = (e + 1) %
|
|
96
|
+
process.stdout.write(T.cyan(`${A[0]} ${t}`)), this.spinnerInterval = setInterval(() => {
|
|
97
|
+
e = (e + 1) % A.length, process.stdout.write(`\r${T.cyan(`${A[e]} ${this.label}`)}`);
|
|
98
98
|
}, 120).unref();
|
|
99
99
|
} else this.logger.start(t);
|
|
100
100
|
}
|
|
@@ -118,9 +118,9 @@ function ve(e) {
|
|
|
118
118
|
//#endregion
|
|
119
119
|
//#region src/node/build/index.ts
|
|
120
120
|
var ye = "typerighter/client/theme-default";
|
|
121
|
-
async function
|
|
122
|
-
let { root: n, logger: r } = e, i =
|
|
123
|
-
await
|
|
121
|
+
async function M(e, t = {}) {
|
|
122
|
+
let { root: n, logger: r } = e, i = C.resolve(n, t.outDir ?? "dist"), a = C.join(i, ".client"), o = C.join(i, ".server");
|
|
123
|
+
await E.rm(i, {
|
|
124
124
|
recursive: !0,
|
|
125
125
|
force: !0
|
|
126
126
|
});
|
|
@@ -129,10 +129,10 @@ async function j(e, t = {}) {
|
|
|
129
129
|
c.listFiles(),
|
|
130
130
|
c.listSidebar(),
|
|
131
131
|
c.listSchemas()
|
|
132
|
-
]), p = t.base ?? l.basePath ?? "/", m = p.endsWith("/") ? p : p + "/",
|
|
132
|
+
]), p = t.base ?? l.basePath ?? "/", m = p.endsWith("/") ? p : p + "/", h = d.map((e) => ({
|
|
133
133
|
...e,
|
|
134
134
|
header: {}
|
|
135
|
-
})), _ = h
|
|
135
|
+
})), _ = g(h), v = JSON.stringify({
|
|
136
136
|
title: l.siteTitle,
|
|
137
137
|
description: l.siteDescription,
|
|
138
138
|
basePath: m,
|
|
@@ -140,10 +140,10 @@ async function j(e, t = {}) {
|
|
|
140
140
|
}), y = JSON.stringify({
|
|
141
141
|
ready: !0,
|
|
142
142
|
contentTree: _
|
|
143
|
-
}), b =
|
|
144
|
-
await
|
|
145
|
-
let x =
|
|
146
|
-
await Promise.all([
|
|
143
|
+
}), b = C.join(n, "node_modules", ".typerighter");
|
|
144
|
+
await E.mkdir(b, { recursive: !0 });
|
|
145
|
+
let x = C.join(b, "client-entry.js"), S = C.join(b, "ssr-entry.js");
|
|
146
|
+
await Promise.all([E.writeFile(x, Q({
|
|
147
147
|
rootDir: l.rootDir,
|
|
148
148
|
basePath: m,
|
|
149
149
|
siteTitle: l.siteTitle,
|
|
@@ -152,15 +152,15 @@ async function j(e, t = {}) {
|
|
|
152
152
|
author: l.author,
|
|
153
153
|
license: l.license,
|
|
154
154
|
nav: l.nav
|
|
155
|
-
})),
|
|
155
|
+
})), E.writeFile(S, be({
|
|
156
156
|
rootDir: l.rootDir,
|
|
157
157
|
layoutImport: ye,
|
|
158
158
|
siteConfig: v,
|
|
159
159
|
siteData: y
|
|
160
160
|
}))]);
|
|
161
161
|
try {
|
|
162
|
-
let c = $({ context: e }), d = e.createViteLogger(), f = new
|
|
163
|
-
await
|
|
162
|
+
let c = $({ context: e }), d = e.createViteLogger(), f = new j(r, "Building client bundle...");
|
|
163
|
+
await ne({
|
|
164
164
|
...t.viteConfig,
|
|
165
165
|
root: n,
|
|
166
166
|
base: m,
|
|
@@ -178,10 +178,10 @@ async function j(e, t = {}) {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
|
-
let p = await
|
|
181
|
+
let p = await E.readdir(C.join(a, "assets")).catch(() => []);
|
|
182
182
|
f.done(`Client bundle (${p.length} chunks)`);
|
|
183
|
-
let h = new
|
|
184
|
-
await
|
|
183
|
+
let h = new j(r, "Building SSR bundle...");
|
|
184
|
+
await ne({
|
|
185
185
|
...t.viteConfig,
|
|
186
186
|
root: n,
|
|
187
187
|
base: m,
|
|
@@ -191,7 +191,7 @@ async function j(e, t = {}) {
|
|
|
191
191
|
build: {
|
|
192
192
|
...t.viteConfig?.build,
|
|
193
193
|
outDir: o,
|
|
194
|
-
ssr:
|
|
194
|
+
ssr: S,
|
|
195
195
|
emptyOutDir: !0
|
|
196
196
|
}
|
|
197
197
|
}), h.done("SSR bundle");
|
|
@@ -199,10 +199,10 @@ async function j(e, t = {}) {
|
|
|
199
199
|
let t = s(e);
|
|
200
200
|
return t === "index" ? "/" : `/${t}`;
|
|
201
201
|
});
|
|
202
|
-
g.push("/"),
|
|
203
|
-
let v = new
|
|
202
|
+
g.push("/"), N(_.entries, "", g);
|
|
203
|
+
let v = new j(r, "Pre-rendering pages...");
|
|
204
204
|
await ge({
|
|
205
|
-
ssrEntryPath:
|
|
205
|
+
ssrEntryPath: C.join(o, "ssr-entry.js"),
|
|
206
206
|
clientOutDir: a,
|
|
207
207
|
outDir: i,
|
|
208
208
|
base: m,
|
|
@@ -211,22 +211,22 @@ async function j(e, t = {}) {
|
|
|
211
211
|
progress: v
|
|
212
212
|
}), v.done(`Pre-rendered ${g.length} pages`);
|
|
213
213
|
let y = Se(g, m);
|
|
214
|
-
await
|
|
215
|
-
let b =
|
|
216
|
-
await
|
|
217
|
-
let T =
|
|
218
|
-
await
|
|
214
|
+
await E.writeFile(C.join(i, "sitemap.xml"), y);
|
|
215
|
+
let b = C.join(a, "assets"), w = C.join(i, "assets");
|
|
216
|
+
await E.cp(b, w, { recursive: !0 }).catch(() => {}), await xe(C.join(n, l.rootDir), i);
|
|
217
|
+
let T = C.join(n, l.publicDir);
|
|
218
|
+
await E.cp(T, i, { recursive: !0 }).catch(() => {});
|
|
219
219
|
} finally {
|
|
220
220
|
await Promise.all([
|
|
221
|
-
|
|
221
|
+
E.rm(b, {
|
|
222
222
|
recursive: !0,
|
|
223
223
|
force: !0
|
|
224
224
|
}),
|
|
225
|
-
|
|
225
|
+
E.rm(a, {
|
|
226
226
|
recursive: !0,
|
|
227
227
|
force: !0
|
|
228
228
|
}),
|
|
229
|
-
|
|
229
|
+
E.rm(o, {
|
|
230
230
|
recursive: !0,
|
|
231
231
|
force: !0
|
|
232
232
|
})
|
|
@@ -235,7 +235,7 @@ async function j(e, t = {}) {
|
|
|
235
235
|
r.log(`\nBuild complete. Output: ${i}`);
|
|
236
236
|
}
|
|
237
237
|
function be(e) {
|
|
238
|
-
let t = `/${e.rootDir}/${u}`, r = JSON.parse(e.siteConfig), i = JSON.parse(e.siteData), a = i.contentTree ?? { entries: [] }, o =
|
|
238
|
+
let t = `/${e.rootDir}/${u}`, r = JSON.parse(e.siteConfig), i = JSON.parse(e.siteData), a = i.contentTree ?? { entries: [] }, o = h(a.entries ?? [], r.title ?? ""), s = JSON.stringify({
|
|
239
239
|
...i,
|
|
240
240
|
directoryListings: o
|
|
241
241
|
});
|
|
@@ -284,27 +284,27 @@ export async function render(url) {
|
|
|
284
284
|
`;
|
|
285
285
|
}
|
|
286
286
|
async function xe(t, n) {
|
|
287
|
-
let r = (await
|
|
287
|
+
let r = (await E.readdir(t, {
|
|
288
288
|
recursive: !0,
|
|
289
289
|
withFileTypes: !0
|
|
290
290
|
})).filter((t) => t.isFile() && !e(t.name)).map(async (e) => {
|
|
291
|
-
let r =
|
|
292
|
-
return
|
|
291
|
+
let r = C.join(e.parentPath, e.name), i = C.relative(t, r), a = C.join(n, i);
|
|
292
|
+
return E.mkdir(C.dirname(a), { recursive: !0 }).then(() => E.copyFile(r, a));
|
|
293
293
|
});
|
|
294
294
|
await Promise.all(r);
|
|
295
295
|
}
|
|
296
296
|
function Se(e, t) {
|
|
297
297
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
298
298
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
299
|
-
${e.map((e) => ` <url><loc>${
|
|
299
|
+
${e.map((e) => ` <url><loc>${_(t + e.replace(/^\//, ""))}</loc></url>`).join("\n")}
|
|
300
300
|
</urlset>
|
|
301
301
|
`;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
303
|
+
function N(e, t, n) {
|
|
304
304
|
for (let r of e) {
|
|
305
305
|
if (r.kind !== "dir") continue;
|
|
306
306
|
let e = `${t}/${r.node.name}`;
|
|
307
|
-
|
|
307
|
+
m(r.node) || n.push(c(e)), N(r.node.entries, e, n);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
//#endregion
|
|
@@ -324,7 +324,7 @@ function De(e, t, n) {
|
|
|
324
324
|
let n = e.children[0];
|
|
325
325
|
if (n.type !== "text") return e;
|
|
326
326
|
let r = t === i.children.length - 1;
|
|
327
|
-
if (!
|
|
327
|
+
if (!F(n.value, r)) return e;
|
|
328
328
|
let a = n.value.split(Ce);
|
|
329
329
|
if (a.length <= 1) return e;
|
|
330
330
|
let o = [a[0]];
|
|
@@ -346,13 +346,13 @@ function De(e, t, n) {
|
|
|
346
346
|
if (a.type !== "element") continue;
|
|
347
347
|
let o = a.children.at(0);
|
|
348
348
|
if (o?.type !== "text") continue;
|
|
349
|
-
let s = n === e.length - 1, c =
|
|
349
|
+
let s = n === e.length - 1, c = F(o.value, s), l;
|
|
350
350
|
if (!c && n > 0 && o.value.trim().startsWith("[!code")) {
|
|
351
351
|
let t = e[n - 1];
|
|
352
352
|
if (t?.type === "element") {
|
|
353
353
|
let n = t.children.at(0);
|
|
354
354
|
if (n?.type === "text" && n.value.includes("//")) {
|
|
355
|
-
let l =
|
|
355
|
+
let l = F(n.value + o.value, s);
|
|
356
356
|
if (l) {
|
|
357
357
|
c = l, r.push({
|
|
358
358
|
info: l,
|
|
@@ -369,7 +369,7 @@ function De(e, t, n) {
|
|
|
369
369
|
}
|
|
370
370
|
if (c) {
|
|
371
371
|
if (t && !s && n !== 0) {
|
|
372
|
-
let t =
|
|
372
|
+
let t = P(e[n - 1], "{") && P(e[n + 1], "}");
|
|
373
373
|
r.push({
|
|
374
374
|
info: c,
|
|
375
375
|
line: i,
|
|
@@ -391,12 +391,12 @@ function De(e, t, n) {
|
|
|
391
391
|
}
|
|
392
392
|
return r;
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function P(e, t) {
|
|
395
395
|
if (e.type !== "element") return !1;
|
|
396
396
|
let n = e.children[0];
|
|
397
397
|
return n.type === "text" && n.value.trim() === t;
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function F(e, t) {
|
|
400
400
|
let n = e.trimStart(), r = e.length - n.length;
|
|
401
401
|
n = n.trimEnd();
|
|
402
402
|
let i = e.length - n.length - r;
|
|
@@ -485,7 +485,7 @@ var Fe = /[.*+?^${}()|[\]\\]/g;
|
|
|
485
485
|
function Ie(e) {
|
|
486
486
|
return e.replace(Fe, "\\$&");
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function I(e = {}, t = "@shikijs/transformers:notation-map") {
|
|
489
489
|
let { classMap: n = {}, classActivePre: r = void 0, classActiveCode: i = void 0 } = e;
|
|
490
490
|
return Ae(t, RegExp(`#?\\s*\\[!code (${Object.keys(n).map(Ie).join("|")})(:\\d+)?\\]`, "gi"), function([e, t, a = ":1"], o, s, c, l) {
|
|
491
491
|
let u = Number.parseInt(a.slice(1), 10);
|
|
@@ -495,7 +495,7 @@ function F(e = {}, t = "@shikijs/transformers:notation-map") {
|
|
|
495
495
|
}
|
|
496
496
|
function Le(e = {}) {
|
|
497
497
|
let { classLineAdd: t = "diff add", classLineRemove: n = "diff remove", classActivePre: r = "has-diff", classActiveCode: i } = e;
|
|
498
|
-
return
|
|
498
|
+
return I({
|
|
499
499
|
classMap: {
|
|
500
500
|
"++": t,
|
|
501
501
|
"--": n
|
|
@@ -511,7 +511,7 @@ function Re(e = {}) {
|
|
|
511
511
|
warning: ["highlighted", "warning"],
|
|
512
512
|
info: ["highlighted", "info"]
|
|
513
513
|
}, classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
514
|
-
return
|
|
514
|
+
return I({
|
|
515
515
|
classMap: t,
|
|
516
516
|
classActivePre: n,
|
|
517
517
|
classActiveCode: r,
|
|
@@ -520,7 +520,7 @@ function Re(e = {}) {
|
|
|
520
520
|
}
|
|
521
521
|
function ze(e = {}) {
|
|
522
522
|
let { classActiveLine: t = "focused", classActivePre: n = "has-focused", classActiveCode: r } = e;
|
|
523
|
-
return
|
|
523
|
+
return I({
|
|
524
524
|
classMap: { focus: t },
|
|
525
525
|
classActivePre: n,
|
|
526
526
|
classActiveCode: r,
|
|
@@ -529,7 +529,7 @@ function ze(e = {}) {
|
|
|
529
529
|
}
|
|
530
530
|
function Be(e = {}) {
|
|
531
531
|
let { classActiveLine: t = "highlighted", classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
532
|
-
return
|
|
532
|
+
return I({
|
|
533
533
|
classMap: {
|
|
534
534
|
highlight: t,
|
|
535
535
|
hl: t
|
|
@@ -557,25 +557,25 @@ function We(e) {
|
|
|
557
557
|
}
|
|
558
558
|
//#endregion
|
|
559
559
|
//#region src/node/lib/logger.ts
|
|
560
|
-
var Ge = /\u001B\[[0-9;]*m/g,
|
|
560
|
+
var Ge = /\u001B\[[0-9;]*m/g, Ke = class {
|
|
561
561
|
logStream;
|
|
562
562
|
constructor(e) {
|
|
563
|
-
e !== void 0 && (this.logStream =
|
|
563
|
+
e !== void 0 && (this.logStream = D.createWriteStream(e, { flags: "a" }), process.once("exit", () => this.close()));
|
|
564
564
|
}
|
|
565
565
|
info(e) {
|
|
566
|
-
console.log(
|
|
566
|
+
console.log(T.cyan(`ℹ ${e}`)), this.writeToFile("INFO", e);
|
|
567
567
|
}
|
|
568
568
|
warn(e) {
|
|
569
|
-
console.warn(
|
|
569
|
+
console.warn(T.yellow(`⚠ ${e}`)), this.writeToFile("WARN", e);
|
|
570
570
|
}
|
|
571
571
|
error(e) {
|
|
572
|
-
console.error(
|
|
572
|
+
console.error(T.red(`✖ ${e}`)), this.writeToFile("ERROR", e);
|
|
573
573
|
}
|
|
574
574
|
success(e) {
|
|
575
|
-
console.log(
|
|
575
|
+
console.log(T.green(`✔ ${e}`)), this.writeToFile("SUCCESS", e);
|
|
576
576
|
}
|
|
577
577
|
start(e) {
|
|
578
|
-
console.log(
|
|
578
|
+
console.log(T.cyan(`◐ ${e}`)), this.writeToFile("START", e);
|
|
579
579
|
}
|
|
580
580
|
log(e) {
|
|
581
581
|
console.log(e), this.writeToFile("LOG", e);
|
|
@@ -588,14 +588,14 @@ var Ge = /\u001B\[[0-9;]*m/g, I = class {
|
|
|
588
588
|
close() {
|
|
589
589
|
this.logStream?.end(), this.logStream = void 0;
|
|
590
590
|
}
|
|
591
|
-
},
|
|
591
|
+
}, qe = new Ke(), Je = new FinalizationRegistry((e) => {
|
|
592
592
|
e();
|
|
593
593
|
}), L = {
|
|
594
594
|
light: "github-light",
|
|
595
595
|
dark: "github-dark"
|
|
596
596
|
};
|
|
597
|
-
async function
|
|
598
|
-
let e = await
|
|
597
|
+
async function Ye() {
|
|
598
|
+
let e = await ae({
|
|
599
599
|
themes: [L.light, L.dark],
|
|
600
600
|
langs: []
|
|
601
601
|
}), t = [
|
|
@@ -607,7 +607,7 @@ async function Je() {
|
|
|
607
607
|
}),
|
|
608
608
|
Be(),
|
|
609
609
|
Re(),
|
|
610
|
-
|
|
610
|
+
Xe(),
|
|
611
611
|
{
|
|
612
612
|
name: "typedown:add-dir",
|
|
613
613
|
pre(e) {
|
|
@@ -623,12 +623,12 @@ async function Je() {
|
|
|
623
623
|
}
|
|
624
624
|
i ||= "txt";
|
|
625
625
|
try {
|
|
626
|
-
!
|
|
626
|
+
!se(i) && !n.has(i) && (await e.loadLanguage(i), n.add(i));
|
|
627
627
|
} catch {
|
|
628
|
-
|
|
628
|
+
qe.warn(`\nThe language '${i}' is not loaded, falling back to 'txt' for syntax highlighting.`), i = "txt";
|
|
629
629
|
}
|
|
630
630
|
r = r.trimEnd();
|
|
631
|
-
let s =
|
|
631
|
+
let s = oe(r, i, e);
|
|
632
632
|
return await e.loadLanguage(...s), e.codeToHtml(r, {
|
|
633
633
|
lang: i,
|
|
634
634
|
transformers: [...t, {
|
|
@@ -670,9 +670,9 @@ async function Je() {
|
|
|
670
670
|
}
|
|
671
671
|
});
|
|
672
672
|
}
|
|
673
|
-
return
|
|
673
|
+
return Je.register(r, () => e.dispose()), r;
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function Xe() {
|
|
676
676
|
return {
|
|
677
677
|
name: "typedown:disable-shell-symbol-select",
|
|
678
678
|
tokens(e) {
|
|
@@ -687,19 +687,19 @@ function Ye() {
|
|
|
687
687
|
//#endregion
|
|
688
688
|
//#region src/node/lib/render/postprocess.ts
|
|
689
689
|
var R;
|
|
690
|
-
async function
|
|
691
|
-
return e = await
|
|
690
|
+
async function Ze(e) {
|
|
691
|
+
return e = await et(e), e = it(e), e;
|
|
692
692
|
}
|
|
693
|
-
function
|
|
694
|
-
return R ||=
|
|
693
|
+
function Qe() {
|
|
694
|
+
return R ||= Ye(), R;
|
|
695
695
|
}
|
|
696
|
-
var
|
|
697
|
-
async function
|
|
698
|
-
let t = await
|
|
696
|
+
var $e = /<pre class="td-code-placeholder"(?: data-lang="([^"]*)")?(?: data-meta="([^"]*)")?><code>([\s\S]*?)<\/code><\/pre>/g;
|
|
697
|
+
async function et(e) {
|
|
698
|
+
let t = await Qe(), n = [...e.matchAll($e)];
|
|
699
699
|
if (n.length === 0) return e;
|
|
700
700
|
let r = await Promise.all(n.map(async (e) => {
|
|
701
|
-
let n = e[1] || "", r = e[2] || "", i =
|
|
702
|
-
return
|
|
701
|
+
let n = e[1] || "", r = e[2] || "", i = v(e[3]);
|
|
702
|
+
return tt(await t(i, n, r), n, r);
|
|
703
703
|
})), i = e;
|
|
704
704
|
for (let e = n.length - 1; 0 <= e; e--) {
|
|
705
705
|
let t = n[e];
|
|
@@ -707,7 +707,7 @@ async function $e(e) {
|
|
|
707
707
|
}
|
|
708
708
|
return i;
|
|
709
709
|
}
|
|
710
|
-
function
|
|
710
|
+
function tt(e, t, n) {
|
|
711
711
|
t ||= "txt";
|
|
712
712
|
let r = t.replace(/_/g, " "), i = `<div class="language-${t}"><button title="Copy code" data-copied="Copied" class="copy"></button><span class="lang">${r}</span>` + e + "</div>";
|
|
713
713
|
if (/:line-numbers\b/.test(n)) {
|
|
@@ -718,14 +718,14 @@ function et(e, t, n) {
|
|
|
718
718
|
}
|
|
719
719
|
return i;
|
|
720
720
|
}
|
|
721
|
-
var
|
|
722
|
-
function
|
|
723
|
-
return e = e.replace(
|
|
721
|
+
var nt = /<span class="td-math-inline">([\s\S]*?)<\/span>/g, rt = /<div class="td-math-block">([\s\S]*?)<\/div>/g;
|
|
722
|
+
function it(e) {
|
|
723
|
+
return e = e.replace(nt, (e, t) => z(t, !1)), e = e.replace(rt, (e, t) => z(t, !0)), e;
|
|
724
724
|
}
|
|
725
725
|
function z(e, t) {
|
|
726
726
|
let n = t ? "div" : "span";
|
|
727
727
|
try {
|
|
728
|
-
return
|
|
728
|
+
return x.renderToString(v(e), {
|
|
729
729
|
throwOnError: !1,
|
|
730
730
|
displayMode: t
|
|
731
731
|
});
|
|
@@ -736,20 +736,20 @@ function z(e, t) {
|
|
|
736
736
|
//#endregion
|
|
737
737
|
//#region src/node/lib/render/vue.ts
|
|
738
738
|
async function B(e, t, n) {
|
|
739
|
-
let r = t.title || (
|
|
739
|
+
let r = t.title || t.label || (y(n) ? p(n, (await e.getConfig()).siteTitle) : d(n));
|
|
740
740
|
return {
|
|
741
741
|
schema: t.schema,
|
|
742
742
|
schemaLabel: t.schemaLabel,
|
|
743
743
|
label: t.label,
|
|
744
744
|
icon: t.icon,
|
|
745
745
|
frontmatter: t.header ?? {},
|
|
746
|
-
headings:
|
|
746
|
+
headings: ot(t.headings),
|
|
747
747
|
title: r,
|
|
748
748
|
metadata: t.metadata
|
|
749
749
|
};
|
|
750
750
|
}
|
|
751
|
-
async function
|
|
752
|
-
let r = await
|
|
751
|
+
async function at(e, t, n) {
|
|
752
|
+
let r = await Ze(t.content), i = await B(e, t, n), a = JSON.stringify(`@typedown/pages?resource=${encodeURIComponent(n)}`);
|
|
753
753
|
return {
|
|
754
754
|
vueSrc: [
|
|
755
755
|
"<script>",
|
|
@@ -761,12 +761,12 @@ async function it(e, t, n) {
|
|
|
761
761
|
`import { pageData } from ${a}`,
|
|
762
762
|
"useRouter().route.data = pageData",
|
|
763
763
|
"<\/script>",
|
|
764
|
-
`<template><div class="typedown-content">\n${
|
|
764
|
+
`<template><div class="typedown-content">\n${st(r)}\n</div></template>`
|
|
765
765
|
].join("\n"),
|
|
766
766
|
pageData: i
|
|
767
767
|
};
|
|
768
768
|
}
|
|
769
|
-
function
|
|
769
|
+
function ot(e) {
|
|
770
770
|
let t = [], n = [];
|
|
771
771
|
for (let r of e) {
|
|
772
772
|
let e = {
|
|
@@ -782,12 +782,12 @@ function at(e) {
|
|
|
782
782
|
}
|
|
783
783
|
return t;
|
|
784
784
|
}
|
|
785
|
-
function
|
|
785
|
+
function st(e) {
|
|
786
786
|
return e.replaceAll("{{", "{{");
|
|
787
787
|
}
|
|
788
788
|
//#endregion
|
|
789
789
|
//#region src/node/lib/typedown-context.ts
|
|
790
|
-
var
|
|
790
|
+
var ct = class {
|
|
791
791
|
client;
|
|
792
792
|
constructor(e) {
|
|
793
793
|
this.client = e, this.registerNotificationHandlers(e);
|
|
@@ -800,12 +800,14 @@ var st = class {
|
|
|
800
800
|
registerNotificationHandlers(e) {
|
|
801
801
|
e.onConfigChanged((e) => {
|
|
802
802
|
this.cachedConfig = e;
|
|
803
|
-
}), e.onContentChanged(({
|
|
803
|
+
}), e.onContentChanged(({ filepath: e, affectedFiles: t = [] }) => {
|
|
804
804
|
this.cachedFileMap.delete(e);
|
|
805
805
|
for (let e of t) this.cachedFileMap.delete(e);
|
|
806
806
|
}), e.onContentCreated(() => {
|
|
807
807
|
this.cachedFiles = void 0;
|
|
808
|
-
}), e.
|
|
808
|
+
}), e.onContentRenamed(({ filepath: e, renamedTo: t }) => {
|
|
809
|
+
this.cachedFiles = void 0, this.cachedFileMap.delete(e), t !== void 0 && this.cachedFileMap.delete(t);
|
|
810
|
+
}), e.onContentDeleted(({ filepath: e }) => {
|
|
809
811
|
this.cachedFiles = void 0, this.cachedFileMap.delete(e);
|
|
810
812
|
}), e.onSchemaChanged(({ schema: e }) => {
|
|
811
813
|
this.cachedSchemaMap.delete(e);
|
|
@@ -858,7 +860,7 @@ var st = class {
|
|
|
858
860
|
}
|
|
859
861
|
};
|
|
860
862
|
function V(e) {
|
|
861
|
-
return e instanceof Error && "code" in e && e.code ===
|
|
863
|
+
return e instanceof Error && "code" in e && e.code === pe;
|
|
862
864
|
}
|
|
863
865
|
async function H(e, t = 5) {
|
|
864
866
|
for (let n = 0; n < t; n++) try {
|
|
@@ -873,9 +875,9 @@ async function H(e, t = 5) {
|
|
|
873
875
|
//#region src/node/context.ts
|
|
874
876
|
var U = ["typedown.yaml", "typedown.yml"];
|
|
875
877
|
function W(e) {
|
|
876
|
-
let t = new
|
|
878
|
+
let t = new Ke(dt(e));
|
|
877
879
|
function n() {
|
|
878
|
-
let e =
|
|
880
|
+
let e = re("warn");
|
|
879
881
|
return {
|
|
880
882
|
...e,
|
|
881
883
|
info(e) {
|
|
@@ -898,14 +900,14 @@ function W(e) {
|
|
|
898
900
|
}
|
|
899
901
|
async function l() {
|
|
900
902
|
if (r) return r;
|
|
901
|
-
process.on("SIGINT", s), process.on("SIGTERM", s), i = new
|
|
903
|
+
process.on("SIGINT", s), process.on("SIGTERM", s), i = new fe({ root: e }), await new Promise((e, t) => {
|
|
902
904
|
i?.once("error", t), i?.listen(() => {
|
|
903
905
|
i?.removeListener("error", t), e();
|
|
904
906
|
});
|
|
905
907
|
});
|
|
906
908
|
let t = i.host, n = i.port;
|
|
907
909
|
if (t === void 0 || n === void 0) throw Error("RPC server started but host/port not available");
|
|
908
|
-
return a = await
|
|
910
|
+
return a = await me.connectTcp(t, n), r = new ct(a), i.unref(), process.on("exit", c), r;
|
|
909
911
|
}
|
|
910
912
|
function u() {
|
|
911
913
|
o || (o = !0, process.removeListener("exit", c), process.removeListener("SIGINT", s), process.removeListener("SIGTERM", s), a?.dispose(), i?.close(), r = void 0, i = void 0, a = void 0);
|
|
@@ -918,59 +920,59 @@ function W(e) {
|
|
|
918
920
|
dispose: u
|
|
919
921
|
};
|
|
920
922
|
}
|
|
921
|
-
function
|
|
922
|
-
let t =
|
|
923
|
+
function lt(e) {
|
|
924
|
+
let t = C.resolve(e);
|
|
923
925
|
for (;;) {
|
|
924
|
-
if (
|
|
925
|
-
let e =
|
|
926
|
+
if (ut(t)) return t;
|
|
927
|
+
let e = C.dirname(t);
|
|
926
928
|
if (e === t) break;
|
|
927
929
|
t = e;
|
|
928
930
|
}
|
|
929
|
-
return
|
|
930
|
-
}
|
|
931
|
-
function lt(e) {
|
|
932
|
-
return U.some((t) => O.existsSync(S.join(e, t)));
|
|
931
|
+
return C.resolve(e);
|
|
933
932
|
}
|
|
934
933
|
function ut(e) {
|
|
934
|
+
return U.some((t) => D.existsSync(C.join(e, t)));
|
|
935
|
+
}
|
|
936
|
+
function dt(e) {
|
|
935
937
|
try {
|
|
936
|
-
let t =
|
|
937
|
-
|
|
938
|
-
let r =
|
|
939
|
-
|
|
938
|
+
let t = C.join(e, ".typedown", ".local"), n = C.join(t, "logs");
|
|
939
|
+
D.mkdirSync(n, { recursive: !0 });
|
|
940
|
+
let r = C.join(t, ".gitignore");
|
|
941
|
+
D.existsSync(r) || D.writeFileSync(r, "*\n");
|
|
940
942
|
let i = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
941
|
-
return
|
|
943
|
+
return C.join(n, `${i}.log`);
|
|
942
944
|
} catch {
|
|
943
945
|
return;
|
|
944
946
|
}
|
|
945
947
|
}
|
|
946
948
|
//#endregion
|
|
947
949
|
//#region src/node/plugin/vite/constants.ts
|
|
948
|
-
var
|
|
950
|
+
var ft = "@typedown/app", G = "\0@typedown/app", K = "@typedown/pages", q = "\0" + K;
|
|
949
951
|
K + "";
|
|
950
|
-
var J = "\0@typedown/pages?resource=", Y = "@typedown/site-data",
|
|
952
|
+
var J = "\0@typedown/pages?resource=", Y = "@typedown/site-data", pt = "\0@typedown/site-data", X = "@typedown/search-index", mt = "\0@typedown/search-index";
|
|
951
953
|
//#endregion
|
|
952
954
|
//#region src/node/plugin/vite/virtual/utils.ts
|
|
953
955
|
function Z(e, t) {
|
|
954
956
|
let n = e.moduleGraph.getModuleById(t);
|
|
955
957
|
if (!n) return;
|
|
956
958
|
e.moduleGraph.invalidateModule(n);
|
|
957
|
-
let r =
|
|
959
|
+
let r = ht(n.url);
|
|
958
960
|
for (let t of n.importers) e.hot.send({
|
|
959
961
|
type: "update",
|
|
960
962
|
updates: [{
|
|
961
963
|
type: "js-update",
|
|
962
|
-
path:
|
|
964
|
+
path: ht(t.url),
|
|
963
965
|
acceptedPath: r,
|
|
964
966
|
timestamp: Date.now()
|
|
965
967
|
}]
|
|
966
968
|
});
|
|
967
969
|
}
|
|
968
|
-
function
|
|
970
|
+
function ht(e) {
|
|
969
971
|
return e.startsWith("\0") ? "/@id/__x00__" + e.slice(1) : e;
|
|
970
972
|
}
|
|
971
973
|
//#endregion
|
|
972
974
|
//#region src/node/plugin/vite/virtual/app.ts
|
|
973
|
-
var
|
|
975
|
+
var gt = class {
|
|
974
976
|
async load(e) {
|
|
975
977
|
let t = await e.getConfig();
|
|
976
978
|
return Q({
|
|
@@ -998,7 +1000,7 @@ import 'typerighter/fonts.css';
|
|
|
998
1000
|
import('typerighter/math.css');
|
|
999
1001
|
import { createTypedownApp } from 'typerighter/client';
|
|
1000
1002
|
import { TdDirectoryIndex, TdGlossaryIndex } from 'typerighter/client/theme-default';
|
|
1001
|
-
import { isIndexUrl, getDirectoryFromPageUrl } from 'typerighter/shared';
|
|
1003
|
+
import { isIndexUrl, getDirectoryFromPageUrl, getParentUrl, path } from 'typerighter/shared';
|
|
1002
1004
|
import { h } from 'vue';
|
|
1003
1005
|
import theme from 'typerighter/client/theme-default';
|
|
1004
1006
|
import { pages as initialPages } from '${K}';
|
|
@@ -1014,8 +1016,7 @@ function findPage(base) {
|
|
|
1014
1016
|
}
|
|
1015
1017
|
|
|
1016
1018
|
async function loadPageModule(pagePath) {
|
|
1017
|
-
const
|
|
1018
|
-
const loader = findPage(base);
|
|
1019
|
+
const loader = findPage(path.join('/', '${t}', pagePath));
|
|
1019
1020
|
if (loader) return loader();
|
|
1020
1021
|
|
|
1021
1022
|
if (isIndexUrl(pagePath)) {
|
|
@@ -1030,7 +1031,7 @@ async function loadPageModule(pagePath) {
|
|
|
1030
1031
|
return undefined;
|
|
1031
1032
|
}
|
|
1032
1033
|
|
|
1033
|
-
const { app, searchIndex: searchIndexRef, siteData } = await createTypedownApp(loadPageModule, theme.Layout, ${r}, initialSiteData);
|
|
1034
|
+
const { app, router, searchIndex: searchIndexRef, siteData } = await createTypedownApp(loadPageModule, theme.Layout, ${r}, initialSiteData);
|
|
1034
1035
|
app.mount('#app');
|
|
1035
1036
|
|
|
1036
1037
|
// Load search index in the background after the app is mounted
|
|
@@ -1039,7 +1040,15 @@ import('${X}').then((m) => { searchIndexRef.value = m.default; });
|
|
|
1039
1040
|
// Accept HMR so modules update without a full page reload
|
|
1040
1041
|
if (import.meta.hot) {
|
|
1041
1042
|
import.meta.hot.accept('${K}', (m) => {
|
|
1042
|
-
if (m)
|
|
1043
|
+
if (!m) return;
|
|
1044
|
+
const base = path.join('/', '${t}', router.route.path);
|
|
1045
|
+
const hadPage = !!findPage(base);
|
|
1046
|
+
pages = m.pages;
|
|
1047
|
+
const hasPage = !!findPage(base);
|
|
1048
|
+
// Current page was removed (deleted or renamed away)
|
|
1049
|
+
if (hadPage && !hasPage) router.go(getParentUrl(router.route.path));
|
|
1050
|
+
// A real page appeared where a directory index was shown
|
|
1051
|
+
if (!hadPage && hasPage) router.go(router.route.path);
|
|
1043
1052
|
});
|
|
1044
1053
|
|
|
1045
1054
|
import.meta.hot.accept('${X}', (m) => {
|
|
@@ -1054,7 +1063,7 @@ if (import.meta.hot) {
|
|
|
1054
1063
|
}
|
|
1055
1064
|
//#endregion
|
|
1056
1065
|
//#region src/node/plugin/vite/virtual/pages.ts
|
|
1057
|
-
var
|
|
1066
|
+
var _t = class {
|
|
1058
1067
|
async load(e) {
|
|
1059
1068
|
let t = (await e.getConfig()).rootDir ?? ".";
|
|
1060
1069
|
return `export const pages = import.meta.glob('${t === "." ? "/**/*.{td,md}" : `/${t}/**/*.{td,md}`}');`;
|
|
@@ -1075,53 +1084,53 @@ var gt = class {
|
|
|
1075
1084
|
invalidate(e) {
|
|
1076
1085
|
Z(e, q);
|
|
1077
1086
|
}
|
|
1078
|
-
},
|
|
1087
|
+
}, vt = "\0@typedown/site-data", yt = {
|
|
1079
1088
|
ready: !1,
|
|
1080
1089
|
contentTree: { entries: [] },
|
|
1081
1090
|
schemas: {},
|
|
1082
1091
|
directoryListings: {}
|
|
1083
|
-
},
|
|
1092
|
+
}, bt = class {
|
|
1084
1093
|
data;
|
|
1085
1094
|
scan(e) {
|
|
1086
|
-
let t =
|
|
1095
|
+
let t = O("**/*.td", {
|
|
1087
1096
|
cwd: e,
|
|
1088
1097
|
exclude: (e) => e.startsWith("_")
|
|
1089
1098
|
}).map((e) => ({
|
|
1090
1099
|
filepath: e,
|
|
1091
1100
|
label: d(e),
|
|
1092
1101
|
header: {}
|
|
1093
|
-
})), n =
|
|
1102
|
+
})), n = g(t);
|
|
1094
1103
|
this.data = {
|
|
1095
1104
|
contentTree: n,
|
|
1096
1105
|
schemas: {},
|
|
1097
|
-
directoryListings:
|
|
1106
|
+
directoryListings: h(n.entries, "")
|
|
1098
1107
|
};
|
|
1099
1108
|
}
|
|
1100
1109
|
load(e) {
|
|
1101
1110
|
let t = this.data ? {
|
|
1102
1111
|
ready: !0,
|
|
1103
1112
|
...this.data
|
|
1104
|
-
} :
|
|
1113
|
+
} : yt;
|
|
1105
1114
|
return `export default ${JSON.stringify(t)}`;
|
|
1106
1115
|
}
|
|
1107
1116
|
clear() {
|
|
1108
1117
|
this.data = void 0;
|
|
1109
1118
|
}
|
|
1110
1119
|
fetch(e, t) {
|
|
1111
|
-
|
|
1120
|
+
xt(e).then((e) => {
|
|
1112
1121
|
this.data = e, t && this.invalidate(t);
|
|
1113
1122
|
}).catch((e) => {
|
|
1114
1123
|
console.error("[typedown] Failed to fetch site data:", e instanceof Error ? e.message : e);
|
|
1115
1124
|
});
|
|
1116
1125
|
}
|
|
1117
1126
|
async fetchSync(e) {
|
|
1118
|
-
this.data = await
|
|
1127
|
+
this.data = await xt(e);
|
|
1119
1128
|
}
|
|
1120
1129
|
invalidate(e) {
|
|
1121
|
-
Z(e,
|
|
1130
|
+
Z(e, vt);
|
|
1122
1131
|
}
|
|
1123
1132
|
};
|
|
1124
|
-
async function
|
|
1133
|
+
async function xt(e) {
|
|
1125
1134
|
let [t, n, r] = await Promise.all([
|
|
1126
1135
|
e.getConfig(),
|
|
1127
1136
|
e.listSidebar(),
|
|
@@ -1129,19 +1138,19 @@ async function bt(e) {
|
|
|
1129
1138
|
]), i = await Promise.all(r.map(async (t) => [t, (await e.getSchema(t)).properties])), a = Object.fromEntries(i), o = n.map((e) => ({
|
|
1130
1139
|
...e,
|
|
1131
1140
|
header: {}
|
|
1132
|
-
})), s =
|
|
1141
|
+
})), s = g(o);
|
|
1133
1142
|
return {
|
|
1134
1143
|
contentTree: s,
|
|
1135
1144
|
schemas: a,
|
|
1136
|
-
directoryListings:
|
|
1145
|
+
directoryListings: h(s.entries, t.siteTitle)
|
|
1137
1146
|
};
|
|
1138
1147
|
}
|
|
1139
1148
|
//#endregion
|
|
1140
1149
|
//#region src/node/lib/search-indexer/index.ts
|
|
1141
|
-
var
|
|
1150
|
+
var St = class {
|
|
1142
1151
|
index;
|
|
1143
1152
|
constructor() {
|
|
1144
|
-
this.index = new
|
|
1153
|
+
this.index = new S({
|
|
1145
1154
|
fields: t,
|
|
1146
1155
|
storeFields: i
|
|
1147
1156
|
});
|
|
@@ -1162,19 +1171,19 @@ var xt = class {
|
|
|
1162
1171
|
};
|
|
1163
1172
|
//#endregion
|
|
1164
1173
|
//#region src/node/lib/search-indexer/scan.ts
|
|
1165
|
-
function
|
|
1166
|
-
let n =
|
|
1174
|
+
function Ct(e, t) {
|
|
1175
|
+
let n = Dt(e), r = [];
|
|
1167
1176
|
for (let t of n) {
|
|
1168
|
-
let n =
|
|
1177
|
+
let n = Et(e, t);
|
|
1169
1178
|
n && r.push(n);
|
|
1170
1179
|
}
|
|
1171
1180
|
t.addAll(r);
|
|
1172
1181
|
}
|
|
1173
|
-
function
|
|
1174
|
-
let r =
|
|
1175
|
-
r ? n.addPage(r) : n.discardPage(
|
|
1182
|
+
function wt(e, t, n) {
|
|
1183
|
+
let r = Et(e, w(e, t));
|
|
1184
|
+
r ? n.addPage(r) : n.discardPage(b(t));
|
|
1176
1185
|
}
|
|
1177
|
-
function
|
|
1186
|
+
function Tt(e, t) {
|
|
1178
1187
|
let n = d(e);
|
|
1179
1188
|
if (!t.startsWith("---")) return {
|
|
1180
1189
|
title: n,
|
|
@@ -1191,56 +1200,56 @@ function wt(e, t) {
|
|
|
1191
1200
|
body: a
|
|
1192
1201
|
};
|
|
1193
1202
|
}
|
|
1194
|
-
function
|
|
1203
|
+
function Et(e, t) {
|
|
1195
1204
|
let n;
|
|
1196
1205
|
try {
|
|
1197
|
-
n =
|
|
1206
|
+
n = ue(t, "utf-8");
|
|
1198
1207
|
} catch {
|
|
1199
1208
|
return;
|
|
1200
1209
|
}
|
|
1201
1210
|
if (!n.trim()) return;
|
|
1202
|
-
let r = t.slice(e.length + 1), { title: i, body: a } =
|
|
1211
|
+
let r = t.slice(e.length + 1), { title: i, body: a } = Tt(r, n);
|
|
1203
1212
|
return {
|
|
1204
|
-
id:
|
|
1213
|
+
id: b(r),
|
|
1205
1214
|
title: i,
|
|
1206
1215
|
text: `${i}\n${a}`
|
|
1207
1216
|
};
|
|
1208
1217
|
}
|
|
1209
|
-
function
|
|
1210
|
-
return
|
|
1218
|
+
function Dt(e) {
|
|
1219
|
+
return O("**/*.td", {
|
|
1211
1220
|
cwd: e,
|
|
1212
1221
|
exclude: (e) => e.startsWith("_")
|
|
1213
|
-
}).map((t) =>
|
|
1222
|
+
}).map((t) => w(e, t));
|
|
1214
1223
|
}
|
|
1215
1224
|
//#endregion
|
|
1216
1225
|
//#region src/node/plugin/vite/virtual/search-index.ts
|
|
1217
|
-
var
|
|
1218
|
-
indexer = new
|
|
1226
|
+
var Ot = "\0@typedown/search-index", kt = class {
|
|
1227
|
+
indexer = new St();
|
|
1219
1228
|
load(e) {
|
|
1220
1229
|
return `export default ${JSON.stringify(this.indexer.serialize())}`;
|
|
1221
1230
|
}
|
|
1222
1231
|
index(e) {
|
|
1223
|
-
|
|
1232
|
+
Ct(e, this.indexer);
|
|
1224
1233
|
}
|
|
1225
1234
|
reindex(e, t) {
|
|
1226
|
-
|
|
1235
|
+
wt(e, t, this.indexer);
|
|
1227
1236
|
}
|
|
1228
1237
|
invalidate(e) {
|
|
1229
|
-
Z(e,
|
|
1238
|
+
Z(e, Ot);
|
|
1230
1239
|
}
|
|
1231
|
-
},
|
|
1232
|
-
function
|
|
1240
|
+
}, At = he(import.meta.url);
|
|
1241
|
+
function jt() {
|
|
1233
1242
|
return [{
|
|
1234
1243
|
find: "vue/server-renderer",
|
|
1235
|
-
replacement:
|
|
1244
|
+
replacement: At.resolve("vue/server-renderer")
|
|
1236
1245
|
}, {
|
|
1237
1246
|
find: "vue",
|
|
1238
|
-
replacement:
|
|
1247
|
+
replacement: At.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
1239
1248
|
}];
|
|
1240
1249
|
}
|
|
1241
1250
|
//#endregion
|
|
1242
1251
|
//#region src/node/plugin/vite/middleware/vault-assets.ts
|
|
1243
|
-
var
|
|
1252
|
+
var Mt = {
|
|
1244
1253
|
jpg: "image/jpeg",
|
|
1245
1254
|
jpeg: "image/jpeg",
|
|
1246
1255
|
png: "image/png",
|
|
@@ -1258,17 +1267,17 @@ var jt = {
|
|
|
1258
1267
|
woff: "font/woff",
|
|
1259
1268
|
ttf: "font/ttf"
|
|
1260
1269
|
};
|
|
1261
|
-
function
|
|
1270
|
+
function Nt(e, t) {
|
|
1262
1271
|
return (n, r, i) => {
|
|
1263
1272
|
if (!n.url || n.method !== "GET" || r.writableEnded) return i();
|
|
1264
1273
|
let a = l(n.url);
|
|
1265
1274
|
if (a.startsWith("/@") || a.startsWith("/node_modules")) return i();
|
|
1266
|
-
let s = a.replace(/^\//, ""), c =
|
|
1267
|
-
if (
|
|
1268
|
-
let e =
|
|
1275
|
+
let s = a.replace(/^\//, ""), c = w(e.config.root, t.rootDirectory, s);
|
|
1276
|
+
if (le(c)) try {
|
|
1277
|
+
let e = de(c);
|
|
1269
1278
|
if (e.isFile()) {
|
|
1270
|
-
let t =
|
|
1271
|
-
r.setHeader("Content-Type", t), r.setHeader("Content-Length", e.size),
|
|
1279
|
+
let t = Mt[o(c).slice(1).toLowerCase()] ?? "application/octet-stream";
|
|
1280
|
+
r.setHeader("Content-Type", t), r.setHeader("Content-Length", e.size), ce(c).pipe(r);
|
|
1272
1281
|
return;
|
|
1273
1282
|
}
|
|
1274
1283
|
} catch {}
|
|
@@ -1277,7 +1286,7 @@ function Mt(e, t) {
|
|
|
1277
1286
|
}
|
|
1278
1287
|
//#endregion
|
|
1279
1288
|
//#region src/node/plugin/vite/middleware/virtual-html.ts
|
|
1280
|
-
function
|
|
1289
|
+
function Pt(e, t, n) {
|
|
1281
1290
|
return (r, i, o) => {
|
|
1282
1291
|
if (!r.url) return o();
|
|
1283
1292
|
let s = a(l(r.url)), c = a(n.basePath);
|
|
@@ -1285,28 +1294,28 @@ function Nt(e, t, n) {
|
|
|
1285
1294
|
let u = s.slice(c.length);
|
|
1286
1295
|
if (u.startsWith("/@") || u.startsWith("/node_modules") || s.includes(".") && !s.endsWith("/index.html")) return o();
|
|
1287
1296
|
t.getConfig().then(async (t) => {
|
|
1288
|
-
let a = await e.transformIndexHtml(r.url ?? "",
|
|
1297
|
+
let a = await e.transformIndexHtml(r.url ?? "", Ft(n, t));
|
|
1289
1298
|
i.setHeader("Content-Type", "text/html"), i.end(a);
|
|
1290
1299
|
}).catch(() => o());
|
|
1291
1300
|
};
|
|
1292
1301
|
}
|
|
1293
|
-
function
|
|
1294
|
-
return e.devHtml === void 0 && (e.devHtml =
|
|
1302
|
+
function Ft(e, t) {
|
|
1303
|
+
return e.devHtml === void 0 && (e.devHtml = k({
|
|
1295
1304
|
title: t.siteTitle,
|
|
1296
1305
|
description: t.siteDescription,
|
|
1297
1306
|
base: "/",
|
|
1298
|
-
entryScript:
|
|
1307
|
+
entryScript: ft
|
|
1299
1308
|
})), e.devHtml;
|
|
1300
1309
|
}
|
|
1301
1310
|
//#endregion
|
|
1302
1311
|
//#region src/node/plugin/vite/index.ts
|
|
1303
1312
|
function $(t = {}) {
|
|
1304
|
-
let n = t.context, i, a, o, s = new
|
|
1313
|
+
let n = t.context, i, a, o, s = new gt(), c = new _t(), l = new bt(), u = new kt(), d = {
|
|
1305
1314
|
devHtml: void 0,
|
|
1306
1315
|
basePath: "/",
|
|
1307
1316
|
rootDirectory: "vault"
|
|
1308
1317
|
};
|
|
1309
|
-
function
|
|
1318
|
+
function p() {
|
|
1310
1319
|
if (n === void 0) throw Error("typedown plugin not initialized");
|
|
1311
1320
|
return n.getTdContext();
|
|
1312
1321
|
}
|
|
@@ -1315,8 +1324,8 @@ function $(t = {}) {
|
|
|
1315
1324
|
name: "vite-plugin-typedown",
|
|
1316
1325
|
enforce: "pre",
|
|
1317
1326
|
async config(e) {
|
|
1318
|
-
n ||= W(t.root ?
|
|
1319
|
-
let r = await (await
|
|
1327
|
+
n ||= W(t.root ? w(e.root ?? process.cwd(), t.root) : lt(e.root ?? process.cwd())), o = e.base ?? "/";
|
|
1328
|
+
let r = await (await p()).getConfig();
|
|
1320
1329
|
return {
|
|
1321
1330
|
base: e.base ?? r.basePath,
|
|
1322
1331
|
publicDir: r.publicDir,
|
|
@@ -1324,19 +1333,19 @@ function $(t = {}) {
|
|
|
1324
1333
|
port: 8686,
|
|
1325
1334
|
strictPort: !1
|
|
1326
1335
|
},
|
|
1327
|
-
resolve: { alias:
|
|
1336
|
+
resolve: { alias: jt() },
|
|
1328
1337
|
ssr: { noExternal: ["typerighter"] }
|
|
1329
1338
|
};
|
|
1330
1339
|
},
|
|
1331
1340
|
configResolved(e) {
|
|
1332
|
-
a =
|
|
1341
|
+
a = w(e.root, e.build.outDir);
|
|
1333
1342
|
},
|
|
1334
1343
|
async buildStart() {
|
|
1335
1344
|
if (i) return;
|
|
1336
|
-
let e = await
|
|
1345
|
+
let e = await p(), t = await e.getConfig(), n = w(t.rootDir);
|
|
1337
1346
|
u.index(n), await l.fetchSync(e);
|
|
1338
1347
|
let r = await e.checkVault();
|
|
1339
|
-
if (
|
|
1348
|
+
if (Bt(r.diagnostics), 0 < r.errorCount) {
|
|
1340
1349
|
let e = r.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
1341
1350
|
this.error(`Vault check failed with ${r.errorCount} error(s):\n${e.join("\n")}`);
|
|
1342
1351
|
}
|
|
@@ -1345,13 +1354,13 @@ function $(t = {}) {
|
|
|
1345
1354
|
if (e === "/@typedown/app" || e === "@typedown/app") return G;
|
|
1346
1355
|
if (e === "@typedown/pages") return q;
|
|
1347
1356
|
if (e.startsWith("@typedown/pages?resource=")) return c.resolvePageData(e);
|
|
1348
|
-
if (e === "@typedown/site-data") return
|
|
1349
|
-
if (e === "@typedown/search-index") return
|
|
1357
|
+
if (e === "@typedown/site-data") return pt;
|
|
1358
|
+
if (e === "@typedown/search-index") return mt;
|
|
1350
1359
|
},
|
|
1351
1360
|
async load(e) {
|
|
1352
|
-
if (c.isPageDataModule(e)) return c.loadPageData(e, await
|
|
1361
|
+
if (c.isPageDataModule(e)) return c.loadPageData(e, await p());
|
|
1353
1362
|
if (e !== "\0@typedown/search-index" && e !== "\0@typedown/site-data" && e !== "\0@typedown/pages" && e !== "\0@typedown/app") return;
|
|
1354
|
-
let t = await
|
|
1363
|
+
let t = await p();
|
|
1355
1364
|
if (e === "\0@typedown/search-index") return u.load(t);
|
|
1356
1365
|
if (e === "\0@typedown/site-data") return l.load(t);
|
|
1357
1366
|
if (e === "\0@typedown/pages") return c.load(t);
|
|
@@ -1359,20 +1368,22 @@ function $(t = {}) {
|
|
|
1359
1368
|
},
|
|
1360
1369
|
async configureServer(e) {
|
|
1361
1370
|
i = e;
|
|
1362
|
-
let t = await
|
|
1371
|
+
let t = await p(), n = await t.getConfig(), r = w(n.rootDir), a = f(() => {
|
|
1372
|
+
i && l.fetch(t, i);
|
|
1373
|
+
}, 200);
|
|
1363
1374
|
u.index(r), l.scan(r), l.fetch(t, i), e.httpServer?.once("listening", async () => {
|
|
1364
1375
|
let e = await t.checkVault();
|
|
1365
|
-
0 < e.diagnostics.length && (console.error(""),
|
|
1376
|
+
0 < e.diagnostics.length && (console.error(""), Bt(e.diagnostics));
|
|
1366
1377
|
}), t.rpc.onConfigChanged(() => {
|
|
1367
|
-
i && (d.devHtml = void 0, l.clear(), s.invalidate(i), c.invalidate(i),
|
|
1368
|
-
}), t.rpc.onContentChanged(({
|
|
1378
|
+
i && (d.devHtml = void 0, l.clear(), s.invalidate(i), c.invalidate(i), Lt(i), l.fetch(t, i));
|
|
1379
|
+
}), t.rpc.onContentChanged(({ filepath: e, affectedFiles: n = [] }) => {
|
|
1369
1380
|
i && (u.reindex(r, e), u.invalidate(i), t.getConfig().then((t) => {
|
|
1370
1381
|
if (!i) return;
|
|
1371
1382
|
let r = [e, ...n], a = [];
|
|
1372
1383
|
for (let e of r) {
|
|
1373
|
-
let n =
|
|
1384
|
+
let n = ie(w(i.config.root, t.rootDir, e)), r = i.moduleGraph.getModulesByFile(n);
|
|
1374
1385
|
if (r?.size) {
|
|
1375
|
-
for (let e of r) i?.moduleGraph.invalidateModule(e), a.push(
|
|
1386
|
+
for (let e of r) i?.moduleGraph.invalidateModule(e), a.push(zt(e));
|
|
1376
1387
|
c.invalidatePageData(i, e);
|
|
1377
1388
|
}
|
|
1378
1389
|
}
|
|
@@ -1380,20 +1391,20 @@ function $(t = {}) {
|
|
|
1380
1391
|
type: "update",
|
|
1381
1392
|
updates: a
|
|
1382
1393
|
});
|
|
1383
|
-
}).catch(() => {}));
|
|
1394
|
+
}).catch(() => {}), a());
|
|
1384
1395
|
});
|
|
1385
|
-
function
|
|
1396
|
+
function o() {
|
|
1386
1397
|
i && (u.index(r), u.invalidate(i), c.invalidate(i), l.clear(), l.fetch(t, i));
|
|
1387
1398
|
}
|
|
1388
|
-
t.rpc.onContentCreated(
|
|
1389
|
-
function
|
|
1390
|
-
i && (l.clear(),
|
|
1399
|
+
t.rpc.onContentCreated(o), t.rpc.onContentDeleted(o), t.rpc.onContentRenamed(o);
|
|
1400
|
+
function m() {
|
|
1401
|
+
i && (l.clear(), Rt(i), l.fetch(t, i));
|
|
1391
1402
|
}
|
|
1392
|
-
t.rpc.onSchemaChanged(
|
|
1393
|
-
let
|
|
1394
|
-
d.basePath =
|
|
1403
|
+
t.rpc.onSchemaChanged(m), t.rpc.onSchemaCreated(m), t.rpc.onSchemaDeleted(m);
|
|
1404
|
+
let h = await t.getConfig();
|
|
1405
|
+
d.basePath = h.basePath, d.rootDirectory = h.rootDir, t.rpc.onConfigChanged((e) => {
|
|
1395
1406
|
d.basePath = e.basePath, d.rootDirectory = e.rootDir, d.devHtml = void 0;
|
|
1396
|
-
}), e.middlewares.use(
|
|
1407
|
+
}), e.middlewares.use(Nt(e, d)), e.middlewares.use(Pt(e, t, d));
|
|
1397
1408
|
},
|
|
1398
1409
|
async transform(t, n) {
|
|
1399
1410
|
let i = n.split("?")[0];
|
|
@@ -1402,9 +1413,9 @@ function $(t = {}) {
|
|
|
1402
1413
|
code: "<script>import { TdNotFound } from 'typerighter/client/theme-default'; export default TdNotFound; export const pageData = { frontmatter: {}, headings: [], title: '' };<\/script>",
|
|
1403
1414
|
map: null
|
|
1404
1415
|
};
|
|
1405
|
-
let a = await
|
|
1416
|
+
let a = await p(), o = (await a.getConfig()).rootDir, s = i.includes(o) ? i.slice(i.indexOf(o) + o.length + 1) : i;
|
|
1406
1417
|
try {
|
|
1407
|
-
let { vueSrc: e } = await
|
|
1418
|
+
let { vueSrc: e } = await at(a, await a.getFile(s), s);
|
|
1408
1419
|
return {
|
|
1409
1420
|
code: e,
|
|
1410
1421
|
map: null
|
|
@@ -1421,8 +1432,8 @@ function $(t = {}) {
|
|
|
1421
1432
|
async closeBundle() {
|
|
1422
1433
|
if (!t.context && n) try {
|
|
1423
1434
|
let e = (await (await n.getTdContext()).getConfig()).basePath, t = e.startsWith(o) ? e.slice(o.length) : e.replace(/^\//, "");
|
|
1424
|
-
await
|
|
1425
|
-
outDir:
|
|
1435
|
+
await M(n, {
|
|
1436
|
+
outDir: w(a, t),
|
|
1426
1437
|
base: e
|
|
1427
1438
|
});
|
|
1428
1439
|
} finally {
|
|
@@ -1430,28 +1441,28 @@ function $(t = {}) {
|
|
|
1430
1441
|
}
|
|
1431
1442
|
}
|
|
1432
1443
|
},
|
|
1433
|
-
|
|
1444
|
+
te({
|
|
1434
1445
|
include: t.root ? RegExp(`${t.root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/.*\\.(?:vue|td)$`) : /\.(?:vue|td)$/,
|
|
1435
1446
|
template: { transformAssetUrls: !1 }
|
|
1436
1447
|
}),
|
|
1437
|
-
...
|
|
1448
|
+
...ee()
|
|
1438
1449
|
];
|
|
1439
1450
|
}
|
|
1440
|
-
function
|
|
1451
|
+
function It(e) {
|
|
1441
1452
|
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
1442
1453
|
}
|
|
1443
|
-
function
|
|
1444
|
-
for (let t of
|
|
1454
|
+
function Lt(e) {
|
|
1455
|
+
for (let t of It(e)) e.moduleGraph.invalidateModule(t);
|
|
1445
1456
|
e.hot.send({ type: "full-reload" });
|
|
1446
1457
|
}
|
|
1447
|
-
function
|
|
1448
|
-
let t =
|
|
1458
|
+
function Rt(e) {
|
|
1459
|
+
let t = It(e).map((t) => (e.moduleGraph.invalidateModule(t), zt(t)));
|
|
1449
1460
|
0 < t.length && e.hot.send({
|
|
1450
1461
|
type: "update",
|
|
1451
1462
|
updates: t
|
|
1452
1463
|
});
|
|
1453
1464
|
}
|
|
1454
|
-
function
|
|
1465
|
+
function zt(e) {
|
|
1455
1466
|
return {
|
|
1456
1467
|
type: "js-update",
|
|
1457
1468
|
path: e.url,
|
|
@@ -1459,11 +1470,11 @@ function Rt(e) {
|
|
|
1459
1470
|
timestamp: Date.now()
|
|
1460
1471
|
};
|
|
1461
1472
|
}
|
|
1462
|
-
function
|
|
1473
|
+
function Bt(e) {
|
|
1463
1474
|
for (let t of e) {
|
|
1464
|
-
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ?
|
|
1465
|
-
console.error(` ${n} ${e} ${t.message} ${
|
|
1475
|
+
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? T.red("error") : T.yellow("warn");
|
|
1476
|
+
console.error(` ${n} ${e} ${t.message} ${T.dim(`(${t.code})`)}`);
|
|
1466
1477
|
}
|
|
1467
1478
|
}
|
|
1468
1479
|
//#endregion
|
|
1469
|
-
export {
|
|
1480
|
+
export { M as a, W as i, Q as n, U as r, $ as t };
|