typerighter 0.36.0 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-I-BVWGvX.js → app-Dp7FPdlU.js} +1 -1
- package/dist/{cli-gWL2iV9t.js → cli-CAX9mFxL.js} +9 -8
- package/dist/cli.js +1 -1
- package/dist/client/theme-default.js +438 -422
- package/dist/client.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{init-B4qgEdbu.js → init-CshzGwys.js} +3 -3
- package/dist/node/cli/index.d.ts.map +1 -1
- 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/middleware/vault-assets.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-hpG9wf_j.js → shared-DwnQV3ZZ.js} +67 -62
- package/dist/shared.js +2 -2
- package/dist/typerighter.css +1 -1
- package/dist/{vite-3b1YMuxJ.js → vite-tIS_9gV0.js} +207 -217
- package/dist/vite.js +1 -1
- package/package.json +8 -5
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { F as e,
|
|
1
|
+
import { F as e, I as t, K as n, M as r, P as i, R as a, S as o, T as s, U as c, W as l, _ as u, g as d, h as f, m as p, p as m, q as h, s as g, u as _, v, w as y, z as b } from "./shared-DwnQV3ZZ.js";
|
|
2
2
|
import { t as x } from "./temml-DZbhOfRE.js";
|
|
3
3
|
import { t as S } from "./es-ClqUVRJn.js";
|
|
4
4
|
import C, { resolve as w } from "node:path";
|
|
5
5
|
import T from "picocolors";
|
|
6
6
|
import ee from "@tailwindcss/vite";
|
|
7
7
|
import te from "@vitejs/plugin-vue";
|
|
8
|
-
import { build as
|
|
9
|
-
import
|
|
10
|
-
import { createHighlighter as
|
|
11
|
-
import
|
|
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
12
|
import { RpcServer as fe } from "@typerighter/rpc-server";
|
|
13
13
|
import { RPC_CANCELLED_CODE as pe, RpcClient as me } from "@typerighter/rpc-client";
|
|
14
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 = g(e.title), n = g(e.description), r = e.siteTitle !== void 0 && e.title !== e.siteTitle ? `${t} - ${g(e.siteTitle)}` : t, i = e.canonicalUrl === void 0 ? "" : `\n <link rel="canonical" href="${g(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,
|
|
@@ -53,12 +53,12 @@ ${a} </head>
|
|
|
53
53
|
}
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/node/build/prerender.ts
|
|
56
|
-
async function
|
|
57
|
-
let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await
|
|
56
|
+
async function ge(e) {
|
|
57
|
+
let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await _e(e.clientOutDir), a = e.pagePaths.length, o = 0, s = [r.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), i.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n")].filter(Boolean).join("\n") || void 0;
|
|
58
58
|
for (let r = 0; r < a; r += 32) {
|
|
59
59
|
let i = e.pagePaths.slice(r, r + 32);
|
|
60
60
|
await Promise.all(i.map(async (r) => {
|
|
61
|
-
let i = await t.render(r), c =
|
|
61
|
+
let i = await t.render(r), c = k({
|
|
62
62
|
title: i.pageData.title,
|
|
63
63
|
description: i.pageData.frontmatter.description === void 0 ? "" : String(i.pageData.frontmatter.description),
|
|
64
64
|
siteTitle: e.siteTitle,
|
|
@@ -68,12 +68,12 @@ async function _e(e) {
|
|
|
68
68
|
headExtra: s,
|
|
69
69
|
appContent: i.html
|
|
70
70
|
}), l = r === "/" ? "index.html" : `${r.replace(/^\//, "")}.html`, u = C.join(e.outDir, l);
|
|
71
|
-
await
|
|
71
|
+
await E.mkdir(C.dirname(u), { recursive: !0 }), await E.writeFile(u, c), o++, e.progress?.update(o, a);
|
|
72
72
|
}));
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
async function
|
|
76
|
-
let t = C.join(e, ".vite", "manifest.json"), n = await
|
|
75
|
+
async function _e(e) {
|
|
76
|
+
let t = C.join(e, ".vite", "manifest.json"), n = await E.readFile(t, "utf-8"), r = JSON.parse(n), i = "", a = [], o = [];
|
|
77
77
|
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);
|
|
78
78
|
return {
|
|
79
79
|
clientEntry: i,
|
|
@@ -83,12 +83,12 @@ async function ve(e) {
|
|
|
83
83
|
}
|
|
84
84
|
//#endregion
|
|
85
85
|
//#region src/node/lib/progress.ts
|
|
86
|
-
var
|
|
86
|
+
var A = [
|
|
87
87
|
"◐",
|
|
88
88
|
"◓",
|
|
89
89
|
"◑",
|
|
90
90
|
"◒"
|
|
91
|
-
],
|
|
91
|
+
], j = class {
|
|
92
92
|
logger;
|
|
93
93
|
label;
|
|
94
94
|
start;
|
|
@@ -96,8 +96,8 @@ var k = [
|
|
|
96
96
|
constructor(e, t) {
|
|
97
97
|
if (this.logger = e, this.label = t, this.start = performance.now(), process.stdout.isTTY) {
|
|
98
98
|
let e = 0;
|
|
99
|
-
process.stdout.write(T.cyan(`${
|
|
100
|
-
e = (e + 1) %
|
|
99
|
+
process.stdout.write(T.cyan(`${A[0]} ${t}`)), this.spinnerInterval = setInterval(() => {
|
|
100
|
+
e = (e + 1) % A.length, process.stdout.write(`\r${T.cyan(`${A[e]} ${this.label}`)}`);
|
|
101
101
|
}, 120).unref();
|
|
102
102
|
} else this.logger.start(t);
|
|
103
103
|
}
|
|
@@ -109,21 +109,21 @@ var k = [
|
|
|
109
109
|
done(e) {
|
|
110
110
|
this.stopSpinner(), process.stdout.isTTY && process.stdout.write("\r\x1B[K");
|
|
111
111
|
let t = Math.round(performance.now() - this.start);
|
|
112
|
-
this.logger.success(`${e} (${
|
|
112
|
+
this.logger.success(`${e} (${ve(t)})`);
|
|
113
113
|
}
|
|
114
114
|
stopSpinner() {
|
|
115
115
|
this.spinnerInterval &&= (clearInterval(this.spinnerInterval), void 0);
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
|
-
function
|
|
118
|
+
function ve(e) {
|
|
119
119
|
return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
|
|
120
120
|
}
|
|
121
121
|
//#endregion
|
|
122
122
|
//#region src/node/build/index.ts
|
|
123
|
-
var
|
|
124
|
-
async function
|
|
125
|
-
let { root: n, logger: r } = e, i = C.resolve(n, t.outDir ?? "dist"),
|
|
126
|
-
await
|
|
123
|
+
var ye = "typerighter/client/theme-default";
|
|
124
|
+
async function M(e, t = {}) {
|
|
125
|
+
let { root: n, logger: r } = e, i = C.resolve(n, t.outDir ?? "dist"), o = C.join(i, ".client"), s = C.join(i, ".server");
|
|
126
|
+
await E.rm(i, {
|
|
127
127
|
recursive: !0,
|
|
128
128
|
force: !0
|
|
129
129
|
});
|
|
@@ -132,47 +132,47 @@ async function j(e, t = {}) {
|
|
|
132
132
|
c.listFiles(),
|
|
133
133
|
c.listSidebar(),
|
|
134
134
|
c.listSchemas()
|
|
135
|
-
]), p = t.base ?? l.basePath ?? "/",
|
|
135
|
+
]), p = t.base ?? l.basePath ?? "/", h = p.endsWith("/") ? p : p + "/", g = d.map((e) => ({
|
|
136
136
|
...e,
|
|
137
137
|
header: {}
|
|
138
|
-
})), _ = g
|
|
138
|
+
})), _ = m(g), v = JSON.stringify({
|
|
139
139
|
title: l.siteTitle,
|
|
140
140
|
description: l.siteDescription,
|
|
141
|
-
basePath:
|
|
141
|
+
basePath: h,
|
|
142
142
|
nav: l.nav
|
|
143
143
|
}), y = JSON.stringify({
|
|
144
144
|
ready: !0,
|
|
145
145
|
contentTree: _
|
|
146
146
|
}), b = C.join(n, "node_modules", ".typerighter");
|
|
147
|
-
await
|
|
147
|
+
await E.mkdir(b, { recursive: !0 });
|
|
148
148
|
let x = C.join(b, "client-entry.js"), S = C.join(b, "ssr-entry.js");
|
|
149
|
-
await Promise.all([
|
|
149
|
+
await Promise.all([E.writeFile(x, Q({
|
|
150
150
|
rootDir: l.rootDir,
|
|
151
|
-
basePath:
|
|
151
|
+
basePath: h,
|
|
152
152
|
siteTitle: l.siteTitle,
|
|
153
153
|
siteDescription: l.siteDescription,
|
|
154
154
|
repo: l.repo,
|
|
155
155
|
author: l.author,
|
|
156
156
|
license: l.license,
|
|
157
157
|
nav: l.nav
|
|
158
|
-
})),
|
|
158
|
+
})), E.writeFile(S, be({
|
|
159
159
|
rootDir: l.rootDir,
|
|
160
|
-
layoutImport:
|
|
160
|
+
layoutImport: ye,
|
|
161
161
|
siteConfig: v,
|
|
162
162
|
siteData: y
|
|
163
163
|
}))]);
|
|
164
164
|
try {
|
|
165
|
-
let c = $({ context: e }), d = e.createViteLogger(), f = new
|
|
166
|
-
await
|
|
165
|
+
let c = $({ context: e }), d = e.createViteLogger(), f = new j(r, "Building client bundle...");
|
|
166
|
+
await ne({
|
|
167
167
|
...t.viteConfig,
|
|
168
168
|
root: n,
|
|
169
|
-
base:
|
|
169
|
+
base: h,
|
|
170
170
|
plugins: c,
|
|
171
171
|
customLogger: d,
|
|
172
172
|
logLevel: "silent",
|
|
173
173
|
build: {
|
|
174
174
|
...t.viteConfig?.build,
|
|
175
|
-
outDir:
|
|
175
|
+
outDir: o,
|
|
176
176
|
manifest: !0,
|
|
177
177
|
emptyOutDir: !0,
|
|
178
178
|
rollupOptions: {
|
|
@@ -181,55 +181,55 @@ async function j(e, t = {}) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
|
-
let p = await
|
|
184
|
+
let p = await E.readdir(C.join(o, "assets")).catch(() => []);
|
|
185
185
|
f.done(`Client bundle (${p.length} chunks)`);
|
|
186
|
-
let
|
|
187
|
-
await
|
|
186
|
+
let m = new j(r, "Building SSR bundle...");
|
|
187
|
+
await ne({
|
|
188
188
|
...t.viteConfig,
|
|
189
189
|
root: n,
|
|
190
|
-
base:
|
|
190
|
+
base: h,
|
|
191
191
|
plugins: c,
|
|
192
192
|
customLogger: d,
|
|
193
193
|
logLevel: "silent",
|
|
194
194
|
build: {
|
|
195
195
|
...t.viteConfig?.build,
|
|
196
|
-
outDir:
|
|
196
|
+
outDir: s,
|
|
197
197
|
ssr: S,
|
|
198
198
|
emptyOutDir: !0
|
|
199
199
|
}
|
|
200
|
-
}),
|
|
200
|
+
}), m.done("SSR bundle");
|
|
201
201
|
let g = u.map((e) => {
|
|
202
|
-
let t =
|
|
202
|
+
let t = a(e);
|
|
203
203
|
return t === "index" ? "/" : `/${t}`;
|
|
204
204
|
});
|
|
205
|
-
g.push("/"),
|
|
206
|
-
let v = new
|
|
207
|
-
await
|
|
208
|
-
ssrEntryPath: C.join(
|
|
209
|
-
clientOutDir:
|
|
205
|
+
g.push("/"), N(_.entries, "", g);
|
|
206
|
+
let v = new j(r, "Pre-rendering pages...");
|
|
207
|
+
await ge({
|
|
208
|
+
ssrEntryPath: C.join(s, "ssr-entry.js"),
|
|
209
|
+
clientOutDir: o,
|
|
210
210
|
outDir: i,
|
|
211
|
-
base:
|
|
211
|
+
base: h,
|
|
212
212
|
pagePaths: g,
|
|
213
213
|
siteTitle: l.siteTitle,
|
|
214
214
|
progress: v
|
|
215
215
|
}), v.done(`Pre-rendered ${g.length} pages`);
|
|
216
|
-
let y =
|
|
217
|
-
await
|
|
218
|
-
let b = C.join(
|
|
219
|
-
await
|
|
216
|
+
let y = Se(g, h);
|
|
217
|
+
await E.writeFile(C.join(i, "sitemap.xml"), y);
|
|
218
|
+
let b = C.join(o, "assets"), w = C.join(i, "assets");
|
|
219
|
+
await E.cp(b, w, { recursive: !0 }).catch(() => {}), await xe(C.join(n, l.rootDir), i);
|
|
220
220
|
let T = C.join(n, l.publicDir);
|
|
221
|
-
await
|
|
221
|
+
await E.cp(T, i, { recursive: !0 }).catch(() => {});
|
|
222
222
|
} finally {
|
|
223
223
|
await Promise.all([
|
|
224
|
-
|
|
224
|
+
E.rm(b, {
|
|
225
225
|
recursive: !0,
|
|
226
226
|
force: !0
|
|
227
227
|
}),
|
|
228
|
-
|
|
228
|
+
E.rm(o, {
|
|
229
229
|
recursive: !0,
|
|
230
230
|
force: !0
|
|
231
231
|
}),
|
|
232
|
-
|
|
232
|
+
E.rm(s, {
|
|
233
233
|
recursive: !0,
|
|
234
234
|
force: !0
|
|
235
235
|
})
|
|
@@ -237,10 +237,10 @@ async function j(e, t = {}) {
|
|
|
237
237
|
}
|
|
238
238
|
r.log(`\nBuild complete. Output: ${i}`);
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
let t = `/${e.rootDir}/${
|
|
242
|
-
...
|
|
243
|
-
directoryListings:
|
|
240
|
+
function be(e) {
|
|
241
|
+
let t = `/${e.rootDir}/${l}`, n = JSON.parse(e.siteConfig), r = JSON.parse(e.siteData), i = r.contentTree ?? { entries: [] }, a = p(i.entries ?? [], n.title ?? ""), o = JSON.stringify({
|
|
242
|
+
...r,
|
|
243
|
+
directoryListings: a
|
|
244
244
|
});
|
|
245
245
|
return `
|
|
246
246
|
import { createTypedownApp } from 'typerighter/client';
|
|
@@ -251,8 +251,8 @@ import { h } from 'vue';
|
|
|
251
251
|
import theme from '${e.layoutImport}';
|
|
252
252
|
|
|
253
253
|
const pages = import.meta.glob('${t}', { eager: true });
|
|
254
|
-
const contentExts = ${JSON.stringify(
|
|
255
|
-
const siteData = ${
|
|
254
|
+
const contentExts = ${JSON.stringify(c)};
|
|
255
|
+
const siteData = ${o};
|
|
256
256
|
|
|
257
257
|
function findPage(base) {
|
|
258
258
|
for (const ext of contentExts) {
|
|
@@ -286,39 +286,39 @@ export async function render(url) {
|
|
|
286
286
|
}
|
|
287
287
|
`;
|
|
288
288
|
}
|
|
289
|
-
async function
|
|
290
|
-
let r = (await
|
|
289
|
+
async function xe(t, n) {
|
|
290
|
+
let r = (await E.readdir(t, {
|
|
291
291
|
recursive: !0,
|
|
292
292
|
withFileTypes: !0
|
|
293
293
|
})).filter((t) => t.isFile() && !e(t.name)).map(async (e) => {
|
|
294
294
|
let r = C.join(e.parentPath, e.name), i = C.relative(t, r), a = C.join(n, i);
|
|
295
|
-
return
|
|
295
|
+
return E.mkdir(C.dirname(a), { recursive: !0 }).then(() => E.copyFile(r, a));
|
|
296
296
|
});
|
|
297
297
|
await Promise.all(r);
|
|
298
298
|
}
|
|
299
|
-
function
|
|
299
|
+
function Se(e, t) {
|
|
300
300
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
301
301
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
302
|
-
${e.map((e) => ` <url><loc>${
|
|
302
|
+
${e.map((e) => ` <url><loc>${g(t + e.replace(/^\//, ""))}</loc></url>`).join("\n")}
|
|
303
303
|
</urlset>
|
|
304
304
|
`;
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function N(e, t, n) {
|
|
307
307
|
for (let r of e) {
|
|
308
308
|
if (r.kind !== "dir") continue;
|
|
309
309
|
let e = `${t}/${r.node.name}`;
|
|
310
|
-
|
|
310
|
+
f(r.node) || n.push(o(e)), N(r.node.entries, e, n);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
313
|
//#endregion
|
|
314
314
|
//#region ../../node_modules/.pnpm/@shikijs+transformers@4.4.3/node_modules/@shikijs/transformers/dist/index.mjs
|
|
315
|
-
var
|
|
315
|
+
var Ce = /(\s+\/\/)/, we = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/, Te = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/, Ee = [
|
|
316
316
|
[/^(<!--)(.+)(-->)$/, !1],
|
|
317
317
|
[/^(\/\*)(.+)(\*\/)$/, !1],
|
|
318
318
|
[/^(\/\/|["'#]|;{1,2}|%{1,2}|--)(.*)$/, !0],
|
|
319
319
|
[/^(\*)(.+)$/, !0]
|
|
320
320
|
];
|
|
321
|
-
function
|
|
321
|
+
function De(e, t, n) {
|
|
322
322
|
let r = [];
|
|
323
323
|
for (let i of e) {
|
|
324
324
|
if (n === "v3") {
|
|
@@ -327,8 +327,8 @@ function Oe(e, t, n) {
|
|
|
327
327
|
let n = e.children[0];
|
|
328
328
|
if (n.type !== "text") return e;
|
|
329
329
|
let r = t === i.children.length - 1;
|
|
330
|
-
if (!
|
|
331
|
-
let a = n.value.split(
|
|
330
|
+
if (!F(n.value, r)) return e;
|
|
331
|
+
let a = n.value.split(Ce);
|
|
332
332
|
if (a.length <= 1) return e;
|
|
333
333
|
let o = [a[0]];
|
|
334
334
|
for (let e = 1; e < a.length; e += 2) o.push(a[e] + (a[e + 1] || ""));
|
|
@@ -349,13 +349,13 @@ function Oe(e, t, n) {
|
|
|
349
349
|
if (a.type !== "element") continue;
|
|
350
350
|
let o = a.children.at(0);
|
|
351
351
|
if (o?.type !== "text") continue;
|
|
352
|
-
let s = n === e.length - 1, c =
|
|
352
|
+
let s = n === e.length - 1, c = F(o.value, s), l;
|
|
353
353
|
if (!c && n > 0 && o.value.trim().startsWith("[!code")) {
|
|
354
354
|
let t = e[n - 1];
|
|
355
355
|
if (t?.type === "element") {
|
|
356
356
|
let n = t.children.at(0);
|
|
357
357
|
if (n?.type === "text" && n.value.includes("//")) {
|
|
358
|
-
let l =
|
|
358
|
+
let l = F(n.value + o.value, s);
|
|
359
359
|
if (l) {
|
|
360
360
|
c = l, r.push({
|
|
361
361
|
info: l,
|
|
@@ -372,7 +372,7 @@ function Oe(e, t, n) {
|
|
|
372
372
|
}
|
|
373
373
|
if (c) {
|
|
374
374
|
if (t && !s && n !== 0) {
|
|
375
|
-
let t =
|
|
375
|
+
let t = P(e[n - 1], "{") && P(e[n + 1], "}");
|
|
376
376
|
r.push({
|
|
377
377
|
info: c,
|
|
378
378
|
line: i,
|
|
@@ -394,16 +394,16 @@ function Oe(e, t, n) {
|
|
|
394
394
|
}
|
|
395
395
|
return r;
|
|
396
396
|
}
|
|
397
|
-
function
|
|
397
|
+
function P(e, t) {
|
|
398
398
|
if (e.type !== "element") return !1;
|
|
399
399
|
let n = e.children[0];
|
|
400
400
|
return n.type === "text" && n.value.trim() === t;
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function F(e, t) {
|
|
403
403
|
let n = e.trimStart(), r = e.length - n.length;
|
|
404
404
|
n = n.trimEnd();
|
|
405
405
|
let i = e.length - n.length - r;
|
|
406
|
-
for (let [e, a] of
|
|
406
|
+
for (let [e, a] of Ee) {
|
|
407
407
|
if (a && !t) continue;
|
|
408
408
|
let o = e.exec(n);
|
|
409
409
|
if (o) return [
|
|
@@ -413,22 +413,22 @@ function P(e, t) {
|
|
|
413
413
|
];
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
let t = e.match(
|
|
416
|
+
function Oe(e) {
|
|
417
|
+
let t = e.match(we);
|
|
418
418
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index) : e;
|
|
419
419
|
}
|
|
420
|
-
function
|
|
421
|
-
let t = e.match(
|
|
420
|
+
function ke(e) {
|
|
421
|
+
let t = e.match(Te);
|
|
422
422
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index).trimEnd() : e;
|
|
423
423
|
}
|
|
424
|
-
function
|
|
424
|
+
function Ae(e, t, n, r) {
|
|
425
425
|
return r ??= "v3", {
|
|
426
426
|
name: e,
|
|
427
427
|
code(e) {
|
|
428
428
|
let i = e.children.filter((e) => e.type === "element"), a = [];
|
|
429
429
|
e.data ??= {};
|
|
430
430
|
let o = e.data;
|
|
431
|
-
o._shiki_notation ??=
|
|
431
|
+
o._shiki_notation ??= De(i, ["jsx", "tsx"].includes(this.options.lang), r);
|
|
432
432
|
let s = o._shiki_notation;
|
|
433
433
|
for (let e of s) {
|
|
434
434
|
if (e.info[1].length === 0) continue;
|
|
@@ -436,7 +436,7 @@ function je(e, t, n, r) {
|
|
|
436
436
|
e.isLineCommentOnly && r !== "v1" && o++;
|
|
437
437
|
let s = !1;
|
|
438
438
|
if (e.info[1] = e.info[1].replace(t, (...t) => n.call(this, t, e.line, e.token, i, o) ? (s = !0, "") : t[0]), !s) continue;
|
|
439
|
-
r === "v1" ? e.info[1] =
|
|
439
|
+
r === "v1" ? e.info[1] = Oe(e.info[1]) : r === "v3" && (e.info[1] = ke(e.info[1]));
|
|
440
440
|
let c = e.info[1].trim().length === 0;
|
|
441
441
|
if (c && (e.info[1] = ""), c && e.isLineCommentOnly) a.push(e.line);
|
|
442
442
|
else if (c && e.isJsxStyle) e.line.children.splice(e.line.children.indexOf(e.token) - 1, 3);
|
|
@@ -461,44 +461,44 @@ function je(e, t, n, r) {
|
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
|
-
var
|
|
465
|
-
function
|
|
464
|
+
var je = /\{([\d,-]+)\}/;
|
|
465
|
+
function Me(e) {
|
|
466
466
|
if (!e) return null;
|
|
467
|
-
let t = e.match(
|
|
467
|
+
let t = e.match(je);
|
|
468
468
|
return t ? t[1].split(",").flatMap((e) => {
|
|
469
469
|
let t = e.split("-").map((e) => Number.parseInt(e, 10));
|
|
470
470
|
return t.length === 1 ? [t[0]] : Array.from({ length: t[1] - t[0] + 1 }, (e, n) => t[0] + n);
|
|
471
471
|
}) : null;
|
|
472
472
|
}
|
|
473
|
-
var
|
|
474
|
-
function
|
|
473
|
+
var Ne = Symbol("highlighted-lines");
|
|
474
|
+
function Pe(e = {}) {
|
|
475
475
|
let { className: t = "highlighted", zeroIndexed: n = !1 } = e;
|
|
476
476
|
return {
|
|
477
477
|
name: "@shikijs/transformers:meta-highlight",
|
|
478
478
|
line(e, r) {
|
|
479
479
|
if (!this.options.meta?.__raw) return;
|
|
480
480
|
let i = this.meta;
|
|
481
|
-
i[
|
|
482
|
-
let a = i[
|
|
481
|
+
i[Ne] ??= Me(this.options.meta.__raw);
|
|
482
|
+
let a = i[Ne] ?? [], o = n ? r - 1 : r;
|
|
483
483
|
return a.includes(o) && this.addClassToHast(e, t), e;
|
|
484
484
|
}
|
|
485
485
|
};
|
|
486
486
|
}
|
|
487
|
-
var
|
|
488
|
-
function
|
|
489
|
-
return e.replace(
|
|
487
|
+
var Fe = /[.*+?^${}()|[\]\\]/g;
|
|
488
|
+
function Ie(e) {
|
|
489
|
+
return e.replace(Fe, "\\$&");
|
|
490
490
|
}
|
|
491
|
-
function
|
|
491
|
+
function I(e = {}, t = "@shikijs/transformers:notation-map") {
|
|
492
492
|
let { classMap: n = {}, classActivePre: r = void 0, classActiveCode: i = void 0 } = e;
|
|
493
|
-
return
|
|
493
|
+
return Ae(t, RegExp(`#?\\s*\\[!code (${Object.keys(n).map(Ie).join("|")})(:\\d+)?\\]`, "gi"), function([e, t, a = ":1"], o, s, c, l) {
|
|
494
494
|
let u = Number.parseInt(a.slice(1), 10);
|
|
495
495
|
for (let e = l; e < Math.min(l + u, c.length); e++) this.addClassToHast(c[e], n[t]);
|
|
496
496
|
return r && this.addClassToHast(this.pre, r), i && this.addClassToHast(this.code, i), !0;
|
|
497
497
|
}, e.matchAlgorithm);
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function Le(e = {}) {
|
|
500
500
|
let { classLineAdd: t = "diff add", classLineRemove: n = "diff remove", classActivePre: r = "has-diff", classActiveCode: i } = e;
|
|
501
|
-
return
|
|
501
|
+
return I({
|
|
502
502
|
classMap: {
|
|
503
503
|
"++": t,
|
|
504
504
|
"--": n
|
|
@@ -508,31 +508,31 @@ function Re(e = {}) {
|
|
|
508
508
|
matchAlgorithm: e.matchAlgorithm
|
|
509
509
|
}, "@shikijs/transformers:notation-diff");
|
|
510
510
|
}
|
|
511
|
-
function
|
|
511
|
+
function Re(e = {}) {
|
|
512
512
|
let { classMap: t = {
|
|
513
513
|
error: ["highlighted", "error"],
|
|
514
514
|
warning: ["highlighted", "warning"],
|
|
515
515
|
info: ["highlighted", "info"]
|
|
516
516
|
}, classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
517
|
-
return
|
|
517
|
+
return I({
|
|
518
518
|
classMap: t,
|
|
519
519
|
classActivePre: n,
|
|
520
520
|
classActiveCode: r,
|
|
521
521
|
matchAlgorithm: e.matchAlgorithm
|
|
522
522
|
}, "@shikijs/transformers:notation-error-level");
|
|
523
523
|
}
|
|
524
|
-
function
|
|
524
|
+
function ze(e = {}) {
|
|
525
525
|
let { classActiveLine: t = "focused", classActivePre: n = "has-focused", classActiveCode: r } = e;
|
|
526
|
-
return
|
|
526
|
+
return I({
|
|
527
527
|
classMap: { focus: t },
|
|
528
528
|
classActivePre: n,
|
|
529
529
|
classActiveCode: r,
|
|
530
530
|
matchAlgorithm: e.matchAlgorithm
|
|
531
531
|
}, "@shikijs/transformers:notation-focus");
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function Be(e = {}) {
|
|
534
534
|
let { classActiveLine: t = "highlighted", classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
535
|
-
return
|
|
535
|
+
return I({
|
|
536
536
|
classMap: {
|
|
537
537
|
highlight: t,
|
|
538
538
|
hl: t
|
|
@@ -544,26 +544,26 @@ function Ve(e = {}) {
|
|
|
544
544
|
}
|
|
545
545
|
//#endregion
|
|
546
546
|
//#region src/node/lib/render/highlight/language.ts
|
|
547
|
-
var
|
|
547
|
+
var Ve = [
|
|
548
548
|
"shellscript",
|
|
549
549
|
"shell",
|
|
550
550
|
"bash",
|
|
551
551
|
"sh",
|
|
552
552
|
"zsh"
|
|
553
553
|
];
|
|
554
|
-
function
|
|
555
|
-
return
|
|
554
|
+
function He(e) {
|
|
555
|
+
return Ve.includes(e);
|
|
556
556
|
}
|
|
557
|
-
var
|
|
558
|
-
function
|
|
559
|
-
return
|
|
557
|
+
var Ue = /^[a-zA-Z0-9-_]+/;
|
|
558
|
+
function We(e) {
|
|
559
|
+
return Ue.exec(e)?.[0] || "";
|
|
560
560
|
}
|
|
561
561
|
//#endregion
|
|
562
562
|
//#region src/node/lib/logger.ts
|
|
563
|
-
var
|
|
563
|
+
var Ge = /\u001B\[[0-9;]*m/g, Ke = class {
|
|
564
564
|
logStream;
|
|
565
565
|
constructor(e) {
|
|
566
|
-
e !== void 0 && (this.logStream =
|
|
566
|
+
e !== void 0 && (this.logStream = D.createWriteStream(e, { flags: "a" }), process.once("exit", () => this.close()));
|
|
567
567
|
}
|
|
568
568
|
info(e) {
|
|
569
569
|
console.log(T.cyan(`ℹ ${e}`)), this.writeToFile("INFO", e);
|
|
@@ -585,31 +585,31 @@ var Ke = /\u001B\[[0-9;]*m/g, I = class {
|
|
|
585
585
|
}
|
|
586
586
|
writeToFile(e, t) {
|
|
587
587
|
if (!this.logStream) return;
|
|
588
|
-
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.replace(
|
|
588
|
+
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.replace(Ge, "");
|
|
589
589
|
this.logStream.write(`${n} [${e}] ${r}\n`);
|
|
590
590
|
}
|
|
591
591
|
close() {
|
|
592
592
|
this.logStream?.end(), this.logStream = void 0;
|
|
593
593
|
}
|
|
594
|
-
}, qe = new
|
|
594
|
+
}, qe = new Ke(), Je = new FinalizationRegistry((e) => {
|
|
595
595
|
e();
|
|
596
596
|
}), L = {
|
|
597
597
|
light: "github-light",
|
|
598
598
|
dark: "github-dark"
|
|
599
599
|
};
|
|
600
600
|
async function Ye() {
|
|
601
|
-
let e = await
|
|
601
|
+
let e = await ae({
|
|
602
602
|
themes: [L.light, L.dark],
|
|
603
603
|
langs: []
|
|
604
604
|
}), t = [
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
605
|
+
Pe(),
|
|
606
|
+
Le(),
|
|
607
|
+
ze({
|
|
608
608
|
classActiveLine: "has-focus",
|
|
609
609
|
classActivePre: "has-focused-lines"
|
|
610
610
|
}),
|
|
611
|
-
|
|
612
|
-
|
|
611
|
+
Be(),
|
|
612
|
+
Re(),
|
|
613
613
|
Xe(),
|
|
614
614
|
{
|
|
615
615
|
name: "typedown:add-dir",
|
|
@@ -619,19 +619,19 @@ async function Ye() {
|
|
|
619
619
|
}
|
|
620
620
|
], n = new Set(e.getLoadedLanguages());
|
|
621
621
|
async function r(r, i, a) {
|
|
622
|
-
let o =
|
|
622
|
+
let o = We(i);
|
|
623
623
|
if (o) {
|
|
624
624
|
let e = i;
|
|
625
625
|
i = o.toLowerCase(), a = e.slice(i.length).replace(/(?<!=)\{/g, " {") + " " + a, a = a.trim().replace(/\s+/g, " ");
|
|
626
626
|
}
|
|
627
627
|
i ||= "txt";
|
|
628
628
|
try {
|
|
629
|
-
!
|
|
629
|
+
!se(i) && !n.has(i) && (await e.loadLanguage(i), n.add(i));
|
|
630
630
|
} catch {
|
|
631
631
|
qe.warn(`\nThe language '${i}' is not loaded, falling back to 'txt' for syntax highlighting.`), i = "txt";
|
|
632
632
|
}
|
|
633
633
|
r = r.trimEnd();
|
|
634
|
-
let s =
|
|
634
|
+
let s = oe(r, i, e);
|
|
635
635
|
return await e.loadLanguage(...s), e.codeToHtml(r, {
|
|
636
636
|
lang: i,
|
|
637
637
|
transformers: [...t, {
|
|
@@ -679,7 +679,7 @@ function Xe() {
|
|
|
679
679
|
return {
|
|
680
680
|
name: "typedown:disable-shell-symbol-select",
|
|
681
681
|
tokens(e) {
|
|
682
|
-
if (
|
|
682
|
+
if (He(this.options.lang)) for (let t of e) {
|
|
683
683
|
if (t.length < 2) continue;
|
|
684
684
|
let e = t[0].content.trim();
|
|
685
685
|
(e === "$" || e === ">") && t[1].content[0] === " " && (t[0].content = e + " ", t[0].htmlStyle ??= {}, t[0].htmlStyle["user-select"] = "none", t[0].htmlStyle["-webkit-user-select"] = "none", t[1].content = t[1].content.slice(1));
|
|
@@ -701,7 +701,7 @@ async function et(e) {
|
|
|
701
701
|
let t = await Qe(), n = [...e.matchAll($e)];
|
|
702
702
|
if (n.length === 0) return e;
|
|
703
703
|
let r = await Promise.all(n.map(async (e) => {
|
|
704
|
-
let n = e[1] || "", r = e[2] || "", i =
|
|
704
|
+
let n = e[1] || "", r = e[2] || "", i = _(e[3]);
|
|
705
705
|
return tt(await t(i, n, r), n, r);
|
|
706
706
|
})), i = e;
|
|
707
707
|
for (let e = n.length - 1; 0 <= e; e--) {
|
|
@@ -728,7 +728,7 @@ function it(e) {
|
|
|
728
728
|
function z(e, t) {
|
|
729
729
|
let n = t ? "div" : "span";
|
|
730
730
|
try {
|
|
731
|
-
return x.renderToString(
|
|
731
|
+
return x.renderToString(_(e), {
|
|
732
732
|
throwOnError: !1,
|
|
733
733
|
displayMode: t
|
|
734
734
|
});
|
|
@@ -739,7 +739,7 @@ function z(e, t) {
|
|
|
739
739
|
//#endregion
|
|
740
740
|
//#region src/node/lib/render/vue.ts
|
|
741
741
|
async function B(e, t, n) {
|
|
742
|
-
let r = t.title || t.label || (
|
|
742
|
+
let r = t.title || t.label || (v(n) ? d(n, (await e.getConfig()).siteTitle) : u(n));
|
|
743
743
|
return {
|
|
744
744
|
schema: t.schema,
|
|
745
745
|
schemaLabel: t.schemaLabel,
|
|
@@ -803,19 +803,13 @@ var ct = class {
|
|
|
803
803
|
registerNotificationHandlers(e) {
|
|
804
804
|
e.onConfigChanged((e) => {
|
|
805
805
|
this.cachedConfig = e;
|
|
806
|
-
}), e.
|
|
807
|
-
this.cachedFileMap.delete(e);
|
|
808
|
-
for (let e of t) this.cachedFileMap.delete(e);
|
|
809
|
-
}), e.onContentCreated(({ filepath: e }) => {
|
|
806
|
+
}), e.onContentUpdated(({ filepath: e, affectedFiles: t = [] }) => {
|
|
810
807
|
this.cachedFiles = void 0, this.cachedFileMap.delete(e);
|
|
811
|
-
|
|
812
|
-
this.cachedFiles = void 0, this.cachedFileMap.delete(e), t !== void 0 && this.cachedFileMap.delete(t);
|
|
808
|
+
for (let e of t) this.cachedFileMap.delete(e);
|
|
813
809
|
}), e.onContentDeleted(({ filepath: e }) => {
|
|
814
810
|
this.cachedFiles = void 0, this.cachedFileMap.delete(e);
|
|
815
|
-
}), e.
|
|
816
|
-
this.cachedSchemaMap.delete(e);
|
|
817
|
-
}), e.onSchemaCreated(() => {
|
|
818
|
-
this.cachedSchemas = void 0;
|
|
811
|
+
}), e.onSchemaUpdated(({ schema: e }) => {
|
|
812
|
+
this.cachedSchemas = void 0, this.cachedSchemaMap.delete(e);
|
|
819
813
|
}), e.onSchemaDeleted(({ schema: e }) => {
|
|
820
814
|
this.cachedSchemas = void 0, this.cachedSchemaMap.delete(e);
|
|
821
815
|
});
|
|
@@ -878,9 +872,9 @@ async function H(e, t = 5) {
|
|
|
878
872
|
//#region src/node/context.ts
|
|
879
873
|
var U = ["typedown.yaml", "typedown.yml"];
|
|
880
874
|
function W(e) {
|
|
881
|
-
let t = new
|
|
875
|
+
let t = new Ke(dt(e));
|
|
882
876
|
function n() {
|
|
883
|
-
let e =
|
|
877
|
+
let e = re("warn");
|
|
884
878
|
return {
|
|
885
879
|
...e,
|
|
886
880
|
info(e) {
|
|
@@ -934,14 +928,14 @@ function lt(e) {
|
|
|
934
928
|
return C.resolve(e);
|
|
935
929
|
}
|
|
936
930
|
function ut(e) {
|
|
937
|
-
return U.some((t) =>
|
|
931
|
+
return U.some((t) => D.existsSync(C.join(e, t)));
|
|
938
932
|
}
|
|
939
933
|
function dt(e) {
|
|
940
934
|
try {
|
|
941
935
|
let t = C.join(e, ".typedown", ".local"), n = C.join(t, "logs");
|
|
942
|
-
|
|
936
|
+
D.mkdirSync(n, { recursive: !0 });
|
|
943
937
|
let r = C.join(t, ".gitignore");
|
|
944
|
-
|
|
938
|
+
D.existsSync(r) || D.writeFileSync(r, "*\n");
|
|
945
939
|
let i = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
946
940
|
return C.join(n, `${i}.log`);
|
|
947
941
|
} catch {
|
|
@@ -988,7 +982,7 @@ var gt = class {
|
|
|
988
982
|
}
|
|
989
983
|
};
|
|
990
984
|
function Q(e) {
|
|
991
|
-
let { rootDir: t = "." } = e,
|
|
985
|
+
let { rootDir: t = "." } = e, n = JSON.stringify({
|
|
992
986
|
title: e.siteTitle,
|
|
993
987
|
description: e.siteDescription,
|
|
994
988
|
basePath: e.basePath ?? "/",
|
|
@@ -1008,7 +1002,7 @@ import theme from 'typerighter/client/theme-default';
|
|
|
1008
1002
|
import { pages as initialPages } from '${K}';
|
|
1009
1003
|
import initialSiteData from '${Y}';
|
|
1010
1004
|
let pages = initialPages;
|
|
1011
|
-
const contentExts = ${JSON.stringify(
|
|
1005
|
+
const contentExts = ${JSON.stringify(c)};
|
|
1012
1006
|
|
|
1013
1007
|
function findPage(base) {
|
|
1014
1008
|
for (const ext of contentExts) {
|
|
@@ -1033,7 +1027,7 @@ async function loadPageModule(pagePath) {
|
|
|
1033
1027
|
return undefined;
|
|
1034
1028
|
}
|
|
1035
1029
|
|
|
1036
|
-
const { app, router, searchIndex: searchIndexRef, siteData } = await createTypedownApp(loadPageModule, theme.Layout, ${
|
|
1030
|
+
const { app, router, searchIndex: searchIndexRef, siteData } = await createTypedownApp(loadPageModule, theme.Layout, ${n}, initialSiteData);
|
|
1037
1031
|
app.mount('#app');
|
|
1038
1032
|
|
|
1039
1033
|
// Load search index in the background after the app is mounted
|
|
@@ -1094,18 +1088,18 @@ var _t = class {
|
|
|
1094
1088
|
}, bt = class {
|
|
1095
1089
|
data;
|
|
1096
1090
|
scan(e) {
|
|
1097
|
-
let t =
|
|
1091
|
+
let t = O("**/*.td", {
|
|
1098
1092
|
cwd: e,
|
|
1099
1093
|
exclude: (e) => e.startsWith("_")
|
|
1100
1094
|
}).map((e) => ({
|
|
1101
1095
|
filepath: e,
|
|
1102
|
-
label:
|
|
1096
|
+
label: u(e),
|
|
1103
1097
|
header: {}
|
|
1104
|
-
})), n =
|
|
1098
|
+
})), n = m(t);
|
|
1105
1099
|
this.data = {
|
|
1106
1100
|
contentTree: n,
|
|
1107
1101
|
schemas: {},
|
|
1108
|
-
directoryListings:
|
|
1102
|
+
directoryListings: p(n.entries, "")
|
|
1109
1103
|
};
|
|
1110
1104
|
}
|
|
1111
1105
|
load(e) {
|
|
@@ -1140,11 +1134,11 @@ async function xt(e) {
|
|
|
1140
1134
|
]), i = await Promise.all(r.map(async (t) => [t, (await e.getSchema(t)).properties])), a = Object.fromEntries(i), o = n.map((e) => ({
|
|
1141
1135
|
...e,
|
|
1142
1136
|
header: {}
|
|
1143
|
-
})), s =
|
|
1137
|
+
})), s = m(o);
|
|
1144
1138
|
return {
|
|
1145
1139
|
contentTree: s,
|
|
1146
1140
|
schemas: a,
|
|
1147
|
-
directoryListings:
|
|
1141
|
+
directoryListings: p(s.entries, t.siteTitle)
|
|
1148
1142
|
};
|
|
1149
1143
|
}
|
|
1150
1144
|
//#endregion
|
|
@@ -1153,8 +1147,8 @@ var St = class {
|
|
|
1153
1147
|
index;
|
|
1154
1148
|
constructor() {
|
|
1155
1149
|
this.index = new S({
|
|
1156
|
-
fields:
|
|
1157
|
-
storeFields:
|
|
1150
|
+
fields: n,
|
|
1151
|
+
storeFields: h
|
|
1158
1152
|
});
|
|
1159
1153
|
}
|
|
1160
1154
|
addAll(e) {
|
|
@@ -1183,10 +1177,10 @@ function Ct(e, t) {
|
|
|
1183
1177
|
}
|
|
1184
1178
|
function wt(e, t, n) {
|
|
1185
1179
|
let r = Et(e, w(e, t));
|
|
1186
|
-
r ? n.addPage(r) : n.discardPage(
|
|
1180
|
+
r ? n.addPage(r) : n.discardPage(y(t));
|
|
1187
1181
|
}
|
|
1188
1182
|
function Tt(e, t) {
|
|
1189
|
-
let n =
|
|
1183
|
+
let n = u(e);
|
|
1190
1184
|
if (!t.startsWith("---")) return {
|
|
1191
1185
|
title: n,
|
|
1192
1186
|
body: t
|
|
@@ -1212,13 +1206,13 @@ function Et(e, t) {
|
|
|
1212
1206
|
if (!n.trim()) return;
|
|
1213
1207
|
let r = t.slice(e.length + 1), { title: i, body: a } = Tt(r, n);
|
|
1214
1208
|
return {
|
|
1215
|
-
id:
|
|
1209
|
+
id: y(r),
|
|
1216
1210
|
title: i,
|
|
1217
1211
|
text: `${i}\n${a}`
|
|
1218
1212
|
};
|
|
1219
1213
|
}
|
|
1220
1214
|
function Dt(e) {
|
|
1221
|
-
return
|
|
1215
|
+
return O("**/*.td", {
|
|
1222
1216
|
cwd: e,
|
|
1223
1217
|
exclude: (e) => e.startsWith("_")
|
|
1224
1218
|
}).map((t) => w(e, t));
|
|
@@ -1270,39 +1264,39 @@ var Mt = {
|
|
|
1270
1264
|
ttf: "font/ttf"
|
|
1271
1265
|
};
|
|
1272
1266
|
function Nt(e, t) {
|
|
1273
|
-
return (n,
|
|
1274
|
-
if (!n.url || n.method !== "GET" ||
|
|
1275
|
-
let
|
|
1276
|
-
if (
|
|
1277
|
-
let
|
|
1278
|
-
if (
|
|
1279
|
-
let e = de(
|
|
1267
|
+
return (n, a, o) => {
|
|
1268
|
+
if (!n.url || n.method !== "GET" || a.writableEnded) return o();
|
|
1269
|
+
let c = s(n.url);
|
|
1270
|
+
if (c.startsWith("/@") || c.startsWith("/node_modules")) return o();
|
|
1271
|
+
let l = r(t.basePath), u = (l && c.startsWith(l) ? c.slice(l.length) : c).replace(/^\//, ""), d = w(e.config.root, t.rootDirectory, u);
|
|
1272
|
+
if (le(d)) try {
|
|
1273
|
+
let e = de(d);
|
|
1280
1274
|
if (e.isFile()) {
|
|
1281
|
-
let t = Mt[
|
|
1282
|
-
|
|
1275
|
+
let t = Mt[i(d).slice(1).toLowerCase()] ?? "application/octet-stream";
|
|
1276
|
+
a.setHeader("Content-Type", t), a.setHeader("Content-Length", e.size), ce(d).pipe(a);
|
|
1283
1277
|
return;
|
|
1284
1278
|
}
|
|
1285
1279
|
} catch {}
|
|
1286
|
-
|
|
1280
|
+
o();
|
|
1287
1281
|
};
|
|
1288
1282
|
}
|
|
1289
1283
|
//#endregion
|
|
1290
1284
|
//#region src/node/plugin/vite/middleware/virtual-html.ts
|
|
1291
1285
|
function Pt(e, t, n) {
|
|
1292
|
-
return (
|
|
1293
|
-
if (!
|
|
1294
|
-
let
|
|
1295
|
-
if (
|
|
1296
|
-
let u =
|
|
1297
|
-
if (u.startsWith("/@") || u.startsWith("/node_modules") ||
|
|
1286
|
+
return (i, a, o) => {
|
|
1287
|
+
if (!i.url) return o();
|
|
1288
|
+
let c = r(s(i.url)), l = r(n.basePath);
|
|
1289
|
+
if (c.startsWith("/@") || c.startsWith("/node_modules") || !c.startsWith(l)) return o();
|
|
1290
|
+
let u = c.slice(l.length);
|
|
1291
|
+
if (u.startsWith("/@") || u.startsWith("/node_modules") || c.includes(".") && !c.endsWith("/index.html")) return o();
|
|
1298
1292
|
t.getConfig().then(async (t) => {
|
|
1299
|
-
let
|
|
1300
|
-
|
|
1293
|
+
let r = await e.transformIndexHtml(i.url ?? "", Ft(n, t));
|
|
1294
|
+
a.setHeader("Content-Type", "text/html"), a.end(r);
|
|
1301
1295
|
}).catch(() => o());
|
|
1302
1296
|
};
|
|
1303
1297
|
}
|
|
1304
1298
|
function Ft(e, t) {
|
|
1305
|
-
return e.devHtml === void 0 && (e.devHtml =
|
|
1299
|
+
return e.devHtml === void 0 && (e.devHtml = k({
|
|
1306
1300
|
title: t.siteTitle,
|
|
1307
1301
|
description: t.siteDescription,
|
|
1308
1302
|
base: "/",
|
|
@@ -1311,29 +1305,29 @@ function Ft(e, t) {
|
|
|
1311
1305
|
}
|
|
1312
1306
|
//#endregion
|
|
1313
1307
|
//#region src/node/plugin/vite/index.ts
|
|
1314
|
-
function $(
|
|
1315
|
-
let
|
|
1308
|
+
function $(n = {}) {
|
|
1309
|
+
let r = n.context, i, a, o, s = new gt(), c = new _t(), l = new bt(), u = new kt(), d = {
|
|
1316
1310
|
devHtml: void 0,
|
|
1317
1311
|
basePath: "/",
|
|
1318
1312
|
rootDirectory: "vault"
|
|
1319
1313
|
};
|
|
1320
|
-
function
|
|
1321
|
-
if (
|
|
1322
|
-
return
|
|
1314
|
+
function f() {
|
|
1315
|
+
if (r === void 0) throw Error("typedown plugin not initialized");
|
|
1316
|
+
return r.getTdContext();
|
|
1323
1317
|
}
|
|
1324
1318
|
return [
|
|
1325
1319
|
{
|
|
1326
1320
|
name: "vite-plugin-typedown",
|
|
1327
1321
|
enforce: "pre",
|
|
1328
1322
|
async config(e) {
|
|
1329
|
-
|
|
1330
|
-
let
|
|
1323
|
+
r ||= W(n.root ? w(e.root ?? process.cwd(), n.root) : lt(e.root ?? process.cwd())), o = e.base ?? "/";
|
|
1324
|
+
let t = await (await f()).getConfig();
|
|
1331
1325
|
return {
|
|
1332
|
-
base: e.base ??
|
|
1333
|
-
publicDir:
|
|
1326
|
+
base: e.base ?? t.basePath,
|
|
1327
|
+
publicDir: t.publicDir,
|
|
1334
1328
|
server: {
|
|
1335
|
-
port: 8686,
|
|
1336
|
-
strictPort: !1
|
|
1329
|
+
port: e.server?.port ?? 8686,
|
|
1330
|
+
strictPort: e.server?.strictPort ?? !1
|
|
1337
1331
|
},
|
|
1338
1332
|
resolve: { alias: jt() },
|
|
1339
1333
|
ssr: { noExternal: ["typerighter"] }
|
|
@@ -1344,7 +1338,7 @@ function $(t = {}) {
|
|
|
1344
1338
|
},
|
|
1345
1339
|
async buildStart() {
|
|
1346
1340
|
if (i) return;
|
|
1347
|
-
let e = await
|
|
1341
|
+
let e = await f(), t = await e.getConfig(), n = w(t.rootDir);
|
|
1348
1342
|
u.index(n), await l.fetchSync(e);
|
|
1349
1343
|
let r = await e.checkVault();
|
|
1350
1344
|
if (Bt(r.diagnostics), 0 < r.errorCount) {
|
|
@@ -1360,9 +1354,9 @@ function $(t = {}) {
|
|
|
1360
1354
|
if (e === "@typedown/search-index") return mt;
|
|
1361
1355
|
},
|
|
1362
1356
|
async load(e) {
|
|
1363
|
-
if (c.isPageDataModule(e)) return c.loadPageData(e, await
|
|
1357
|
+
if (c.isPageDataModule(e)) return c.loadPageData(e, await f());
|
|
1364
1358
|
if (e !== "\0@typedown/search-index" && e !== "\0@typedown/site-data" && e !== "\0@typedown/pages" && e !== "\0@typedown/app") return;
|
|
1365
|
-
let t = await
|
|
1359
|
+
let t = await f();
|
|
1366
1360
|
if (e === "\0@typedown/search-index") return u.load(t);
|
|
1367
1361
|
if (e === "\0@typedown/site-data") return l.load(t);
|
|
1368
1362
|
if (e === "\0@typedown/pages") return c.load(t);
|
|
@@ -1370,21 +1364,19 @@ function $(t = {}) {
|
|
|
1370
1364
|
},
|
|
1371
1365
|
async configureServer(e) {
|
|
1372
1366
|
i = e;
|
|
1373
|
-
let t = await
|
|
1374
|
-
i && l.fetch(t, i);
|
|
1375
|
-
}, 200);
|
|
1367
|
+
let t = await f(), n = await t.getConfig(), r = w(n.rootDir);
|
|
1376
1368
|
u.index(r), l.scan(r), l.fetch(t, i), e.httpServer?.once("listening", async () => {
|
|
1377
1369
|
let e = await t.checkVault();
|
|
1378
1370
|
0 < e.diagnostics.length && (console.error(""), Bt(e.diagnostics));
|
|
1379
1371
|
}), t.rpc.onConfigChanged(() => {
|
|
1380
1372
|
i && (d.devHtml = void 0, l.clear(), s.invalidate(i), c.invalidate(i), Lt(i), l.fetch(t, i));
|
|
1381
1373
|
});
|
|
1382
|
-
function
|
|
1374
|
+
function a(...e) {
|
|
1383
1375
|
i && t.getConfig().then((t) => {
|
|
1384
1376
|
if (!i) return;
|
|
1385
1377
|
let n = [];
|
|
1386
1378
|
for (let r of e) {
|
|
1387
|
-
let e =
|
|
1379
|
+
let e = ie(w(i.config.root, t.rootDir, r)), a = i.moduleGraph.getModulesByFile(e);
|
|
1388
1380
|
if (a?.size) {
|
|
1389
1381
|
for (let e of a) i.moduleGraph.invalidateModule(e), n.push(zt(e));
|
|
1390
1382
|
c.invalidatePageData(i, r);
|
|
@@ -1396,30 +1388,28 @@ function $(t = {}) {
|
|
|
1396
1388
|
});
|
|
1397
1389
|
}).catch(() => {});
|
|
1398
1390
|
}
|
|
1399
|
-
t.rpc.
|
|
1400
|
-
i && (u.
|
|
1391
|
+
t.rpc.onContentUpdated(({ filepath: e, affectedFiles: n = [] }) => {
|
|
1392
|
+
i && (u.index(r), u.invalidate(i), c.invalidate(i), l.clear(), l.fetch(t, i), a(e, ...n));
|
|
1393
|
+
}), t.rpc.onContentDeleted(({ filepath: e }) => {
|
|
1394
|
+
i && (u.index(r), u.invalidate(i), c.invalidate(i), l.clear(), l.fetch(t, i), a(e));
|
|
1401
1395
|
});
|
|
1402
|
-
function
|
|
1403
|
-
i && (u.index(r), u.invalidate(i), c.invalidate(i), l.clear(), l.fetch(t, i), o(e));
|
|
1404
|
-
}
|
|
1405
|
-
t.rpc.onContentCreated(m), t.rpc.onContentDeleted(m), t.rpc.onContentRenamed(m);
|
|
1406
|
-
function h() {
|
|
1396
|
+
function o() {
|
|
1407
1397
|
i && (l.clear(), Rt(i), l.fetch(t, i));
|
|
1408
1398
|
}
|
|
1409
|
-
t.rpc.
|
|
1410
|
-
let
|
|
1411
|
-
d.basePath =
|
|
1399
|
+
t.rpc.onSchemaUpdated(o), t.rpc.onSchemaDeleted(o);
|
|
1400
|
+
let p = await t.getConfig();
|
|
1401
|
+
d.basePath = p.basePath, d.rootDirectory = p.rootDir, t.rpc.onConfigChanged((e) => {
|
|
1412
1402
|
d.basePath = e.basePath, d.rootDirectory = e.rootDir, d.devHtml = void 0;
|
|
1413
1403
|
}), e.middlewares.use(Nt(e, d)), e.middlewares.use(Pt(e, t, d));
|
|
1414
1404
|
},
|
|
1415
|
-
async transform(
|
|
1416
|
-
let i =
|
|
1405
|
+
async transform(n, r) {
|
|
1406
|
+
let i = r.split("?")[0];
|
|
1417
1407
|
if (!e(i)) return;
|
|
1418
|
-
if (
|
|
1408
|
+
if (t(i)) return {
|
|
1419
1409
|
code: "<script>import { TdNotFound } from 'typerighter/client/theme-default'; export default TdNotFound; export const pageData = { frontmatter: {}, headings: [], title: '' };<\/script>",
|
|
1420
1410
|
map: null
|
|
1421
1411
|
};
|
|
1422
|
-
let a = await
|
|
1412
|
+
let a = await f(), o = await a.getConfig(), s = b(i, o.rootDir);
|
|
1423
1413
|
try {
|
|
1424
1414
|
let { vueSrc: e } = await at(a, await a.getFile(s), s);
|
|
1425
1415
|
return {
|
|
@@ -1436,19 +1426,19 @@ function $(t = {}) {
|
|
|
1436
1426
|
if (e(t)) return [];
|
|
1437
1427
|
},
|
|
1438
1428
|
async closeBundle() {
|
|
1439
|
-
if (!
|
|
1440
|
-
let e = (await (await
|
|
1441
|
-
await
|
|
1429
|
+
if (!n.context && r) try {
|
|
1430
|
+
let e = (await (await r.getTdContext()).getConfig()).basePath, t = e.startsWith(o) ? e.slice(o.length) : e.replace(/^\//, "");
|
|
1431
|
+
await M(r, {
|
|
1442
1432
|
outDir: w(a, t),
|
|
1443
1433
|
base: e
|
|
1444
1434
|
});
|
|
1445
1435
|
} finally {
|
|
1446
|
-
|
|
1436
|
+
r.dispose();
|
|
1447
1437
|
}
|
|
1448
1438
|
}
|
|
1449
1439
|
},
|
|
1450
1440
|
te({
|
|
1451
|
-
include:
|
|
1441
|
+
include: n.root ? RegExp(`${n.root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/.*\\.(?:vue|td)$`) : /\.(?:vue|td)$/,
|
|
1452
1442
|
template: { transformAssetUrls: !1 }
|
|
1453
1443
|
}),
|
|
1454
1444
|
...ee()
|
|
@@ -1483,4 +1473,4 @@ function Bt(e) {
|
|
|
1483
1473
|
}
|
|
1484
1474
|
}
|
|
1485
1475
|
//#endregion
|
|
1486
|
-
export {
|
|
1476
|
+
export { M as a, W as i, Q as n, U as r, $ as t };
|