typerighter 0.3.0 → 0.4.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.

Potentially problematic release.


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

Files changed (91) hide show
  1. package/dist/app-Bw90hv7G.js +266 -0
  2. package/dist/brand-BtMsUv5o.js +201 -0
  3. package/dist/{cli-CoyGXgR1.js → cli-s44ly0MH.js} +233 -172
  4. package/dist/cli.js +1 -1
  5. package/dist/client/app/index.d.ts +12 -4
  6. package/dist/client/app/index.d.ts.map +1 -1
  7. package/dist/client/app/router.d.ts.map +1 -1
  8. package/dist/client/theme-default.js +707 -149
  9. package/dist/client.js +2 -2
  10. package/dist/constants-E2UATqMm.js +32183 -0
  11. package/dist/es-ClqUVRJn.js +705 -0
  12. package/dist/index.js +4 -4
  13. package/dist/{init-CUo89E7j.js → init-0hKcjQtf.js} +10 -12
  14. package/dist/node/build/index.d.ts.map +1 -1
  15. package/dist/node/lib/markdown/index.d.ts.map +1 -1
  16. package/dist/node/lib/markdown/plugins/callout-container.d.ts +4 -0
  17. package/dist/node/lib/markdown/plugins/callout-container.d.ts.map +1 -0
  18. package/dist/node/lib/markdown/plugins/custom-container.d.ts +3 -0
  19. package/dist/node/lib/markdown/plugins/custom-container.d.ts.map +1 -0
  20. package/dist/node/lib/markdown/plugins/{highlight.d.ts → highlight/index.d.ts} +1 -1
  21. package/dist/node/lib/markdown/plugins/highlight/index.d.ts.map +1 -0
  22. package/dist/node/lib/markdown/plugins/highlight/language.d.ts +3 -0
  23. package/dist/node/lib/markdown/plugins/highlight/language.d.ts.map +1 -0
  24. package/dist/node/lib/progress.d.ts.map +1 -1
  25. package/dist/node/lib/render/vue.d.ts +2 -2
  26. package/dist/node/lib/render/vue.d.ts.map +1 -1
  27. package/dist/node/lib/typedown-context.d.ts +4 -4
  28. package/dist/node/lib/typedown-context.d.ts.map +1 -1
  29. package/dist/node/plugin/vite/constants.d.ts +2 -1
  30. package/dist/node/plugin/vite/constants.d.ts.map +1 -1
  31. package/dist/node/plugin/vite/index.d.ts +15 -1
  32. package/dist/node/plugin/vite/index.d.ts.map +1 -1
  33. package/dist/node/plugin/vite/search.d.ts +15 -0
  34. package/dist/node/plugin/vite/search.d.ts.map +1 -0
  35. package/dist/shared/constants.d.ts +6 -0
  36. package/dist/shared/constants.d.ts.map +1 -0
  37. package/dist/shared/index.d.ts +1 -0
  38. package/dist/shared/index.d.ts.map +1 -1
  39. package/dist/shared/types/content.d.ts +54 -4
  40. package/dist/shared/types/content.d.ts.map +1 -1
  41. package/dist/shared/types/ssg.d.ts +3 -1
  42. package/dist/shared/types/ssg.d.ts.map +1 -1
  43. package/dist/shared/utils/content.d.ts +5 -5
  44. package/dist/shared/utils/content.d.ts.map +1 -1
  45. package/dist/shared/utils/debounce.d.ts +2 -0
  46. package/dist/shared/utils/debounce.d.ts.map +1 -0
  47. package/dist/shared/utils/format.d.ts +5 -1
  48. package/dist/shared/utils/format.d.ts.map +1 -1
  49. package/dist/shared/utils/html.d.ts +1 -0
  50. package/dist/shared/utils/html.d.ts.map +1 -1
  51. package/dist/shared/utils/index.d.ts +6 -4
  52. package/dist/shared/utils/index.d.ts.map +1 -1
  53. package/dist/shared/utils/path.d.ts +8 -0
  54. package/dist/shared/utils/path.d.ts.map +1 -0
  55. package/dist/shared/utils/regex.d.ts +2 -0
  56. package/dist/shared/utils/regex.d.ts.map +1 -0
  57. package/dist/shared/utils/time.d.ts +6 -0
  58. package/dist/shared/utils/time.d.ts.map +1 -0
  59. package/dist/shared/utils/url.d.ts +6 -2
  60. package/dist/shared/utils/url.d.ts.map +1 -1
  61. package/dist/typerighter.css +1 -1
  62. package/dist/vite-nzhkELg7.js +309 -0
  63. package/dist/vite.js +2 -3
  64. package/package.json +9 -5
  65. package/dist/app-CM3biamr.js +0 -184
  66. package/dist/brand-CeSqpEQ2.js +0 -4
  67. package/dist/chunk-DfAF0w94-EwUSVR-h.js +0 -13
  68. package/dist/constants-B7b8AsH0.js +0 -9530
  69. package/dist/content-BM3UKxcc.js +0 -16
  70. package/dist/lib-CBtriEt5-Ch50D04V.js +0 -3309
  71. package/dist/liteDOM-Cp0aN3bP-YwW1TGWI.js +0 -741
  72. package/dist/node/lib/markdown/plugins/container.d.ts +0 -3
  73. package/dist/node/lib/markdown/plugins/container.d.ts.map +0 -1
  74. package/dist/node/lib/markdown/plugins/highlight.d.ts.map +0 -1
  75. package/dist/node/plugin/vite/codegen.d.ts +0 -27
  76. package/dist/node/plugin/vite/codegen.d.ts.map +0 -1
  77. package/dist/node/plugin/vite/codegen.test.d.ts +0 -2
  78. package/dist/node/plugin/vite/codegen.test.d.ts.map +0 -1
  79. package/dist/plugin-D2xuSVM4.js +0 -1
  80. package/dist/rolldown-runtime-Dqa2HsxW.js +0 -20
  81. package/dist/shared/utils/environment.d.ts +0 -2
  82. package/dist/shared/utils/environment.d.ts.map +0 -1
  83. package/dist/shared/utils/highlight.d.ts +0 -3
  84. package/dist/shared/utils/highlight.d.ts.map +0 -1
  85. package/dist/shared/utils/html.test.d.ts +0 -2
  86. package/dist/shared/utils/html.test.d.ts.map +0 -1
  87. package/dist/shared-DzTfF-_d.js +0 -14
  88. package/dist/tex-svg-full-BI3fonbT-CfoPQ3xc.js +0 -60224
  89. package/dist/vite-BxXQPieu.js +0 -228
  90. package/dist/wgxpath.install-node-Csk64Aj9-C0enUGLs.js +0 -1094
  91. package/dist/xypic-DrMJn58R-B4fw2rYo.js +0 -14846
