typerighter 0.30.7 → 0.31.0

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