typerighter 0.30.6 → 0.30.8
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/{app-BIZW-EFe.js → app-DZp-uDTw.js} +3 -1
- package/dist/{cli-x2zGzLEx.js → cli-Dqblgogf.js} +5 -5
- package/dist/cli.js +1 -1
- package/dist/client/app/router.d.ts.map +1 -1
- package/dist/client/theme-default.js +1 -1
- package/dist/client.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{init-Bn4rrlkQ.js → init-BmRxS763.js} +2 -2
- package/dist/{vite-vMuZ0f3f.js → vite-CdFJrVOC.js} +306 -306
- 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,
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { build 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, g as f, h as p, m, p as h, s as g, u as _, v, w as y } from "./shared-B-n46X4N.js";
|
|
2
|
+
import { t as b } from "./temml-DZbhOfRE.js";
|
|
3
|
+
import { t as x } from "./es-ClqUVRJn.js";
|
|
4
|
+
import S, { resolve as C } from "node:path";
|
|
5
|
+
import w from "picocolors";
|
|
6
|
+
import T from "@tailwindcss/vite";
|
|
7
|
+
import ee from "@vitejs/plugin-vue";
|
|
8
|
+
import { build as E, createLogger as te, normalizePath as ne } from "vite";
|
|
9
9
|
import D from "node:fs/promises";
|
|
10
|
-
import { createHighlighter as
|
|
11
|
-
import O, { createReadStream as
|
|
12
|
-
import { RpcServer as
|
|
13
|
-
import { RPC_CANCELLED_CODE as
|
|
14
|
-
import { createRequire as
|
|
10
|
+
import { createHighlighter as re, guessEmbeddedLanguages as ie, isSpecialLang as ae } from "shiki";
|
|
11
|
+
import O, { createReadStream as oe, existsSync as se, globSync as ce, readFileSync as le, statSync as ue } from "node:fs";
|
|
12
|
+
import { RpcServer as de } from "@typerighter/rpc-server";
|
|
13
|
+
import { RPC_CANCELLED_CODE as fe, RpcClient as pe } from "@typerighter/rpc-client";
|
|
14
|
+
import { createRequire as me } from "node:module";
|
|
15
15
|
//#region src/node/lib/html-template.ts
|
|
16
|
-
function
|
|
17
|
-
let t =
|
|
16
|
+
function he(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,10 +53,10 @@ ${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;
|
|
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 = he({
|
|
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 pe(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 D.mkdir(
|
|
68
|
+
}), f = s === "/" ? "index.html" : `${s.replace(/^\//, "")}.html`, p = S.join(e.outDir, f);
|
|
69
|
+
await D.mkdir(S.dirname(p), { recursive: !0 }), await D.writeFile(p, d), o++, e.progress?.update(o, a);
|
|
70
70
|
}));
|
|
71
71
|
}
|
|
72
|
-
async function
|
|
73
|
-
let t =
|
|
72
|
+
async function _e(e) {
|
|
73
|
+
let t = S.join(e, ".vite", "manifest.json"), n = await D.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 me(e) {
|
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
82
|
//#region src/node/lib/progress.ts
|
|
83
|
-
var
|
|
83
|
+
var k = [
|
|
84
84
|
"◐",
|
|
85
85
|
"◓",
|
|
86
86
|
"◑",
|
|
87
87
|
"◒"
|
|
88
|
-
],
|
|
88
|
+
], A = class {
|
|
89
89
|
logger;
|
|
90
90
|
label;
|
|
91
91
|
start;
|
|
@@ -93,8 +93,8 @@ var A = [
|
|
|
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(w.cyan(`${k[0]} ${t}`)), this.spinnerInterval = setInterval(() => {
|
|
97
|
+
e = (e + 1) % k.length, process.stdout.write(`\r${w.cyan(`${k[e]} ${this.label}`)}`);
|
|
98
98
|
}, 120).unref();
|
|
99
99
|
} else this.logger.start(t);
|
|
100
100
|
}
|
|
@@ -106,20 +106,20 @@ var A = [
|
|
|
106
106
|
done(e) {
|
|
107
107
|
this.stopSpinner(), process.stdout.isTTY && process.stdout.write("\r\x1B[K");
|
|
108
108
|
let t = Math.round(performance.now() - this.start);
|
|
109
|
-
this.logger.success(`${e} (${
|
|
109
|
+
this.logger.success(`${e} (${ve(t)})`);
|
|
110
110
|
}
|
|
111
111
|
stopSpinner() {
|
|
112
112
|
this.spinnerInterval &&= (clearInterval(this.spinnerInterval), void 0);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
|
-
function
|
|
115
|
+
function ve(e) {
|
|
116
116
|
return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
|
|
117
117
|
}
|
|
118
118
|
//#endregion
|
|
119
119
|
//#region src/node/build/index.ts
|
|
120
|
-
var
|
|
121
|
-
async function
|
|
122
|
-
let { root: n, logger: r } = e, i =
|
|
120
|
+
var ye = "typerighter/client/theme-default";
|
|
121
|
+
async function j(e, t = {}) {
|
|
122
|
+
let { root: n, logger: r } = e, i = S.resolve(n, t.outDir ?? "dist"), a = S.join(i, ".client"), o = S.join(i, ".server");
|
|
123
123
|
await D.rm(i, {
|
|
124
124
|
recursive: !0,
|
|
125
125
|
force: !0
|
|
@@ -129,41 +129,41 @@ async function M(e, t = {}) {
|
|
|
129
129
|
c.listFiles(),
|
|
130
130
|
c.listSidebar(),
|
|
131
131
|
c.listSchemas()
|
|
132
|
-
]),
|
|
132
|
+
]), p = t.base ?? l.basePath ?? "/", m = p.endsWith("/") ? p : p + "/", g = d.map((e) => ({
|
|
133
133
|
...e,
|
|
134
134
|
header: {}
|
|
135
|
-
})), _ =
|
|
135
|
+
})), _ = h(g), v = JSON.stringify({
|
|
136
136
|
title: l.siteTitle,
|
|
137
137
|
description: l.siteDescription,
|
|
138
|
-
basePath:
|
|
138
|
+
basePath: m,
|
|
139
139
|
nav: l.nav
|
|
140
140
|
}), y = JSON.stringify({
|
|
141
141
|
ready: !0,
|
|
142
142
|
contentTree: _
|
|
143
|
-
}),
|
|
144
|
-
await D.mkdir(
|
|
145
|
-
let
|
|
146
|
-
await Promise.all([D.writeFile(
|
|
143
|
+
}), b = S.join(n, "node_modules", ".typerighter");
|
|
144
|
+
await D.mkdir(b, { recursive: !0 });
|
|
145
|
+
let x = S.join(b, "client-entry.js"), C = S.join(b, "ssr-entry.js");
|
|
146
|
+
await Promise.all([D.writeFile(x, Q({
|
|
147
147
|
rootDir: l.rootDir,
|
|
148
|
-
basePath:
|
|
148
|
+
basePath: m,
|
|
149
149
|
siteTitle: l.siteTitle,
|
|
150
150
|
siteDescription: l.siteDescription,
|
|
151
151
|
repo: l.repo,
|
|
152
152
|
author: l.author,
|
|
153
153
|
license: l.license,
|
|
154
154
|
nav: l.nav
|
|
155
|
-
})), D.writeFile(C,
|
|
155
|
+
})), D.writeFile(C, be({
|
|
156
156
|
rootDir: l.rootDir,
|
|
157
|
-
layoutImport:
|
|
157
|
+
layoutImport: ye,
|
|
158
158
|
siteConfig: v,
|
|
159
159
|
siteData: y
|
|
160
160
|
}))]);
|
|
161
161
|
try {
|
|
162
|
-
let c =
|
|
163
|
-
await
|
|
162
|
+
let c = $({ context: e }), d = e.createViteLogger(), f = new A(r, "Building client bundle...");
|
|
163
|
+
await E({
|
|
164
164
|
...t.viteConfig,
|
|
165
165
|
root: n,
|
|
166
|
-
base:
|
|
166
|
+
base: m,
|
|
167
167
|
plugins: c,
|
|
168
168
|
customLogger: d,
|
|
169
169
|
logLevel: "silent",
|
|
@@ -174,17 +174,17 @@ async function M(e, t = {}) {
|
|
|
174
174
|
emptyOutDir: !0,
|
|
175
175
|
rollupOptions: {
|
|
176
176
|
...t.viteConfig?.build?.rollupOptions,
|
|
177
|
-
input:
|
|
177
|
+
input: x
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
|
-
let p = await D.readdir(
|
|
181
|
+
let p = await D.readdir(S.join(a, "assets")).catch(() => []);
|
|
182
182
|
f.done(`Client bundle (${p.length} chunks)`);
|
|
183
|
-
let
|
|
184
|
-
await
|
|
183
|
+
let h = new A(r, "Building SSR bundle...");
|
|
184
|
+
await E({
|
|
185
185
|
...t.viteConfig,
|
|
186
186
|
root: n,
|
|
187
|
-
base:
|
|
187
|
+
base: m,
|
|
188
188
|
plugins: c,
|
|
189
189
|
customLogger: d,
|
|
190
190
|
logLevel: "silent",
|
|
@@ -194,31 +194,31 @@ async function M(e, t = {}) {
|
|
|
194
194
|
ssr: C,
|
|
195
195
|
emptyOutDir: !0
|
|
196
196
|
}
|
|
197
|
-
}),
|
|
197
|
+
}), h.done("SSR bundle");
|
|
198
198
|
let g = u.map((e) => {
|
|
199
199
|
let t = s(e);
|
|
200
200
|
return t === "index" ? "/" : `/${t}`;
|
|
201
201
|
});
|
|
202
|
-
g.push("/"),
|
|
203
|
-
let v = new
|
|
204
|
-
await
|
|
205
|
-
ssrEntryPath:
|
|
202
|
+
g.push("/"), M(_.entries, "", g);
|
|
203
|
+
let v = new A(r, "Pre-rendering pages...");
|
|
204
|
+
await ge({
|
|
205
|
+
ssrEntryPath: S.join(o, "ssr-entry.js"),
|
|
206
206
|
clientOutDir: a,
|
|
207
207
|
outDir: i,
|
|
208
|
-
base:
|
|
208
|
+
base: m,
|
|
209
209
|
pagePaths: g,
|
|
210
210
|
siteTitle: l.siteTitle,
|
|
211
211
|
progress: v
|
|
212
212
|
}), v.done(`Pre-rendered ${g.length} pages`);
|
|
213
|
-
let y =
|
|
214
|
-
await D.writeFile(
|
|
215
|
-
let
|
|
216
|
-
await D.cp(
|
|
217
|
-
let
|
|
218
|
-
await D.cp(
|
|
213
|
+
let y = Se(g, m);
|
|
214
|
+
await D.writeFile(S.join(i, "sitemap.xml"), y);
|
|
215
|
+
let b = S.join(a, "assets"), w = S.join(i, "assets");
|
|
216
|
+
await D.cp(b, w, { recursive: !0 }).catch(() => {}), await xe(S.join(n, l.rootDir), i);
|
|
217
|
+
let T = S.join(n, l.publicDir);
|
|
218
|
+
await D.cp(T, i, { recursive: !0 }).catch(() => {});
|
|
219
219
|
} finally {
|
|
220
220
|
await Promise.all([
|
|
221
|
-
D.rm(
|
|
221
|
+
D.rm(b, {
|
|
222
222
|
recursive: !0,
|
|
223
223
|
force: !0
|
|
224
224
|
}),
|
|
@@ -234,8 +234,8 @@ async function M(e, t = {}) {
|
|
|
234
234
|
}
|
|
235
235
|
r.log(`\nBuild complete. Output: ${i}`);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
let t = `/${e.rootDir}/${
|
|
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 = m(a.entries ?? [], r.title ?? ""), s = JSON.stringify({
|
|
239
239
|
...i,
|
|
240
240
|
directoryListings: o
|
|
241
241
|
});
|
|
@@ -283,39 +283,39 @@ export async function render(url) {
|
|
|
283
283
|
}
|
|
284
284
|
`;
|
|
285
285
|
}
|
|
286
|
-
async function
|
|
286
|
+
async function xe(t, n) {
|
|
287
287
|
let r = (await D.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 D.mkdir(
|
|
291
|
+
let r = S.join(e.parentPath, e.name), i = S.relative(t, r), a = S.join(n, i);
|
|
292
|
+
return D.mkdir(S.dirname(a), { recursive: !0 }).then(() => D.copyFile(r, a));
|
|
293
293
|
});
|
|
294
294
|
await Promise.all(r);
|
|
295
295
|
}
|
|
296
|
-
function
|
|
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>${g(t + e.replace(/^\//, ""))}</loc></url>`).join("\n")}
|
|
300
300
|
</urlset>
|
|
301
301
|
`;
|
|
302
302
|
}
|
|
303
|
-
function
|
|
303
|
+
function M(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
|
-
n.push(e),
|
|
307
|
+
p(r.node) || n.push(c(e)), M(r.node.entries, e, n);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
//#endregion
|
|
311
311
|
//#region ../../node_modules/.pnpm/@shikijs+transformers@4.4.3/node_modules/@shikijs/transformers/dist/index.mjs
|
|
312
|
-
var
|
|
312
|
+
var Ce = /(\s+\/\/)/, we = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/, Te = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/, Ee = [
|
|
313
313
|
[/^(<!--)(.+)(-->)$/, !1],
|
|
314
314
|
[/^(\/\*)(.+)(\*\/)$/, !1],
|
|
315
315
|
[/^(\/\/|["'#]|;{1,2}|%{1,2}|--)(.*)$/, !0],
|
|
316
316
|
[/^(\*)(.+)$/, !0]
|
|
317
317
|
];
|
|
318
|
-
function
|
|
318
|
+
function De(e, t, n) {
|
|
319
319
|
let r = [];
|
|
320
320
|
for (let i of e) {
|
|
321
321
|
if (n === "v3") {
|
|
@@ -324,8 +324,8 @@ function we(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 (!
|
|
328
|
-
let a = n.value.split(
|
|
327
|
+
if (!P(n.value, r)) return e;
|
|
328
|
+
let a = n.value.split(Ce);
|
|
329
329
|
if (a.length <= 1) return e;
|
|
330
330
|
let o = [a[0]];
|
|
331
331
|
for (let e = 1; e < a.length; e += 2) o.push(a[e] + (a[e + 1] || ""));
|
|
@@ -346,13 +346,13 @@ function we(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 = P(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 = P(n.value + o.value, s);
|
|
356
356
|
if (l) {
|
|
357
357
|
c = l, r.push({
|
|
358
358
|
info: l,
|
|
@@ -369,7 +369,7 @@ function we(e, t, n) {
|
|
|
369
369
|
}
|
|
370
370
|
if (c) {
|
|
371
371
|
if (t && !s && n !== 0) {
|
|
372
|
-
let t =
|
|
372
|
+
let t = N(e[n - 1], "{") && N(e[n + 1], "}");
|
|
373
373
|
r.push({
|
|
374
374
|
info: c,
|
|
375
375
|
line: i,
|
|
@@ -391,16 +391,16 @@ function we(e, t, n) {
|
|
|
391
391
|
}
|
|
392
392
|
return r;
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function N(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 P(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;
|
|
403
|
-
for (let [e, a] of
|
|
403
|
+
for (let [e, a] of Ee) {
|
|
404
404
|
if (a && !t) continue;
|
|
405
405
|
let o = e.exec(n);
|
|
406
406
|
if (o) return [
|
|
@@ -410,22 +410,22 @@ function F(e, t) {
|
|
|
410
410
|
];
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
|
-
function
|
|
414
|
-
let t = e.match(
|
|
413
|
+
function Oe(e) {
|
|
414
|
+
let t = e.match(we);
|
|
415
415
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index) : e;
|
|
416
416
|
}
|
|
417
|
-
function
|
|
418
|
-
let t = e.match(
|
|
417
|
+
function ke(e) {
|
|
418
|
+
let t = e.match(Te);
|
|
419
419
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index).trimEnd() : e;
|
|
420
420
|
}
|
|
421
|
-
function
|
|
421
|
+
function Ae(e, t, n, r) {
|
|
422
422
|
return r ??= "v3", {
|
|
423
423
|
name: e,
|
|
424
424
|
code(e) {
|
|
425
425
|
let i = e.children.filter((e) => e.type === "element"), a = [];
|
|
426
426
|
e.data ??= {};
|
|
427
427
|
let o = e.data;
|
|
428
|
-
o._shiki_notation ??=
|
|
428
|
+
o._shiki_notation ??= De(i, ["jsx", "tsx"].includes(this.options.lang), r);
|
|
429
429
|
let s = o._shiki_notation;
|
|
430
430
|
for (let e of s) {
|
|
431
431
|
if (e.info[1].length === 0) continue;
|
|
@@ -433,7 +433,7 @@ function De(e, t, n, r) {
|
|
|
433
433
|
e.isLineCommentOnly && r !== "v1" && o++;
|
|
434
434
|
let s = !1;
|
|
435
435
|
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;
|
|
436
|
-
r === "v1" ? e.info[1] =
|
|
436
|
+
r === "v1" ? e.info[1] = Oe(e.info[1]) : r === "v3" && (e.info[1] = ke(e.info[1]));
|
|
437
437
|
let c = e.info[1].trim().length === 0;
|
|
438
438
|
if (c && (e.info[1] = ""), c && e.isLineCommentOnly) a.push(e.line);
|
|
439
439
|
else if (c && e.isJsxStyle) e.line.children.splice(e.line.children.indexOf(e.token) - 1, 3);
|
|
@@ -458,44 +458,44 @@ function De(e, t, n, r) {
|
|
|
458
458
|
}
|
|
459
459
|
};
|
|
460
460
|
}
|
|
461
|
-
var
|
|
462
|
-
function
|
|
461
|
+
var je = /\{([\d,-]+)\}/;
|
|
462
|
+
function Me(e) {
|
|
463
463
|
if (!e) return null;
|
|
464
|
-
let t = e.match(
|
|
464
|
+
let t = e.match(je);
|
|
465
465
|
return t ? t[1].split(",").flatMap((e) => {
|
|
466
466
|
let t = e.split("-").map((e) => Number.parseInt(e, 10));
|
|
467
467
|
return t.length === 1 ? [t[0]] : Array.from({ length: t[1] - t[0] + 1 }, (e, n) => t[0] + n);
|
|
468
468
|
}) : null;
|
|
469
469
|
}
|
|
470
|
-
var
|
|
471
|
-
function
|
|
470
|
+
var Ne = Symbol("highlighted-lines");
|
|
471
|
+
function Pe(e = {}) {
|
|
472
472
|
let { className: t = "highlighted", zeroIndexed: n = !1 } = e;
|
|
473
473
|
return {
|
|
474
474
|
name: "@shikijs/transformers:meta-highlight",
|
|
475
475
|
line(e, r) {
|
|
476
476
|
if (!this.options.meta?.__raw) return;
|
|
477
477
|
let i = this.meta;
|
|
478
|
-
i[
|
|
479
|
-
let a = i[
|
|
478
|
+
i[Ne] ??= Me(this.options.meta.__raw);
|
|
479
|
+
let a = i[Ne] ?? [], o = n ? r - 1 : r;
|
|
480
480
|
return a.includes(o) && this.addClassToHast(e, t), e;
|
|
481
481
|
}
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
|
-
var
|
|
485
|
-
function
|
|
486
|
-
return e.replace(
|
|
484
|
+
var Fe = /[.*+?^${}()|[\]\\]/g;
|
|
485
|
+
function Ie(e) {
|
|
486
|
+
return e.replace(Fe, "\\$&");
|
|
487
487
|
}
|
|
488
|
-
function
|
|
488
|
+
function F(e = {}, t = "@shikijs/transformers:notation-map") {
|
|
489
489
|
let { classMap: n = {}, classActivePre: r = void 0, classActiveCode: i = void 0 } = e;
|
|
490
|
-
return
|
|
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);
|
|
492
492
|
for (let e = l; e < Math.min(l + u, c.length); e++) this.addClassToHast(c[e], n[t]);
|
|
493
493
|
return r && this.addClassToHast(this.pre, r), i && this.addClassToHast(this.code, i), !0;
|
|
494
494
|
}, e.matchAlgorithm);
|
|
495
495
|
}
|
|
496
|
-
function
|
|
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 F({
|
|
499
499
|
classMap: {
|
|
500
500
|
"++": t,
|
|
501
501
|
"--": n
|
|
@@ -505,31 +505,31 @@ function Ne(e = {}) {
|
|
|
505
505
|
matchAlgorithm: e.matchAlgorithm
|
|
506
506
|
}, "@shikijs/transformers:notation-diff");
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function Re(e = {}) {
|
|
509
509
|
let { classMap: t = {
|
|
510
510
|
error: ["highlighted", "error"],
|
|
511
511
|
warning: ["highlighted", "warning"],
|
|
512
512
|
info: ["highlighted", "info"]
|
|
513
513
|
}, classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
514
|
-
return
|
|
514
|
+
return F({
|
|
515
515
|
classMap: t,
|
|
516
516
|
classActivePre: n,
|
|
517
517
|
classActiveCode: r,
|
|
518
518
|
matchAlgorithm: e.matchAlgorithm
|
|
519
519
|
}, "@shikijs/transformers:notation-error-level");
|
|
520
520
|
}
|
|
521
|
-
function
|
|
521
|
+
function ze(e = {}) {
|
|
522
522
|
let { classActiveLine: t = "focused", classActivePre: n = "has-focused", classActiveCode: r } = e;
|
|
523
|
-
return
|
|
523
|
+
return F({
|
|
524
524
|
classMap: { focus: t },
|
|
525
525
|
classActivePre: n,
|
|
526
526
|
classActiveCode: r,
|
|
527
527
|
matchAlgorithm: e.matchAlgorithm
|
|
528
528
|
}, "@shikijs/transformers:notation-focus");
|
|
529
529
|
}
|
|
530
|
-
function
|
|
530
|
+
function Be(e = {}) {
|
|
531
531
|
let { classActiveLine: t = "highlighted", classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
532
|
-
return
|
|
532
|
+
return F({
|
|
533
533
|
classMap: {
|
|
534
534
|
highlight: t,
|
|
535
535
|
hl: t
|
|
@@ -541,73 +541,73 @@ function Ie(e = {}) {
|
|
|
541
541
|
}
|
|
542
542
|
//#endregion
|
|
543
543
|
//#region src/node/lib/render/highlight/language.ts
|
|
544
|
-
var
|
|
544
|
+
var Ve = [
|
|
545
545
|
"shellscript",
|
|
546
546
|
"shell",
|
|
547
547
|
"bash",
|
|
548
548
|
"sh",
|
|
549
549
|
"zsh"
|
|
550
550
|
];
|
|
551
|
-
function
|
|
552
|
-
return
|
|
551
|
+
function He(e) {
|
|
552
|
+
return Ve.includes(e);
|
|
553
553
|
}
|
|
554
|
-
var
|
|
555
|
-
function
|
|
556
|
-
return
|
|
554
|
+
var Ue = /^[a-zA-Z0-9-_]+/;
|
|
555
|
+
function We(e) {
|
|
556
|
+
return Ue.exec(e)?.[0] || "";
|
|
557
557
|
}
|
|
558
558
|
//#endregion
|
|
559
559
|
//#region src/node/lib/logger.ts
|
|
560
|
-
var
|
|
560
|
+
var Ge = /\u001B\[[0-9;]*m/g, I = class {
|
|
561
561
|
logStream;
|
|
562
562
|
constructor(e) {
|
|
563
563
|
e !== void 0 && (this.logStream = O.createWriteStream(e, { flags: "a" }), process.once("exit", () => this.close()));
|
|
564
564
|
}
|
|
565
565
|
info(e) {
|
|
566
|
-
console.log(
|
|
566
|
+
console.log(w.cyan(`ℹ ${e}`)), this.writeToFile("INFO", e);
|
|
567
567
|
}
|
|
568
568
|
warn(e) {
|
|
569
|
-
console.warn(
|
|
569
|
+
console.warn(w.yellow(`⚠ ${e}`)), this.writeToFile("WARN", e);
|
|
570
570
|
}
|
|
571
571
|
error(e) {
|
|
572
|
-
console.error(
|
|
572
|
+
console.error(w.red(`✖ ${e}`)), this.writeToFile("ERROR", e);
|
|
573
573
|
}
|
|
574
574
|
success(e) {
|
|
575
|
-
console.log(
|
|
575
|
+
console.log(w.green(`✔ ${e}`)), this.writeToFile("SUCCESS", e);
|
|
576
576
|
}
|
|
577
577
|
start(e) {
|
|
578
|
-
console.log(
|
|
578
|
+
console.log(w.cyan(`◐ ${e}`)), this.writeToFile("START", e);
|
|
579
579
|
}
|
|
580
580
|
log(e) {
|
|
581
581
|
console.log(e), this.writeToFile("LOG", e);
|
|
582
582
|
}
|
|
583
583
|
writeToFile(e, t) {
|
|
584
584
|
if (!this.logStream) return;
|
|
585
|
-
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.replace(
|
|
585
|
+
let n = (/* @__PURE__ */ new Date()).toISOString(), r = t.replace(Ge, "");
|
|
586
586
|
this.logStream.write(`${n} [${e}] ${r}\n`);
|
|
587
587
|
}
|
|
588
588
|
close() {
|
|
589
589
|
this.logStream?.end(), this.logStream = void 0;
|
|
590
590
|
}
|
|
591
|
-
},
|
|
591
|
+
}, Ke = new I(), qe = 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
|
|
599
|
-
themes: [
|
|
597
|
+
async function Je() {
|
|
598
|
+
let e = await re({
|
|
599
|
+
themes: [L.light, L.dark],
|
|
600
600
|
langs: []
|
|
601
601
|
}), t = [
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
602
|
+
Pe(),
|
|
603
|
+
Le(),
|
|
604
|
+
ze({
|
|
605
605
|
classActiveLine: "has-focus",
|
|
606
606
|
classActivePre: "has-focused-lines"
|
|
607
607
|
}),
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
608
|
+
Be(),
|
|
609
|
+
Re(),
|
|
610
|
+
Ye(),
|
|
611
611
|
{
|
|
612
612
|
name: "typedown:add-dir",
|
|
613
613
|
pre(e) {
|
|
@@ -616,19 +616,19 @@ async function We() {
|
|
|
616
616
|
}
|
|
617
617
|
], n = new Set(e.getLoadedLanguages());
|
|
618
618
|
async function r(r, i, a) {
|
|
619
|
-
let o =
|
|
619
|
+
let o = We(i);
|
|
620
620
|
if (o) {
|
|
621
621
|
let e = i;
|
|
622
622
|
i = o.toLowerCase(), a = e.slice(i.length).replace(/(?<!=)\{/g, " {") + " " + a, a = a.trim().replace(/\s+/g, " ");
|
|
623
623
|
}
|
|
624
624
|
i ||= "txt";
|
|
625
625
|
try {
|
|
626
|
-
!
|
|
626
|
+
!ae(i) && !n.has(i) && (await e.loadLanguage(i), n.add(i));
|
|
627
627
|
} catch {
|
|
628
|
-
|
|
628
|
+
Ke.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 = ie(r, i, e);
|
|
632
632
|
return await e.loadLanguage(...s), e.codeToHtml(r, {
|
|
633
633
|
lang: i,
|
|
634
634
|
transformers: [...t, {
|
|
@@ -645,7 +645,7 @@ async function We() {
|
|
|
645
645
|
}
|
|
646
646
|
}],
|
|
647
647
|
meta: { __raw: a },
|
|
648
|
-
themes:
|
|
648
|
+
themes: L,
|
|
649
649
|
defaultColor: !1,
|
|
650
650
|
colorReplacements: {
|
|
651
651
|
"github-light": {
|
|
@@ -670,13 +670,13 @@ async function We() {
|
|
|
670
670
|
}
|
|
671
671
|
});
|
|
672
672
|
}
|
|
673
|
-
return
|
|
673
|
+
return qe.register(r, () => e.dispose()), r;
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function Ye() {
|
|
676
676
|
return {
|
|
677
677
|
name: "typedown:disable-shell-symbol-select",
|
|
678
678
|
tokens(e) {
|
|
679
|
-
if (
|
|
679
|
+
if (He(this.options.lang)) for (let t of e) {
|
|
680
680
|
if (t.length < 2) continue;
|
|
681
681
|
let e = t[0].content.trim();
|
|
682
682
|
(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));
|
|
@@ -686,20 +686,20 @@ function Ge() {
|
|
|
686
686
|
}
|
|
687
687
|
//#endregion
|
|
688
688
|
//#region src/node/lib/render/postprocess.ts
|
|
689
|
-
var
|
|
690
|
-
async function
|
|
691
|
-
return e = await
|
|
689
|
+
var R;
|
|
690
|
+
async function Xe(e) {
|
|
691
|
+
return e = await $e(e), e = rt(e), e;
|
|
692
692
|
}
|
|
693
|
-
function
|
|
694
|
-
return
|
|
693
|
+
function Ze() {
|
|
694
|
+
return R ||= Je(), R;
|
|
695
695
|
}
|
|
696
|
-
var
|
|
697
|
-
async function
|
|
698
|
-
let t = await
|
|
696
|
+
var Qe = /<pre class="td-code-placeholder"(?: data-lang="([^"]*)")?(?: data-meta="([^"]*)")?><code>([\s\S]*?)<\/code><\/pre>/g;
|
|
697
|
+
async function $e(e) {
|
|
698
|
+
let t = await Ze(), n = [...e.matchAll(Qe)];
|
|
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 = _(e[3]);
|
|
702
|
+
return et(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 Ye(e) {
|
|
|
707
707
|
}
|
|
708
708
|
return i;
|
|
709
709
|
}
|
|
710
|
-
function
|
|
710
|
+
function et(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 Xe(e, t, n) {
|
|
|
718
718
|
}
|
|
719
719
|
return i;
|
|
720
720
|
}
|
|
721
|
-
var
|
|
722
|
-
function
|
|
723
|
-
return e = e.replace(
|
|
721
|
+
var tt = /<span class="td-math-inline">([\s\S]*?)<\/span>/g, nt = /<div class="td-math-block">([\s\S]*?)<\/div>/g;
|
|
722
|
+
function rt(e) {
|
|
723
|
+
return e = e.replace(tt, (e, t) => z(t, !1)), e = e.replace(nt, (e, t) => z(t, !0)), e;
|
|
724
724
|
}
|
|
725
|
-
function
|
|
725
|
+
function z(e, t) {
|
|
726
726
|
let n = t ? "div" : "span";
|
|
727
727
|
try {
|
|
728
|
-
return
|
|
728
|
+
return b.renderToString(_(e), {
|
|
729
729
|
throwOnError: !1,
|
|
730
730
|
displayMode: t
|
|
731
731
|
});
|
|
@@ -735,21 +735,21 @@ function V(e, t) {
|
|
|
735
735
|
}
|
|
736
736
|
//#endregion
|
|
737
737
|
//#region src/node/lib/render/vue.ts
|
|
738
|
-
async function
|
|
739
|
-
let r = t.title || (
|
|
738
|
+
async function B(e, t, n) {
|
|
739
|
+
let r = t.title || (v(n) ? f(n, (await e.getConfig()).siteTitle) : d(n, t.label));
|
|
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: at(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 it(e, t, n) {
|
|
752
|
+
let r = await Xe(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 et(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${ot(r)}\n</div></template>`
|
|
765
765
|
].join("\n"),
|
|
766
766
|
pageData: i
|
|
767
767
|
};
|
|
768
768
|
}
|
|
769
|
-
function
|
|
769
|
+
function at(e) {
|
|
770
770
|
let t = [], n = [];
|
|
771
771
|
for (let r of e) {
|
|
772
772
|
let e = {
|
|
@@ -782,12 +782,12 @@ function tt(e) {
|
|
|
782
782
|
}
|
|
783
783
|
return t;
|
|
784
784
|
}
|
|
785
|
-
function
|
|
785
|
+
function ot(e) {
|
|
786
786
|
return e.replaceAll("{{", "{{");
|
|
787
787
|
}
|
|
788
788
|
//#endregion
|
|
789
789
|
//#region src/node/lib/typedown-context.ts
|
|
790
|
-
var
|
|
790
|
+
var st = class {
|
|
791
791
|
client;
|
|
792
792
|
constructor(e) {
|
|
793
793
|
this.client = e, this.registerNotificationHandlers(e);
|
|
@@ -821,61 +821,61 @@ var rt = class {
|
|
|
821
821
|
async getFile(e) {
|
|
822
822
|
let t = this.cachedFileMap.get(e);
|
|
823
823
|
if (t) return t;
|
|
824
|
-
let n = await
|
|
824
|
+
let n = await H(() => this.rpc.requestFile(e));
|
|
825
825
|
return this.cachedFileMap.set(e, n), n;
|
|
826
826
|
}
|
|
827
827
|
async getFiles(e) {
|
|
828
828
|
let t = e.filter((e) => !this.cachedFileMap.has(e));
|
|
829
829
|
if (0 < t.length) {
|
|
830
|
-
let e = await
|
|
830
|
+
let e = await H(() => this.rpc.requestFiles(t));
|
|
831
831
|
for (let [n, r] of t.entries()) this.cachedFileMap.set(r, e[n]);
|
|
832
832
|
}
|
|
833
833
|
return e.map((e) => this.cachedFileMap.get(e));
|
|
834
834
|
}
|
|
835
835
|
async listFiles() {
|
|
836
|
-
return this.cachedFiles ||= await
|
|
836
|
+
return this.cachedFiles ||= await H(() => this.rpc.listVault()), this.cachedFiles;
|
|
837
837
|
}
|
|
838
838
|
async listSidebar() {
|
|
839
|
-
return
|
|
839
|
+
return H(() => this.rpc.listSidebar());
|
|
840
840
|
}
|
|
841
841
|
async getConfig() {
|
|
842
|
-
return this.cachedConfig ||= await
|
|
842
|
+
return this.cachedConfig ||= await H(() => this.rpc.getConfig()), this.cachedConfig;
|
|
843
843
|
}
|
|
844
844
|
async getSchema(e) {
|
|
845
845
|
let t = this.cachedSchemaMap.get(e);
|
|
846
846
|
if (t) return t;
|
|
847
|
-
let n = await
|
|
847
|
+
let n = await H(() => this.rpc.getSchema(e));
|
|
848
848
|
return this.cachedSchemaMap.set(e, n), n;
|
|
849
849
|
}
|
|
850
850
|
async listSchemas() {
|
|
851
|
-
return this.cachedSchemas ||= await
|
|
851
|
+
return this.cachedSchemas ||= await H(() => this.rpc.listSchemas()), this.cachedSchemas;
|
|
852
852
|
}
|
|
853
853
|
async checkVault() {
|
|
854
|
-
return
|
|
854
|
+
return H(() => this.rpc.checkVault());
|
|
855
855
|
}
|
|
856
856
|
async formatFile(e) {
|
|
857
|
-
return
|
|
857
|
+
return H(() => this.rpc.formatFile(e));
|
|
858
858
|
}
|
|
859
859
|
};
|
|
860
|
-
function
|
|
861
|
-
return e instanceof Error && "code" in e && e.code ===
|
|
860
|
+
function V(e) {
|
|
861
|
+
return e instanceof Error && "code" in e && e.code === fe;
|
|
862
862
|
}
|
|
863
|
-
async function
|
|
863
|
+
async function H(e, t = 5) {
|
|
864
864
|
for (let n = 0; n < t; n++) try {
|
|
865
865
|
return await e();
|
|
866
866
|
} catch (e) {
|
|
867
|
-
if (!
|
|
867
|
+
if (!V(e) || n === t - 1) throw e;
|
|
868
868
|
await new Promise((e) => setTimeout(e, 50 * (n + 1)));
|
|
869
869
|
}
|
|
870
870
|
throw Error("unreachable");
|
|
871
871
|
}
|
|
872
872
|
//#endregion
|
|
873
873
|
//#region src/node/context.ts
|
|
874
|
-
var
|
|
875
|
-
function
|
|
876
|
-
let t = new
|
|
874
|
+
var U = ["typedown.yaml", "typedown.yml"];
|
|
875
|
+
function W(e) {
|
|
876
|
+
let t = new I(ut(e));
|
|
877
877
|
function n() {
|
|
878
|
-
let e =
|
|
878
|
+
let e = te("warn");
|
|
879
879
|
return {
|
|
880
880
|
...e,
|
|
881
881
|
info(e) {
|
|
@@ -898,14 +898,14 @@ function K(e) {
|
|
|
898
898
|
}
|
|
899
899
|
async function l() {
|
|
900
900
|
if (r) return r;
|
|
901
|
-
process.on("SIGINT", s), process.on("SIGTERM", s), i = new
|
|
901
|
+
process.on("SIGINT", s), process.on("SIGTERM", s), i = new de({ root: e }), await new Promise((e, t) => {
|
|
902
902
|
i?.once("error", t), i?.listen(() => {
|
|
903
903
|
i?.removeListener("error", t), e();
|
|
904
904
|
});
|
|
905
905
|
});
|
|
906
906
|
let t = i.host, n = i.port;
|
|
907
907
|
if (t === void 0 || n === void 0) throw Error("RPC server started but host/port not available");
|
|
908
|
-
return a = await
|
|
908
|
+
return a = await pe.connectTcp(t, n), r = new st(a), i.unref(), process.on("exit", c), r;
|
|
909
909
|
}
|
|
910
910
|
function u() {
|
|
911
911
|
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,71 +918,71 @@ function K(e) {
|
|
|
918
918
|
dispose: u
|
|
919
919
|
};
|
|
920
920
|
}
|
|
921
|
-
function
|
|
922
|
-
let t =
|
|
921
|
+
function ct(e) {
|
|
922
|
+
let t = S.resolve(e);
|
|
923
923
|
for (;;) {
|
|
924
|
-
if (
|
|
925
|
-
let e =
|
|
924
|
+
if (lt(t)) return t;
|
|
925
|
+
let e = S.dirname(t);
|
|
926
926
|
if (e === t) break;
|
|
927
927
|
t = e;
|
|
928
928
|
}
|
|
929
|
-
return
|
|
929
|
+
return S.resolve(e);
|
|
930
930
|
}
|
|
931
|
-
function
|
|
932
|
-
return
|
|
931
|
+
function lt(e) {
|
|
932
|
+
return U.some((t) => O.existsSync(S.join(e, t)));
|
|
933
933
|
}
|
|
934
|
-
function
|
|
934
|
+
function ut(e) {
|
|
935
935
|
try {
|
|
936
|
-
let t =
|
|
936
|
+
let t = S.join(e, ".typedown", ".local"), n = S.join(t, "logs");
|
|
937
937
|
O.mkdirSync(n, { recursive: !0 });
|
|
938
|
-
let r =
|
|
938
|
+
let r = S.join(t, ".gitignore");
|
|
939
939
|
O.existsSync(r) || O.writeFileSync(r, "*\n");
|
|
940
940
|
let i = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
941
|
-
return
|
|
941
|
+
return S.join(n, `${i}.log`);
|
|
942
942
|
} catch {
|
|
943
943
|
return;
|
|
944
944
|
}
|
|
945
945
|
}
|
|
946
946
|
//#endregion
|
|
947
947
|
//#region src/node/plugin/vite/constants.ts
|
|
948
|
-
var
|
|
949
|
-
|
|
950
|
-
var
|
|
948
|
+
var dt = "@typedown/app", G = "\0@typedown/app", K = "@typedown/pages", q = "\0" + K;
|
|
949
|
+
K + "";
|
|
950
|
+
var J = "\0@typedown/pages?resource=", Y = "@typedown/site-data", ft = "\0@typedown/site-data", X = "@typedown/search-index", pt = "\0@typedown/search-index";
|
|
951
951
|
//#endregion
|
|
952
952
|
//#region src/node/plugin/vite/virtual/utils.ts
|
|
953
|
-
function
|
|
953
|
+
function Z(e, t) {
|
|
954
954
|
let n = e.moduleGraph.getModuleById(t);
|
|
955
955
|
if (!n) return;
|
|
956
956
|
e.moduleGraph.invalidateModule(n);
|
|
957
|
-
let r =
|
|
957
|
+
let r = mt(n.url);
|
|
958
958
|
for (let t of n.importers) e.hot.send({
|
|
959
959
|
type: "update",
|
|
960
960
|
updates: [{
|
|
961
961
|
type: "js-update",
|
|
962
|
-
path:
|
|
962
|
+
path: mt(t.url),
|
|
963
963
|
acceptedPath: r,
|
|
964
964
|
timestamp: Date.now()
|
|
965
965
|
}]
|
|
966
966
|
});
|
|
967
967
|
}
|
|
968
|
-
function
|
|
968
|
+
function mt(e) {
|
|
969
969
|
return e.startsWith("\0") ? "/@id/__x00__" + e.slice(1) : e;
|
|
970
970
|
}
|
|
971
971
|
//#endregion
|
|
972
972
|
//#region src/node/plugin/vite/virtual/app.ts
|
|
973
|
-
var
|
|
973
|
+
var ht = class {
|
|
974
974
|
async load(e) {
|
|
975
975
|
let t = await e.getConfig();
|
|
976
|
-
return
|
|
976
|
+
return Q({
|
|
977
977
|
...t,
|
|
978
978
|
rootDir: t.rootDir
|
|
979
979
|
});
|
|
980
980
|
}
|
|
981
981
|
invalidate(e) {
|
|
982
|
-
|
|
982
|
+
Z(e, G);
|
|
983
983
|
}
|
|
984
984
|
};
|
|
985
|
-
function
|
|
985
|
+
function Q(e) {
|
|
986
986
|
let { rootDir: t = "." } = e, r = JSON.stringify({
|
|
987
987
|
title: e.siteTitle,
|
|
988
988
|
description: e.siteDescription,
|
|
@@ -1001,8 +1001,8 @@ import { TdDirectoryIndex, TdGlossaryIndex } from 'typerighter/client/theme-defa
|
|
|
1001
1001
|
import { isIndexUrl, getDirectoryFromPageUrl } from 'typerighter/shared';
|
|
1002
1002
|
import { h } from 'vue';
|
|
1003
1003
|
import theme from 'typerighter/client/theme-default';
|
|
1004
|
-
import { pages as initialPages } from '${
|
|
1005
|
-
import initialSiteData from '${
|
|
1004
|
+
import { pages as initialPages } from '${K}';
|
|
1005
|
+
import initialSiteData from '${Y}';
|
|
1006
1006
|
let pages = initialPages;
|
|
1007
1007
|
const contentExts = ${JSON.stringify(n)};
|
|
1008
1008
|
|
|
@@ -1034,19 +1034,19 @@ const { app, searchIndex: searchIndexRef, siteData } = await createTypedownApp(l
|
|
|
1034
1034
|
app.mount('#app');
|
|
1035
1035
|
|
|
1036
1036
|
// Load search index in the background after the app is mounted
|
|
1037
|
-
import('${
|
|
1037
|
+
import('${X}').then((m) => { searchIndexRef.value = m.default; });
|
|
1038
1038
|
|
|
1039
1039
|
// Accept HMR so modules update without a full page reload
|
|
1040
1040
|
if (import.meta.hot) {
|
|
1041
|
-
import.meta.hot.accept('${
|
|
1041
|
+
import.meta.hot.accept('${K}', (m) => {
|
|
1042
1042
|
if (m) pages = m.pages;
|
|
1043
1043
|
});
|
|
1044
1044
|
|
|
1045
|
-
import.meta.hot.accept('${
|
|
1045
|
+
import.meta.hot.accept('${X}', (m) => {
|
|
1046
1046
|
if (m) searchIndexRef.value = m.default;
|
|
1047
1047
|
});
|
|
1048
1048
|
|
|
1049
|
-
import.meta.hot.accept('${
|
|
1049
|
+
import.meta.hot.accept('${Y}', (m) => {
|
|
1050
1050
|
if (m) siteData.value = m.default;
|
|
1051
1051
|
});
|
|
1052
1052
|
}
|
|
@@ -1054,7 +1054,7 @@ if (import.meta.hot) {
|
|
|
1054
1054
|
}
|
|
1055
1055
|
//#endregion
|
|
1056
1056
|
//#region src/node/plugin/vite/virtual/pages.ts
|
|
1057
|
-
var
|
|
1057
|
+
var gt = class {
|
|
1058
1058
|
async load(e) {
|
|
1059
1059
|
let t = (await e.getConfig()).rootDir ?? ".";
|
|
1060
1060
|
return `export const pages = import.meta.glob('${t === "." ? "/**/*.{td,md}" : `/${t}/**/*.{td,md}`}');`;
|
|
@@ -1063,65 +1063,65 @@ var ht = class {
|
|
|
1063
1063
|
if (e.startsWith("@typedown/pages?resource=")) return "\0" + e;
|
|
1064
1064
|
}
|
|
1065
1065
|
isPageDataModule(e) {
|
|
1066
|
-
return e.startsWith(
|
|
1066
|
+
return e.startsWith(J);
|
|
1067
1067
|
}
|
|
1068
1068
|
async loadPageData(e, t) {
|
|
1069
|
-
let n = decodeURIComponent(e.slice(
|
|
1069
|
+
let n = decodeURIComponent(e.slice(J.length)), r = await B(t, await t.getFile(n), n);
|
|
1070
1070
|
return `export const pageData = ${JSON.stringify(r)}`;
|
|
1071
1071
|
}
|
|
1072
1072
|
invalidatePageData(e, t) {
|
|
1073
|
-
|
|
1073
|
+
Z(e, J + encodeURIComponent(t));
|
|
1074
1074
|
}
|
|
1075
1075
|
invalidate(e) {
|
|
1076
|
-
|
|
1076
|
+
Z(e, q);
|
|
1077
1077
|
}
|
|
1078
|
-
},
|
|
1078
|
+
}, _t = "\0@typedown/site-data", vt = {
|
|
1079
1079
|
ready: !1,
|
|
1080
1080
|
contentTree: { entries: [] },
|
|
1081
1081
|
schemas: {},
|
|
1082
1082
|
directoryListings: {}
|
|
1083
|
-
},
|
|
1083
|
+
}, yt = class {
|
|
1084
1084
|
data;
|
|
1085
1085
|
scan(e) {
|
|
1086
|
-
let t =
|
|
1086
|
+
let t = ce("**/*.td", {
|
|
1087
1087
|
cwd: e,
|
|
1088
1088
|
exclude: (e) => e.startsWith("_")
|
|
1089
1089
|
}).map((e) => ({
|
|
1090
1090
|
filepath: e,
|
|
1091
|
-
label:
|
|
1091
|
+
label: d(e),
|
|
1092
1092
|
header: {}
|
|
1093
|
-
})), n =
|
|
1093
|
+
})), n = h(t);
|
|
1094
1094
|
this.data = {
|
|
1095
1095
|
contentTree: n,
|
|
1096
1096
|
schemas: {},
|
|
1097
|
-
directoryListings:
|
|
1097
|
+
directoryListings: m(n.entries, "")
|
|
1098
1098
|
};
|
|
1099
1099
|
}
|
|
1100
1100
|
load(e) {
|
|
1101
1101
|
let t = this.data ? {
|
|
1102
1102
|
ready: !0,
|
|
1103
1103
|
...this.data
|
|
1104
|
-
} :
|
|
1104
|
+
} : vt;
|
|
1105
1105
|
return `export default ${JSON.stringify(t)}`;
|
|
1106
1106
|
}
|
|
1107
1107
|
clear() {
|
|
1108
1108
|
this.data = void 0;
|
|
1109
1109
|
}
|
|
1110
1110
|
fetch(e, t) {
|
|
1111
|
-
|
|
1111
|
+
bt(e).then((e) => {
|
|
1112
1112
|
this.data = e, t && this.invalidate(t);
|
|
1113
1113
|
}).catch((e) => {
|
|
1114
1114
|
console.error("[typedown] Failed to fetch site data:", e instanceof Error ? e.message : e);
|
|
1115
1115
|
});
|
|
1116
1116
|
}
|
|
1117
1117
|
async fetchSync(e) {
|
|
1118
|
-
this.data = await
|
|
1118
|
+
this.data = await bt(e);
|
|
1119
1119
|
}
|
|
1120
1120
|
invalidate(e) {
|
|
1121
|
-
|
|
1121
|
+
Z(e, _t);
|
|
1122
1122
|
}
|
|
1123
1123
|
};
|
|
1124
|
-
async function
|
|
1124
|
+
async function bt(e) {
|
|
1125
1125
|
let [t, n, r] = await Promise.all([
|
|
1126
1126
|
e.getConfig(),
|
|
1127
1127
|
e.listSidebar(),
|
|
@@ -1129,19 +1129,19 @@ async function yt(e) {
|
|
|
1129
1129
|
]), i = await Promise.all(r.map(async (t) => [t, (await e.getSchema(t)).properties])), a = Object.fromEntries(i), o = n.map((e) => ({
|
|
1130
1130
|
...e,
|
|
1131
1131
|
header: {}
|
|
1132
|
-
})), s =
|
|
1132
|
+
})), s = h(o);
|
|
1133
1133
|
return {
|
|
1134
1134
|
contentTree: s,
|
|
1135
1135
|
schemas: a,
|
|
1136
|
-
directoryListings:
|
|
1136
|
+
directoryListings: m(s.entries, t.siteTitle)
|
|
1137
1137
|
};
|
|
1138
1138
|
}
|
|
1139
1139
|
//#endregion
|
|
1140
1140
|
//#region src/node/lib/search-indexer/index.ts
|
|
1141
|
-
var
|
|
1141
|
+
var xt = class {
|
|
1142
1142
|
index;
|
|
1143
1143
|
constructor() {
|
|
1144
|
-
this.index = new
|
|
1144
|
+
this.index = new x({
|
|
1145
1145
|
fields: t,
|
|
1146
1146
|
storeFields: i
|
|
1147
1147
|
});
|
|
@@ -1162,20 +1162,20 @@ var bt = class {
|
|
|
1162
1162
|
};
|
|
1163
1163
|
//#endregion
|
|
1164
1164
|
//#region src/node/lib/search-indexer/scan.ts
|
|
1165
|
-
function
|
|
1166
|
-
let n =
|
|
1165
|
+
function St(e, t) {
|
|
1166
|
+
let n = Et(e), r = [];
|
|
1167
1167
|
for (let t of n) {
|
|
1168
|
-
let n =
|
|
1168
|
+
let n = Tt(e, t);
|
|
1169
1169
|
n && r.push(n);
|
|
1170
1170
|
}
|
|
1171
1171
|
t.addAll(r);
|
|
1172
1172
|
}
|
|
1173
|
-
function
|
|
1174
|
-
let r =
|
|
1175
|
-
r ? n.addPage(r) : n.discardPage(
|
|
1173
|
+
function Ct(e, t, n) {
|
|
1174
|
+
let r = Tt(e, C(e, t));
|
|
1175
|
+
r ? n.addPage(r) : n.discardPage(y(t));
|
|
1176
1176
|
}
|
|
1177
|
-
function
|
|
1178
|
-
let n =
|
|
1177
|
+
function wt(e, t) {
|
|
1178
|
+
let n = d(e);
|
|
1179
1179
|
if (!t.startsWith("---")) return {
|
|
1180
1180
|
title: n,
|
|
1181
1181
|
body: t
|
|
@@ -1191,56 +1191,56 @@ function Ct(e, t) {
|
|
|
1191
1191
|
body: a
|
|
1192
1192
|
};
|
|
1193
1193
|
}
|
|
1194
|
-
function
|
|
1194
|
+
function Tt(e, t) {
|
|
1195
1195
|
let n;
|
|
1196
1196
|
try {
|
|
1197
|
-
n =
|
|
1197
|
+
n = le(t, "utf-8");
|
|
1198
1198
|
} catch {
|
|
1199
1199
|
return;
|
|
1200
1200
|
}
|
|
1201
1201
|
if (!n.trim()) return;
|
|
1202
|
-
let r = t.slice(e.length + 1), { title: i, body: a } =
|
|
1202
|
+
let r = t.slice(e.length + 1), { title: i, body: a } = wt(r, n);
|
|
1203
1203
|
return {
|
|
1204
|
-
id:
|
|
1204
|
+
id: y(r),
|
|
1205
1205
|
title: i,
|
|
1206
1206
|
text: `${i}\n${a}`
|
|
1207
1207
|
};
|
|
1208
1208
|
}
|
|
1209
|
-
function
|
|
1210
|
-
return
|
|
1209
|
+
function Et(e) {
|
|
1210
|
+
return ce("**/*.td", {
|
|
1211
1211
|
cwd: e,
|
|
1212
1212
|
exclude: (e) => e.startsWith("_")
|
|
1213
|
-
}).map((t) =>
|
|
1213
|
+
}).map((t) => C(e, t));
|
|
1214
1214
|
}
|
|
1215
1215
|
//#endregion
|
|
1216
1216
|
//#region src/node/plugin/vite/virtual/search-index.ts
|
|
1217
|
-
var
|
|
1218
|
-
indexer = new
|
|
1217
|
+
var Dt = "\0@typedown/search-index", Ot = class {
|
|
1218
|
+
indexer = new xt();
|
|
1219
1219
|
load(e) {
|
|
1220
1220
|
return `export default ${JSON.stringify(this.indexer.serialize())}`;
|
|
1221
1221
|
}
|
|
1222
1222
|
index(e) {
|
|
1223
|
-
|
|
1223
|
+
St(e, this.indexer);
|
|
1224
1224
|
}
|
|
1225
1225
|
reindex(e, t) {
|
|
1226
|
-
|
|
1226
|
+
Ct(e, t, this.indexer);
|
|
1227
1227
|
}
|
|
1228
1228
|
invalidate(e) {
|
|
1229
|
-
|
|
1229
|
+
Z(e, Dt);
|
|
1230
1230
|
}
|
|
1231
|
-
},
|
|
1232
|
-
function
|
|
1231
|
+
}, kt = me(import.meta.url);
|
|
1232
|
+
function At() {
|
|
1233
1233
|
return [{
|
|
1234
1234
|
find: "vue/server-renderer",
|
|
1235
|
-
replacement:
|
|
1235
|
+
replacement: kt.resolve("vue/server-renderer")
|
|
1236
1236
|
}, {
|
|
1237
1237
|
find: "vue",
|
|
1238
|
-
replacement:
|
|
1238
|
+
replacement: kt.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
1239
1239
|
}];
|
|
1240
1240
|
}
|
|
1241
1241
|
//#endregion
|
|
1242
1242
|
//#region src/node/plugin/vite/middleware/vault-assets.ts
|
|
1243
|
-
var
|
|
1243
|
+
var jt = {
|
|
1244
1244
|
jpg: "image/jpeg",
|
|
1245
1245
|
jpeg: "image/jpeg",
|
|
1246
1246
|
png: "image/png",
|
|
@@ -1258,17 +1258,17 @@ var kt = {
|
|
|
1258
1258
|
woff: "font/woff",
|
|
1259
1259
|
ttf: "font/ttf"
|
|
1260
1260
|
};
|
|
1261
|
-
function
|
|
1261
|
+
function Mt(e, t) {
|
|
1262
1262
|
return (n, r, i) => {
|
|
1263
1263
|
if (!n.url || n.method !== "GET" || r.writableEnded) return i();
|
|
1264
|
-
let a =
|
|
1264
|
+
let a = l(n.url);
|
|
1265
1265
|
if (a.startsWith("/@") || a.startsWith("/node_modules")) return i();
|
|
1266
|
-
let s = a.replace(/^\//, ""),
|
|
1267
|
-
if (
|
|
1268
|
-
let e =
|
|
1266
|
+
let s = a.replace(/^\//, ""), c = C(e.config.root, t.rootDirectory, s);
|
|
1267
|
+
if (se(c)) try {
|
|
1268
|
+
let e = ue(c);
|
|
1269
1269
|
if (e.isFile()) {
|
|
1270
|
-
let t =
|
|
1271
|
-
r.setHeader("Content-Type", t), r.setHeader("Content-Length", e.size),
|
|
1270
|
+
let t = jt[o(c).slice(1).toLowerCase()] ?? "application/octet-stream";
|
|
1271
|
+
r.setHeader("Content-Type", t), r.setHeader("Content-Length", e.size), oe(c).pipe(r);
|
|
1272
1272
|
return;
|
|
1273
1273
|
}
|
|
1274
1274
|
} catch {}
|
|
@@ -1277,31 +1277,31 @@ function At(e, t) {
|
|
|
1277
1277
|
}
|
|
1278
1278
|
//#endregion
|
|
1279
1279
|
//#region src/node/plugin/vite/middleware/virtual-html.ts
|
|
1280
|
-
function
|
|
1280
|
+
function Nt(e, t, n) {
|
|
1281
1281
|
return (r, i, o) => {
|
|
1282
1282
|
if (!r.url) return o();
|
|
1283
|
-
let s = a(
|
|
1284
|
-
if (s.startsWith("/@") || s.startsWith("/node_modules") || !s.startsWith(
|
|
1285
|
-
let u = s.slice(
|
|
1283
|
+
let s = a(l(r.url)), c = a(n.basePath);
|
|
1284
|
+
if (s.startsWith("/@") || s.startsWith("/node_modules") || !s.startsWith(c)) return o();
|
|
1285
|
+
let u = s.slice(c.length);
|
|
1286
1286
|
if (u.startsWith("/@") || u.startsWith("/node_modules") || s.includes(".") && !s.endsWith("/index.html")) return o();
|
|
1287
1287
|
t.getConfig().then(async (t) => {
|
|
1288
|
-
let a = await e.transformIndexHtml(r.url ?? "",
|
|
1288
|
+
let a = await e.transformIndexHtml(r.url ?? "", Pt(n, t));
|
|
1289
1289
|
i.setHeader("Content-Type", "text/html"), i.end(a);
|
|
1290
1290
|
}).catch(() => o());
|
|
1291
1291
|
};
|
|
1292
1292
|
}
|
|
1293
|
-
function
|
|
1294
|
-
return e.devHtml === void 0 && (e.devHtml =
|
|
1293
|
+
function Pt(e, t) {
|
|
1294
|
+
return e.devHtml === void 0 && (e.devHtml = he({
|
|
1295
1295
|
title: t.siteTitle,
|
|
1296
1296
|
description: t.siteDescription,
|
|
1297
1297
|
base: "/",
|
|
1298
|
-
entryScript:
|
|
1298
|
+
entryScript: dt
|
|
1299
1299
|
})), e.devHtml;
|
|
1300
1300
|
}
|
|
1301
1301
|
//#endregion
|
|
1302
1302
|
//#region src/node/plugin/vite/index.ts
|
|
1303
|
-
function
|
|
1304
|
-
let n = t.context, i, a, o, s = new
|
|
1303
|
+
function $(t = {}) {
|
|
1304
|
+
let n = t.context, i, a, o, s = new ht(), c = new gt(), l = new yt(), u = new Ot(), d = {
|
|
1305
1305
|
devHtml: void 0,
|
|
1306
1306
|
basePath: "/",
|
|
1307
1307
|
rootDirectory: "vault"
|
|
@@ -1315,7 +1315,7 @@ function Nt(t = {}) {
|
|
|
1315
1315
|
name: "vite-plugin-typedown",
|
|
1316
1316
|
enforce: "pre",
|
|
1317
1317
|
async config(e) {
|
|
1318
|
-
n ||=
|
|
1318
|
+
n ||= W(t.root ? C(e.root ?? process.cwd(), t.root) : ct(e.root ?? process.cwd())), o = e.base ?? "/";
|
|
1319
1319
|
let r = await (await f()).getConfig();
|
|
1320
1320
|
return {
|
|
1321
1321
|
base: e.base ?? r.basePath,
|
|
@@ -1324,29 +1324,29 @@ function Nt(t = {}) {
|
|
|
1324
1324
|
port: 8686,
|
|
1325
1325
|
strictPort: !1
|
|
1326
1326
|
},
|
|
1327
|
-
resolve: { alias:
|
|
1327
|
+
resolve: { alias: At() },
|
|
1328
1328
|
ssr: { noExternal: ["typerighter"] }
|
|
1329
1329
|
};
|
|
1330
1330
|
},
|
|
1331
1331
|
configResolved(e) {
|
|
1332
|
-
a =
|
|
1332
|
+
a = C(e.root, e.build.outDir);
|
|
1333
1333
|
},
|
|
1334
1334
|
async buildStart() {
|
|
1335
1335
|
if (i) return;
|
|
1336
|
-
let e = await f(), t = await e.getConfig(), n =
|
|
1336
|
+
let e = await f(), t = await e.getConfig(), n = C(t.rootDir);
|
|
1337
1337
|
u.index(n), await l.fetchSync(e);
|
|
1338
1338
|
let r = await e.checkVault();
|
|
1339
|
-
if (
|
|
1339
|
+
if (zt(r.diagnostics), 0 < r.errorCount) {
|
|
1340
1340
|
let e = r.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
1341
1341
|
this.error(`Vault check failed with ${r.errorCount} error(s):\n${e.join("\n")}`);
|
|
1342
1342
|
}
|
|
1343
1343
|
},
|
|
1344
1344
|
resolveId(e) {
|
|
1345
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return
|
|
1346
|
-
if (e === "@typedown/pages") return
|
|
1345
|
+
if (e === "/@typedown/app" || e === "@typedown/app") return G;
|
|
1346
|
+
if (e === "@typedown/pages") return q;
|
|
1347
1347
|
if (e.startsWith("@typedown/pages?resource=")) return c.resolvePageData(e);
|
|
1348
|
-
if (e === "@typedown/site-data") return
|
|
1349
|
-
if (e === "@typedown/search-index") return
|
|
1348
|
+
if (e === "@typedown/site-data") return ft;
|
|
1349
|
+
if (e === "@typedown/search-index") return pt;
|
|
1350
1350
|
},
|
|
1351
1351
|
async load(e) {
|
|
1352
1352
|
if (c.isPageDataModule(e)) return c.loadPageData(e, await f());
|
|
@@ -1359,20 +1359,20 @@ function Nt(t = {}) {
|
|
|
1359
1359
|
},
|
|
1360
1360
|
async configureServer(e) {
|
|
1361
1361
|
i = e;
|
|
1362
|
-
let t = await f(), n = await t.getConfig(), r =
|
|
1362
|
+
let t = await f(), n = await t.getConfig(), r = C(n.rootDir);
|
|
1363
1363
|
u.index(r), l.scan(r), l.fetch(t, i), e.httpServer?.once("listening", async () => {
|
|
1364
1364
|
let e = await t.checkVault();
|
|
1365
|
-
0 < e.diagnostics.length && (console.error(""),
|
|
1365
|
+
0 < e.diagnostics.length && (console.error(""), zt(e.diagnostics));
|
|
1366
1366
|
}), t.rpc.onConfigChanged(() => {
|
|
1367
|
-
i && (d.devHtml = void 0, l.clear(), s.invalidate(i), c.invalidate(i),
|
|
1367
|
+
i && (d.devHtml = void 0, l.clear(), s.invalidate(i), c.invalidate(i), It(i), l.fetch(t, i));
|
|
1368
1368
|
}), t.rpc.onContentChanged(({ content: e, affectedFiles: n = [] }) => {
|
|
1369
1369
|
i && (u.reindex(r, e), u.invalidate(i), t.getConfig().then((t) => {
|
|
1370
1370
|
if (!i) return;
|
|
1371
1371
|
let r = [e, ...n], a = [];
|
|
1372
1372
|
for (let e of r) {
|
|
1373
|
-
let n =
|
|
1373
|
+
let n = ne(C(i.config.root, t.rootDir, e)), r = i.moduleGraph.getModulesByFile(n);
|
|
1374
1374
|
if (r?.size) {
|
|
1375
|
-
for (let e of r) i?.moduleGraph.invalidateModule(e), a.push(
|
|
1375
|
+
for (let e of r) i?.moduleGraph.invalidateModule(e), a.push(Rt(e));
|
|
1376
1376
|
c.invalidatePageData(i, e);
|
|
1377
1377
|
}
|
|
1378
1378
|
}
|
|
@@ -1387,13 +1387,13 @@ function Nt(t = {}) {
|
|
|
1387
1387
|
}
|
|
1388
1388
|
t.rpc.onContentCreated(a), t.rpc.onContentDeleted(a);
|
|
1389
1389
|
function o() {
|
|
1390
|
-
i && (l.clear(),
|
|
1390
|
+
i && (l.clear(), Lt(i), l.fetch(t, i));
|
|
1391
1391
|
}
|
|
1392
1392
|
t.rpc.onSchemaChanged(o), t.rpc.onSchemaCreated(o), t.rpc.onSchemaDeleted(o);
|
|
1393
1393
|
let p = await t.getConfig();
|
|
1394
1394
|
d.basePath = p.basePath, d.rootDirectory = p.rootDir, t.rpc.onConfigChanged((e) => {
|
|
1395
1395
|
d.basePath = e.basePath, d.rootDirectory = e.rootDir, d.devHtml = void 0;
|
|
1396
|
-
}), e.middlewares.use(
|
|
1396
|
+
}), e.middlewares.use(Mt(e, d)), e.middlewares.use(Nt(e, t, d));
|
|
1397
1397
|
},
|
|
1398
1398
|
async transform(t, n) {
|
|
1399
1399
|
let i = n.split("?")[0];
|
|
@@ -1404,13 +1404,13 @@ function Nt(t = {}) {
|
|
|
1404
1404
|
};
|
|
1405
1405
|
let a = await f(), o = (await a.getConfig()).rootDir, s = i.includes(o) ? i.slice(i.indexOf(o) + o.length + 1) : i;
|
|
1406
1406
|
try {
|
|
1407
|
-
let { vueSrc: e } = await
|
|
1407
|
+
let { vueSrc: e } = await it(a, await a.getFile(s), s);
|
|
1408
1408
|
return {
|
|
1409
1409
|
code: e,
|
|
1410
1410
|
map: null
|
|
1411
1411
|
};
|
|
1412
1412
|
} catch (e) {
|
|
1413
|
-
if (
|
|
1413
|
+
if (V(e)) return;
|
|
1414
1414
|
let t = e instanceof Error ? e.message : String(e);
|
|
1415
1415
|
this.error(`[typedown] Failed to transform ${s}: ${t}`);
|
|
1416
1416
|
}
|
|
@@ -1421,8 +1421,8 @@ function Nt(t = {}) {
|
|
|
1421
1421
|
async closeBundle() {
|
|
1422
1422
|
if (!t.context && n) try {
|
|
1423
1423
|
let e = (await (await n.getTdContext()).getConfig()).basePath, t = e.startsWith(o) ? e.slice(o.length) : e.replace(/^\//, "");
|
|
1424
|
-
await
|
|
1425
|
-
outDir:
|
|
1424
|
+
await j(n, {
|
|
1425
|
+
outDir: C(a, t),
|
|
1426
1426
|
base: e
|
|
1427
1427
|
});
|
|
1428
1428
|
} finally {
|
|
@@ -1430,28 +1430,28 @@ function Nt(t = {}) {
|
|
|
1430
1430
|
}
|
|
1431
1431
|
}
|
|
1432
1432
|
},
|
|
1433
|
-
|
|
1433
|
+
ee({
|
|
1434
1434
|
include: t.root ? RegExp(`${t.root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/.*\\.(?:vue|td)$`) : /\.(?:vue|td)$/,
|
|
1435
1435
|
template: { transformAssetUrls: !1 }
|
|
1436
1436
|
}),
|
|
1437
|
-
...
|
|
1437
|
+
...T()
|
|
1438
1438
|
];
|
|
1439
1439
|
}
|
|
1440
|
-
function
|
|
1440
|
+
function Ft(e) {
|
|
1441
1441
|
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
1442
1442
|
}
|
|
1443
|
-
function
|
|
1444
|
-
for (let t of
|
|
1443
|
+
function It(e) {
|
|
1444
|
+
for (let t of Ft(e)) e.moduleGraph.invalidateModule(t);
|
|
1445
1445
|
e.hot.send({ type: "full-reload" });
|
|
1446
1446
|
}
|
|
1447
|
-
function
|
|
1448
|
-
let t =
|
|
1447
|
+
function Lt(e) {
|
|
1448
|
+
let t = Ft(e).map((t) => (e.moduleGraph.invalidateModule(t), Rt(t)));
|
|
1449
1449
|
0 < t.length && e.hot.send({
|
|
1450
1450
|
type: "update",
|
|
1451
1451
|
updates: t
|
|
1452
1452
|
});
|
|
1453
1453
|
}
|
|
1454
|
-
function
|
|
1454
|
+
function Rt(e) {
|
|
1455
1455
|
return {
|
|
1456
1456
|
type: "js-update",
|
|
1457
1457
|
path: e.url,
|
|
@@ -1459,11 +1459,11 @@ function Lt(e) {
|
|
|
1459
1459
|
timestamp: Date.now()
|
|
1460
1460
|
};
|
|
1461
1461
|
}
|
|
1462
|
-
function
|
|
1462
|
+
function zt(e) {
|
|
1463
1463
|
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} ${
|
|
1464
|
+
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? w.red("error") : w.yellow("warn");
|
|
1465
|
+
console.error(` ${n} ${e} ${t.message} ${w.dim(`(${t.code})`)}`);
|
|
1466
1466
|
}
|
|
1467
1467
|
}
|
|
1468
1468
|
//#endregion
|
|
1469
|
-
export {
|
|
1469
|
+
export { j as a, W as i, Q as n, U as r, $ as t };
|