typerighter 0.32.6 → 0.38.0

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