typerighter 0.4.3 → 0.5.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,15 +1,16 @@
1
- import { o as e } from "./constants-7heqadyd.js";
1
+ import { o as e } from "./constants-Bo603IxE.js";
2
2
  import { C as t, D as n, E as r, S as i, d as a, f as o, l as s } from "./brand-CmL-6h9U.js";
3
- import { n as c, t as l } from "./vite-B-ktlRz9.js";
3
+ import { n as c, t as l } from "./vite-DaD9YRkN.js";
4
4
  import u from "node:path";
5
- import { build as d, createServer as f } from "vite";
6
- import p from "picocolors";
7
- import m from "node:fs/promises";
5
+ import d from "picocolors";
6
+ import { build as f, createServer as p } from "vite";
7
+ import m from "node:fs";
8
+ import h from "node:fs/promises";
8
9
  //#region src/node/build/prerender.ts
9
- async function h(e) {
10
- let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await _(e.clientOutDir), a = e.pagePaths.length, o = 0;
10
+ async function g(e) {
11
+ let t = await import(e.ssrEntryPath), { clientEntry: n, cssFiles: r, jsFiles: i } = await v(e.clientOutDir), a = e.pagePaths.length, o = 0;
11
12
  await Promise.all(e.pagePaths.map(async (s) => {
12
- let c = await t.render(s), l = g({
13
+ let c = await t.render(s), l = _({
13
14
  content: c.html,
14
15
  title: c.pageData.title,
15
16
  description: c.pageData.frontmatter.description === void 0 ? "" : String(c.pageData.frontmatter.description),
@@ -18,10 +19,10 @@ async function h(e) {
18
19
  jsFiles: i,
19
20
  base: e.base
20
21
  }), d = s === "/" ? "index.html" : `${s.replace(/^\//, "")}.html`, f = u.join(e.outDir, d);
21
- await m.mkdir(u.dirname(f), { recursive: !0 }), await m.writeFile(f, l), o++, e.progress?.update(o, a);
22
+ await h.mkdir(u.dirname(f), { recursive: !0 }), await h.writeFile(f, l), o++, e.progress?.update(o, a);
22
23
  }));
23
24
  }
24
- function g(e) {
25
+ function _(e) {
25
26
  let t = e.cssFiles.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), n = e.jsFiles.map((t) => ` <link rel="modulepreload" href="${e.base}${t}">`).join("\n");
26
27
  return `<!DOCTYPE html>
27
28
  <html lang="${e.lang ?? "en"}">
@@ -39,8 +40,8 @@ ${n}
39
40
  </body>
40
41
  </html>`;
41
42
  }
42
- async function _(e) {
43
- let t = u.join(e, ".vite", "manifest.json"), n = await m.readFile(t, "utf-8"), r = JSON.parse(n), i = "", a = [], o = [];
43
+ async function v(e) {
44
+ let t = u.join(e, ".vite", "manifest.json"), n = await h.readFile(t, "utf-8"), r = JSON.parse(n), i = "", a = [], o = [];
44
45
  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);
45
46
  return {
46
47
  clientEntry: i,
@@ -50,7 +51,7 @@ async function _(e) {
50
51
  }
51
52
  //#endregion
52
53
  //#region src/node/lib/progress.ts
53
- var v = class {
54
+ var y = class {
54
55
  logger;
55
56
  label;
56
57
  start;
@@ -65,47 +66,47 @@ var v = class {
65
66
  done(e) {
66
67
  process.stdout.isTTY && process.stdout.write("\r\x1B[K");
67
68
  let t = Math.round(performance.now() - this.start);
68
- this.logger.success(`${e} (${y(t)})`);
69
+ this.logger.success(`${e} (${b(t)})`);
69
70
  }
70
71
  };
71
- function y(e) {
72
+ function b(e) {
72
73
  return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
73
74
  }
74
75
  //#endregion
75
76
  //#region src/node/build/index.ts
76
- var b = "typerighter/client/theme-default";
77
- async function x(e, n = {}) {
78
- let { root: r, logger: i } = e, o = u.resolve(r, n.outDir ?? "dist"), s = n.base ?? "/", f = u.join(o, ".client"), p = u.join(o, ".server");
79
- await m.rm(o, {
77
+ var x = "typerighter/client/theme-default";
78
+ async function S(e, n = {}) {
79
+ let { root: r, logger: i } = e, o = u.resolve(r, n.outDir ?? "dist"), s = n.base ?? "/", d = u.join(o, ".client"), p = u.join(o, ".server");
80
+ await h.rm(o, {
80
81
  recursive: !0,
81
82
  force: !0
82
83
  });
83
- let g = await e.getTdContext(), [_, y, x, T] = await Promise.all([
84
- g.getConfig(),
85
- g.listFiles(),
86
- g.listFilesGroupedBySchema(),
87
- g.listSchemas()
88
- ]), E = await Promise.all(T.map(async (e) => [e, (await g.getSchema(e)).properties])), D = Object.fromEntries(E), O = a(Object.values(x).flat()), k = JSON.stringify({
84
+ let m = await e.getTdContext(), [_, v, b, S] = await Promise.all([
85
+ m.getConfig(),
86
+ m.listFiles(),
87
+ m.listFilesGroupedBySchema(),
88
+ m.listSchemas()
89
+ ]), E = await Promise.all(S.map(async (e) => [e, (await m.getSchema(e)).properties])), D = Object.fromEntries(E), O = a(Object.values(b).flat()), k = JSON.stringify({
89
90
  title: _.siteTitle,
90
91
  description: _.siteDescription
91
92
  }), A = JSON.stringify({ contentTree: O }), j = u.join(r, "node_modules", ".typerighter");
92
- await m.mkdir(j, { recursive: !0 });
93
+ await h.mkdir(j, { recursive: !0 });
93
94
  let M = u.join(j, "client-entry.js"), N = u.join(j, "ssr-entry.js");
94
- await Promise.all([m.writeFile(M, l({
95
+ await Promise.all([h.writeFile(M, l({
95
96
  contentDir: _.contentDir,
96
97
  siteTitle: _.siteTitle,
97
98
  siteDescription: _.siteDescription,
98
99
  contentTree: O,
99
100
  schemas: D
100
- })), m.writeFile(N, S({
101
+ })), h.writeFile(N, C({
101
102
  contentDir: _.contentDir,
102
- layoutImport: b,
103
+ layoutImport: x,
103
104
  siteConfig: k,
104
105
  siteData: A
105
106
  }))]);
106
107
  try {
107
- let a = c({ context: e }), l = e.createViteLogger(), g = new v(i, "Building client bundle...");
108
- await d({
108
+ let a = c({ context: e }), l = e.createViteLogger(), m = new y(i, "Building client bundle...");
109
+ await f({
109
110
  ...n.viteConfig,
110
111
  root: r,
111
112
  base: s,
@@ -114,7 +115,7 @@ async function x(e, n = {}) {
114
115
  logLevel: "silent",
115
116
  build: {
116
117
  ...n.viteConfig?.build,
117
- outDir: f,
118
+ outDir: d,
118
119
  manifest: !0,
119
120
  emptyOutDir: !0,
120
121
  rollupOptions: {
@@ -123,10 +124,10 @@ async function x(e, n = {}) {
123
124
  }
124
125
  }
125
126
  });
126
- let b = await m.readdir(u.join(f, "assets")).catch(() => []);
127
- g.done(`Client bundle (${b.length} chunks)`);
128
- let x = new v(i, "Building SSR bundle...");
129
- await d({
127
+ let b = await h.readdir(u.join(d, "assets")).catch(() => []);
128
+ m.done(`Client bundle (${b.length} chunks)`);
129
+ let x = new y(i, "Building SSR bundle...");
130
+ await f({
130
131
  ...n.viteConfig,
131
132
  root: r,
132
133
  base: s,
@@ -140,33 +141,33 @@ async function x(e, n = {}) {
140
141
  emptyOutDir: !0
141
142
  }
142
143
  }), x.done("SSR bundle");
143
- let S = y.map((e) => {
144
+ let S = v.map((e) => {
144
145
  let n = t(e);
145
146
  return n === "index" ? "/" : `/${n}`;
146
147
  });
147
- S.push("/"), w(O.children, "", S);
148
- let T = new v(i, "Pre-rendering pages...");
149
- await h({
148
+ S.push("/"), T(O.children, "", S);
149
+ let C = new y(i, "Pre-rendering pages...");
150
+ await g({
150
151
  ssrEntryPath: u.join(p, "ssr-entry.js"),
151
- clientOutDir: f,
152
+ clientOutDir: d,
152
153
  outDir: o,
153
154
  base: s,
154
155
  pagePaths: S,
155
- progress: T
156
- }), T.done(`Pre-rendered ${S.length} pages`);
157
- let E = u.join(f, "assets"), D = u.join(o, "assets");
158
- await m.cp(E, D, { recursive: !0 }).catch(() => {}), await C(u.join(r, _.contentDir), o);
156
+ progress: C
157
+ }), C.done(`Pre-rendered ${S.length} pages`);
158
+ let E = u.join(d, "assets"), D = u.join(o, "assets");
159
+ await h.cp(E, D, { recursive: !0 }).catch(() => {}), await w(u.join(r, _.contentDir), o);
159
160
  } finally {
160
161
  await Promise.all([
161
- m.rm(j, {
162
+ h.rm(j, {
162
163
  recursive: !0,
163
164
  force: !0
164
165
  }),
165
- m.rm(f, {
166
+ h.rm(d, {
166
167
  recursive: !0,
167
168
  force: !0
168
169
  }),
169
- m.rm(p, {
170
+ h.rm(p, {
170
171
  recursive: !0,
171
172
  force: !0
172
173
  })
@@ -174,7 +175,7 @@ async function x(e, n = {}) {
174
175
  }
175
176
  i.log(`\nBuild complete. Output: ${o}`);
176
177
  }
177
- function S(e) {
178
+ function C(e) {
178
179
  let t = `/${e.contentDir}/${n}`, i = JSON.parse(e.siteConfig), a = o((JSON.parse(e.siteData).contentTree ?? {
179
180
  rootItems: [],
180
181
  children: []
@@ -222,36 +223,36 @@ export async function render(url) {
222
223
  }
223
224
  `;
224
225
  }
225
- async function C(e, t) {
226
- let n = (await m.readdir(e, {
226
+ async function w(e, t) {
227
+ let n = (await h.readdir(e, {
227
228
  recursive: !0,
228
229
  withFileTypes: !0
229
230
  })).filter((e) => e.isFile() && !i(e.name)).map(async (n) => {
230
231
  let r = u.join(n.parentPath, n.name), i = u.relative(e, r), a = u.join(t, i);
231
- return m.mkdir(u.dirname(a), { recursive: !0 }).then(() => m.copyFile(r, a));
232
+ return h.mkdir(u.dirname(a), { recursive: !0 }).then(() => h.copyFile(r, a));
232
233
  });
233
234
  await Promise.all(n);
234
235
  }
235
- function w(e, t, n) {
236
+ function T(e, t, n) {
236
237
  for (let r of e) {
237
238
  let e = `${t}/${r.name}`;
238
- n.push(e), w(r.children, e, n);
239
+ n.push(e), T(r.children, e, n);
239
240
  }
240
241
  }
241
242
  //#endregion
242
243
  //#region ../../node_modules/.pnpm/cac@7.0.0/node_modules/cac/dist/index.js
243
- function T(e) {
244
+ function E(e) {
244
245
  return e == null ? [] : Array.isArray(e) ? e : [e];
245
246
  }
246
- function E(e, t, n, r) {
247
+ function D(e, t, n, r) {
247
248
  var i, a = e[t], o = ~r.string.indexOf(t) ? n == null || n === !0 ? "" : String(n) : typeof n == "boolean" ? n : ~r.boolean.indexOf(t) ? n === "false" ? !1 : n === "true" || (e._.push((i = +n, i * 0 == 0 ? i : n)), !!n) : (i = +n, i * 0 == 0 ? i : n);
248
249
  e[t] = a == null ? o : Array.isArray(a) ? a.concat(o) : [a, o];
249
250
  }
250
- function D(e, t) {
251
+ function O(e, t) {
251
252
  e ||= [], t ||= {};
252
253
  var n, r, i, a, o, s = { _: [] }, c = 0, l = 0, u = 0, d = e.length;
253
254
  let f = t.alias !== void 0, p = t.unknown !== void 0, m = t.default !== void 0;
254
- if (t.alias = t.alias || {}, t.string = T(t.string), t.boolean = T(t.boolean), f) for (n in t.alias) for (r = t.alias[n] = T(t.alias[n]), c = 0; c < r.length; c++) (t.alias[r[c]] = r.concat(n)).splice(c, 1);
255
+ if (t.alias = t.alias || {}, t.string = E(t.string), t.boolean = E(t.boolean), f) for (n in t.alias) for (r = t.alias[n] = E(t.alias[n]), c = 0; c < r.length; c++) (t.alias[r[c]] = r.concat(n)).splice(c, 1);
255
256
  for (c = t.boolean.length; c-- > 0;) for (r = t.alias[t.boolean[c]] || [], l = r.length; l-- > 0;) t.boolean.push(r[l]);
256
257
  for (c = t.string.length; c-- > 0;) for (r = t.alias[t.string[c]] || [], l = r.length; l-- > 0;) t.string.push(r[l]);
257
258
  if (m) {
@@ -272,7 +273,7 @@ function D(e, t) {
272
273
  for (u = l + 1; u < i.length && i.charCodeAt(u) !== 61; u++);
273
274
  for (a = i.substring(l, u), o = i.substring(++u) || c + 1 === d || ("" + e[c + 1]).charCodeAt(0) === 45 || e[++c], r = l === 2 ? [a] : a, u = 0; u < r.length; u++) {
274
275
  if (a = r[u], p && !~h.indexOf(a)) return t.unknown("-".repeat(l) + a);
275
- E(s, a, u + 1 < r.length || o, t);
276
+ D(s, a, u + 1 < r.length || o, t);
276
277
  }
277
278
  }
278
279
  }
@@ -280,10 +281,10 @@ function D(e, t) {
280
281
  if (f) for (n in s) for (r = t.alias[n] || []; r.length > 0;) s[r.shift()] = s[n];
281
282
  return s;
282
283
  }
283
- function O(e) {
284
+ function k(e) {
284
285
  return e.replace(/[<[].+/, "").trim();
285
286
  }
286
- function k(e) {
287
+ function A(e) {
287
288
  let t = /<([^>]+)>/g, n = /\[([^\]]+)\]/g, r = [], i = (e) => {
288
289
  let t = !1, n = e[1];
289
290
  return n.startsWith("...") && (n = n.slice(3), t = !0), {
@@ -297,7 +298,7 @@ function k(e) {
297
298
  for (; o = n.exec(e);) r.push(i(o));
298
299
  return r;
299
300
  }
300
- function A(e) {
301
+ function j(e) {
301
302
  let t = {
302
303
  alias: {},
303
304
  boolean: []
@@ -305,16 +306,16 @@ function A(e) {
305
306
  for (let [n, r] of e.entries()) r.names.length > 1 && (t.alias[r.names[0]] = r.names.slice(1)), r.isBoolean && (r.negated && e.some((e, t) => t !== n && e.names.some((e) => r.names.includes(e)) && typeof e.required == "boolean") || t.boolean.push(r.names[0]));
306
307
  return t;
307
308
  }
308
- function j(e) {
309
+ function M(e) {
309
310
  return e.sort((e, t) => e.length > t.length ? -1 : 1)[0];
310
311
  }
311
- function M(e, t) {
312
+ function N(e, t) {
312
313
  return e.length >= t ? e : `${e}${" ".repeat(t - e.length)}`;
313
314
  }
314
- function N(e) {
315
+ function P(e) {
315
316
  return e.replaceAll(/([a-z])-([a-z])/g, (e, t, n) => t + n.toUpperCase());
316
317
  }
317
- function P(e, t, n) {
318
+ function F(e, t, n) {
318
319
  let r = e;
319
320
  for (let e = 0; e < t.length; e++) {
320
321
  let i = t[e];
@@ -329,24 +330,24 @@ function P(e, t, n) {
329
330
  r = r[i];
330
331
  }
331
332
  }
332
- function F(e, t) {
333
+ function I(e, t) {
333
334
  for (let n of Object.keys(t)) {
334
335
  let r = t[n];
335
336
  r.shouldTransform && (e[n] = [e[n]].flat(), typeof r.transformFunction == "function" && (e[n] = e[n].map(r.transformFunction)));
336
337
  }
337
338
  }
338
- function I(e) {
339
+ function L(e) {
339
340
  let t = /([^\\/]+)$/.exec(e);
340
341
  return t ? t[1] : "";
341
342
  }
342
- function L(e) {
343
- return e.split(".").map((e, t) => t === 0 ? N(e) : e).join(".");
343
+ function R(e) {
344
+ return e.split(".").map((e, t) => t === 0 ? P(e) : e).join(".");
344
345
  }
345
- var R = class extends Error {
346
+ var z = class extends Error {
346
347
  constructor(e) {
347
348
  super(e), this.name = "CACError", typeof Error.captureStackTrace != "function" && (this.stack = Error(e).stack);
348
349
  }
349
- }, z = class {
350
+ }, B = class {
350
351
  rawName;
351
352
  description;
352
353
  name;
@@ -356,17 +357,17 @@ var R = class extends Error {
356
357
  config;
357
358
  negated;
358
359
  constructor(e, t, n) {
359
- this.rawName = e, this.description = t, this.config = Object.assign({}, n), e = e.replaceAll(".*", ""), this.negated = !1, this.names = O(e).split(",").map((e) => {
360
+ this.rawName = e, this.description = t, this.config = Object.assign({}, n), e = e.replaceAll(".*", ""), this.negated = !1, this.names = k(e).split(",").map((e) => {
360
361
  let t = e.trim().replace(/^-{1,2}/, "");
361
- return t.startsWith("no-") && (this.negated = !0, t = t.replace(/^no-/, "")), L(t);
362
+ return t.startsWith("no-") && (this.negated = !0, t = t.replace(/^no-/, "")), R(t);
362
363
  }).sort((e, t) => e.length > t.length ? 1 : -1), this.name = this.names.at(-1), this.negated && this.config.default == null && (this.config.default = !0), e.includes("<") ? this.required = !0 : e.includes("[") ? this.required = !1 : this.isBoolean = !0;
363
364
  }
364
- }, B, V;
365
+ }, V, H;
365
366
  if (typeof process < "u") {
366
367
  let e;
367
- e = typeof Deno < "u" && typeof Deno.version?.deno == "string" ? "deno" : typeof Bun < "u" && typeof Bun.version == "string" ? "bun" : "node", V = `${process.platform}-${process.arch} ${e}-${process.version}`, B = process.argv;
368
- } else V = typeof navigator > "u" ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
369
- var H = class {
368
+ e = typeof Deno < "u" && typeof Deno.version?.deno == "string" ? "deno" : typeof Bun < "u" && typeof Bun.version == "string" ? "bun" : "node", H = `${process.platform}-${process.arch} ${e}-${process.version}`, V = process.argv;
369
+ } else H = typeof navigator > "u" ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
370
+ var U = class {
370
371
  rawName;
371
372
  description;
372
373
  config;
@@ -382,7 +383,7 @@ var H = class {
382
383
  helpCallback;
383
384
  globalCommand;
384
385
  constructor(e, t, n = {}, r) {
385
- this.rawName = e, this.description = t, this.config = n, this.cli = r, this.options = [], this.aliasNames = [], this.name = O(e), this.args = k(e), this.examples = [];
386
+ this.rawName = e, this.description = t, this.config = n, this.cli = r, this.options = [], this.aliasNames = [], this.name = k(e), this.args = A(e), this.examples = [];
386
387
  }
387
388
  usage(e) {
388
389
  return this.usageText = e, this;
@@ -400,7 +401,7 @@ var H = class {
400
401
  return this.examples.push(e), this;
401
402
  }
402
403
  option(e, t, n) {
403
- let r = new z(e, t, n);
404
+ let r = new B(e, t, n);
404
405
  return this.options.push(r), this;
405
406
  }
406
407
  alias(e) {
@@ -416,7 +417,7 @@ var H = class {
416
417
  return this.name === "" || this.aliasNames.includes("!");
417
418
  }
418
419
  get isGlobalCommand() {
419
- return this instanceof U;
420
+ return this instanceof W;
420
421
  }
421
422
  hasOption(e) {
422
423
  return e = e.split(".")[0], this.options.find((t) => t.names.includes(e));
@@ -427,10 +428,10 @@ var H = class {
427
428
  title: "Usage",
428
429
  body: ` $ ${e} ${this.usageText || this.rawName}`
429
430
  }), (this.isGlobalCommand || this.isDefaultCommand) && t.length > 0) {
430
- let n = j(t.map((e) => e.rawName));
431
+ let n = M(t.map((e) => e.rawName));
431
432
  a.push({
432
433
  title: "Commands",
433
- body: t.map((e) => ` ${M(e.rawName, n.length)} ${e.description}`).join("\n")
434
+ body: t.map((e) => ` ${N(e.rawName, n.length)} ${e.description}`).join("\n")
434
435
  }, {
435
436
  title: "For more info, run any command with the `--help` flag",
436
437
  body: t.map((t) => ` $ ${e}${t.name === "" ? "" : ` ${t.name}`} --help`).join("\n")
@@ -438,10 +439,10 @@ var H = class {
438
439
  }
439
440
  let o = this.isGlobalCommand ? r : [...this.options, ...r || []];
440
441
  if (!this.isGlobalCommand && !this.isDefaultCommand && (o = o.filter((e) => e.name !== "version")), o.length > 0) {
441
- let e = j(o.map((e) => e.rawName));
442
+ let e = M(o.map((e) => e.rawName));
442
443
  a.push({
443
444
  title: "Options",
444
- body: o.map((t) => ` ${M(t.rawName, e.length)} ${t.description} ${t.config.default === void 0 ? "" : `(default: ${t.config.default})`}`).join("\n")
445
+ body: o.map((t) => ` ${N(t.rawName, e.length)} ${t.description} ${t.config.default === void 0 ? "" : `(default: ${t.config.default})`}`).join("\n")
445
446
  });
446
447
  }
447
448
  this.examples.length > 0 && a.push({
@@ -451,16 +452,16 @@ var H = class {
451
452
  }
452
453
  outputVersion() {
453
454
  let { name: e } = this.cli, { versionNumber: t } = this.cli.globalCommand;
454
- t && console.info(`${e}/${t} ${V}`);
455
+ t && console.info(`${e}/${t} ${H}`);
455
456
  }
456
457
  checkRequiredArgs() {
457
458
  let e = this.args.filter((e) => e.required).length;
458
- if (this.cli.args.length < e) throw new R(`missing required args for command \`${this.rawName}\``);
459
+ if (this.cli.args.length < e) throw new z(`missing required args for command \`${this.rawName}\``);
459
460
  }
460
461
  checkUnknownOptions() {
461
462
  let { options: e, globalCommand: t } = this.cli;
462
463
  if (!this.config.allowUnknownOptions) {
463
- for (let n of Object.keys(e)) if (n !== "--" && !this.hasOption(n) && !t.hasOption(n)) throw new R(`Unknown option \`${n.length > 1 ? `--${n}` : `-${n}`}\``);
464
+ for (let n of Object.keys(e)) if (n !== "--" && !this.hasOption(n) && !t.hasOption(n)) throw new z(`Unknown option \`${n.length > 1 ? `--${n}` : `-${n}`}\``);
464
465
  }
465
466
  }
466
467
  checkOptionValue() {
@@ -469,19 +470,19 @@ var H = class {
469
470
  let r = e[t.name.split(".")[0]];
470
471
  if (t.required) {
471
472
  let e = n.some((e) => e.negated && e.names.includes(t.name));
472
- if (r === !0 || r === !1 && !e) throw new R(`option \`${t.rawName}\` value is missing`);
473
+ if (r === !0 || r === !1 && !e) throw new z(`option \`${t.rawName}\` value is missing`);
473
474
  }
474
475
  }
475
476
  }
476
477
  checkUnusedArgs() {
477
478
  let e = this.args.some((e) => e.variadic) ? Infinity : this.args.length;
478
- if (e < this.cli.args.length) throw new R(`Unused args: ${this.cli.args.slice(e).map((e) => `\`${e}\``).join(", ")}`);
479
+ if (e < this.cli.args.length) throw new z(`Unused args: ${this.cli.args.slice(e).map((e) => `\`${e}\``).join(", ")}`);
479
480
  }
480
- }, U = class extends H {
481
+ }, W = class extends U {
481
482
  constructor(e) {
482
483
  super("@@global@@", "", {}, e);
483
484
  }
484
- }, W = class extends EventTarget {
485
+ }, G = class extends EventTarget {
485
486
  name;
486
487
  commands;
487
488
  globalCommand;
@@ -493,13 +494,13 @@ var H = class {
493
494
  showHelpOnExit;
494
495
  showVersionOnExit;
495
496
  constructor(e = "") {
496
- super(), this.name = e, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new U(this), this.globalCommand.usage("<command> [options]");
497
+ super(), this.name = e, this.commands = [], this.rawArgs = [], this.args = [], this.options = {}, this.globalCommand = new W(this), this.globalCommand.usage("<command> [options]");
497
498
  }
498
499
  usage(e) {
499
500
  return this.globalCommand.usage(e), this;
500
501
  }
501
502
  command(e, t, n) {
502
- let r = new H(e, t || "", n, this);
503
+ let r = new U(e, t || "", n, this);
503
504
  return r.globalCommand = this.globalCommand, this.commands.push(r), r;
504
505
  }
505
506
  option(e, t, n) {
@@ -528,10 +529,10 @@ var H = class {
528
529
  }
529
530
  parse(e, { run: t = !0 } = {}) {
530
531
  if (!e) {
531
- if (!B) throw Error("No argv provided and runtime process argv is not available.");
532
- e = B;
532
+ if (!V) throw Error("No argv provided and runtime process argv is not available.");
533
+ e = V;
533
534
  }
534
- this.rawArgs = e, this.name ||= e[1] ? I(e[1]) : "cli";
535
+ this.rawArgs = e, this.name ||= e[1] ? L(e[1]) : "cli";
535
536
  let n = !0;
536
537
  for (let t of this.commands) {
537
538
  let r = this.mri(e.slice(2), t), i = r.args[0];
@@ -563,19 +564,19 @@ var H = class {
563
564
  return t && this.runMatchedCommand(), !this.matchedCommand && this.args[0] && this.dispatchEvent(new CustomEvent("command:*", { detail: this.args[0] })), r;
564
565
  }
565
566
  mri(e, t) {
566
- let n = [...this.globalCommand.options, ...t ? t.options : []], r = A(n), i = [], a = e.indexOf("--");
567
+ let n = [...this.globalCommand.options, ...t ? t.options : []], r = j(n), i = [], a = e.indexOf("--");
567
568
  a !== -1 && (i = e.slice(a + 1), e = e.slice(0, a));
568
- let o = D(e, r);
569
+ let o = O(e, r);
569
570
  o = Object.keys(o).reduce((e, t) => ({
570
571
  ...e,
571
- [L(t)]: o[t]
572
+ [R(t)]: o[t]
572
573
  }), { _: [] });
573
574
  let s = o._, c = { "--": i }, l = t && t.config.ignoreOptionDefaultValue ? t.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue, u = Object.create(null);
574
575
  for (let e of n) {
575
576
  if (!l && e.config.default !== void 0) for (let t of e.names) c[t] = e.config.default;
576
577
  Array.isArray(e.config.type) && u[e.name] === void 0 && (u[e.name] = Object.create(null), u[e.name].shouldTransform = !0, u[e.name].transformFunction = e.config.type[0]);
577
578
  }
578
- for (let e of Object.keys(o)) e !== "_" && (P(c, e.split("."), o[e]), F(c, u));
579
+ for (let e of Object.keys(o)) e !== "_" && (F(c, e.split("."), o[e]), I(c, u));
579
580
  return {
580
581
  args: s,
581
582
  options: c
@@ -590,16 +591,16 @@ var H = class {
590
591
  t.variadic ? r.push(e.slice(n)) : r.push(e[n]);
591
592
  }), r.push(t), n.commandAction.apply(this, r);
592
593
  }
593
- }, G = (e = "") => new W(e), K = p.bold(p.cyan("[typerighter]"));
594
- function q() {
595
- let t = G("typerighter");
594
+ }, K = (e = "") => new G(e), q = d.bold(d.cyan("[typerighter]"));
595
+ function J() {
596
+ let t = K("typerighter");
596
597
  process.on("uncaughtException", (e) => {
597
- J("runtime", e);
598
+ Y("runtime", e);
598
599
  }), process.on("unhandledRejection", (e) => {
599
- J("runtime", e instanceof Error ? e : Error(String(e)));
600
+ Y("runtime", e instanceof Error ? e : Error(String(e)));
600
601
  }), t.command("[root]", "Start dev server").alias("dev").option("--port <port>", "Port to listen on").option("--host", "Expose to network").action(async (e, t) => {
601
- let n = await f({
602
- root: Y(e),
602
+ let n = await p({
603
+ root: X(e),
603
604
  configFile: !1,
604
605
  plugins: [c()],
605
606
  server: {
@@ -609,9 +610,9 @@ function q() {
609
610
  });
610
611
  await n.listen(), n.printUrls();
611
612
  }), t.command("build [root]", "Build for production").option("--outDir <dir>", "Output directory", { default: "dist" }).option("--base <path>", "Base public path", { default: "/" }).action(async (t, n) => {
612
- let r = e(Y(t));
613
+ let r = e(X(t));
613
614
  try {
614
- await x(r, {
615
+ await S(r, {
615
616
  outDir: n.outDir,
616
617
  base: n.base
617
618
  });
@@ -619,22 +620,44 @@ function q() {
619
620
  r.dispose();
620
621
  }
621
622
  }), t.command("init [root]", "Scaffold a new project").action(async (e) => {
622
- let { initialize: t } = await import("./init-DCkztTxJ.js");
623
- await t(Y(e));
623
+ let { initialize: t } = await import("./init-a4nECqEz.js");
624
+ await t(X(e));
624
625
  }), t.command("preview [root]", "Preview production build").option("--port <port>", "Port to listen on").action(async (e, t) => {
625
626
  let { preview: n } = await import("vite");
626
627
  (await n({
627
- root: Y(e),
628
+ root: X(e),
628
629
  preview: { port: t.port }
629
630
  })).printUrls();
630
- }), t.help(), t.version("0.4.3"), t.parse();
631
+ }), t.command("check [root]", "Check vault for errors").option("--fix", "Auto-fix formatting issues").action(async (t, n) => {
632
+ let r = e(X(t)), { logger: i } = r;
633
+ try {
634
+ i.start("Checking vault...");
635
+ let e = await r.getTdContext(), t = await e.checkVault();
636
+ for (let e of t.diagnostics) e.severity === "error" ? i.error(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`) : i.warn(`${e.filepath}:${e.line}:${e.column} ${e.message} (${e.code})`);
637
+ if (n.fix && 0 < t.warningCount) {
638
+ let t = await e.getConfig(), n = await e.listFiles(), r = 0;
639
+ for (let i of n) {
640
+ let n = await e.formatFile(i);
641
+ if (n.changed) {
642
+ let e = u.resolve(t.contentDir, i);
643
+ m.writeFileSync(e, n.content), r++;
644
+ }
645
+ }
646
+ 0 < r && i.success(`Fixed ${r} file(s)`);
647
+ }
648
+ let a = `${t.fileCount} files checked, ${t.errorCount} error(s), ${t.warningCount} warning(s)`;
649
+ 0 < t.errorCount ? (i.error(a), process.exit(1)) : i.success(a);
650
+ } finally {
651
+ r.dispose();
652
+ }
653
+ }), t.help(), t.version("0.5.0"), t.parse();
631
654
  }
632
- function J(e, t) {
655
+ function Y(e, t) {
633
656
  let n = t instanceof Error ? t.message : String(t);
634
- console.error(`\n${K} ${p.red(`${e} failed`)}\n`), console.error(p.red(n)), console.error(""), process.exit(1);
657
+ console.error(`\n${q} ${d.red(`${e} failed`)}\n`), console.error(d.red(n)), console.error(""), process.exit(1);
635
658
  }
636
- function Y(e) {
659
+ function X(e) {
637
660
  return u.resolve(e ?? process.cwd());
638
661
  }
639
662
  //#endregion
640
- export { x as n, q as t };
663
+ export { S as n, J as t };
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as e } from "./cli-BbvLsY1i.js";
1
+ import { t as e } from "./cli-9LGeV7cc.js";
2
2
  export { e as cli };
@@ -1,12 +1,12 @@
1
1
  import { T as EXTERNAL_URL_RE, b as isUrlToPage, y as isUrlExternal } from "./brand-CmL-6h9U.js";
2
2
  import path from "node:path";
3
+ import pc from "picocolors";
3
4
  import { createLogger } from "vite";
4
5
  import fs from "node:fs";
5
6
  import { RpcServer } from "@typerighter/rpc-server";
6
7
  import { RpcClient } from "@typerighter/rpc-client";
7
8
  import MarkdownIt from "markdown-it";
8
9
  import { createHighlighter, guessEmbeddedLanguages, isSpecialLang } from "shiki";
9
- import pc from "picocolors";
10
10
  import { URL as URL$1 } from "node:url";
11
11
  //#region \0rolldown/runtime.js
12
12
  var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJSMin = (A, j) => () => (j || (A((j = { exports: {} }).exports, j), A = null), j.exports), __copyProps = (A, j, M, N) => {
@@ -32099,6 +32099,12 @@ var TypedownContext = class {
32099
32099
  async listSchemas() {
32100
32100
  return this.cachedSchemas ||= await this.rpc.listSchemas(), this.cachedSchemas;
32101
32101
  }
32102
+ async checkVault() {
32103
+ return this.rpc.checkVault();
32104
+ }
32105
+ async formatFile(A) {
32106
+ return this.rpc.formatFile(A);
32107
+ }
32102
32108
  get md() {
32103
32109
  return this._md;
32104
32110
  }
@@ -32122,7 +32128,7 @@ function createAppContext(A) {
32122
32128
  }
32123
32129
  let N, P, F, I = !1;
32124
32130
  function L() {
32125
- B(), process.exit(0);
32131
+ j.log(""), B(), process.exit(0);
32126
32132
  }
32127
32133
  function R() {
32128
32134
  B();
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as e, t } from "./vite-B-ktlRz9.js";
1
+ import { n as e, t } from "./vite-DaD9YRkN.js";
2
2
  import "./vite.js";
3
- import { n, t as r } from "./cli-BbvLsY1i.js";
3
+ import { n, t as r } from "./cli-9LGeV7cc.js";
4
4
  export { n as buildSite, r as cli, t as generateClientAppEntry, e as typedown };
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, i as n } from "./constants-7heqadyd.js";
1
+ import { a as e, c as t, i as n } from "./constants-Bo603IxE.js";
2
2
  import { l as r, r as i } from "./brand-CmL-6h9U.js";
3
3
  import a from "node:path";
4
4
  import "node:fs";
@@ -2298,7 +2298,7 @@ function ei(e) {
2298
2298
  build: "typerighter build",
2299
2299
  preview: "typerighter preview"
2300
2300
  },
2301
- devDependencies: { typerighter: "^0.4.3" }
2301
+ devDependencies: { typerighter: "^0.5.0" }
2302
2302
  }, void 0, 2) + "\n";
2303
2303
  }
2304
2304
  function ti() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/cli/index.ts"],"names":[],"mappings":"AAkBA,wBAAgB,GAAG,SA4FlB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/cli/index.ts"],"names":[],"mappings":"AAmBA,wBAAgB,GAAG,SAsJlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/node/context.ts"],"names":[],"mappings":"AAEA,OAAO,EACS,KAAK,MAAM,EAC1B,MAAM,MAAM,CAAC;AAOd,OAAO,EACL,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,QAAQ,EACT,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC;IACjB,YAAY,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7C,gBAAgB,EAAE,MAAM,MAAM,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,UAG7B,CAAC;AAEF,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAmG1D;AAGD,wBAAgB,kBAAkB,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAaxD"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/node/context.ts"],"names":[],"mappings":"AAEA,OAAO,EACS,KAAK,MAAM,EAC1B,MAAM,MAAM,CAAC;AAOd,OAAO,EACL,eAAe,EAChB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,QAAQ,EACT,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC;IACjB,YAAY,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7C,gBAAgB,EAAE,MAAM,MAAM,CAAC;IAC/B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,UAG7B,CAAC;AAEF,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAoG1D;AAGD,wBAAgB,kBAAkB,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAaxD"}
@@ -1,4 +1,4 @@
1
- import type { RpcClient, TdBuiltResource, TdSiteConfig, TdSchemaInfo } from '@typerighter/rpc-client';
1
+ import type { RpcClient, TdBuiltResource, TdDiagnosticReport, TdFormatResult, TdSiteConfig, TdSchemaInfo } from '@typerighter/rpc-client';
2
2
  import { type MarkdownRenderer } from './markdown';
3
3
  import type { SchemaGroups } from '@/shared';
4
4
  export declare class TypedownContext {
@@ -22,6 +22,8 @@ export declare class TypedownContext {
22
22
  getAssetDir(filepath: string): Promise<string>;
23
23
  getSchema(schema: string): Promise<TdSchemaInfo>;
24
24
  listSchemas(): Promise<string[]>;
25
+ checkVault(): Promise<TdDiagnosticReport>;
26
+ formatFile(filepath: string): Promise<TdFormatResult>;
25
27
  get md(): MarkdownRenderer;
26
28
  }
27
29
  //# sourceMappingURL=typedown-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typedown-context.d.ts","sourceRoot":"","sources":["../../../src/node/lib/typedown-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EAAE,YAAY,EAAE,YAAY,EAC5C,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACmB,KAAK,gBAAgB,EAC9C,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,YAAY,EACb,MAAM,UAAU,CAAC;AAIlB,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,GAAG,CAAmB;gBAEjB,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,gBAAgB;IAMpD,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,0BAA0B,CAA2B;IAC7D,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,aAAa,CAAsC;IAE3D,OAAO,CAAC,aAAa,CAAK;IAE1B,OAAO,CAAC,4BAA4B;IA8DpC,IAAI,GAAG,IAAK,SAAS,CAEpB;IAIK,OAAO,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAIpD,QAAQ,CAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAatD,SAAS,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ/B,wBAAwB,IAAK,OAAO,CAAC,YAAY,CAAC;IAgBlD,SAAS,IAAK,OAAO,CAAC,YAAY,CAAC;IASnC,WAAW,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM/C,SAAS,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAYjD,WAAW,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAQvC,IAAI,EAAE,IAAK,gBAAgB,CAE1B;CACF"}
1
+ {"version":3,"file":"typedown-context.d.ts","sourceRoot":"","sources":["../../../src/node/lib/typedown-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAChF,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACmB,KAAK,gBAAgB,EAC9C,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,YAAY,EACb,MAAM,UAAU,CAAC;AAIlB,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,GAAG,CAAmB;gBAEjB,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,gBAAgB;IAMpD,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,0BAA0B,CAA2B;IAC7D,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,eAAe,CAAmC;IAC1D,OAAO,CAAC,aAAa,CAAsC;IAE3D,OAAO,CAAC,aAAa,CAAK;IAE1B,OAAO,CAAC,4BAA4B;IA8DpC,IAAI,GAAG,IAAK,SAAS,CAEpB;IAIK,OAAO,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAIpD,QAAQ,CAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAatD,SAAS,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ/B,wBAAwB,IAAK,OAAO,CAAC,YAAY,CAAC;IAgBlD,SAAS,IAAK,OAAO,CAAC,YAAY,CAAC;IASnC,WAAW,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM/C,SAAS,CAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAYjD,WAAW,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC;IAQjC,UAAU,IAAK,OAAO,CAAC,kBAAkB,CAAC;IAI1C,UAAU,CAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAI5D,IAAI,EAAE,IAAK,gBAAgB,CAE1B;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,MAAM,EACZ,MAAM,MAAM,CAAC;AAId,OAAO,EACiC,KAAK,UAAU,EACtD,MAAM,eAAe,CAAC;AAuBvB,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,UAAU,CAAC;AAKlB,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,WAAW,EAAE,WAAW,CAAC;IACzB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAGD,MAAM,WAAW,qBAAqB;IAEpC,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,wBAAgB,sBAAsB,CAAE,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAgE9E;AAED,wBAAgB,QAAQ,CAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,EAAE,CA8OvE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/plugin/vite/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,MAAM,EACZ,MAAM,MAAM,CAAC;AAId,OAAO,EACiC,KAAK,UAAU,EACtD,MAAM,eAAe,CAAC;AAuBvB,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,UAAU,CAAC;AAKlB,MAAM,WAAW,qBAAqB;IACpC,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,WAAW,EAAE,WAAW,CAAC;IACzB,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAGD,MAAM,WAAW,qBAAqB;IAEpC,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED,wBAAgB,sBAAsB,CAAE,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAgE9E;AAED,wBAAgB,QAAQ,CAAE,OAAO,GAAE,qBAA0B,GAAG,MAAM,EAAE,CAuQvE"}
@@ -1,13 +1,14 @@
1
- import { i as e, n as t, o as n, r, s as i, t as a } from "./constants-7heqadyd.js";
1
+ import { i as e, n as t, o as n, r, s as i, t as a } from "./constants-Bo603IxE.js";
2
2
  import { A as o, E as s, O as c, S as l, _ as u, d, f, k as p, l as m, m as h, p as g, r as _, u as v, x as y } from "./brand-CmL-6h9U.js";
3
3
  import { t as b } from "./es-ClqUVRJn.js";
4
4
  import { resolve as x } from "node:path";
5
- import S from "@tailwindcss/vite";
6
- import C from "@vitejs/plugin-vue";
7
- import { normalizePath as w } from "vite";
8
- import { createRequire as T } from "node:module";
5
+ import S from "picocolors";
6
+ import C from "@tailwindcss/vite";
7
+ import w from "@vitejs/plugin-vue";
8
+ import { normalizePath as T } from "vite";
9
+ import { createRequire as E } from "node:module";
9
10
  //#region src/node/lib/render/vue.ts
10
- async function E(e, t, n) {
11
+ async function D(e, t, n) {
11
12
  let r = {
12
13
  path: n,
13
14
  relativePath: n,
@@ -25,17 +26,17 @@ async function E(e, t, n) {
25
26
  `export const __pageData = JSON.parse(${JSON.stringify(JSON.stringify(s))})`,
26
27
  `export default { name: ${JSON.stringify(n)} }`,
27
28
  "<\/script>",
28
- `<template><div class="typedown-content">\n${D(i)}\n</div></template>`
29
+ `<template><div class="typedown-content">\n${O(i)}\n</div></template>`
29
30
  ].join("\n"),
30
31
  pageData: s
31
32
  };
32
33
  }
33
- function D(e) {
34
+ function O(e) {
34
35
  return e.replaceAll("{{", "&#123;&#123;");
35
36
  }
36
37
  //#endregion
37
38
  //#region src/node/plugin/vite/search.ts
38
- var O = /<h(\d*).*?>(.*?<a.*? href="#.*?".*?>.*?<\/a>)<\/h\1>/gi, k = /(.*)<a.*? href="#(.*?)".*?>.*?<\/a>/i, A = class {
39
+ var k = /<h(\d*).*?>(.*?<a.*? href="#.*?".*?>.*?<\/a>)<\/h\1>/gi, A = /(.*)<a.*? href="#(.*?)".*?>.*?<\/a>/i, j = class {
39
40
  index;
40
41
  pageDocIds = /* @__PURE__ */ new Map();
41
42
  constructor() {
@@ -52,7 +53,7 @@ var O = /<h(\d*).*?>(.*?<a.*? href="#.*?".*?>.*?<\/a>)<\/h\1>/gi, k = /(.*)<a.*?
52
53
  addPage(e) {
53
54
  this.discardPage(e.id);
54
55
  let t = [];
55
- for (let n of j(e.html)) {
56
+ for (let n of M(e.html)) {
56
57
  let r = n.anchor ? `${e.id}#${n.anchor}` : e.id;
57
58
  this.index.has(r) && this.index.discard(r), this.index.add({
58
59
  id: r,
@@ -74,12 +75,12 @@ var O = /<h(\d*).*?>(.*?<a.*? href="#.*?".*?>.*?<\/a>)<\/h\1>/gi, k = /(.*)<a.*?
74
75
  return JSON.stringify(this.index);
75
76
  }
76
77
  };
77
- function* j(e) {
78
- let t = e.split(O);
78
+ function* M(e) {
79
+ let t = e.split(k);
79
80
  t.shift();
80
81
  let n = [];
81
82
  for (let e = 0; e < t.length; e += 3) {
82
- let r = Number.parseInt(t[e]) - 1, i = t[e + 1], a = k.exec(i), o = v(a?.[1] ?? "").trim(), s = a?.[2] ?? "", c = t[e + 2];
83
+ let r = Number.parseInt(t[e]) - 1, i = t[e + 1], a = A.exec(i), o = v(a?.[1] ?? "").trim(), s = a?.[2] ?? "", c = t[e + 2];
83
84
  if (!o || !c) continue;
84
85
  let l = n.slice(0, r);
85
86
  l[r] = o, yield {
@@ -91,19 +92,19 @@ function* j(e) {
91
92
  }
92
93
  //#endregion
93
94
  //#region src/node/plugin/vite/alias.ts
94
- var M = T(import.meta.url);
95
- function N() {
95
+ var N = E(import.meta.url);
96
+ function P() {
96
97
  return [{
97
98
  find: "vue/server-renderer",
98
- replacement: M.resolve("vue/server-renderer")
99
+ replacement: N.resolve("vue/server-renderer")
99
100
  }, {
100
101
  find: "vue",
101
- replacement: M.resolve("vue/dist/vue.runtime.esm-bundler.js")
102
+ replacement: N.resolve("vue/dist/vue.runtime.esm-bundler.js")
102
103
  }];
103
104
  }
104
105
  //#endregion
105
106
  //#region src/node/plugin/vite/index.ts
106
- function P(e) {
107
+ function F(e) {
107
108
  let { contentDir: t } = e, n = `/${t}/**/*.{td,md}`, i = JSON.stringify({
108
109
  title: e.siteTitle,
109
110
  description: e.siteDescription
@@ -158,8 +159,8 @@ if (import.meta.hot) {
158
159
  }
159
160
  `;
160
161
  }
161
- function F(r = {}) {
162
- let o = r.context, s, c = new A(), u;
162
+ function I(r = {}) {
163
+ let o = r.context, s, c = new j(), u;
163
164
  function f() {
164
165
  if (o === void 0) throw Error("typedown plugin not initialized");
165
166
  return o.getTdContext();
@@ -173,23 +174,34 @@ function F(r = {}) {
173
174
  },
174
175
  config() {
175
176
  return {
176
- resolve: { alias: N() },
177
+ resolve: { alias: P() },
177
178
  ssr: { noExternal: ["typerighter"] }
178
179
  };
179
180
  },
181
+ async buildStart() {
182
+ let e = await (await f()).checkVault();
183
+ if (e.errorCount > 0 || e.warningCount > 0) for (let t of e.diagnostics) {
184
+ let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? S.red("error") : S.yellow("warn");
185
+ console.error(` ${n} ${e} ${t.message} ${S.dim(`(${t.code})`)}`);
186
+ }
187
+ if (!s && e.errorCount > 0) {
188
+ let t = e.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
189
+ this.error(`Vault check failed with ${e.errorCount} error(s):\n${t.join("\n")}`);
190
+ }
191
+ },
180
192
  resolveId(e) {
181
193
  if (e === "/@typedown/app" || e === "@typedown/app") return t;
182
194
  if (e === "@typedown/search-index") return a;
183
195
  },
184
196
  async load(e) {
185
- if (e === "\0@typedown/search-index") return u ||= B(await f(), c), await u, `export default ${JSON.stringify(c.serialize())}`;
197
+ if (e === "\0@typedown/search-index") return u ||= V(await f(), c), await u, `export default ${JSON.stringify(c.serialize())}`;
186
198
  if (e !== "\0@typedown/app") return;
187
199
  let t = await f(), [n, r, i] = await Promise.all([
188
200
  t.getConfig(),
189
201
  t.listFilesGroupedBySchema(),
190
202
  t.listSchemas()
191
203
  ]), a = await Promise.all(i.map(async (e) => [e, (await t.getSchema(e)).properties])), o = Object.fromEntries(a), s = d(Object.values(r).flat());
192
- return P({
204
+ return F({
193
205
  ...n,
194
206
  contentTree: s,
195
207
  schemas: o
@@ -198,14 +210,14 @@ function F(r = {}) {
198
210
  async configureServer(t) {
199
211
  s = t;
200
212
  let n = await f();
201
- n.rpc.onConfigChanged(() => s && R(s)), n.rpc.onContentChanged(({ content: e }) => {
202
- s && (I(n, e).then((e) => {
203
- e && s && (c.addPage(e), V(s));
213
+ n.rpc.onConfigChanged(() => s && z(s)), n.rpc.onContentChanged(({ content: e }) => {
214
+ s && (L(n, e).then((e) => {
215
+ e && s && (c.addPage(e), H(s));
204
216
  }).catch(() => {}), n.getConfig().then((t) => {
205
217
  if (!s) return;
206
- let n = w(x(s.config.root, t.contentDir, e)), r = s.moduleGraph.getModulesByFile(n);
218
+ let n = T(x(s.config.root, t.contentDir, e)), r = s.moduleGraph.getModulesByFile(n);
207
219
  if (!r?.size) return;
208
- let i = [...r].map((e) => (s?.moduleGraph.invalidateModule(e), H(e)));
220
+ let i = [...r].map((e) => (s?.moduleGraph.invalidateModule(e), U(e)));
209
221
  s.hot.send({
210
222
  type: "update",
211
223
  updates: i
@@ -213,11 +225,11 @@ function F(r = {}) {
213
225
  }).catch(() => {}));
214
226
  });
215
227
  function r() {
216
- s && (u = B(n, c), u.then(() => {
217
- s && V(s);
218
- }), z(s));
228
+ s && (u = V(n, c), u.then(() => {
229
+ s && H(s);
230
+ }), B(s));
219
231
  }
220
- return n.rpc.onContentCreated(r), n.rpc.onContentDeleted(r), n.rpc.onSchemaChanged(() => s && z(s)), n.rpc.onSchemaCreated(() => s && z(s)), n.rpc.onSchemaDeleted(() => s && z(s)), () => {
232
+ return n.rpc.onContentCreated(r), n.rpc.onContentDeleted(r), n.rpc.onSchemaChanged(() => s && B(s)), n.rpc.onSchemaCreated(() => s && B(s)), n.rpc.onSchemaDeleted(() => s && B(s)), () => {
221
233
  t.middlewares.use((t, r, i) => {
222
234
  if (!t.url || r.writableEnded || t.url.startsWith("/@") || t.url.startsWith("/node_modules") || t.url.includes(".")) return i();
223
235
  n.getConfig().then((t) => {
@@ -242,7 +254,7 @@ function F(r = {}) {
242
254
  async transform(e, t) {
243
255
  let n = t.split("?")[0];
244
256
  if (!l(n)) return;
245
- let r = await f(), i = (await r.getConfig()).contentDir, a = n.includes(i) ? n.slice(n.indexOf(i) + i.length + 1) : n, { vueSrc: o } = await E(r, await r.getFile(a), a);
257
+ let r = await f(), i = (await r.getConfig()).contentDir, a = n.includes(i) ? n.slice(n.indexOf(i) + i.length + 1) : n, { vueSrc: o } = await D(r, await r.getFile(a), a);
246
258
  return {
247
259
  code: o,
248
260
  map: null
@@ -252,11 +264,11 @@ function F(r = {}) {
252
264
  if (l(e)) return [];
253
265
  }
254
266
  },
255
- C({ include: /\.(?:vue|td)$/ }),
256
- ...S()
267
+ w({ include: /\.(?:vue|td)$/ }),
268
+ ...C()
257
269
  ];
258
270
  }
259
- async function I(e, t) {
271
+ async function L(e, t) {
260
272
  try {
261
273
  let n = await e.getFile(t), r = await e.md.renderAsync(n.content, {
262
274
  path: t,
@@ -272,32 +284,32 @@ async function I(e, t) {
272
284
  return;
273
285
  }
274
286
  }
275
- function L(e) {
287
+ function R(e) {
276
288
  return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
277
289
  }
278
- function R(e) {
279
- for (let t of L(e)) e.moduleGraph.invalidateModule(t);
290
+ function z(e) {
291
+ for (let t of R(e)) e.moduleGraph.invalidateModule(t);
280
292
  e.hot.send({ type: "full-reload" });
281
293
  }
282
- function z(e) {
283
- let t = L(e).map((t) => (e.moduleGraph.invalidateModule(t), H(t)));
294
+ function B(e) {
295
+ let t = R(e).map((t) => (e.moduleGraph.invalidateModule(t), U(t)));
284
296
  0 < t.length && e.hot.send({
285
297
  type: "update",
286
298
  updates: t
287
299
  });
288
300
  }
289
- async function B(e, t) {
290
- let n = await e.listFiles(), r = await Promise.all(n.map((t) => I(e, t)));
301
+ async function V(e, t) {
302
+ let n = await e.listFiles(), r = await Promise.all(n.map((t) => L(e, t)));
291
303
  t.addAll(r.filter((e) => e !== void 0));
292
304
  }
293
- function V(e) {
305
+ function H(e) {
294
306
  let t = e.moduleGraph.getModuleById(a);
295
307
  t && (e.moduleGraph.invalidateModule(t), e.hot.send({
296
308
  type: "update",
297
- updates: [H(t)]
309
+ updates: [U(t)]
298
310
  }));
299
311
  }
300
- function H(e) {
312
+ function U(e) {
301
313
  return {
302
314
  type: "js-update",
303
315
  path: e.url,
@@ -306,4 +318,4 @@ function H(e) {
306
318
  };
307
319
  }
308
320
  //#endregion
309
- export { F as n, P as t };
321
+ export { I as n, F as t };
package/dist/vite.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./vite-B-ktlRz9.js";
1
+ import { n as e, t } from "./vite-DaD9YRkN.js";
2
2
  export { t as generateClientAppEntry, e as typedown };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "typerighter",
4
- "version": "0.4.3",
4
+ "version": "0.5.0",
5
5
  "description": "Typedown: A typed content framework.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -81,8 +81,8 @@
81
81
  "tailwindcss": "^4.3.3",
82
82
  "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
83
83
  "vue": "^3.0.0",
84
- "@typerighter/rpc-client": "0.4.3",
85
- "@typerighter/rpc-server": "0.4.3"
84
+ "@typerighter/rpc-client": "0.5.0",
85
+ "@typerighter/rpc-server": "0.5.0"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@hdnax/nuclint": "^0.17.4",