@@ -0,0 +1,309 @@
1
+ import { i as e, n as t, o as n, r, s as i, t as a } from "./constants-E2UATqMm.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-BtMsUv5o.js";
3
+ import { t as b } from "./es-ClqUVRJn.js";
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";
9
+ //#region src/node/lib/render/vue.ts
10
+ async function E(e, t, n) {
11
+ let r = {
12
+ path: n,
13
+ relativePath: n,
14
+ cleanUrls: !0
15
+ }, i = await e.md.renderAsync(t.content, r), a = y(n) === c, o = r.title || (a ? g(n, (await e.getConfig()).siteTitle) : h(t.header, n)), s = {
16
+ schema: t.schema,
17
+ frontmatter: t.header,
18
+ headings: r.headers ?? [],
19
+ title: o,
20
+ metadata: t.metadata
21
+ };
22
+ return {
23
+ vueSrc: [
24
+ "<script>",
25
+ `export const __pageData = JSON.parse(${JSON.stringify(JSON.stringify(s))})`,
26
+ `export default { name: ${JSON.stringify(n)} }`,
27
+ "<\/script>",
28
+ `<template><div class="typedown-content">\n${D(i)}\n</div></template>`
29
+ ].join("\n"),
30
+ pageData: s
31
+ };
32
+ }
33
+ function D(e) {
34
+ return e.replaceAll("{{", "&#123;&#123;");
35
+ }
36
+ //#endregion
37
+ //#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
+ index;
40
+ pageDocIds = /* @__PURE__ */ new Map();
41
+ constructor() {
42
+ this.index = new b({
43
+ fields: p,
44
+ storeFields: o
45
+ });
46
+ }
47
+ addAll(e) {
48
+ let t = new Set(e.map((e) => e.id));
49
+ for (let e of this.pageDocIds.keys()) t.has(e) || this.discardPage(e);
50
+ for (let t of e) this.addPage(t);
51
+ }
52
+ addPage(e) {
53
+ this.discardPage(e.id);
54
+ let t = [];
55
+ for (let n of j(e.html)) {
56
+ let r = n.anchor ? `${e.id}#${n.anchor}` : e.id;
57
+ this.index.has(r) && this.index.discard(r), this.index.add({
58
+ id: r,
59
+ text: n.text,
60
+ title: n.titles.at(-1) ?? e.title,
61
+ titles: 1 < n.titles.length ? n.titles.slice(0, -1) : [e.title]
62
+ }), t.push(r);
63
+ }
64
+ this.pageDocIds.set(e.id, t);
65
+ }
66
+ discardPage(e) {
67
+ let t = this.pageDocIds.get(e);
68
+ if (t) {
69
+ for (let e of t) this.index.has(e) && this.index.discard(e);
70
+ this.pageDocIds.delete(e);
71
+ }
72
+ }
73
+ serialize() {
74
+ return JSON.stringify(this.index);
75
+ }
76
+ };
77
+ function* j(e) {
78
+ let t = e.split(O);
79
+ t.shift();
80
+ let n = [];
81
+ 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
+ if (!o || !c) continue;
84
+ let l = n.slice(0, r);
85
+ l[r] = o, yield {
86
+ anchor: s,
87
+ titles: l.filter(Boolean),
88
+ text: v(c)
89
+ }, r === 0 ? (n.length = 0, n[0] = o) : n[r] = o;
90
+ }
91
+ }
92
+ //#endregion
93
+ //#region src/node/plugin/vite/alias.ts
94
+ var M = T(import.meta.url);
95
+ function N() {
96
+ return [{
97
+ find: "vue/server-renderer",
98
+ replacement: M.resolve("vue/server-renderer")
99
+ }, {
100
+ find: "vue",
101
+ replacement: M.resolve("vue/dist/vue.runtime.esm-bundler.js")
102
+ }];
103
+ }
104
+ //#endregion
105
+ //#region src/node/plugin/vite/index.ts
106
+ function P(e) {
107
+ let { contentDir: t } = e, n = `/${t}/**/*.{td,md}`, i = JSON.stringify({
108
+ title: e.siteTitle,
109
+ description: e.siteDescription
110
+ }), a = JSON.stringify({
111
+ contentTree: e.contentTree,
112
+ schemas: e.schemas ?? {}
113
+ }), o = f(e.contentTree.children, e.siteTitle);
114
+ return `
115
+ import 'typerighter/style.css';
116
+ import { createTypedownApp } from 'typerighter/client';
117
+ import { TdDirectoryIndex } from 'typerighter/client/theme-default';
118
+ import { h } from 'vue';
119
+ import theme from 'typerighter/client/theme-default';
120
+ import searchIndex from '${r}';
121
+
122
+ const pages = import.meta.glob('${n}');
123
+ const contentExts = ${JSON.stringify(s)};
124
+
125
+ const directoryIndex = ${JSON.stringify(o)};
126
+
127
+ function findPage(base) {
128
+ for (const ext of contentExts) {
129
+ const key = base + ext;
130
+ if (pages[key]) return pages[key];
131
+ const indexKey = base + '/index' + ext;
132
+ if (pages[indexKey]) return pages[indexKey];
133
+ }
134
+ }
135
+
136
+ async function loadPageModule(pagePath) {
137
+ const base = ('/${t}/' + pagePath).replace(/\\/+/g, '/').replace(/\\/$/, '');
138
+ const loader = findPage(base);
139
+ if (loader) return loader();
140
+
141
+ const dir = directoryIndex[pagePath] || directoryIndex[pagePath + '/'];
142
+ if (dir) return {
143
+ default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex, dir); } },
144
+ __pageData: { frontmatter: {}, headings: [], title: dir.title },
145
+ };
146
+
147
+ return undefined;
148
+ }
149
+
150
+ const { app, searchIndex: searchIndexRef } = await createTypedownApp(loadPageModule, theme.Layout, ${i}, { ...${a}, searchIndex });
151
+ app.mount('#app');
152
+
153
+ // Accept HMR for the search index so it updates without a full reload
154
+ if (import.meta.hot) {
155
+ import.meta.hot.accept('${r}', (m) => {
156
+ if (m) searchIndexRef.value = m.default;
157
+ });
158
+ }
159
+ `;
160
+ }
161
+ function F(r = {}) {
162
+ let o = r.context, s, c = new A(), u;
163
+ function f() {
164
+ if (o === void 0) throw Error("typedown plugin not initialized");
165
+ return o.getTdContext();
166
+ }
167
+ return [
168
+ {
169
+ name: "vite-plugin-typedown",
170
+ enforce: "pre",
171
+ configResolved(e) {
172
+ o ||= n(i(e.root));
173
+ },
174
+ config() {
175
+ return {
176
+ resolve: { alias: N() },
177
+ ssr: { noExternal: ["typerighter"] }
178
+ };
179
+ },
180
+ resolveId(e) {
181
+ if (e === "/@typedown/app" || e === "@typedown/app") return t;
182
+ if (e === "@typedown/search-index") return a;
183
+ },
184
+ async load(e) {
185
+ if (e === "\0@typedown/search-index") return u ||= B(await f(), c), await u, `export default ${JSON.stringify(c.serialize())}`;
186
+ if (e !== "\0@typedown/app") return;
187
+ let t = await f(), [n, r, i] = await Promise.all([
188
+ t.getConfig(),
189
+ t.listFilesGroupedBySchema(),
190
+ t.listSchemas()
191
+ ]), 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({
193
+ ...n,
194
+ contentTree: s,
195
+ schemas: o
196
+ });
197
+ },
198
+ async configureServer(t) {
199
+ s = t;
200
+ 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));
204
+ }).catch(() => {}), n.getConfig().then((t) => {
205
+ if (!s) return;
206
+ let n = w(x(s.config.root, t.contentDir, e)), r = s.moduleGraph.getModulesByFile(n);
207
+ if (!r?.size) return;
208
+ let i = [...r].map((e) => (s?.moduleGraph.invalidateModule(e), H(e)));
209
+ s.hot.send({
210
+ type: "update",
211
+ updates: i
212
+ });
213
+ }).catch(() => {}));
214
+ });
215
+ function r() {
216
+ s && (u = B(n, c), u.then(() => {
217
+ s && V(s);
218
+ }), z(s));
219
+ }
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)), () => {
221
+ t.middlewares.use((t, r, i) => {
222
+ if (!t.url || r.writableEnded || t.url.startsWith("/@") || t.url.startsWith("/node_modules") || t.url.includes(".")) return i();
223
+ n.getConfig().then((t) => {
224
+ let n = `<!DOCTYPE html>
225
+ <html lang="en">
226
+ <head>
227
+ <meta charset="UTF-8">
228
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
229
+ <title>${m(t.siteTitle)}</title>
230
+ <link rel="icon" type="image/svg+xml" href="${_}">
231
+ </head>
232
+ <body>
233
+ <div id="app"></div>
234
+ <script type="module" src="/${e}"><\/script>
235
+ </body>
236
+ </html>`;
237
+ r.setHeader("Content-Type", "text/html"), r.end(n);
238
+ }).catch(i);
239
+ });
240
+ };
241
+ },
242
+ async transform(e, t) {
243
+ let n = t.split("?")[0];
244
+ 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);
246
+ return {
247
+ code: o,
248
+ map: null
249
+ };
250
+ },
251
+ handleHotUpdate({ file: e }) {
252
+ if (l(e)) return [];
253
+ }
254
+ },
255
+ C({ include: /\.(?:vue|td)$/ }),
256
+ ...S()
257
+ ];
258
+ }
259
+ async function I(e, t) {
260
+ try {
261
+ let n = await e.getFile(t), r = await e.md.renderAsync(n.content, {
262
+ path: t,
263
+ relativePath: t,
264
+ cleanUrls: !0
265
+ });
266
+ return {
267
+ id: u(t),
268
+ title: h(n.header, t),
269
+ html: r
270
+ };
271
+ } catch {
272
+ return;
273
+ }
274
+ }
275
+ function L(e) {
276
+ return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
277
+ }
278
+ function R(e) {
279
+ for (let t of L(e)) e.moduleGraph.invalidateModule(t);
280
+ e.hot.send({ type: "full-reload" });
281
+ }
282
+ function z(e) {
283
+ let t = L(e).map((t) => (e.moduleGraph.invalidateModule(t), H(t)));
284
+ 0 < t.length && e.hot.send({
285
+ type: "update",
286
+ updates: t
287
+ });
288
+ }
289
+ async function B(e, t) {
290
+ let n = await e.listFiles(), r = await Promise.all(n.map((t) => I(e, t)));
291
+ t.addAll(r.filter((e) => e !== void 0));
292
+ }
293
+ function V(e) {
294
+ let t = e.moduleGraph.getModuleById(a);
295
+ t && (e.moduleGraph.invalidateModule(t), e.hot.send({
296
+ type: "update",
297
+ updates: [H(t)]
298
+ }));
299
+ }
300
+ function H(e) {
301
+ return {
302
+ type: "js-update",
303
+ path: e.url,
304
+ acceptedPath: e.url,
305
+ timestamp: Date.now()
306
+ };
307
+ }
308
+ //#endregion
309
+ export { F as n, P as t };
package/dist/vite.js CHANGED
@@ -1,3 +1,2 @@
1
- import { t as e } from "./vite-BxXQPieu.js";
2
- import "./plugin-D2xuSVM4.js";
3
- export { e as typedown };
1
+ import { n as e, t } from "./vite-nzhkELg7.js";
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.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "Typedown: A typed content framework.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -48,38 +48,41 @@
48
48
  "@clack/prompts": "^1.7.0",
