typerighter 0.4.4 → 0.5.1

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.

Potentially problematic release.


This version of typerighter might be problematic. Click here for more details.

@@ -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";
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";
1
+ import { i as e, n as t, o as n, r, s as i, t as a } from "./constants-BVW9e5iH.js";
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-C6VJ3Tpf.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-DPRlAukM.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.4",
4
+ "version": "0.5.1",
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.4",
85
- "@typerighter/rpc-server": "0.4.4"
84
+ "@typerighter/rpc-client": "0.5.1",
85
+ "@typerighter/rpc-server": "0.5.1"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@hdnax/nuclint": "^0.17.4",