typerighter 0.55.0 → 0.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-Dj09xvlJ.js → app-C1ognrj1.js} +37 -37
- package/dist/{cli-qdkrcgUe.js → cli-Cfn9ef18.js} +5 -5
- package/dist/cli.js +1 -1
- package/dist/client/theme-default.js +218 -218
- package/dist/client.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{init-CqTfzJfC.js → init-DLnxbm8u.js} +1 -1
- package/dist/node/build/prerender.d.ts +2 -2
- package/dist/node/build/prerender.d.ts.map +1 -1
- package/dist/node/build/seo/feed.d.ts +1 -1
- package/dist/node/build/seo/feed.d.ts.map +1 -1
- package/dist/node/build/seo/index.d.ts +4 -4
- package/dist/node/build/seo/index.d.ts.map +1 -1
- package/dist/node/build/seo/jsonld.d.ts +15 -2
- package/dist/node/build/seo/jsonld.d.ts.map +1 -1
- package/dist/node/build/seo/page.d.ts +16 -5
- package/dist/node/build/seo/page.d.ts.map +1 -1
- package/dist/node/build/seo/sitemap.d.ts +2 -2
- package/dist/node/build/seo/sitemap.d.ts.map +1 -1
- package/dist/node/lib/html-template.d.ts +3 -0
- package/dist/node/lib/html-template.d.ts.map +1 -1
- package/dist/node/lib/render/vue.d.ts.map +1 -1
- package/dist/page-BktMady3.js +114 -0
- package/dist/prerenderWorker.js +31 -32
- package/dist/{renderMath-cPd-YSsZ.js → renderMath-CJKXI63h.js} +1 -1
- package/dist/shared/types/content.d.ts +3 -3
- package/dist/shared/types/content.d.ts.map +1 -1
- package/dist/shared/types/ssg.d.ts +3 -0
- package/dist/shared/types/ssg.d.ts.map +1 -1
- package/dist/shared/utils/format.d.ts +1 -0
- package/dist/shared/utils/format.d.ts.map +1 -1
- package/dist/shared/utils/url.d.ts +1 -0
- package/dist/shared/utils/url.d.ts.map +1 -1
- package/dist/{shared-tntT6SIH.js → shared-BK7uzYmy.js} +100 -94
- package/dist/shared.js +1 -1
- package/dist/typerighter.css +1 -1
- package/dist/{vite-C6g7N9dI.js → vite-B9tiBEhg.js} +489 -488
- package/dist/vite.js +1 -1
- package/package.json +3 -3
- package/dist/jsonld-Bb_dN3WE.js +0 -81
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { a as
|
|
5
|
-
import { t as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { build as
|
|
11
|
-
import
|
|
12
|
-
import { fileURLToPath as
|
|
13
|
-
import
|
|
14
|
-
import { Worker as
|
|
15
|
-
import
|
|
16
|
-
import { createRequire as
|
|
17
|
-
import { createChecker as
|
|
18
|
-
import { createHighlighter as
|
|
1
|
+
import { $ as e, B as t, D as n, F as r, H as i, I as a, O as o, R as s, T as c, U as l, Z as u, _ as d, b as f, c as p, d as m, et as h, g, h as _, i as v, nt as y, p as b, q as x, rt as S, v as C, x as w, y as T, z as E } from "./shared-BK7uzYmy.js";
|
|
2
|
+
import { n as D, t as O } from "./page-BktMady3.js";
|
|
3
|
+
import { t as k } from "./temml-CjI4drVW.js";
|
|
4
|
+
import { a as ee, i as te, n as ne, r as re } from "./context-CPrHBM3S.js";
|
|
5
|
+
import { t as ie } from "./es-B_QJMowB.js";
|
|
6
|
+
import A, { resolve as j } from "node:path";
|
|
7
|
+
import M from "picocolors";
|
|
8
|
+
import ae from "@tailwindcss/vite";
|
|
9
|
+
import oe from "@vitejs/plugin-vue";
|
|
10
|
+
import { build as se, normalizePath as N } from "vite";
|
|
11
|
+
import P, { readdir as ce } from "node:fs/promises";
|
|
12
|
+
import { fileURLToPath as le } from "node:url";
|
|
13
|
+
import ue from "node:os";
|
|
14
|
+
import { Worker as de } from "node:worker_threads";
|
|
15
|
+
import F, { createReadStream as fe, existsSync as pe, globSync as me, readFileSync as he, statSync as ge } from "node:fs";
|
|
16
|
+
import { createRequire as _e } from "node:module";
|
|
17
|
+
import { createChecker as ve, createCheckerByJson as ye } from "vue-component-meta";
|
|
18
|
+
import { createHighlighter as be, guessEmbeddedLanguages as xe, isSpecialLang as Se } from "shiki";
|
|
19
19
|
// src/node/lib/worker-pool/index.ts
|
|
20
|
-
var
|
|
20
|
+
var Ce = 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(ue.cpus().length / 2));
|
|
27
27
|
for (let n = 0; n < t; n++) {
|
|
28
|
-
let t = new
|
|
28
|
+
let t = new de(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 Oe = class {
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
// src/node/build/seo/sitemap.ts
|
|
65
|
-
function
|
|
66
|
-
let
|
|
65
|
+
function we(e, t, n, i) {
|
|
66
|
+
let a = n ?? "";
|
|
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 n =
|
|
71
|
-
return ` <url><loc>${n}</loc>${
|
|
70
|
+
let n = p(a + t + r(e)), o = i?.get(e);
|
|
71
|
+
return ` <url><loc>${n}</loc>${o === void 0 ? "" : `<lastmod>${v(o * 1e3)}</lastmod>`}</url>`;
|
|
72
72
|
}).join("\n")}
|
|
73
73
|
</urlset>
|
|
74
74
|
`;
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function Te(e, t) {
|
|
77
77
|
return `User-agent: *
|
|
78
78
|
Allow: /
|
|
79
79
|
|
|
@@ -81,44 +81,44 @@ Sitemap: ${e}${t}sitemap.xml
|
|
|
81
81
|
`;
|
|
82
82
|
}
|
|
83
83
|
// src/node/build/seo/feed.ts
|
|
84
|
-
function
|
|
85
|
-
let
|
|
86
|
-
let r =
|
|
84
|
+
function Ee(e, t, n, r, a, o) {
|
|
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 r = i(e.filepath), a = `${n}${t}${r}`, o = (/* @__PURE__ */ new Date(e.fileMetadata.mtimeSecs * 1e3)).toUTCString(), s = p(e.label ?? r), c = e.excerpt === void 0 ? "" : `<![CDATA[${e.excerpt}]]>`;
|
|
87
87
|
return ` <item>
|
|
88
|
-
<title>${
|
|
89
|
-
<link>${
|
|
90
|
-
<guid>${
|
|
91
|
-
<pubDate>${
|
|
92
|
-
<description>${
|
|
88
|
+
<title>${s}</title>
|
|
89
|
+
<link>${p(a)}</link>
|
|
90
|
+
<guid>${p(a)}</guid>
|
|
91
|
+
<pubDate>${o}</pubDate>
|
|
92
|
+
<description>${c}</description>
|
|
93
93
|
</item>`;
|
|
94
94
|
}).join("\n");
|
|
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>${
|
|
101
|
-
<language>${
|
|
102
|
-
<atom:link href="${
|
|
103
|
-
${
|
|
98
|
+
<title>${p(r)}</title>
|
|
99
|
+
<link>${p(n + t)}</link>
|
|
100
|
+
<description>${p(a)}</description>
|
|
101
|
+
<language>${o}</language>
|
|
102
|
+
<atom:link href="${p(n + t)}feed.xml" rel="self" type="application/rss+xml"/>
|
|
103
|
+
${s}
|
|
104
104
|
</channel>
|
|
105
105
|
</rss>
|
|
106
106
|
`;
|
|
107
107
|
}
|
|
108
108
|
// src/node/build/fonts.ts
|
|
109
|
-
function
|
|
110
|
-
let t =
|
|
109
|
+
function De(e) {
|
|
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.
|
|
118
|
-
}
|
|
119
|
-
async function
|
|
120
|
-
let r = new
|
|
121
|
-
filename:
|
|
114
|
+
var Oe = 64;
|
|
115
|
+
async function ke(e) {
|
|
116
|
+
let { clientEntry: t, cssFiles: n, fontFiles: r } = await Me(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 >= Oe ? await Ae(e, t, i) : await je(e, t, i);
|
|
118
|
+
}
|
|
119
|
+
async function Ae(e, t, n) {
|
|
120
|
+
let r = new Ce({
|
|
121
|
+
filename: A.resolve(le(import.meta.url), "../prerenderWorker.js"),
|
|
122
122
|
workerData: {
|
|
123
123
|
ssrEntryPath: e.ssrEntryPath,
|
|
124
124
|
base: e.base,
|
|
@@ -129,46 +129,45 @@ async function Fe(e, t, n) {
|
|
|
129
129
|
clientEntry: t,
|
|
130
130
|
headExtra: n
|
|
131
131
|
}
|
|
132
|
-
}), i = 0, a = e.
|
|
132
|
+
}), i = 0, a = e.pageRoutes.length;
|
|
133
133
|
try {
|
|
134
|
-
await Promise.all(e.
|
|
135
|
-
let n = await r.run(t), o =
|
|
136
|
-
await
|
|
134
|
+
await Promise.all(e.pageRoutes.map(async (t) => {
|
|
135
|
+
let n = await r.run(t), o = A.join(e.outDir, n.fileName);
|
|
136
|
+
await P.mkdir(A.dirname(o), { recursive: !0 }), await P.writeFile(o, n.html), i++, e.progress?.update(i, a);
|
|
137
137
|
}));
|
|
138
138
|
} finally {
|
|
139
139
|
await r.destroy();
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
async function
|
|
143
|
-
let
|
|
144
|
-
for (let s of e.
|
|
145
|
-
let c = await
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
title: l,
|
|
153
|
-
description: u,
|
|
142
|
+
async function je(e, t, n) {
|
|
143
|
+
let i = await (await import(e.ssrEntryPath)).createRenderer(), a = e.pageRoutes.length, o = 0;
|
|
144
|
+
for (let s of e.pageRoutes) {
|
|
145
|
+
let c = await i(s), l = O(c.pageData, s, {
|
|
146
|
+
base: e.base,
|
|
147
|
+
origin: e.origin,
|
|
148
|
+
author: e.author
|
|
149
|
+
}), u = D({
|
|
150
|
+
title: l.title,
|
|
151
|
+
description: l.description,
|
|
154
152
|
siteTitle: e.siteTitle,
|
|
155
153
|
author: e.author,
|
|
156
154
|
base: e.base,
|
|
157
155
|
origin: e.origin,
|
|
158
156
|
lang: e.lang,
|
|
159
157
|
entryScript: t,
|
|
160
|
-
canonicalUrl:
|
|
161
|
-
|
|
162
|
-
|
|
158
|
+
canonicalUrl: l.canonicalUrl,
|
|
159
|
+
ogType: l.ogType,
|
|
160
|
+
ogImagePath: l.ogImagePath,
|
|
161
|
+
jsonLdBlocks: l.jsonLdBlocks,
|
|
163
162
|
headExtra: n,
|
|
164
163
|
appContent: c.html
|
|
165
|
-
}),
|
|
166
|
-
await
|
|
164
|
+
}), d = l.isHomepage ? "index.html" : `${r(s)}.html`, f = A.join(e.outDir, d);
|
|
165
|
+
await P.mkdir(A.dirname(f), { recursive: !0 }), await P.writeFile(f, u), o++, e.progress?.update(o, a);
|
|
167
166
|
}
|
|
168
167
|
}
|
|
169
|
-
async function
|
|
170
|
-
let t =
|
|
171
|
-
for (let e of Object.values(r)) e.isEntry ? (i = e.file, e.css && a.push(...e.css)) :
|
|
168
|
+
async function Me(e) {
|
|
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)) : De(e.file) && o.push(e.file);
|
|
172
171
|
return {
|
|
173
172
|
clientEntry: i,
|
|
174
173
|
cssFiles: a,
|
|
@@ -176,32 +175,32 @@ async function Le(e) {
|
|
|
176
175
|
};
|
|
177
176
|
}
|
|
178
177
|
// src/node/lib/codegen/app-entry.ts
|
|
179
|
-
function
|
|
180
|
-
let { rootDir:
|
|
181
|
-
title:
|
|
182
|
-
description:
|
|
183
|
-
basePath:
|
|
184
|
-
origin:
|
|
185
|
-
lang:
|
|
186
|
-
repo:
|
|
187
|
-
author:
|
|
188
|
-
license:
|
|
189
|
-
rootDir:
|
|
190
|
-
nav:
|
|
178
|
+
function Ne(t, n) {
|
|
179
|
+
let { rootDir: r = ".", mountPath: i = "", userComponents: a = [] } = t, o = [i, r === "." ? "" : r].filter(Boolean).join("/"), s = a.map((e) => `import ${e.name} from ${JSON.stringify(e.absolutePath)};`).join("\n"), c = a.map((e) => `app.component(${JSON.stringify(e.name)}, ${e.name});`).join("\n"), l = JSON.stringify({
|
|
180
|
+
title: t.siteTitle,
|
|
181
|
+
description: t.siteDescription,
|
|
182
|
+
basePath: t.basePath ?? "/",
|
|
183
|
+
origin: t.origin,
|
|
184
|
+
lang: t.lang,
|
|
185
|
+
repo: t.repo,
|
|
186
|
+
author: t.author,
|
|
187
|
+
license: t.license,
|
|
188
|
+
rootDir: r,
|
|
189
|
+
nav: t.nav
|
|
191
190
|
});
|
|
192
191
|
return `
|
|
193
|
-
${[
|
|
192
|
+
${[s, "import 'typerighter/style.css';"].filter(Boolean).join("\n")}
|
|
194
193
|
import 'typerighter/fonts.css';
|
|
195
194
|
import('typerighter/math.css');
|
|
196
195
|
import { createTypedownApp } from 'typerighter/client';
|
|
197
196
|
import { TdDirectoryIndex, TdGlossaryIndex } from 'typerighter/client/theme-default';
|
|
198
197
|
import { isIndexUrl, getDirectoryFromPageUrl, getParentUrl, path } from 'typerighter/shared';
|
|
199
198
|
import { h } from 'vue';
|
|
200
|
-
import theme from '${
|
|
201
|
-
import { pages as initialPages } from '${
|
|
202
|
-
import initialSiteData from '${
|
|
199
|
+
import theme from '${n.theme}';
|
|
200
|
+
import { pages as initialPages } from '${n.pages}';
|
|
201
|
+
import initialSiteData from '${n.siteData}';
|
|
203
202
|
let pages = initialPages;
|
|
204
|
-
const contentExts = ${JSON.stringify(
|
|
203
|
+
const contentExts = ${JSON.stringify(e)};
|
|
205
204
|
|
|
206
205
|
function findPage(base) {
|
|
207
206
|
for (const ext of contentExts) {
|
|
@@ -211,7 +210,7 @@ function findPage(base) {
|
|
|
211
210
|
}
|
|
212
211
|
|
|
213
212
|
async function loadPageModule(pagePath) {
|
|
214
|
-
const loader = findPage(path.join('/', '${
|
|
213
|
+
const loader = findPage(path.join('/', '${o}', pagePath));
|
|
215
214
|
if (loader) return loader();
|
|
216
215
|
|
|
217
216
|
if (isIndexUrl(pagePath)) {
|
|
@@ -226,18 +225,18 @@ async function loadPageModule(pagePath) {
|
|
|
226
225
|
return undefined;
|
|
227
226
|
}
|
|
228
227
|
|
|
229
|
-
const { app, router, searchIndex: searchIndexRef, siteData } = await createTypedownApp(loadPageModule, theme, ${
|
|
230
|
-
${
|
|
228
|
+
const { app, router, searchIndex: searchIndexRef, siteData } = await createTypedownApp(loadPageModule, theme, ${l}, initialSiteData);
|
|
229
|
+
${c}
|
|
231
230
|
app.mount('#app');
|
|
232
231
|
|
|
233
232
|
// Load search index in the background after the app is mounted
|
|
234
|
-
import('${
|
|
233
|
+
import('${n.searchIndex}').then((m) => { searchIndexRef.value = m.default; });
|
|
235
234
|
|
|
236
235
|
// Accept HMR so modules update without a full page reload
|
|
237
236
|
if (import.meta.hot) {
|
|
238
|
-
import.meta.hot.accept('${
|
|
237
|
+
import.meta.hot.accept('${n.pages}', (m) => {
|
|
239
238
|
if (!m) return;
|
|
240
|
-
const base = path.join('/', '${
|
|
239
|
+
const base = path.join('/', '${o}', router.route.path);
|
|
241
240
|
const hadPage = !!findPage(base);
|
|
242
241
|
pages = m.pages;
|
|
243
242
|
const hasPage = !!findPage(base);
|
|
@@ -247,18 +246,18 @@ if (import.meta.hot) {
|
|
|
247
246
|
if (!hadPage && hasPage) router.go(router.route.path);
|
|
248
247
|
});
|
|
249
248
|
|
|
250
|
-
import.meta.hot.accept('${
|
|
249
|
+
import.meta.hot.accept('${n.searchIndex}', (m) => {
|
|
251
250
|
if (m) searchIndexRef.value = m.default;
|
|
252
251
|
});
|
|
253
252
|
|
|
254
|
-
import.meta.hot.accept('${
|
|
253
|
+
import.meta.hot.accept('${n.siteData}', (m) => {
|
|
255
254
|
if (m) siteData.value = m.default;
|
|
256
255
|
});
|
|
257
256
|
|
|
258
257
|
// 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('/', '${
|
|
258
|
+
import.meta.hot.on('${n.pageDataEvent}', ({ filepath, pageData }) => {
|
|
259
|
+
const eventBase = path.join('/', '${o}', path.stripExtension(filepath));
|
|
260
|
+
const routeBase = path.join('/', '${o}', router.route.path);
|
|
262
261
|
if (eventBase === routeBase) {
|
|
263
262
|
router.route.data = pageData;
|
|
264
263
|
}
|
|
@@ -267,89 +266,89 @@ if (import.meta.hot) {
|
|
|
267
266
|
`;
|
|
268
267
|
}
|
|
269
268
|
// src/node/lib/codegen/theme.ts
|
|
270
|
-
var
|
|
271
|
-
function
|
|
272
|
-
let n = e?.notFound ? `import CustomNotFound from ${JSON.stringify(t ?
|
|
269
|
+
var I = "typerighter/client/theme-default";
|
|
270
|
+
function Pe(e, t) {
|
|
271
|
+
let n = e?.notFound ? `import CustomNotFound from ${JSON.stringify(t ? A.resolve(t, e.notFound) : e.notFound)};` : "", r = e?.notFound ? ", NotFound: CustomNotFound" : "";
|
|
273
272
|
if (e?.component) {
|
|
274
|
-
let i = t ?
|
|
273
|
+
let i = t ? A.resolve(t, e.component) : e.component;
|
|
275
274
|
return [
|
|
276
275
|
`import CustomLayout from ${JSON.stringify(i)};`,
|
|
277
276
|
n,
|
|
278
277
|
`export default { Layout: CustomLayout${r} };`
|
|
279
278
|
].filter(Boolean).join("\n");
|
|
280
279
|
}
|
|
281
|
-
let
|
|
282
|
-
if (0 <
|
|
283
|
-
let e =
|
|
280
|
+
let i = Object.entries(e?.slots ?? {});
|
|
281
|
+
if (0 < i.length) {
|
|
282
|
+
let e = i.map(([e, t]) => `${JSON.stringify(x(e))}: () => h(resolveComponent(${JSON.stringify(t)}))`).join(", ");
|
|
284
283
|
return [
|
|
285
|
-
`import DefaultTheme from ${JSON.stringify(
|
|
284
|
+
`import DefaultTheme from ${JSON.stringify(I)};`,
|
|
286
285
|
"import { h, resolveComponent } from 'vue';",
|
|
287
286
|
n,
|
|
288
287
|
`export default { Layout: { render() { return h(DefaultTheme.Layout, null, { ${e} }); } }${r} };`
|
|
289
288
|
].filter(Boolean).join("\n");
|
|
290
289
|
}
|
|
291
290
|
return n ? [
|
|
292
|
-
`import DefaultTheme from ${JSON.stringify(
|
|
291
|
+
`import DefaultTheme from ${JSON.stringify(I)};`,
|
|
293
292
|
n,
|
|
294
293
|
`export default { ...DefaultTheme${r} };`
|
|
295
|
-
].join("\n") : `export { default } from ${JSON.stringify(
|
|
294
|
+
].join("\n") : `export { default } from ${JSON.stringify(I)};`;
|
|
296
295
|
}
|
|
297
296
|
// src/node/lib/components.ts
|
|
298
|
-
function
|
|
299
|
-
let t =
|
|
300
|
-
if (
|
|
301
|
-
let n =
|
|
302
|
-
return
|
|
297
|
+
function Fe(e) {
|
|
298
|
+
let t = A.join(e, "tsconfig.json");
|
|
299
|
+
if (F.existsSync(t)) return ve(t);
|
|
300
|
+
let n = Ie(e);
|
|
301
|
+
return ye(e, { compilerOptions: {
|
|
303
302
|
strict: !1,
|
|
304
303
|
jsx: "preserve",
|
|
305
304
|
jsxImportSource: "vue",
|
|
306
305
|
...n && { paths: n }
|
|
307
306
|
} });
|
|
308
307
|
}
|
|
309
|
-
async function
|
|
308
|
+
async function L(e, t) {
|
|
310
309
|
let n = [];
|
|
311
310
|
for (let r of e) if (r.kind === "dir") {
|
|
312
|
-
let e =
|
|
311
|
+
let e = A.resolve(t, r.path), i;
|
|
313
312
|
try {
|
|
314
|
-
i = await
|
|
313
|
+
i = await ce(e, { withFileTypes: !0 });
|
|
315
314
|
} catch {
|
|
316
315
|
continue;
|
|
317
316
|
}
|
|
318
317
|
for (let t of i) if (t.isFile() && t.name.endsWith(".vue")) n.push({
|
|
319
318
|
name: t.name.slice(0, -4),
|
|
320
|
-
absolutePath:
|
|
319
|
+
absolutePath: A.join(e, t.name)
|
|
321
320
|
});
|
|
322
321
|
else if (t.isDirectory()) {
|
|
323
|
-
let r =
|
|
324
|
-
|
|
322
|
+
let r = A.join(e, t.name, "index.vue");
|
|
323
|
+
F.existsSync(r) && n.push({
|
|
325
324
|
name: t.name,
|
|
326
325
|
absolutePath: r
|
|
327
326
|
});
|
|
328
327
|
}
|
|
329
328
|
} else n.push({
|
|
330
329
|
name: r.name,
|
|
331
|
-
absolutePath:
|
|
330
|
+
absolutePath: A.resolve(t, r.source)
|
|
332
331
|
});
|
|
333
332
|
return n;
|
|
334
333
|
}
|
|
335
|
-
function
|
|
334
|
+
function Ie(e) {
|
|
336
335
|
try {
|
|
337
|
-
let t =
|
|
336
|
+
let t = _e(A.join(e, "package.json")), n = A.dirname(t.resolve("vue/package.json"));
|
|
338
337
|
return {
|
|
339
338
|
vue: [n],
|
|
340
|
-
"vue/*": [
|
|
339
|
+
"vue/*": [A.join(n, "*")]
|
|
341
340
|
};
|
|
342
341
|
} catch {
|
|
343
342
|
return;
|
|
344
343
|
}
|
|
345
344
|
}
|
|
346
345
|
// src/node/lib/progress.ts
|
|
347
|
-
var
|
|
346
|
+
var R = [
|
|
348
347
|
"◐",
|
|
349
348
|
"◓",
|
|
350
349
|
"◑",
|
|
351
350
|
"◒"
|
|
352
|
-
],
|
|
351
|
+
], Le = class {
|
|
353
352
|
logger;
|
|
354
353
|
label;
|
|
355
354
|
start;
|
|
@@ -357,8 +356,8 @@ var L = [
|
|
|
357
356
|
constructor(e, t) {
|
|
358
357
|
if (this.logger = e, this.label = t, this.start = performance.now(), process.stdout.isTTY) {
|
|
359
358
|
let e = 0;
|
|
360
|
-
process.stdout.write(
|
|
361
|
-
e = (e + 1) %
|
|
359
|
+
process.stdout.write(M.cyan(`${R[0]} ${t}`)), this.spinnerInterval = setInterval(() => {
|
|
360
|
+
e = (e + 1) % R.length, process.stdout.write(`\r${M.cyan(`${R[e]} ${this.label}`)}`);
|
|
362
361
|
}, 120).unref();
|
|
363
362
|
} else this.logger.start(t);
|
|
364
363
|
}
|
|
@@ -370,59 +369,59 @@ var L = [
|
|
|
370
369
|
done(e) {
|
|
371
370
|
this.stopSpinner(), process.stdout.isTTY && process.stdout.write("\r\x1B[K");
|
|
372
371
|
let t = Math.round(performance.now() - this.start);
|
|
373
|
-
this.logger.success(`${e} (${
|
|
372
|
+
this.logger.success(`${e} (${Re(t)})`);
|
|
374
373
|
}
|
|
375
374
|
stopSpinner() {
|
|
376
375
|
this.spinnerInterval &&= (clearInterval(this.spinnerInterval), void 0);
|
|
377
376
|
}
|
|
378
377
|
};
|
|
379
|
-
function
|
|
378
|
+
function Re(e) {
|
|
380
379
|
return e < 1e3 ? `${Math.round(e)}ms` : `${(e / 1e3).toFixed(1)}s`;
|
|
381
380
|
}
|
|
382
381
|
// src/node/build/index.ts
|
|
383
|
-
async function
|
|
384
|
-
let { root: n, logger: r } = e,
|
|
385
|
-
await
|
|
382
|
+
async function ze(e, t = {}) {
|
|
383
|
+
let { root: n, logger: r } = e, a = A.resolve(n, t.outDir ?? "dist"), o = A.join(a, ".client"), s = A.join(a, ".server");
|
|
384
|
+
await P.rm(a, {
|
|
386
385
|
recursive: !0,
|
|
387
386
|
force: !0
|
|
388
387
|
});
|
|
389
|
-
let
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
]), f =
|
|
388
|
+
let c = await e.getTdContext(), [l, u, d] = await Promise.all([
|
|
389
|
+
c.getConfig(),
|
|
390
|
+
c.listFiles(),
|
|
391
|
+
c.listSidebar()
|
|
392
|
+
]), f = l.origin ?? void 0, p = l.author ?? void 0, m = l.license ?? void 0, h = l.repo ?? void 0, g = t.base ?? l.basePath ?? "/", v = w(g), y = d.map((e) => ({
|
|
394
393
|
...e,
|
|
395
394
|
header: {}
|
|
396
|
-
})), b =
|
|
397
|
-
title:
|
|
398
|
-
description:
|
|
399
|
-
basePath:
|
|
395
|
+
})), b = _(y), x = JSON.stringify({
|
|
396
|
+
title: l.siteTitle,
|
|
397
|
+
description: l.siteDescription,
|
|
398
|
+
basePath: v,
|
|
400
399
|
origin: f,
|
|
401
|
-
lang:
|
|
402
|
-
rootDir:
|
|
400
|
+
lang: l.lang,
|
|
401
|
+
rootDir: l.rootDir,
|
|
403
402
|
repo: h,
|
|
404
403
|
author: p,
|
|
405
404
|
license: m,
|
|
406
|
-
nav:
|
|
405
|
+
nav: l.nav
|
|
407
406
|
}), S = JSON.stringify({
|
|
408
407
|
ready: !0,
|
|
409
408
|
contentTree: b
|
|
410
|
-
}), C =
|
|
411
|
-
await
|
|
412
|
-
let
|
|
409
|
+
}), C = A.join(n, "node_modules", ".typerighter");
|
|
410
|
+
await P.mkdir(C, { recursive: !0 });
|
|
411
|
+
let T = A.join(C, "client-entry.js"), E = A.join(C, "ssr-entry.js"), D = A.join(C, "theme.js"), O = await L(l.components, n), k = Pe(l.layout ?? void 0, n);
|
|
413
412
|
await Promise.all([
|
|
414
|
-
|
|
415
|
-
rootDir:
|
|
416
|
-
basePath:
|
|
413
|
+
P.writeFile(T, Ne({
|
|
414
|
+
rootDir: l.rootDir,
|
|
415
|
+
basePath: v,
|
|
417
416
|
origin: f,
|
|
418
|
-
lang:
|
|
419
|
-
siteTitle:
|
|
420
|
-
siteDescription:
|
|
417
|
+
lang: l.lang,
|
|
418
|
+
siteTitle: l.siteTitle,
|
|
419
|
+
siteDescription: l.siteDescription,
|
|
421
420
|
repo: h,
|
|
422
421
|
author: p,
|
|
423
422
|
license: m,
|
|
424
|
-
nav:
|
|
425
|
-
userComponents:
|
|
423
|
+
nav: l.nav,
|
|
424
|
+
userComponents: O
|
|
426
425
|
}, {
|
|
427
426
|
theme: J,
|
|
428
427
|
pages: W,
|
|
@@ -430,115 +429,115 @@ async function Ue(e, t = {}) {
|
|
|
430
429
|
searchIndex: q,
|
|
431
430
|
pageDataEvent: Y
|
|
432
431
|
})),
|
|
433
|
-
|
|
434
|
-
rootDir:
|
|
432
|
+
P.writeFile(E, Be({
|
|
433
|
+
rootDir: l.rootDir,
|
|
435
434
|
siteConfig: x,
|
|
436
435
|
siteData: S,
|
|
437
|
-
themeModulePath:
|
|
438
|
-
userComponents:
|
|
436
|
+
themeModulePath: D,
|
|
437
|
+
userComponents: O
|
|
439
438
|
})),
|
|
440
|
-
|
|
439
|
+
P.writeFile(D, k)
|
|
441
440
|
]);
|
|
442
441
|
try {
|
|
443
|
-
let
|
|
444
|
-
await
|
|
442
|
+
let c = vn({ context: e }), m = e.createViteLogger(), h = new Le(r, "Building client bundle...");
|
|
443
|
+
await se({
|
|
445
444
|
...t.viteConfig,
|
|
446
445
|
root: n,
|
|
447
|
-
base:
|
|
448
|
-
plugins:
|
|
446
|
+
base: v,
|
|
447
|
+
plugins: c,
|
|
449
448
|
customLogger: m,
|
|
450
449
|
logLevel: "silent",
|
|
451
450
|
build: {
|
|
452
451
|
...t.viteConfig?.build,
|
|
453
|
-
outDir:
|
|
452
|
+
outDir: o,
|
|
454
453
|
manifest: !0,
|
|
455
454
|
emptyOutDir: !0,
|
|
456
455
|
rollupOptions: {
|
|
457
456
|
...t.viteConfig?.build?.rollupOptions,
|
|
458
|
-
input:
|
|
457
|
+
input: T
|
|
459
458
|
}
|
|
460
459
|
}
|
|
461
460
|
});
|
|
462
|
-
let g = await
|
|
461
|
+
let g = await P.readdir(A.join(o, "assets")).catch(() => []);
|
|
463
462
|
h.done(`Client bundle (${g.length} chunks)`);
|
|
464
|
-
let
|
|
465
|
-
await
|
|
463
|
+
let _ = new Le(r, "Building SSR bundle...");
|
|
464
|
+
await se({
|
|
466
465
|
...t.viteConfig,
|
|
467
466
|
root: n,
|
|
468
|
-
base:
|
|
469
|
-
plugins:
|
|
467
|
+
base: v,
|
|
468
|
+
plugins: c,
|
|
470
469
|
customLogger: m,
|
|
471
470
|
logLevel: "silent",
|
|
472
471
|
build: {
|
|
473
472
|
...t.viteConfig?.build,
|
|
474
|
-
outDir:
|
|
475
|
-
ssr:
|
|
473
|
+
outDir: s,
|
|
474
|
+
ssr: E,
|
|
476
475
|
emptyOutDir: !0
|
|
477
476
|
}
|
|
478
|
-
}),
|
|
477
|
+
}), _.done("SSR bundle");
|
|
479
478
|
let y = u.map((e) => {
|
|
480
|
-
let t =
|
|
479
|
+
let t = i(e);
|
|
481
480
|
return t === "index" ? "/" : `/${t}`;
|
|
482
481
|
});
|
|
483
|
-
y.push("/"),
|
|
484
|
-
let x = new
|
|
485
|
-
await
|
|
486
|
-
ssrEntryPath:
|
|
487
|
-
clientOutDir:
|
|
488
|
-
outDir:
|
|
489
|
-
base:
|
|
482
|
+
y.push("/"), He(b.entries, "", y);
|
|
483
|
+
let x = new Le(r, "Pre-rendering pages...");
|
|
484
|
+
await ke({
|
|
485
|
+
ssrEntryPath: A.join(s, "ssr-entry.js"),
|
|
486
|
+
clientOutDir: o,
|
|
487
|
+
outDir: a,
|
|
488
|
+
base: v,
|
|
490
489
|
origin: f,
|
|
491
|
-
lang:
|
|
492
|
-
|
|
493
|
-
siteTitle:
|
|
490
|
+
lang: l.lang,
|
|
491
|
+
pageRoutes: y,
|
|
492
|
+
siteTitle: l.siteTitle,
|
|
494
493
|
author: p,
|
|
495
494
|
progress: x
|
|
496
495
|
}), x.done(`Pre-rendered ${y.length} pages`);
|
|
497
496
|
let S = /* @__PURE__ */ new Map();
|
|
498
497
|
for (let e of d) {
|
|
499
|
-
let t =
|
|
500
|
-
S.set(n, e.fileMetadata.
|
|
498
|
+
let t = i(e.filepath), n = t === "index" ? "/" : `/${t}`;
|
|
499
|
+
S.set(n, e.fileMetadata.mtimeSecs);
|
|
501
500
|
}
|
|
502
|
-
let C =
|
|
503
|
-
f !== void 0 && (
|
|
504
|
-
let D =
|
|
505
|
-
await
|
|
506
|
-
let
|
|
507
|
-
await
|
|
501
|
+
let C = we(y, v, f, S), w = [P.writeFile(A.join(a, "sitemap.xml"), C)];
|
|
502
|
+
f !== void 0 && (w.push(P.writeFile(A.join(a, "robots.txt"), Te(f, v))), w.push(P.writeFile(A.join(a, "feed.xml"), Ee(d, v, f, l.siteTitle, l.siteDescription, l.lang)))), await Promise.all(w);
|
|
503
|
+
let D = A.join(o, "assets"), O = A.join(a, "assets");
|
|
504
|
+
await P.cp(D, O, { recursive: !0 }).catch(() => {}), await Ve(A.join(n, l.rootDir), a);
|
|
505
|
+
let k = A.join(n, l.publicDir);
|
|
506
|
+
await P.cp(k, a, { recursive: !0 }).catch(() => {});
|
|
508
507
|
} finally {
|
|
509
508
|
await Promise.all([
|
|
510
|
-
|
|
509
|
+
P.rm(C, {
|
|
511
510
|
recursive: !0,
|
|
512
511
|
force: !0
|
|
513
512
|
}),
|
|
514
|
-
|
|
513
|
+
P.rm(o, {
|
|
515
514
|
recursive: !0,
|
|
516
515
|
force: !0
|
|
517
516
|
}),
|
|
518
|
-
|
|
517
|
+
P.rm(s, {
|
|
519
518
|
recursive: !0,
|
|
520
519
|
force: !0
|
|
521
520
|
})
|
|
522
521
|
]);
|
|
523
522
|
}
|
|
524
|
-
r.log(`\nBuild complete. Output: ${
|
|
523
|
+
r.log(`\nBuild complete. Output: ${a}`);
|
|
525
524
|
}
|
|
526
|
-
function
|
|
527
|
-
let
|
|
528
|
-
...
|
|
529
|
-
directoryListings:
|
|
530
|
-
}), c =
|
|
525
|
+
function Be(t) {
|
|
526
|
+
let n = `/${t.rootDir}/${h}`, r = JSON.parse(t.siteConfig), i = JSON.parse(t.siteData), a = i.contentTree ?? { entries: [] }, o = g(a.entries ?? [], r.title ?? ""), s = JSON.stringify({
|
|
527
|
+
...i,
|
|
528
|
+
directoryListings: o
|
|
529
|
+
}), c = t.userComponents ?? [], l = c.map((e) => `import ${e.name} from ${JSON.stringify(e.absolutePath)};`).join("\n"), u = c.map((e) => `app.component(${JSON.stringify(e.name)}, ${e.name});`).join("\n");
|
|
531
530
|
return `
|
|
532
531
|
${[l, "import { createTypedownApp } from 'typerighter/client';"].filter(Boolean).join("\n")}
|
|
533
532
|
import { TdDirectoryIndex, TdGlossaryIndex } from 'typerighter/client/theme-default';
|
|
534
533
|
import { isIndexUrl, getDirectoryFromPageUrl } from 'typerighter/shared';
|
|
535
534
|
import { renderToString } from 'vue/server-renderer';
|
|
536
535
|
import { h } from 'vue';
|
|
537
|
-
import theme from ${JSON.stringify(
|
|
536
|
+
import theme from ${JSON.stringify(t.themeModulePath)};
|
|
538
537
|
|
|
539
|
-
const pages = import.meta.glob('${
|
|
540
|
-
const contentExts = ${JSON.stringify(
|
|
541
|
-
const siteData = ${
|
|
538
|
+
const pages = import.meta.glob('${n}', { eager: true });
|
|
539
|
+
const contentExts = ${JSON.stringify(e)};
|
|
540
|
+
const siteData = ${s};
|
|
542
541
|
|
|
543
542
|
function findPage(base) {
|
|
544
543
|
for (const ext of contentExts) {
|
|
@@ -548,7 +547,7 @@ function findPage(base) {
|
|
|
548
547
|
}
|
|
549
548
|
|
|
550
549
|
function loadPageModule(pagePath) {
|
|
551
|
-
const base = ('/${
|
|
550
|
+
const base = ('/${t.rootDir}/' + pagePath).replace(/\\/+/g, '/').replace(/\\/$/, '');
|
|
552
551
|
const page = findPage(base);
|
|
553
552
|
if (page) return Promise.resolve(page);
|
|
554
553
|
|
|
@@ -565,7 +564,7 @@ function loadPageModule(pagePath) {
|
|
|
565
564
|
}
|
|
566
565
|
|
|
567
566
|
export async function createRenderer() {
|
|
568
|
-
const { app, router } = await createTypedownApp(loadPageModule, theme, ${
|
|
567
|
+
const { app, router } = await createTypedownApp(loadPageModule, theme, ${t.siteConfig}, siteData);
|
|
569
568
|
${u}
|
|
570
569
|
return async function render(url) {
|
|
571
570
|
await router.go(url, { replace: true });
|
|
@@ -575,31 +574,31 @@ export async function createRenderer() {
|
|
|
575
574
|
}
|
|
576
575
|
`;
|
|
577
576
|
}
|
|
578
|
-
async function
|
|
579
|
-
let n = (await
|
|
577
|
+
async function Ve(e, t) {
|
|
578
|
+
let n = (await P.readdir(e, {
|
|
580
579
|
recursive: !0,
|
|
581
580
|
withFileTypes: !0
|
|
582
|
-
})).filter((e) => e.isFile() && !
|
|
583
|
-
let r =
|
|
584
|
-
return
|
|
581
|
+
})).filter((e) => e.isFile() && !E(e.name)).map(async (n) => {
|
|
582
|
+
let r = A.join(n.parentPath, n.name), i = A.relative(e, r), a = A.join(t, i);
|
|
583
|
+
return P.mkdir(A.dirname(a), { recursive: !0 }).then(() => P.copyFile(r, a));
|
|
585
584
|
});
|
|
586
585
|
await Promise.all(n);
|
|
587
586
|
}
|
|
588
|
-
function
|
|
587
|
+
function He(e, t, n) {
|
|
589
588
|
for (let r of e) {
|
|
590
589
|
if (r.kind !== "dir") continue;
|
|
591
590
|
let e = `${t}/${r.node.name}`;
|
|
592
|
-
|
|
591
|
+
d(r.node) || n.push(c(e)), He(r.node.entries, e, n);
|
|
593
592
|
}
|
|
594
593
|
}
|
|
595
594
|
// ../../node_modules/.pnpm/@shikijs+transformers@4.4.3/node_modules/@shikijs/transformers/dist/index.mjs
|
|
596
|
-
var
|
|
595
|
+
var Ue = /(\s+\/\/)/, We = /(?:\/\/|["'#]|;{1,2}|%{1,2}|--)(\s*)$/, Ge = /(?:\/\/|#|;{1,2}|%{1,2}|--)(\s*)$/, Ke = [
|
|
597
596
|
[/^(<!--)(.+)(-->)$/, !1],
|
|
598
597
|
[/^(\/\*)(.+)(\*\/)$/, !1],
|
|
599
598
|
[/^(\/\/|["'#]|;{1,2}|%{1,2}|--)(.*)$/, !0],
|
|
600
599
|
[/^(\*)(.+)$/, !0]
|
|
601
600
|
];
|
|
602
|
-
function
|
|
601
|
+
function qe(e, t, n) {
|
|
603
602
|
let r = [];
|
|
604
603
|
for (let i of e) {
|
|
605
604
|
if (n === "v3") {
|
|
@@ -609,7 +608,7 @@ function Ze(e, t, n) {
|
|
|
609
608
|
if (n.type !== "text") return e;
|
|
610
609
|
let r = t === i.children.length - 1;
|
|
611
610
|
if (!z(n.value, r)) return e;
|
|
612
|
-
let a = n.value.split(
|
|
611
|
+
let a = n.value.split(Ue);
|
|
613
612
|
if (a.length <= 1) return e;
|
|
614
613
|
let o = [a[0]];
|
|
615
614
|
for (let e = 1; e < a.length; e += 2) o.push(a[e] + (a[e + 1] || ""));
|
|
@@ -653,7 +652,7 @@ function Ze(e, t, n) {
|
|
|
653
652
|
}
|
|
654
653
|
if (c) {
|
|
655
654
|
if (t && !s && n !== 0) {
|
|
656
|
-
let t =
|
|
655
|
+
let t = Je(e[n - 1], "{") && Je(e[n + 1], "}");
|
|
657
656
|
r.push({
|
|
658
657
|
info: c,
|
|
659
658
|
line: i,
|
|
@@ -675,7 +674,7 @@ function Ze(e, t, n) {
|
|
|
675
674
|
}
|
|
676
675
|
return r;
|
|
677
676
|
}
|
|
678
|
-
function
|
|
677
|
+
function Je(e, t) {
|
|
679
678
|
if (e.type !== "element") return !1;
|
|
680
679
|
let n = e.children[0];
|
|
681
680
|
return n.type === "text" && n.value.trim() === t;
|
|
@@ -684,7 +683,7 @@ function z(e, t) {
|
|
|
684
683
|
let n = e.trimStart(), r = e.length - n.length;
|
|
685
684
|
n = n.trimEnd();
|
|
686
685
|
let i = e.length - n.length - r;
|
|
687
|
-
for (let [e, a] of
|
|
686
|
+
for (let [e, a] of Ke) {
|
|
688
687
|
if (a && !t) continue;
|
|
689
688
|
let o = e.exec(n);
|
|
690
689
|
if (o) return [
|
|
@@ -694,22 +693,22 @@ function z(e, t) {
|
|
|
694
693
|
];
|
|
695
694
|
}
|
|
696
695
|
}
|
|
697
|
-
function
|
|
698
|
-
let t = e.match(
|
|
696
|
+
function Ye(e) {
|
|
697
|
+
let t = e.match(We);
|
|
699
698
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index) : e;
|
|
700
699
|
}
|
|
701
|
-
function
|
|
702
|
-
let t = e.match(
|
|
700
|
+
function Xe(e) {
|
|
701
|
+
let t = e.match(Ge);
|
|
703
702
|
return t && t[1].trim().length === 0 ? e.slice(0, t.index).trimEnd() : e;
|
|
704
703
|
}
|
|
705
|
-
function
|
|
704
|
+
function Ze(e, t, n, r) {
|
|
706
705
|
return r ??= "v3", {
|
|
707
706
|
name: e,
|
|
708
707
|
code(e) {
|
|
709
708
|
let i = e.children.filter((e) => e.type === "element"), a = [];
|
|
710
709
|
e.data ??= {};
|
|
711
710
|
let o = e.data;
|
|
712
|
-
o._shiki_notation ??=
|
|
711
|
+
o._shiki_notation ??= qe(i, ["jsx", "tsx"].includes(this.options.lang), r);
|
|
713
712
|
let s = o._shiki_notation;
|
|
714
713
|
for (let e of s) {
|
|
715
714
|
if (e.info[1].length === 0) continue;
|
|
@@ -717,7 +716,7 @@ function tt(e, t, n, r) {
|
|
|
717
716
|
e.isLineCommentOnly && r !== "v1" && o++;
|
|
718
717
|
let s = !1;
|
|
719
718
|
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] =
|
|
719
|
+
r === "v1" ? e.info[1] = Ye(e.info[1]) : r === "v3" && (e.info[1] = Xe(e.info[1]));
|
|
721
720
|
let c = e.info[1].trim().length === 0;
|
|
722
721
|
if (c && (e.info[1] = ""), c && e.isLineCommentOnly) a.push(e.line);
|
|
723
722
|
else if (c && e.isJsxStyle) e.line.children.splice(e.line.children.indexOf(e.token) - 1, 3);
|
|
@@ -742,42 +741,42 @@ function tt(e, t, n, r) {
|
|
|
742
741
|
}
|
|
743
742
|
};
|
|
744
743
|
}
|
|
745
|
-
var
|
|
746
|
-
function
|
|
744
|
+
var Qe = /\{([\d,-]+)\}/;
|
|
745
|
+
function $e(e) {
|
|
747
746
|
if (!e) return null;
|
|
748
|
-
let t = e.match(
|
|
747
|
+
let t = e.match(Qe);
|
|
749
748
|
return t ? t[1].split(",").flatMap((e) => {
|
|
750
749
|
let t = e.split("-").map((e) => Number.parseInt(e, 10));
|
|
751
750
|
return t.length === 1 ? [t[0]] : Array.from({ length: t[1] - t[0] + 1 }, (e, n) => t[0] + n);
|
|
752
751
|
}) : null;
|
|
753
752
|
}
|
|
754
|
-
var
|
|
755
|
-
function
|
|
753
|
+
var et = Symbol("highlighted-lines");
|
|
754
|
+
function tt(e = {}) {
|
|
756
755
|
let { className: t = "highlighted", zeroIndexed: n = !1 } = e;
|
|
757
756
|
return {
|
|
758
757
|
name: "@shikijs/transformers:meta-highlight",
|
|
759
758
|
line(e, r) {
|
|
760
759
|
if (!this.options.meta?.__raw) return;
|
|
761
760
|
let i = this.meta;
|
|
762
|
-
i[
|
|
763
|
-
let a = i[
|
|
761
|
+
i[et] ??= $e(this.options.meta.__raw);
|
|
762
|
+
let a = i[et] ?? [], o = n ? r - 1 : r;
|
|
764
763
|
return a.includes(o) && this.addClassToHast(e, t), e;
|
|
765
764
|
}
|
|
766
765
|
};
|
|
767
766
|
}
|
|
768
|
-
var
|
|
769
|
-
function
|
|
770
|
-
return e.replace(
|
|
767
|
+
var nt = /[.*+?^${}()|[\]\\]/g;
|
|
768
|
+
function rt(e) {
|
|
769
|
+
return e.replace(nt, "\\$&");
|
|
771
770
|
}
|
|
772
771
|
function B(e = {}, t = "@shikijs/transformers:notation-map") {
|
|
773
772
|
let { classMap: n = {}, classActivePre: r = void 0, classActiveCode: i = void 0 } = e;
|
|
774
|
-
return
|
|
773
|
+
return Ze(t, RegExp(`#?\\s*\\[!code (${Object.keys(n).map(rt).join("|")})(:\\d+)?\\]`, "gi"), function([e, t, a = ":1"], o, s, c, l) {
|
|
775
774
|
let u = Number.parseInt(a.slice(1), 10);
|
|
776
775
|
for (let e = l; e < Math.min(l + u, c.length); e++) this.addClassToHast(c[e], n[t]);
|
|
777
776
|
return r && this.addClassToHast(this.pre, r), i && this.addClassToHast(this.code, i), !0;
|
|
778
777
|
}, e.matchAlgorithm);
|
|
779
778
|
}
|
|
780
|
-
function
|
|
779
|
+
function it(e = {}) {
|
|
781
780
|
let { classLineAdd: t = "diff add", classLineRemove: n = "diff remove", classActivePre: r = "has-diff", classActiveCode: i } = e;
|
|
782
781
|
return B({
|
|
783
782
|
classMap: {
|
|
@@ -789,7 +788,7 @@ function ct(e = {}) {
|
|
|
789
788
|
matchAlgorithm: e.matchAlgorithm
|
|
790
789
|
}, "@shikijs/transformers:notation-diff");
|
|
791
790
|
}
|
|
792
|
-
function
|
|
791
|
+
function at(e = {}) {
|
|
793
792
|
let { classMap: t = {
|
|
794
793
|
error: ["highlighted", "error"],
|
|
795
794
|
warning: ["highlighted", "warning"],
|
|
@@ -802,7 +801,7 @@ function lt(e = {}) {
|
|
|
802
801
|
matchAlgorithm: e.matchAlgorithm
|
|
803
802
|
}, "@shikijs/transformers:notation-error-level");
|
|
804
803
|
}
|
|
805
|
-
function
|
|
804
|
+
function ot(e = {}) {
|
|
806
805
|
let { classActiveLine: t = "focused", classActivePre: n = "has-focused", classActiveCode: r } = e;
|
|
807
806
|
return B({
|
|
808
807
|
classMap: { focus: t },
|
|
@@ -811,7 +810,7 @@ function ut(e = {}) {
|
|
|
811
810
|
matchAlgorithm: e.matchAlgorithm
|
|
812
811
|
}, "@shikijs/transformers:notation-focus");
|
|
813
812
|
}
|
|
814
|
-
function
|
|
813
|
+
function st(e = {}) {
|
|
815
814
|
let { classActiveLine: t = "highlighted", classActivePre: n = "has-highlighted", classActiveCode: r } = e;
|
|
816
815
|
return B({
|
|
817
816
|
classMap: {
|
|
@@ -824,41 +823,41 @@ function dt(e = {}) {
|
|
|
824
823
|
}, "@shikijs/transformers:notation-highlight");
|
|
825
824
|
}
|
|
826
825
|
// src/node/lib/render/highlight/language.ts
|
|
827
|
-
var
|
|
826
|
+
var ct = [
|
|
828
827
|
"shellscript",
|
|
829
828
|
"shell",
|
|
830
829
|
"bash",
|
|
831
830
|
"sh",
|
|
832
831
|
"zsh"
|
|
833
832
|
];
|
|
834
|
-
function
|
|
835
|
-
return
|
|
833
|
+
function lt(e) {
|
|
834
|
+
return ct.includes(e);
|
|
836
835
|
}
|
|
837
|
-
var
|
|
838
|
-
function
|
|
839
|
-
return
|
|
836
|
+
var ut = /^[a-zA-Z0-9-_]+/;
|
|
837
|
+
function dt(e) {
|
|
838
|
+
return ut.exec(e)?.[0] || "";
|
|
840
839
|
}
|
|
841
840
|
// src/node/lib/render/highlight/index.ts
|
|
842
|
-
var
|
|
841
|
+
var ft = new FinalizationRegistry((e) => {
|
|
843
842
|
e();
|
|
844
843
|
}), V = {
|
|
845
844
|
light: "github-light",
|
|
846
845
|
dark: "github-dark"
|
|
847
846
|
};
|
|
848
|
-
async function
|
|
849
|
-
let e = await
|
|
847
|
+
async function pt() {
|
|
848
|
+
let e = await be({
|
|
850
849
|
themes: [V.light, V.dark],
|
|
851
850
|
langs: []
|
|
852
851
|
}), t = [
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
852
|
+
tt(),
|
|
853
|
+
it(),
|
|
854
|
+
ot({
|
|
856
855
|
classActiveLine: "has-focus",
|
|
857
856
|
classActivePre: "has-focused-lines"
|
|
858
857
|
}),
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
858
|
+
st(),
|
|
859
|
+
at(),
|
|
860
|
+
mt(),
|
|
862
861
|
{
|
|
863
862
|
name: "typedown:add-dir",
|
|
864
863
|
pre(e) {
|
|
@@ -867,19 +866,19 @@ async function _t() {
|
|
|
867
866
|
}
|
|
868
867
|
], n = new Set(e.getLoadedLanguages());
|
|
869
868
|
async function r(r, i, a, o) {
|
|
870
|
-
let s =
|
|
869
|
+
let s = dt(i);
|
|
871
870
|
if (s) {
|
|
872
871
|
let e = i;
|
|
873
872
|
i = s.toLowerCase(), a = e.slice(i.length).replace(/(?<!=)\{/g, " {") + " " + a, a = a.trim().replace(/\s+/g, " ");
|
|
874
873
|
}
|
|
875
874
|
i ||= "txt";
|
|
876
875
|
try {
|
|
877
|
-
!
|
|
876
|
+
!Se(i) && !n.has(i) && (await e.loadLanguage(i), n.add(i));
|
|
878
877
|
} catch {
|
|
879
|
-
|
|
878
|
+
ee.warn(`\nThe language '${i}' is not loaded, falling back to 'txt' for syntax highlighting.`), i = "txt";
|
|
880
879
|
}
|
|
881
880
|
r = r.trimEnd();
|
|
882
|
-
let c =
|
|
881
|
+
let c = xe(r, i, e);
|
|
883
882
|
return await e.loadLanguage(...c), e.codeToHtml(r, {
|
|
884
883
|
lang: i,
|
|
885
884
|
transformers: [
|
|
@@ -900,7 +899,7 @@ async function _t() {
|
|
|
900
899
|
});
|
|
901
900
|
}
|
|
902
901
|
},
|
|
903
|
-
...o === void 0 ? [] : [
|
|
902
|
+
...o === void 0 ? [] : [ht(o)]
|
|
904
903
|
],
|
|
905
904
|
meta: { __raw: a },
|
|
906
905
|
themes: V,
|
|
@@ -928,13 +927,13 @@ async function _t() {
|
|
|
928
927
|
}
|
|
929
928
|
});
|
|
930
929
|
}
|
|
931
|
-
return
|
|
930
|
+
return ft.register(r, () => e.dispose()), r;
|
|
932
931
|
}
|
|
933
|
-
function
|
|
932
|
+
function mt() {
|
|
934
933
|
return {
|
|
935
934
|
name: "typedown:disable-shell-symbol-select",
|
|
936
935
|
tokens(e) {
|
|
937
|
-
if (
|
|
936
|
+
if (lt(this.options.lang)) for (let t of e) {
|
|
938
937
|
if (t.length < 2) continue;
|
|
939
938
|
let e = t[0].content.trim();
|
|
940
939
|
(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 +941,7 @@ function vt() {
|
|
|
942
941
|
}
|
|
943
942
|
};
|
|
944
943
|
}
|
|
945
|
-
function
|
|
944
|
+
function ht(e) {
|
|
946
945
|
return {
|
|
947
946
|
name: "typedown:line-numbers",
|
|
948
947
|
code(t) {
|
|
@@ -974,23 +973,23 @@ function yt(e) {
|
|
|
974
973
|
};
|
|
975
974
|
}
|
|
976
975
|
// src/node/lib/render/postprocess.ts
|
|
977
|
-
var
|
|
978
|
-
async function
|
|
979
|
-
return e = await
|
|
976
|
+
var gt;
|
|
977
|
+
async function _t(e) {
|
|
978
|
+
return e = await bt(e), e = Et(e), e;
|
|
980
979
|
}
|
|
981
|
-
function
|
|
982
|
-
return
|
|
980
|
+
function vt() {
|
|
981
|
+
return gt ||= pt(), gt;
|
|
983
982
|
}
|
|
984
|
-
var
|
|
983
|
+
var yt = /<pre class="td-code-placeholder"([^>]*)><code>([\s\S]*?)<\/code><\/pre>/g;
|
|
985
984
|
function H(e, t) {
|
|
986
985
|
return e.match(RegExp(`${t}="([^"]*)"`))?.[1];
|
|
987
986
|
}
|
|
988
|
-
async function
|
|
989
|
-
let t = await
|
|
987
|
+
async function bt(e) {
|
|
988
|
+
let t = await vt(), n = [...e.matchAll(yt)];
|
|
990
989
|
if (n.length === 0) return e;
|
|
991
990
|
let r = await Promise.all(n.map(async (e) => {
|
|
992
|
-
let n = e[1], r = H(n, "data-lang") ?? "", i = H(n, "data-meta") ?? "", a = H(n, "data-title"), o = H(n, "data-line-numbers"), s =
|
|
993
|
-
return
|
|
991
|
+
let n = e[1], r = H(n, "data-lang") ?? "", i = H(n, "data-meta") ?? "", a = H(n, "data-title"), o = H(n, "data-line-numbers"), s = m(e[2]);
|
|
992
|
+
return Ct(await t(s, r, i, o === void 0 ? void 0 : parseInt(o) || 1), r, {
|
|
994
993
|
title: a,
|
|
995
994
|
lineNumbers: o
|
|
996
995
|
});
|
|
@@ -1001,7 +1000,7 @@ async function wt(e) {
|
|
|
1001
1000
|
}
|
|
1002
1001
|
return i;
|
|
1003
1002
|
}
|
|
1004
|
-
var
|
|
1003
|
+
var xt = {
|
|
1005
1004
|
typescript: "TypeScript",
|
|
1006
1005
|
javascript: "JavaScript",
|
|
1007
1006
|
tsx: "TSX",
|
|
@@ -1049,38 +1048,38 @@ var Tt = {
|
|
|
1049
1048
|
scala: "Scala",
|
|
1050
1049
|
txt: "Text"
|
|
1051
1050
|
};
|
|
1052
|
-
function
|
|
1053
|
-
return
|
|
1051
|
+
function St(e) {
|
|
1052
|
+
return xt[e.toLowerCase()] ?? e;
|
|
1054
1053
|
}
|
|
1055
|
-
function
|
|
1054
|
+
function Ct(e, t, n) {
|
|
1056
1055
|
t ||= "txt";
|
|
1057
|
-
let r =
|
|
1056
|
+
let r = St(t), i = ["td-code-block", "language-" + t];
|
|
1058
1057
|
n.title && i.push("has-title"), n.lineNumbers !== void 0 && i.push("line-numbers-mode");
|
|
1059
1058
|
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">${
|
|
1059
|
+
return a += "<figcaption class=\"td-code-header\">", a += "<span class=\"td-code-left\">", a += `<span class="td-code-lang">${p(r)}</span>`, n.title && (a += `<span class="td-code-label">${p(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
1060
|
}
|
|
1062
|
-
var
|
|
1063
|
-
function
|
|
1064
|
-
return e = e.replace(
|
|
1061
|
+
var wt = /<span class="td-math-inline">([\s\S]*?)<\/span>/g, Tt = /<div class="td-math-block">([\s\S]*?)<\/div>/g;
|
|
1062
|
+
function Et(e) {
|
|
1063
|
+
return e = e.replace(wt, (e, t) => kt(t, !1)), e = e.replace(Tt, (e, t) => kt(t, !0)), e;
|
|
1065
1064
|
}
|
|
1066
|
-
var
|
|
1067
|
-
function
|
|
1065
|
+
var Dt = /`([^`]+)`|\$([^$]+)\$/g;
|
|
1066
|
+
function Ot(e) {
|
|
1068
1067
|
let t = 0, n = "";
|
|
1069
|
-
for (let r of e.matchAll(
|
|
1070
|
-
if (n +=
|
|
1068
|
+
for (let r of e.matchAll(Dt)) {
|
|
1069
|
+
if (n += p(e.slice(t, r.index)), r[1] !== void 0) n += `<code>${p(r[1])}</code>`;
|
|
1071
1070
|
else if (r[2] !== void 0) try {
|
|
1072
|
-
n +=
|
|
1071
|
+
n += k.renderToString(r[2], { throwOnError: !1 });
|
|
1073
1072
|
} catch {
|
|
1074
|
-
n +=
|
|
1073
|
+
n += p(r[0]);
|
|
1075
1074
|
}
|
|
1076
1075
|
t = r.index + r[0].length;
|
|
1077
1076
|
}
|
|
1078
|
-
return n +=
|
|
1077
|
+
return n += p(e.slice(t)), n;
|
|
1079
1078
|
}
|
|
1080
|
-
function
|
|
1079
|
+
function kt(e, t) {
|
|
1081
1080
|
let n = t ? "div" : "span";
|
|
1082
1081
|
try {
|
|
1083
|
-
return
|
|
1082
|
+
return k.renderToString(m(e), {
|
|
1084
1083
|
throwOnError: !1,
|
|
1085
1084
|
displayMode: t
|
|
1086
1085
|
});
|
|
@@ -1090,23 +1089,24 @@ function Nt(e, t) {
|
|
|
1090
1089
|
}
|
|
1091
1090
|
// src/node/lib/render/vue.ts
|
|
1092
1091
|
async function U(e, t, n) {
|
|
1093
|
-
let r = t.title || t.label || (
|
|
1092
|
+
let r = t.title || t.label || (f(n) ? C(n, (await e.getConfig()).siteTitle) : T(n));
|
|
1094
1093
|
return {
|
|
1095
1094
|
schema: t.schema,
|
|
1096
1095
|
schemaLabel: t.schemaLabel,
|
|
1097
1096
|
label: t.label,
|
|
1098
1097
|
icon: t.icon,
|
|
1099
1098
|
frontmatter: t.header ?? {},
|
|
1100
|
-
headings:
|
|
1099
|
+
headings: jt(t.headings),
|
|
1101
1100
|
title: r,
|
|
1102
|
-
titleHtml:
|
|
1101
|
+
titleHtml: Ot(r),
|
|
1103
1102
|
filepath: n,
|
|
1104
1103
|
fileMetadata: t.fileMetadata,
|
|
1105
|
-
seoMetadata: t.seoMetadata
|
|
1104
|
+
seoMetadata: t.seoMetadata,
|
|
1105
|
+
excerpt: t.excerpt
|
|
1106
1106
|
};
|
|
1107
1107
|
}
|
|
1108
|
-
async function
|
|
1109
|
-
let r = await
|
|
1108
|
+
async function At(e, t, n) {
|
|
1109
|
+
let r = await _t(t.content), i = await U(e, t, n), a = JSON.stringify(`@typedown/pages?resource=${encodeURIComponent(n)}`);
|
|
1110
1110
|
return {
|
|
1111
1111
|
vueSrc: [
|
|
1112
1112
|
"<script>",
|
|
@@ -1118,12 +1118,12 @@ async function Pt(e, t, n) {
|
|
|
1118
1118
|
`import { pageData } from ${a}`,
|
|
1119
1119
|
"useRouter().route.data = pageData",
|
|
1120
1120
|
"<\/script>",
|
|
1121
|
-
`<template><div class="typedown-content">\n${
|
|
1121
|
+
`<template><div class="typedown-content">\n${Mt(r)}\n</div></template>`
|
|
1122
1122
|
].join("\n"),
|
|
1123
1123
|
pageData: i
|
|
1124
1124
|
};
|
|
1125
1125
|
}
|
|
1126
|
-
function
|
|
1126
|
+
function jt(e) {
|
|
1127
1127
|
let t = [], n = [];
|
|
1128
1128
|
for (let r of e) {
|
|
1129
1129
|
let e = {
|
|
@@ -1139,13 +1139,13 @@ function Ft(e) {
|
|
|
1139
1139
|
}
|
|
1140
1140
|
return t;
|
|
1141
1141
|
}
|
|
1142
|
-
function
|
|
1142
|
+
function Mt(e) {
|
|
1143
1143
|
return e.replaceAll("{{", "{{").replaceAll("}}", "}}");
|
|
1144
1144
|
}
|
|
1145
1145
|
// src/node/plugin/vite/constants.ts
|
|
1146
|
-
var
|
|
1146
|
+
var Nt = "@typedown/app", Pt = "\0@typedown/app", W = "@typedown/pages", Ft = "\0" + W;
|
|
1147
1147
|
W + "";
|
|
1148
|
-
var G = "\0@typedown/pages?resource=", K = "@typedown/site-data",
|
|
1148
|
+
var G = "\0@typedown/pages?resource=", K = "@typedown/site-data", It = "\0@typedown/site-data", q = "@typedown/search-index", Lt = "\0@typedown/search-index", J = "@typedown/theme", Rt = "\0@typedown/theme", Y = "typedown:page-data";
|
|
1149
1149
|
// src/node/plugin/vite/virtual/utils.ts
|
|
1150
1150
|
function X(e, t) {
|
|
1151
1151
|
let n = e.moduleGraph.getModuleById(t);
|
|
@@ -1163,14 +1163,14 @@ function X(e, t) {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
}
|
|
1165
1165
|
// src/node/plugin/vite/virtual/app.ts
|
|
1166
|
-
var
|
|
1166
|
+
var zt = class {
|
|
1167
1167
|
mountPath;
|
|
1168
1168
|
constructor(e = "") {
|
|
1169
1169
|
this.mountPath = e;
|
|
1170
1170
|
}
|
|
1171
1171
|
async load(e) {
|
|
1172
|
-
let t = await (await e.getTdContext()).getConfig(), n = await
|
|
1173
|
-
return
|
|
1172
|
+
let t = await (await e.getTdContext()).getConfig(), n = await L(t.components, e.root);
|
|
1173
|
+
return Ne({
|
|
1174
1174
|
rootDir: t.rootDir,
|
|
1175
1175
|
mountPath: this.mountPath,
|
|
1176
1176
|
basePath: t.basePath,
|
|
@@ -1192,9 +1192,9 @@ var Ut = class {
|
|
|
1192
1192
|
});
|
|
1193
1193
|
}
|
|
1194
1194
|
invalidate(e) {
|
|
1195
|
-
X(e,
|
|
1195
|
+
X(e, Pt);
|
|
1196
1196
|
}
|
|
1197
|
-
},
|
|
1197
|
+
}, Bt = class {
|
|
1198
1198
|
mountPath;
|
|
1199
1199
|
constructor(e = "") {
|
|
1200
1200
|
this.mountPath = e;
|
|
@@ -1232,62 +1232,62 @@ var Ut = class {
|
|
|
1232
1232
|
});
|
|
1233
1233
|
}
|
|
1234
1234
|
invalidate(e) {
|
|
1235
|
-
X(e,
|
|
1235
|
+
X(e, Ft);
|
|
1236
1236
|
}
|
|
1237
|
-
},
|
|
1237
|
+
}, Vt = class {
|
|
1238
1238
|
async load(e) {
|
|
1239
|
-
return
|
|
1239
|
+
return Pe((await (await e.getTdContext()).getConfig()).layout ?? void 0, e.root);
|
|
1240
1240
|
}
|
|
1241
1241
|
invalidate(e) {
|
|
1242
|
-
X(e,
|
|
1242
|
+
X(e, Rt);
|
|
1243
1243
|
}
|
|
1244
|
-
},
|
|
1244
|
+
}, Ht = "\0@typedown/site-data", Ut = {
|
|
1245
1245
|
ready: !1,
|
|
1246
1246
|
contentTree: { entries: [] },
|
|
1247
1247
|
schemas: {},
|
|
1248
1248
|
directoryListings: {}
|
|
1249
|
-
},
|
|
1249
|
+
}, Wt = class {
|
|
1250
1250
|
data;
|
|
1251
1251
|
scan(e) {
|
|
1252
|
-
let t =
|
|
1252
|
+
let t = me("**/*.td", {
|
|
1253
1253
|
cwd: e,
|
|
1254
1254
|
exclude: (e) => e.startsWith("_")
|
|
1255
1255
|
}).map((e) => ({
|
|
1256
1256
|
filepath: e,
|
|
1257
|
-
label:
|
|
1257
|
+
label: T(e),
|
|
1258
1258
|
header: {}
|
|
1259
|
-
})), n =
|
|
1259
|
+
})), n = _(t);
|
|
1260
1260
|
this.data = {
|
|
1261
1261
|
contentTree: n,
|
|
1262
1262
|
schemas: {},
|
|
1263
|
-
directoryListings:
|
|
1263
|
+
directoryListings: g(n.entries, "")
|
|
1264
1264
|
};
|
|
1265
1265
|
}
|
|
1266
1266
|
load(e) {
|
|
1267
1267
|
let t = this.data ? {
|
|
1268
1268
|
ready: !0,
|
|
1269
1269
|
...this.data
|
|
1270
|
-
} :
|
|
1270
|
+
} : Ut;
|
|
1271
1271
|
return `export default ${JSON.stringify(t)}`;
|
|
1272
1272
|
}
|
|
1273
1273
|
clear() {
|
|
1274
1274
|
this.data = void 0;
|
|
1275
1275
|
}
|
|
1276
1276
|
fetch = b((e, t) => {
|
|
1277
|
-
|
|
1277
|
+
Gt(e).then((e) => {
|
|
1278
1278
|
this.data = e, t && this.invalidate(t);
|
|
1279
1279
|
}).catch((e) => {
|
|
1280
1280
|
console.error("[typedown] Failed to fetch site data:", e instanceof Error ? e.message : e);
|
|
1281
1281
|
});
|
|
1282
1282
|
}, 200);
|
|
1283
1283
|
async fetchSync(e) {
|
|
1284
|
-
this.data = await
|
|
1284
|
+
this.data = await Gt(e);
|
|
1285
1285
|
}
|
|
1286
1286
|
invalidate(e) {
|
|
1287
|
-
X(e,
|
|
1287
|
+
X(e, Ht);
|
|
1288
1288
|
}
|
|
1289
1289
|
};
|
|
1290
|
-
async function
|
|
1290
|
+
async function Gt(e) {
|
|
1291
1291
|
let [t, n, r] = await Promise.all([
|
|
1292
1292
|
e.getConfig(),
|
|
1293
1293
|
e.listSidebar(),
|
|
@@ -1295,20 +1295,20 @@ async function Yt(e) {
|
|
|
1295
1295
|
]), i = await Promise.all(r.map(async (t) => [t, (await e.getSchema(t)).properties])), a = Object.fromEntries(i), o = n.map((e) => ({
|
|
1296
1296
|
...e,
|
|
1297
1297
|
header: {}
|
|
1298
|
-
})), s =
|
|
1298
|
+
})), s = _(o);
|
|
1299
1299
|
return {
|
|
1300
1300
|
contentTree: s,
|
|
1301
1301
|
schemas: a,
|
|
1302
|
-
directoryListings:
|
|
1302
|
+
directoryListings: g(s.entries, t.siteTitle)
|
|
1303
1303
|
};
|
|
1304
1304
|
}
|
|
1305
1305
|
// src/node/lib/search-indexer/index.ts
|
|
1306
|
-
var
|
|
1306
|
+
var Kt = class {
|
|
1307
1307
|
index;
|
|
1308
1308
|
constructor() {
|
|
1309
|
-
this.index = new
|
|
1310
|
-
fields:
|
|
1311
|
-
storeFields:
|
|
1309
|
+
this.index = new ie({
|
|
1310
|
+
fields: y,
|
|
1311
|
+
storeFields: S
|
|
1312
1312
|
});
|
|
1313
1313
|
}
|
|
1314
1314
|
addAll(e) {
|
|
@@ -1326,20 +1326,20 @@ var Xt = class {
|
|
|
1326
1326
|
}
|
|
1327
1327
|
};
|
|
1328
1328
|
// src/node/lib/search-indexer/scan.ts
|
|
1329
|
-
function
|
|
1330
|
-
let n =
|
|
1329
|
+
function qt(e, t) {
|
|
1330
|
+
let n = Zt(e), r = [];
|
|
1331
1331
|
for (let t of n) {
|
|
1332
|
-
let n =
|
|
1332
|
+
let n = Xt(e, t);
|
|
1333
1333
|
n && r.push(n);
|
|
1334
1334
|
}
|
|
1335
1335
|
t.addAll(r);
|
|
1336
1336
|
}
|
|
1337
|
-
function
|
|
1338
|
-
let i =
|
|
1339
|
-
i ? r.addPage(i) : r.discardPage(t
|
|
1337
|
+
function Jt(e, t, r) {
|
|
1338
|
+
let i = Xt(e, j(e, t));
|
|
1339
|
+
i ? r.addPage(i) : r.discardPage(n(t));
|
|
1340
1340
|
}
|
|
1341
|
-
function
|
|
1342
|
-
let n =
|
|
1341
|
+
function Yt(e, t) {
|
|
1342
|
+
let n = T(e);
|
|
1343
1343
|
if (!t.startsWith("---")) return {
|
|
1344
1344
|
title: n,
|
|
1345
1345
|
body: t
|
|
@@ -1355,54 +1355,54 @@ function $t(e, t) {
|
|
|
1355
1355
|
body: a
|
|
1356
1356
|
};
|
|
1357
1357
|
}
|
|
1358
|
-
function
|
|
1358
|
+
function Xt(e, t) {
|
|
1359
1359
|
let r;
|
|
1360
1360
|
try {
|
|
1361
|
-
r =
|
|
1361
|
+
r = he(t, "utf-8");
|
|
1362
1362
|
} catch {
|
|
1363
1363
|
return;
|
|
1364
1364
|
}
|
|
1365
1365
|
if (!r.trim()) return;
|
|
1366
|
-
let i =
|
|
1366
|
+
let i = t.slice(e.length + 1), { title: a, body: o } = Yt(i, r);
|
|
1367
1367
|
return {
|
|
1368
|
-
id:
|
|
1368
|
+
id: n(i),
|
|
1369
1369
|
title: a,
|
|
1370
1370
|
text: `${a}\n${o}`
|
|
1371
1371
|
};
|
|
1372
1372
|
}
|
|
1373
|
-
function
|
|
1374
|
-
return
|
|
1373
|
+
function Zt(e) {
|
|
1374
|
+
return me("**/*.td", {
|
|
1375
1375
|
cwd: e,
|
|
1376
1376
|
exclude: (e) => e.startsWith("_")
|
|
1377
|
-
}).map((t) =>
|
|
1377
|
+
}).map((t) => j(e, t));
|
|
1378
1378
|
}
|
|
1379
1379
|
// src/node/plugin/vite/virtual/search-index.ts
|
|
1380
|
-
var
|
|
1381
|
-
indexer = new
|
|
1380
|
+
var Qt = "\0@typedown/search-index", $t = class {
|
|
1381
|
+
indexer = new Kt();
|
|
1382
1382
|
load(e) {
|
|
1383
1383
|
return `export default ${JSON.stringify(this.indexer.serialize())}`;
|
|
1384
1384
|
}
|
|
1385
1385
|
index(e) {
|
|
1386
|
-
|
|
1386
|
+
qt(e, this.indexer);
|
|
1387
1387
|
}
|
|
1388
1388
|
reindex(e, t) {
|
|
1389
|
-
|
|
1389
|
+
Jt(e, t, this.indexer);
|
|
1390
1390
|
}
|
|
1391
1391
|
invalidate(e) {
|
|
1392
|
-
X(e,
|
|
1392
|
+
X(e, Qt);
|
|
1393
1393
|
}
|
|
1394
|
-
},
|
|
1395
|
-
function
|
|
1394
|
+
}, en = _e(import.meta.url);
|
|
1395
|
+
function tn() {
|
|
1396
1396
|
return [{
|
|
1397
1397
|
find: "vue/server-renderer",
|
|
1398
|
-
replacement:
|
|
1398
|
+
replacement: en.resolve("vue/server-renderer")
|
|
1399
1399
|
}, {
|
|
1400
1400
|
find: "vue",
|
|
1401
|
-
replacement:
|
|
1401
|
+
replacement: en.resolve("vue/dist/vue.runtime.esm-bundler.js")
|
|
1402
1402
|
}];
|
|
1403
1403
|
}
|
|
1404
1404
|
// src/node/plugin/vite/middleware/vault-assets.ts
|
|
1405
|
-
var
|
|
1405
|
+
var nn = {
|
|
1406
1406
|
jpg: "image/jpeg",
|
|
1407
1407
|
jpeg: "image/jpeg",
|
|
1408
1408
|
png: "image/png",
|
|
@@ -1420,50 +1420,51 @@ var sn = {
|
|
|
1420
1420
|
woff: "font/woff",
|
|
1421
1421
|
ttf: "font/ttf"
|
|
1422
1422
|
};
|
|
1423
|
-
function
|
|
1424
|
-
return (
|
|
1425
|
-
if (!
|
|
1426
|
-
let c =
|
|
1427
|
-
if (c.startsWith("/@") || c.startsWith("/node_modules")) return
|
|
1428
|
-
let l =
|
|
1429
|
-
if (
|
|
1430
|
-
let e =
|
|
1423
|
+
function rn(e, t) {
|
|
1424
|
+
return (n, r, i) => {
|
|
1425
|
+
if (!n.url || n.method !== "GET" || r.writableEnded) return i();
|
|
1426
|
+
let c = o(n.url);
|
|
1427
|
+
if (c.startsWith("/@") || c.startsWith("/node_modules")) return i();
|
|
1428
|
+
let l = a(t.basePath), u = (l && c.startsWith(l) ? c.slice(l.length) : c).replace(/^\//, ""), d = j(e.config.root, t.rootDirectory, u);
|
|
1429
|
+
if (pe(d)) try {
|
|
1430
|
+
let e = ge(d);
|
|
1431
1431
|
if (e.isFile()) {
|
|
1432
|
-
let t =
|
|
1433
|
-
|
|
1432
|
+
let t = nn[s(d).slice(1).toLowerCase()] ?? "application/octet-stream";
|
|
1433
|
+
r.setHeader("Content-Type", t), r.setHeader("Content-Length", e.size), fe(d).pipe(r);
|
|
1434
1434
|
return;
|
|
1435
1435
|
}
|
|
1436
1436
|
} catch {}
|
|
1437
|
-
|
|
1437
|
+
i();
|
|
1438
1438
|
};
|
|
1439
1439
|
}
|
|
1440
1440
|
// src/node/plugin/vite/middleware/virtual-html.ts
|
|
1441
|
-
function
|
|
1442
|
-
return (
|
|
1443
|
-
if (!
|
|
1444
|
-
let c =
|
|
1441
|
+
function an(e, t, n) {
|
|
1442
|
+
return (r, i, s) => {
|
|
1443
|
+
if (!r.url) return s();
|
|
1444
|
+
let c = a(o(r.url)), l = a(n.basePath);
|
|
1445
1445
|
if (c.startsWith("/@") || c.startsWith("/node_modules") || !c.startsWith(l)) return s();
|
|
1446
1446
|
let u = c.slice(l.length);
|
|
1447
1447
|
if (u.startsWith("/@") || u.startsWith("/node_modules") || c.includes(".") && !c.endsWith("/index.html")) return s();
|
|
1448
|
-
|
|
1449
|
-
let
|
|
1450
|
-
|
|
1448
|
+
t.getConfig().then(async (t) => {
|
|
1449
|
+
let a = await e.transformIndexHtml(r.url ?? "", on(n, t));
|
|
1450
|
+
i.setHeader("Content-Type", "text/html"), i.end(a);
|
|
1451
1451
|
}).catch(() => s());
|
|
1452
1452
|
};
|
|
1453
1453
|
}
|
|
1454
|
-
function
|
|
1455
|
-
return e.devHtml === void 0 && (e.devHtml =
|
|
1454
|
+
function on(e, t) {
|
|
1455
|
+
return e.devHtml === void 0 && (e.devHtml = D({
|
|
1456
1456
|
title: t.siteTitle,
|
|
1457
1457
|
description: t.siteDescription,
|
|
1458
1458
|
base: "/",
|
|
1459
|
-
|
|
1459
|
+
ogType: "website",
|
|
1460
|
+
entryScript: Nt
|
|
1460
1461
|
})), e.devHtml;
|
|
1461
1462
|
}
|
|
1462
1463
|
// src/node/lib/prop-schema.ts
|
|
1463
|
-
function
|
|
1464
|
+
function sn(e, t, n) {
|
|
1464
1465
|
let r = {};
|
|
1465
1466
|
for (let i of e) {
|
|
1466
|
-
let e = `./${
|
|
1467
|
+
let e = `./${A.relative(t, i.absolutePath)}`;
|
|
1467
1468
|
try {
|
|
1468
1469
|
let t = n.getComponentMeta(i.absolutePath), a = {}, o = !1;
|
|
1469
1470
|
for (let e of t.props) {
|
|
@@ -1486,7 +1487,7 @@ function dn(e, t, n) {
|
|
|
1486
1487
|
}
|
|
1487
1488
|
return r;
|
|
1488
1489
|
}
|
|
1489
|
-
function
|
|
1490
|
+
function cn(e) {
|
|
1490
1491
|
if (!e || e.length !== 1) return;
|
|
1491
1492
|
let t = Q(e[0]);
|
|
1492
1493
|
return t === void 0 ? void 0 : {
|
|
@@ -1494,8 +1495,8 @@ function fn(e) {
|
|
|
1494
1495
|
items: t
|
|
1495
1496
|
};
|
|
1496
1497
|
}
|
|
1497
|
-
function
|
|
1498
|
-
if (t && 0 < Object.keys(t).length) return
|
|
1498
|
+
function ln(e, t) {
|
|
1499
|
+
if (t && 0 < Object.keys(t).length) return un(t);
|
|
1499
1500
|
let n = /^(?:Record<string,\s*(\w+)>|\{\s*\[key:\s*string\]:\s*(\w+);\s*\})$/.exec(e);
|
|
1500
1501
|
if (!n) return;
|
|
1501
1502
|
let r = Z(n[1] ?? n[2]);
|
|
@@ -1528,7 +1529,7 @@ function Z(e) {
|
|
|
1528
1529
|
return;
|
|
1529
1530
|
}
|
|
1530
1531
|
}
|
|
1531
|
-
function
|
|
1532
|
+
function un(e) {
|
|
1532
1533
|
let t = {}, n = [];
|
|
1533
1534
|
for (let [r, i] of Object.entries(e)) {
|
|
1534
1535
|
let e = Q(i.schema);
|
|
@@ -1545,14 +1546,14 @@ function mn(e) {
|
|
|
1545
1546
|
function Q(e) {
|
|
1546
1547
|
if (typeof e == "string") return Z(e);
|
|
1547
1548
|
switch (e.kind) {
|
|
1548
|
-
case "enum": return
|
|
1549
|
-
case "array": return
|
|
1550
|
-
case "object": return
|
|
1549
|
+
case "enum": return dn(e.schema);
|
|
1550
|
+
case "array": return cn(e.schema);
|
|
1551
|
+
case "object": return ln(e.type, e.schema);
|
|
1551
1552
|
case "literal": return "value" in e ? { const: e.value } : void 0;
|
|
1552
1553
|
default: return;
|
|
1553
1554
|
}
|
|
1554
1555
|
}
|
|
1555
|
-
function
|
|
1556
|
+
function dn(e) {
|
|
1556
1557
|
let t = e ?? [], n = t.some((e) => e === "undefined" || e === "null"), r = t.filter((e) => e !== "undefined" && e !== "null");
|
|
1557
1558
|
if (r.length === 0) return;
|
|
1558
1559
|
if (r.length === 1) {
|
|
@@ -1579,43 +1580,43 @@ function hn(e) {
|
|
|
1579
1580
|
return n ? u(a) : a;
|
|
1580
1581
|
}
|
|
1581
1582
|
// src/node/plugin/vite/subplugins/component-contract.ts
|
|
1582
|
-
var
|
|
1583
|
-
function
|
|
1583
|
+
var fn = ".typedown/components.json";
|
|
1584
|
+
function pn(e) {
|
|
1584
1585
|
return {
|
|
1585
1586
|
name: "vite-plugin-typedown-component-contract",
|
|
1586
1587
|
async buildStart() {
|
|
1587
1588
|
let t = e();
|
|
1588
1589
|
if (!t) return;
|
|
1589
|
-
let n = await
|
|
1590
|
+
let n = await L((await (await t.getTdContext()).getConfig()).components, t.root);
|
|
1590
1591
|
$(t.root, n);
|
|
1591
1592
|
},
|
|
1592
1593
|
configureServer(t) {
|
|
1593
1594
|
let n = e();
|
|
1594
1595
|
n && n.getTdContext().then(async (e) => {
|
|
1595
|
-
let r = await e.getConfig(), i = await
|
|
1596
|
-
$(n.root, i),
|
|
1596
|
+
let r = await e.getConfig(), i = await L(r.components, n.root);
|
|
1597
|
+
$(n.root, i), mn(t, r.components, n.root);
|
|
1597
1598
|
}).catch(() => {});
|
|
1598
1599
|
}
|
|
1599
1600
|
};
|
|
1600
1601
|
}
|
|
1601
|
-
function
|
|
1602
|
-
let r = new Set(t.filter((e) => e.kind === "explicit").map((e) =>
|
|
1602
|
+
function mn(e, t, n) {
|
|
1603
|
+
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))));
|
|
1603
1604
|
for (let t of i) e.watcher.add(t);
|
|
1604
1605
|
let a = (a) => {
|
|
1605
|
-
|
|
1606
|
+
hn(a, r, i) && (e.config.logger.info("[typedown] component changed, rebuilding contract..."), L(t, n).then((e) => $(n, e)).catch(() => {}));
|
|
1606
1607
|
};
|
|
1607
1608
|
e.watcher.on("change", a), e.watcher.on("add", a), e.watcher.on("unlink", a);
|
|
1608
1609
|
}
|
|
1609
|
-
function
|
|
1610
|
+
function hn(e, t, n) {
|
|
1610
1611
|
if (!e.endsWith(".vue")) return !1;
|
|
1611
|
-
let r =
|
|
1612
|
+
let r = N(e);
|
|
1612
1613
|
if (t.has(r)) return !0;
|
|
1613
1614
|
for (let e of n) if (r.startsWith(e + "/")) return !0;
|
|
1614
1615
|
return !1;
|
|
1615
1616
|
}
|
|
1616
|
-
function
|
|
1617
|
+
function gn() {
|
|
1617
1618
|
try {
|
|
1618
|
-
let e =
|
|
1619
|
+
let e = A.dirname(le(import.meta.url)), t = A.resolve(e, "builtin-components.json"), n = JSON.parse(F.readFileSync(t, "utf-8"));
|
|
1619
1620
|
for (let e of Object.values(n)) if (typeof e == "object" && e && "source" in e) {
|
|
1620
1621
|
let t = e;
|
|
1621
1622
|
typeof t.source == "string" && t.source.startsWith("./") && (t.source = `typerighter/${t.source.slice(2)}`);
|
|
@@ -1625,180 +1626,180 @@ function bn() {
|
|
|
1625
1626
|
return {};
|
|
1626
1627
|
}
|
|
1627
1628
|
}
|
|
1628
|
-
var
|
|
1629
|
+
var _n = gn();
|
|
1629
1630
|
function $(e, t) {
|
|
1630
|
-
if (!(0 < Object.keys(
|
|
1631
|
-
let n = 0 < t.length ?
|
|
1632
|
-
...
|
|
1631
|
+
if (!(0 < Object.keys(_n).length) && t.length === 0) return;
|
|
1632
|
+
let n = 0 < t.length ? sn(t, e, Fe(e)) : {}, r = {
|
|
1633
|
+
..._n,
|
|
1633
1634
|
...n
|
|
1634
|
-
}, i =
|
|
1635
|
-
|
|
1635
|
+
}, i = A.join(e, fn);
|
|
1636
|
+
F.mkdirSync(A.dirname(i), { recursive: !0 }), F.writeFileSync(i, JSON.stringify(r, null, 2));
|
|
1636
1637
|
}
|
|
1637
1638
|
// src/node/plugin/vite/index.ts
|
|
1638
|
-
function
|
|
1639
|
-
let
|
|
1639
|
+
function vn(e = {}) {
|
|
1640
|
+
let n = e.context, r, i, a, o = new zt(e.root ?? ""), s = new Vt(), c = new Bt(e.root ?? ""), u = new Wt(), d = new $t(), f = {
|
|
1640
1641
|
devHtml: void 0,
|
|
1641
1642
|
basePath: "/",
|
|
1642
1643
|
rootDirectory: "vault"
|
|
1643
1644
|
};
|
|
1644
1645
|
function p() {
|
|
1645
|
-
if (
|
|
1646
|
-
return
|
|
1646
|
+
if (n === void 0) throw Error("typedown plugin not initialized");
|
|
1647
|
+
return n.getTdContext();
|
|
1647
1648
|
}
|
|
1648
1649
|
let m = {
|
|
1649
1650
|
name: "vite-plugin-typedown",
|
|
1650
1651
|
enforce: "pre",
|
|
1651
|
-
async config(
|
|
1652
|
-
if (!
|
|
1653
|
-
let r = e.root ?
|
|
1654
|
-
|
|
1652
|
+
async config(t) {
|
|
1653
|
+
if (!n) {
|
|
1654
|
+
let r = e.root ? j(t.root ?? process.cwd(), e.root) : re(t.root ?? process.cwd());
|
|
1655
|
+
n = ne(r);
|
|
1655
1656
|
}
|
|
1656
|
-
a =
|
|
1657
|
+
a = t.base ?? "/";
|
|
1657
1658
|
let r = await (await p()).getConfig();
|
|
1658
1659
|
return {
|
|
1659
|
-
base:
|
|
1660
|
+
base: t.base ?? r.basePath,
|
|
1660
1661
|
publicDir: r.publicDir,
|
|
1661
1662
|
server: {
|
|
1662
|
-
port:
|
|
1663
|
-
strictPort:
|
|
1663
|
+
port: t.server?.port ?? 8686,
|
|
1664
|
+
strictPort: t.server?.strictPort ?? !1
|
|
1664
1665
|
},
|
|
1665
|
-
resolve: { alias:
|
|
1666
|
+
resolve: { alias: tn() },
|
|
1666
1667
|
ssr: { noExternal: ["typerighter"] }
|
|
1667
1668
|
};
|
|
1668
1669
|
},
|
|
1669
1670
|
configResolved(e) {
|
|
1670
|
-
i =
|
|
1671
|
+
i = j(e.root, e.build.outDir);
|
|
1671
1672
|
},
|
|
1672
1673
|
async buildStart() {
|
|
1673
|
-
if (
|
|
1674
|
-
let e = await p(), t = await e.getConfig(),
|
|
1675
|
-
d.index(
|
|
1674
|
+
if (r) return;
|
|
1675
|
+
let e = await p(), t = await e.getConfig(), n = j(t.rootDir);
|
|
1676
|
+
d.index(n), await u.fetchSync(e);
|
|
1676
1677
|
let i = await e.checkVault();
|
|
1677
|
-
if (
|
|
1678
|
+
if (Cn(i.diagnostics), 0 < i.errorCount) {
|
|
1678
1679
|
let e = i.diagnostics.filter((e) => e.severity === "error").map((e) => ` ${e.filepath}:${e.line}:${e.column} - ${e.message} (${e.code})`);
|
|
1679
1680
|
this.error(`Vault check failed with ${i.errorCount} error(s):\n${e.join("\n")}`);
|
|
1680
1681
|
}
|
|
1681
1682
|
},
|
|
1682
1683
|
resolveId(e) {
|
|
1683
|
-
if (e === "/@typedown/app" || e === "@typedown/app") return
|
|
1684
|
-
if (e === "@typedown/pages") return
|
|
1685
|
-
if (e.startsWith("@typedown/pages?resource=")) return
|
|
1686
|
-
if (e === "@typedown/site-data") return
|
|
1687
|
-
if (e === "@typedown/search-index") return
|
|
1688
|
-
if (e === "@typedown/theme") return
|
|
1684
|
+
if (e === "/@typedown/app" || e === "@typedown/app") return Pt;
|
|
1685
|
+
if (e === "@typedown/pages") return Ft;
|
|
1686
|
+
if (e.startsWith("@typedown/pages?resource=")) return c.resolvePageData(e);
|
|
1687
|
+
if (e === "@typedown/site-data") return It;
|
|
1688
|
+
if (e === "@typedown/search-index") return Lt;
|
|
1689
|
+
if (e === "@typedown/theme") return Rt;
|
|
1689
1690
|
},
|
|
1690
1691
|
async load(e) {
|
|
1691
|
-
if (
|
|
1692
|
+
if (c.isPageDataModule(e)) return c.loadPageData(e, await p());
|
|
1692
1693
|
if (e !== "\0@typedown/search-index" && e !== "\0@typedown/site-data" && e !== "\0@typedown/pages" && e !== "\0@typedown/app" && e !== "\0@typedown/theme") return;
|
|
1693
|
-
let
|
|
1694
|
-
if (e === "\0@typedown/search-index") return d.load(
|
|
1695
|
-
if (e === "\0@typedown/site-data") return u.load(
|
|
1696
|
-
if (e === "\0@typedown/pages") return
|
|
1697
|
-
if (e === "\0@typedown/app") return o.load(
|
|
1698
|
-
if (e === "\0@typedown/theme") return s.load(
|
|
1694
|
+
let t = await p();
|
|
1695
|
+
if (e === "\0@typedown/search-index") return d.load(t);
|
|
1696
|
+
if (e === "\0@typedown/site-data") return u.load(t);
|
|
1697
|
+
if (e === "\0@typedown/pages") return c.load(t);
|
|
1698
|
+
if (e === "\0@typedown/app") return o.load(n);
|
|
1699
|
+
if (e === "\0@typedown/theme") return s.load(n);
|
|
1699
1700
|
},
|
|
1700
1701
|
async configureServer(e) {
|
|
1701
|
-
|
|
1702
|
-
let t = await p(),
|
|
1703
|
-
d.index(i), u.scan(i), u.fetch(t,
|
|
1702
|
+
r = e;
|
|
1703
|
+
let t = await p(), n = await t.getConfig(), i = j(n.rootDir);
|
|
1704
|
+
d.index(i), u.scan(i), u.fetch(t, r), e.httpServer?.once("listening", async () => {
|
|
1704
1705
|
let e = await t.checkVault();
|
|
1705
|
-
0 < e.diagnostics.length && (console.error(""),
|
|
1706
|
+
0 < e.diagnostics.length && (console.error(""), Cn(e.diagnostics));
|
|
1706
1707
|
}), t.rpc.onConfigChanged(() => {
|
|
1707
|
-
|
|
1708
|
+
r && (f.devHtml = void 0, u.clear(), o.invalidate(r), s.invalidate(r), c.invalidate(r), bn(r), u.fetch(t, r));
|
|
1708
1709
|
}), t.rpc.onComponentContractChanged(() => {
|
|
1709
|
-
|
|
1710
|
+
r && (o.invalidate(r), bn(r));
|
|
1710
1711
|
});
|
|
1711
1712
|
function a(...e) {
|
|
1712
|
-
|
|
1713
|
-
if (!
|
|
1714
|
-
let
|
|
1713
|
+
r && t.getConfig().then((t) => {
|
|
1714
|
+
if (!r) return;
|
|
1715
|
+
let n = [];
|
|
1715
1716
|
for (let i of e) {
|
|
1716
|
-
let e =
|
|
1717
|
+
let e = N(j(r.config.root, t.rootDir, i)), a = r.moduleGraph.getModulesByFile(e);
|
|
1717
1718
|
if (a?.size) {
|
|
1718
|
-
for (let e of a)
|
|
1719
|
-
|
|
1719
|
+
for (let e of a) r.moduleGraph.invalidateModule(e), n.push(Sn(e));
|
|
1720
|
+
c.invalidatePageData(r, i);
|
|
1720
1721
|
}
|
|
1721
1722
|
}
|
|
1722
|
-
0 <
|
|
1723
|
+
0 < n.length && r.hot.send({
|
|
1723
1724
|
type: "update",
|
|
1724
|
-
updates:
|
|
1725
|
+
updates: n
|
|
1725
1726
|
});
|
|
1726
1727
|
}).catch(() => {});
|
|
1727
1728
|
}
|
|
1728
|
-
t.rpc.onContentUpdated(({ filepath: e, affectedFiles:
|
|
1729
|
-
|
|
1729
|
+
t.rpc.onContentUpdated(({ filepath: e, affectedFiles: n = [] }) => {
|
|
1730
|
+
r && (d.reindex(i, e), d.invalidate(r), c.invalidate(r), u.fetch(t, r), a(e, ...n), c.sendPageData(r, t, e));
|
|
1730
1731
|
}), t.rpc.onContentDeleted(({ filepath: e }) => {
|
|
1731
|
-
|
|
1732
|
+
r && (d.reindex(i, e), d.invalidate(r), c.invalidate(r), u.fetch(t, r), a(e));
|
|
1732
1733
|
});
|
|
1733
|
-
function
|
|
1734
|
-
|
|
1734
|
+
function l() {
|
|
1735
|
+
r && (u.clear(), xn(r), u.fetch(t, r));
|
|
1735
1736
|
}
|
|
1736
|
-
t.rpc.onSchemaUpdated(
|
|
1737
|
+
t.rpc.onSchemaUpdated(l), t.rpc.onSchemaDeleted(l);
|
|
1737
1738
|
let m = await t.getConfig();
|
|
1738
1739
|
f.basePath = m.basePath, f.rootDirectory = m.rootDir, t.rpc.onConfigChanged((e) => {
|
|
1739
1740
|
f.basePath = e.basePath, f.rootDirectory = e.rootDir, f.devHtml = void 0;
|
|
1740
|
-
}), e.middlewares.use(
|
|
1741
|
+
}), e.middlewares.use(rn(e, f)), e.middlewares.use(an(e, t, f));
|
|
1741
1742
|
},
|
|
1742
|
-
async transform(e,
|
|
1743
|
-
let
|
|
1744
|
-
if (!
|
|
1745
|
-
if (
|
|
1743
|
+
async transform(e, n) {
|
|
1744
|
+
let r = n.split("?")[0];
|
|
1745
|
+
if (!E(r)) return;
|
|
1746
|
+
if (t(r)) return {
|
|
1746
1747
|
code: `<script>import theme from '${J}'; import { TdNotFound } from 'typerighter/client/theme-default'; export default theme.NotFound || TdNotFound; export const pageData = { frontmatter: {}, headings: [], title: '' };<\/script>`,
|
|
1747
1748
|
map: null
|
|
1748
1749
|
};
|
|
1749
|
-
let i = await p(), a = await i.getConfig(), o = r
|
|
1750
|
+
let i = await p(), a = await i.getConfig(), o = l(r, a.rootDir);
|
|
1750
1751
|
try {
|
|
1751
|
-
let { vueSrc: e } = await
|
|
1752
|
+
let { vueSrc: e } = await At(i, await i.getFile(o), o);
|
|
1752
1753
|
return {
|
|
1753
1754
|
code: e,
|
|
1754
1755
|
map: null
|
|
1755
1756
|
};
|
|
1756
1757
|
} catch (e) {
|
|
1757
|
-
if (
|
|
1758
|
+
if (te(e)) return;
|
|
1758
1759
|
let t = e instanceof Error ? e.message : String(e);
|
|
1759
1760
|
this.error(`[typedown] Failed to transform ${o}: ${t}`);
|
|
1760
1761
|
}
|
|
1761
1762
|
},
|
|
1762
1763
|
handleHotUpdate({ file: e }) {
|
|
1763
|
-
if (
|
|
1764
|
+
if (E(e)) return [];
|
|
1764
1765
|
},
|
|
1765
1766
|
async closeBundle() {
|
|
1766
|
-
if (!e.context &&
|
|
1767
|
-
let e = (await (await
|
|
1768
|
-
await
|
|
1769
|
-
outDir:
|
|
1767
|
+
if (!e.context && n) try {
|
|
1768
|
+
let e = (await (await n.getTdContext()).getConfig()).basePath, t = e.startsWith(a) ? e.slice(a.length) : e.replace(/^\//, "");
|
|
1769
|
+
await ze(n, {
|
|
1770
|
+
outDir: j(i, t),
|
|
1770
1771
|
base: e
|
|
1771
1772
|
});
|
|
1772
1773
|
} finally {
|
|
1773
|
-
|
|
1774
|
+
n.dispose();
|
|
1774
1775
|
}
|
|
1775
1776
|
}
|
|
1776
|
-
}, h =
|
|
1777
|
+
}, h = oe({
|
|
1777
1778
|
include: e.root ? RegExp(`${e.root.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}/.*\\.(?:vue|td)$`) : /\.(?:vue|td)$/,
|
|
1778
1779
|
template: { transformAssetUrls: !1 }
|
|
1779
1780
|
});
|
|
1780
1781
|
return [
|
|
1781
1782
|
m,
|
|
1782
|
-
|
|
1783
|
+
pn(() => n),
|
|
1783
1784
|
h,
|
|
1784
|
-
...
|
|
1785
|
+
...ae()
|
|
1785
1786
|
];
|
|
1786
1787
|
}
|
|
1787
|
-
function
|
|
1788
|
+
function yn(e) {
|
|
1788
1789
|
return [...e.moduleGraph.idToModuleMap.entries()].filter(([e]) => e.endsWith(".td")).map(([, e]) => e);
|
|
1789
1790
|
}
|
|
1790
|
-
function
|
|
1791
|
-
for (let t of
|
|
1791
|
+
function bn(e) {
|
|
1792
|
+
for (let t of yn(e)) e.moduleGraph.invalidateModule(t);
|
|
1792
1793
|
e.hot.send({ type: "full-reload" });
|
|
1793
1794
|
}
|
|
1794
|
-
function
|
|
1795
|
-
let t =
|
|
1795
|
+
function xn(e) {
|
|
1796
|
+
let t = yn(e).map((t) => (e.moduleGraph.invalidateModule(t), Sn(t)));
|
|
1796
1797
|
0 < t.length && e.hot.send({
|
|
1797
1798
|
type: "update",
|
|
1798
1799
|
updates: t
|
|
1799
1800
|
});
|
|
1800
1801
|
}
|
|
1801
|
-
function
|
|
1802
|
+
function Sn(e) {
|
|
1802
1803
|
return {
|
|
1803
1804
|
type: "js-update",
|
|
1804
1805
|
path: e.url,
|
|
@@ -1806,10 +1807,10 @@ function En(e) {
|
|
|
1806
1807
|
timestamp: Date.now()
|
|
1807
1808
|
};
|
|
1808
1809
|
}
|
|
1809
|
-
function
|
|
1810
|
+
function Cn(e) {
|
|
1810
1811
|
for (let t of e) {
|
|
1811
|
-
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ?
|
|
1812
|
-
console.error(` ${n} ${e} ${t.message} ${
|
|
1812
|
+
let e = `${t.filepath}:${t.line}:${t.column}`, n = t.severity === "error" ? M.red("error") : M.yellow("warn");
|
|
1813
|
+
console.error(` ${n} ${e} ${t.message} ${M.dim(`(${t.code})`)}`);
|
|
1813
1814
|
}
|
|
1814
1815
|
}
|
|
1815
|
-
export { K as a, q as i, W as n, J as o, Y as r,
|
|
1816
|
+
export { K as a, q as i, W as n, J as o, Y as r, ze as s, vn as t };
|