49
49
  "@fontsource-variable/archivo": "^5.3.0",
50
50
  "@fontsource-variable/jetbrains-mono": "^5.3.0",
51
+ "@lucide/vue": "^1.30.0",
51
52
  "@mdit-vue/plugin-frontmatter": "^3.0.2",
52
53
  "@mdit-vue/plugin-headers": "^3.0.2",
53
54
  "@mdit-vue/plugin-title": "^3.0.2",
54
55
  "@mdit-vue/plugin-toc": "^3.0.2",
55
56
  "@mdit-vue/shared": "^3.0.2",
56
57
  "@mdit/plugin-anchor": "^1.1.1",
58
+ "@mdit/plugin-attrs": "^1.1.1",
57
59
  "@mdit/plugin-container": "^1.0.1",
58
60
  "@mdit/plugin-emoji": "^1.1.0",
61
+ "@mdit/plugin-katex": "^1.0.2",
59
62
  "@mdit/plugin-tasklist": "^1.0.1",
60
63
  "@shikijs/markdown-it": "^4.3.1",
61
64
  "@shikijs/transformers": "^4.3.1",
62
65
  "@shikijs/types": "^4.3.1",
63
66
  "@tailwindcss/vite": "^4.3.3",
64
67
  "@vitejs/plugin-vue": "^5.0.0 || ^6.0.0",
