typerighter 0.57.0 → 0.57.2
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.
- package/dist/app-D-dbbyVD.js +7830 -0
- package/dist/{cli-tCqB1T4m.js → cli-Dpa3j5Sm.js} +5 -5
- package/dist/cli.js +1 -1
- package/dist/client/app/index.d.ts +9 -4
- package/dist/client/app/index.d.ts.map +1 -1
- package/dist/client/theme-default/composables/useCopyCode.d.ts +2 -0
- package/dist/client/theme-default/composables/useCopyCode.d.ts.map +1 -0
- package/dist/client/theme-default/composables/useHotkey.d.ts +13 -0
- package/dist/client/theme-default/composables/useHotkey.d.ts.map +1 -0
- package/dist/client/theme-default/index.d.ts +25 -0
- package/dist/client/theme-default/index.d.ts.map +1 -0
- package/dist/client/theme-default/utils/keys.d.ts +58 -0
- package/dist/client/theme-default/utils/keys.d.ts.map +1 -0
- package/dist/client/theme-default.js +3 -3892
- package/dist/client.js +3 -3
- package/dist/index.js +2 -2
- package/dist/{init-BVj3BWS6.js → init-DPhEzp34.js} +1 -1
- package/dist/node/build/index.d.ts +2 -2
- package/dist/node/build/index.d.ts.map +1 -1
- package/dist/node/lib/codegen/app-entry.d.ts.map +1 -1
- package/dist/{page-BreMA8X5.js → page-BbSO0VG8.js} +2 -3
- package/dist/prerenderWorker.js +1 -1
- package/dist/typerighter.css +1 -1
- package/dist/useSidebarConfig-0kMemgUS.js +94 -0
- package/dist/{vite-DKLVYuLb.js → vite-D3_cd2_2.js} +453 -511
- package/dist/vite.js +1 -1
- package/package.json +3 -3
- package/dist/app-C7F5xTZI.js +0 -3929
- package/dist/useSidebarConfig-DUcdHn0W.js +0 -33
- package/dist/useTheme-BF8TNao6.js +0 -65
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import { a as
|
|
5
|
-
import { t as
|
|
1
|
+
import { B as e, D as t, F as n, H as r, I as i, O as a, R as o, T as s, U as c, Z as l, _ as u, b as d, c as f, d as p, et as m, g as h, h as g, i as _, nt as v, p as y, q as b, rt as x, v as ee, x as S, y as C, z as w } from "./shared-dB08amQA.js";
|
|
2
|
+
import { n as T, t as E } from "./page-BbSO0VG8.js";
|
|
3
|
+
import { t as D } from "./temml-CjI4drVW.js";
|
|
4
|
+
import { a as O, i as k, n as te, r as ne } from "./context-CPrHBM3S.js";
|
|
5
|
+
import { t as re } from "./es-B_QJMowB.js";
|
|
6
6
|
import A, { resolve as j } from "node:path";
|
|
7
7
|
import M from "picocolors";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { build as
|
|
11
|
-
import P, { readdir as
|
|
12
|
-
import { fileURLToPath as
|
|
13
|
-
import
|
|
14
|
-
import { Worker as
|
|
15
|
-
import F, { createReadStream as
|
|
16
|
-
import { createRequire as
|
|
17
|
-
import { createChecker as
|
|
18
|
-
import { createHighlighter as
|
|
8
|
+
import ie from "@tailwindcss/vite";
|
|
9
|
+
import ae from "@vitejs/plugin-vue";
|
|
10
|
+
import { build as oe, normalizePath as N } from "vite";
|
|
11
|
+
import P, { readdir as se } from "node:fs/promises";
|
|
12
|
+
import { fileURLToPath as ce } from "node:url";
|
|
13
|
+
import le from "node:os";
|
|
14
|
+
import { Worker as ue } from "node:worker_threads";
|
|
15
|
+
import F, { createReadStream as de, existsSync as fe, globSync as pe, readFileSync as me, statSync as he } from "node:fs";
|
|
16
|
+
import { createRequire as ge } from "node:module";
|
|
17
|
+
import { createChecker as _e, createCheckerByJson as ve } from "vue-component-meta";
|
|
18
|
+
import { createHighlighter as ye, guessEmbeddedLanguages as be, isSpecialLang as xe } from "shiki";
|
|
19
19
|
// src/node/lib/worker-pool/index.ts
|
|
20
|
-
var
|
|
20
|
+
var Se = class {
|
|
21
21
|
workers = [];
|
|
22
22
|
queue = [];
|
|
23
23
|
destroyed = !1;
|
|
24
24
|
startupError;
|
|
25
25
|
constructor(e) {
|
|
26
|
-
let t = e.concurrency ?? Math.max(1, Math.floor(
|
|
26
|
+
let t = e.concurrency ?? Math.max(1, Math.floor(le.cpus().length / 2));
|
|
27
27
|
for (let n = 0; n < t; n++) {
|
|
28
|
-
let t = new
|
|
28
|
+
let t = new ue(e.filename, { workerData: e.workerData }), n = { worker: t };
|
|
29
29
|
this.workers.push(n), t.on("message", (e) => {
|
|
30
30
|
let t = n.pending;
|
|
31
31
|
n.pending = void 0, e.error === void 0 ? t?.resolve(e.result) : t?.reject(Error(e.error)), this.dispatch(n);
|
|
@@ -62,18 +62,18 @@ var Ce = class {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
// src/node/build/seo/sitemap.ts
|
|
65
|
-
function
|
|
66
|
-
let a =
|
|
65
|
+
function Ce(e, t, r, i) {
|
|
66
|
+
let a = r ?? "";
|
|
67
67
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
68
68
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
69
69
|
${e.map((e) => {
|
|
70
|
-
let
|
|
71
|
-
return ` <url><loc>${
|
|
70
|
+
let r = f(a + t + n(e)), o = i?.get(e);
|
|
71
|
+
return ` <url><loc>${r}</loc>${o === void 0 ? "" : `<lastmod>${_(o * 1e3)}</lastmod>`}</url>`;
|
|
72
72
|
}).join("\n")}
|
|
73
73
|
</urlset>
|
|
74
74
|
`;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function we(e, t) {
|
|
77
77
|
return `User-agent: *
|
|
78
78
|
Allow: /
|
|
79
79
|
|
|
@@ -81,13 +81,13 @@ Sitemap: ${e}${t}sitemap.xml
|
|
|
81
81
|
`;
|
|
82
82
|
}
|
|
83
83
|
// src/node/build/seo/feed.ts
|
|
84
|
-
function
|
|
84
|
+
function Te(e, t, n, i, a, o) {
|
|
85
85
|
let s = [...e].filter((e) => e.fileMetadata.mtimeSecs > 0).sort((e, t) => t.fileMetadata.mtimeSecs - e.fileMetadata.mtimeSecs).slice(0, 50).map((e) => {
|
|
86
|
-
let
|
|
86
|
+
let i = r(e.filepath), a = `${n}${t}${i}`, o = (/* @__PURE__ */ new Date(e.fileMetadata.mtimeSecs * 1e3)).toUTCString(), s = f(e.label ?? i), c = e.excerpt === void 0 ? "" : `<![CDATA[${e.excerpt}]]>`;
|
|
87
87
|
return ` <item>
|
|
88
88
|
<title>${s}</title>
|
|
89
|
-
<link>${
|
|
90
|
-
<guid>${
|
|
89
|
+
<link>${f(a)}</link>
|
|
90
|
+
<guid>${f(a)}</guid>
|
|
91
91
|
<pubDate>${o}</pubDate>
|
|
92
92
|
<description>${c}</description>
|
|
93
93
|
</item>`;
|
|
@@ -95,30 +95,30 @@ function Ee(e, t, n, r, a, o) {
|
|
|
95
95
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
96
96
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
97
97
|
<channel>
|
|
98
|
-
<title>${
|
|
99
|
-
<link>${
|
|
100
|
-
<description>${
|
|
98
|
+
<title>${f(i)}</title>
|
|
99
|
+
<link>${f(n + t)}</link>
|
|
100
|
+
<description>${f(a)}</description>
|
|
101
101
|
<language>${o}</language>
|
|
102
|
-
<atom:link href="${
|
|
102
|
+
<atom:link href="${f(n + t)}feed.xml" rel="self" type="application/rss+xml"/>
|
|
103
103
|
${s}
|
|
104
104
|
</channel>
|
|
105
105
|
</rss>
|
|
106
106
|
`;
|
|
107
107
|
}
|
|
108
108
|
// src/node/build/fonts.ts
|
|
109
|
-
function
|
|
109
|
+
function Ee(e) {
|
|
110
110
|
let t = A.basename(e);
|
|
111
111
|
return t.endsWith(".woff2") && t.includes("-latin-") && !t.includes("-latin-ext-");
|
|
112
112
|
}
|
|
113
113
|
// src/node/build/prerender.ts
|
|
114
|
-
var
|
|
115
|
-
async function
|
|
116
|
-
let { clientEntry: t, cssFiles: n, fontFiles: r } = await
|
|
117
|
-
e.pageRoutes.length >=
|
|
118
|
-
}
|
|
119
|
-
async function
|
|
120
|
-
let r = new
|
|
121
|
-
filename: A.resolve(
|
|
114
|
+
var De = 64;
|
|
115
|
+
async function Oe(e) {
|
|
116
|
+
let { clientEntry: t, cssFiles: n, fontFiles: r } = await je(e.clientOutDir), i = [n.map((t) => ` <link rel="stylesheet" href="${e.base}${t}">`).join("\n"), r.map((t) => ` <link rel="preload" as="font" type="font/woff2" crossorigin href="${e.base}${t}">`).join("\n")].filter(Boolean).join("\n") || void 0;
|
|
117
|
+
e.pageRoutes.length >= De ? await ke(e, t, i) : await Ae(e, t, i);
|
|
118
|
+
}
|
|
119
|
+
async function ke(e, t, n) {
|
|
120
|
+
let r = new Se({
|
|
121
|
+
filename: A.resolve(ce(import.meta.url), "../prerenderWorker.js"),
|
|
122
122
|
workerData: {
|
|
123
123
|
ssrEntryPath: e.ssrEntryPath,
|
|
124
124
|
base: e.base,
|
|
@@ -139,14 +139,14 @@ async function Ae(e, t, n) {
|
|
|
139
139
|
await r.destroy();
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
async function
|
|
142
|
+
async function Ae(e, t, r) {
|
|
143
143
|
let i = await (await import(e.ssrEntryPath)).createRenderer(), a = e.pageRoutes.length, o = 0;
|
|
144
144
|
for (let s of e.pageRoutes) {
|
|
145
|
-
let c = await i(s), l =
|
|
145
|
+
let c = await i(s), l = E(c.pageData, s, {
|
|
146
146
|
base: e.base,
|
|
147
147
|
origin: e.origin,
|
|
148
148
|
author: e.author
|
|
149
|
-
}), u =
|
|
149
|
+
}), u = T({
|
|
150
150
|
title: l.title,
|
|
151
151
|
description: l.description,
|
|
152
152
|
siteTitle: e.siteTitle,
|
|
@@ -159,15 +159,15 @@ async function je(e, t, n) {
|
|
|
159
159
|
ogType: l.ogType,
|
|
160
160
|
ogImagePath: l.ogImagePath,
|
|
161
161
|
jsonLdBlocks: l.jsonLdBlocks,
|
|
162
|
-
headExtra:
|
|
162
|
+
headExtra: r,
|
|
163
163
|
appContent: c.html
|
|
164
|
-
}), d = l.isHomepage ? "index.html" : `${
|
|
164
|
+
}), d = l.isHomepage ? "index.html" : `${n(s)}.html`, f = A.join(e.outDir, d);
|
|
165
165
|
await P.mkdir(A.dirname(f), { recursive: !0 }), await P.writeFile(f, u), o++, e.progress?.update(o, a);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
async function
|
|
168
|
+
async function je(e) {
|
|
169
169
|
let t = A.join(e, ".vite", "manifest.json"), n = await P.readFile(t, "utf-8"), r = JSON.parse(n), i = "", a = [], o = [];
|
|
170
|
-
for (let e of Object.values(r)) e.isEntry ? (i = e.file, e.css && a.push(...e.css)) :
|
|
170
|
+
for (let e of Object.values(r)) e.isEntry ? (i = e.file, e.css && a.push(...e.css)) : Ee(e.file) && o.push(e.file);
|
|
171
171
|
return {
|
|
172
172
|
clientEntry: i,
|
|
173
173
|
cssFiles: a,
|
|
@@ -175,90 +175,56 @@ async function Me(e) {
|
|
|
175
175
|
};
|
|
176
176
|
}
|
|
177
177
|
// src/node/lib/codegen/app-entry.ts
|
|
178
|
-
function
|
|
179
|
-
let { rootDir:
|
|
180
|
-
title:
|
|
181
|
-
description:
|
|
182
|
-
basePath:
|
|
183
|
-
origin:
|
|
184
|
-
lang:
|
|
185
|
-
repo:
|
|
186
|
-
author:
|
|
187
|
-
license:
|
|
188
|
-
rootDir:
|
|
189
|
-
nav:
|
|
178
|
+
function Me(e, t) {
|
|
179
|
+
let { rootDir: n = ".", mountPath: r = "", userComponents: i = [] } = e, a = [r, n === "." ? "" : n].filter(Boolean).join("/"), o = i.map((e) => `import ${e.name} from ${JSON.stringify(e.absolutePath)};`).join("\n"), s = i.map((e) => `app.component(${JSON.stringify(e.name)}, ${e.name});`).join("\n"), c = JSON.stringify({
|
|
180
|
+
title: e.siteTitle,
|
|
181
|
+
description: e.siteDescription,
|
|
182
|
+
basePath: e.basePath ?? "/",
|
|
183
|
+
origin: e.origin,
|
|
184
|
+
lang: e.lang,
|
|
185
|
+
repo: e.repo,
|
|
186
|
+
author: e.author,
|
|
187
|
+
license: e.license,
|
|
188
|
+
rootDir: n === "." ? void 0 : n,
|
|
189
|
+
nav: e.nav
|
|
190
190
|
});
|
|
191
191
|
return `
|
|
192
|
-
${[
|
|
192
|
+
${[o, "import 'typerighter/style.css';"].filter(Boolean).join("\n")}
|
|
193
193
|
import 'typerighter/fonts.css';
|
|
194
194
|
import('typerighter/math.css');
|
|
195
195
|
import { createTypedownApp } from 'typerighter/client';
|
|
196
|
-
import {
|
|
197
|
-
import {
|
|
198
|
-
import
|
|
199
|
-
import
|
|
200
|
-
import
|
|
201
|
-
import initialSiteData from '${n.siteData}';
|
|
202
|
-
let pages = initialPages;
|
|
203
|
-
let siteData = initialSiteData;
|
|
204
|
-
const contentExts = ${JSON.stringify(e)};
|
|
205
|
-
|
|
206
|
-
function findPage(base) {
|
|
207
|
-
for (const ext of contentExts) {
|
|
208
|
-
const key = base + ext;
|
|
209
|
-
if (pages[key]) return pages[key];
|
|
210
|
-
}
|
|
211
|
-
}
|
|
196
|
+
import { path } from 'typerighter/shared';
|
|
197
|
+
import { shallowRef } from 'vue';
|
|
198
|
+
import theme from '${t.theme}';
|
|
199
|
+
import { pages as initialPages } from '${t.pages}';
|
|
200
|
+
import initialSiteData from '${t.siteData}';
|
|
212
201
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (isIndexUrl(pagePath)) {
|
|
218
|
-
const dirPath = getDirectoryFromPageUrl(pagePath);
|
|
219
|
-
const dir = siteData.directoryListings[dirPath];
|
|
220
|
-
if (dir) return {
|
|
221
|
-
default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex); } },
|
|
222
|
-
pageData: { frontmatter: {}, headings: [], title: dir.title },
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return undefined;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const { app, router, searchIndex: searchIndexRef } = await createTypedownApp(loadPageModule, theme, ${l}, initialSiteData);
|
|
230
|
-
${c}
|
|
202
|
+
const siteData = shallowRef({ ...initialSiteData, pages: initialPages });
|
|
203
|
+
const { app, router, searchIndex: searchIndexRef } = await createTypedownApp({ ...${c}, theme }, siteData);
|
|
204
|
+
${s}
|
|
231
205
|
app.mount('#app');
|
|
232
206
|
|
|
233
207
|
// Load search index in the background after the app is mounted
|
|
234
|
-
import('${
|
|
208
|
+
import('${t.searchIndex}').then((m) => { searchIndexRef.value = m.default; });
|
|
235
209
|
|
|
236
210
|
// Accept HMR so modules update without a full page reload
|
|
237
211
|
if (import.meta.hot) {
|
|
238
|
-
import.meta.hot.accept('${
|
|
239
|
-
if (
|
|
240
|
-
const base = path.join('/', '${o}', router.route.path);
|
|
241
|
-
const hadPage = !!findPage(base);
|
|
242
|
-
pages = m.pages;
|
|
243
|
-
const hasPage = !!findPage(base);
|
|
244
|
-
// Current page was removed (deleted or renamed away)
|
|
245
|
-
if (hadPage && !hasPage) router.go(getParentUrl(router.route.path));
|
|
246
|
-
// A real page appeared where a directory index was shown
|
|
247
|
-
if (!hadPage && hasPage) router.go(router.route.path);
|
|
212
|
+
import.meta.hot.accept('${t.pages}', (m) => {
|
|
213
|
+
if (m) siteData.value = { ...siteData.value, pages: m.pages };
|
|
248
214
|
});
|
|
249
215
|
|
|
250
|
-
import.meta.hot.accept('${
|
|
216
|
+
import.meta.hot.accept('${t.searchIndex}', (m) => {
|
|
251
217
|
if (m) searchIndexRef.value = m.default;
|
|
252
218
|
});
|
|
253
219
|
|
|
254
|
-
import.meta.hot.accept('${
|
|
255
|
-
if (m) siteData = m.default;
|
|
220
|
+
import.meta.hot.accept('${t.siteData}', (m) => {
|
|
221
|
+
if (m) siteData.value = { ...m.default, pages: siteData.value.pages };
|
|
256
222
|
});
|
|
257
223
|
|
|
258
224
|
// Update route.data directly when content changes - Vue SFC setup only re-runs on script block changes
|
|
259
|
-
import.meta.hot.on('${
|
|
260
|
-
const eventBase = path.join('/', '${
|
|
261
|
-
const routeBase = path.join('/', '${
|
|
225
|
+
import.meta.hot.on('${t.pageDataEvent}', ({ filepath, pageData }) => {
|
|
226
|
+
const eventBase = path.join('/', '${a}', path.stripExtension(filepath));
|
|
227
|
+
const routeBase = path.join('/', '${a}', router.route.path);
|
|
262
228
|
if (eventBase === routeBase) {
|
|
263
229
|
router.route.data = pageData;
|
|
264
230
|
}
|
|
@@ -268,7 +234,7 @@ if (import.meta.hot) {
|
|
|
268
234
|
}
|
|
269
235
|
// src/node/lib/codegen/theme.ts
|
|
270
236
|
var I = "typerighter/client/theme-default";
|
|
271
|
-
function
|
|
237
|
+
function Ne(e, t) {
|
|
272
238
|
let n = e?.notFound ? `import CustomNotFound from ${JSON.stringify(t ? A.resolve(t, e.notFound) : e.notFound)};` : "", r = e?.notFound ? ", NotFound: CustomNotFound" : "";
|
|
273
239
|
if (e?.component) {
|
|
274
240
|
let i = t ? A.resolve(t, e.component) : e.component;
|
|
@@ -280,7 +246,7 @@ function Pe(e, t) {
|
|
|
280
246
|
}
|
|
281
247
|
let i = Object.entries(e?.slots ?? {});
|
|
282
248
|
if (0 < i.length) {
|
|
283
|
-
let e = i.map(([e, t]) => `${JSON.stringify(
|
|
249
|
+
let e = i.map(([e, t]) => `${JSON.stringify(b(e))}: () => h(resolveComponent(${JSON.stringify(t)}))`).join(", ");
|
|
284
250
|
return [
|
|
285
251
|
`import DefaultTheme from ${JSON.stringify(I)};`,
|
|
286
252
|
"import { h, resolveComponent } from 'vue';",
|
|
@@ -295,11 +261,11 @@ function Pe(e, t) {
|
|
|
295
261
|
].join("\n") : `export { default } from ${JSON.stringify(I)};`;
|
|
296
262
|
}
|
|
297
263
|
// src/node/lib/components.ts
|
|
298
|
-
function
|
|
264
|
+
function Pe(e) {
|
|
299
265
|
let t = A.join(e, "tsconfig.json");
|
|
300
|
-
if (F.existsSync(t)) return
|
|
301
|
-
let n =
|
|
302
|
-
return
|
|
266
|
+
if (F.existsSync(t)) return _e(t);
|
|
267
|
+
let n = Fe(e);
|
|
268
|
+
return ve(e, { compilerOptions: {
|
|
303
269
|
strict: !1,
|
|
304
270
|
jsx: "preserve",
|
|
305
271
|
jsxImportSource: "vue",
|
|
@@ -311,7 +277,7 @@ async function L(e, t) {
|
|
|
311
277
|
for (let r of e) if (r.kind === "dir") {
|
|
312
278
|
let e = A.resolve(t, r.path), i;
|
|
313
279
|
try {
|
|
314
|
-
i = await
|
|
280
|
+
i = await se(e, { withFileTypes: !0 });
|
|
315
281
|
} catch {
|
|
316
282
|
continue;
|
|
317
283
|
}
|
|
@@ -332,9 +298,9 @@ async function L(e, t) {
|
|
|
332
298
|
});
|
|
333
299
|
return n;
|
|
334
300
|
}
|
|
335
|
-
function
|
|
301
|
+
function Fe(e) {
|
|
336
302
|
try {
|
|
337
|
-
let t =
|
|
303
|
+
let t = ge(A.join(e, "package.json")), n = A.dirname(t.resolve("vue/package.json"));
|
|
338
304
|
return {
|
|
339
305
|
vue: [n],
|
|
340
306
|
"vue/*": [A.join(n, "*")]
|
|
@@ -349,7 +315,7 @@ var R = [
|
|
|
349
315
|
"◓",
|
|
350
316
|
"◑",
|
|
351
317
|
"◒"
|
|
352
|
-
],
|
|
318
|
+
], z = class {
|
|
353
319
|
logger;
|
|
354
320
|
label;
|
|
355
321
|
start;
|
|
@@ -370,83 +336,85 @@ var R = [
|
|
|
370
336
|
done(e) {
|
|
371
337
|
this.stopSpinner(), process.stdout.isTTY && process.stdout.write("\r\x1B[K");
|
|
372
338
|
let t = Math.round(performance.now() - this.start);
|
|
373
|
-
this.logger.success(`${e} (${
|
|
339
|
+
this.logger.success(`${e} (${Ie(t)})`);
|
|
374
340
|
}
|
|
375
341
|
stopSpinner() {
|
|
376
342
|
this.spinnerInterval &&= (clearInterval(this.spinnerInterval), void 0);
|
|
377
343
|
}
|
|
378
344
|
};
|
|
379
|
-
function
|
|
345
|
+
function Ie(e) {
|
|
380
346
|
return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
|
|
381
347
|
}
|
|
382
348
|
// src/node/build/index.ts
|
|
383
|
-
async function
|
|
384
|
-
let { root: n, logger:
|
|
349
|
+
async function Le(e, t = {}) {
|
|
350
|
+
let { root: n, logger: i } = e, a = A.resolve(n, t.outDir ?? "dist"), o = A.join(a, ".client"), s = A.join(a, ".server");
|
|
385
351
|
await P.rm(a, {
|
|
386
352
|
recursive: !0,
|
|
387
353
|
force: !0
|
|
388
354
|
});
|
|
389
|
-
let c = await e.getTdContext(), [l, u, d] = await Promise.all([
|
|
355
|
+
let c = await e.getTdContext(), [l, u, d, f] = await Promise.all([
|
|
390
356
|
c.getConfig(),
|
|
391
357
|
c.listFiles(),
|
|
392
|
-
c.listSidebar()
|
|
393
|
-
|
|
358
|
+
c.listSidebar(),
|
|
359
|
+
c.listSchemas()
|
|
360
|
+
]), p = await Promise.all(f.map(async (e) => [e, (await c.getSchema(e)).properties])), m = Object.fromEntries(p), h = l.origin ?? void 0, _ = l.author ?? void 0, v = l.license ?? void 0, y = l.repo ?? void 0, b = t.base ?? l.basePath ?? "/", x = S(b), ee = d.map((e) => ({
|
|
394
361
|
...e,
|
|
395
362
|
header: {}
|
|
396
|
-
})),
|
|
363
|
+
})), C = g(ee), w = JSON.stringify({
|
|
397
364
|
title: l.siteTitle,
|
|
398
365
|
description: l.siteDescription,
|
|
399
|
-
basePath:
|
|
400
|
-
origin:
|
|
366
|
+
basePath: x,
|
|
367
|
+
origin: h,
|
|
401
368
|
lang: l.lang,
|
|
402
369
|
rootDir: l.rootDir,
|
|
403
|
-
repo:
|
|
404
|
-
author:
|
|
405
|
-
license:
|
|
370
|
+
repo: y,
|
|
371
|
+
author: _,
|
|
372
|
+
license: v,
|
|
406
373
|
nav: l.nav
|
|
407
|
-
}),
|
|
374
|
+
}), T = JSON.stringify({
|
|
408
375
|
ready: !0,
|
|
409
|
-
contentTree:
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
376
|
+
contentTree: C,
|
|
377
|
+
schemas: m
|
|
378
|
+
}), E = A.join(n, "node_modules", ".typerighter");
|
|
379
|
+
await P.mkdir(E, { recursive: !0 });
|
|
380
|
+
let D = A.join(E, "client-entry.js"), O = A.join(E, "ssr-entry.js"), k = A.join(E, "theme.js"), te = await L(l.components, n), ne = Ne(l.layout ?? void 0, n);
|
|
413
381
|
await Promise.all([
|
|
414
|
-
P.writeFile(
|
|
382
|
+
P.writeFile(D, Me({
|
|
415
383
|
rootDir: l.rootDir,
|
|
416
|
-
basePath:
|
|
417
|
-
origin:
|
|
384
|
+
basePath: x,
|
|
385
|
+
origin: h,
|
|
418
386
|
lang: l.lang,
|
|
419
387
|
siteTitle: l.siteTitle,
|
|
420
388
|
siteDescription: l.siteDescription,
|
|
421
|
-
repo:
|
|
422
|
-
author:
|
|
423
|
-
license:
|
|
389
|
+
repo: y,
|
|
390
|
+
author: _,
|
|
391
|
+
license: v,
|
|
424
392
|
nav: l.nav,
|
|
425
|
-
userComponents:
|
|
393
|
+
userComponents: te
|
|
426
394
|
}, {
|
|
427
|
-
theme:
|
|
428
|
-
pages:
|
|
429
|
-
siteData:
|
|
430
|
-
searchIndex:
|
|
431
|
-
pageDataEvent:
|
|
395
|
+
theme: Y,
|
|
396
|
+
pages: G,
|
|
397
|
+
siteData: q,
|
|
398
|
+
searchIndex: J,
|
|
399
|
+
pageDataEvent: X
|
|
432
400
|
})),
|
|
433
|
-
P.writeFile(
|
|
401
|
+
P.writeFile(O, Re({
|
|
434
402
|
rootDir: l.rootDir,
|
|
435
|
-
siteConfig:
|
|
436
|
-
siteData:
|
|
437
|
-
themeModulePath:
|
|
438
|
-
userComponents:
|
|
403
|
+
siteConfig: w,
|
|
404
|
+
siteData: T,
|
|
405
|
+
themeModulePath: k,
|
|
406
|
+
userComponents: te
|
|
439
407
|
})),
|
|
440
|
-
P.writeFile(
|
|
408
|
+
P.writeFile(k, ne)
|
|
441
409
|
]);
|
|
442
410
|
try {
|
|
443
|
-
let c =
|
|
444
|
-
await
|
|
411
|
+
let c = _n({ context: e }), f = e.createViteLogger(), p = new z(i, "Building client bundle...");
|
|
412
|
+
await oe({
|
|
445
413
|
...t.viteConfig,
|
|
446
414
|
root: n,
|
|
447
|
-
base:
|
|
415
|
+
base: x,
|
|
448
416
|
plugins: c,
|
|
449
|
-
customLogger:
|
|
417
|
+
customLogger: f,
|
|
450
418
|
logLevel: "silent",
|
|
451
419
|
build: {
|
|
452
420
|
...t.viteConfig?.build,
|
|
@@ -455,59 +423,59 @@ async function ze(e, t = {}) {
|
|
|
455
423
|
emptyOutDir: !0,
|
|
456
424
|
rollupOptions: {
|
|
457
425
|
...t.viteConfig?.build?.rollupOptions,
|
|
458
|
-
input:
|
|
426
|
+
input: D
|
|
459
427
|
}
|
|
460
428
|
}
|
|
461
429
|
});
|
|
462
|
-
let
|
|
463
|
-
|
|
464
|
-
let
|
|
465
|
-
await
|
|
430
|
+
let m = await P.readdir(A.join(o, "assets")).catch(() => []);
|
|
431
|
+
p.done(`Client bundle (${m.length} chunks)`);
|
|
432
|
+
let g = new z(i, "Building SSR bundle...");
|
|
433
|
+
await oe({
|
|
466
434
|
...t.viteConfig,
|
|
467
435
|
root: n,
|
|
468
|
-
base:
|
|
436
|
+
base: x,
|
|
469
437
|
plugins: c,
|
|
470
|
-
customLogger:
|
|
438
|
+
customLogger: f,
|
|
471
439
|
logLevel: "silent",
|
|
472
440
|
build: {
|
|
473
441
|
...t.viteConfig?.build,
|
|
474
442
|
outDir: s,
|
|
475
|
-
ssr:
|
|
443
|
+
ssr: O,
|
|
476
444
|
emptyOutDir: !0
|
|
477
445
|
}
|
|
478
|
-
}),
|
|
479
|
-
let
|
|
480
|
-
let t =
|
|
446
|
+
}), g.done("SSR bundle");
|
|
447
|
+
let v = u.map((e) => {
|
|
448
|
+
let t = r(e);
|
|
481
449
|
return t === "index" ? "/" : `/${t}`;
|
|
482
450
|
});
|
|
483
|
-
|
|
484
|
-
let
|
|
485
|
-
await
|
|
451
|
+
v.push("/"), Be(C.entries, v);
|
|
452
|
+
let y = new z(i, "Pre-rendering pages...");
|
|
453
|
+
await Oe({
|
|
486
454
|
ssrEntryPath: A.join(s, "ssr-entry.js"),
|
|
487
455
|
clientOutDir: o,
|
|
488
456
|
outDir: a,
|
|
489
|
-
base:
|
|
490
|
-
origin:
|
|
457
|
+
base: x,
|
|
458
|
+
origin: h,
|
|
491
459
|
lang: l.lang,
|
|
492
|
-
pageRoutes:
|
|
460
|
+
pageRoutes: v,
|
|
493
461
|
siteTitle: l.siteTitle,
|
|
494
|
-
author:
|
|
495
|
-
progress:
|
|
496
|
-
}),
|
|
497
|
-
let
|
|
462
|
+
author: _,
|
|
463
|
+
progress: y
|
|
464
|
+
}), y.done(`Pre-rendered ${v.length} pages`);
|
|
465
|
+
let b = /* @__PURE__ */ new Map();
|
|
498
466
|
for (let e of d) {
|
|
499
|
-
let t =
|
|
500
|
-
|
|
467
|
+
let t = r(e.filepath), n = t === "index" ? "/" : `/${t}`;
|
|
468
|
+
b.set(n, e.fileMetadata.mtimeSecs);
|
|
501
469
|
}
|
|
502
|
-
let
|
|
503
|
-
|
|
504
|
-
let
|
|
505
|
-
await P.cp(
|
|
506
|
-
let
|
|
507
|
-
await P.cp(
|
|
470
|
+
let ee = Ce(v, x, h, b), S = [P.writeFile(A.join(a, "sitemap.xml"), ee)];
|
|
471
|
+
h !== void 0 && (S.push(P.writeFile(A.join(a, "robots.txt"), we(h, x))), S.push(P.writeFile(A.join(a, "feed.xml"), Te(d, x, h, l.siteTitle, l.siteDescription, l.lang)))), await Promise.all(S);
|
|
472
|
+
let w = A.join(o, "assets"), T = A.join(a, "assets");
|
|
473
|
+
await P.cp(w, T, { recursive: !0 }).catch(() => {}), await ze(A.join(n, l.rootDir), a);
|
|
474
|
+
let E = A.join(n, l.publicDir);
|
|
475
|
+
await P.cp(E, a, { recursive: !0 }).catch(() => {});
|
|
508
476
|
} finally {
|
|
509
477
|
await Promise.all([
|
|
510
|
-
P.rm(
|
|
478
|
+
P.rm(E, {
|
|
511
479
|
recursive: !0,
|
|
512
480
|
force: !0
|
|
513
481
|
}),
|
|
@@ -521,52 +489,26 @@ async function ze(e, t = {}) {
|
|
|
521
489
|
})
|
|
522
490
|
]);
|
|
523
491
|
}
|
|
524
|
-
|
|
492
|
+
i.log(`\nBuild complete. Output: ${a}`);
|
|
525
493
|
}
|
|
526
|
-
function
|
|
527
|
-
let
|
|
528
|
-
...
|
|
529
|
-
directoryListings:
|
|
530
|
-
}),
|
|
494
|
+
function Re(e) {
|
|
495
|
+
let t = `/${e.rootDir}/${m}`, n = JSON.parse(e.siteConfig), r = JSON.parse(e.siteData), i = r.contentTree ?? { entries: [] }, a = h(i.entries ?? [], n.title ?? ""), o = JSON.stringify({
|
|
496
|
+
...r,
|
|
497
|
+
directoryListings: a
|
|
498
|
+
}), s = e.userComponents ?? [], c = s.map((e) => `import ${e.name} from ${JSON.stringify(e.absolutePath)};`).join("\n"), l = s.map((e) => `app.component(${JSON.stringify(e.name)}, ${e.name});`).join("\n");
|
|
531
499
|
return `
|
|
532
|
-
${[
|
|
533
|
-
import { TdDirectoryIndex, TdGlossaryIndex } from 'typerighter/client/theme-default';
|
|
534
|
-
import { isIndexUrl, getDirectoryFromPageUrl } from 'typerighter/shared';
|
|
500
|
+
${[c, "import { createTypedownApp } from 'typerighter/client';"].filter(Boolean).join("\n")}
|
|
535
501
|
import { renderToString } from 'vue/server-renderer';
|
|
536
|
-
import {
|
|
537
|
-
import theme from ${JSON.stringify(
|
|
538
|
-
|
|
539
|
-
const pages = import.meta.glob('${n}', { eager: true });
|
|
540
|
-
const contentExts = ${JSON.stringify(e)};
|
|
541
|
-
const siteData = ${s};
|
|
542
|
-
|
|
543
|
-
function findPage(base) {
|
|
544
|
-
for (const ext of contentExts) {
|
|
545
|
-
const key = base + ext;
|
|
546
|
-
if (pages[key]) return pages[key];
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
function loadPageModule(pagePath) {
|
|
551
|
-
const base = ('/${t.rootDir}/' + pagePath).replace(/\\/+/g, '/').replace(/\\/$/, '');
|
|
552
|
-
const page = findPage(base);
|
|
553
|
-
if (page) return Promise.resolve(page);
|
|
502
|
+
import { shallowRef } from 'vue';
|
|
503
|
+
import theme from ${JSON.stringify(e.themeModulePath)};
|
|
554
504
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
if (dir) return Promise.resolve({
|
|
559
|
-
default: { name: 'DirectoryIndex', render() { return h(TdDirectoryIndex); } },
|
|
560
|
-
pageData: { frontmatter: {}, headings: [], title: dir.title },
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
return Promise.resolve(undefined);
|
|
565
|
-
}
|
|
505
|
+
const rawPages = import.meta.glob('${t}', { eager: true });
|
|
506
|
+
const pages = Object.fromEntries(Object.entries(rawPages).map(([k, v]) => [k, () => Promise.resolve(v)]));
|
|
507
|
+
const siteData = shallowRef({ ...${o}, pages });
|
|
566
508
|
|
|
567
509
|
export async function createRenderer() {
|
|
568
|
-
const { app, router } = await createTypedownApp(
|
|
569
|
-
${
|
|
510
|
+
const { app, router } = await createTypedownApp({ ...${e.siteConfig}, theme }, siteData);
|
|
511
|
+
${l}
|
|
570
512
|
return async function render(url) {
|
|
571
513
|
await router.go(url, { replace: true });
|
|
572
514
|
const html = await renderToString(app);
|
|
@@ -575,31 +517,31 @@ export async function createRenderer() {
|
|
|
575
517
|
}
|
|
576
518
|
`;
|
|
577
519
|
}
|
|
578
|
-
async function
|
|
520
|
+
async function ze(e, t) {
|
|
579
521
|
let n = (await P.readdir(e, {
|
|
580
522
|
recursive: !0,
|
|
581
523
|
withFileTypes: !0
|
|
582
|
-
})).filter((e) => e.isFile() && !
|
|
524
|
+
})).filter((e) => e.isFile() && !w(e.name)).map(async (n) => {
|
|
583
525
|
let r = A.join(n.parentPath, n.name), i = A.relative(e, r), a = A.join(t, i);
|
|
584
526
|
return P.mkdir(A.dirname(a), { recursive: !0 }).then(() => P.copyFile(r, a));
|
|
585
527
|
});
|
|
586
528
|
await Promise.all(n);
|
|
587
529
|
}
|
|
588
|
-
function
|
|
530
|
+
function Be(e, t, n = "") {
|
|
589
531
|
for (let r of e) {
|
|
590
532
|
if (r.kind !== "dir") continue;
|
|
591
533
|
let e = `${n}/${r.node.name}`;
|
|
592
|
-
|
|
534
|
+
u(r.node) || t.push(s(e)), Be(r.node.entries, t, e);
|
|
593
535
|
}
|
|
594
536
|
}
|
|
595
537
|
// ../../node_modules/.pnpm/@shikijs+transformers@4.4.3/node_modules/@shikijs/transformers/dist/index.mjs
|
|
596
|
-
var
|
|
538
|
+
var Ve = /(\s+\/\/)/, He = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/, Ue = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/, We = [
|
|
597
539
|
[/^(<!--)(.+)(-->)$/, !1],
|
|
598
540
|
[/^(\/\*)(.+)(\*\/)$/, !1],
|
|
599
541
|
[/^(\/\/|["'#]|;{1,2}|%{1,2}|--)(.*)$/, !0],
|
|
600
542
|
[/^(\*)(.+)$/, !0]
|
|
601
543
|
];
|
|
602
|
-
function
|
|
544
|
+
function Ge(e, t, n) {
|
|
603
545
|
let r = [];
|
|
604
546
|
for (let i of e) {
|
|
605
547
|
if (n === "v3") {
|
|
@@ -608,8 +550,8 @@ function qe(e, t, n) {
|
|
|
608
550
|
let n = e.children[0];
|
|
609
551
|
if (n.type !== "text") return e;
|
|
610
552
|
let r = t === i.children.length - 1;
|
|
611
|
-
if (!
|
|
612
|
-
let a = n.value.split(
|
|
553
|
+
if (!B(n.value, r)) return e;
|
|
554
|
+
let a = n.value.split(Ve);
|
|
613
555
|
if (a.length <= 1) return e;
|
|
614
556
|
let o = [a[0]];
|
|
615
557
|
for (let e = 1; e < a.length; e += 2) o.push(a[e] + (a[e + 1] || ""));
|
|
@@ -630,13 +572,13 @@ function qe(e, t, n) {
|
|
|
630
572
|
if (a.type !== "element") continue;
|
|
631
573
|
let o = a.children.at(0);
|
|
632
574
|
if (o?.type !== "text") continue;
|
|
633
|
-
let s = n === e.length - 1, c =
|
|
575
|
+
let s = n === e.length - 1, c = B(o.value, s), l;
|
|
634
576
|
if (!c && n > 0 && o.value.trim().startsWith("[!code")) {
|
|
635
577
|
let t = e[n - 1];
|
|
636
578
|
if (t?.type === "element") {
|
|
637
579
|
let n = t.children.at(0);
|
|
638
580
|
if (n?.type === "text" && n.value.includes("//")) {
|
|
639
|
-
let l =
|
|
581
|
+
let l = B(n.value + o.value, s);
|
|
640
582
|
if (l) {
|
|
641
583
|
c = l, r.push({
|
|
642
584
|
info: l,
|
|
@@ -653,7 +595,7 @@ function qe(e, t, n) {
|
|
|
653
595
|
}
|
|
654
596
|
if (c) {
|
|
655
597
|
if (t && !s && n !== 0) {
|
|
656
|
-
let t =
|
|
598
|
+
let t = Ke(e[n - 1], "{") && Ke(e[n + 1], "}");
|
|
657
599
|
r.push({
|
|
658
600
|
info: c,
|
|
659
601
|
line: i,
|
|
@@ -675,16 +617,16 @@ function qe(e, t, n) {
|
|
|
675
617
|
}
|
|
676
618
|
return r;
|
|
677
619
|
}
|
|
678
|
-
function
|
|
620
|
+
function Ke(e, t) {
|
|
679
621
|
if (e.type !== "element") return !1;
|
|
680
622
|
let n = e.children[0];
|
|
681
623
|
return n.type === "text" && n.value.trim() === t;
|
|
682
624
|
}
|
|
683
|
-
function
|
|
625
|
+
function B(e, t) {
|
|
684
626
|
let n = e.trimStart(), r = e.length - n.length;
|
|
685
627
|
n = n.trimEnd();
|
|
686
628
|
let i = e.length - n.length - r;
|
|
687
|
-
for (let [e, a] of
|
|
629
|
+
for (let [e, a] of We) {
|
|
688
630
|
if (a && !t) continue;
|
|
689
631
|
let o = e.exec(n);
|
|
690
632
|
if (o) return [
|
|
@@ -694,22 +636,22 @@ function z(e, t) {
|
|
|
694
636
|
];
|
|
695
637
|
}
|
|
696
638
|
}
|
|
697
|
-
function
|
|
698
|
-
let t = e.match(
|
|
639
|
+
function qe(e) {
|
|
640
|
+
let t = e.match(He);
|
|
699
641
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index) : e;
|
|
700
642
|
}
|
|
701
|
-
function
|
|
702
|
-
let t = e.match(
|
|
643
|
+
function Je(e) {
|
|
644
|
+
let t = e.match(Ue);
|
|
703
645
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index).trimEnd() : e;
|
|
704
646
|
}
|
|
705
|
-
function
|
|
647
|
+
function Ye(e, t, n, r) {
|
|
706
648
|
return r ??= "v3", {
|
|
707
649
|
name: e,
|
|
708
650
|
code(e) {
|
|
709
651
|
let i = e.children.filter((e) => e.type === "element"), a = [];
|
|
710
652
|
e.data ??= {};
|
|
711
653
|
let o = e.data;
|
|
712
|
-
o._shiki_notation ??=
|
|
654
|
+
o._shiki_notation ??= Ge(i, ["jsx", "tsx"].includes(this.options.lang), r);
|
|
713
655
|
let s = o._shiki_notation;
|
|
714
656
|
for (let e of s) {
|
|
715
657
|
if (e.info[1].length === 0) continue;
|
|
@@ -717,7 +659,7 @@ function Ze(e, t, n, r) {
|
|
|
717
659
|
e.isLineCommentOnly && r !== "v1" && o++;
|
|
718
660
|
let s = !1;
|
|
719
661
|
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;
|
|
720
|
-
r === "v1" ? e.info[1] =
|
|
662
|
+
r === "v1" ? e.info[1] = qe(e.info[1]) : r === "v3" && (e.info[1] = Je(e.info[1]));
|
|
721
663
|
let c = e.info[1].trim().length === 0;
|
|
722
664
|
if (c && (e.info[1] = ""), c && e.isLineCommentOnly) a.push(e.line);
|
|
723
665
|
else if (c && e.isJsxStyle) e.line.children.splice(e.line.children.indexOf(e.token) - 1, 3);
|
|
@@ -742,44 +684,44 @@ function Ze(e, t, n, r) {
|
|
|
742
684
|
}
|
|
743
685
|
};
|
|
744
686
|
}
|
|
745
|
-
var
|
|
746
|
-
function
|
|
687
|
+
var Xe = /\{([\d,-]+)\}/;
|
|
688
|
+
function Ze(e) {
|
|
747
689
|
if (!e) return null;
|
|
748
|
-
let t = e.match(
|
|
690
|
+
let t = e.match(Xe);
|
|
749
691
|
return t ? t[1].split(",").flatMap((e) => {
|
|
750
692
|
let t = e.split("-").map((e) => Number.parseInt(e, 10));
|
|
751
693
|
return t.length === 1 ? [t[0]] : Array.from({ length: t[1] - t[0] + 1 }, (e, n) => t[0] + n);
|
|
752
694
|
}) : null;
|
|
753
695
|
}
|
|
754
|
-
var
|
|
755
|
-
function
|
|
696
|
+
var Qe = Symbol("highlighted-lines");
|
|
697
|
+
function $e(e = {}) {
|
|
756
698
|
let { className: t = "highlighted", zeroIndexed: n = !1 } = e;
|
|
757
699
|
return {
|
|
758
700
|
name: "@shikijs/transformers:meta-highlight",
|
|
759
701
|
line(e, r) {
|
|
760
702
|
if (!this.options.meta?.__raw) return;
|
|
761
703
|
let i = this.meta;
|
|
762
|
-
i[
|
|
763
|
-
let a = i[
|
|
704
|
+
i[Qe] ??= Ze(this.options.meta.__raw);
|
|
705
|
+
let a = i[Qe] ?? [], o = n ? r - 1 : r;
|
|
764
706
|
return a.includes(o) && this.addClassToHast(e, t), e;
|
|
765
707
|
}
|
|
766
708
|
};
|
|
767
709
|
}
|
|
768
|
-
var
|
|
769
|
-
function
|
|
770
|
-
return e.replace(
|
|
710
|
+
var et = /[.*+?^${}()|[\]\\]/g;
|
|
711
|
+
function tt(e) {
|
|
712
|
+
return e.replace(et, "\\$&");
|
|
771
713
|
}
|
|
772
|
-
function
|
|
714
|
+
function V(e = {}, t = "@shikijs/transformers:notation-map") {
|
|
773
715
|
let { classMap: n = {}, classActivePre: r = void 0, classActiveCode: i = void 0 } = e;
|
|
774
|
-
return
|
|
716
|
+
return Ye(t, RegExp(`#?\\s*\\[!code (${Object.keys(n).map(tt).join("|")})(:\\d+)?\\]`, "gi"), function([e, t, a = ":1"], o, s, c, l) {
|
|
775
717
|
let u = Number.parseInt(a.slice(1), 10);
|
|
776
718
|
for (let e = l; e < Math.min(l + u, c.length); e++) this.addClassToHast(c[e], n[t]);
|
|
777
719
|
return r && this.addClassToHast(this.pre, r), i && this.addClassToHast(this.code, i), !0;
|
|
778
720
|
}, e.matchAlgorithm);
|
|
779
721
|
}
|
|
780
|
-
function
|
|
722
|
+
function nt(e = {}) {
|
|
781
723
|
let { classLineAdd: t = "diff add", classLineRemove: n = "diff remove", classActivePre: r = "has-diff", classActiveCode: i } = e;
|
|
782
|
-
return
|
|
724
|
+
return V({
|
|
783
725
|
classMap: {
|
|
784
726
|
"++": t,
|
|
785
727
|
"--": n
|
|
@@ -789,31 +731,31 @@ function it(e = {}) {
|
|
|
789
731
|
matchAlgorithm: e.matchAlgorithm
|
|
790
732
|
}, "@shikijs/transformers:notation-diff");
|
|
791
733
|
}
|
|
792
|
-
function
|
|
734
|
+
function rt(e = {}) {
|
|
793
735
|
let { classMap: t = {
|
|
794
736
|
error: ["highlighted", "error"],
|
|
795
737
|
warning: ["highlighted", "warning"],
|
|
796
738
|
info: ["highlighted", "info"]
|
|
797
739
|
}, classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
798
|
-
return
|
|
740
|
+
return V({
|
|
799
741
|
classMap: t,
|
|
800
742
|
classActivePre: n,
|
|
801
743
|
classActiveCode: r,
|
|
802
744
|
matchAlgorithm: e.matchAlgorithm
|
|
803
745
|
}, "@shikijs/transformers:notation-error-level");
|
|
804
746
|
}
|
|
805
|
-
function
|
|
747
|
+
function it(e = {}) {
|
|
806
748
|
let { classActiveLine: t = "focused", classActivePre: n = "has-focused", classActiveCode: r } = e;
|
|
807
|
-
return
|
|
749
|
+
return V({
|
|
808
750
|
classMap: { focus: t },
|
|
809
751
|
classActivePre: n,
|
|
810
752
|
classActiveCode: r,
|
|
811
753
|
matchAlgorithm: e.matchAlgorithm
|
|
812
754
|
}, "@shikijs/transformers:notation-focus");
|
|
813
755
|
}
|
|
814
|
-
function
|
|
756
|
+
function at(e = {}) {
|
|
815
757
|
let { classActiveLine: t = "highlighted", classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
816
|
-
return
|
|
758
|
+
return V({
|
|
817
759
|
classMap: {
|
|
818
760
|
highlight: t,
|
|
819
761
|
hl: t
|
|
@@ -824,41 +766,41 @@ function st(e = {}) {
|
|
|
824
766
|
}, "@shikijs/transformers:notation-highlight");
|
|
825
767
|
}
|
|
826
768
|
// src/node/lib/render/highlight/language.ts
|
|
827
|
-
var
|
|
769
|
+
var ot = [
|
|
828
770
|
"shellscript",
|
|
829
771
|
"shell",
|
|
830
772
|
"bash",
|
|
831
773
|
"sh",
|
|
832
774
|
"zsh"
|
|
833
775
|
];
|
|
834
|
-
function
|
|
835
|
-
return
|
|
776
|
+
function st(e) {
|
|
777
|
+
return ot.includes(e);
|
|
836
778
|
}
|
|
837
|
-
var
|
|
838
|
-
function
|
|
839
|
-
return
|
|
779
|
+
var ct = /^[a-zA-Z0-9-_]+/;
|
|
780
|
+
function lt(e) {
|
|
781
|
+
return ct.exec(e)?.[0] || "";
|
|
840
782
|
}
|
|
841
783
|
// src/node/lib/render/highlight/index.ts
|
|
842
|
-
var
|
|
784
|
+
var ut = new FinalizationRegistry((e) => {
|
|
843
785
|
e();
|
|
844
|
-
}),
|
|
786
|
+
}), H = {
|
|
845
787
|
light: "github-light",
|
|
846
788
|
dark: "github-dark"
|
|
847
789
|
};
|
|
848
|
-
async function
|
|
849
|
-
let e = await
|
|
850
|
-
themes: [
|
|
790
|
+
async function dt() {
|
|
791
|
+
let e = await ye({
|
|
792
|
+
themes: [H.light, H.dark],
|
|
851
793
|
langs: []
|
|
852
794
|
}), t = [
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
795
|
+
$e(),
|
|
796
|
+
nt(),
|
|
797
|
+
it({
|
|
856
798
|
classActiveLine: "has-focus",
|
|
857
799
|
classActivePre: "has-focused-lines"
|
|
858
800
|
}),
|
|
859
|
-
st(),
|
|
860
801
|
at(),
|
|
861
|
-
|
|
802
|
+
rt(),
|
|
803
|
+
ft(),
|
|
862
804
|
{
|
|
863
805
|
name: "typedown:add-dir",
|
|
864
806
|
pre(e) {
|
|
@@ -867,19 +809,19 @@ async function pt() {
|
|
|
867
809
|
}
|
|
868
810
|
], n = new Set(e.getLoadedLanguages());
|
|
869
811
|
async function r(r, i, a, o) {
|
|
870
|
-
let s =
|
|
812
|
+
let s = lt(i);
|
|
871
813
|
if (s) {
|
|
872
814
|
let e = i;
|
|
873
815
|
i = s.toLowerCase(), a = e.slice(i.length).replace(/(?<!=)\{/g, " {") + " " + a, a = a.trim().replace(/\s+/g, " ");
|
|
874
816
|
}
|
|
875
817
|
i ||= "txt";
|
|
876
818
|
try {
|
|
877
|
-
!
|
|
819
|
+
!xe(i) && !n.has(i) && (await e.loadLanguage(i), n.add(i));
|
|
878
820
|
} catch {
|
|
879
|
-
|
|
821
|
+
O.warn(`\nThe language '${i}' is not loaded, falling back to 'txt' for syntax highlighting.`), i = "txt";
|
|
880
822
|
}
|
|
881
823
|
r = r.trimEnd();
|
|
882
|
-
let c =
|
|
824
|
+
let c = be(r, i, e);
|
|
883
825
|
return await e.loadLanguage(...c), e.codeToHtml(r, {
|
|
884
826
|
lang: i,
|
|
885
827
|
transformers: [
|
|
@@ -900,10 +842,10 @@ async function pt() {
|
|
|
900
842
|
});
|
|
901
843
|
}
|
|
902
844
|
},
|
|
903
|
-
...o === void 0 ? [] : [
|
|
845
|
+
...o === void 0 ? [] : [pt(o)]
|
|
904
846
|
],
|
|
905
847
|
meta: { __raw: a },
|
|
906
|
-
themes:
|
|
848
|
+
themes: H,
|
|
907
849
|
defaultColor: !1,
|
|
908
850
|
colorReplacements: {
|
|
909
851
|
"github-light": {
|
|
@@ -928,13 +870,13 @@ async function pt() {
|
|
|
928
870
|
}
|
|
929
871
|
});
|
|
930
872
|
}
|
|
931
|
-
return
|
|
873
|
+
return ut.register(r, () => e.dispose()), r;
|
|
932
874
|
}
|
|
933
|
-
function
|
|
875
|
+
function ft() {
|
|
934
876
|
return {
|
|
935
877
|
name: "typedown:disable-shell-symbol-select",
|
|
936
878
|
tokens(e) {
|
|
937
|
-
if (
|
|
879
|
+
if (st(this.options.lang)) for (let t of e) {
|
|
938
880
|
if (t.length < 2) continue;
|
|
939
881
|
let e = t[0].content.trim();
|
|
940
882
|
(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));
|
|
@@ -942,7 +884,7 @@ function mt() {
|
|
|
942
884
|
}
|
|
943
885
|
};
|
|
944
886
|
}
|
|
945
|
-
function
|
|
887
|
+
function pt(e) {
|
|
946
888
|
return {
|
|
947
889
|
name: "typedown:line-numbers",
|
|
948
890
|
code(t) {
|
|
@@ -974,23 +916,23 @@ function ht(e) {
|
|
|
974
916
|
};
|
|
975
917
|
}
|
|
976
918
|
// src/node/lib/render/postprocess.ts
|
|
977
|
-
var
|
|
978
|
-
async function
|
|
979
|
-
return e = await
|
|
919
|
+
var mt;
|
|
920
|
+
async function ht(e) {
|
|
921
|
+
return e = await vt(e), e = wt(e), e;
|
|
980
922
|
}
|
|
981
|
-
function
|
|
982
|
-
return
|
|
923
|
+
function gt() {
|
|
924
|
+
return mt ||= dt(), mt;
|
|
983
925
|
}
|
|
984
|
-
var
|
|
985
|
-
function
|
|
926
|
+
var _t = /<pre class="td-code-placeholder"([^>]*)><code>([\s\S]*?)<\/code><\/pre>/g;
|
|
927
|
+
function U(e, t) {
|
|
986
928
|
return e.match(RegExp(`${t}="([^"]*)"`))?.[1];
|
|
987
929
|
}
|
|
988
|
-
async function
|
|
989
|
-
let t = await
|
|
930
|
+
async function vt(e) {
|
|
931
|
+
let t = await gt(), n = [...e.matchAll(_t)];
|
|
990
932
|
if (n.length === 0) return e;
|
|
991
933
|
let r = await Promise.all(n.map(async (e) => {
|
|
992
|
-
let n = e[1], r =
|
|
993
|
-
return
|
|
934
|
+
let n = e[1], r = U(n, "data-lang") ?? "", i = U(n, "data-meta") ?? "", a = U(n, "data-title"), o = U(n, "data-line-numbers"), s = p(e[2]);
|
|
935
|
+
return xt(await t(s, r, i, o === void 0 ? void 0 : parseInt(o) || 1), r, {
|
|
994
936
|
title: a,
|
|
995
937
|
lineNumbers: o
|
|
996
938
|
});
|
|
@@ -1001,7 +943,7 @@ async function bt(e) {
|
|
|
1001
943
|
}
|
|
1002
944
|
return i;
|
|
1003
945
|
}
|
|
1004
|
-
var
|
|
946
|
+
var yt = {
|
|
1005
947
|
typescript: "TypeScript",
|
|
1006
948
|
javascript: "JavaScript",
|
|
1007
949
|
tsx: "TSX",
|
|
@@ -1049,38 +991,38 @@ var xt = {
|
|
|
1049
991
|
scala: "Scala",
|
|
1050
992
|
txt: "Text"
|
|
1051
993
|
};
|
|
1052
|
-
function
|
|
1053
|
-
return
|
|
994
|
+
function bt(e) {
|
|
995
|
+
return yt[e.toLowerCase()] ?? e;
|
|
1054
996
|
}
|
|
1055
|
-
function
|
|
997
|
+
function xt(e, t, n) {
|
|
1056
998
|
t ||= "txt";
|
|
1057
|
-
let r =
|
|
999
|
+
let r = bt(t), i = ["td-code-block", "language-" + t];
|
|
1058
1000
|
n.title && i.push("has-title"), n.lineNumbers !== void 0 && i.push("line-numbers-mode");
|
|
1059
1001
|
let a = `<figure class="${i.join(" ")}">`;
|
|
1060
|
-
return a += "<figcaption class=\"td-code-header\">", a += "<span class=\"td-code-left\">", a += `<span class="td-code-lang">${
|
|
1002
|
+
return a += "<figcaption class=\"td-code-header\">", a += "<span class=\"td-code-left\">", a += `<span class="td-code-lang">${f(r)}</span>`, n.title && (a += `<span class="td-code-label">${f(n.title)}</span>`), a += "</span>", a += "<span class=\"td-code-actions\">", a += "<button type=\"button\" aria-label=\"Copy code\" data-copied=\"Copied\" class=\"td-code-copy\">", a += "<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"></rect><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"></path></svg>", a += "<span class=\"td-code-copy-text\">Copy</span>", a += "</button>", a += "</span>", a += "</figcaption>", a += e, a += "</figure>", a;
|
|
1061
1003
|
}
|
|
1062
|
-
var
|
|
1063
|
-
function
|
|
1064
|
-
return e = e.replace(
|
|
1004
|
+
var St = /<span class="td-math-inline">([\s\S]*?)<\/span>/g, Ct = /<div class="td-math-block">([\s\S]*?)<\/div>/g;
|
|
1005
|
+
function wt(e) {
|
|
1006
|
+
return e = e.replace(St, (e, t) => Dt(t, !1)), e = e.replace(Ct, (e, t) => Dt(t, !0)), e;
|
|
1065
1007
|
}
|
|
1066
|
-
var
|
|
1067
|
-
function
|
|
1008
|
+
var Tt = /`([^`]+)`|\$([^$]+)\$/g;
|
|
1009
|
+
function Et(e) {
|
|
1068
1010
|
let t = 0, n = "";
|
|
1069
|
-
for (let r of e.matchAll(
|
|
1070
|
-
if (n +=
|
|
1011
|
+
for (let r of e.matchAll(Tt)) {
|
|
1012
|
+
if (n += f(e.slice(t, r.index)), r[1] !== void 0) n += `<code>${f(r[1])}</code>`;
|
|
1071
1013
|
else if (r[2] !== void 0) try {
|
|
1072
|
-
n +=
|
|
1014
|
+
n += D.renderToString(r[2], { throwOnError: !1 });
|
|
1073
1015
|
} catch {
|
|
1074
|
-
n +=
|
|
1016
|
+
n += f(r[0]);
|
|
1075
1017
|
}
|
|
1076
1018
|
t = r.index + r[0].length;
|
|
1077
1019
|
}
|
|
1078
|
-
return n +=
|
|
1020
|
+
return n += f(e.slice(t)), n;
|
|
1079
1021
|
}
|
|
1080
|
-
function
|
|
1022
|
+
function Dt(e, t) {
|
|
1081
1023
|
let n = t ? "div" : "span";
|
|
1082
1024
|
try {
|
|
1083
|
-
return
|
|
1025
|
+
return D.renderToString(p(e), {
|
|
1084
1026
|
throwOnError: !1,
|
|
1085
1027
|
displayMode: t
|
|
1086
1028
|
});
|
|
@@ -1089,25 +1031,25 @@ function kt(e, t) {
|
|
|
1089
1031
|
}
|
|
1090
1032
|
}
|
|
1091
1033
|
// src/node/lib/render/vue.ts
|
|
1092
|
-
async function
|
|
1093
|
-
let r = t.title || t.label || (
|
|
1034
|
+
async function W(e, t, n) {
|
|
1035
|
+
let r = t.title || t.label || (d(n) ? ee(n, (await e.getConfig()).siteTitle) : C(n));
|
|
1094
1036
|
return {
|
|
1095
1037
|
schema: t.schema,
|
|
1096
1038
|
schemaLabel: t.schemaLabel,
|
|
1097
1039
|
label: t.label,
|
|
1098
1040
|
icon: t.icon,
|
|
1099
1041
|
frontmatter: t.header ?? {},
|
|
1100
|
-
headings:
|
|
1042
|
+
headings: kt(t.headings),
|
|
1101
1043
|
title: r,
|
|
1102
|
-
titleHtml:
|
|
1044
|
+
titleHtml: Et(r),
|
|
1103
1045
|
filepath: n,
|
|
1104
1046
|
fileMetadata: t.fileMetadata,
|
|
1105
1047
|
seoMetadata: t.seoMetadata,
|
|
1106
1048
|
excerpt: t.excerpt
|
|
1107
1049
|
};
|
|
1108
1050
|
}
|
|
1109
|
-
async function
|
|
1110
|
-
let r = await
|
|
1051
|
+
async function Ot(e, t, n) {
|
|
1052
|
+
let r = await ht(t.content), i = await W(e, t, n), a = JSON.stringify(`@typedown/pages?resource=${encodeURIComponent(n)}`);
|
|
1111
1053
|
return {
|
|
1112
1054
|
vueSrc: [
|
|
1113
1055
|
"<script>",
|
|
@@ -1119,12 +1061,12 @@ async function At(e, t, n) {
|
|
|
1119
1061
|
`import { pageData } from ${a}`,
|
|
1120
1062
|
"useRouter().route.data = pageData",
|
|
1121
1063
|
"<\/script>",
|
|
1122
|
-
`<template><div class="typedown-content">\n${
|
|
1064
|
+
`<template><div class="typedown-content">\n${At(r)}\n</div></template>`
|
|
1123
1065
|
].join("\n"),
|
|
1124
1066
|
pageData: i
|
|
1125
1067
|
};
|
|
1126
1068
|
}
|
|
1127
|
-
function
|
|
1069
|
+
function kt(e) {
|
|
1128
1070
|
let t = [], n = [];
|
|
1129
1071
|
for (let r of e) {
|
|
1130
1072
|
let e = {
|
|
@@ -1140,15 +1082,15 @@ function jt(e) {
|
|
|
1140
1082
|
}
|
|
1141
1083
|
return t;
|
|
1142
1084
|
}
|
|
1143
|
-
function
|
|
1085
|
+
function At(e) {
|
|
1144
1086
|
return e.replaceAll("{{", "{{").replaceAll("}}", "}}");
|
|
1145
1087
|
}
|
|
1146
1088
|
// src/node/plugin/vite/constants.ts
|
|
1147
|
-
var
|
|
1148
|
-
|
|
1149
|
-
var
|
|
1089
|
+
var jt = "@typedown/app", Mt = "\0@typedown/app", G = "@typedown/pages", Nt = "\0" + G;
|
|
1090
|
+
G + "";
|
|
1091
|
+
var K = "\0@typedown/pages?resource=", q = "@typedown/site-data", Pt = "\0@typedown/site-data", J = "@typedown/search-index", Ft = "\0@typedown/search-index", Y = "@typedown/theme", It = "\0@typedown/theme", X = "typedown:page-data";
|
|
1150
1092
|
// src/node/plugin/vite/virtual/utils.ts
|
|
1151
|
-
function
|
|
1093
|
+
function Z(e, t) {
|
|
1152
1094
|
let n = e.moduleGraph.getModuleById(t);
|
|
1153
1095
|
if (n) {
|
|
1154
1096
|
e.moduleGraph.invalidateModule(n);
|
|
@@ -1164,14 +1106,14 @@ function X(e, t) {
|
|
|
1164
1106
|
}
|
|
1165
1107
|
}
|
|
1166
1108
|
// src/node/plugin/vite/virtual/app.ts
|
|
1167
|
-
var
|
|
1109
|
+
var Lt = class {
|
|
1168
1110
|
mountPath;
|
|
1169
1111
|
constructor(e = "") {
|
|
1170
1112
|
this.mountPath = e;
|
|
1171
1113
|
}
|
|
1172
1114
|
async load(e) {
|
|
1173
1115
|
let t = await (await e.getTdContext()).getConfig(), n = await L(t.components, e.root);
|
|
1174
|
-
return
|
|
1116
|
+
return Me({
|
|
1175
1117
|
rootDir: t.rootDir,
|
|
1176
1118
|
mountPath: this.mountPath,
|
|
1177
1119
|
basePath: t.basePath,
|
|
@@ -1185,17 +1127,17 @@ var zt = class {
|
|
|
1185
1127
|
nav: t.nav,
|
|
1186
1128
|
userComponents: n
|
|
1187
1129
|
}, {
|
|
1188
|
-
theme:
|
|
1189
|
-
pages:
|
|
1190
|
-
siteData:
|
|
1191
|
-
searchIndex:
|
|
1192
|
-
pageDataEvent:
|
|
1130
|
+
theme: Y,
|
|
1131
|
+
pages: G,
|
|
1132
|
+
siteData: q,
|
|
1133
|
+
searchIndex: J,
|
|
1134
|
+
pageDataEvent: X
|
|
1193
1135
|
});
|
|
1194
1136
|
}
|
|
1195
1137
|
invalidate(e) {
|
|
1196
|
-
|
|
1138
|
+
Z(e, Mt);
|
|
1197
1139
|
}
|
|
1198
|
-
},
|
|
1140
|
+
}, Rt = class {
|
|
1199
1141
|
mountPath;
|
|
1200
1142
|
constructor(e = "") {
|
|
1201
1143
|
this.mountPath = e;
|
|
@@ -1208,21 +1150,21 @@ var zt = class {
|
|
|
1208
1150
|
if (e.startsWith("@typedown/pages?resource=")) return "\0" + e;
|
|
1209
1151
|
}
|
|
1210
1152
|
isPageDataModule(e) {
|
|
1211
|
-
return e.startsWith(
|
|
1153
|
+
return e.startsWith(K);
|
|
1212
1154
|
}
|
|
1213
1155
|
async loadPageData(e, t) {
|
|
1214
|
-
let n = decodeURIComponent(e.slice(
|
|
1156
|
+
let n = decodeURIComponent(e.slice(K.length)), r = await W(t, await t.getFile(n), n);
|
|
1215
1157
|
return `export const pageData = ${JSON.stringify(r)}`;
|
|
1216
1158
|
}
|
|
1217
1159
|
invalidatePageData(e, t) {
|
|
1218
|
-
|
|
1160
|
+
Z(e, K + encodeURIComponent(t));
|
|
1219
1161
|
}
|
|
1220
1162
|
sendPageData(e, t, n) {
|
|
1221
1163
|
t.getFile(n).then(async (r) => {
|
|
1222
|
-
let i = await
|
|
1164
|
+
let i = await W(t, r, n);
|
|
1223
1165
|
e.hot.send({
|
|
1224
1166
|
type: "custom",
|
|
1225
|
-
event:
|
|
1167
|
+
event: X,
|
|
1226
1168
|
data: {
|
|
1227
1169
|
filepath: n,
|
|
1228
1170
|
pageData: i
|
|
@@ -1233,62 +1175,62 @@ var zt = class {
|
|
|
1233
1175
|
});
|
|
1234
1176
|
}
|
|
1235
1177
|
invalidate(e) {
|
|
1236
|
-
|
|
1178
|
+
Z(e, Nt);
|
|
1237
1179
|
}
|
|
1238
|
-
},
|
|
1180
|
+
}, zt = class {
|
|
1239
1181
|
async load(e) {
|
|
1240
|
-
return
|
|
1182
|
+
return Ne((await (await e.getTdContext()).getConfig()).layout ?? void 0, e.root);
|
|
1241
1183
|
}
|
|
1242
1184
|
invalidate(e) {
|
|
1243
|
-
|
|
1185
|
+
Z(e, It);
|
|
1244
1186
|
}
|
|
1245
|
-
},
|
|
1187
|
+
}, Bt = "\0@typedown/site-data", Vt = {
|
|
1246
1188
|
ready: !1,
|
|
1247
1189
|
contentTree: { entries: [] },
|
|
1248
1190
|
schemas: {},
|
|
1249
1191
|
directoryListings: {}
|
|
1250
|
-
},
|
|
1192
|
+
}, Ht = class {
|
|
1251
1193
|
data;
|
|
1252
1194
|
scan(e) {
|
|
1253
|
-
let t =
|
|
1195
|
+
let t = pe("**/*.td", {
|
|
1254
1196
|
cwd: e,
|
|
1255
1197
|
exclude: (e) => e.startsWith("_")
|
|
1256
1198
|
}).map((e) => ({
|
|
1257
1199
|
filepath: e,
|
|
1258
|
-
label:
|
|
1200
|
+
label: C(e),
|
|
1259
1201
|
header: {}
|
|
1260
|
-
})), n =
|
|
1202
|
+
})), n = g(t);
|
|
1261
1203
|
this.data = {
|
|
1262
1204
|
contentTree: n,
|
|
1263
1205
|
schemas: {},
|
|
1264
|
-
directoryListings:
|
|
1206
|
+
directoryListings: h(n.entries, "")
|
|
1265
1207
|
};
|
|
1266
1208
|
}
|
|
1267
1209
|
load(e) {
|
|
1268
1210
|
let t = this.data ? {
|
|
1269
1211
|
ready: !0,
|
|
1270
1212
|
...this.data
|
|
1271
|
-
} :
|
|
1213
|
+
} : Vt;
|
|
1272
1214
|
return `export default ${JSON.stringify(t)}`;
|
|
1273
1215
|
}
|
|
1274
1216
|
clear() {
|
|
1275
1217
|
this.data = void 0;
|
|
1276
1218
|
}
|
|
1277
|
-
fetch =
|
|
1278
|
-
|
|
1219
|
+
fetch = y((e, t) => {
|
|
1220
|
+
Ut(e).then((e) => {
|
|
1279
1221
|
this.data = e, t && this.invalidate(t);
|
|
1280
1222
|
}).catch((e) => {
|
|
1281
1223
|
console.error("[typedown] Failed to fetch site data:", e instanceof Error ? e.message : e);
|
|
1282
1224
|
});
|
|
1283
1225
|
}, 200);
|
|
1284
1226
|
async fetchSync(e) {
|
|
1285
|
-
this.data = await
|
|
1227
|
+
this.data = await Ut(e);
|
|
1286
1228
|
}
|
|
1287
1229
|
invalidate(e) {
|
|
1288
|
-
|
|
1230
|
+
Z(e, Bt);
|
|
1289
1231
|
}
|
|
1290
1232
|
};
|
|
1291
|
-
async function
|
|
1233
|
+
async function Ut(e) {
|
|
1292
1234
|
let [t, n, r] = await Promise.all([
|
|
1293
1235
|
e.getConfig(),
|
|
1294
1236
|
e.listSidebar(),
|
|
@@ -1296,20 +1238,20 @@ async function Gt(e) {
|
|
|
1296
1238
|
]), i = await Promise.all(r.map(async (t) => [t, (await e.getSchema(t)).properties])), a = Object.fromEntries(i), o = n.map((e) => ({
|
|
1297
1239
|
...e,
|
|
1298
1240
|
header: {}
|
|
1299
|
-
})), s =
|
|
1241
|
+
})), s = g(o);
|
|
1300
1242
|
return {
|
|
1301
1243
|
contentTree: s,
|
|
1302
1244
|
schemas: a,
|
|
1303
|
-
directoryListings:
|
|
1245
|
+
directoryListings: h(s.entries, t.siteTitle)
|
|
1304
1246
|
};
|
|
1305
1247
|
}
|
|
1306
1248
|
// src/node/lib/search-indexer/index.ts
|
|
1307
|
-
var
|
|
1249
|
+
var Wt = class {
|
|
1308
1250
|
index;
|
|
1309
1251
|
constructor() {
|
|
1310
|
-
this.index = new
|
|
1311
|
-
fields:
|
|
1312
|
-
storeFields:
|
|
1252
|
+
this.index = new re({
|
|
1253
|
+
fields: v,
|
|
1254
|
+
storeFields: x
|
|
1313
1255
|
});
|
|
1314
1256
|
}
|
|
1315
1257
|
addAll(e) {
|
|
@@ -1327,20 +1269,20 @@ var Kt = class {
|
|
|
1327
1269
|
}
|
|
1328
1270
|
};
|
|
1329
1271
|
// src/node/lib/search-indexer/scan.ts
|
|
1330
|
-
function
|
|
1331
|
-
let n =
|
|
1272
|
+
function Gt(e, t) {
|
|
1273
|
+
let n = Yt(e), r = [];
|
|
1332
1274
|
for (let t of n) {
|
|
1333
|
-
let n =
|
|
1275
|
+
let n = Jt(e, t);
|
|
1334
1276
|
n && r.push(n);
|
|
1335
1277
|
}
|
|
1336
1278
|
t.addAll(r);
|
|
1337
1279
|
}
|
|
1338
|
-
function
|
|
1339
|
-
let i =
|
|
1340
|
-
i ? r.addPage(i) : r.discardPage(n
|
|
1280
|
+
function Kt(e, n, r) {
|
|
1281
|
+
let i = Jt(e, j(e, n));
|
|
1282
|
+
i ? r.addPage(i) : r.discardPage(t(n));
|
|
1341
1283
|
}
|
|
1342
|
-
function
|
|
1343
|
-
let n =
|
|
1284
|
+
function qt(e, t) {
|
|
1285
|
+
let n = C(e);
|
|
1344
1286
|
if (!t.startsWith("---")) return {
|
|
1345
1287
|
title: n,
|
|
1346
1288
|
body: t
|
|
@@ -1356,54 +1298,54 @@ function Yt(e, t) {
|
|
|
1356
1298
|
body: a
|
|
1357
1299
|
};
|
|
1358
1300
|
}
|
|
1359
|
-
function
|
|
1301
|
+
function Jt(e, n) {
|
|
1360
1302
|
let r;
|
|
1361
1303
|
try {
|
|
1362
|
-
r =
|
|
1304
|
+
r = me(n, "utf-8");
|
|
1363
1305
|
} catch {
|
|
1364
1306
|
return;
|
|
1365
1307
|
}
|
|
1366
1308
|
if (!r.trim()) return;
|
|
1367
|
-
let i =
|
|
1309
|
+
let i = n.slice(e.length + 1), { title: a, body: o } = qt(i, r);
|
|
1368
1310
|
return {
|
|
1369
|
-
id:
|
|
1311
|
+
id: t(i),
|
|
1370
1312
|
title: a,
|
|
1371
1313
|
text: `${a}\n${o}`
|
|
1372
1314
|
};
|
|
1373
1315
|
}
|
|
1374
|
-
function
|
|
1375
|
-
return
|
|
1316
|
+
function Yt(e) {
|
|
1317
|
+
return pe("**/*.td", {
|
|
1376
1318
|
cwd: e,
|
|
1377
1319
|
exclude: (e) => e.startsWith("_")
|
|
1378
1320
|
}).map((t) => j(e, t));
|
|
1379
1321
|
}
|
|
1380
1322
|
// src/node/plugin/vite/virtual/search-index.ts
|
|
1381
|
-
var
|
|
1382
|
-
indexer = new
|
|
1323
|
+
var Xt = "\0@typedown/search-index", Zt = class {
|
|
1324
|
+
indexer = new Wt();
|
|
1383
1325
|
load(e) {
|
|
1384
1326
|
return `export default ${JSON.stringify(this.indexer.serialize())}`;
|
|
1385
1327
|
}
|
|
1386
1328
|
index(e) {
|
|
1387
|
-
|
|
1329
|
+
Gt(e, this.indexer);
|
|
1388
1330
|
}
|
|
1389
1331
|
reindex(e, t) {
|
|
1390
|
-
|
|
1332
|
+
Kt(e, t, this.indexer);
|
|
1391
1333
|
}
|
|
1392
1334
|
invalidate(e) {
|
|
1393
|
-
|
|
1335
|
+
Z(e, Xt);
|
|
1394
1336
|
}
|
|
1395
|
-
},
|
|
1396
|
-
function
|
|
1337
|
+
}, Qt = ge(import.meta.url);
|
|
1338
|
+
function $t() {
|
|
1397
1339
|
return [{
|
|
1398
1340
|
find: "vue/server-renderer",
|
|
1399
|
-
replacement:
|
|
1341
|
+
replacement: Qt.resolve("vue/server-renderer")
|
|
1400
1342
|
}, {
|
|
1401
1343
|
find: "vue",
|
|
1402
|
-
replacement:
|
|
1344
|
+
replacement: Qt.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
1403
1345
|
}];
|
|
1404
1346
|
}
|
|
1405
1347
|
// src/node/plugin/vite/middleware/vault-assets.ts
|
|
1406
|
-
var
|
|
1348
|
+
var en = {
|
|
1407
1349
|
jpg: "image/jpeg",
|
|
1408
1350
|
jpeg: "image/jpeg",
|
|
1409
1351
|
png: "image/png",
|
|
@@ -1421,48 +1363,48 @@ var nn = {
|
|
|
1421
1363
|
woff: "font/woff",
|
|
1422
1364
|
ttf: "font/ttf"
|
|
1423
1365
|
};
|
|
1424
|
-
function
|
|
1425
|
-
return (n, r,
|
|
1426
|
-
if (!n.url || n.method !== "GET" || r.writableEnded) return
|
|
1427
|
-
let c =
|
|
1428
|
-
if (c.startsWith("/@") || c.startsWith("/node_modules")) return
|
|
1429
|
-
let l =
|
|
1430
|
-
if (
|
|
1431
|
-
let e =
|
|
1366
|
+
function tn(e, t) {
|
|
1367
|
+
return (n, r, s) => {
|
|
1368
|
+
if (!n.url || n.method !== "GET" || r.writableEnded) return s();
|
|
1369
|
+
let c = a(n.url);
|
|
1370
|
+
if (c.startsWith("/@") || c.startsWith("/node_modules")) return s();
|
|
1371
|
+
let l = i(t.basePath), u = (l && c.startsWith(l) ? c.slice(l.length) : c).replace(/^\//, ""), d = j(e.config.root, t.rootDirectory, u);
|
|
1372
|
+
if (fe(d)) try {
|
|
1373
|
+
let e = he(d);
|
|
1432
1374
|
if (e.isFile()) {
|
|
1433
|
-
let t =
|
|
1434
|
-
r.setHeader("Content-Type", t), r.setHeader("Content-Length", e.size),
|
|
1375
|
+
let t = en[o(d).slice(1).toLowerCase()] ?? "application/octet-stream";
|
|
1376
|
+
r.setHeader("Content-Type", t), r.setHeader("Content-Length", e.size), de(d).pipe(r);
|
|
1435
1377
|
return;
|
|
1436
1378
|
}
|
|
1437
1379
|
} catch {}
|
|
1438
|
-
|
|
1380
|
+
s();
|
|
1439
1381
|
};
|
|
1440
1382
|
}
|
|
1441
1383
|
// src/node/plugin/vite/middleware/virtual-html.ts
|
|
1442
|
-
function
|
|
1443
|
-
return (r,
|
|
1384
|
+
function nn(e, t, n) {
|
|
1385
|
+
return (r, o, s) => {
|
|
1444
1386
|
if (!r.url) return s();
|
|
1445
|
-
let c = a(
|
|
1387
|
+
let c = i(a(r.url)), l = i(n.basePath);
|
|
1446
1388
|
if (c.startsWith("/@") || c.startsWith("/node_modules") || !c.startsWith(l)) return s();
|
|
1447
1389
|
let u = c.slice(l.length);
|
|
1448
1390
|
if (u.startsWith("/@") || u.startsWith("/node_modules") || c.includes(".") && !c.endsWith("/index.html")) return s();
|
|
1449
1391
|
t.getConfig().then(async (t) => {
|
|
1450
|
-
let
|
|
1451
|
-
|
|
1392
|
+
let i = await e.transformIndexHtml(r.url ?? "", rn(n, t));
|
|
1393
|
+
o.setHeader("Content-Type", "text/html"), o.end(i);
|
|
1452
1394
|
}).catch(() => s());
|
|
1453
1395
|
};
|
|
1454
1396
|
}
|
|
1455
|
-
function
|
|
1456
|
-
return e.devHtml === void 0 && (e.devHtml =
|
|
1397
|
+
function rn(e, t) {
|
|
1398
|
+
return e.devHtml === void 0 && (e.devHtml = T({
|
|
1457
1399
|
title: t.siteTitle,
|
|
1458
1400
|
description: t.siteDescription,
|
|
1459
1401
|
base: "/",
|
|
1460
1402
|
ogType: "website",
|
|
1461
|
-
entryScript:
|
|
1403
|
+
entryScript: jt
|
|
1462
1404
|
})), e.devHtml;
|
|
1463
1405
|
}
|
|
1464
1406
|
// src/node/lib/prop-schema.ts
|
|
1465
|
-
function
|
|
1407
|
+
function an(e, t, n) {
|
|
1466
1408
|
let r = {};
|
|
1467
1409
|
for (let i of e) {
|
|
1468
1410
|
let e = `./${A.relative(t, i.absolutePath)}`;
|
|
@@ -1470,9 +1412,9 @@ function sn(e, t, n) {
|
|
|
1470
1412
|
let t = n.getComponentMeta(i.absolutePath), a = {}, o = !1;
|
|
1471
1413
|
for (let e of t.props) {
|
|
1472
1414
|
if (e.global) continue;
|
|
1473
|
-
let t =
|
|
1415
|
+
let t = $(e.schema);
|
|
1474
1416
|
if (t !== void 0) {
|
|
1475
|
-
let n = { schema: e.required ? t :
|
|
1417
|
+
let n = { schema: e.required ? t : l(t) };
|
|
1476
1418
|
e.description && (n.description = e.description), a[e.name] = n, o = !0;
|
|
1477
1419
|
}
|
|
1478
1420
|
}
|
|
@@ -1488,25 +1430,25 @@ function sn(e, t, n) {
|
|
|
1488
1430
|
}
|
|
1489
1431
|
return r;
|
|
1490
1432
|
}
|
|
1491
|
-
function
|
|
1433
|
+
function on(e) {
|
|
1492
1434
|
if (!e || e.length !== 1) return;
|
|
1493
|
-
let t =
|
|
1435
|
+
let t = $(e[0]);
|
|
1494
1436
|
return t === void 0 ? void 0 : {
|
|
1495
1437
|
type: "array",
|
|
1496
1438
|
items: t
|
|
1497
1439
|
};
|
|
1498
1440
|
}
|
|
1499
|
-
function
|
|
1500
|
-
if (t && 0 < Object.keys(t).length) return
|
|
1441
|
+
function sn(e, t) {
|
|
1442
|
+
if (t && 0 < Object.keys(t).length) return cn(t);
|
|
1501
1443
|
let n = /^(?:Record<string,\s*(\w+)>|\{\s*\[key:\s*string\]:\s*(\w+);\s*\})$/.exec(e);
|
|
1502
1444
|
if (!n) return;
|
|
1503
|
-
let r =
|
|
1445
|
+
let r = Q(n[1] ?? n[2]);
|
|
1504
1446
|
return r === void 0 ? void 0 : {
|
|
1505
1447
|
type: "object",
|
|
1506
1448
|
additionalProperties: r
|
|
1507
1449
|
};
|
|
1508
1450
|
}
|
|
1509
|
-
function
|
|
1451
|
+
function Q(e) {
|
|
1510
1452
|
switch (e) {
|
|
1511
1453
|
case "string": return { type: "string" };
|
|
1512
1454
|
case "number": return { type: "number" };
|
|
@@ -1520,20 +1462,20 @@ function Z(e) {
|
|
|
1520
1462
|
let t = e.replace(/^["']|["']$/g, "");
|
|
1521
1463
|
i.push({ const: t });
|
|
1522
1464
|
} else {
|
|
1523
|
-
let t =
|
|
1465
|
+
let t = Q(e);
|
|
1524
1466
|
if (t === void 0) return;
|
|
1525
1467
|
i.push(t);
|
|
1526
1468
|
}
|
|
1527
1469
|
let a = i.length === 1 ? i[0] : { oneOf: i };
|
|
1528
|
-
return n ?
|
|
1470
|
+
return n ? l(a) : a;
|
|
1529
1471
|
}
|
|
1530
1472
|
return;
|
|
1531
1473
|
}
|
|
1532
1474
|
}
|
|
1533
|
-
function
|
|
1475
|
+
function cn(e) {
|
|
1534
1476
|
let t = {}, n = [];
|
|
1535
1477
|
for (let [r, i] of Object.entries(e)) {
|
|
1536
|
-
let e =
|
|
1478
|
+
let e = $(i.schema);
|
|
1537
1479
|
if (e === void 0) return;
|
|
1538
1480
|
t[r] = e, i.required && n.push(r);
|
|
1539
1481
|
}
|
|
@@ -1544,22 +1486,22 @@ function un(e) {
|
|
|
1544
1486
|
};
|
|
1545
1487
|
return 0 < n.length && (r.required = n), r;
|
|
1546
1488
|
}
|
|
1547
|
-
function
|
|
1548
|
-
if (typeof e == "string") return
|
|
1489
|
+
function $(e) {
|
|
1490
|
+
if (typeof e == "string") return Q(e);
|
|
1549
1491
|
switch (e.kind) {
|
|
1550
|
-
case "enum": return
|
|
1551
|
-
case "array": return
|
|
1552
|
-
case "object": return
|
|
1492
|
+
case "enum": return ln(e.schema);
|
|
1493
|
+
case "array": return on(e.schema);
|
|
1494
|
+
case "object": return sn(e.type, e.schema);
|
|
1553
1495
|
case "literal": return "value" in e ? { const: e.value } : void 0;
|
|
1554
1496
|
default: return;
|
|
1555
1497
|
}
|
|
1556
1498
|
}
|
|
1557
|
-
function
|
|
1499
|
+
function ln(e) {
|
|
1558
1500
|
let t = e ?? [], n = t.some((e) => e === "undefined" || e === "null"), r = t.filter((e) => e !== "undefined" && e !== "null");
|
|
1559
1501
|
if (r.length === 0) return;
|
|
1560
1502
|
if (r.length === 1) {
|
|
1561
|
-
let e =
|
|
1562
|
-
return e === void 0 ? void 0 : n ?
|
|
1503
|
+
let e = $(r[0]);
|
|
1504
|
+
return e === void 0 ? void 0 : n ? l(e) : e;
|
|
1563
1505
|
}
|
|
1564
1506
|
if (r.every((e) => typeof e == "object" && e.kind === "literal")) {
|
|
1565
1507
|
let e = [];
|
|
@@ -1568,56 +1510,56 @@ function dn(e) {
|
|
|
1568
1510
|
e.push(t.value);
|
|
1569
1511
|
}
|
|
1570
1512
|
let t = { enum: e };
|
|
1571
|
-
return n ?
|
|
1513
|
+
return n ? l(t) : t;
|
|
1572
1514
|
}
|
|
1573
1515
|
let i = [];
|
|
1574
1516
|
for (let e of r) {
|
|
1575
|
-
let t =
|
|
1517
|
+
let t = $(e);
|
|
1576
1518
|
if (t === void 0) return;
|
|
1577
1519
|
i.push(t);
|
|
1578
1520
|
}
|
|
1579
1521
|
if (i.length === 0) return;
|
|
1580
1522
|
let a = { oneOf: i };
|
|
1581
|
-
return n ?
|
|
1523
|
+
return n ? l(a) : a;
|
|
1582
1524
|
}
|
|
1583
1525
|
// src/node/plugin/vite/subplugins/component-contract.ts
|
|
1584
|
-
var
|
|
1585
|
-
function
|
|
1526
|
+
var un = ".typedown/components.json";
|
|
1527
|
+
function dn(e) {
|
|
1586
1528
|
return {
|
|
1587
1529
|
name: "vite-plugin-typedown-component-contract",
|
|
1588
1530
|
async buildStart() {
|
|
1589
1531
|
let t = e();
|
|
1590
1532
|
if (!t) return;
|
|
1591
1533
|
let n = await L((await (await t.getTdContext()).getConfig()).components, t.root);
|
|
1592
|
-
|
|
1534
|
+
gn(t.root, n);
|
|
1593
1535
|
},
|
|
1594
1536
|
configureServer(t) {
|
|
1595
1537
|
let n = e();
|
|
1596
1538
|
n && n.getTdContext().then(async (e) => {
|
|
1597
1539
|
let r = await e.getConfig(), i = await L(r.components, n.root);
|
|
1598
|
-
|
|
1540
|
+
gn(n.root, i), fn(t, r.components, n.root);
|
|
1599
1541
|
}).catch(() => {});
|
|
1600
1542
|
}
|
|
1601
1543
|
};
|
|
1602
1544
|
}
|
|
1603
|
-
function
|
|
1545
|
+
function fn(e, t, n) {
|
|
1604
1546
|
let r = new Set(t.filter((e) => e.kind === "explicit").map((e) => N(A.resolve(n, e.source)))), i = new Set(t.filter((e) => e.kind === "dir").map((e) => N(A.resolve(n, e.path))));
|
|
1605
1547
|
for (let t of i) e.watcher.add(t);
|
|
1606
1548
|
let a = (a) => {
|
|
1607
|
-
|
|
1549
|
+
pn(a, r, i) && (e.config.logger.info("[typedown] component changed, rebuilding contract..."), L(t, n).then((e) => gn(n, e)).catch(() => {}));
|
|
1608
1550
|
};
|
|
1609
1551
|
e.watcher.on("change", a), e.watcher.on("add", a), e.watcher.on("unlink", a);
|
|
1610
1552
|
}
|
|
1611
|
-
function
|
|
1553
|
+
function pn(e, t, n) {
|
|
1612
1554
|
if (!e.endsWith(".vue")) return !1;
|
|
1613
1555
|
let r = N(e);
|
|
1614
1556
|
if (t.has(r)) return !0;
|
|
1615
1557
|
for (let e of n) if (r.startsWith(e + "/")) return !0;
|
|
1616
1558
|
return !1;
|
|
1617
1559
|
}
|
|
1618
|
-
function
|
|
1560
|
+
function mn() {
|
|
1619
1561
|
try {
|
|
1620
|
-
let e = A.dirname(
|
|
1562
|
+
let e = A.dirname(ce(import.meta.url)), t = A.resolve(e, "builtin-components.json"), n = JSON.parse(F.readFileSync(t, "utf-8"));
|
|
1621
1563
|
for (let e of Object.values(n)) if (typeof e == "object" && e && "source" in e) {
|
|
1622
1564
|
let t = e;
|
|
1623
1565
|
typeof t.source == "string" && t.source.startsWith("./") && (t.source = `typerighter/${t.source.slice(2)}`);
|
|
@@ -1627,18 +1569,18 @@ function gn() {
|
|
|
1627
1569
|
return {};
|
|
1628
1570
|
}
|
|
1629
1571
|
}
|
|
1630
|
-
var
|
|
1631
|
-
function
|
|
1632
|
-
if (!(0 < Object.keys(
|
|
1633
|
-
let n = 0 < t.length ?
|
|
1634
|
-
...
|
|
1572
|
+
var hn = mn();
|
|
1573
|
+
function gn(e, t) {
|
|
1574
|
+
if (!(0 < Object.keys(hn).length) && t.length === 0) return;
|
|
1575
|
+
let n = 0 < t.length ? an(t, e, Pe(e)) : {}, r = {
|
|
1576
|
+
...hn,
|
|
1635
1577
|
...n
|
|
1636
|
-
}, i = A.join(e,
|
|
1578
|
+
}, i = A.join(e, un);
|
|
1637
1579
|
F.mkdirSync(A.dirname(i), { recursive: !0 }), F.writeFileSync(i, JSON.stringify(r, null, 2));
|
|
1638
1580
|
}
|
|
1639
1581
|
// src/node/plugin/vite/index.ts
|
|
1640
|
-
function
|
|
1641
|
-
let n =
|
|
1582
|
+
function _n(t = {}) {
|
|
1583
|
+
let n = t.context, r, i, a, o = new Lt(t.root ?? ""), s = new zt(), l = new Rt(t.root ?? ""), u = new Ht(), d = new Zt(), f = {
|
|
1642
1584
|
devHtml: void 0,
|
|
1643
1585
|
basePath: "/",
|
|
1644
1586
|
rootDirectory: "vault"
|
|
@@ -1650,21 +1592,21 @@ function vn(e = {}) {
|
|
|
1650
1592
|
let m = {
|
|
1651
1593
|
name: "vite-plugin-typedown",
|
|
1652
1594
|
enforce: "pre",
|
|
1653
|
-
async config(
|
|
1595
|
+
async config(e) {
|
|
1654
1596
|
if (!n) {
|
|
1655
|
-
let r =
|
|
1656
|
-
n =
|
|
1597
|
+
let r = t.root ? j(e.root ?? process.cwd(), t.root) : ne(e.root ?? process.cwd());
|
|
1598
|
+
n = te(r);
|
|
1657
1599
|
}
|
|
1658
|
-
a =
|
|
1600
|
+
a = e.base ?? "/";
|
|
1659
1601
|
let r = await (await p()).getConfig();
|
|
1660
1602
|
return {
|
|
1661
|
-
base:
|
|
1603
|
+
base: e.base ?? r.basePath,
|
|
1662
1604
|
publicDir: r.publicDir,
|
|
1663
1605
|
server: {
|
|
1664
|
-
port:
|
|
1665
|
-
strictPort:
|
|
1606
|
+
port: e.server?.port ?? 8686,
|
|
1607
|
+
strictPort: e.server?.strictPort ?? !1
|
|
1666
1608
|
},
|
|
1667
|
-
resolve: { alias:
|
|
1609
|
+
resolve: { alias: $t() },
|
|
1668
1610
|
ssr: { noExternal: ["typerighter"] }
|
|
1669
1611
|
};
|
|
1670
1612
|
},
|
|
@@ -1676,26 +1618,26 @@ function vn(e = {}) {
|
|
|
1676
1618
|
let e = await p(), t = await e.getConfig(), n = j(t.rootDir);
|
|
1677
1619
|
d.index(n), await u.fetchSync(e);
|
|
1678
1620
|
let i = await e.checkVault();
|
|
1679
|
-
if (
|
|
1621
|
+
if (Sn(i.diagnostics), 0 < i.errorCount) {
|
|
1680
1622
|
let e = i.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
1681
1623
|
this.error(`Vault check failed with ${i.errorCount} error(s):\n${e.join("\n")}`);
|
|
1682
1624
|
}
|
|
1683
1625
|
},
|
|
1684
1626
|
resolveId(e) {
|
|
1685
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return
|
|
1686
|
-
if (e === "@typedown/pages") return
|
|
1687
|
-
if (e.startsWith("@typedown/pages?resource=")) return
|
|
1688
|
-
if (e === "@typedown/site-data") return
|
|
1689
|
-
if (e === "@typedown/search-index") return
|
|
1690
|
-
if (e === "@typedown/theme") return
|
|
1627
|
+
if (e === "/@typedown/app" || e === "@typedown/app") return Mt;
|
|
1628
|
+
if (e === "@typedown/pages") return Nt;
|
|
1629
|
+
if (e.startsWith("@typedown/pages?resource=")) return l.resolvePageData(e);
|
|
1630
|
+
if (e === "@typedown/site-data") return Pt;
|
|
1631
|
+
if (e === "@typedown/search-index") return Ft;
|
|
1632
|
+
if (e === "@typedown/theme") return It;
|
|
1691
1633
|
},
|
|
1692
1634
|
async load(e) {
|
|
1693
|
-
if (
|
|
1635
|
+
if (l.isPageDataModule(e)) return l.loadPageData(e, await p());
|
|
1694
1636
|
if (e !== "\0@typedown/search-index" && e !== "\0@typedown/site-data" && e !== "\0@typedown/pages" && e !== "\0@typedown/app" && e !== "\0@typedown/theme") return;
|
|
1695
1637
|
let t = await p();
|
|
1696
1638
|
if (e === "\0@typedown/search-index") return d.load(t);
|
|
1697
1639
|
if (e === "\0@typedown/site-data") return u.load(t);
|
|
1698
|
-
if (e === "\0@typedown/pages") return
|
|
1640
|
+
if (e === "\0@typedown/pages") return l.load(t);
|
|
1699
1641
|
if (e === "\0@typedown/app") return o.load(n);
|
|
1700
1642
|
if (e === "\0@typedown/theme") return s.load(n);
|
|
1701
1643
|
},
|
|
@@ -1704,11 +1646,11 @@ function vn(e = {}) {
|
|
|
1704
1646
|
let t = await p(), n = await t.getConfig(), i = j(n.rootDir);
|
|
1705
1647
|
d.index(i), u.scan(i), u.fetch(t, r), e.httpServer?.once("listening", async () => {
|
|
1706
1648
|
let e = await t.checkVault();
|
|
1707
|
-
0 < e.diagnostics.length && (console.error(""),
|
|
1649
|
+
0 < e.diagnostics.length && (console.error(""), Sn(e.diagnostics));
|
|
1708
1650
|
}), t.rpc.onConfigChanged(() => {
|
|
1709
|
-
r && (f.devHtml = void 0, u.clear(), o.invalidate(r), s.invalidate(r),
|
|
1651
|
+
r && (f.devHtml = void 0, u.clear(), o.invalidate(r), s.invalidate(r), l.invalidate(r), yn(r), u.fetch(t, r));
|
|
1710
1652
|
}), t.rpc.onComponentContractChanged(() => {
|
|
1711
|
-
r && (o.invalidate(r),
|
|
1653
|
+
r && (o.invalidate(r), yn(r));
|
|
1712
1654
|
});
|
|
1713
1655
|
function a(...e) {
|
|
1714
1656
|
r && t.getConfig().then((t) => {
|
|
@@ -1717,8 +1659,8 @@ function vn(e = {}) {
|
|
|
1717
1659
|
for (let i of e) {
|
|
1718
1660
|
let e = N(j(r.config.root, t.rootDir, i)), a = r.moduleGraph.getModulesByFile(e);
|
|
1719
1661
|
if (a?.size) {
|
|
1720
|
-
for (let e of a) r.moduleGraph.invalidateModule(e), n.push(
|
|
1721
|
-
|
|
1662
|
+
for (let e of a) r.moduleGraph.invalidateModule(e), n.push(xn(e));
|
|
1663
|
+
l.invalidatePageData(r, i);
|
|
1722
1664
|
}
|
|
1723
1665
|
}
|
|
1724
1666
|
0 < n.length && r.hot.send({
|
|
@@ -1728,46 +1670,46 @@ function vn(e = {}) {
|
|
|
1728
1670
|
}).catch(() => {});
|
|
1729
1671
|
}
|
|
1730
1672
|
t.rpc.onContentUpdated(({ filepath: e, affectedFiles: n = [] }) => {
|
|
1731
|
-
r && (d.reindex(i, e), d.invalidate(r),
|
|
1673
|
+
r && (d.reindex(i, e), d.invalidate(r), l.invalidate(r), u.fetch(t, r), a(e, ...n), l.sendPageData(r, t, e));
|
|
1732
1674
|
}), t.rpc.onContentDeleted(({ filepath: e }) => {
|
|
1733
|
-
r && (d.reindex(i, e), d.invalidate(r),
|
|
1675
|
+
r && (d.reindex(i, e), d.invalidate(r), l.invalidate(r), u.fetch(t, r), a(e));
|
|
1734
1676
|
});
|
|
1735
|
-
function
|
|
1736
|
-
r && (u.clear(),
|
|
1677
|
+
function c() {
|
|
1678
|
+
r && (u.clear(), bn(r), u.fetch(t, r));
|
|
1737
1679
|
}
|
|
1738
|
-
t.rpc.onSchemaUpdated(
|
|
1680
|
+
t.rpc.onSchemaUpdated(c), t.rpc.onSchemaDeleted(c);
|
|
1739
1681
|
let m = await t.getConfig();
|
|
1740
1682
|
f.basePath = m.basePath, f.rootDirectory = m.rootDir, t.rpc.onConfigChanged((e) => {
|
|
1741
1683
|
f.basePath = e.basePath, f.rootDirectory = e.rootDir, f.devHtml = void 0;
|
|
1742
|
-
}), e.middlewares.use(
|
|
1684
|
+
}), e.middlewares.use(tn(e, f)), e.middlewares.use(nn(e, t, f));
|
|
1743
1685
|
},
|
|
1744
|
-
async transform(
|
|
1686
|
+
async transform(t, n) {
|
|
1745
1687
|
let r = n.split("?")[0];
|
|
1746
|
-
if (!
|
|
1747
|
-
if (
|
|
1748
|
-
code: `<script>import theme from '${
|
|
1688
|
+
if (!w(r)) return;
|
|
1689
|
+
if (e(r)) return {
|
|
1690
|
+
code: `<script>import theme from '${Y}'; import { TdNotFound } from 'typerighter/client/theme-default'; export default theme.NotFound || TdNotFound; export const pageData = { frontmatter: {}, headings: [], title: '' };<\/script>`,
|
|
1749
1691
|
map: null
|
|
1750
1692
|
};
|
|
1751
|
-
let i = await p(), a = await i.getConfig(), o =
|
|
1693
|
+
let i = await p(), a = await i.getConfig(), o = c(r, a.rootDir);
|
|
1752
1694
|
try {
|
|
1753
|
-
let { vueSrc: e } = await
|
|
1695
|
+
let { vueSrc: e } = await Ot(i, await i.getFile(o), o);
|
|
1754
1696
|
return {
|
|
1755
1697
|
code: e,
|
|
1756
1698
|
map: null
|
|
1757
1699
|
};
|
|
1758
1700
|
} catch (e) {
|
|
1759
|
-
if (
|
|
1701
|
+
if (k(e)) return;
|
|
1760
1702
|
let t = e instanceof Error ? e.message : String(e);
|
|
1761
1703
|
this.error(`[typedown] Failed to transform ${o}: ${t}`);
|
|
1762
1704
|
}
|
|
1763
1705
|
},
|
|
1764
1706
|
handleHotUpdate({ file: e }) {
|
|
1765
|
-
if (
|
|
1707
|
+
if (w(e)) return [];
|
|
1766
1708
|
},
|
|
1767
1709
|
async closeBundle() {
|
|
1768
|
-
if (!
|
|
1710
|
+
if (!t.context && n) try {
|
|
1769
1711
|
let e = (await (await n.getTdContext()).getConfig()).basePath, t = e.startsWith(a) ? e.slice(a.length) : e.replace(/^\//, "");
|
|
1770
|
-
await
|
|
1712
|
+
await Le(n, {
|
|
1771
1713
|
outDir: j(i, t),
|
|
1772
1714
|
base: e
|
|
1773
1715
|
});
|
|
@@ -1775,32 +1717,32 @@ function vn(e = {}) {
|
|
|
1775
1717
|
n.dispose();
|
|
1776
1718
|
}
|
|
1777
1719
|
}
|
|
1778
|
-
}, h =
|
|
1779
|
-
include:
|
|
1720
|
+
}, h = ae({
|
|
1721
|
+
include: t.root ? RegExp(`${t.root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/.*\\.(?:vue|td)$`) : /\.(?:vue|td)$/,
|
|
1780
1722
|
template: { transformAssetUrls: !1 }
|
|
1781
1723
|
});
|
|
1782
1724
|
return [
|
|
1783
1725
|
m,
|
|
1784
|
-
|
|
1726
|
+
dn(() => n),
|
|
1785
1727
|
h,
|
|
1786
|
-
...
|
|
1728
|
+
...ie()
|
|
1787
1729
|
];
|
|
1788
1730
|
}
|
|
1789
|
-
function
|
|
1731
|
+
function vn(e) {
|
|
1790
1732
|
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
1791
1733
|
}
|
|
1792
|
-
function
|
|
1793
|
-
for (let t of
|
|
1734
|
+
function yn(e) {
|
|
1735
|
+
for (let t of vn(e)) e.moduleGraph.invalidateModule(t);
|
|
1794
1736
|
e.hot.send({ type: "full-reload" });
|
|
1795
1737
|
}
|
|
1796
|
-
function
|
|
1797
|
-
let t =
|
|
1738
|
+
function bn(e) {
|
|
1739
|
+
let t = vn(e).map((t) => (e.moduleGraph.invalidateModule(t), xn(t)));
|
|
1798
1740
|
0 < t.length && e.hot.send({
|
|
1799
1741
|
type: "update",
|
|
1800
1742
|
updates: t
|
|
1801
1743
|
});
|
|
1802
1744
|
}
|
|
1803
|
-
function
|
|
1745
|
+
function xn(e) {
|
|
1804
1746
|
return {
|
|
1805
1747
|
type: "js-update",
|
|
1806
1748
|
path: e.url,
|
|
@@ -1808,10 +1750,10 @@ function Sn(e) {
|
|
|
1808
1750
|
timestamp: Date.now()
|
|
1809
1751
|
};
|
|
1810
1752
|
}
|
|
1811
|
-
function
|
|
1753
|
+
function Sn(e) {
|
|
1812
1754
|
for (let t of e) {
|
|
1813
1755
|
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? M.red("error") : M.yellow("warn");
|
|
1814
1756
|
console.error(` ${n} ${e} ${t.message} ${M.dim(`(${t.code})`)}`);
|
|
1815
1757
|
}
|
|
1816
1758
|
}
|
|
1817
|
-
export {
|
|
1759
|
+
export { q as a, J as i, G as n, Y as o, X as r, Le as s, _n as t };
|