68
+ "@vue/shared": "^3.5.41",
65
69
  "cac": "^7.0.0",
66
70
  "image-size": "^2.0.2",
67
71
  "js-yaml": "^5.2.3",
68
- "lucide-vue-next": "^1.0.0",
72
+ "katex": "^0.18.1",
69
73
  "markdown-it": "^14.0.0",
70
74
  "markdown-it-anchor": "^9.0.0",
71
75
  "markdown-it-async": "^2.2.0",
72
76
  "markdown-it-container": "^4.0.0",
73
77
  "markdown-it-emoji": "^3.0.0",
74
- "markdown-it-mathjax3": "^5.2.0",
75
78
  "markdown-it-task-lists": "^2.1.1",
76
79
  "picocolors": "^1.1.1",
77
80
  "shiki": "^4.3.1",
78
81
  "tailwindcss": "^4.3.3",
79
82
  "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
80
83
  "vue": "^3.0.0",
81
- "@typerighter/rpc-client": "0.3.0",
82
- "@typerighter/rpc-server": "0.3.0"
84
+ "@typerighter/rpc-client": "0.4.0",
85
+ "@typerighter/rpc-server": "0.4.0"
83
86
  },
84
87
  "devDependencies": {
85
88
  "@hdnax/nuclint": "^0.17.4",
@@ -88,6 +91,7 @@
88
91
  "@types/markdown-it-container": "^4.0.0",
89
92
  "@types/markdown-it-emoji": "^3.0.1",
90
93
  "@types/node": "~24.13.3",
94
+ "minisearch": "^7.2.0",
91
95
  "typescript": "^6.0.3",
92
96
  "vitest": "^4.1.5"
93
97
  },
@@ -1,184 +0,0 @@
1
- import "./shared-DzTfF-_d.js";
2
- import { computed as e, createApp as t, defineComponent as n, h as r, inject as i, markRaw as a, nextTick as o, provide as s, reactive as c, readonly as l, ref as u } from "vue";
3
- //#region src/shared/utils/environment.ts
4
- var d = typeof window < "u", f = Symbol("typedown-router"), p = {
5
- schema: "",
6
- frontmatter: {},
7
- headings: [],
8
- title: "Not Found"
9
- };
10
- function m(e, t) {
11
- let n = c({
12
- path: "/",
13
- hash: "",
14
- query: "",
15
- contentSfc: void 0,
16
- data: p
17
- }), r = {
18
- route: n,
19
- async go(e, t) {
20
- e = y(e), await r.onBeforeRouteChange?.(e) !== !1 && ((!d || t?.initialLoad || v(e, t)) && await s(e), l(), await r.onAfterRouteChange?.(e));
21
- }
22
- }, i;
23
- async function s(r) {
24
- let s = new URL(r, "http://a.com"), c = i = s.pathname;
25
- try {
26
- let t = await e(c);
27
- if (!t) throw Error(`Page not found: ${c}`);
28
- if (i === c) {
29
- i = void 0;
30
- let { default: e, __pageData: r } = t;
31
- n.path = c, n.contentSfc = a(e), n.data = a(r), l(s), d && o(() => {
32
- h(s.hash);
33
- });
34
- }
35
- } catch {
36
- i === c && (i = void 0, n.path = c, n.contentSfc = t ? a(t) : void 0, n.data = p, l(s));
37
- }
38
- }
39
- function l(e = d ? location : {
40
- search: "",
41
- hash: ""
42
- }) {
43
- n.query = e.search, n.hash = decodeURIComponent(e.hash);
44
- }
45
- return d && (history.state ?? history.replaceState({}, ""), window.addEventListener("click", (e) => {
46
- if (e.defaultPrevented || !(e.target instanceof Element) || e.button !== 0 || e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) return;
47
- let t = e.target.closest("a");
48
- if (!t || t.hasAttribute("download") || t.hasAttribute("target")) return;
49
- let n = t.getAttribute("href");
50
- if (n === null) return;
51
- let { href: i, origin: a, pathname: o } = new URL(n, t.baseURI);
52
- a === location.origin && !o.match(/\.\w+$/) && (e.preventDefault(), r.go(i));
53
- }, { capture: !0 }), window.addEventListener("popstate", async (e) => {
54
- if (e.state == null) return;
55
- let t = y(location.href);
56
- await s(t), l(), await r.onAfterRouteChange?.(t);
57
- }), window.addEventListener("hashchange", (e) => {
58
- e.preventDefault(), l();
59
- })), r;
60
- }
61
- function h(e) {
62
- if (!e) return;
63
- let t;
64
- try {
65
- t = document.getElementById(decodeURIComponent(e).slice(1)) ?? void 0;
66
- } catch {
67
- return;
68
- }
69
- t?.scrollIntoView({ block: "start" });
70
- }
71
- function g() {
72
- return _().route;
73
- }
74
- function _() {
75
- let e = i(f);
76
- if (!e) throw Error("useRouter() called outside of Typedown app");
77
- return e;
78
- }
79
- function v(e, { replace: t = !1 } = {}) {
80
- let n = y(location.href);
81
- if (e === n) return h(new URL(e, "http://a.com").hash), !1;
82
- t ? history.replaceState({}, "", e) : (history.replaceState({ scrollPosition: window.scrollY }, ""), history.pushState({}, "", e));
83
- let r = new URL(e, location.origin), i = new URL(n, location.origin);
84
- return r.pathname === i.pathname ? (h(r.hash), !1) : !0;
85
- }
86
- function y(e) {
87
- let t = new URL(e, "http://a.com");
88
- return t.pathname = t.pathname.replace(/(^|\/)index(\.html)?$/, "$1"), t.pathname + t.search + t.hash;
89
- }
90
- //#endregion
91
- //#region src/client/app/components/Content.ts
92
- var b = n({
93
- name: "TypedownContent",
94
- setup() {
95
- let e = g();
96
- return () => e.contentSfc ? r(e.contentSfc) : void 0;
97
- }
98
- }), x = "td-theme";
99
- function S(e) {
100
- if (typeof document > "u") return;
101
- let t = e === "system" ? C() : e;
102
- document.documentElement.classList.toggle("dark", t === "dark");
103
- }
104
- function C() {
105
- return typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
106
- }
107
- var w = u("system"), T = u(C()), E = !1;
108
- function D() {
109
- O();
110
- let t = e(() => w.value === "system" ? T.value : w.value), n = e(() => t.value === "dark");
111
- function r(e) {
112
- w.value = e, S(e), typeof localStorage < "u" && localStorage.setItem(x, e);
113
- }
114
- function i() {
115
- r(t.value === "light" ? "dark" : "light");
116
- }
117
- return {
118
- theme: l(w),
119
- effectiveTheme: t,
120
- isDark: n,
121
- setTheme: r,
122
- toggle: i
123
- };
124
- }
125
- function O() {
126
- if (!E) {
127
- if (E = !0, typeof localStorage < "u") {
128
- let e = localStorage.getItem(x);
129
- (e === "light" || e === "dark" || e === "system") && (w.value = e);
130
- }
131
- S(w.value), typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
132
- T.value = C(), w.value === "system" && S("system");
133
- });
134
- }
135
- }
136
- //#endregion
137
- //#region src/client/app/composables/useTdContent.ts
138
- var k = Symbol("td-content");
139
- function A(t) {
140
- let n = D(), r = {
141
- page: e(() => t.data),
142
- frontmatter: e(() => t.data.frontmatter),
143
- title: e(() => t.data.title),
144
- isDark: e(() => n.isDark.value)
145
- };
146
- return s(k, r), r;
147
- }
148
- function j() {
149
- let e = i(k);
150
- if (e === void 0) throw Error("useTdContent() called without a parent provideTdContent()");
151
- return e;
152
- }
153
- //#endregion
154
- //#region src/client/app/index.ts
155
- var M = Symbol("typedown-site-config"), N = Symbol("typedown-site-data");
156
- async function P(e, i, a = {}, o = {}) {
157
- let s = {
158
- title: a.title ?? "",
159
- description: a.description ?? ""
160
- }, c = { sidebarGroups: o.sidebarGroups ?? {} }, l = m(e), u = t(n({
161
- name: "TypedownApp",
162
- setup() {
163
- return A(l.route), () => r(i);
164
- }
165
- }));
166
- return u.provide(f, l), u.provide(M, s), u.provide(N, c), u.component("TypedownContent", b), d && await l.go(location.href, {
167
- replace: !0,
168
- initialLoad: !0
169
- }), {
170
- app: u,
171
- router: l
172
- };
173
- }
174
- function F() {
175
- return i(M, {
176
- title: "",
177
- description: ""
178
- });
179
- }
180
- function I() {
181
- return i(N, { sidebarGroups: {} });
182
- }
183
- //#endregion
184
- export { D as a, _ as c, j as i, F as n, b as o, I as r, g as s, P as t };
@@ -1,4 +0,0 @@
1
- //#region src/shared/brand.ts
2
- var e = "m15 10c-2.7614 0-5 2.2386-5 5v98c0 2.761 2.2386 5 5 5h178c2.761 0 5-2.239 5-5v-98c0-2.7614-2.239-5-5-5zm-15 5c0-8.28427 6.71573-15 15-15h178c8.284 0 15 6.71573 15 15v98c0 8.284-6.716 15-15 15h-178c-8.28427 0-15-6.716-15-15z", t = "M30 30h70v16h-27v52h-16v-52h-27z", n = "m155 98-30-33h20v-35h20v35h20z", r = "0 0 208 128", i = "#a0522d", a = `<svg fill='none' viewBox='${r}' xmlns='http://www.w3.org/2000/svg'><path clip-rule='evenodd' d='${e}' fill-rule='evenodd' fill='${i}'/><path d='${t}' fill='${i}'/><path d='${n}' fill='${i}'/></svg>`, o = `data:image/svg+xml,${encodeURIComponent(a)}`;
3
- //#endregion
4
- export { r as a, t as i, e as n, o as r, n as t };
@@ -1,13 +0,0 @@
1
- //#region ../../node_modules/.pnpm/mathxyjax3@0.8.3/node_modules/mathxyjax3/dist/chunk-DfAF0w94.js
2
- var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), s = (e, i, o, s) => {
3
- if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
- get: ((e) => i[e]).bind(null, d),
5
- enumerable: !(s = n(i, d)) || s.enumerable
6
- });
7
- return e;
8
- }, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
9
- value: n,
10
- enumerable: !0
11
- }) : a, n)), l = (e) => (t) => c(t.default, e);
12
- //#endregion
13
- export { o as n, l as t };